From d5c3fa3c9d99c22a4b98ab6e68462255830cdd46 Mon Sep 17 00:00:00 2001 From: David Perry Date: Wed, 15 Feb 2017 09:40:40 -0500 Subject: [PATCH 001/677] Revert "Authorize.net: Allow settings to be passed for CIM purchases" This reverts commit b4de7a7b6892db2a605890fbeebea186e76d0657. Closes #2339 --- CHANGELOG | 1 + .../billing/gateways/authorize_net.rb | 1 - test/unit/gateways/authorize_net_test.rb | 15 --------------- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 24ab9f1f460..84c52b3c534 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * PayU LATAM: Count pending refunds as succeeded [curiousepic] #2336 * Stripe: Remove idempotency key from verify [shasum] #2335 * CardStream: Add additional of currencies [shasum] #2337 +* Revert "Authorize.net: Allow settings to be passed for CIM purchases" [curiousepic] #2339 == Version 1.63.0 (February 2, 2017) * Authorize.net: Add #unstore support [jimryan] #2293 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index c9e937098ec..0b7871f669e 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -250,7 +250,6 @@ def add_cim_auth_purchase(xml, transaction_type, amount, payment, options) xml.send(transaction_type) do xml.amount(amount(amount)) add_payment_source(xml, payment) - add_settings(xml, payment, options) add_invoice(xml, options) end end diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 0fa604f6e74..72594dff7bb 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -643,21 +643,6 @@ def test_duplicate_window end.respond_with(successful_purchase_response) end - def test_settings_for_cim_purchase - stub_comms do - @store = @gateway.store(@credit_card, @options) - assert_success @store - end.respond_with(successful_store_response) - - stub_comms do - test_options = {email_customer: true, duplicate_window: 0} - @gateway.purchase(@amount, @store.authorization, test_options) - end.check_request do |_endpoint, data, _headers| - assert_equal settings_from_doc(parse(data))["duplicateWindow"], "0" - assert_equal settings_from_doc(parse(data))["emailCustomer"], "true" - end.respond_with(successful_purchase_using_stored_card_response) - end - def test_duplicate_window_class_attribute_deprecated @gateway.class.duplicate_window = 0 assert_deprecation_warning("Using the duplicate_window class_attribute is deprecated. Use the transaction options hash instead.") do From 2d2484ea17d0da1ef48e39c5fbd02fbce7c1423f Mon Sep 17 00:00:00 2001 From: David Santoso Date: Tue, 13 Dec 2016 13:48:12 -0500 Subject: [PATCH 002/677] Digitzs: Add gateway --- CHANGELOG | 1 + .../billing/gateways/digitzs.rb | 292 ++++++++++++++++++ test/fixtures.yml | 6 + test/remote/gateways/remote_digitzs_test.rb | 133 ++++++++ test/unit/gateways/digitzs_test.rb | 269 ++++++++++++++++ 5 files changed, 701 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/digitzs.rb create mode 100644 test/remote/gateways/remote_digitzs_test.rb create mode 100644 test/unit/gateways/digitzs_test.rb diff --git a/CHANGELOG b/CHANGELOG index 84c52b3c534..40e072cc70b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * Stripe: Remove idempotency key from verify [shasum] #2335 * CardStream: Add additional of currencies [shasum] #2337 * Revert "Authorize.net: Allow settings to be passed for CIM purchases" [curiousepic] #2339 +* Digitzs: Add gateway [davidsantoso] == Version 1.63.0 (February 2, 2017) * Authorize.net: Add #unstore support [jimryan] #2293 diff --git a/lib/active_merchant/billing/gateways/digitzs.rb b/lib/active_merchant/billing/gateways/digitzs.rb new file mode 100644 index 00000000000..834de7842ba --- /dev/null +++ b/lib/active_merchant/billing/gateways/digitzs.rb @@ -0,0 +1,292 @@ +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class DigitzsGateway < Gateway + include Empty + + self.test_url = 'https://beta.digitzsapi.com/sandbox' + self.live_url = 'https://beta.digitzsapi.com/v3' + + self.supported_countries = ['US'] + self.default_currency = 'USD' + self.supported_cardtypes = [:visa, :master, :american_express, :discover] + self.money_format = :cents + + self.homepage_url = 'https://digitzs.com' + self.display_name = 'Digitzs' + + def initialize(options={}) + requires!(options, :app_key, :api_key, :merchant_id) + super + end + + def purchase(money, payment, options={}) + MultiResponse.run do |r| + r.process { commit("auth/token", app_token_request(options)) } + r.process { commit('payments', purchase_request(money, payment, options), options.merge({ app_token: app_token_from(r) })) } + end + end + + def refund(money, authorization, options={}) + MultiResponse.run do |r| + r.process { commit("auth/token", app_token_request(options)) } + r.process { commit('payments', refund_request(money, authorization, options), options.merge({ app_token: app_token_from(r) })) } + end + end + + def store(payment, options = {}) + MultiResponse.run do |r| + r.process { commit("auth/token", app_token_request(options)) } + options.merge!({ app_token: app_token_from(r) }) + + if options[:customer_id].present? + customer_id = check_customer_exists(options) + + if customer_id + r.process { add_credit_card_to_customer(payment, options) } + else + r.process { add_customer_with_credit_card(payment, options) } + end + else + r.process { add_customer_with_credit_card(payment, options) } + end + end + end + + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((Authorization: Bearer ).+), '\1[FILTERED]'). + gsub(%r((X-Api-Key: )\w+), '\1[FILTERED]'). + gsub(%r((\"id\\\":\\\").+), '\1[FILTERED]'). + gsub(%r((\"appKey\\\":\\\").+), '\1[FILTERED]'). + gsub(%r((\"appToken\\\":\\\").+), '\1[FILTERED]'). + gsub(%r((\"code\\\":\\\")\d+), '\1[FILTERED]'). + gsub(%r((\"number\\\":\\\")\d+), '\1[FILTERED]') + end + + private + + def new_post + { + data: { + attributes: {} + } + } + end + + def add_split(post, options) + return unless options[:payment_type] == "card_split" || options[:payment_type] == "token_split" + + post[:data][:attributes][:split] = { + merchantId: options[:split_merchant_id], + amount: amount(options[:split_amount]) + } + end + + def add_payment(post, payment, options) + if payment.is_a? String + customer_id, token = split_authorization(payment) + post[:data][:attributes][:token] = { + customerId: customer_id, + tokenId: token + } + else + post[:data][:attributes][:card] = { + type: payment.brand, + holder: payment.name, + number: payment.number, + expiry: expdate(payment), + code: payment.verification_value + } + end + end + + def add_transaction(post, money, options) + post[:data][:attributes][:transaction] = { + amount: amount(money), + currency: (options[:currency] || currency(money)), + invoice: options[:order_id] || generate_unique_id + } + end + + def add_address(post, options) + if address = options[:billing_address] || options[:address] + post[:data][:attributes][:billingAddress] = { + line1: address[:address1] || "", + line2: address[:address2] || "", + city: address[:city] || "", + state: address[:state] || "", + zip: address[:zip] || "", + country: address["country"] || "USA" + } + end + end + + def app_token_request(options) + post = new_post + post[:data][:type] = "auth" + post[:data][:attributes] = { appKey: @options[:app_key] } + + post + end + + def purchase_request(money, payment, options) + post = new_post + post[:data][:type] = "payments" + post[:data][:attributes][:merchantId] = @options[:merchant_id] + post[:data][:attributes][:paymentType] = determine_payment_type(payment, options) + add_split(post, options) + add_payment(post, payment, options) + add_transaction(post, money, options) + add_address(post, options) + + post + end + + def refund_request(money, authorization, options) + post = new_post + post[:data][:type] = "payments" + post[:data][:attributes][:merchantId] = @options[:merchant_id] + post[:data][:attributes][:paymentType] = "cardRefund" + post[:data][:attributes][:originalTransaction] = {id: authorization} + add_transaction(post, money, options) + + post + end + + def create_customer_request(payment, options) + post = new_post + post[:data][:type] = "customers" + post[:data][:attributes] = { + merchantId: @options[:merchant_id], + name: payment.name, + externalId: "#{SecureRandom.hex(16)}" + } + + post + end + + def create_token_request(payment, options) + post = new_post + post[:data][:type] = "tokens" + post[:data][:attributes] = { + tokenType: "card", + customerId: options[:customer_id], + label: "Credit Card", + } + add_payment(post, payment, options) + add_address(post, options) + + post + end + + def check_customer_exists(options = {}) + url = (test? ? test_url : live_url) + response = parse(ssl_get(url + "/customers/#{options[:customer_id]}", headers(options))) + + return response.try(:[], "data").try(:[], "customerId") if success_from(response) + return nil + end + + def add_credit_card_to_customer(payment, options = {}) + commit('tokens', create_token_request(payment, options), options) + end + + def add_customer_with_credit_card(payment, options = {}) + customer_response = commit('customers', create_customer_request(payment, options), options) + options.merge!({customer_id: customer_response.authorization}) + commit('tokens', create_token_request(payment, options), options) + end + + def parse(body) + JSON.parse(body) + end + + def commit(action, parameters, options={}) + url = (test? ? test_url : live_url) + response = parse(ssl_post(url + "/#{action}", parameters.to_json, headers(options))) + + Response.new( + success_from(response), + message_from(response), + response, + authorization: authorization_from(response), + avs_result: AVSResult.new(code: avs_result_from(response)), + cvv_result: CVVResult.new(cvv_result_from(response)), + test: test?, + error_code: error_code_from(response) + ) + end + + def success_from(response) + response["errors"].nil? && response["message"].nil? + end + + def message_from(response) + return response["message"] if response["message"] + return "Success" if success_from(response) + response["errors"].map {|error_hash| error_hash["detail"] }.join(", ") + end + + def authorization_from(response) + if customer_id = response.try(:[], "data").try(:[], "attributes").try(:[], "customerId") + "#{customer_id}|#{response.try(:[], "data").try(:[], "id")}" + else + response.try(:[], "data").try(:[], "id") + end + end + + def avs_result_from(response) + response.try(:[], "data").try(:[], "attributes").try(:[], "transaction").try(:[], "avsResult") + end + + def cvv_result_from(response) + response.try(:[], "data").try(:[], "attributes").try(:[], "transaction").try(:[], "codeResult") + end + + def app_token_from(response) + response.params.try(:[], "data").try(:[], "attributes").try(:[], "appToken") + end + + def headers(options) + headers = { + 'Content-Type' => 'application/json', + 'x-api-key' => @options[:api_key] + } + + headers.merge!({"Authorization" => "Bearer #{options[:app_token]}"}) if options[:app_token] + headers + end + + def error_code_from(response) + unless success_from(response) + response["errors"].nil? ? response["message"] : response["errors"].map {|error_hash| error_hash["code"] }.join(", ") + end + end + + def split_authorization(authorization) + customer_id, token = authorization.split("|") + [customer_id, token] + end + + def determine_payment_type(payment, options) + return "cardSplit" if options[:payment_type] == "card_split" + return "tokenSplit" if options[:payment_type] == "token_split" + return "token" if payment.is_a? String + "card" + end + + def handle_response(response) + case response.code.to_i + when 200..499 + response.body + else + raise ResponseError.new(response) + end + end + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index df749af71fd..3e694c162f7 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -230,6 +230,12 @@ dibs: merchant_id: SOMECREDENTIAL secret_key: NOPUBLICCREDENTIAL +# Working credentials, no need to replace +digitzs: + app_key: tcwtTux8SPZYO44Gf0UHZH74Z1HSutqCxmIV2PFj2jRc9Poroh3Z3R1BBQNRQ98Q + api_key: 0HhRdOU2AsWVEu3gRIKi2UpMMmj8Fj48qggBYTo4 + merchant_id: spreedly-susanswidg-32268973-2091076-148408385 + direc_pay: login: 200904281000001 diff --git a/test/remote/gateways/remote_digitzs_test.rb b/test/remote/gateways/remote_digitzs_test.rb new file mode 100644 index 00000000000..b4ea164f2df --- /dev/null +++ b/test/remote/gateways/remote_digitzs_test.rb @@ -0,0 +1,133 @@ +require 'test_helper' + +class RemoteDigitzsTest < Test::Unit::TestCase + def setup + @gateway = DigitzsGateway.new(fixtures(:digitzs)) + + @amount = 500 + @credit_card = credit_card('4747474747474747', verification_value: '999') + @declined_card = credit_card('4616161616161616') + @options = { + billing_address: address, + description: 'Store Purchase' + } + + @options_card_split = { + billing_address: address, + description: 'Split Purchase', + payment_type: 'card_split', + split_amount: 100, + split_merchant_id: 'spreedly-susanswidg-32270590-2095203-148657924' + } + + @options_token_split = { + billing_address: address, + description: 'Token Split Purchase', + payment_type: 'token_split', + split_amount: 100, + split_merchant_id: 'spreedly-susanswidg-32270590-2095203-148657924' + } + end + + def test_successful_purchase + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Success', response.message + end + + def test_successful_token_purchase + assert store = @gateway.store(@credit_card, @options) + assert_success store + + response = @gateway.purchase(@amount, store.authorization, @options) + assert_success response + assert_equal 'Success', response.message + end + + def test_successful_token_split_purchase + assert store = @gateway.store(@credit_card, @options) + assert_success store + + response = @gateway.purchase(@amount, store.authorization, @options_token_split) + assert_success response + assert_equal 'Success', response.message + assert response.params["data"]["attributes"]["split"]["splitId"] + end + + def test_successful_card_split_purchase + response = @gateway.purchase(@amount, @credit_card, @options_card_split) + assert_success response + assert_equal 'Success', response.message + assert response.params["data"]["attributes"]["split"]["splitId"] + end + + def test_failed_purchase + response = @gateway.purchase(@amount, @declined_card, @options) + assert_failure response + assert_equal 'Partner error: Credit card declined (transaction element shows reason for decline)', response.message + end + + def test_successful_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount, purchase.authorization, @options) + assert_success refund + assert_equal 'Success', refund.message + end + + def test_partial_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount-1, purchase.authorization, @options) + assert_success refund + end + + def test_failed_refund + response = @gateway.refund(@amount, '', @options) + assert_failure response + assert_equal '"id" is not allowed to be empty', response.message + end + + def test_successful_store + assert response = @gateway.store(@credit_card, @options) + assert_success response + end + + def test_successful_store_without_billing_address + assert response = @gateway.store(@credit_card, {}) + assert_success response + end + + def test_store_adds_card_to_existing_customer + assert response = @gateway.store(@credit_card, @options.merge({customer_id: "spreedly-susanswidg-32268973-2091076-148408385-5980208887457495-148700575"})) + assert_success response + end + + def test_store_creates_new_customer_and_adds_card + assert response = @gateway.store(@credit_card, @options.merge({customer_id: "nonexistant"})) + assert_success response + end + + def test_invalid_login + gateway = DigitzsGateway.new(app_key: '', api_key: '', merchant_id: '') + + response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_match %r{Forbidden}, response.message + end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:api_key], transcript) + assert_scrubbed(@gateway.options[:app_key], transcript) + end + +end diff --git a/test/unit/gateways/digitzs_test.rb b/test/unit/gateways/digitzs_test.rb new file mode 100644 index 00000000000..b7ff3a1ea69 --- /dev/null +++ b/test/unit/gateways/digitzs_test.rb @@ -0,0 +1,269 @@ +require 'test_helper' + +class DigitzsTest < Test::Unit::TestCase + include CommStub + + def setup + @gateway = DigitzsGateway.new(api_key: 'api_key', app_key: 'app_key', merchant_id: 'merchant_id') + @credit_card = credit_card + @amount = 100 + + @options = { + order_id: '1', + billing_address: address, + description: 'Store Purchase' + } + + @options_with_split = { + billing_address: address, + description: 'Split Purchase', + merchant_id: 'spreedly-susanswidg-32268973-2091076-148408385', + payment_type: 'card_split', + split_amount: 100, + split_merchant_id: 'spreedly-susanswidg-32270590-2095203-148657924' + } + end + + def test_successful_purchase + @gateway.expects(:ssl_post).times(2).returns(successful_app_token_response, successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + + assert_equal 'spreedly-susanswidg-32268973-2091076-148408385-124-148606421', response.authorization + assert response.test? + end + + 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"/ + assert_match(%r(split), data) + assert_match(%r("merchantId":"spreedly-susanswidg-32270590-2095203-148657924"), data) + end + end.respond_with(successful_app_token_response, successful_purchase_response) + assert_success response + + assert_equal 'spreedly-susanswidg-32268973-2091076-148408385-124-148606421', response.authorization + end + + 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"/ + assert_match(%r(split), data) + assert_match(%r("merchantId":"spreedly-susanswidg-32270590-2095203-148657924"), data) + end + end.respond_with(successful_app_token_response, successful_purchase_response) + assert_success response + + assert_equal 'spreedly-susanswidg-32268973-2091076-148408385-124-148606421', response.authorization + end + + def test_failed_purchase + @gateway.expects(:ssl_post).times(2).returns(successful_app_token_response, failed_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal "58", response.error_code + end + + def test_successful_refund + @gateway.expects(:ssl_post).times(2).returns(successful_app_token_response, successful_refund_response) + + response = @gateway.refund(@amount, "authorization", @options) + assert_success response + + assert_equal 'spreedly-susanswidg-32268973-2091076-148408385-127-148606617', response.authorization + assert response.test? + end + + def test_failed_refund + @gateway.expects(:ssl_post).times(2).returns(successful_app_token_response, failed_refund_response) + + response = @gateway.refund(@amount, "", @options) + assert_failure response + + assert_equal nil, response.authorization + assert response.test? + end + + def test_successful_store + @gateway.expects(:ssl_post).times(3).returns(successful_app_token_response, successful_create_customer_response, successful_token_response) + + response = @gateway.store(@credit_card, @options) + assert_success response + assert_equal "spreedly-susanswidg-32268973-2091076-148408385-2894006614343495-148710226|c0302d83-a694-4bec-9086-d1886b9eefd9-148710226", response.authorization + end + + 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_success response + assert_equal "spreedly-susanswidg-32268973-2091076-148408385-2894006614343495-148710226|c0302d83-a694-4bec-9086-d1886b9eefd9-148710226", response.authorization + end + + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + + private + + def pre_scrubbed + %q( +opening connection to beta.digitzsapi.com:443... +opened +starting SSL for beta.digitzsapi.com:443... +SSL established +<- "POST /sandbox/auth/token HTTP/1.1\r\nContent-Type: application/json\r\nX-Api-Key: 0HhRdOU2AsWVEu3gRIKi2UpMMmj8Fj48qggBYTo4\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: beta.digitzsapi.com\r\nContent-Length: 115\r\n\r\n" +<- "{\"data\":{\"attributes\":{\"appKey\":\"tcwtTux8SPZYO44Gf0UHZH74Z1HSutqCxmIV2PFj2jRc9Poroh3Z3R1BBQNRQ98Q\"},\"type\":\"auth\"}}" +-> "HTTP/1.1 201 Created\r\n" +-> "Content-Type: application/json\r\n" +-> "Content-Length: 434\r\n" +-> "Connection: close\r\n" +-> "Date: Fri, 27 Jan 2017 20:47:32 GMT\r\n" +-> "Content-Location: https://beta.digitzsapi.com/sandbox/auth/token\r\n" +-> "x-amzn-RequestId: d3637ff0-e4d1-11e6-a393-3dbd03385fb7\r\n" +-> "X-Amzn-Trace-Id: Root=1-588bb1e4-49acd61c62e319bc67e443d8\r\n" +-> "Via: 1.1 344c0192a2becdfa5c3c6b927653ff8b.cloudfront.net (CloudFront), 1.1 986a2cb4ab6fb48c9a4379a4e9d691c4.cloudfront.net (CloudFront)\r\n" +-> "X-Cache: Miss from cloudfront\r\n" +-> "X-Amz-Cf-Id: NfmaknL15LfaGNXlXtc2mhwFwpzNHMbNExCfsMxORdRF7t3bbc77vA==\r\n" +-> "\r\n" +reading 434 bytes... +-> "{\"links\":{\"self\":\"https://beta.digitzsapi.com/sandbox/auth/token\"},\"data\":{\"type\":\"auth\",\"id\":\"0HhRdOU2AsWVEu3gRIKi2UpMMmj8Fj48qggBYTo4\",\"attributes\":{\"appToken\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXJ0bmVySWQiOiJzcHJlZWRseS0xNDgyMzAxOTEiLCJwYXJ0bmVyUHJlZml4Ijoic3ByZWVkbHkiLCJwcm9wYXlUaWVyIjoiU2V0TGlzdGVyIiwicHJvcGF5TWNjIjoiNTk5OSIsImlhdCI6MTQ4NTU1MDA1MiwiZXhwIjoxNDg1NTUzNjUyfQ.P2gunlNF56IKbAKpnRci7vLgUK0Yd7K1PGPzTtYP3Nc\"}}}" +read 434 bytes +Conn close +opening connection to beta.digitzsapi.com:443... +opened +starting SSL for beta.digitzsapi.com:443... +SSL established +<- "POST /sandbox/payments HTTP/1.1\r\nContent-Type: application/json\r\nX-Api-Key: 0HhRdOU2AsWVEu3gRIKi2UpMMmj8Fj48qggBYTo4\r\nAuthorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXJ0bmVySWQiOiJzcHJlZWRseS0xNDgyMzAxOTEiLCJwYXJ0bmVyUHJlZml4Ijoic3ByZWVkbHkiLCJwcm9wYXlUaWVyIjoiU2V0TGlzdGVyIiwicHJvcGF5TWNjIjoiNTk5OSIsImlhdCI6MTQ4NTU1MDA1MiwiZXhwIjoxNDg1NTUzNjUyfQ.P2gunlNF56IKbAKpnRci7vLgUK0Yd7K1PGPzTtYP3Nc\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: beta.digitzsapi.com\r\nContent-Length: 430\r\n\r\n" +<- "{\"data\":{\"attributes\":{\"paymentType\":\"card\",\"merchantId\":\"spreedly-susanswidg-32268973-2091076-148408385\",\"card\":{\"holder\":\"Longbob Longsen\",\"number\":\"4747474747474747\",\"expiry\":\"0918\",\"code\":\"999\"},\"transaction\":{\"amount\":\"200\",\"currency\":\"USD\",\"invoice\":\"91bbccdd926ab8effc53bc7be094bd2b\"},\"billingAddress\":{\"line1\":\"456 My Street\",\"line2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"zip\":\"K1C2N6\",\"country\":\"US\"}},\"type\":\"payments\"}}" +-> "HTTP/1.1 201 Created\r\n" +-> "Content-Type: application/json\r\n" +-> "Content-Length: 504\r\n" +-> "Connection: close\r\n" +-> "Date: Fri, 27 Jan 2017 20:47:35 GMT\r\n" +-> "Content-Location: https://beta.digitzsapi.com/sandbox/payments/spreedly-susanswidg-32268973-2091076-148408385-88-148555005\r\n" +-> "x-amzn-RequestId: d3dcf5b4-e4d1-11e6-9d9a-59db6e3f8bc6\r\n" +-> "X-Amzn-Trace-Id: Root=1-588bb1e5-5c6481e9f44a8bd604900914\r\n" +-> "Via: 1.1 b06057d522f80c65400aebb1c06a2d72.cloudfront.net (CloudFront), 1.1 e6cb8f0dccd39d6bf4fcef2d892671bf.cloudfront.net (CloudFront)\r\n" +-> "X-Cache: Miss from cloudfront\r\n" +-> "X-Amz-Cf-Id: Q62cc8eH9XbSUl9No6Mp_xPS10ld0GQ8XN_S5uT4RdxkvUUA97a2kg==\r\n" +-> "\r\n" +reading 504 bytes... +-> "{\"links\":{\"self\":\"https://beta.digitzsapi.com/sandbox/payments/spreedly-susanswidg-32268973-2091076-148408385-88-148555005\"},\"data\":{\"type\":\"payments\",\"id\":\"spreedly-susanswidg-32268973-2091076-148408385-88-148555005\",\"attributes\":{\"paymentType\":\"card\",\"transaction\":{\"code\":\"0\",\"message\":\"Success\",\"amount\":\"200\",\"invoice\":\"91bbccdd926ab8effc53bc7be094bd2b\",\"currency\":\"USD\",\"authCode\":\"A11111\",\"avsResult\":\"T\",\"codeResult\":\"M\",\"gross\":\"200\",\"net\":\"169\",\"grossMinusNet\":\"31\",\"fee\":\"25\",\"rate\":\"2.90\"}}}}" +read 504 bytes +Conn close + ) + end + + def post_scrubbed + %q( +opening connection to beta.digitzsapi.com:443... +opened +starting SSL for beta.digitzsapi.com:443... +SSL established +<- "POST /sandbox/auth/token HTTP/1.1\r\nContent-Type: application/json\r\nX-Api-Key: [FILTERED]\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: beta.digitzsapi.com\r\nContent-Length: 115\r\n\r\n" +<- "{\"data\":{\"attributes\":{\"appKey\":\"[FILTERED] +-> "HTTP/1.1 201 Created\r\n" +-> "Content-Type: application/json\r\n" +-> "Content-Length: 434\r\n" +-> "Connection: close\r\n" +-> "Date: Fri, 27 Jan 2017 20:47:32 GMT\r\n" +-> "Content-Location: https://beta.digitzsapi.com/sandbox/auth/token\r\n" +-> "x-amzn-RequestId: d3637ff0-e4d1-11e6-a393-3dbd03385fb7\r\n" +-> "X-Amzn-Trace-Id: Root=1-588bb1e4-49acd61c62e319bc67e443d8\r\n" +-> "Via: 1.1 344c0192a2becdfa5c3c6b927653ff8b.cloudfront.net (CloudFront), 1.1 986a2cb4ab6fb48c9a4379a4e9d691c4.cloudfront.net (CloudFront)\r\n" +-> "X-Cache: Miss from cloudfront\r\n" +-> "X-Amz-Cf-Id: NfmaknL15LfaGNXlXtc2mhwFwpzNHMbNExCfsMxORdRF7t3bbc77vA==\r\n" +-> "\r\n" +reading 434 bytes... +-> "{\"links\":{\"self\":\"https://beta.digitzsapi.com/sandbox/auth/token\"},\"data\":{\"type\":\"auth\",\"id\":\"[FILTERED] +read 434 bytes +Conn close +opening connection to beta.digitzsapi.com:443... +opened +starting SSL for beta.digitzsapi.com:443... +SSL established +<- "POST /sandbox/payments HTTP/1.1\r\nContent-Type: application/json\r\nX-Api-Key: [FILTERED]\r\nAuthorization: Bearer [FILTERED] +<- "{\"data\":{\"attributes\":{\"paymentType\":\"card\",\"merchantId\":\"spreedly-susanswidg-32268973-2091076-148408385\",\"card\":{\"holder\":\"Longbob Longsen\",\"number\":\"[FILTERED]\",\"expiry\":\"0918\",\"code\":\"[FILTERED]\"},\"transaction\":{\"amount\":\"200\",\"currency\":\"USD\",\"invoice\":\"91bbccdd926ab8effc53bc7be094bd2b\"},\"billingAddress\":{\"line1\":\"456 My Street\",\"line2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"zip\":\"K1C2N6\",\"country\":\"US\"}},\"type\":\"payments\"}}" +-> "HTTP/1.1 201 Created\r\n" +-> "Content-Type: application/json\r\n" +-> "Content-Length: 504\r\n" +-> "Connection: close\r\n" +-> "Date: Fri, 27 Jan 2017 20:47:35 GMT\r\n" +-> "Content-Location: https://beta.digitzsapi.com/sandbox/payments/spreedly-susanswidg-32268973-2091076-148408385-88-148555005\r\n" +-> "x-amzn-RequestId: d3dcf5b4-e4d1-11e6-9d9a-59db6e3f8bc6\r\n" +-> "X-Amzn-Trace-Id: Root=1-588bb1e5-5c6481e9f44a8bd604900914\r\n" +-> "Via: 1.1 b06057d522f80c65400aebb1c06a2d72.cloudfront.net (CloudFront), 1.1 e6cb8f0dccd39d6bf4fcef2d892671bf.cloudfront.net (CloudFront)\r\n" +-> "X-Cache: Miss from cloudfront\r\n" +-> "X-Amz-Cf-Id: Q62cc8eH9XbSUl9No6Mp_xPS10ld0GQ8XN_S5uT4RdxkvUUA97a2kg==\r\n" +-> "\r\n" +reading 504 bytes... +-> "{\"links\":{\"self\":\"https://beta.digitzsapi.com/sandbox/payments/spreedly-susanswidg-32268973-2091076-148408385-88-148555005\"},\"data\":{\"type\":\"payments\",\"id\":\"[FILTERED] +read 504 bytes +Conn close + ) + end + + def successful_app_token_response + %( + {\"links\":{\"self\":\"https://beta.digitzsapi.com/sandbox/auth/token\"},\"data\":{\"type\":\"auth\",\"id\":\"0HhRdOU2AsWVEu3gRIKi2UpMMmj8Fj48qggBYTo4\",\"attributes\":{\"appToken\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXJ0bmVySWQiOiJzcHJlZWRseS0xNDgyMzAxOTEiLCJwYXJ0bmVyUHJlZml4Ijoic3ByZWVkbHkiLCJwcm9wYXlUaWVyIjoiU2V0TGlzdGVyIiwicHJvcGF5TWNjIjoiNTk5OSIsImlhdCI6MTQ4NjA2NDIxNiwiZXhwIjoxNDg2MDY3ODE2fQ.MaLR3ijeMuIGSHnNYINVILwa9hpxahd4U4Q44HW4jFQ\"}}} + ) + end + + def successful_purchase_response + %( + {\"links\":{\"self\":\"https://beta.digitzsapi.com/sandbox/payments/spreedly-susanswidg-32268973-2091076-148408385-124-148606421\"},\"data\":{\"type\":\"payments\",\"id\":\"spreedly-susanswidg-32268973-2091076-148408385-124-148606421\",\"attributes\":{\"paymentType\":\"card\",\"transaction\":{\"code\":\"0\",\"message\":\"Success\",\"amount\":\"200\",\"invoice\":\"42d7b1d026becf29e2005bae84e8935b\",\"currency\":\"USD\",\"authCode\":\"A11111\",\"avsResult\":\"T\",\"codeResult\":\"M\",\"gross\":\"200\",\"net\":\"169\",\"grossMinusNet\":\"31\",\"fee\":\"25\",\"rate\":\"2.90\"}}}} + ) + end + + def successful_split_purchase_response + %( + {\"links\":{\"self\":\"https://beta.digitzsapi.com/sandbox/payments/spreedly-susanswidg-32268973-2091076-148408385-153-148658575\"},\"data\":{\"type\":\"payments\",\"id\":\"spreedly-susanswidg-32268973-2091076-148408385-153-148658575\",\"attributes\":{\"paymentType\":\"cardSplit\",\"transaction\":{\"code\":\"0\",\"message\":\"Success\",\"amount\":\"500\",\"invoice\":\"88ec8adf6c86762684ae54820423acc8\",\"currency\":\"USD\",\"authCode\":\"A11111\",\"avsResult\":\"T\",\"codeResult\":\"M\"},\"split\":{\"merchantId\":\"spreedly-susanswidg-32270590-2095203-148657924\",\"amount\":\"100\",\"splitId\":\"spreedly-susanswidg-32270590-2095203-148657924-2-148658575\"}}}} + ) + end + + + def failed_purchase_response + %( + {\"meta\":{},\"errors\":[{\"status\":\"400\",\"source\":{\"pointer\":\"/payments\"},\"title\":\"Bad Request\",\"detail\":\"Partner error: Credit card declined (transaction element shows reason for decline)\",\"code\":\"58\",\"meta\":{\"debug\":{\"message\":\"Include debug info with support request.\",\"resource\":\"/payments POST\",\"log\":\"2017/02/02/[23]eb325f3ca78b4f7eb2178a0d1e635a0e\",\"request\":\"73c22dc3-e980-11e6-9390-69c24d5ed1f4\"},\"transaction\":{\"code\":\"51\",\"message\":\"Insufficient funds\",\"invoice\":\"3d1f247d9112349e3db252f9f3327047\",\"authCode\":\"A11111\",\"avsResult\":\"T\"}}}]} + ) + end + + def successful_refund_response + %( + {\"links\":{\"self\":\"https://beta.digitzsapi.com/sandbox/payments/spreedly-susanswidg-32268973-2091076-148408385-127-148606617\"},\"data\":{\"type\":\"payments\",\"id\":\"spreedly-susanswidg-32268973-2091076-148408385-127-148606617\",\"attributes\":{\"paymentType\":\"cardRefund\",\"transaction\":{\"code\":\"0\",\"message\":\"Success\",\"amount\":\"200\",\"invoice\":\"f87139e53b5273c12bc32d4be6fff9a8\",\"currency\":\"USD\"}}}} + ) + end + + def failed_refund_response + %( + {\"meta\":{},\"errors\":[{\"status\":\"400\",\"source\":{\"pointer\":\"/data/attributes/originalTransaction/id\"},\"title\":\"Bad Request\",\"detail\":\"\\\"id\\\" is not allowed to be empty\"}]} + ) + end + + def successful_create_customer_response + %( + {\"links\":{\"self\":\"https://beta.digitzsapi.com/sandbox/customers/spreedly-susanswidg-32268973-2091076-148408385-2894006614343495-148710226\"},\"data\":{\"type\":\"customers\",\"id\":\"spreedly-susanswidg-32268973-2091076-148408385-2894006614343495-148710226\",\"attributes\":{\"name\":\"Longbob Longsen\",\"externalId\":\"2b942bae49e9297f60428ee841f30724\"}}} + ) + end + + def successful_token_response + %( + {\"links\":{\"self\":\"https://beta.digitzsapi.com/sandbox/tokens/c0302d83-a694-4bec-9086-d1886b9eefd9-148710226\"},\"data\":{\"type\":\"tokens\",\"id\":\"c0302d83-a694-4bec-9086-d1886b9eefd9-148710226\",\"attributes\":{\"label\":\"Credit Card\",\"customerId\":\"spreedly-susanswidg-32268973-2091076-148408385-2894006614343495-148710226\"}}} + ) + end + + def customer_id_exists_response + %( + {\"links\":{\"self\":\"https://beta.digitzsapi.com/sandbox/customers/spreedly-susanswidg-32268973-2091076-148408385-5980208887457495-148700575\"},\"data\":{\"id\":\"spreedly-susanswidg-32268973-2091076-148408385-5980208887457495-148700575\",\"attributes\":{\"merchantId\":\"spreedly-susanswidg-32268973-2091076-148408385\",\"created\":\"2017-02-13T17:09:12.724Z\",\"name\":\"Jon Doe\",\"externalId\":\"123456\"},\"type\":\"customers\"}} + ) + end +end From 84ba622a56c802be051fc0dfad169af11a1f4114 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Fri, 17 Feb 2017 20:52:09 +0530 Subject: [PATCH 003/677] Credorax: Return failure response reason Closes #2341 --- CHANGELOG | 1 + .../billing/gateways/credorax.rb | 79 ++- test/remote/gateways/remote_credorax_test.rb | 628 +++++++++--------- test/unit/gateways/credorax_test.rb | 8 +- 4 files changed, 397 insertions(+), 319 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 40e072cc70b..488c287d50f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * CardStream: Add additional of currencies [shasum] #2337 * Revert "Authorize.net: Allow settings to be passed for CIM purchases" [curiousepic] #2339 * Digitzs: Add gateway [davidsantoso] +* Credorax: Return failure response reason [shasum] #2341 == Version 1.63.0 (February 2, 2017) * Authorize.net: Add #unstore support [jimryan] #2293 diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb index c36e04c88c4..ae9ae730bad 100644 --- a/lib/active_merchant/billing/gateways/credorax.rb +++ b/lib/active_merchant/billing/gateways/credorax.rb @@ -20,6 +20,83 @@ class CredoraxGateway < Gateway self.money_format = :cents self.supported_cardtypes = [:visa, :master, :maestro] + RESPONSE_MESSAGES = { + "00" => "Approved or completed successfully", + "01" => "Refer to card issuer", + "02" => "Refer to card issuer special condition", + "03" => "Invalid merchant", + "04" => "Pick up card", + "05" => "Do not Honour", + "06" => "Invalid Transaction for Terminal", + "07" => "Pick up card special condition", + "08" => "Time-Out", + "09" => "No Original", + "10" => "Approved for partial amount", + "11" => "Partial Approval", + "12" => "Invalid transaction card / issuer / acquirer", + "13" => "Invalid amount", + "14" => "Invalid card number", + "17" => "Invalid Capture date (terminal business date)", + "19" => "System Error; Re-enter transaction", + "20" => "No From Account", + "21" => "No To Account", + "22" => "No Checking Account", + "23" => "No Saving Account", + "24" => "No Credit Account", + "30" => "Format error", + "34" => "Implausible card data", + "39" => "Transaction Not Allowed", + "41" => "Lost Card, Pickup", + "42" => "Special Pickup", + "43" => "Hot Card, Pickup (if possible)", + "44" => "Pickup Card", + "51" => "Not sufficient funds", + "52" => "No checking Account", + "53" => "No savings account", + "54" => "Expired card", + "55" => "Pin incorrect", + "57" => "Transaction not allowed for cardholder", + "58" => "Transaction not allowed for merchant", + "59" => "Suspected Fraud", + "61" => "Exceeds withdrawal amount limit", + "62" => "Restricted card", + "63" => "MAC Key Error", + "65" => "Activity count limit exceeded", + "66" => "Exceeds Acquirer Limit", + "67" => "Retain Card; no reason specified", + "68" => "Response received too late", + "75" => "Pin tries exceeded", + "76" => "Invalid Account", + "77" => "Issuer Does Not Participate In The Service", + "78" => "Function Not Available", + "79" => "Key Validation Error", + "80" => "Approval for Purchase Amount Only", + "81" => "Unable to Verify PIN", + "82" => "Time out at issuer system", + "83" => "Not declined (Valid for all zero amount transactions)", + "84" => "Invalid Life Cycle of transaction", + "85" => "Not declined", + "86" => "Cannot verify pin", + "87" => "Purchase amount only, no cashback allowed", + "88" => "MAC sync Error", + "89" => "Security Violation", + "91" => "Issuer not available", + "92" => "Unable to route at acquirer Module", + "93" => "Transaction cannot be completed", + "94" => "Duplicate transaction", + "95" => "Contact Acquirer", + "96" => "System malfunction", + "97" => "No Funds Transfer", + "98" => "Duplicate Reversal", + "99" => "Duplicate Transaction", + "N3" => "Cash Service Not Available", + "N4" => "Cash Back Request Exceeds Issuer Limit", + "N7" => "N7 (visa), Decline CVV2 failure", + "R0" => "Stop Payment Order", + "R1" => "Revocation of Authorisation Order", + "R3" => "Revocation of all Authorisations Order" + } + def initialize(options={}) requires!(options, :merchant_id, :cipher_key) super @@ -225,7 +302,7 @@ def message_from(response) if success_from(response) "Succeeded" else - response["Z3"] || "Unable to read error message" + RESPONSE_MESSAGES[response["Z6"]] || response["Z3"] || "Unable to read error message" end end end diff --git a/test/remote/gateways/remote_credorax_test.rb b/test/remote/gateways/remote_credorax_test.rb index 6787b6567a5..6f4927cc6f4 100644 --- a/test/remote/gateways/remote_credorax_test.rb +++ b/test/remote/gateways/remote_credorax_test.rb @@ -31,7 +31,7 @@ def test_successful_purchase def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "Transaction has been declined.", response.message + assert_equal "Transaction not allowed for cardholder", response.message end def test_successful_authorize_and_capture @@ -48,7 +48,7 @@ def test_successful_authorize_and_capture def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal "Transaction has been declined.", response.message + assert_equal "Transaction not allowed for cardholder", response.message assert_equal "05", response.params["Z2"] end @@ -137,7 +137,7 @@ def test_successful_credit def test_failed_credit response = @gateway.credit(@amount, @declined_card, @options) assert_failure response - assert_equal "Transaction has been declined.", response.message + assert_equal "Transaction not allowed for cardholder", response.message end def test_successful_verify @@ -149,7 +149,7 @@ def test_successful_verify def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "Transaction has been declined.", response.message + assert_equal "Transaction not allowed for cardholder", response.message assert_equal "05", response.params["Z2"] end @@ -163,314 +163,314 @@ def test_transcript_scrubbing assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript) end - ######################################################################### - # CERTIFICATION SPECIFIC REMOTE TESTS - ######################################################################### - - # Send [a5] currency code parameter as "AFN" - def test_certification_error_unregistered_currency - @options[:echo] = "33BE888" - @options[:currency] = "AFN" - response = @gateway.purchase(@amount, @credit_card, @options) - assert_failure response - end - - # Send [b2] parameter as "6" - def test_certification_error_unregistered_card - @options[:echo] = "33BE889" - response = @gateway.purchase(@amount, @credit_card, @options) - assert_failure response - end - - # In the future, merchant expected to investigate each such case offline. - def test_certification_error_no_response_from_the_gate - @options[:echo] = "33BE88A" - response = @gateway.purchase(@amount, @credit_card, @options) - assert_failure response - end - - # Merchant is expected to verify if the code is "0" - in this case the - # transaction should be considered approved. In all other cases the - # offline investigation should take place. - def test_certification_error_unknown_result_code - @options[:echo] = "33BE88B" - response = @gateway.purchase(@amount, @credit_card, @options) - assert_failure response - end - - # Merchant is expected to verify if the code is "00" - in this case the - # transaction should be considered approved. In all other cases the - # transaction is declined. The exact reason should be investigated offline. - def test_certification_error_unknown_response_reason_code - @options[:echo] = "33BE88C" - @options[:email] = "brucewayne@dccomics.com" - @options[:billing_address] = { - address1: "5050 Gotham Drive", - city: "Toronto", - zip: "B2M 1Y9", - state: "ON", - country: "CA", - phone: "(0800)228626" - } - - credit_card = credit_card('4176661000001015', - brand: "visa", - verification_value: "281", - month: "12", - year: "17", - first_name: "Bruce", - last_name: "Wayne") - - response = @gateway.purchase(@amount, credit_card, @options) - assert_failure response - end - - # All fields marked as mandatory are expected to be populated with the - # above default values. Mandatory fields with no values on the - # certification template should be populated with your own meaningful - # values and comply with our API specifications. The d2 parameter is - # mandatory during certification only to allow for tracking of tests. - # Expected result of this test: Time out - def test_certification_time_out - @options[:echo] = "33BE88D" - @options[:email] = "brucewayne@dccomics.com" - @options[:billing_address] = { - address1: "5050 Gotham Drive", - city: "Toronto", - zip: "B2M 1Y9", - state: "ON", - country: "CA", - phone: "(0800)228626" - } - - credit_card = credit_card('5473470000000010', - brand: "master", - verification_value: "939", - month: "12", - year: "17", - first_name: "Bruce", - last_name: "Wayne") - - response = @gateway.purchase(@amount, credit_card, @options) - assert_failure response - end - - # All fields marked as mandatory are expected to be populated - # with the above default values. Mandatory fields with no values - # on the certification template should be populated with your - # own meaningful values and comply with our API specifications. - # The d2 parameter is mandatory during certification only to - # allow for tracking of tests. - def test_certification_za_zb_zc - @options[:echo] = "33BE88E" - @options[:email] = "brucewayne@dccomics.com" - @options[:billing_address] = { - address1: "5050 Gotham Drive", - city: "Toronto", - zip: "B2M 1Y9", - state: "ON", - country: "CA", - phone: "(0800)228626" - } - - credit_card = credit_card('5473470000000010', - verification_value: "939", - month: "12", - year: "17", - first_name: "Bruce", - last_name: "Wayne") - - purchase = @gateway.purchase(@amount, credit_card, @options) - assert_success purchase - assert_equal "Succeeded", purchase.message - - refund_options = {echo: "33BE892"} - refund = @gateway.refund(@amount, purchase.authorization, refund_options) - assert_success refund - assert_equal "Succeeded", refund.message - - void_options = {echo: "33BE895"} - void = @gateway.void(refund.authorization, void_options) - assert_success void - assert_equal "Succeeded", refund.message - end - - # All fields marked as mandatory are expected to be populated - # with the above default values. Mandatory fields with no values - # on the certification template should be populated with your - # own meaningful values and comply with our API specifications. - # The d2 parameter is mandatory during certification only to - # allow for tracking of tests. - def test_certification_zg_zh - @options[:echo] = "33BE88F" - @options[:email] = "clark.kent@dccomics.com" - @options[:billing_address] = { - address1: "2020 Krypton Drive", - city: "Toronto", - zip: "S2M 1YR", - state: "ON", - country: "CA", - phone: "(0800) 78737626" - } - - credit_card = credit_card('4176661000001015', - brand: "visa", - verification_value: "281", - month: "12", - year: "17", - first_name: "Clark", - last_name: "Kent") - - response = @gateway.authorize(@amount, credit_card, @options) - assert_success response - assert_equal "Succeeded", response.message - - capture_options = {echo: "33BE890"} - capture = @gateway.capture(@amount, response.authorization, capture_options) - assert_success capture - assert_equal "Succeeded", capture.message - end - - # All fields marked as mandatory are expected to be populated - # with the above default values. Mandatory fields with no values - # on the certification template should be populated with your - # own meaningful values and comply with our API specifications. - # The d2 parameter is mandatory during certification only to - # allow for tracking of tests. - def test_certification_zg_zj - @options[:echo] = "33BE88F" - @options[:email] = "clark.kent@dccomics.com" - @options[:billing_address] = { - address1: "2020 Krypton Drive", - city: "Toronto", - zip: "S2M 1YR", - state: "ON", - country: "CA", - phone: "(0800) 78737626" - } - - credit_card = credit_card('4176661000001015', - brand: "visa", - verification_value: "281", - month: "12", - year: "17", - first_name: "Clark", - last_name: "Kent") - - response = @gateway.authorize(@amount, credit_card, @options) - assert_success response - assert_equal "Succeeded", response.message - - auth_void_options = {echo: "33BE891"} - auth_void = @gateway.void(response.authorization, auth_void_options) - assert_success auth_void - assert_equal "Succeeded", auth_void.message - end - - # All fields marked as mandatory are expected to be populated - # with the above default values. Mandatory fields with no values - # on the certification template should be populated with your - # own meaningful values and comply with our API specifications. - # The d2 parameter is mandatory during certification only to - # allow for tracking of tests. - # - # Certification for independent credit (credit) - def test_certification_zd - @options[:echo] = "33BE893" - @options[:email] = "wadewilson@marvel.com" - @options[:billing_address] = { - address1: "5050 Deadpool Drive", - city: "Toronto", - zip: "D2P 1Y9", - state: "ON", - country: "CA", - phone: "+1(555)123-4567" - } - - credit_card = credit_card('4176661000001015', - brand: "visa", - verification_value: "281", - month: "12", - year: "17", - first_name: "Wade", - last_name: "Wilson") - - response = @gateway.credit(@amount, credit_card, @options) - assert_success response - assert_equal "Succeeded", response.message - end - - # Use the above values to fill the mandatory parameters in your - # certification test transactions. Note:The d2 parameter is only - # mandatory during certification to allow for tracking of tests. - # - # Certification for purchase void - def test_certification_zf - @options[:echo] = "33BE88E" - @options[:email] = "brucewayne@dccomics.com" - @options[:billing_address] = { - address1: "5050 Gotham Drive", - city: "Toronto", - zip: "B2M 1Y9", - state: "ON", - country: "CA", - phone: "(0800)228626" - } - - credit_card = credit_card('5473470000000010', - verification_value: "939", - month: "12", - year: "17", - first_name: "Bruce", - last_name: "Wayne") - - response = @gateway.purchase(@amount, credit_card, @options) - assert_success response - assert_equal "Succeeded", response.message - - void_options = {echo: "33BE894"} - void = @gateway.void(response.authorization, void_options) - assert_success void - assert_equal "Succeeded", void.message - end - - # Use the above values to fill the mandatory parameters in your - # certification test transactions. Note:The d2 parameter is only - # mandatory during certification to allow for tracking of tests. - # - # Certification for capture void - def test_certification_zi - @options[:echo] = "33BE88F" - @options[:email] = "clark.kent@dccomics.com" - @options[:billing_address] = { - address1: "2020 Krypton Drive", - city: "Toronto", - zip: "S2M 1YR", - state: "ON", - country: "CA", - phone: "(0800) 78737626" - } - - credit_card = credit_card('4176661000001015', - brand: "visa", - verification_value: "281", - month: "12", - year: "17", - first_name: "Clark", - last_name: "Kent") - - authorize = @gateway.authorize(@amount, credit_card, @options) - assert_success authorize - assert_equal "Succeeded", authorize.message - - capture_options = {echo: "33BE890"} - capture = @gateway.capture(@amount, authorize.authorization, capture_options) - assert_success capture - assert_equal "Succeeded", capture.message - - void_options = {echo: "33BE896"} - void = @gateway.void(capture.authorization, void_options) - assert_success void - assert_equal "Succeeded", void.message - end + # ######################################################################### + # # CERTIFICATION SPECIFIC REMOTE TESTS + # ######################################################################### + # + # # Send [a5] currency code parameter as "AFN" + # def test_certification_error_unregistered_currency + # @options[:echo] = "33BE888" + # @options[:currency] = "AFN" + # response = @gateway.purchase(@amount, @credit_card, @options) + # assert_failure response + # end + # + # # Send [b2] parameter as "6" + # def test_certification_error_unregistered_card + # @options[:echo] = "33BE889" + # response = @gateway.purchase(@amount, @credit_card, @options) + # assert_failure response + # end + # + # # In the future, merchant expected to investigate each such case offline. + # def test_certification_error_no_response_from_the_gate + # @options[:echo] = "33BE88A" + # response = @gateway.purchase(@amount, @credit_card, @options) + # assert_failure response + # end + # + # # Merchant is expected to verify if the code is "0" - in this case the + # # transaction should be considered approved. In all other cases the + # # offline investigation should take place. + # def test_certification_error_unknown_result_code + # @options[:echo] = "33BE88B" + # response = @gateway.purchase(@amount, @credit_card, @options) + # assert_failure response + # end + # + # # Merchant is expected to verify if the code is "00" - in this case the + # # transaction should be considered approved. In all other cases the + # # transaction is declined. The exact reason should be investigated offline. + # def test_certification_error_unknown_response_reason_code + # @options[:echo] = "33BE88C" + # @options[:email] = "brucewayne@dccomics.com" + # @options[:billing_address] = { + # address1: "5050 Gotham Drive", + # city: "Toronto", + # zip: "B2M 1Y9", + # state: "ON", + # country: "CA", + # phone: "(0800)228626" + # } + # + # credit_card = credit_card('4176661000001015', + # brand: "visa", + # verification_value: "281", + # month: "12", + # year: "17", + # first_name: "Bruce", + # last_name: "Wayne") + # + # response = @gateway.purchase(@amount, credit_card, @options) + # assert_failure response + # end + # + # # All fields marked as mandatory are expected to be populated with the + # # above default values. Mandatory fields with no values on the + # # certification template should be populated with your own meaningful + # # values and comply with our API specifications. The d2 parameter is + # # mandatory during certification only to allow for tracking of tests. + # # Expected result of this test: Time out + # def test_certification_time_out + # @options[:echo] = "33BE88D" + # @options[:email] = "brucewayne@dccomics.com" + # @options[:billing_address] = { + # address1: "5050 Gotham Drive", + # city: "Toronto", + # zip: "B2M 1Y9", + # state: "ON", + # country: "CA", + # phone: "(0800)228626" + # } + # + # credit_card = credit_card('5473470000000010', + # brand: "master", + # verification_value: "939", + # month: "12", + # year: "17", + # first_name: "Bruce", + # last_name: "Wayne") + # + # response = @gateway.purchase(@amount, credit_card, @options) + # assert_failure response + # end + # + # # All fields marked as mandatory are expected to be populated + # # with the above default values. Mandatory fields with no values + # # on the certification template should be populated with your + # # own meaningful values and comply with our API specifications. + # # The d2 parameter is mandatory during certification only to + # # allow for tracking of tests. + # def test_certification_za_zb_zc + # @options[:echo] = "33BE88E" + # @options[:email] = "brucewayne@dccomics.com" + # @options[:billing_address] = { + # address1: "5050 Gotham Drive", + # city: "Toronto", + # zip: "B2M 1Y9", + # state: "ON", + # country: "CA", + # phone: "(0800)228626" + # } + # + # credit_card = credit_card('5473470000000010', + # verification_value: "939", + # month: "12", + # year: "17", + # first_name: "Bruce", + # last_name: "Wayne") + # + # purchase = @gateway.purchase(@amount, credit_card, @options) + # assert_success purchase + # assert_equal "Succeeded", purchase.message + # + # refund_options = {echo: "33BE892"} + # refund = @gateway.refund(@amount, purchase.authorization, refund_options) + # assert_success refund + # assert_equal "Succeeded", refund.message + # + # void_options = {echo: "33BE895"} + # void = @gateway.void(refund.authorization, void_options) + # assert_success void + # assert_equal "Succeeded", refund.message + # end + # + # # All fields marked as mandatory are expected to be populated + # # with the above default values. Mandatory fields with no values + # # on the certification template should be populated with your + # # own meaningful values and comply with our API specifications. + # # The d2 parameter is mandatory during certification only to + # # allow for tracking of tests. + # def test_certification_zg_zh + # @options[:echo] = "33BE88F" + # @options[:email] = "clark.kent@dccomics.com" + # @options[:billing_address] = { + # address1: "2020 Krypton Drive", + # city: "Toronto", + # zip: "S2M 1YR", + # state: "ON", + # country: "CA", + # phone: "(0800) 78737626" + # } + # + # credit_card = credit_card('4176661000001015', + # brand: "visa", + # verification_value: "281", + # month: "12", + # year: "17", + # first_name: "Clark", + # last_name: "Kent") + # + # response = @gateway.authorize(@amount, credit_card, @options) + # assert_success response + # assert_equal "Succeeded", response.message + # + # capture_options = {echo: "33BE890"} + # capture = @gateway.capture(@amount, response.authorization, capture_options) + # assert_success capture + # assert_equal "Succeeded", capture.message + # end + # + # # All fields marked as mandatory are expected to be populated + # # with the above default values. Mandatory fields with no values + # # on the certification template should be populated with your + # # own meaningful values and comply with our API specifications. + # # The d2 parameter is mandatory during certification only to + # # allow for tracking of tests. + # def test_certification_zg_zj + # @options[:echo] = "33BE88F" + # @options[:email] = "clark.kent@dccomics.com" + # @options[:billing_address] = { + # address1: "2020 Krypton Drive", + # city: "Toronto", + # zip: "S2M 1YR", + # state: "ON", + # country: "CA", + # phone: "(0800) 78737626" + # } + # + # credit_card = credit_card('4176661000001015', + # brand: "visa", + # verification_value: "281", + # month: "12", + # year: "17", + # first_name: "Clark", + # last_name: "Kent") + # + # response = @gateway.authorize(@amount, credit_card, @options) + # assert_success response + # assert_equal "Succeeded", response.message + # + # auth_void_options = {echo: "33BE891"} + # auth_void = @gateway.void(response.authorization, auth_void_options) + # assert_success auth_void + # assert_equal "Succeeded", auth_void.message + # end + # + # # All fields marked as mandatory are expected to be populated + # # with the above default values. Mandatory fields with no values + # # on the certification template should be populated with your + # # own meaningful values and comply with our API specifications. + # # The d2 parameter is mandatory during certification only to + # # allow for tracking of tests. + # # + # # Certification for independent credit (credit) + # def test_certification_zd + # @options[:echo] = "33BE893" + # @options[:email] = "wadewilson@marvel.com" + # @options[:billing_address] = { + # address1: "5050 Deadpool Drive", + # city: "Toronto", + # zip: "D2P 1Y9", + # state: "ON", + # country: "CA", + # phone: "+1(555)123-4567" + # } + # + # credit_card = credit_card('4176661000001015', + # brand: "visa", + # verification_value: "281", + # month: "12", + # year: "17", + # first_name: "Wade", + # last_name: "Wilson") + # + # response = @gateway.credit(@amount, credit_card, @options) + # assert_success response + # assert_equal "Succeeded", response.message + # end + # + # # Use the above values to fill the mandatory parameters in your + # # certification test transactions. Note:The d2 parameter is only + # # mandatory during certification to allow for tracking of tests. + # # + # # Certification for purchase void + # def test_certification_zf + # @options[:echo] = "33BE88E" + # @options[:email] = "brucewayne@dccomics.com" + # @options[:billing_address] = { + # address1: "5050 Gotham Drive", + # city: "Toronto", + # zip: "B2M 1Y9", + # state: "ON", + # country: "CA", + # phone: "(0800)228626" + # } + # + # credit_card = credit_card('5473470000000010', + # verification_value: "939", + # month: "12", + # year: "17", + # first_name: "Bruce", + # last_name: "Wayne") + # + # response = @gateway.purchase(@amount, credit_card, @options) + # assert_success response + # assert_equal "Succeeded", response.message + # + # void_options = {echo: "33BE894"} + # void = @gateway.void(response.authorization, void_options) + # assert_success void + # assert_equal "Succeeded", void.message + # end + # + # # Use the above values to fill the mandatory parameters in your + # # certification test transactions. Note:The d2 parameter is only + # # mandatory during certification to allow for tracking of tests. + # # + # # Certification for capture void + # def test_certification_zi + # @options[:echo] = "33BE88F" + # @options[:email] = "clark.kent@dccomics.com" + # @options[:billing_address] = { + # address1: "2020 Krypton Drive", + # city: "Toronto", + # zip: "S2M 1YR", + # state: "ON", + # country: "CA", + # phone: "(0800) 78737626" + # } + # + # credit_card = credit_card('4176661000001015', + # brand: "visa", + # verification_value: "281", + # month: "12", + # year: "17", + # first_name: "Clark", + # last_name: "Kent") + # + # authorize = @gateway.authorize(@amount, credit_card, @options) + # assert_success authorize + # assert_equal "Succeeded", authorize.message + # + # capture_options = {echo: "33BE890"} + # capture = @gateway.capture(@amount, authorize.authorization, capture_options) + # assert_success capture + # assert_equal "Succeeded", capture.message + # + # void_options = {echo: "33BE896"} + # void = @gateway.void(capture.authorization, void_options) + # assert_success void + # assert_equal "Succeeded", void.message + # end end diff --git a/test/unit/gateways/credorax_test.rb b/test/unit/gateways/credorax_test.rb index 6498d449c14..29066e966bd 100644 --- a/test/unit/gateways/credorax_test.rb +++ b/test/unit/gateways/credorax_test.rb @@ -31,7 +31,7 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "Transaction has been declined.", response.message + assert_equal "Transaction not allowed for cardholder", response.message assert response.test? end @@ -58,7 +58,7 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Transaction has been declined.", response.message + assert_equal "Transaction not allowed for cardholder", response.message assert response.test? end @@ -139,7 +139,7 @@ def test_failed_credit end.respond_with(failed_credit_response) assert_failure response - assert_equal "Transaction has been declined.", response.message + assert_equal "Transaction not allowed for cardholder", response.message assert response.test? end @@ -156,7 +156,7 @@ def test_failed_verify @gateway.verify(@credit_card) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "Transaction has been declined.", response.message + assert_equal "Transaction not allowed for cardholder", response.message end def test_empty_response_fails From 2681ea70439b0f8a9abe0274e2f47fc01f806230 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Fri, 17 Feb 2017 14:22:51 +0530 Subject: [PATCH 004/677] Sage: Default billing state when outside US Sage requires an address state be sent even if transacting outside of the US/North America and the country does not have states. Unfortunately Sage support is unwilling to say what exactly should be sent in the state field (they say you can send anything) if no state is part of a billing address so this commit mimics the behaviour of the virtual terminal which uses the text "Outside of US". Moreover Sage now supports countries outside of the US so it would appear as though the supported_countries field could be updated. Closes #2340 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/sage.rb | 8 +++++--- test/remote/gateways/remote_sage_test.rb | 7 +++++++ test/unit/gateways/sage_test.rb | 10 +++++----- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 488c287d50f..c485526eada 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ * Revert "Authorize.net: Allow settings to be passed for CIM purchases" [curiousepic] #2339 * Digitzs: Add gateway [davidsantoso] * Credorax: Return failure response reason [shasum] #2341 +* Sage: Default billing state when outside US [shasum] #2340 == Version 1.63.0 (February 2, 2017) * Authorize.net: Add #unstore support [jimryan] #2293 diff --git a/lib/active_merchant/billing/gateways/sage.rb b/lib/active_merchant/billing/gateways/sage.rb index 257c4300c85..b1a10a02c8e 100644 --- a/lib/active_merchant/billing/gateways/sage.rb +++ b/lib/active_merchant/billing/gateways/sage.rb @@ -1,6 +1,8 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class SageGateway < Gateway + include Empty + self.display_name = 'http://www.sagepayments.com' self.homepage_url = 'Sage Payment Solutions' self.live_url = 'https://www.sagepayments.net/cgi-bin' @@ -204,8 +206,8 @@ def parse_credit_card(data) def add_invoice(post, options) post[:T_ordernum] = (options[:order_id] || generate_unique_id).slice(0, 20) - post[:T_tax] = amount(options[:tax]) unless options[:tax].blank? - post[:T_shipping] = amount(options[:shipping]) unless options[:shipping].blank? + post[:T_tax] = amount(options[:tax]) unless empty?(options[:tax]) + post[:T_shipping] = amount(options[:shipping]) unless empty?(options[:shipping]) end def add_reference(post, reference) @@ -226,7 +228,7 @@ def add_addresses(post, options) post[:C_address] = billing_address[:address1] post[:C_city] = billing_address[:city] - post[:C_state] = billing_address[:state] + post[:C_state] = empty?(billing_address[:state]) ? "Outside of US" : billing_address[:state] post[:C_zip] = billing_address[:zip] post[:C_country] = billing_address[:country] post[:C_telephone] = billing_address[:phone] diff --git a/test/remote/gateways/remote_sage_test.rb b/test/remote/gateways/remote_sage_test.rb index d196d4ada97..4f688dc2e9d 100644 --- a/test/remote/gateways/remote_sage_test.rb +++ b/test/remote/gateways/remote_sage_test.rb @@ -80,6 +80,13 @@ def test_successful_with_minimal_options assert_false response.authorization.blank? end + def test_successful_purchase_with_blank_state + assert response = @gateway.purchase(@amount, @visa, billing_address: address(state: "")) + assert_success response + assert response.test? + assert_false response.authorization.blank? + end + def test_authorization_and_capture assert auth = @gateway.authorize(@amount, @visa, @options) assert_success auth diff --git a/test/unit/gateways/sage_test.rb b/test/unit/gateways/sage_test.rb index 0c805fb4b2f..527fbc68d4c 100644 --- a/test/unit/gateways/sage_test.rb +++ b/test/unit/gateways/sage_test.rb @@ -185,7 +185,7 @@ def test_cvv_result assert_equal 'M', response.cvv_result['code'] end - def test_us_address_with_state + def test_address_with_state post = {} options = { :billing_address => { :country => "US", :state => "CA"} @@ -196,15 +196,15 @@ def test_us_address_with_state assert_equal "CA", post[:C_state] end - def test_us_address_without_state + def test_address_without_state post = {} options = { - :billing_address => { :country => "US", :state => ""} + :billing_address => { :country => "NZ", :state => ""} } @gateway.send(:add_addresses, post, options) - assert_equal "US", post[:C_country] - assert_equal "", post[:C_state] + assert_equal "NZ", post[:C_country] + assert_equal "Outside of US", post[:C_state] end def test_successful_check_purchase From 206cf579951d3e984de5bb98e5291936a92b18f5 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Fri, 17 Feb 2017 23:39:21 +0530 Subject: [PATCH 005/677] TransFirst Transaction Express: Fix improper AVS and CVV response code mapping Closes #2342 --- CHANGELOG | 1 + .../billing/gateways/trans_first_transaction_express.rb | 4 ++-- .../remote_trans_first_transaction_express_test.rb | 9 +++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c485526eada..ebf2204d74d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * Digitzs: Add gateway [davidsantoso] * Credorax: Return failure response reason [shasum] #2341 * Sage: Default billing state when outside US [shasum] #2340 +* TransFirst Transaction Express: Fix improper AVS and CVV response code mapping [shasum] #2342 == Version 1.63.0 (February 2, 2017) * Authorize.net: Add #unstore support [jimryan] #2293 diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb index 1e30c9a290e..7ca84cda458 100644 --- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb @@ -338,8 +338,8 @@ def commit(action, request) response, error_code: error_code_from(succeeded, response), authorization: authorization_from(action, response), - avs_result: AVSResult.new(code: response["AVSCode"]), - cvv_result: CVVResult.new(response["CVV2Response"]), + avs_result: AVSResult.new(code: response["avsRslt"]), + cvv_result: CVVResult.new(response["secRslt"]), test: test? ) end diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb index 4976e69ed25..8261c0cb14b 100644 --- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb +++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb @@ -1,6 +1,7 @@ require "test_helper" class RemoteTransFirstTransactionExpressTest < Test::Unit::TestCase + def setup @gateway = TransFirstTransactionExpressGateway.new(fixtures(:trans_first_transaction_express)) @@ -39,6 +40,10 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal "Succeeded", response.message + assert_not_nil response.avs_result + assert_not_nil response.cvv_result + assert_equal "Street address does not match, but 5-digit postal code matches.", response.avs_result["message"] + assert_equal "CVV matches", response.cvv_result["message"] end def test_successful_purchase_without_cvv @@ -211,7 +216,7 @@ def test_failed_verify response = @gateway.verify(credit_card(""), @options) assert_failure response assert_equal "Validation Failure", response.message - assert_equal "50011", response.error_code + assert_equal "51308", response.error_code end def test_successful_store @@ -261,7 +266,7 @@ def test_failed_store response = @gateway.store(credit_card("123"), @options) assert_failure response assert_equal "Validation Failure", response.message - assert_equal "50011", response.error_code + assert_equal "51308", response.error_code end # def test_dump_transcript From 4ca9726b27ae65e18a367a7656e4dc960e5454e6 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Fri, 17 Feb 2017 15:37:25 -0500 Subject: [PATCH 006/677] Digitzs: Remove merchant_id from gateway credentials During the initial implementation of the Digitzs gateway, there was a misunderstanding on how the merchant id field should be used. Although it's required on each request the value itself can vary which means it should be an option passed in vs being considered a credential. --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/digitzs.rb | 8 ++++---- test/fixtures.yml | 1 - test/remote/gateways/remote_digitzs_test.rb | 5 ++++- test/unit/gateways/digitzs_test.rb | 5 +++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ebf2204d74d..29422949edc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * Credorax: Return failure response reason [shasum] #2341 * Sage: Default billing state when outside US [shasum] #2340 * TransFirst Transaction Express: Fix improper AVS and CVV response code mapping [shasum] #2342 +* Digitzs: Remove merchant_id from gateway credentials [davidsantoso] == Version 1.63.0 (February 2, 2017) * Authorize.net: Add #unstore support [jimryan] #2293 diff --git a/lib/active_merchant/billing/gateways/digitzs.rb b/lib/active_merchant/billing/gateways/digitzs.rb index 834de7842ba..d1eadd7ffd2 100644 --- a/lib/active_merchant/billing/gateways/digitzs.rb +++ b/lib/active_merchant/billing/gateways/digitzs.rb @@ -15,7 +15,7 @@ class DigitzsGateway < Gateway self.display_name = 'Digitzs' def initialize(options={}) - requires!(options, :app_key, :api_key, :merchant_id) + requires!(options, :app_key, :api_key) super end @@ -136,7 +136,7 @@ def app_token_request(options) def purchase_request(money, payment, options) post = new_post post[:data][:type] = "payments" - post[:data][:attributes][:merchantId] = @options[:merchant_id] + post[:data][:attributes][:merchantId] = options[:merchant_id] post[:data][:attributes][:paymentType] = determine_payment_type(payment, options) add_split(post, options) add_payment(post, payment, options) @@ -149,7 +149,7 @@ def purchase_request(money, payment, options) def refund_request(money, authorization, options) post = new_post post[:data][:type] = "payments" - post[:data][:attributes][:merchantId] = @options[:merchant_id] + post[:data][:attributes][:merchantId] = options[:merchant_id] post[:data][:attributes][:paymentType] = "cardRefund" post[:data][:attributes][:originalTransaction] = {id: authorization} add_transaction(post, money, options) @@ -161,7 +161,7 @@ def create_customer_request(payment, options) post = new_post post[:data][:type] = "customers" post[:data][:attributes] = { - merchantId: @options[:merchant_id], + merchantId: options[:merchant_id], name: payment.name, externalId: "#{SecureRandom.hex(16)}" } diff --git a/test/fixtures.yml b/test/fixtures.yml index 3e694c162f7..1b1cd6bed87 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -234,7 +234,6 @@ dibs: digitzs: app_key: tcwtTux8SPZYO44Gf0UHZH74Z1HSutqCxmIV2PFj2jRc9Poroh3Z3R1BBQNRQ98Q api_key: 0HhRdOU2AsWVEu3gRIKi2UpMMmj8Fj48qggBYTo4 - merchant_id: spreedly-susanswidg-32268973-2091076-148408385 direc_pay: login: 200904281000001 diff --git a/test/remote/gateways/remote_digitzs_test.rb b/test/remote/gateways/remote_digitzs_test.rb index b4ea164f2df..1074d1556f1 100644 --- a/test/remote/gateways/remote_digitzs_test.rb +++ b/test/remote/gateways/remote_digitzs_test.rb @@ -8,11 +8,13 @@ def setup @credit_card = credit_card('4747474747474747', verification_value: '999') @declined_card = credit_card('4616161616161616') @options = { + merchant_id: 'spreedly-susanswidg-32268973-2091076-148408385', billing_address: address, description: 'Store Purchase' } @options_card_split = { + merchant_id: 'spreedly-susanswidg-32268973-2091076-148408385', billing_address: address, description: 'Split Purchase', payment_type: 'card_split', @@ -21,6 +23,7 @@ def setup } @options_token_split = { + merchant_id: 'spreedly-susanswidg-32268973-2091076-148408385', billing_address: address, description: 'Token Split Purchase', payment_type: 'token_split', @@ -96,7 +99,7 @@ def test_successful_store end def test_successful_store_without_billing_address - assert response = @gateway.store(@credit_card, {}) + assert response = @gateway.store(@credit_card, {merchant_id: 'spreedly-susanswidg-32268973-2091076-148408385'}) assert_success response end diff --git a/test/unit/gateways/digitzs_test.rb b/test/unit/gateways/digitzs_test.rb index b7ff3a1ea69..2218d909dae 100644 --- a/test/unit/gateways/digitzs_test.rb +++ b/test/unit/gateways/digitzs_test.rb @@ -4,20 +4,21 @@ class DigitzsTest < Test::Unit::TestCase include CommStub def setup - @gateway = DigitzsGateway.new(api_key: 'api_key', app_key: 'app_key', merchant_id: 'merchant_id') + @gateway = DigitzsGateway.new(api_key: 'api_key', app_key: 'app_key') @credit_card = credit_card @amount = 100 @options = { + merchant_id: 'spreedly-susanswidg-32268973-2091076-148408385', order_id: '1', billing_address: address, description: 'Store Purchase' } @options_with_split = { + merchant_id: 'spreedly-susanswidg-32268973-2091076-148408385', billing_address: address, description: 'Split Purchase', - merchant_id: 'spreedly-susanswidg-32268973-2091076-148408385', payment_type: 'card_split', split_amount: 100, split_merchant_id: 'spreedly-susanswidg-32270590-2095203-148657924' From 90a85193ebb0992f9bffe6b8c8750a88a9adabec Mon Sep 17 00:00:00 2001 From: Aemon Malone Date: Wed, 22 Feb 2017 22:33:59 -0500 Subject: [PATCH 007/677] change money_format from :decimal to :cents --- lib/active_merchant/billing/gateways/checkout.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/checkout.rb b/lib/active_merchant/billing/gateways/checkout.rb index d52d4656fd4..c0ad0cb2ef6 100644 --- a/lib/active_merchant/billing/gateways/checkout.rb +++ b/lib/active_merchant/billing/gateways/checkout.rb @@ -5,7 +5,7 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class CheckoutGateway < Gateway self.default_currency = 'USD' - self.money_format = :decimals + self.money_format = :cents self.supported_countries = ['AD', 'AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GI', 'GL', 'GR', 'HR', 'HU', 'IE', 'IS', 'IL', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SM', 'SK', 'SJ', 'TR', 'VA'] self.supported_cardtypes = [:visa, :master, :american_express, :diners_club] From 89699538faa55efe03c332b9a93de9442451e32a Mon Sep 17 00:00:00 2001 From: Jared Knipp Date: Mon, 27 Feb 2017 12:55:38 -0600 Subject: [PATCH 008/677] Braintree: Add Android Pay meta data fields Braintree requested two additional fields be added for Android Pay requests - `source_card_type` and `source_card_last_four`. From Braintree: For Android Pay, we noticed that when we are passed decrypted tokens, there are two fields missing from your payload. Both fields are related to the details of the source card that is in the user's Android Pay wallet. * source_card_type * source_card_last_four We currently use these fields within our search functionality, as such it'd be super helpful if you could make this update. Closes #2347 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/braintree_blue.rb | 4 +++- test/unit/gateways/braintree_blue_test.rb | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 29422949edc..d46d4a939dc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ * Sage: Default billing state when outside US [shasum] #2340 * TransFirst Transaction Express: Fix improper AVS and CVV response code mapping [shasum] #2342 * Digitzs: Remove merchant_id from gateway credentials [davidsantoso] +* Braintree: Add Android Pay meta data fields [jknipp] #2347 == Version 1.63.0 (February 2, 2017) * Authorize.net: Add #unstore support [jimryan] #2293 diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 0a5ebc1d302..a56a13cec40 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -582,7 +582,9 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) :cryptogram => credit_card_or_vault_id.payment_cryptogram, :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, "0"), :expiration_year => credit_card_or_vault_id.year.to_s, - :google_transaction_id => credit_card_or_vault_id.transaction_id + :google_transaction_id => credit_card_or_vault_id.transaction_id, + :source_card_type => credit_card_or_vault_id.brand, + :source_card_last_four => credit_card_or_vault_id.last_digits } end else diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index fbb95eaa405..489ce3b16b4 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -635,7 +635,9 @@ def test_android_pay_card :expiration_month => '09', :expiration_year => (Time.now.year + 1).to_s, :cryptogram => '111111111100cryptogram', - :google_transaction_id => '1234567890' + :google_transaction_id => '1234567890', + :source_card_type => "visa", + :source_card_last_four => "1111" } ). returns(braintree_result(:id => "transaction_id")) From 4c5c9ee437212a4c1b497aa298de667f51f2c1dc Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Tue, 28 Feb 2017 19:49:59 +0530 Subject: [PATCH 009/677] Kushki: Remove body from void call And remove all associated code changes made earlier to accommodate a http delete call with a body. Closes #2348 --- CHANGELOG | 1 + lib/active_merchant.rb | 1 - .../billing/gateways/kushki.rb | 18 +++++----- lib/active_merchant/connection.rb | 3 -- lib/active_merchant/delete_with_body.rb | 10 ------ test/remote/gateways/remote_kushki_test.rb | 26 +++----------- test/unit/gateways/kushki_test.rb | 35 ++++--------------- 7 files changed, 21 insertions(+), 73 deletions(-) delete mode 100644 lib/active_merchant/delete_with_body.rb diff --git a/CHANGELOG b/CHANGELOG index d46d4a939dc..a81bbb76809 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,7 @@ * TransFirst Transaction Express: Fix improper AVS and CVV response code mapping [shasum] #2342 * Digitzs: Remove merchant_id from gateway credentials [davidsantoso] * Braintree: Add Android Pay meta data fields [jknipp] #2347 +* Kushki: Remove body from void call [shasum] #2348 == Version 1.63.0 (February 2, 2017) * Authorize.net: Add #unstore support [jimryan] #2293 diff --git a/lib/active_merchant.rb b/lib/active_merchant.rb index b53c4bbbed4..66de1834685 100644 --- a/lib/active_merchant.rb +++ b/lib/active_merchant.rb @@ -44,7 +44,6 @@ require 'socket' require 'active_merchant/network_connection_retries' -require 'active_merchant/delete_with_body' require 'active_merchant/connection' require 'active_merchant/post_data' require 'active_merchant/posts_data' diff --git a/lib/active_merchant/billing/gateways/kushki.rb b/lib/active_merchant/billing/gateways/kushki.rb index 3ef46158d0d..98c553951c3 100644 --- a/lib/active_merchant/billing/gateways/kushki.rb +++ b/lib/active_merchant/billing/gateways/kushki.rb @@ -28,9 +28,9 @@ def void(authorization, options={}) action = "void" post = {} - add_invoice(action, post, nil, options) + post[:ticketNumber] = authorization - commit(action, post, authorization) + commit(action, post) end def supports_scrubbing? @@ -132,9 +132,9 @@ def add_reference(post, authorization, options) "void" => "charges" } - def commit(action, params, authorization=nil) + def commit(action, params) response = begin - parse(ssl_invoke(action, params, authorization)) + parse(ssl_invoke(action, params)) rescue ResponseError => e parse(e.response.body) end @@ -151,11 +151,11 @@ def commit(action, params, authorization=nil) ) end - def ssl_invoke(action, params, authorization) + def ssl_invoke(action, params) if action == "void" - ssl_request(:delete_with_body, url(action, authorization), post_data(params), headers(action)) + ssl_request(:delete, url(action, params), nil, headers(action)) else - ssl_post(url(action, authorization), post_data(params), headers(action)) + ssl_post(url(action, params), post_data(params), headers(action)) end end @@ -171,11 +171,11 @@ def post_data(params) params.to_json end - def url(action, authorization) + def url(action, params) base_url = test? ? test_url : live_url if action == "void" - base_url + ENDPOINT[action] + "/" + authorization + base_url + ENDPOINT[action] + "/" + params[:ticketNumber] else base_url + ENDPOINT[action] end diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index 34c4f2991af..7bd0328bee8 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -77,9 +77,6 @@ def request(method, body, headers = {}) # very unambiguously does not. raise ArgumentError, "DELETE requests do not support a request body" if body http.delete(endpoint.request_uri, headers) - when :delete_with_body - debug body - http.request(DeleteWithBody.new(endpoint.request_uri, headers), body) else raise ArgumentError, "Unsupported request method #{method.to_s.upcase}" end diff --git a/lib/active_merchant/delete_with_body.rb b/lib/active_merchant/delete_with_body.rb deleted file mode 100644 index cc03926646b..00000000000 --- a/lib/active_merchant/delete_with_body.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'net/http' -require 'net/https' - -module ActiveMerchant - class DeleteWithBody < Net::HTTPRequest - METHOD = 'DELETE' - REQUEST_HAS_BODY = true - RESPONSE_HAS_BODY = true - end -end diff --git a/test/remote/gateways/remote_kushki_test.rb b/test/remote/gateways/remote_kushki_test.rb index 79fa277a664..3f90d661083 100644 --- a/test/remote/gateways/remote_kushki_test.rb +++ b/test/remote/gateways/remote_kushki_test.rb @@ -52,36 +52,18 @@ def test_failed_purchase end def test_successful_void - options = { - amount: { - subtotal_iva_0: "4.95", - subtotal_iva: "10", - iva: "1.54", - ice: "3.50" - } - } - amount = 100 * ( - options[:amount][:subtotal_iva_0].to_f + - options[:amount][:subtotal_iva].to_f + - options[:amount][:iva].to_f + - options[:amount][:ice].to_f - ) - - purchase = @gateway.purchase(amount, @credit_card, options) + purchase = @gateway.purchase(@amount, @credit_card) assert_success purchase - assert void = @gateway.void(purchase.authorization, options) + assert void = @gateway.void(purchase.authorization) assert_success void assert_equal 'Succeeded', void.message end def test_failed_void - purchase = @gateway.purchase(@amount, @credit_card) - assert_success purchase - - response = @gateway.void(purchase.authorization) + response = @gateway.void("000") assert_failure response - assert_equal 'El monto es zero', response.message + assert_equal 'Tipo de moneda no válida', response.message end def test_invalid_login diff --git a/test/unit/gateways/kushki_test.rb b/test/unit/gateways/kushki_test.rb index 315497841d1..07198fa87b7 100644 --- a/test/unit/gateways/kushki_test.rb +++ b/test/unit/gateways/kushki_test.rb @@ -63,47 +63,26 @@ def test_failed_purchase end def test_successful_void - options = { - amount: { - subtotal_iva_0: "4.95", - subtotal_iva: "10", - iva: "1.54", - ice: "3.50" - } - } - amount = 100 * ( - options[:amount][:subtotal_iva_0].to_f + - options[:amount][:subtotal_iva].to_f + - options[:amount][:iva].to_f + - options[:amount][:ice].to_f - ) - @gateway.expects(:ssl_post).returns(successful_charge_response) @gateway.expects(:ssl_post).returns(successful_token_response) - purchase = @gateway.purchase(amount, @credit_card, options) + purchase = @gateway.purchase(@amount, @credit_card) assert_success purchase @gateway.expects(:ssl_request).returns(successful_void_response) - assert void = @gateway.void(purchase.authorization, options) + assert void = @gateway.void(purchase.authorization) assert_success void assert_equal 'Succeeded', void.message end def test_failed_void - @gateway.expects(:ssl_post).returns(successful_charge_response) - @gateway.expects(:ssl_post).returns(successful_token_response) - - purchase = @gateway.purchase(@amount, @credit_card) - assert_success purchase - @gateway.expects(:ssl_request).returns(failed_void_response) - response = @gateway.void(purchase.authorization) + response = @gateway.void("000") assert_failure response - assert_equal 'El monto es zero', response.message - assert_equal '219', response.error_code + assert_equal 'Tipo de moneda no válida', response.message + assert_equal '205', response.error_code end def test_scrub @@ -247,8 +226,8 @@ def successful_void_response def failed_void_response %( { - "code":"219", - "message":"El monto es zero" + "code":"205", + "message":"Tipo de moneda no válida" } ) end From 3fd27ea420ef82014ebf2d5fe5c793feacf478a9 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Wed, 1 Mar 2017 16:05:24 -0500 Subject: [PATCH 010/677] FirstdataE4: Add remote test for Network Tokenization Credit Card purchase --- test/remote/gateways/remote_firstdata_e4_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/remote/gateways/remote_firstdata_e4_test.rb b/test/remote/gateways/remote_firstdata_e4_test.rb index 80cce2aaf04..ffcadb90518 100755 --- a/test/remote/gateways/remote_firstdata_e4_test.rb +++ b/test/remote/gateways/remote_firstdata_e4_test.rb @@ -25,6 +25,17 @@ def test_successful_purchase assert_success response end + def test_successful_purchase_with_network_tokenization + @credit_card = network_tokenization_credit_card('4242424242424242', + payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + verification_value: nil + ) + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Transaction Normal - Approved', response.message + assert_false response.authorization.blank? + end + def test_successful_purchase_with_specified_currency options_with_specified_currency = @options.merge({currency: 'GBP'}) assert response = @gateway.purchase(@amount, @credit_card, options_with_specified_currency) From 42657fca69a3fcfca408f652763b68dd755c9881 Mon Sep 17 00:00:00 2001 From: David Perry Date: Thu, 2 Mar 2017 15:46:05 -0500 Subject: [PATCH 011/677] TransFirst Transaction Express: Don't send order_id with refunds Production refund calls to the gateway are inexplicably throwing a invalid content error for this element. We cannot reproduced the error in their sandbox testing environment. For now, we will prevent the element being sent with refunds. Closes #2350 --- CHANGELOG | 1 + .../billing/gateways/trans_first_transaction_express.rb | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a81bbb76809..fc0ba8be65f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,6 +22,7 @@ * Digitzs: Remove merchant_id from gateway credentials [davidsantoso] * Braintree: Add Android Pay meta data fields [jknipp] #2347 * Kushki: Remove body from void call [shasum] #2348 +* TransFirst Transaction Express: Don't send order_id with refunds [curiousepic] #2350 == Version 1.63.0 (February 2, 2017) * Authorize.net: Add #unstore support [jimryan] #2293 diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb index 7ca84cda458..5c1908a47cc 100644 --- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb @@ -248,7 +248,6 @@ def refund(amount, authorization, options={}) request = build_xml_transaction_request do |doc| add_amount(doc, amount) add_original_transaction_data(doc, transaction_id) - add_order_number(doc, options) end commit(:refund, request) From 8d0902782acda84332bf1ff34120df174b436976 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Thu, 2 Mar 2017 12:24:56 +0530 Subject: [PATCH 012/677] WePay: Update API version Closes #2349 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/wepay.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index fc0ba8be65f..482714ad0fc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,7 @@ * Braintree: Add Android Pay meta data fields [jknipp] #2347 * Kushki: Remove body from void call [shasum] #2348 * TransFirst Transaction Express: Don't send order_id with refunds [curiousepic] #2350 +* WePay: Update API version [shasum] #2349 == Version 1.63.0 (February 2, 2017) * Authorize.net: Add #unstore support [jimryan] #2293 diff --git a/lib/active_merchant/billing/gateways/wepay.rb b/lib/active_merchant/billing/gateways/wepay.rb index 650891a1bc1..343ea0c731e 100644 --- a/lib/active_merchant/billing/gateways/wepay.rb +++ b/lib/active_merchant/billing/gateways/wepay.rb @@ -10,7 +10,7 @@ class WepayGateway < Gateway self.default_currency = 'USD' self.display_name = 'WePay' - API_VERSION = "2016-12-07" + API_VERSION = "2017-02-01" def initialize(options = {}) requires!(options, :client_id, :account_id, :access_token) From c063a49f0f7909111c23e1d5d01cc128fb9a33ed Mon Sep 17 00:00:00 2001 From: Josh Reeves Date: Thu, 29 Sep 2016 23:48:22 -0700 Subject: [PATCH 013/677] USA ePay Advanced: Add quick_update_customer action Closes #2229 --- CHANGELOG | 1 + .../billing/gateways/usa_epay_advanced.rb | 123 ++++++++++++++++-- .../gateways/remote_usa_epay_advanced_test.rb | 8 ++ test/unit/gateways/usa_epay_advanced_test.rb | 12 ++ 4 files changed, 135 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 482714ad0fc..9ea1028fa3b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,7 @@ * Kushki: Remove body from void call [shasum] #2348 * TransFirst Transaction Express: Don't send order_id with refunds [curiousepic] #2350 * WePay: Update API version [shasum] #2349 +* USA ePay Advanced: Add quick_update_customer action [joshreeves] #2229 == Version 1.63.0 (February 2, 2017) * Authorize.net: Add #unstore support [jimryan] #2293 diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb index 497f4b54e5d..627d2de95d2 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb @@ -77,12 +77,14 @@ class UsaEpayAdvancedGateway < Gateway self.homepage_url = 'http://www.usaepay.com/' self.display_name = 'USA ePay Advanced SOAP Interface' - CUSTOMER_OPTIONS = { + CUSTOMER_PROFILE_OPTIONS = { :id => [:string, 'CustomerID'], # merchant assigned number :notes => [:string, 'Notes'], :data => [:string, 'CustomData'], - :url => [:string, 'URL'], - # Recurring Billing + :url => [:string, 'URL'] + } #:nodoc: + + CUSTOMER_RECURRING_BILLING_OPTIONS = { :enabled => [:boolean, 'Enabled'], :schedule => [:string, 'Schedule'], :number_left => [:integer, 'NumLeft'], @@ -92,18 +94,24 @@ class UsaEpayAdvancedGateway < Gateway :user => [:string, 'User'], :source => [:string, 'Source'], :send_receipt => [:boolean, 'SendReceipt'], - :receipt_note => [:string, 'ReceiptNote'], - # Point of Sale + :receipt_note => [:string, 'ReceiptNote'] + } #:nodoc: + + CUSTOMER_POINT_OF_SALE_OPTIONS = { :price_tier => [:string, 'PriceTier'], :tax_class => [:string, 'TaxClass'], :lookup_code => [:string, 'LookupCode'] } #:nodoc: - ADDRESS_OPTIONS = { + CUSTOMER_OPTIONS = [ + CUSTOMER_PROFILE_OPTIONS, + CUSTOMER_RECURRING_BILLING_OPTIONS, + CUSTOMER_POINT_OF_SALE_OPTIONS + ].inject(:merge) #:nodoc: + + COMMON_ADDRESS_OPTIONS = { :first_name => [:string, 'FirstName'], :last_name => [:string, 'LastName'], - :address1 => [:string, 'Street'], - :address2 => [:string, 'Street2'], :city => [:string, 'City'], :state => [:string, 'State'], :zip => [:string, 'Zip'], @@ -114,6 +122,32 @@ class UsaEpayAdvancedGateway < Gateway :company => [:string, 'Company'] } #:nodoc: + ADDRESS_OPTIONS = [ + COMMON_ADDRESS_OPTIONS, + { + :address1 => [:string, 'Street'], + :address2 => [:string, 'Street2'], + } + ].inject(:merge) #:nodoc + + CUSTOMER_UPDATE_DATA_FIELDS = [ + CUSTOMER_PROFILE_OPTIONS, + CUSTOMER_RECURRING_BILLING_OPTIONS, + COMMON_ADDRESS_OPTIONS, + { + :address1 => [:string, 'Address'], + :address2 => [:string, 'Address2'], + }, + { + :card_number => [:string, 'CardNumber'], + :card_exp => [:string, 'CardExp'], + :account => [:string, 'Account'], + :routing => [:string, 'Routing'], + :check_format => [:string, 'CheckFormat'], + :record_type => [:string, 'RecordType'], + } + ].inject(:merge) #:nodoc + CUSTOMER_TRANSACTION_REQUEST_OPTIONS = { :command => [:string, 'Command'], :ignore_duplicate => [:boolean, 'IgnoreDuplicate'], @@ -354,6 +388,55 @@ def update_customer(options={}) commit(__method__, request) end + # Update a customer by replacing only the provided fields. + # + # ==== Required + # * :customer_number -- customer to update + # * :update_data -- FieldValue array of fields to retrieve + # * :first_name + # * :last_name + # * :id + # * :company + # * :address + # * :address2 + # * :city + # * :state + # * :zip + # * :country + # * :phone + # * :fax + # * :email + # * :url + # * :receipt_note + # * :send_receipt + # * :notes + # * :description + # * :order_id + # * :enabled + # * :schedule + # * :next + # * :num_left + # * :amount + # * :custom_data + # * :source + # * :user + # * :card_number + # * :card_exp + # * :account + # * :routing + # * :check_format or :record_type + # + # ==== Response + # * #message -- boolean; Returns true if successful. Exception thrown all failures. + # + def quick_update_customer(options={}) + requires! options, :customer_number + requires! options, :update_data + + request = build_request(__method__, options) + commit(__method__, request) + end + # Enable a customer for recurring billing. # # Note: Customer does not need to have all recurring parameters to succeed. @@ -1019,6 +1102,14 @@ def build_delete_customer(soap, options) build_customer(soap, options, 'deleteCustomer') end + def build_quick_update_customer(soap, options) + soap.tag! "ns1:quickUpdateCustomer" do + build_token soap, options + build_tag soap, :integer, 'CustNum', options[:customer_number] + build_field_value_array soap, "UpdateData", "FieldValue", options[:update_data], CUSTOMER_UPDATE_DATA_FIELDS + end + end + def build_add_customer_payment_method(soap, options) soap.tag! "ns1:addCustomerPaymentMethod" do build_token soap, options @@ -1408,6 +1499,21 @@ def build_shipping_address(soap, options) end end + def build_field_value_array(soap, tag_name, type, custom_data, fields) + soap.tag! tag_name, 'SOAP-ENC:arryType' => "xsd:#{type}[#{options.length}]", 'xsi:type' => "ns1:#{type}Array" do + custom_data.each do |k, v| + build_field_value soap, fields[k][1], v, fields[k][0] if fields.keys.include? k + end + end + end + + def build_field_value(soap, field, value, value_type) + soap.FieldValue 'xsi:type' => 'ns1:FieldValue' do + build_tag soap, :string, 'Field', field + build_tag soap, value_type, 'Value', value + end + end + def build_line_items(soap, options) # TODO end @@ -1511,4 +1617,3 @@ def parse_element(node) end end end - diff --git a/test/remote/gateways/remote_usa_epay_advanced_test.rb b/test/remote/gateways/remote_usa_epay_advanced_test.rb index 6bac49c18e1..de314da965b 100644 --- a/test/remote/gateways/remote_usa_epay_advanced_test.rb +++ b/test/remote/gateways/remote_usa_epay_advanced_test.rb @@ -175,6 +175,14 @@ def test_update_customer assert response.params['update_customer_return'] end + def test_quick_update_customer + response = @gateway.add_customer(@options.merge(@customer_options)) + customer_number = response.params['add_customer_return'] + + response = @gateway.quick_update_customer({customer_number: customer_number, update_data: @update_customer_options}) + assert response.params['quick_update_customer_return'] + end + def test_enable_disable_customer response = @gateway.add_customer(@options.merge(@customer_options)) customer_number = response.params['add_customer_return'] diff --git a/test/unit/gateways/usa_epay_advanced_test.rb b/test/unit/gateways/usa_epay_advanced_test.rb index 91c6d13e2b4..10c8967b96a 100644 --- a/test/unit/gateways/usa_epay_advanced_test.rb +++ b/test/unit/gateways/usa_epay_advanced_test.rb @@ -199,6 +199,18 @@ def test_successful_update_customer assert_nil response.authorization end + def test_successful_quick_update_customer + @gateway.expects(:ssl_post).returns(successful_customer_response('quickUpdateCustomer')) + + assert response = @gateway.quick_update_customer({customer_number: @options[:customer_number], update_data: @customer_options}) + assert_instance_of Response, response + assert response.test? + assert_success response + assert_equal 'true', response.params['quick_update_customer_return'] + assert_equal 'true', response.message + assert_nil response.authorization + end + def test_successful_enable_customer @options.merge!(@standard_transaction_options) @gateway.expects(:ssl_post).returns(successful_customer_response('enableCustomer')) From 82777b87dd1d26193a1ad4bc27df828580bb2bc4 Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Mon, 6 Mar 2017 14:31:29 -0500 Subject: [PATCH 014/677] Release version 1.64.0 --- CHANGELOG | 30 ++++++++++++++++-------------- lib/active_merchant/version.rb | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9ea1028fa3b..c2790e03c5b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,28 +1,30 @@ = ActiveMerchant CHANGELOG == HEAD + +== Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 -* Omise: Enable Japan, JPY and JCB support [zdk] #2284 +* Authorize.net: Use new `unsupported_feature` standard error code [jasonwebster] #2322 +* Base Gateway: Add new `unsupported_feature` standard error code [jasonwebster] #2322 * Braintree Blue: Pass cardholder_name with card [curiousepic] #2324 -* Paymill: Send new required fields on tokenization requests [tschelabaumann] #2279 +* Braintree: Add Android Pay meta data fields [jknipp] #2347 +* CardStream: Add additional of currencies [shasum] #2337 +* Credorax: Return failure response reason [shasum] #2341 +* Digitzs: Add gateway [davidsantoso] +* Digitzs: Remove merchant_id from gateway credentials [davidsantoso] * GlobalCollect: Pass options to Refund [curiousepic] #2330 -* PayU LATAM: Let Refund take amount value [curiousepic] #2334 -* Linkpoint: Raise ArgumentError when trying to instantiate without `:pem` [jasonwebster] #2329 -* Base Gateway: Add new `unsupported_feature` standard error code [jasonwebster] #2322 -* Authorize.net: Use new `unsupported_feature` standard error code [jasonwebster] #2322 * Kushki: Add new gateway [shasum] #2326 +* Kushki: Remove body from void call [shasum] #2348 +* Linkpoint: Raise ArgumentError when trying to instantiate without `:pem` [jasonwebster] #2329 +* Omise: Enable Japan, JPY and JCB support [zdk] #2284 * PayU LATAM: Count pending refunds as succeeded [curiousepic] #2336 -* Stripe: Remove idempotency key from verify [shasum] #2335 -* CardStream: Add additional of currencies [shasum] #2337 +* PayU LATAM: Let Refund take amount value [curiousepic] #2334 +* Paymill: Send new required fields on tokenization requests [tschelabaumann] #2279 * Revert "Authorize.net: Allow settings to be passed for CIM purchases" [curiousepic] #2339 -* Digitzs: Add gateway [davidsantoso] -* Credorax: Return failure response reason [shasum] #2341 * Sage: Default billing state when outside US [shasum] #2340 -* TransFirst Transaction Express: Fix improper AVS and CVV response code mapping [shasum] #2342 -* Digitzs: Remove merchant_id from gateway credentials [davidsantoso] -* Braintree: Add Android Pay meta data fields [jknipp] #2347 -* Kushki: Remove body from void call [shasum] #2348 +* Stripe: Remove idempotency key from verify [shasum] #2335 * TransFirst Transaction Express: Don't send order_id with refunds [curiousepic] #2350 +* TransFirst Transaction Express: Fix improper AVS and CVV response code mapping [shasum] #2342 * WePay: Update API version [shasum] #2349 * USA ePay Advanced: Add quick_update_customer action [joshreeves] #2229 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 722aa6a8aa8..016beff7024 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.63.0" + VERSION = "1.64.0" end From ed1192a35e185877c5843ffe1558e82479ba037e Mon Sep 17 00:00:00 2001 From: David Santoso Date: Tue, 7 Mar 2017 14:45:58 -0500 Subject: [PATCH 015/677] JetPay: Adjust refund and void transaction types Closes #2356 --- CHANGELOG | 1 + .../billing/gateways/jetpay.rb | 8 +++--- test/remote/gateways/remote_jetpay_test.rb | 25 ++++++++++++++----- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c2790e03c5b..3676730b88e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* JetPay: Adjust refund and void transaction types [davidsantoso] #2356 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/jetpay.rb b/lib/active_merchant/billing/gateways/jetpay.rb index 03fe5f2b828..d322258a0df 100644 --- a/lib/active_merchant/billing/gateways/jetpay.rb +++ b/lib/active_merchant/billing/gateways/jetpay.rb @@ -183,11 +183,9 @@ def credit(money, transaction_id_or_card, options = {}) end def refund(money, reference, options = {}) - params = reference.split(";") - transaction_id = params[0] - token = params[3] + transaction_id, approval, original_amount, token = reference.split(";") credit_card = options[:credit_card] - commit(money, build_credit_request('CREDIT', money, transaction_id, credit_card, token, options)) + commit(money, build_credit_request('VOID', money, transaction_id, credit_card, token, options)) end def supports_scrubbing @@ -256,7 +254,7 @@ def build_capture_request(transaction_id, money, options) end def build_void_request(money, transaction_id, approval, token, options) - build_xml_request('VOID', options, transaction_id) do |xml| + build_xml_request('REVERSEAUTH', options, transaction_id) do |xml| xml.tag! 'Approval', approval xml.tag! 'TotalAmount', amount(money) xml.tag! 'Token', token if token diff --git a/test/remote/gateways/remote_jetpay_test.rb b/test/remote/gateways/remote_jetpay_test.rb index d528a3694b5..7f77b4b39c5 100644 --- a/test/remote/gateways/remote_jetpay_test.rb +++ b/test/remote/gateways/remote_jetpay_test.rb @@ -75,22 +75,18 @@ def test_ud_fields_on_capture assert_success capture end - - def test_void - # must void a valid auth + def test_successful_void assert auth = @gateway.authorize(9900, @credit_card, @options) assert_success auth assert_equal 'APPROVED', auth.message assert_not_nil auth.authorization assert_not_nil auth.params["approval"] - assert void = @gateway.void(auth.authorization) assert_success void end - def test_refund_with_token - + def test_refund_after_purchase assert response = @gateway.purchase(9900, @credit_card, @options) assert_success response assert_equal "APPROVED", response.message @@ -105,6 +101,23 @@ def test_refund_with_token assert_equal [response.params['transaction_id'], response.params["approval"], 9900, response.params["token"]].join(";"), response.authorization end + def test_refund_after_authorize_capture + assert auth = @gateway.authorize(9900, @credit_card, @options) + assert_success auth + assert_equal 'APPROVED', auth.message + assert_not_nil auth.authorization + assert_not_nil auth.params["approval"] + + assert capture = @gateway.capture(9900, auth.authorization) + assert_success capture + + assert refund = @gateway.refund(9900, capture.authorization) + assert_success refund + assert_not_nil(refund.authorization) + assert_not_nil(refund.params["approval"]) + assert_equal [refund.params['transaction_id'], refund.params["approval"], 9900, refund.params["token"]].join(";"), refund.authorization + end + def test_refund_backwards_compatible # no need for csv card = credit_card('4242424242424242', :verification_value => nil) From 91860c115f866714a299c9b1989795642b28fb57 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Fri, 10 Mar 2017 15:12:38 -0500 Subject: [PATCH 016/677] GlobalCollect: Truncate firstName field to 15 characters --- CHANGELOG | 1 + .../billing/gateways/global_collect.rb | 4 ++-- test/fixtures.yml | 6 +++--- .../gateways/remote_global_collect_test.rb | 16 ++++++++++++---- test/unit/gateways/global_collect_test.rb | 13 +++++++++++++ 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3676730b88e..4ae22d2e24c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * JetPay: Adjust refund and void transaction types [davidsantoso] #2356 +* GlobalCollect: Truncate firstName field to 15 characters [davidsantoso] == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 8c1245cc8e6..9a0b9142f62 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -131,8 +131,8 @@ def add_customer_data(post, options, payment = nil) if payment post["order"]["customer"]["personalInformation"] = { "name" => { - "firstName" => payment.first_name, - "surname" => payment.last_name + "firstName" => payment.first_name[0..14], + "surname" => payment.last_name[0..69] } } end diff --git a/test/fixtures.yml b/test/fixtures.yml index 1b1cd6bed87..28b2467d6a2 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -337,9 +337,9 @@ garanti: password: "123qweASD" global_collect: - merchant_id: 1428 - api_key_id: 96f16a41890565d0 - secret_api_key: g/VQ432G02bFpwg/6EY7uiPRSZxKMbQ87Kal716XORA= + merchant_id: 2196 + api_key_id: c91d6752cbbf9cf1 + secret_api_key: xHjQr5gL9Wcihkqoj4w/UQugdSCNXM2oUQHG5C82jy4= global_transport: global_user_name: "USERNAME" diff --git a/test/remote/gateways/remote_global_collect_test.rb b/test/remote/gateways/remote_global_collect_test.rb index e0b0dc32857..26146b679ca 100644 --- a/test/remote/gateways/remote_global_collect_test.rb +++ b/test/remote/gateways/remote_global_collect_test.rb @@ -33,6 +33,14 @@ def test_successful_purchase_with_more_options assert_equal 'Succeeded', response.message end + def test_successful_purchase_with_very_long_name + credit_card = credit_card('4567350000427977', { first_name: "thisisaverylongfirstname"}) + + response = @gateway.purchase(@amount, credit_card, @options) + assert_success response + assert_equal 'Succeeded', response.message + end + def test_failed_purchase response = @gateway.purchase(@rejected_amount, @declined_card, @options) assert_failure response @@ -65,7 +73,7 @@ def test_partial_capture def test_failed_capture response = @gateway.capture(@amount, '123', @options) assert_failure response - assert_equal 'UNKNOWN_PAYMENT_ID', response.message + assert_match %r{The given paymentId is not correct}, response.message end # Because payments are not fully authorized immediately, refunds can only be @@ -89,7 +97,7 @@ def test_failed_capture def test_failed_refund response = @gateway.refund(@amount, '123') assert_failure response - assert_equal 'UNKNOWN_PAYMENT_ID', response.message + assert_match %r{The given paymentId is not correct}, response.message end def test_successful_void @@ -104,7 +112,7 @@ def test_successful_void def test_failed_void response = @gateway.void('123') assert_failure response - assert_equal 'UNKNOWN_PAYMENT_ID', response.message + assert_match %r{The given paymentId is not correct}, response.message end def test_successful_verify @@ -124,7 +132,7 @@ def test_invalid_login response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_match %r{MISSING_OR_INVALID_AUTHORIZATION}, response.message + assert_match %r{The authorization was missing or invalid}, response.message end def test_transcript_scrubbing diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb index 5fd92020abb..04043fdf4bf 100644 --- a/test/unit/gateways/global_collect_test.rb +++ b/test/unit/gateways/global_collect_test.rb @@ -45,6 +45,19 @@ def test_purchase_does_not_run_capture_if_authorize_auto_captured assert_equal 1, response.responses.size end + def test_trucates_first_name_to_15_chars + credit_card = credit_card('4567350000427977', { first_name: "thisisaverylongfirstname" }) + + response = stub_comms do + @gateway.authorize(@accepted_amount, credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match(/thisisaverylong/, data) + end.respond_with(successful_authorize_response) + + assert_success response + assert_equal "000000142800000000920000100001", response.authorization + end + def test_failed_authorize response = stub_comms do @gateway.authorize(@rejected_amount, @declined_card, @options) From cbca048252e6d1e082b99bf15c93c95adb2ece55 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Thu, 2 Mar 2017 17:04:42 -0500 Subject: [PATCH 017/677] Qvalent: Add soft descriptor fields. Add authorize, capture, and void --- CHANGELOG | 1 + .../billing/gateways/qvalent.rb | 45 +++++++- test/fixtures.yml | 99 ++++++++++++++++- test/remote/gateways/remote_qvalent_test.rb | 89 ++++++++++++++- test/unit/gateways/qvalent_test.rb | 103 +++++++++++++++++- 5 files changed, 328 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4ae22d2e24c..3ea8f884757 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * JetPay: Adjust refund and void transaction types [davidsantoso] #2356 * GlobalCollect: Truncate firstName field to 15 characters [davidsantoso] +* Qvalent: Add soft descriptor fields. Add authorize, capture, and void [davidsantoso] == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/qvalent.rb b/lib/active_merchant/billing/gateways/qvalent.rb index 12ba65e879a..539c5d1514f 100644 --- a/lib/active_merchant/billing/gateways/qvalent.rb +++ b/lib/active_merchant/billing/gateways/qvalent.rb @@ -13,7 +13,7 @@ class QvalentGateway < Gateway self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners] def initialize(options={}) - requires!(options, :username, :password, :merchant) + requires!(options, :username, :password, :merchant, :pem, :pem_password) super end @@ -24,19 +24,52 @@ def purchase(amount, payment_method, options={}) add_payment_method(post, payment_method) add_verification_value(post, payment_method) add_customer_data(post, options) + add_soft_descriptors(post, options) commit("capture", post) end + def authorize(amount, payment_method, options={}) + post = {} + add_invoice(post, amount, options) + add_order_number(post, options) + add_payment_method(post, payment_method) + add_verification_value(post, payment_method) + add_customer_data(post, options) + add_soft_descriptors(post, options) + + commit("preauth", post) + end + + def capture(amount, authorization, options={}) + post = {} + add_invoice(post, amount, options) + add_reference(post, authorization, options) + add_customer_data(post, options) + add_soft_descriptors(post, options) + + commit("captureWithoutAuth", post) + end + def refund(amount, authorization, options={}) post = {} add_invoice(post, amount, options) add_reference(post, authorization, options) add_customer_data(post, options) + add_soft_descriptors(post, options) commit("refund", post) end + def void(authorization, options={}) + post = {} + add_reference(post, authorization, options) + add_customer_data(post, options) + add_soft_descriptors(post, options) + + commit("reversal", post) + end + def store(payment_method, options = {}) post = {} add_payment_method(post, payment_method) @@ -62,6 +95,16 @@ def scrub(transcript) CURRENCY_CODES["AUD"] = "AUD" CURRENCY_CODES["INR"] = "INR" + def add_soft_descriptors(post, options) + post["customer.merchantName"] = options[:customer_merchant_name] if options[:customer_merchant_name] + post["customer.merchantStreetAddress"] = options[:customer_merchant_street_address] if options[:customer_merchant_street_address] + post["customer.merchantLocation"] = options[:customer_merchant_location] if options[:customer_merchant_location] + post["customer.merchantState"] = options[:customer_merchant_state] if options[:customer_merchant_state] + post["customer.merchantCountry"] = options[:customer_merchant_country] if options[:customer_merchant_country] + post["customer.merchantPostCode"] = options[:customer_merchant_post_code] if options[:customer_merchant_post_code] + post["customer.subMerchantId"] = options[:customer_sub_merchant_id] if options[:customer_sub_merchant_id] + end + def add_invoice(post, money, options) post["order.amount"] = amount(money) post["card.currency"] = CURRENCY_CODES[options[:currency] || currency(money)] diff --git a/test/fixtures.yml b/test/fixtures.yml index 28b2467d6a2..bf5f6bd5238 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -830,9 +830,102 @@ quickpay_with_api_key: version: 7 qvalent: - username: TEST - password: TEST - merchant: TEST + username: "QRSL" + password: "QRSLTEST" + merchant: 24436057 + pem_password: "Ceic4s4ig" + pem: | + Bag Attributes + localKeyID: 01 00 00 00 + friendlyName: CCAPI Client Certificate + Key Attributes + X509v3 Key Usage: 10 + -----BEGIN RSA PRIVATE KEY----- + MIIEpAIBAAKCAQEAtgPNEzLEFAm2CXCiaJeEFQxzkxXHn+Lyf65FjTDIOMknXnmw + gtoPTrFHtDVLJqWHaccLg9/lMKHivW1iGPTeZj4Uke07EcmIaDQD3Gq33gukDbgx + d5QDN+mEPRs0TF6FHlKKELKGIZdw4BlM+Jg7hebwZnBC/g9cetmB3ny99g0e5ANk + pPESguo+HTFk5vwHkLjMtDB+0zM5y6AyU6z+PaCDr3Q7+vcR50kQLNxpSWH1Il1g + BewIHAroN4lJjPvKLnDWvK5SsxW9XB14gLAyQg6qCHDYOdTsdiG6BFG1eijT+3W7 + iXm8uTDiXSj+PiADEeKvnbEsWqXu+DvUsR/m8wIDAQABAoIBADtC/ZBUpRbJGqX0 + MEzRmEWqKi8nljlukPoVabvQuEAU7maKRHg2O2mpuujnuTI6Dt7X2d30FhFBhCuc + 46WwhIDRkaz5ipP+BBW5adBoRrlbHO0CnciLPokD1PR4WQzMcZcv1JgfKCDjx/KP + CkqedjLgwED6KDXEFp5BF1GzV742dfux0Bgq+5kzLp0uAe0+ADxGll1Fx1wWbP/e + 4XSTWz4P1q3fmGAJB7fgXcfdp+Yri1x0RNDjBUa6YsR5fFVZBXcFEmPcRGbcsO3J + ApJTrskt4H0rQafcx/LmUj3pBVsl/tcyMBHHGHUb0N5pKypf2X+79IYhV+b9K9Ll + 5EHVV+ECgYEA8TTci5PsysRvzN5HIgpfsd3ZK/JrTkJ2z3Xx2HFL9XU8EAx9gO5h + Qa7CnJY+myoes+x90I7uKqfJdB1JDq2Bek6Jfj8stVd/YTtrOMt7WhHc6OW2S+qY + TpvtdeoVcJ2rKGFyo5/mj0aO+Hg1i6wxsIhDPKvSEqSqUrbjmLi5AfkCgYEAwS2V + IVzmMZIaRg0FxRccWl/XgpK9JNVjNr4PRiSkjsbFktVNLkbBcFOvrbmPPkBuHW8t + XDK6goRcNraxkkzB81mx0glW/zHfEQS4GWuQQEqIWwBfC9QEvC+AlGLaNhQYMleC + omLzTDTkBPtQSc72H0ov8TpowgeyM1+U2uozq0sCgYEAm+Szag64KzEcpQdAaDLW + OIoO04WBbvor+dfb8C0Bj+ouYJ0B/HOVLjN6GmRMoFJvt4/wnPvT2IPLAx3uWusu + 1NKvsIW6KpYbgMc7fGCfH86NvYTB9nzv5VaH+f7JzphIx/d7dV9iT1WmD9b5nIU1 + NEhNVIgkZOJCJuWHYex5vlkCgYAF4uqxapBFIGuWiN0NJWgixNrfSrNixPHSADac + 747oHtx0XfWNHHDWiGZJB+d6gSIZ2YJrVcxjH79jl2uPxrD+RlRpzwkMm6ttbFRj + yehKXTsMctVymdJPHa9wVhbKIRCfsBT198fsIYx1LmdC6ICNcYhGdH4us2dVs2ro + xMwwQwKBgQDgNA9bGhiajsOI//M9ndH8KZCGdOoYM+6JBurHKX2fF8INRX+sxWix + DbUr9rQXkDrX1CY5RNs9kZpNxLJpOSHOpYlIytnGghYTrU1nzXoKLVopkO9Oz1A6 + WzrOd297XdEoyEbAeCgcLr2WtjMiFHonesjeWIgbqXSKZ+W1oek0vQ== + -----END RSA PRIVATE KEY----- + Bag Attributes + localKeyID: 01 00 00 00 + friendlyName: CCAPI Client Certificate + subject=/CN=Returned & Services League of Australia (Queensland Branch) - Support/OU=IT/O=Returned & Services League of Australia (Queensland Branch)/ST=NSW/C=AU/EMAILADDRESS=pp_support@qvalent.com + issuer=/CN=eQvalent/OU=Operations/O=QValent Pty Ltd/L=Wallsend/ST=NSW/C=AU + -----BEGIN CERTIFICATE----- + MIIE0DCCA7igAwIBAgIEWLX2pzANBgkqhkiG9w0BAQUFADBwMQswCQYDVQQGEwJB + VTEMMAoGA1UECBMDTlNXMREwDwYDVQQHEwhXYWxsc2VuZDEYMBYGA1UEChMPUVZh + bGVudCBQdHkgTHRkMRMwEQYDVQQLEwpPcGVyYXRpb25zMREwDwYDVQQDEwhlUXZh + bGVudDAeFw0xNzAyMjgyMjE2MDdaFw0xOTAyMjgyMjE2MDdaMIHtMSUwIwYJKoZI + hvcNAQkBFhZwcF9zdXBwb3J0QHF2YWxlbnQuY29tMQswCQYDVQQGEwJBVTEMMAoG + A1UECAwDTlNXMUgwRgYDVQQKDD9SZXR1cm5lZCAmIzM4OyBTZXJ2aWNlcyBMZWFn + dWUgb2YgQXVzdHJhbGlhIChRdWVlbnNsYW5kIEJyYW5jaCkxCzAJBgNVBAsMAklU + MVIwUAYDVQQDDElSZXR1cm5lZCAmIzM4OyBTZXJ2aWNlcyBMZWFndWUgb2YgQXVz + dHJhbGlhIChRdWVlbnNsYW5kIEJyYW5jaCkgLSBTdXBwb3J0MIIBIjANBgkqhkiG + 9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtgPNEzLEFAm2CXCiaJeEFQxzkxXHn+Lyf65F + jTDIOMknXnmwgtoPTrFHtDVLJqWHaccLg9/lMKHivW1iGPTeZj4Uke07EcmIaDQD + 3Gq33gukDbgxd5QDN+mEPRs0TF6FHlKKELKGIZdw4BlM+Jg7hebwZnBC/g9cetmB + 3ny99g0e5ANkpPESguo+HTFk5vwHkLjMtDB+0zM5y6AyU6z+PaCDr3Q7+vcR50kQ + LNxpSWH1Il1gBewIHAroN4lJjPvKLnDWvK5SsxW9XB14gLAyQg6qCHDYOdTsdiG6 + BFG1eijT+3W7iXm8uTDiXSj+PiADEeKvnbEsWqXu+DvUsR/m8wIDAQABo4HzMIHw + MBMGA1UdJQQMMAoGCCsGAQUFBwMCMB0GA1UdDgQWBBTujPN/magozRJ8XJxAVYPw + v5/HsDCBqQYDVR0jBIGhMIGegBQ2QKUf9O24xKZrWTyUqRmZeq04IqF0pHIwcDEL + MAkGA1UEBhMCQVUxDDAKBgNVBAgTA05TVzERMA8GA1UEBxMIV2FsbHNlbmQxGDAW + BgNVBAoTD1FWYWxlbnQgUHR5IEx0ZDETMBEGA1UECxMKT3BlcmF0aW9uczERMA8G + A1UEAxMIZVF2YWxlbnSCEG49SZXSVViNQE7XcOvVjwYwDgYDVR0PAQH/BAQDAgTw + MA0GCSqGSIb3DQEBBQUAA4IBAQCQwdv8D4B5sRnA9/ppDfwlix6omzh/SdA3SI4m + BNcImoqzBEq1OokdWKDkRQXlP6822aJn8fzDMV1/YsmomC4fT0wdag0DvBEvRlhy + roQRFjQai6CKRUgoH/p0q4EwxKLOa/H0kix+cn6Nszl07wu6YtHzvISXf4MC72au + /xTf/qwXI1uXnQghb4sFM9/ubYlsNEFiNHt7CHBK7ivhFGcT7eI9rmSOTMKsZfmV + pALJ58Ynz08xLYRMq54FxzwhN3CZ7AWRA+9JpzJacJ6lzHX9Y4FAjzRzoqn5h/IN + dgMIW+HoTgCe4+M1aDx2A0SKJCSK9tYZCYSsPMi9JXdLDU+k + -----END CERTIFICATE----- + Bag Attributes + localKeyID: 02 00 00 00 + subject=/CN=eQvalent/OU=Operations/O=QValent Pty Ltd/L=Wallsend/ST=NSW/C=AU + issuer=/CN=eQvalent/OU=Operations/O=QValent Pty Ltd/L=Wallsend/ST=NSW/C=AU + -----BEGIN CERTIFICATE----- + MIIDuzCCAqOgAwIBAgIQbj1JldJVWI1ATtdw69WPBjANBgkqhkiG9w0BAQUFADBw + MQswCQYDVQQGEwJBVTEMMAoGA1UECBMDTlNXMREwDwYDVQQHEwhXYWxsc2VuZDEY + MBYGA1UEChMPUVZhbGVudCBQdHkgTHRkMRMwEQYDVQQLEwpPcGVyYXRpb25zMREw + DwYDVQQDEwhlUXZhbGVudDAeFw0xMDA0MDcwNTUyMThaFw0zMDA0MDcwNjAyMTda + MHAxCzAJBgNVBAYTAkFVMQwwCgYDVQQIEwNOU1cxETAPBgNVBAcTCFdhbGxzZW5k + MRgwFgYDVQQKEw9RVmFsZW50IFB0eSBMdGQxEzARBgNVBAsTCk9wZXJhdGlvbnMx + ETAPBgNVBAMTCGVRdmFsZW50MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC + AQEAxKuwonFlg53dyb0zFyS0JPUbxKmHwBDZcTT78eV4hs9TveOR34yT9xv+y7R1 + GbUdtXxidGaXW6lfkWvVnS1mkDbj84OY2FzRTHeKuNmkcPddQDUgE+gaOGV6GKW7 + v/s5jMt6pz075teLKvNO2Gs2alpPl4NYU5zJfa+AGFzqE1z7Zxbl9N/Sc6Y8ZbWI + IGWKJFeaTic8tE05hIGuWw1KfxbhH0QMKnTSzW5fJi4Pce3iIftkCTjIXdTg+El8 + 9b+Jn5VMk+bQZQiusPbPbHZTvAADX/WCUuzAlFqyyNtutJmUlD/TiEB12YYp9R6U + 1MGRvC9+c+sz2bBccW3c+Zm7cQIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0T + AQH/BAUwAwEB/zAdBgNVHQ4EFgQUNkClH/TtuMSma1k8lKkZmXqtOCIwEAYJKwYB + BAGCNxUBBAMCAQAwDQYJKoZIhvcNAQEFBQADggEBAAJRMGZzxO3lcTXoFdmOpo8P + Ptf/agwrlGT8krwKcZt42YZ98VoIaCTI83kkACYlTlkTTNkDdHtAwF7ROteZmbfQ + 5ky0nqZTpdQ2IPfGXpxcMIrGqrSJ6GbLTxrm0kXDH6TgYeY1dVTHtJD9wEgWwdI9 + coRkKQVjK/QucPuVX0uoRppCz0rCiJfCQf2825BrcbaY4HyDHvNxRXKV9ECuYwrk + HYDy3bnYWVB2ekk8xOEiocjQI3T//V36ZfiGubKlUZ4xsSed410hkLtB6ttCyZB1 + RFjxWKtn9pXbM1PLmUXCkKQnSJSeD1K0NjV+g8KFChTEgmhnLogyF/7YYw/amfc= + -----END CERTIFICATE----- raven_pac_net: user: ernest diff --git a/test/remote/gateways/remote_qvalent_test.rb b/test/remote/gateways/remote_qvalent_test.rb index e18f376c613..2c596497839 100644 --- a/test/remote/gateways/remote_qvalent_test.rb +++ b/test/remote/gateways/remote_qvalent_test.rb @@ -7,6 +7,7 @@ def setup @amount = 100 @credit_card = credit_card("4000100011112224") @declined_card = credit_card("4000000000000000") + @expired_card = credit_card("4111111113444494") @options = { order_id: generate_unique_id, @@ -19,14 +20,14 @@ def test_invalid_login gateway = QvalentGateway.new( username: "bad", password: "bad", - merchant: "101" + merchant: "101", + pem: "bad", + pem_password: "bad" ) - authentication_exception = assert_raise ActiveMerchant::ResponseError do + assert_raise ActiveMerchant::ClientCertificateError do gateway.purchase(@amount, @credit_card, @options) end - response = authentication_exception.response - assert_match(%r{Error 403: Missing authentication}, response.body) end def test_successful_purchase @@ -35,6 +36,24 @@ def test_successful_purchase assert_equal "Succeeded", response.message end + def test_successful_purchase_with_soft_descriptors + options = { + order_id: generate_unique_id, + billing_address: address, + description: "Store Purchase", + customer_merchant_name: "Some Merchant", + customer_merchant_street_address: "42 Wallaby Way", + customer_merchant_location: "Sydney", + customer_merchant_country: "AU", + customer_merchant_post_code: "2060", + customer_merchant_state: "NSW" + } + + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_equal "Succeeded", response.message + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response @@ -42,6 +61,68 @@ def test_failed_purchase assert_equal Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code end + def test_successful_authorize + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + assert_equal "Succeeded", response.message + end + + def test_failed_authorize + response = @gateway.authorize(@amount, @expired_card, @options) + assert_failure response + assert_equal "Expired card", response.message + end + + def test_successful_capture + assert auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + assert_equal "Succeeded", auth.message + assert_not_nil auth.authorization + + assert capture = @gateway.capture(@amount, auth.authorization, @options.merge({ order_id: generate_unique_id })) + assert_success capture + end + + def test_failed_capture + assert auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + assert_equal "Succeeded", auth.message + assert_not_nil auth.authorization + + assert capture = @gateway.capture(@amount, '', @options.merge({ order_id: generate_unique_id })) + assert_failure capture + end + + def test_successful_partial_capture + assert auth = @gateway.authorize(200, @credit_card, @options) + assert_success auth + assert_equal "Succeeded", auth.message + assert_not_nil auth.authorization + + assert capture = @gateway.capture(100, auth.authorization, @options.merge({ order_id: generate_unique_id })) + assert_success capture + end + + def test_successful_void + assert auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + assert_equal "Succeeded", auth.message + assert_not_nil auth.authorization + + assert void = @gateway.void(auth.authorization, @options.merge({ order_id: generate_unique_id })) + assert_success void + end + + def test_failed_void + assert auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + assert_equal "Succeeded", auth.message + assert_not_nil auth.authorization + + assert void = @gateway.void('', @options.merge({ order_id: generate_unique_id })) + assert_failure void + end + def test_successful_refund response = @gateway.purchase(@amount, @credit_card, @options) assert_success response diff --git a/test/unit/gateways/qvalent_test.rb b/test/unit/gateways/qvalent_test.rb index 5c3ff6d6155..d58d10e3f81 100644 --- a/test/unit/gateways/qvalent_test.rb +++ b/test/unit/gateways/qvalent_test.rb @@ -7,7 +7,9 @@ def setup @gateway = QvalentGateway.new( username: "username", password: "password", - merchant: "merchant" + merchant: "merchant", + pem: "pem", + pem_password: "pempassword" ) @credit_card = credit_card @@ -36,6 +38,48 @@ def test_failed_purchase assert response.test? end + def test_successful_authorize + response = stub_comms do + @gateway.authorize(@amount, @credit_card) + end.respond_with(successful_authorize_response) + + assert_success response + + assert_equal "21c74c8f08bca415b5373022e6194f74", response.authorization + assert response.test? + end + + def test_failed_authorize + response = stub_comms do + @gateway.authorize(@amount, @credit_card) + end.respond_with(failed_authorize_response) + + assert_failure response + assert_equal "Expired card",response.message + assert response.test? + end + + def test_successful_capture + response = stub_comms do + @gateway.capture(@amount, "auth") + end.respond_with(successful_capture_response) + + assert_success response + + assert_equal "fedf9ea13afa46872592d62e8cdcb0a3", response.authorization + assert response.test? + end + + def test_failed_capture + response = stub_comms do + @gateway.capture(@amount, "") + end.respond_with(failed_capture_response) + + assert_failure response + assert_equal "Invalid Parameters - order.authId: Required field", response.message + assert response.test? + end + def test_successful_refund response = stub_comms do @gateway.purchase(@amount, @credit_card) @@ -61,6 +105,27 @@ def test_failed_refund assert_failure response end + def test_successful_void + response = stub_comms do + @gateway.void("auth") + end.respond_with(successful_void_response) + + assert_success response + + assert_equal "67686b64b544335815002fd85704c8a1", response.authorization + assert response.test? + end + + def test_failed_void + response = stub_comms do + @gateway.void("") + end.respond_with(failed_void_response) + + assert_failure response + assert_equal "Invalid Parameters - customer.originalOrderNumber: Required field", response.message + assert response.test? + end + def test_successful_store response = stub_comms do @gateway.store(@credit_card) @@ -111,6 +176,42 @@ def failed_purchase_response ) end + def successful_authorize_response + %( + response.summaryCode=0\r\nresponse.responseCode=08\r\nresponse.text=Honour with identification\r\nresponse.referenceNo=731560096\r\nresponse.orderNumber=21c74c8f08bca415b5373022e6194f74\r\nresponse.RRN=731560096 \r\nresponse.settlementDate=20170314\r\nresponse.transactionDate=14-MAR-2017 05:41:44\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.previousTxn=0\r\nresponse.authId=C3JVDS\r\nresponse.end\r\n + ) + end + + def failed_authorize_response + %( + response.summaryCode=1\r\nresponse.responseCode=54\r\nresponse.text=Expired card\r\nresponse.referenceNo=731560142\r\nresponse.orderNumber=d48cb6104266ed1a51647576d8948c57\r\nresponse.RRN=731560142 \r\nresponse.settlementDate=20170314\r\nresponse.transactionDate=14-MAR-2017 05:45:18\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.previousTxn=0\r\nresponse.end\r\n + ) + end + + def successful_capture_response + %( + response.summaryCode=0\r\nresponse.responseCode=00\r\nresponse.text=Approved or completed successfully\r\nresponse.referenceNo=731560097\r\nresponse.orderNumber=fedf9ea13afa46872592d62e8cdcb0a3\r\nresponse.RRN=731560097\r\nresponse.settlementDate=20170314\r\nresponse.transactionDate=14-MAR-2017 05:45:52\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.previousTxn=0\r\nresponse.end\r\n + ) + end + + def failed_capture_response + %( + response.summaryCode=3\r\nresponse.responseCode=QA\r\nresponse.text=Invalid Parameters - order.authId: Required field\r\nresponse.previousTxn=0\r\nresponse.end\r\n + ) + end + + def successful_void_response + %( + response.summaryCode=0\r\nresponse.responseCode=00\r\nresponse.text=Approved or completed successfully\r\nresponse.referenceNo=731560098\r\nresponse.orderNumber=67686b64b544335815002fd85704c8a1\r\nresponse.settlementDate=20170314\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.previousTxn=0\r\nresponse.end\r\n + ) + end + + def failed_void_response + %( + response.summaryCode=3\r\nresponse.responseCode=QA\r\nresponse.text=Invalid Parameters - customer.originalOrderNumber: Required field\r\nresponse.previousTxn=0\r\nresponse.end\r\n + ) + end + def successful_refund_response %( response.summaryCode=0\r\nresponse.responseCode=08\r\nresponse.text=Honour with identification\r\nresponse.referenceNo=723907127\r\nresponse.orderNumber=f1a65bfe-f95b-4e06-b800-6d3b3a771238\r\nresponse.RRN=723907127 \r\nresponse.settlementDate=20150228\r\nresponse.transactionDate=28-FEB-2015 09:37:20\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.previousTxn=0\r\nresponse.end\r\n From f17c4da5f5de1919083f0686077a2297c4daa21f Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Wed, 30 Nov 2016 10:52:33 +0100 Subject: [PATCH 018/677] Adyen: Add Adyen v18 gateway Closes https://github.com/activemerchant/active_merchant/pull/2272 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 228 ++++++++++++ test/fixtures.yml | 5 + test/remote/gateways/remote_adyen_test.rb | 220 ++++++++++++ test/unit/gateways/adyen_test.rb | 327 ++++++++++++++++++ 5 files changed, 781 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/adyen.rb create mode 100644 test/remote/gateways/remote_adyen_test.rb create mode 100644 test/unit/gateways/adyen_test.rb diff --git a/CHANGELOG b/CHANGELOG index 3ea8f884757..3d9c64a6e6a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * JetPay: Adjust refund and void transaction types [davidsantoso] #2356 * GlobalCollect: Truncate firstName field to 15 characters [davidsantoso] * Qvalent: Add soft descriptor fields. Add authorize, capture, and void [davidsantoso] +* Adyen: Add Adyen v18 gateway [adyenpayments] #2272 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb new file mode 100644 index 00000000000..744331a0245 --- /dev/null +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -0,0 +1,228 @@ +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class AdyenGateway < Gateway + + # we recommend setting up merchant-specific endpoints. + # https://docs.adyen.com/developers/api-manual#apiendpoints + self.test_url = 'https://pal-test.adyen.com/pal/servlet/Payment/v18' + self.live_url = 'https://pal-live.adyen.com/pal/servlet/Payment/v18' + + self.supported_countries = ['AD','AE','AF','AG','AI','AL','AM','AO','AQ','AR','AS','AT','AU','AW','AX','AZ','BA','BB','BD','BE','BF','BG','BH','BI','BJ','BL','BM','BN','BO','BQ','BR','BS','BT','BV','BW','BY','BZ','CA','CC','CD','CF','CG','CH','CI','CK','CL','CM','CN','CO','CR','CU','CV','CW','CX','CY','CZ','DE','DJ','DK','DM','DO','DZ','EC','EE','EG','EH','ER','ES','ET','FI','FJ','FK','FM','FO','FR','GA','GB','GD','GE','GF','GG','GH','GI','GL','GM','GN','GP','GQ','GR','GS','GT','GU','GW','GY','HK','HM','HN','HR','HT','HU','ID','IE','IL','IM','IN','IO','IQ','IR','IS','IT','JE','JM','JO','JP','KE','KG','KH','KI','KM','KN','KP','KR','KW','KY','KZ','LA','LB','LC','LI','LK','LR','LS','LT','LU','LV','LY','MA','MC','MD','ME','MF','MG','MH','MK','ML','MM','MN','MO','MP','MQ','MR','MS','MT','MU','MV','MW','MX','MY','MZ','NA','NC','NE','NF','NG','NI','NL','NO','NP','NR','NU','NZ','OM','PA','PE','PF','PG','PH','PK','PL','PM','PN','PR','PS','PT','PW','PY','QA','RE','RO','RS','RU','RW','SA','SB','SC','SD','SE','SG','SH','SI','SJ','SK','SL','SM','SN','SO','SR','SS','ST','SV','SX','SY','SZ','TC','TD','TF','TG','TH','TJ','TK','TL','TM','TN','TO','TR','TT','TV','TW','TZ','UA','UG','UM','US','UY','UZ','VA','VC','VE','VG','VI','VN','VU','WF','WS','YE','YT','ZA','ZM','ZW'] + self.default_currency = 'USD' + self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb, :dankort, :maestro, :discover] + + self.money_format = :cents + + self.homepage_url = 'https://www.adyen.com/' + self.display_name = 'Adyen' + + STANDARD_ERROR_CODE_MAPPING = { + '101' => STANDARD_ERROR_CODE[:incorrect_number], + '103' => STANDARD_ERROR_CODE[:invalid_cvc], + '131' => STANDARD_ERROR_CODE[:incorrect_address], + '132' => STANDARD_ERROR_CODE[:incorrect_address], + '133' => STANDARD_ERROR_CODE[:incorrect_address], + '134' => STANDARD_ERROR_CODE[:incorrect_address], + '135' => STANDARD_ERROR_CODE[:incorrect_address], + } + + def initialize(options={}) + requires!(options, :username, :password, :merchant_account) + @username, @password, @merchant_account = options.values_at(:username, :password, :merchant_account) + super + end + + def purchase(money, payment, options={}) + MultiResponse.run do |r| + r.process{authorize(money, payment, options)} + r.process{capture(money, r.authorization, options)} + end + end + + def authorize(money, payment, options={}) + requires!(options, :reference) + post = init_post(options) + add_invoice(post, money, options) + add_payment(post, payment) + add_extra_data(post, options) + add_address(post, options) + commit('authorise', post) + end + + def capture(money, authorization, options={}) + post = init_post(options) + add_invoice_for_modification(post, money, authorization, options) + add_references(post, authorization, options) + commit('capture', post) + end + + def refund(money, authorization, options={}) + post = init_post(options) + add_invoice_for_modification(post, money, authorization, options) + add_references(post, authorization, options) + commit('refund', post) + end + + def void(authorization, options={}) + post = init_post(options) + add_references(post, authorization, options) + commit('cancel', post) + end + + def verify(credit_card, options={}) + MultiResponse.run(:use_first_response) do |r| + r.process { authorize(100, credit_card, options) } + r.process(:ignore_result) { void(r.authorization, options) } + end + end + + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). + gsub(%r(("number\\?":\\?")[^"]*)i, '\1[FILTERED]'). + gsub(%r(("cvc\\?":\\?")[^"]*)i, '\1[FILTERED]') + end + + private + + def add_extra_data(post, options) + post[:shopperEmail] = options[:shopper_email] if options[:shopper_email] + post[:shopperIP] = options[:shopper_ip] if options[:shopper_ip] + post[:shopperReference] = options[:shopper_reference] if options[:shopper_reference] + post[:fraudOffset] = options[:fraud_offset] if options[:fraud_offset] + post[:selectedBrand] = options[:selected_brand] if options[:selected_brand] + post[:deliveryDate] = options[:delivery_date] if options[:delivery_date] + post[:merchantOrderReference] = options[:merchant_order_reference] if options[:merchant_order_reference] + post[:shopperInteraction] = options[:shopper_interaction] if options[:shopper_interaction] + end + + def add_address(post, options) + return unless post[:card] && post[:card].kind_of?(Hash) + if address = options[:billing_address] || options[:address] + post[:card][:billingAddress] = {} + post[:card][:billingAddress][:street] = address[:address1] if address[:address1] + post[:card][:billingAddress][:houseNumberOrName] = address[:address2] if address[:address2] + post[:card][:billingAddress][:postalCode] = address[:zip] if address[:zip] + post[:card][:billingAddress][:city] = address[:city] if address[:city] + post[:card][:billingAddress][:stateOrProvince] = address[:state] if address[:state] + post[:card][:billingAddress][:country] = address[:country] if address[:country] + end + end + + def add_invoice(post, money, options) + amount = { + value: amount(money), + currency: options[:currency] || currency(money) + } + post[:reference] = options[:reference] + post[:amount] = amount + end + + def add_invoice_for_modification(post, money, authorization, options) + amount = { + value: amount(money), + currency: options[:currency] || currency(money) + } + post[:modificationAmount] = amount + end + + def add_payment(post, payment) + card = { + expiryMonth: payment.month, + expiryYear: payment.year, + holderName: payment.name, + number: payment.number, + cvc: payment.verification_value + } + card.delete_if{|k,v| v.blank? } + requires!(card, :expiryMonth, :expiryYear, :holderName, :number, :cvc) + post[:card] = card + end + + def add_references(post, authorization, options = {}) + post[:originalReference] = authorization + post[:reference] = options[:reference] + end + + def parse(body) + return {} if body.blank? + JSON.parse(body) + end + + def commit(action, parameters) + url = (test? ? test_url : live_url) + + begin + raw_response = ssl_post("#{url}/#{action.to_s}", post_data(action, parameters), request_headers) + response = parse(raw_response) + rescue ResponseError => e + raw_response = e.response.body + response = parse(raw_response) + end + + success = success_from(action, response) + Response.new( + success, + message_from(action, response), + response, + authorization: authorization_from(response), + test: test?, + error_code: success ? nil : error_code_from(response) + ) + + end + + def basic_auth + Base64.strict_encode64("#{@username}:#{@password}") + end + + def request_headers + { + "Content-Type" => "application/json", + "Authorization" => "Basic #{basic_auth}" + } + end + + def success_from(action, response) + case action.to_s + when 'authorise' + ['Authorised', 'Received', 'RedirectShopper'].include?(response['resultCode']) + when 'capture', 'refund', 'cancel' + response['response'] == "[#{action}-received]" + else + false + end + end + + def message_from(action, response) + case action.to_s + when 'authorise' + response['refusalReason'] || response['resultCode'] || response['message'] + when 'capture', 'refund', 'cancel' + response['response'] || response['message'] + end + end + + def authorization_from(response) + response['pspReference'] + end + + def init_post(options = {}) + {merchantAccount: options[:merchant_account] || @merchant_account} + end + + def post_data(action, parameters = {}) + JSON.generate(parameters) + end + + def error_code_from(response) + STANDARD_ERROR_CODE_MAPPING[response['errorCode']] + end + + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index bf5f6bd5238..c71b9f80230 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -11,6 +11,11 @@ # Paste any required PEM certificates after the pem key. # +adyen: + username: '' + password: '' + merchant_account: '' + allied_wallet: site_id: site_id merchant_id: merchant_id diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb new file mode 100644 index 00000000000..5be62e1d320 --- /dev/null +++ b/test/remote/gateways/remote_adyen_test.rb @@ -0,0 +1,220 @@ +require 'test_helper' + +class RemoteAdyenTest < Test::Unit::TestCase + def setup + @gateway = AdyenGateway.new(fixtures(:adyen)) + + @amount = 100 + + @credit_card = credit_card('4111111111111111', + :month => 8, + :year => 2018, + :first_name => 'John', + :last_name => 'Smith', + :verification_value => '737', + :brand => 'visa' + ) + + @declined_card = credit_card('4000300011112220') + + @options = { + reference: '345123', + shopper_email: "john.smith@test.com", + shopper_ip: "77.110.174.153", + shopper_reference: "John Smith", + :billing_address => address(), + } + end + + def test_successful_authorize + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + assert_equal 'Authorised', response.message + end + + def test_failed_authorize + response = @gateway.authorize(@amount, @declined_card, @options) + assert_failure response + assert_equal 'Refused', response.message + end + + def test_successful_purchase + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal '[capture-received]', response.message + end + + def test_successful_purchase_with_more_options + options = @options.merge!(fraudOffset: '1') + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_equal '[capture-received]', response.message + end + + def test_failed_purchase + response = @gateway.purchase(@amount, @declined_card, @options) + assert_failure response + assert_equal 'Refused', response.message + end + + def test_successful_authorize_and_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + assert_equal '[capture-received]', capture.message + end + + def test_partial_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount-1, auth.authorization) + assert_success capture + end + + def test_failed_capture + response = @gateway.capture(@amount, '') + assert_failure response + assert_equal 'Original pspReference required for this operation', response.message + end + + def test_successful_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount, purchase.authorization) + assert_success refund + assert_equal '[refund-received]', refund.message + end + + def test_partial_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount-1, purchase.authorization) + assert_success refund + end + + def test_failed_refund + response = @gateway.refund(@amount, '') + assert_failure response + assert_equal 'Original pspReference required for this operation', response.message + end + + def test_successful_void + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert void = @gateway.void(auth.authorization) + assert_success void + assert_equal '[cancel-received]', void.message + end + + def test_failed_void + response = @gateway.void('') + assert_failure response + assert_equal 'Original pspReference required for this operation', response.message + end + + def test_successful_verify + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_match 'Authorised', response.message + end + + def test_failed_verify + response = @gateway.verify(@declined_card, @options) + assert_failure response + assert_match 'Refused', response.message + end + + def test_invalid_login + gateway = AdyenGateway.new(username: '', password: '', merchant_account: '') + + response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + end + + def test_incorrect_number_for_purchase + card = credit_card('4242424242424241') + assert response = @gateway.purchase(@amount, card, @options) + assert_failure response + assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + end + + def test_invalid_number_for_purchase + card = credit_card('-1') + assert response = @gateway.purchase(@amount, card, @options) + assert_failure response + assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + end + + def test_invalid_expiry_month_for_purchase + card = credit_card('4242424242424242', month: 16) + assert response = @gateway.purchase(@amount, card, @options) + assert_failure response + assert_equal 'Expiry month should be between 1 and 12 inclusive Card', response.message + end + + def test_invalid_expiry_year_for_purchase + card = credit_card('4242424242424242', year: 'xx') + assert response = @gateway.purchase(@amount, card, @options) + assert_failure response + assert response.message.include?('Expiry year should be a 4 digit number greater than') + end + + def test_invalid_cvc_for_purchase + card = credit_card('4242424242424242', verification_value: -1) + assert response = @gateway.purchase(@amount, card, @options) + assert_failure response + assert_match Gateway::STANDARD_ERROR_CODE[:invalid_cvc], response.error_code + end + + def test_missing_address_for_purchase + @options[:billing_address].delete(:address1) + @options[:billing_address].delete(:address2) + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code + end + + def test_missing_city_for_purchase + @options[:billing_address].delete(:city) + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code + end + + def test_missing_house_number_or_name_for_purchase + @options[:billing_address].delete(:address2) + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code + end + + def test_invalid_country_for_purchase + @options[:billing_address][:country] = '' + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code + end + + def test_invalid_state_for_purchase + @options[:billing_address][:state] = '' + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code + end +end diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb new file mode 100644 index 00000000000..488b2f3025c --- /dev/null +++ b/test/unit/gateways/adyen_test.rb @@ -0,0 +1,327 @@ +require 'test_helper' + +class AdyenTest < Test::Unit::TestCase + include CommStub + + def setup + @gateway = AdyenGateway.new( + username: 'ws@adyenmerchant.com', + password: 'password', + merchant_account: 'merchantAccount' + ) + + @credit_card = credit_card('4111111111111111', + :month => 8, + :year => 2018, + :first_name => 'Test', + :last_name => 'Card', + :verification_value => '737', + :brand => 'visa' + ) + + @amount = 100 + + @options = { + :billing_address => address(), + reference: '345123' + } + end + + def test_successful_authorize + @gateway.expects(:ssl_post).returns(successful_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + + assert_equal '7914775043909934', response.authorization + assert response.test? + end + + def test_failed_authorize + @gateway.expects(:ssl_post).returns(failed_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_equal 'Expired Card', response.message + assert_failure response + end + + def test_successful_capture + @gateway.expects(:ssl_post).returns(successful_capture_response) + response = @gateway.capture(@amount, 'pspReference') + assert_equal '8814775564188305', response.authorization + assert_success response + assert response.test? + end + + def test_failed_capture + @gateway.expects(:ssl_post).returns(failed_capture_response) + response = @gateway.capture(nil, '') + assert_nil response.authorization + assert_equal 'Original pspReference required for this operation', response.message + assert_failure response + end + + def test_successful_purchase + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.respond_with(successful_authorize_response, successful_capture_response) + assert_success response + assert_equal '8814775564188305', response.authorization + assert response.test? + end + + def test_failed_purchase + @gateway.expects(:ssl_post).returns(failed_purchase_response) + + response = @gateway.purchase(@amount, credit_card('400111'), @options) + assert_failure response + + assert_equal AdyenGateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + end + + def test_successful_refund + @gateway.expects(:ssl_post).returns(successful_refund_response) + response = @gateway.refund(@amount, 'pspReference') + assert_equal '8514775559925128', response.authorization + assert_equal '[refund-received]', response.message + assert response.test? + end + + def test_failed_refund + @gateway.expects(:ssl_post).returns(failed_refund_response) + response = @gateway.refund(@amount, '') + assert_nil response.authorization + assert_equal 'Original pspReference required for this operation', response.message + assert_failure response + end + + def test_successful_void + @gateway.expects(:ssl_post).returns(successful_void_response) + response = @gateway.void('pspReference') + assert_equal '8614775821628806', response.authorization + assert_equal '[cancel-received]', response.message + assert response.test? + end + + def test_failed_void + @gateway.expects(:ssl_post).returns(failed_void_response) + response = @gateway.void('') + assert_equal 'Original pspReference required for this operation', response.message + assert_failure response + end + + def test_successful_verify + response = stub_comms do + @gateway.verify(@credit_card, @options) + end.respond_with(successful_verify_response) + assert_success response + assert_equal '7914776426645103', response.authorization + assert_equal 'Authorised', response.message + assert response.test? + end + + def test_failed_verify + response = stub_comms do + @gateway.verify(@credit_card, @options) + end.respond_with(failed_verify_response) + assert_failure response + assert_equal '7914776433387947', response.authorization + assert_equal 'Refused', response.message + assert response.test? + end + + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + + def test_add_address + post = {:card => {:billingAddress => {}}} + @gateway.send(:add_address, post, @options) + assert_equal @options[:billing_address][:address1], post[:card][:billingAddress][:street] + assert_equal @options[:billing_address][:address2], post[:card][:billingAddress][:houseNumberOrName] + assert_equal @options[:billing_address][:zip], post[:card][:billingAddress][:postalCode] + assert_equal @options[:billing_address][:city], post[:card][:billingAddress][:city] + assert_equal @options[:billing_address][:state], post[:card][:billingAddress][:stateOrProvince] + assert_equal @options[:billing_address][:country], post[:card][:billingAddress][:country] + end + + + private + + def pre_scrubbed + <<-PRE_SCRUBBED + opening connection to pal-test.adyen.com:443... + opened + starting SSL for pal-test.adyen.com:443... + SSL established + <- "POST /pal/servlet/Payment/v18/authorise HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Basic d3NfMTYzMjQ1QENvbXBhbnkuRGFuaWVsYmFra2Vybmw6eXU0aD50ZlxIVEdydSU1PDhxYTVMTkxVUw==\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: pal-test.adyen.com\r\nContent-Length: 308\r\n\r\n" + <- "{\"merchantAccount\":\"DanielbakkernlNL\",\"reference\":\"345123\",\"amount\":{\"value\":\"100\",\"currency\":\"USD\"},\"card\":{\"expiryMonth\":8,\"expiryYear\":2018,\"holderName\":\"John Smith\",\"number\":\"4111111111111111\",\"cvc\":\"737\"},\"shopperEmail\":\"john.smith@test.com\",\"shopperIP\":\"77.110.174.153\",\"shopperReference\":\"John Smith\"}" + -> "HTTP/1.1 200 OK\r\n" + -> "Date: Thu, 27 Oct 2016 11:37:13 GMT\r\n" + -> "Server: Apache\r\n" + -> "Set-Cookie: JSESSIONID=C0D66C19173B3491D862B8FDBFD72FD7.test3e; Path=/pal/; Secure; HttpOnly\r\n" + -> "pspReference: 8514775682339577\r\n" + -> "Connection: close\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Content-Type: application/json;charset=utf-8\r\n" + -> "\r\n" + -> "50\r\n" + reading 80 bytes... + -> "" + -> "{\"pspReference\":\"8514775682339577\",\"resultCode\":\"Authorised\",\"authCode\":\"31845\"}" + read 80 bytes + reading 2 bytes... + -> "" + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + PRE_SCRUBBED + end + + def post_scrubbed + <<-POST_SCRUBBED + opening connection to pal-test.adyen.com:443... + opened + starting SSL for pal-test.adyen.com:443... + SSL established + <- "POST /pal/servlet/Payment/v18/authorise HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Basic [FILTERED]==\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: pal-test.adyen.com\r\nContent-Length: 308\r\n\r\n" + <- "{\"merchantAccount\":\"DanielbakkernlNL\",\"reference\":\"345123\",\"amount\":{\"value\":\"100\",\"currency\":\"USD\"},\"card\":{\"expiryMonth\":8,\"expiryYear\":2018,\"holderName\":\"John Smith\",\"number\":\"[FILTERED]\",\"cvc\":\"[FILTERED]\"},\"shopperEmail\":\"john.smith@test.com\",\"shopperIP\":\"77.110.174.153\",\"shopperReference\":\"John Smith\"}" + -> "HTTP/1.1 200 OK\r\n" + -> "Date: Thu, 27 Oct 2016 11:37:13 GMT\r\n" + -> "Server: Apache\r\n" + -> "Set-Cookie: JSESSIONID=C0D66C19173B3491D862B8FDBFD72FD7.test3e; Path=/pal/; Secure; HttpOnly\r\n" + -> "pspReference: 8514775682339577\r\n" + -> "Connection: close\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Content-Type: application/json;charset=utf-8\r\n" + -> "\r\n" + -> "50\r\n" + reading 80 bytes... + -> "" + -> "{\"pspReference\":\"8514775682339577\",\"resultCode\":\"Authorised\",\"authCode\":\"31845\"}" + read 80 bytes + reading 2 bytes... + -> "" + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + POST_SCRUBBED + end + + def failed_purchase_response + <<-RESPONSE + { + "status": 422, + "errorCode": "101", + "message": "Invalid card number", + "errorType": "validation", + "pspReference": "8514775645144049" + } + RESPONSE + end + + def successful_authorize_response + <<-RESPONSE + { + "pspReference":"7914775043909934", + "resultCode":"Authorised", + "authCode":"50055" + } + RESPONSE + end + + def failed_authorize_response + <<-RESPONSE + { + "pspReference": "8514775559925128", + "refusalReason": "Expired Card", + "resultCode": "Refused" + } + RESPONSE + end + + def successful_capture_response + <<-RESPONSE + { + "pspReference": "8814775564188305", + "response": "[capture-received]" + } + RESPONSE + end + + def failed_capture_response + <<-RESPONSE + { + "status": 422, + "errorCode": "167", + "message": "Original pspReference required for this operation", + "errorType": "validation" + } + RESPONSE + end + + def successful_refund_response + <<-RESPONSE + { + "pspReference": "8514775559925128", + "response": "[refund-received]" + } + RESPONSE + end + + def failed_refund_response + <<-RESPONSE + { + "status":422, + "errorCode":"167", + "message":"Original pspReference required for this operation", + "errorType":"validation" + } + RESPONSE + end + + def successful_void_response + <<-RESPONSE + { + "pspReference":"8614775821628806", + "response":"[cancel-received]" + } + RESPONSE + end + + def failed_void_response + <<-RESPONSE + { + "status":422, + "errorCode":"167", + "message":"Original pspReference required for this operation", + "errorType":"validation" + } + RESPONSE + end + + def successful_verify_response + <<-RESPONSE + { + "pspReference":"7914776426645103", + "resultCode":"Authorised", + "authCode":"31265" + } + RESPONSE + end + + def failed_verify_response + <<-RESPONSE + { + "pspReference":"7914776433387947", + "refusalReason":"Refused", + "resultCode":"Refused" + } + RESPONSE + end +end From fa82102345007d3cae5689c4502304490565cc34 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Tue, 14 Mar 2017 22:16:53 +0530 Subject: [PATCH 019/677] Pin: Add metadata optional field Pin API does not have an assigned field to map `order_id` Metadata is a placeholder for user defined key value pairs Closes #2363 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/pin.rb | 5 +++++ test/remote/gateways/remote_pin_test.rb | 16 +++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 3d9c64a6e6a..326445ec700 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * GlobalCollect: Truncate firstName field to 15 characters [davidsantoso] * Qvalent: Add soft descriptor fields. Add authorize, capture, and void [davidsantoso] * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 +* Pin: Add metadata optional field [shasum] #2363 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/pin.rb b/lib/active_merchant/billing/gateways/pin.rb index 5c9b5b86e27..a7e04216977 100644 --- a/lib/active_merchant/billing/gateways/pin.rb +++ b/lib/active_merchant/billing/gateways/pin.rb @@ -29,6 +29,7 @@ def purchase(money, creditcard, options = {}) add_creditcard(post, creditcard) add_address(post, creditcard, options) add_capture(post, options) + add_metadata(post, options) commit(:post, 'charges', post, options) end @@ -141,6 +142,10 @@ def add_creditcard(post, creditcard) end end + def add_metadata(post, options) + post[:metadata] = options[:metadata] if options[:metadata] + end + def headers(params = {}) result = { "Content-Type" => "application/json", diff --git a/test/remote/gateways/remote_pin_test.rb b/test/remote/gateways/remote_pin_test.rb index 8ad2f9ce593..88d41346671 100644 --- a/test/remote/gateways/remote_pin_test.rb +++ b/test/remote/gateways/remote_pin_test.rb @@ -24,6 +24,20 @@ def test_successful_purchase assert_equal true, response.params['response']['captured'] end + def test_successful_purchase_with_metadata + options_with_metadata = { + metadata: { + order_id: generate_unique_id, + purchase_number: generate_unique_id + } + } + response = @gateway.purchase(@amount, @credit_card, @options.merge(options_with_metadata)) + assert_success response + assert_equal true, response.params['response']['captured'] + assert_equal options_with_metadata[:metadata][:order_id], response.params['response']['metadata']['order_id'] + assert_equal options_with_metadata[:metadata][:purchase_number], response.params['response']['metadata']['purchase_number'] + end + def test_successful_authorize_and_capture authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization @@ -162,7 +176,7 @@ def test_transcript_scrubbing @gateway.purchase(@amount, @credit_card, @options) end clean_transcript = @gateway.scrub(transcript) - + assert_scrubbed(@credit_card.number, clean_transcript) assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript) end From 2bdc1ed66b21c4caa2f36014145317533bc7838e Mon Sep 17 00:00:00 2001 From: David Santoso Date: Tue, 14 Mar 2017 16:56:10 -0400 Subject: [PATCH 020/677] Revert "JetPay: Adjust refund and void transaction types" This reverts commit ed1192a35e185877c5843ffe1558e82479ba037e. There was a bit of confusion around the documentation in that VOID transaction type only works on same day captured transactions before they have settled. If the transaction has settled then a CREDIT transaction type is required. However it should be noted that it appears as though there's no way to refund a previous CAPT transaction so that should be fixed at a later point if it is possible. --- CHANGELOG | 1 - .../billing/gateways/jetpay.rb | 8 +++--- test/remote/gateways/remote_jetpay_test.rb | 25 +++++-------------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 326445ec700..a5ead18c729 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,6 @@ = ActiveMerchant CHANGELOG == HEAD -* JetPay: Adjust refund and void transaction types [davidsantoso] #2356 * GlobalCollect: Truncate firstName field to 15 characters [davidsantoso] * Qvalent: Add soft descriptor fields. Add authorize, capture, and void [davidsantoso] * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/jetpay.rb b/lib/active_merchant/billing/gateways/jetpay.rb index d322258a0df..03fe5f2b828 100644 --- a/lib/active_merchant/billing/gateways/jetpay.rb +++ b/lib/active_merchant/billing/gateways/jetpay.rb @@ -183,9 +183,11 @@ def credit(money, transaction_id_or_card, options = {}) end def refund(money, reference, options = {}) - transaction_id, approval, original_amount, token = reference.split(";") + params = reference.split(";") + transaction_id = params[0] + token = params[3] credit_card = options[:credit_card] - commit(money, build_credit_request('VOID', money, transaction_id, credit_card, token, options)) + commit(money, build_credit_request('CREDIT', money, transaction_id, credit_card, token, options)) end def supports_scrubbing @@ -254,7 +256,7 @@ def build_capture_request(transaction_id, money, options) end def build_void_request(money, transaction_id, approval, token, options) - build_xml_request('REVERSEAUTH', options, transaction_id) do |xml| + build_xml_request('VOID', options, transaction_id) do |xml| xml.tag! 'Approval', approval xml.tag! 'TotalAmount', amount(money) xml.tag! 'Token', token if token diff --git a/test/remote/gateways/remote_jetpay_test.rb b/test/remote/gateways/remote_jetpay_test.rb index 7f77b4b39c5..d528a3694b5 100644 --- a/test/remote/gateways/remote_jetpay_test.rb +++ b/test/remote/gateways/remote_jetpay_test.rb @@ -75,18 +75,22 @@ def test_ud_fields_on_capture assert_success capture end - def test_successful_void + + def test_void + # must void a valid auth assert auth = @gateway.authorize(9900, @credit_card, @options) assert_success auth assert_equal 'APPROVED', auth.message assert_not_nil auth.authorization assert_not_nil auth.params["approval"] + assert void = @gateway.void(auth.authorization) assert_success void end - def test_refund_after_purchase + def test_refund_with_token + assert response = @gateway.purchase(9900, @credit_card, @options) assert_success response assert_equal "APPROVED", response.message @@ -101,23 +105,6 @@ def test_refund_after_purchase assert_equal [response.params['transaction_id'], response.params["approval"], 9900, response.params["token"]].join(";"), response.authorization end - def test_refund_after_authorize_capture - assert auth = @gateway.authorize(9900, @credit_card, @options) - assert_success auth - assert_equal 'APPROVED', auth.message - assert_not_nil auth.authorization - assert_not_nil auth.params["approval"] - - assert capture = @gateway.capture(9900, auth.authorization) - assert_success capture - - assert refund = @gateway.refund(9900, capture.authorization) - assert_success refund - assert_not_nil(refund.authorization) - assert_not_nil(refund.params["approval"]) - assert_equal [refund.params['transaction_id'], refund.params["approval"], 9900, refund.params["token"]].join(";"), refund.authorization - end - def test_refund_backwards_compatible # no need for csv card = credit_card('4242424242424242', :verification_value => nil) From e4bf9e230b9fa530686cdf46897b1175b0f41877 Mon Sep 17 00:00:00 2001 From: Bart de Water Date: Wed, 8 Feb 2017 16:29:04 -0500 Subject: [PATCH 021/677] Remove Barclays ePDQ MPI At Shopify we're seeing errors connecting to the endpoint and after reaching out to support it turns out that this product is not available to new accounts. It has been replaced by ePDQ DirectLink. --- CHANGELOG | 1 + README.md | 1 - .../billing/gateways/barclays_epdq.rb | 314 ------------ test/fixtures.yml | 5 - test/unit/gateways/barclays_epdq_test.rb | 450 ------------------ 5 files changed, 1 insertion(+), 770 deletions(-) delete mode 100644 lib/active_merchant/billing/gateways/barclays_epdq.rb delete mode 100644 test/unit/gateways/barclays_epdq_test.rb diff --git a/CHANGELOG b/CHANGELOG index a5ead18c729..5cbeacc0262 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Barclays ePDQ: removed because it has been replaced by a new API [bdewater] #2331 * GlobalCollect: Truncate firstName field to 15 characters [davidsantoso] * Qvalent: Add soft descriptor fields. Add authorize, capture, and void [davidsantoso] * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/README.md b/README.md index be48a8c8fa5..02aa7b4e486 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,6 @@ The [ActiveMerchant Wiki](http://github.com/activemerchant/active_merchant/wikis * [Bank Frick](http://www.bankfrickacquiring.com/) - LI, US * [Banwire](http://www.banwire.com/) - MX * [Barclays ePDQ Extra Plus](http://www.barclaycard.co.uk/business/accepting-payments/epdq-ecomm/) - GB -* [Barclays ePDQ MPI](http://www.barclaycard.co.uk/business/accepting-payments/epdq-mpi/) - GB * [Be2Bill](http://www.be2bill.com/) - FR * [Beanstream.com](http://www.beanstream.com/) - CA, US * [BluePay](http://www.bluepay.com/) - US diff --git a/lib/active_merchant/billing/gateways/barclays_epdq.rb b/lib/active_merchant/billing/gateways/barclays_epdq.rb deleted file mode 100644 index 4349f0726a7..00000000000 --- a/lib/active_merchant/billing/gateways/barclays_epdq.rb +++ /dev/null @@ -1,314 +0,0 @@ -module ActiveMerchant #:nodoc: - module Billing #:nodoc: - class BarclaysEpdqGateway < Gateway - self.test_url = 'https://secure2.mde.epdq.co.uk:11500' - self.live_url = 'https://secure2.epdq.co.uk:11500' - - self.supported_countries = ['GB'] - self.default_currency = 'GBP' - self.supported_cardtypes = [:visa, :master, :american_express, :maestro, :switch ] - self.money_format = :cents - self.homepage_url = 'http://www.barclaycard.co.uk/business/accepting-payments/epdq-mpi/' - self.display_name = 'Barclays ePDQ MPI' - - def initialize(options = {}) - requires!(options, :login, :password, :client_id) - super - end - - def authorize(money, creditcard, options = {}) - document = Document.new(self, @options) do - add_order_form(options[:order_id]) do - add_consumer(options) do - add_creditcard(creditcard) - end - add_transaction(:PreAuth, money) - end - end - - commit(document) - end - - def purchase(money, creditcard, options = {}) - # disable fraud checks if this is a repeat order: - if options[:payment_number] && (options[:payment_number] > 1) - no_fraud = true - else - no_fraud = options[:no_fraud] - end - document = Document.new(self, @options, :no_fraud => no_fraud) do - add_order_form(options[:order_id], options[:group_id]) do - add_consumer(options) do - add_creditcard(creditcard) - end - add_transaction(:Auth, money, options) - end - end - commit(document) - end - - # authorization is your unique order ID, not the authorization - # code returned by ePDQ - def capture(money, authorization, options = {}) - document = Document.new(self, @options) do - add_order_form(authorization) do - add_transaction(:PostAuth, money) - end - end - - commit(document) - end - - # authorization is your unique order ID, not the authorization - # code returned by ePDQ - def credit(money, creditcard_or_authorization, options = {}) - if creditcard_or_authorization.is_a?(String) - ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE - refund(money, creditcard_or_authorization, options) - else - credit_new_order(money, creditcard_or_authorization, options) - end - end - - def refund(money, authorization, options = {}) - credit_existing_order(money, authorization, options) - end - - def void(authorization, options = {}) - document = Document.new(self, @options) do - add_order_form(authorization) do - add_transaction(:Void) - end - end - - commit(document) - end - - private - def credit_new_order(money, creditcard, options) - document = Document.new(self, @options) do - add_order_form do - add_consumer(options) do - add_creditcard(creditcard) - end - add_transaction(:Credit, money) - end - end - - commit(document) - end - - def credit_existing_order(money, authorization, options) - order_id, _ = authorization.split(":") - document = Document.new(self, @options) do - add_order_form(order_id) do - add_transaction(:Credit, money) - end - end - - commit(document) - end - - def parse(body) - parser = Parser.new(body) - response = parser.parse - Response.new(response[:success], response[:message], response, - :test => test?, - :authorization => response[:authorization], - :avs_result => response[:avsresponse], - :cvv_result => response[:cvv_result], - :order_id => response[:order_id], - :raw_response => response[:raw_response] - ) - end - - def commit(document) - url = (test? ? self.test_url : self.live_url) - data = ssl_post(url, document.to_xml) - parse(data) - end - - class Parser - def initialize(response) - @response = response - end - - def parse - require 'iconv' unless String.method_defined?(:encode) - if String.method_defined?(:encode) - doc = REXML::Document.new(@response.encode("UTF-8", "ISO-8859-1")) - else - ic = Iconv.new('UTF-8', 'ISO-8859-1') - doc = REXML::Document.new(ic.iconv(@response)) - end - - auth_type = find(doc, "//Transaction/Type").to_s - - message = find(doc, "//Message/Text") - if message.blank? - message = find(doc, "//Transaction/CardProcResp/CcReturnMsg") - end - - case auth_type - when 'Credit', 'Void' - success = find(doc, "//CcReturnMsg") == "Approved." - else - success = find(doc, "//Transaction/AuthCode").present? - end - - { - :success => success, - :message => message, - :transaction_id => find(doc, "//Transaction/Id"), - :avs_result => find(doc, "//Transaction/AvsRespCode"), - :cvv_result => find(doc, "//Transaction/Cvv2Resp"), - :authorization => find(doc, "//OrderFormDoc/Id"), - :raw_response => @response - } - end - - def find(doc, xpath) - REXML::XPath.first(doc, xpath).try(:text) - end - end - - class Document - attr_reader :type, :xml - - PAYMENT_INTERVALS = { - :days => 'D', - :months => 'M' - } - - EPDQ_CARD_TYPES = { - :visa => 1, - :master => 2, - :switch => 9, - :maestro => 10, - } - - def initialize(gateway, options = {}, document_options = {}, &block) - @gateway = gateway - @options = options - @document_options = document_options - @xml = Builder::XmlMarkup.new(:indent => 2) - build(&block) - end - - def to_xml - @xml.target! - end - - def build(&block) - xml.instruct!(:xml, :version => '1.0') - xml.EngineDocList do - xml.DocVersion "1.0" - xml.EngineDoc do - xml.ContentType "OrderFormDoc" - xml.User do - xml.Name(@options[:login]) - xml.Password(@options[:password]) - xml.ClientId({ :DataType => "S32" }, @options[:client_id]) - end - xml.Instructions do - if @document_options[:no_fraud] - xml.Pipeline "PaymentNoFraud" - else - xml.Pipeline "Payment" - end - end - instance_eval(&block) - end - end - end - - def add_order_form(order_id=nil, group_id=nil, &block) - xml.OrderFormDoc do - xml.Mode 'P' - xml.Id(order_id) if order_id - xml.GroupId(group_id) if group_id - instance_eval(&block) - end - end - - def add_consumer(options=nil, &block) - xml.Consumer do - if options - xml.Email(options[:email]) if options[:email] - billing_address = options[:billing_address] || options[:address] - if billing_address - xml.BillTo do - xml.Location do - xml.Address do - xml.Street1 billing_address[:address1] - xml.Street2 billing_address[:address2] - xml.City billing_address[:city] - xml.StateProv billing_address[:state] - xml.PostalCode billing_address[:zip] - xml.Country billing_address[:country_code] - end - end - end - end - end - instance_eval(&block) - end - end - - def add_creditcard(creditcard) - xml.PaymentMech do - xml.CreditCard do - xml.Type({ :DataType => 'S32' }, EPDQ_CARD_TYPES[creditcard.brand.to_sym]) - xml.Number creditcard.number - xml.Expires({ :DataType => 'ExpirationDate', :Locale => 826 }, format_expiry_date(creditcard)) - if creditcard.verification_value.present? - xml.Cvv2Indicator 1 - xml.Cvv2Val creditcard.verification_value - else - xml.Cvv2Indicator 5 - end - xml.IssueNum(creditcard.issue_number) if creditcard.issue_number.present? - end - end - end - - def add_transaction(auth_type, amount = nil, options = {}) - @auth_type = auth_type - xml.Transaction do - xml.Type @auth_type.to_s - if options[:payment_number] && options[:payment_number] > 1 - xml.CardholderPresentCode({ :DataType => 'S32' }, 8) - else - xml.CardholderPresentCode({ :DataType => 'S32' }, 7) - end - if options[:payment_number] - xml.PaymentNumber({ :DataType => 'S32' }, options[:payment_number]) - end - if options[:total_payments] - xml.TotalNumberPayments({ :DataType => 'S32' }, options[:total_payments]) - end - if amount - xml.CurrentTotals do - xml.Totals do - xml.Total({ :DataType => 'Money', :Currency => 826 }, amount) - end - end - end - end - end - - # date must be formatted MM/YY - def format_expiry_date(creditcard) - month_str = "%02d" % creditcard.month - if match = creditcard.year.to_s.match(/^\d{2}(\d{2})$/) - year_str = "%02d" % match[1].to_i - else - year_str = "%02d" % creditcard.year - end - "#{month_str}/#{year_str}" - end - end - end - end -end - diff --git a/test/fixtures.yml b/test/fixtures.yml index c71b9f80230..53afcadef91 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -52,11 +52,6 @@ barclaycard_smartpay: merchant: merchant password: password -barclays_epdq: - login: test - password: test - client_id: 1234 - barclays_epdq_extra_plus: login: merchant number user: username diff --git a/test/unit/gateways/barclays_epdq_test.rb b/test/unit/gateways/barclays_epdq_test.rb deleted file mode 100644 index 499d877a188..00000000000 --- a/test/unit/gateways/barclays_epdq_test.rb +++ /dev/null @@ -1,450 +0,0 @@ -require 'test_helper' - -class BarclaysEpdqTest < Test::Unit::TestCase - def setup - @gateway = BarclaysEpdqGateway.new( - :login => 'login', - :password => 'password', - :client_id => 'client_id' - ) - - @credit_card = credit_card - @amount = 100 - - @options = { - :billing_address => address - } - end - - def test_successful_purchase - @gateway.expects(:ssl_post).returns(successful_purchase_response) - - assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_success response - - # Replace with authorization number from the successful response - assert_equal "150127237", response.authorization - assert response.test? - end - - def test_failed_purchase - @gateway.expects(:ssl_post).returns(failed_purchase_response) - - assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_failure response - assert response.test? - end - - def test_deprecated_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/>asdfasdfasdfasdf - - 1.0 - - OrderFormDoc - 4d45da6a-5e10-3000-002b-00144ff2e45c - - Payment - - - - 3 - - 32 - Merchant - CcxBarclaysGbpAuth - PaymentNormErrors - 3 - 121 - CcxBarclaysAuthResponseRedirector.cpp - 10:41:43May 26 2009 - 1 - 3 - Approved. - - - - - - - - -
- Ottawa - - K1C2N6 - ON - 1234 My Street - Apt 1 - -
- 4d45da6a-5e12-3000-002b-00144ff2e45c - -
- -
- - - 1 - 123 - 09/12 - 4715320629000001 - 1 - - - CreditCard - - - -
- 1296599280954 - - None - 0 - 0 - - - None - 1 - My Rules - 2974 - 0 - - - - - 0 - - - 150127237 - 150127237 - P - - 442130 - - 90003750 - - - - YY - EX - 1 - Approved. - 2 - 22 - 00 - AUTH CODE:442130 - 1 - - - 7 - - - 3900 - - - - - 4d45da6a-5e11-3000-002b-00144ff2e45c - 4 - 7 - 1 - Auth - - - -
- - 2974 - 2974 - 2974 - 2974 - spreedlytesting - XXXXXXX - - - -
- 1296599280948 - 1296599283885 - -
-) - end - - def failed_purchase_response - %( - - 1.0 - - OrderFormDoc - 4d45da6a-5d6b-3000-002b-00144ff2e45c - - Payment - - - - 3 - - 32 - Merchant - CcxBarclaysGbpAuth - PaymentNormErrors - 3 - 121 - CcxBarclaysAuthResponseRedirector.cpp - 10:41:43May 26 2009 - 50 - 3 - Declined (General). - - - - - - - - -
- Ottawa - - K1C2N6 - ON - 1234 My Street - Apt 1 - -
- 4d45da6a-5d6d-3000-002b-00144ff2e45c - -
- -
- - - 1 - 123 - 09/12 - 4715320629000027 - 1 - - - CreditCard - - - -
- 1296598178436 - - None - 0 - 0 - - - None - 1 - My Rules - 2974 - 0 - - - - - 0 - - - 22394792 - 22394792 - P - - - 90003745 - - - - NY - B5 - 50 - Declined (General). - 2 - 24 - 05 - NOT AUTHORISED - 1 - - - 7 - - - 4205 - - - - - 4d45da6a-5d6c-3000-002b-00144ff2e45c - 4 - 7 - 1 - Auth - - - -
- - 2974 - 2974 - 2974 - 2974 - login - XXXXXXX - - - -
- 1296598178430 - 1296598179756 - -
-) - end - - def successful_credit_response - %( - - 1.0 - - OrderFormDoc - 4d45da6a-8bcd-3000-002b-00144ff2e45c - - Payment - - - - - - - - - -
- Ottawa - K1C2N6 - ON - 1234 My Street - Apt 1 - -
- 4d45da6a-8bcc-3000-002b-00144ff2e45c - -
- -
- - - 1 - 09/12 - 4715320629000001 - - - CreditCard - - - -
- 1296679499967 - - None - 0 - 0 - - - None - 1 - My Rules - 2974 - 0 - - - - - 0 - - - b92b5bff09d05d771c17e6b6b30531ed - b92b5bff09d05d771c17e6b6b30531ed - P - - - 1 - Approved. - 1 - Approved - 1 - - - 7 - S - - - 3900 - - - - - 4d45da6a-8bce-3000-002b-00144ff2e45c - 4 - 7 - 1 - Credit - - - -
- - 2974 - 2974 - 2974 - 2974 - spreedlytesting - XXXXXXX - - - -
- 1296679499961 - 1296679500312 - -
- -) - end - - def incorrectly_encoded_response - successful_purchase_response.gsub("Ottawa", "\xD6ttawa") - end -end From 703f655cf30418e91fefc26df2ac044f4a71149c Mon Sep 17 00:00:00 2001 From: David Santoso Date: Wed, 15 Mar 2017 15:20:36 -0400 Subject: [PATCH 022/677] GlobalCollect: Set REJECTED refunds as unsuccessful transactions It should be noted that Global Collect requires 24 hours for purchase to settle before attempting a refund so remote tests for refunds are not easily reproducible. Furthermore, forcing a REJECTED response in a refund is not covered in the docs which is why this is lacking a remote tests. However the unit test does take into account the response as shown in the docs. Closes #2365 --- CHANGELOG | 1 + .../billing/gateways/global_collect.rb | 14 +++++++++++--- test/unit/gateways/global_collect_test.rb | 12 ++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a5ead18c729..1c78aabe623 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Qvalent: Add soft descriptor fields. Add authorize, capture, and void [davidsantoso] * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 * Pin: Add metadata optional field [shasum] #2363 +* GlobalCollect: Set REJECTED refunds as unsuccessful transactions [davidsantoso] #2365 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 9a0b9142f62..1bef55122c5 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -262,14 +262,18 @@ def content_type end def success_from(response) - !response["errorId"] + !response["errorId"] && response["status"] != "REJECTED" end def message_from(succeeded, response) if succeeded "Succeeded" else - response["errors"][0]["message"] || "Unable to read error message" + if errors = response["errors"] + errors.first.try(:[], "message") + else + "Unable to read error message" + end end end @@ -283,7 +287,11 @@ def authorization_from(succeeded, response) def error_code_from(succeeded, response) unless succeeded - response["errors"][0]["code"] || "Unable to read error code" + if errors = response["errors"] + errors.first.try(:[], "code") + else + "Unable to read error code" + end end end diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb index 04043fdf4bf..1e4f7d35267 100644 --- a/test/unit/gateways/global_collect_test.rb +++ b/test/unit/gateways/global_collect_test.rb @@ -156,6 +156,14 @@ def test_failed_refund assert_failure response end + def test_rejected_refund + response = stub_comms do + @gateway.refund(@accepted_amount, '000000142800000000920000100001') + end.respond_with(rejected_refund_response) + + assert_failure response + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed @@ -299,6 +307,10 @@ def failed_refund_response %({\n \"errorId\" : \"1bd31e6a-39dd-4214-941a-088a320e0286\",\n \"errors\" : [ {\n \"code\" : \"1002\",\n \"propertyName\" : \"paymentId\",\n \"message\" : \"INVALID_PAYMENT_ID\"\n } ]\n}) end + def rejected_refund_response + %({\n \"id\" : \"00000022184000047564000-100001\",\n \"refundOutput\" : {\n \"amountOfMoney\" : {\n \"amount\" : 627000,\n \"currencyCode\" : \"COP\"\n },\n \"references\" : {\n \"merchantReference\" : \"17091GTgZmcC\",\n \"paymentReference\" : \"0\"\n },\n \"paymentMethod\" : \"card\",\n \"cardRefundMethodSpecificOutput\" : {\n }\n },\n \"status\" : \"REJECTED\",\n \"statusOutput\" : {\n \"isCancellable\" : false,\n \"statusCategory\" : \"UNSUCCESSFUL\",\n \"statusCode\" : 1850,\n \"statusCodeChangeDateTime\" : \"20170313230631\"\n }\n}) + end + def successful_void_response %({\n \"payment\" : {\n \"id\" : \"000000142800000000920000100001\",\n \"paymentOutput\" : {\n \"amountOfMoney\" : {\n \"amount\" : 100,\n \"currencyCode\" : \"USD\"\n },\n \"references\" : {\n \"paymentReference\" : \"0\"\n },\n \"paymentMethod\" : \"card\",\n \"cardPaymentMethodSpecificOutput\" : {\n \"paymentProductId\" : 1,\n \"authorisationCode\" : \"OK1131\",\n \"card\" : {\n \"cardNumber\" : \"************7977\",\n \"expiryDate\" : \"0917\"\n },\n \"fraudResults\" : {\n \"fraudServiceResult\" : \"no-advice\",\n \"avsResult\" : \"0\",\n \"cvvResult\" : \"0\"\n }\n }\n },\n \"status\" : \"CANCELLED\",\n \"statusOutput\" : {\n \"isCancellable\" : false,\n \"statusCode\" : 99999,\n \"statusCodeChangeDateTime\" : \"20160317191526\"\n }\n }\n}) end From c4846a84f41f30e0ca68802c659e0424e581cbb3 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Fri, 17 Mar 2017 23:48:55 +0530 Subject: [PATCH 023/677] WePay: Support unique_id for idempotent transactions Closes #2367 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/wepay.rb | 1 + test/remote/gateways/remote_wepay_test.rb | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 2378098d12b..7fa25d6359a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 * Pin: Add metadata optional field [shasum] #2363 * GlobalCollect: Set REJECTED refunds as unsuccessful transactions [davidsantoso] #2365 +* WePay: Support unique_id for idempotent transactions [shasum] #2367 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/wepay.rb b/lib/active_merchant/billing/gateways/wepay.rb index 343ea0c731e..6c6890a157e 100644 --- a/lib/active_merchant/billing/gateways/wepay.rb +++ b/lib/active_merchant/billing/gateways/wepay.rb @@ -126,6 +126,7 @@ def add_product_data(post, money, options) post[:payer_email_message] = options[:payer_email_message] if options[:payer_email_message] post[:payee_email_message] = options[:payee_email_message] if options[:payee_email_message] post[:reference_id] = options[:order_id] if options[:order_id] + post[:unique_id] = options[:unique_id] if options[:unique_id] post[:redirect_uri] = options[:redirect_uri] if options[:redirect_uri] post[:callback_uri] = options[:callback_uri] if options[:callback_uri] post[:fallback_uri] = options[:fallback_uri] if options[:fallback_uri] diff --git a/test/remote/gateways/remote_wepay_test.rb b/test/remote/gateways/remote_wepay_test.rb index 51b156d52f5..9f19bb1f24d 100644 --- a/test/remote/gateways/remote_wepay_test.rb +++ b/test/remote/gateways/remote_wepay_test.rb @@ -66,6 +66,12 @@ def test_successful_purchase_with_fee assert_equal 'Success', response.message end + def test_successful_purchase_with_unique_id + response = @gateway.purchase(@amount, @credit_card, @options.merge(unique_id: generate_unique_id)) + assert_success response + assert_equal 'Success', response.message + end + def test_successful_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_success response From d53cd03224d379a19de0a5194e1a29497fbbbd75 Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 20 Mar 2017 18:36:23 -0400 Subject: [PATCH 024/677] Orbital: Don't send CVV indicator if CVV is not present Previously, the CardSecValInd field was being passed with a value of 9 ("Cardholder states data not available") when no CVV was present and the card brand was Visa or Discover. Chase has indicated that the field should not be passed at all when no CVV is provided with the request. This may have been causing declines. Unfortunately remote tests cannot be run as we do not currently have credentials for an active test account. Closes #2368 --- CHANGELOG | 1 + .../billing/gateways/orbital.rb | 8 +++++--- test/unit/gateways/orbital_test.rb | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7fa25d6359a..d066fbed767 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * Pin: Add metadata optional field [shasum] #2363 * GlobalCollect: Set REJECTED refunds as unsuccessful transactions [davidsantoso] #2365 * WePay: Support unique_id for idempotent transactions [shasum] #2367 +* Orbital: Don't send CVV indicator if CVV is not present [curiousepic] #2368 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index 8b67ca493f5..fcddf4d5cce 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -417,10 +417,12 @@ def add_creditcard(xml, creditcard, currency=nil) # Do not submit the attribute at all. # - http://download.chasepaymentech.com/docs/orbital/orbital_gateway_xml_specification.pdf unless creditcard.nil? - if %w( visa discover ).include?(creditcard.brand) - xml.tag! :CardSecValInd, (creditcard.verification_value? ? '1' : '9') + if creditcard.verification_value? + if %w( visa discover ).include?(creditcard.brand) + xml.tag! :CardSecValInd, '1' + end + xml.tag! :CardSecVal, creditcard.verification_value end - xml.tag! :CardSecVal, creditcard.verification_value if creditcard.verification_value? end end diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index 310a84e2b75..5e528bac39e 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -676,6 +676,24 @@ def test_failed_verify assert_equal "AUTH DECLINED 12001", response.message end + def test_cvv_indicator_present_for_visas_with_cvvs + stub_comms do + @gateway.purchase(50, credit_card, @options) + end.check_request do |_endpoint, data, _headers| + assert_match %r{1<\/CardSecValInd>}, data + assert_match %r{123<\/CardSecVal>}, data + end.respond_with(successful_purchase_response) + end + + def test_cvv_indicator_absent_for_recurring + stub_comms do + @gateway.purchase(50, credit_card(nil, {verification_value: nil}), @options) + end.check_request do |_endpoint, data, _headers| + assert_no_match %r{}, data + assert_no_match %r{}, data + end.respond_with(successful_purchase_response) + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed From 05db1ca414aa06721a4a7138175f45311261fc80 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Mon, 20 Mar 2017 15:45:30 -0400 Subject: [PATCH 025/677] JetPay: Pass down authorization payment method token to refund a capture Capture responses do not return the token used during the authorize and without a token, it's not possible to refund the capture without sending in the original credit card number. This passes down the payment method token returned in the authorization response to the capture's concatenated authorization. This allows the token to be passed when refunding a capture which negates the need to send in a credit card number. Previously, this discrepency bubbled up as a failed refund with the error message being that the credit card number is missing. --- CHANGELOG | 1 + .../billing/gateways/jetpay.rb | 21 ++++++++++-------- test/remote/gateways/remote_jetpay_test.rb | 22 +++++++++++++++++-- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d066fbed767..a10c4a109d6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * GlobalCollect: Set REJECTED refunds as unsuccessful transactions [davidsantoso] #2365 * WePay: Support unique_id for idempotent transactions [shasum] #2367 * Orbital: Don't send CVV indicator if CVV is not present [curiousepic] #2368 +* JetPay: Pass down authorization payment method token to refund a capture [davidsantoso] == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/jetpay.rb b/lib/active_merchant/billing/gateways/jetpay.rb index 03fe5f2b828..9dfdefe2b2a 100644 --- a/lib/active_merchant/billing/gateways/jetpay.rb +++ b/lib/active_merchant/billing/gateways/jetpay.rb @@ -165,12 +165,15 @@ def authorize(money, credit_card, options = {}) end def capture(money, reference, options = {}) - commit(money, build_capture_request(reference.split(";").first, money, options)) + split_authorization = reference.split(";") + transaction_id = split_authorization[0] + token = split_authorization[3] + commit(money, build_capture_request(transaction_id, money, options), token) end def void(reference, options = {}) transaction_id, approval, amount, token = reference.split(";") - commit(amount.to_i, build_void_request(amount.to_i, transaction_id, approval, token, options)) + commit(amount.to_i, build_void_request(amount.to_i, transaction_id, approval, token, options), token) end def credit(money, transaction_id_or_card, options = {}) @@ -183,9 +186,9 @@ def credit(money, transaction_id_or_card, options = {}) end def refund(money, reference, options = {}) - params = reference.split(";") - transaction_id = params[0] - token = params[3] + split_authorization = reference.split(";") + transaction_id = split_authorization[0] + token = split_authorization[3] credit_card = options[:credit_card] commit(money, build_credit_request('CREDIT', money, transaction_id, credit_card, token, options)) end @@ -279,7 +282,7 @@ def build_credit_request(transaction_type, money, transaction_id, card, token, o end end - def commit(money, request) + def commit(money, request, token = nil) response = parse(ssl_post(url, request)) success = success?(response) @@ -287,7 +290,7 @@ def commit(money, request) success ? 'APPROVED' : message_from(response), response, :test => test?, - :authorization => authorization_from(response, money), + :authorization => authorization_from(response, money, token), :avs_result => { :code => response[:avs] }, :cvv_result => response[:cvv2] ) @@ -330,9 +333,9 @@ def message_from(response) ACTION_CODE_MESSAGES[response[:action_code]] end - def authorization_from(response, money) + def authorization_from(response, money, previous_token) original_amount = amount(money) if money - [ response[:transaction_id], response[:approval], original_amount, response[:token]].join(";") + [ response[:transaction_id], response[:approval], original_amount, (response[:token] || previous_token)].join(";") end def add_credit_card(xml, credit_card) diff --git a/test/remote/gateways/remote_jetpay_test.rb b/test/remote/gateways/remote_jetpay_test.rb index d528a3694b5..48ef90770f5 100644 --- a/test/remote/gateways/remote_jetpay_test.rb +++ b/test/remote/gateways/remote_jetpay_test.rb @@ -89,8 +89,7 @@ def test_void assert_success void end - def test_refund_with_token - + def test_purchase_refund_with_token assert response = @gateway.purchase(9900, @credit_card, @options) assert_success response assert_equal "APPROVED", response.message @@ -105,6 +104,25 @@ def test_refund_with_token assert_equal [response.params['transaction_id'], response.params["approval"], 9900, response.params["token"]].join(";"), response.authorization end + def test_capture_refund_with_token + assert auth = @gateway.authorize(9900, @credit_card, @options) + assert_success auth + assert_equal 'APPROVED', auth.message + assert_not_nil auth.authorization + assert_not_nil auth.params["approval"] + assert_equal [auth.params['transaction_id'], auth.params["approval"], 9900, auth.params["token"]].join(";"), auth.authorization + + assert capture = @gateway.capture(9900, auth.authorization) + assert_success capture + assert_equal [capture.params['transaction_id'], capture.params["approval"], 9900, auth.params["token"]].join(";"), capture.authorization + + # linked to a specific transaction_id + assert refund = @gateway.refund(9900, capture.authorization) + assert_success refund + assert_not_nil(refund.authorization) + assert_not_nil(refund.params["approval"]) + end + def test_refund_backwards_compatible # no need for csv card = credit_card('4242424242424242', :verification_value => nil) From 61859226a4296a5f5f9c87543f90655d0c84f182 Mon Sep 17 00:00:00 2001 From: Karol Galanciak Date: Sat, 26 Dec 2015 15:55:11 +0100 Subject: [PATCH 026/677] Make Quickpay initialization exception more idiomatic Closes #1982 --- lib/active_merchant/billing/gateways/quickpay.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/active_merchant/billing/gateways/quickpay.rb b/lib/active_merchant/billing/gateways/quickpay.rb index 6fe34125cbc..3cc61e5656a 100644 --- a/lib/active_merchant/billing/gateways/quickpay.rb +++ b/lib/active_merchant/billing/gateways/quickpay.rb @@ -10,16 +10,16 @@ class QuickpayGateway < Gateway self.abstract_class = true def self.new(options = {}) - options.fetch(:login) rescue raise ArgumentError.new("Missing required parameter: login") + options.fetch(:login) { raise ArgumentError.new("Missing required parameter: login") } version = options[:login].to_i < 10000000 ? 10 : 7 if version <= 7 QuickpayV4to7Gateway.new(options) else - QuickpayV10Gateway.new(options) + QuickpayV10Gateway.new(options) end end - + end end end From 54cf5c538e16c18d869f2011730fea4ecd1a8b16 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Thu, 23 Mar 2017 15:44:45 -0400 Subject: [PATCH 027/677] Anchor Travis to Rails 5.0 --- .travis.yml | 4 ++-- Gemfile.rails5 => Gemfile.rails50 | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) rename Gemfile.rails5 => Gemfile.rails50 (68%) diff --git a/.travis.yml b/.travis.yml index d0e49bc6109..e2b674827da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,12 +13,12 @@ gemfile: - Gemfile.rails40 - Gemfile.rails41 - Gemfile.rails42 -- Gemfile.rails5 +- Gemfile.rails50 matrix: exclude: - rvm: 2.1 - gemfile: Gemfile.rails5 + gemfile: Gemfile.rails50 notifications: email: diff --git a/Gemfile.rails5 b/Gemfile.rails50 similarity index 68% rename from Gemfile.rails5 rename to Gemfile.rails50 index a7bec76b4bc..5b6ae97c89f 100644 --- a/Gemfile.rails5 +++ b/Gemfile.rails50 @@ -8,6 +8,4 @@ group :test, :remote_test do gem 'braintree', '>= 2.50.0' end -gem 'rails', github: 'rails/rails' -gem 'arel', github: 'rails/arel' -gem 'rack', github: 'rack/rack' +gem 'rails', '~> 5.0.0' From 9c44975612deec9d6795d1ff385071a9ae5106ae Mon Sep 17 00:00:00 2001 From: David Perry Date: Wed, 22 Mar 2017 15:16:24 -0400 Subject: [PATCH 028/677] GlobalCollect: Make message and error reporting more robust For some transactions, particularly refunds when rejected, the transaction was unsusscessful but no error code or useful message was being mapped in the response. This change maps statusCode to error_code when errors are absent, and status to message when an error message is absent. It also updates some remote test message expectations, so they are all passing now. 15 tests, 35 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2370 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/global_collect.rb | 8 ++++++-- test/remote/gateways/remote_global_collect_test.rb | 8 ++++---- .../remote_trans_first_transaction_express_test.rb | 2 +- test/unit/gateways/global_collect_test.rb | 2 ++ 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a10c4a109d6..24a27213edb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * WePay: Support unique_id for idempotent transactions [shasum] #2367 * Orbital: Don't send CVV indicator if CVV is not present [curiousepic] #2368 * JetPay: Pass down authorization payment method token to refund a capture [davidsantoso] +* GlobalCollect: Make message and error reporting more robust [curiousepic] #2370 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 1bef55122c5..2e21d62ca9f 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -271,8 +271,10 @@ def message_from(succeeded, response) else if errors = response["errors"] errors.first.try(:[], "message") + elsif status = response["status"] + "Status: " + status else - "Unable to read error message" + "No message available" end end end @@ -289,8 +291,10 @@ def error_code_from(succeeded, response) unless succeeded if errors = response["errors"] errors.first.try(:[], "code") + elsif status = response.try(:[], "statusOutput").try(:[], "statusCode") + status.to_s else - "Unable to read error code" + "No error code available" end end end diff --git a/test/remote/gateways/remote_global_collect_test.rb b/test/remote/gateways/remote_global_collect_test.rb index 26146b679ca..f2760af7b76 100644 --- a/test/remote/gateways/remote_global_collect_test.rb +++ b/test/remote/gateways/remote_global_collect_test.rb @@ -73,7 +73,7 @@ def test_partial_capture def test_failed_capture response = @gateway.capture(@amount, '123', @options) assert_failure response - assert_match %r{The given paymentId is not correct}, response.message + assert_match %r{UNKNOWN_PAYMENT_ID}, response.message end # Because payments are not fully authorized immediately, refunds can only be @@ -97,7 +97,7 @@ def test_failed_capture def test_failed_refund response = @gateway.refund(@amount, '123') assert_failure response - assert_match %r{The given paymentId is not correct}, response.message + assert_match %r{UNKNOWN_PAYMENT_ID}, response.message end def test_successful_void @@ -112,7 +112,7 @@ def test_successful_void def test_failed_void response = @gateway.void('123') assert_failure response - assert_match %r{The given paymentId is not correct}, response.message + assert_match %r{UNKNOWN_PAYMENT_ID}, response.message end def test_successful_verify @@ -132,7 +132,7 @@ def test_invalid_login response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_match %r{The authorization was missing or invalid}, response.message + assert_match %r{MISSING_OR_INVALID_AUTHORIZATION}, response.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb index 8261c0cb14b..235b25d8fc1 100644 --- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb +++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb @@ -87,7 +87,7 @@ def test_partial_purchase end def test_failed_purchase - response = @gateway.purchase(@declined_amount, @credit_card, @options) + response = @gateway.purchase(@rejected_amount, @declined_card, @options) assert_failure response assert_equal "Not sufficient funds", response.message assert_equal "51", response.params["rspCode"] diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb index 1e4f7d35267..e256de0c432 100644 --- a/test/unit/gateways/global_collect_test.rb +++ b/test/unit/gateways/global_collect_test.rb @@ -162,6 +162,8 @@ def test_rejected_refund end.respond_with(rejected_refund_response) assert_failure response + assert_equal "1850", response.error_code + assert_equal "Status: REJECTED", response.message end def test_scrub From fef5be235023fcff033017d1184cd71bd8d7cbb6 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Wed, 29 Mar 2017 18:02:52 +0530 Subject: [PATCH 029/677] Cybersource: Rescue XML parse exception Closes #2380 --- CHANGELOG | 1 + .../billing/gateways/cyber_source.rb | 2 ++ test/unit/gateways/cyber_source_test.rb | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 24a27213edb..ebd0ce56dbe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Orbital: Don't send CVV indicator if CVV is not present [curiousepic] #2368 * JetPay: Pass down authorization payment method token to refund a capture [davidsantoso] * GlobalCollect: Make message and error reporting more robust [curiousepic] #2370 +* Cybersource: Rescue XML parse exception [shasum] #2380 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 87435db29f6..92791e56d4f 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -686,6 +686,8 @@ def commit(request, action, amount, options) response = parse(ssl_post(test? ? self.test_url : self.live_url, build_request(request, options))) rescue ResponseError => e response = parse(e.response.body) + rescue REXML::ParseException => e + response = { message: e.to_s } end success = response[:decision] == "ACCEPT" diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index 7806b52e9ee..dba909fff4c 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -404,6 +404,15 @@ def test_nonfractional_currency_handling assert_success response end + def test_malformed_xml_handling + @gateway.expects(:ssl_post).returns(malformed_xml_response) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_match %r(Missing end tag for), response.message + assert response.test? + end + def test_scrub assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed end @@ -583,4 +592,12 @@ def successful_nonfractional_authorization_response 2007-07-12T18:31:53.838ZTEST111111111111842651133440156177166ACCEPT100AP4JY+Or4xRonEAOERAyMzQzOTEzMEM0MFZaNUZCBgDH3fgJ8AEGAMfd+AnwAwzRpAAA7RT/JPY1001004542AI72007-07-12T18:31:53Z10023439130C40VZ2FB XML end + + def malformed_xml_response + <<-XML + + +2008-01-15T21:42:03.343Zb0a6cf9aa07f1a8495f89c364bbd6a9a2004333231260008401927ACCEPT100Afvvj7Ke2Fmsbq0wHFE2sM6R4GAptYZ0jwPSA+R9PhkyhFTb0KRjoE4+ynthZrG6tMBwjAtTUSD1001.00123456YYMM2008-01-15T21:42:03Z00U

+ XML + end end From 12abf7f3fed7f28ff448e13af56ae01f1e916eb4 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Thu, 30 Mar 2017 23:45:19 +0530 Subject: [PATCH 030/677] Payeezy: Support dynamic soft descriptors Closes #2384 --- CHANGELOG | 1 + .../billing/gateways/payeezy.rb | 7 ++++++ test/remote/gateways/remote_payeezy_test.rb | 25 ++++++++++++++++--- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ebd0ce56dbe..b94e9c68032 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * JetPay: Pass down authorization payment method token to refund a capture [davidsantoso] * GlobalCollect: Make message and error reporting more robust [curiousepic] #2370 * Cybersource: Rescue XML parse exception [shasum] #2380 +* Payeezy: Support dynamic soft descriptors [shasum] #2384 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index 1d6f72191ec..22b886d44b1 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -37,6 +37,7 @@ def purchase(amount, payment_method, options = {}) add_payment_method(params, payment_method) add_address(params, options) add_amount(params, amount, options) + add_soft_descriptors(params, options) commit(params, options) end @@ -48,6 +49,7 @@ def authorize(amount, payment_method, options = {}) add_payment_method(params, payment_method) add_address(params, options) add_amount(params, amount, options) + add_soft_descriptors(params, options) commit(params, options) end @@ -57,6 +59,7 @@ def capture(amount, authorization, options = {}) add_authorization_info(params, authorization) add_amount(params, amount, options) + add_soft_descriptors(params, options) commit(params, options) end @@ -169,6 +172,10 @@ def add_amount(params, money, options) params[:amount] = amount(money) end + def add_soft_descriptors(params, options) + params[:soft_descriptors] = options[:soft_descriptors] if options[:soft_descriptors] + end + def commit(params, options) url = if options[:integration] integration_url diff --git a/test/remote/gateways/remote_payeezy_test.rb b/test/remote/gateways/remote_payeezy_test.rb index a94283207bd..09cba168374 100644 --- a/test/remote/gateways/remote_payeezy_test.rb +++ b/test/remote/gateways/remote_payeezy_test.rb @@ -11,6 +11,19 @@ def setup :billing_address => address, :merchant_ref => 'Store Purchase' } + @options_mdd = { + soft_descriptors: { + dba_name: "Caddyshack", + street: "1234 Any Street", + city: "Durham", + region: "North Carolina", + mid: "mid_1234", + mcc: "mcc_5678", + postal_code: "27701", + country_code: "US", + merchant_contact_info: "8885551212" + } + } end def test_successful_purchase @@ -25,6 +38,12 @@ def test_successful_purchase_with_echeck assert_success response end + def test_successful_purchase_with_soft_descriptors + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(@options_mdd)) + assert_match(/Transaction Normal/, response.message) + assert_success response + end + def test_failed_purchase @amount = 501300 assert response = @gateway.purchase(@amount, @credit_card, @options ) @@ -125,7 +144,7 @@ def test_successful_verify def test_failed_verify response = @gateway.verify(@bad_credit_card, @options) assert_failure response - assert_match %r{The card number must be numeric}, response.message + assert_match %r{The credit card number check failed}, response.message end def test_bad_creditcard_number @@ -152,9 +171,9 @@ def test_trans_error # ask for error 42 (unable to send trans) as the cents bit... @amount = 500042 assert response = @gateway.purchase(@amount, @credit_card, @options ) - assert_match(/Internal Server Error/, response.message) # 42 is 'unable to send trans' + assert_match(/Server Error/, response.message) # 42 is 'unable to send trans' assert_failure response - assert_equal response.error_code, "internal_server_error" + assert_equal "500", response.error_code end def test_transcript_scrubbing From 5e598e2ac5a1c983139c1e973771a58befa02a47 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Tue, 21 Mar 2017 14:15:35 -0400 Subject: [PATCH 031/677] Stripe: Support custom application in X-Stripe-Client-User-Agent header Closes #2385 --- CHANGELOG | 1 + .../billing/gateways/stripe.rb | 7 ++++++- test/unit/gateways/stripe_test.rb | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index b94e9c68032..6c0bc676a4a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * GlobalCollect: Make message and error reporting more robust [curiousepic] #2370 * Cybersource: Rescue XML parse exception [shasum] #2380 * Payeezy: Support dynamic soft descriptors [shasum] #2384 +* Stripe: Support custom application in X-Stripe-Client-User-Agent header [davidsantoso] == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index f75a569a847..95155347e8b 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -475,7 +475,7 @@ def headers(options = {}) "Authorization" => "Basic " + Base64.encode64(key.to_s + ":").strip, "User-Agent" => "Stripe/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}", "Stripe-Version" => api_version(options), - "X-Stripe-Client-User-Agent" => user_agent, + "X-Stripe-Client-User-Agent" => stripe_client_user_agent(options), "X-Stripe-Client-User-Metadata" => {:ip => options[:ip]}.to_json } headers.merge!("Idempotency-Key" => idempotency_key) if idempotency_key @@ -483,6 +483,11 @@ def headers(options = {}) headers end + def stripe_client_user_agent(options) + return user_agent unless options[:application] + JSON.dump(JSON.parse(user_agent).merge!({application: options[:application]})) + end + def api_version(options) options[:version] || @options[:version] || "2015-04-07" end diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index 8c0182a3ee6..c9a217d8c64 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -439,6 +439,25 @@ def test_amount_localization @gateway.purchase(@amount, @credit_card, @options) end + def test_adds_application_to_x_stripe_client_user_agent_header + application = { + name: "app", + version: "1.0", + url: "https://example.com" + } + + response = stub_comms(@gateway, :ssl_request) do + @gateway.purchase(@amount, "cus_xxx|card_xxx", @options.merge({application: application})) + end.check_request do |method, endpoint, data, headers| + assert_match(/\"application\"/, headers["X-Stripe-Client-User-Agent"]) + assert_match(/\"name\":\"app\"/, headers["X-Stripe-Client-User-Agent"]) + assert_match(/\"version\":\"1.0\"/, headers["X-Stripe-Client-User-Agent"]) + assert_match(/\"url\":\"https:\/\/example.com\"/, headers["X-Stripe-Client-User-Agent"]) + end.respond_with(successful_purchase_response) + + assert_success response + end + def test_successful_purchase_with_token_including_customer response = stub_comms(@gateway, :ssl_request) do @gateway.purchase(@amount, "cus_xxx|card_xxx") From 2165d25240aacd2e2571804a3b231520164e79f1 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Thu, 23 Mar 2017 11:06:51 -0400 Subject: [PATCH 032/677] SafeCharge: Add gateway --- CHANGELOG | 1 + .../billing/gateways/safe_charge.rb | 211 +++++++++++++++ test/fixtures.yml | 5 + .../gateways/remote_safe_charge_test.rb | 138 ++++++++++ test/unit/gateways/safe_charge_test.rb | 256 ++++++++++++++++++ 5 files changed, 611 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/safe_charge.rb create mode 100644 test/remote/gateways/remote_safe_charge_test.rb create mode 100644 test/unit/gateways/safe_charge_test.rb diff --git a/CHANGELOG b/CHANGELOG index 6c0bc676a4a..ed7435d5153 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * Cybersource: Rescue XML parse exception [shasum] #2380 * Payeezy: Support dynamic soft descriptors [shasum] #2384 * Stripe: Support custom application in X-Stripe-Client-User-Agent header [davidsantoso] +* SafeCharge: Add gateway [davidsantoso] == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb new file mode 100644 index 00000000000..384a5cdcc33 --- /dev/null +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -0,0 +1,211 @@ +require 'nokogiri' + +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class SafeChargeGateway < Gateway + self.test_url = 'https://process.sandbox.safecharge.com/service.asmx/Process' + self.live_url = 'https://process.safecharge.com/service.asmx/Process' + + self.supported_countries = ['US'] + self.default_currency = 'USD' + self.supported_cardtypes = [:visa, :master] + + self.homepage_url = 'https://www.safecharge.com' + self.display_name = 'SafeCharge' + + VERSION = '4.0.4' + + def initialize(options={}) + requires!(options, :client_login_id, :client_password) + super + end + + def purchase(money, payment, options={}) + post = {} + add_transaction_data("Sale", post, money, options) + add_payment(post, payment) + + commit(post) + end + + def authorize(money, payment, options={}) + post = {} + add_transaction_data("Auth", post, money, options) + add_payment(post, payment) + + commit(post) + end + + def capture(money, authorization, options={}) + post = {} + add_transaction_data("Settle", post, money, options) + auth, transaction_id, token, exp_month, exp_year, _ = authorization.split("|") + post[:sg_AuthCode] = auth + post[:sg_TransactionID] = transaction_id + post[:sg_CCToken] = token + post[:sg_ExpMonth] = exp_month + post[:sg_ExpYear] = exp_year + + commit(post) + end + + def refund(money, authorization, options={}) + post = {} + add_transaction_data("Credit", post, money, options) + auth, transaction_id, token, exp_month, exp_year, _ = authorization.split("|") + post[:sg_CreditType] = 2 + post[:sg_AuthCode] = auth + post[:sg_TransactionID] = transaction_id + post[:sg_CCToken] = token + post[:sg_ExpMonth] = exp_month + post[:sg_ExpYear] = exp_year + + commit(post) + end + + def void(authorization, options={}) + post = {} + auth, transaction_id, token, exp_month, exp_year, original_amount = authorization.split("|") + add_transaction_data("Void", post, (original_amount.to_f * 100), options) + post[:sg_CreditType] = 2 + post[:sg_AuthCode] = auth + post[:sg_TransactionID] = transaction_id + post[:sg_CCToken] = token + post[:sg_ExpMonth] = exp_month + post[:sg_ExpYear] = exp_year + + commit(post) + end + + def verify(credit_card, options={}) + MultiResponse.run(:use_first_response) do |r| + r.process { authorize(100, credit_card, options) } + r.process(:ignore_result) { void(r.authorization, options) } + end + end + + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((sg_ClientPassword=)[^&]+(&?)), '\1[FILTERED]\2'). + gsub(%r((sg_CardNumber=)[^&]+(&?)), '\1[FILTERED]\2'). + gsub(%r((sg_CVV2=)\d+), '\1[FILTERED]') + end + + private + + def add_transaction_data(trans_type, post, money, options) + post[:sg_TransType] = trans_type + post[:sg_Currency] = (options[:currency] || currency(money)) + post[:sg_Amount] = amount(money) + post[:sg_ClientLoginID] = @options[:client_login_id] + post[:sg_ClientPassword] = @options[:client_password] + post[:sg_ResponseFormat] = "4" + post[:sg_Version] = VERSION + end + + def add_payment(post, payment) + post[:sg_NameOnCard] = payment.name + post[:sg_CardNumber] = payment.number + post[:sg_ExpMonth] = format(payment.month, :two_digits) + post[:sg_ExpYear] = format(payment.year, :two_digits) + post[:sg_CVV2] = payment.verification_value + end + + def parse(xml) + response = {} + + doc = Nokogiri::XML(xml) + doc.root.xpath('*').each do |node| + response[node.name.underscore.downcase.to_sym] = node.text + end + + response + end + + def childnode_to_response(response, node, childnode) + name = "#{node.name.downcase}_#{childnode.name.downcase}" + if name == 'payment_method_data' && !childnode.elements.empty? + response[name.to_sym] = Hash.from_xml(childnode.to_s).values.first + else + response[name.to_sym] = childnode.text + end + end + + def commit(parameters) + url = (test? ? test_url : live_url) + response = parse(ssl_post(url, post_data(parameters))) + + Response.new( + success_from(response), + message_from(response), + response, + authorization: authorization_from(response, parameters), + avs_result: AVSResult.new(code: response[:avs_code]), + cvv_result: CVVResult.new(response[:cvv2_reply]), + test: test?, + error_code: error_code_from(response) + ) + end + + def success_from(response) + response[:status] == "APPROVED" + end + + def message_from(response) + return "Success" if success_from(response) + response[:reason_codes] || response[:reason] + end + + def authorization_from(response, parameters) + [ + response[:auth_code], + response[:transaction_id], + response[:token], + parameters[:sg_ExpMonth], + parameters[:sg_ExpYear], + parameters[:sg_Amount] + ].join("|") + end + + def split_authorization(authorization) + auth_code, transaction_id, token, month, year, original_amount = authorization.split("|") + + { + auth_code: auth_code, + transaction_id: transaction_id, + token: token, + exp_month: month, + exp_year: year, + original_amount: amount(original_amount.to_f * 100) + } + end + + def post_data(params) + return nil unless params + + params.map do |key, value| + next if value != false && value.blank? + "#{key}=#{CGI.escape(value.to_s)}" + end.compact.join("&") + end + + def error_code_from(response) + unless success_from(response) + response[:ex_err_code] || response[:err_code] + end + end + + def underscore(camel_cased_word) + camel_cased_word.to_s.gsub(/::/, '/'). + gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). + gsub(/([a-z\d])([A-Z])/,'\1_\2'). + tr("-", "_"). + downcase + end + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index 53afcadef91..3d53bb0c999 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -1021,6 +1021,11 @@ s5: login: 8a82941847c4d0780147cea1d1730dcc password: n3yNMBGK +# Working credentials, no need to replace +safe_charge: + client_login_id: 'SpreedlyTestTRX' + client_password: '5Jp5xKmgqY' + sage: login: 214282982451 password: 'Z5W2S8J7X8T5' diff --git a/test/remote/gateways/remote_safe_charge_test.rb b/test/remote/gateways/remote_safe_charge_test.rb new file mode 100644 index 00000000000..5569eab9969 --- /dev/null +++ b/test/remote/gateways/remote_safe_charge_test.rb @@ -0,0 +1,138 @@ +require 'test_helper' + +class RemoteSafeChargeTest < Test::Unit::TestCase + def setup + @gateway = SafeChargeGateway.new(fixtures(:safe_charge)) + + @amount = 100 + @credit_card = credit_card('4000100011112224') + @declined_card = credit_card('4000300011112220') + @options = { + billing_address: address, + description: 'Store Purchase' + } + end + + def test_successful_purchase + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Success', response.message + end + + def test_successful_purchase_with_more_options + options = { + order_id: '1', + ip: "127.0.0.1", + email: "joe@example.com" + } + + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_equal 'Success', response.message + end + + def test_failed_purchase + response = @gateway.purchase(@amount, @declined_card, @options) + assert_failure response + assert_equal 'Decline', response.message + end + + def test_successful_authorize_and_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + assert_equal 'Success', capture.message + end + + def test_failed_authorize + response = @gateway.authorize(@amount, @declined_card, @options) + assert_failure response + assert_equal 'Decline', response.message + end + + def test_partial_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount-1, auth.authorization) + assert_success capture + end + + def test_failed_capture + response = @gateway.capture(@amount, '') + assert_failure response + assert_equal 'Transaction must contain a Card/Token/Account', response.message + end + + def test_successful_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount, purchase.authorization) + assert_success refund + assert_equal 'Success', refund.message + end + + def test_partial_refund + purchase = @gateway.purchase(200, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(100, purchase.authorization) + assert_success refund + end + + def test_failed_refund + response = @gateway.refund(@amount, '') + assert_failure response + assert_equal 'Transaction must contain a Card/Token/Account', response.message + end + + def test_successful_void + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert void = @gateway.void(auth.authorization) + assert_success void + assert_equal 'Success', void.message + end + + def test_failed_void + response = @gateway.void('') + assert_failure response + assert_equal 'Invalid Amount', response.message + end + + def test_successful_verify + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_match 'Success', response.message + end + + def test_failed_verify + response = @gateway.verify(@declined_card, @options) + assert_failure response + assert_match 'Decline', response.message + end + + def test_invalid_login + gateway = SafeChargeGateway.new(client_login_id: '', client_password: '') + + response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_match 'Invalid login', response.message + end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:client_password], transcript) + end + +end diff --git a/test/unit/gateways/safe_charge_test.rb b/test/unit/gateways/safe_charge_test.rb new file mode 100644 index 00000000000..440f42e1e4d --- /dev/null +++ b/test/unit/gateways/safe_charge_test.rb @@ -0,0 +1,256 @@ +require 'test_helper' + +class SafeChargeTest < Test::Unit::TestCase + def setup + @gateway = SafeChargeGateway.new(client_login_id: 'login', client_password: 'password') + @credit_card = credit_card + @amount = 100 + + @options = { + order_id: '1', + billing_address: address, + description: 'Store Purchase' + } + end + + def test_successful_purchase + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + + assert_equal '111951|101508189567|ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAd' \ + 'AAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAF' \ + 'UAbQBYAFIAMwA=|09|18|1.00', response.authorization + assert response.test? + end + + def test_failed_purchase + @gateway.expects(:ssl_post).returns(failed_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal "0", response.error_code + end + + def test_successful_authorize + @gateway.expects(:ssl_post).returns(successful_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + + assert_equal '111534|101508189855|MQBVAG4ASABkAEgAagB3AEsAbgAtACoAWgAzAFwAW' \ + 'wBNAF8ATQBUAD0AegBQAGwAQAAtAD0AXAB5AFkALwBtAFAALABaAHoAOgBFAE' \ + 'wAUAA1AFUAMwA=|09|18|1.00', response.authorization + assert response.test? + end + + def test_failed_authorize + @gateway.expects(:ssl_post).returns(failed_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_equal "0", response.error_code + end + + def test_successful_capture + @gateway.expects(:ssl_post).returns(successful_capture_response) + + response = @gateway.capture(@amount, "auth|transaction_id|token|month|year") + assert_success response + + assert_equal '111301|101508190200|RwA1AGQAMgAwAEkAWABKADkAcABjAHYAQQA4AC8AZ' \ + 'AAlAHMAfABoADEALAA8ADQAewB8ADsAewBiADsANQBoACwAeAA/AGQAXQAjAF' \ + 'EAYgBVAHIAMwA=|month|year|1.00', response.authorization + assert response.test? + end + + def test_failed_capture + @gateway.expects(:ssl_post).returns(failed_capture_response) + + response = @gateway.capture(@amount, '', @options) + assert_failure response + assert_equal "1163", response.error_code + end + + def test_successful_refund + end + + def test_failed_refund + @gateway.expects(:ssl_post).returns(failed_refund_response) + + response = @gateway.refund(@amount, '', @options) + assert_failure response + assert_equal "1163", response.error_code + end + + def test_successful_void + @gateway.expects(:ssl_post).returns(successful_void_response) + + response = @gateway.void("auth|transaction_id|token|month|year") + assert_success response + + assert_equal '111171|101508208625|ZQBpAFAAZgBuAHEATgBUAHcASAAwADUAcwBHAHQAV' \ + 'QBLAHAAbgB6AGwAJAA1AEMAfAB2AGYASwBrAHEAeQBOAEwAOwBZAGIAewB4AG' \ + 'wAYwBUAE0AMwA=|month|year|0.00', response.authorization + assert response.test? + end + + def test_failed_void + @gateway.expects(:ssl_post).returns(failed_void_response) + + response = @gateway.void('') + assert_failure response + assert_equal "Invalid Amount", response.message + assert response.test? + end + + def test_successful_verify + @gateway.expects(:ssl_post).times(2).returns(successful_authorize_response, successful_void_response) + + response = @gateway.verify(@credit_card, @options) + assert_success response + + assert_equal '111534|101508189855|MQBVAG4ASABkAEgAagB3AEsAbgAtACoAWgAzAFwAW' \ + 'wBNAF8ATQBUAD0AegBQAGwAQAAtAD0AXAB5AFkALwBtAFAALABaAHoAOgBFAE' \ + 'wAUAA1AFUAMwA=|09|18|1.00', response.authorization + assert response.test? + end + + def test_successful_verify_with_failed_void + @gateway.expects(:ssl_post).times(2).returns(successful_authorize_response, failed_void_response) + + response = @gateway.verify(@credit_card, @options) + assert_success response + end + + + + def test_failed_verify + @gateway.expects(:ssl_post).returns(failed_authorize_response) + + response = @gateway.verify(@credit_card, @options) + assert_failure response + assert_equal "0", response.error_code + end + + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + + private + + def pre_scrubbed + %q( +opening connection to process.sandbox.safecharge.com:443... +opened +starting SSL for process.sandbox.safecharge.com:443... +SSL established +<- "POST /service.asmx/Process 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: process.sandbox.safecharge.com\r\nContent-Length: 249\r\n\r\n" +<- "sg_TransType=Sale&sg_Currency=USD&sg_Amount=1.00&sg_ClientLoginID=SpreedlyTestTRX&sg_ClientPassword=5Jp5xKmgqY&sg_ResponseFormat=4&sg_Version=4.0.4&sg_NameOnCard=Longbob+Longsen&sg_CardNumber=4000100011112224&sg_ExpMonth=09&sg_ExpYear=18&sg_CVV2=123" +-> "HTTP/1.1 200 OK\r\n" +-> "Cache-Control: private, max-age=0\r\n" +-> "Content-Type: text/xml; charset=utf-8\r\n" +-> "Content-Encoding: gzip\r\n" +-> "Vary: Accept-Encoding\r\n" +-> "Server: Microsoft-IIS/8.5\r\n" +-> "X-AspNet-Version: 4.0.30319\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "Date: Wed, 29 Mar 2017 18:28:17 GMT\r\n" +-> "Connection: close\r\n" +-> "Content-Length: 727\r\n" +-> "Set-Cookie: visid_incap_847807=oQqFyASiS0y3sQoZ55M7TsH821gAAAAAQUIPAAAAAAA/rRn9PSjQ7LsSqhb2S1AZ; expires=Thu, 29 Mar 2018 13:12:58 GMT; path=/; Domain=.sandbox.safecharge.com\r\n" +-> "Set-Cookie: incap_ses_225_847807=H1/pC1tNgzhTmiAXOl0fA8H821gAAAAAFE9hBYJtG83f0yrtcxrGsg==; path=/; Domain=.sandbox.safecharge.com\r\n" +-> "X-Iinfo: 9-132035054-132035081 NNNN CT(207 413 0) RT(1490812095742 212) q(0 0 6 -1) r(14 14) U5\r\n" +-> "X-CDN: Incapsula\r\n" +-> "\r\n" +reading 727 bytes... + ) + end + + def post_scrubbed + %q( +opening connection to process.sandbox.safecharge.com:443... +opened +starting SSL for process.sandbox.safecharge.com:443... +SSL established +<- "POST /service.asmx/Process 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: process.sandbox.safecharge.com\r\nContent-Length: 249\r\n\r\n" +<- "sg_TransType=Sale&sg_Currency=USD&sg_Amount=1.00&sg_ClientLoginID=SpreedlyTestTRX&sg_ClientPassword=[FILTERED]&sg_ResponseFormat=4&sg_Version=4.0.4&sg_NameOnCard=Longbob+Longsen&sg_CardNumber=[FILTERED]&sg_ExpMonth=09&sg_ExpYear=18&sg_CVV2=[FILTERED]" +-> "HTTP/1.1 200 OK\r\n" +-> "Cache-Control: private, max-age=0\r\n" +-> "Content-Type: text/xml; charset=utf-8\r\n" +-> "Content-Encoding: gzip\r\n" +-> "Vary: Accept-Encoding\r\n" +-> "Server: Microsoft-IIS/8.5\r\n" +-> "X-AspNet-Version: 4.0.30319\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "Date: Wed, 29 Mar 2017 18:28:17 GMT\r\n" +-> "Connection: close\r\n" +-> "Content-Length: 727\r\n" +-> "Set-Cookie: visid_incap_847807=oQqFyASiS0y3sQoZ55M7TsH821gAAAAAQUIPAAAAAAA/rRn9PSjQ7LsSqhb2S1AZ; expires=Thu, 29 Mar 2018 13:12:58 GMT; path=/; Domain=.sandbox.safecharge.com\r\n" +-> "Set-Cookie: incap_ses_225_847807=H1/pC1tNgzhTmiAXOl0fA8H821gAAAAAFE9hBYJtG83f0yrtcxrGsg==; path=/; Domain=.sandbox.safecharge.com\r\n" +-> "X-Iinfo: 9-132035054-132035081 NNNN CT(207 413 0) RT(1490812095742 212) q(0 0 6 -1) r(14 14) U5\r\n" +-> "X-CDN: Incapsula\r\n" +-> "\r\n" +reading 727 bytes... + ) + end + + def successful_purchase_response + %( + 4.0.4SpreedlyTestTRX101508189567APPROVED11195100ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAdAAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAFUAbQBYAFIAMwA=19University First Federal Credit UnionusSuiMHP60FrDKfyaJs47hqqrR/JU=0CreditAccept + ) + end + + def failed_purchase_response + %( + 4.0.4SpreedlyTestTRX101508189637DECLINEDDecline-10bwBVAEYAUgBuAGcAbABSAFYASgB5AEAAMgA/ACsAUQBIAC4AbgB1AHgAdABAAE8ARgBRAGoAbwApACQAWwBKAFwATwAxAEcAMwBZAG4AdwBmACgAMwA=19GyueFkuQqW+UL38d57fuA5/RqfQ=0Accept + ) + end + + def successful_authorize_response + %( + 4.0.4SpreedlyTestTRX101508189855APPROVED11153400MQBVAG4ASABkAEgAagB3AEsAbgAtACoAWgAzAFwAWwBNAF8ATQBUAD0AegBQAGwAQAAtAD0AXAB5AFkALwBtAFAALABaAHoAOgBFAEwAUAA1AFUAMwA=19University First Federal Credit UnionusSuiMHP60FrDKfyaJs47hqqrR/JU=0CreditAccept + ) + end + + def failed_authorize_response + %( + 4.0.4SpreedlyTestTRX101508190604DECLINEDDecline-10MQBLAG4AMgAwADMAOABmAFYANABbAGYAcwA+ACMAVgBXAD0AUQBQAEoANQBrAHQAWABsAFEAeABQAF8ARwA6ACsALgBHADUALwBTAEAARwBIACgAMwA=19GyueFkuQqW+UL38d57fuA5/RqfQ=0Accept + ) + end + + def successful_capture_response + %( + 4.0.4SpreedlyTestTRX101508190200APPROVED11130100RwA1AGQAMgAwAEkAWABKADkAcABjAHYAQQA4AC8AZAAlAHMAfABoADEALAA8ADQAewB8ADsAewBiADsANQBoACwAeAA/AGQAXQAjAFEAYgBVAHIAMwA=19University First Federal Credit UnionusSuiMHP60FrDKfyaJs47hqqrR/JU=0Credit + ) + end + + def failed_capture_response + %( + 4.0.4SpreedlyTestTRX101508190627ERRORTransaction must contain a Card/Token/Account-11001163-12jmj7l5rSw0yVb/vlWAYkK/YBwk=0 + ) + end + + def successful_refund_response + end + + def failed_refund_response + %( + 4.0.4SpreedlyTestTRX101508208595ERRORTransaction must contain a Card/Token/Account-11001163-12jmj7l5rSw0yVb/vlWAYkK/YBwk=0 + ) + end + + def successful_void_response + %( + 4.0.4SpreedlyTestTRX101508208625APPROVED11117100ZQBpAFAAZgBuAHEATgBUAHcASAAwADUAcwBHAHQAVQBLAHAAbgB6AGwAJAA1AEMAfAB2AGYASwBrAHEAeQBOAEwAOwBZAGIAewB4AGwAYwBUAE0AMwA=19University First Federal Credit UnionusSuiMHP60FrDKfyaJs47hqqrR/JU=0Credit + ) + end + + def failed_void_response + %( + 4.0.4SpreedlyTestTRX101508208633ERRORInvalid Amount-11001201-12jmj7l5rSw0yVb/vlWAYkK/YBwk=0 + ) + end +end From bdf5c2dbf62884de44824963907a78981aa405aa Mon Sep 17 00:00:00 2001 From: David Perry Date: Wed, 1 Mar 2017 09:28:26 -0500 Subject: [PATCH 033/677] TransFirst Transaction Express: Support ACH This adds support for purchase, refund, and void of eChecks. eCheck general credit transactions ("blind credit") are strictly controlled by TransFirst and are not included in this implementation. It also cleans up some remote tests and removed tests for "partial purchases", which aren't actually a thing. 29 tests, 99 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2389 --- CHANGELOG | 1 + .../trans_first_transaction_express.rb | 56 +++++++++++--- ...te_trans_first_transaction_express_test.rb | 47 +++++++++--- .../trans_first_transaction_express_test.rb | 74 +++++++++++++++---- 4 files changed, 143 insertions(+), 35 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ed7435d5153..a9dd209dad7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * Payeezy: Support dynamic soft descriptors [shasum] #2384 * Stripe: Support custom application in X-Stripe-Client-User-Agent header [davidsantoso] * SafeCharge: Add gateway [davidsantoso] +* TransFirst Transaction Express: Support ACH [curiousepic] #2389 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb index 5c1908a47cc..577147199cc 100644 --- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb @@ -175,6 +175,10 @@ class TransFirstTransactionExpressGateway < Gateway verify: 9, + purchase_echeck: 11, + refund_echeck: 16, + void_echeck: 16, + wallet_sale: 14, } @@ -187,7 +191,15 @@ def purchase(amount, payment_method, options={}) if credit_card?(payment_method) action = :purchase request = build_xml_transaction_request do |doc| - add_payment_method(doc, payment_method) + add_credit_card(doc, payment_method) + add_contact(doc, payment_method.name, options) + add_amount(doc, amount) + add_order_number(doc, options) + end + elsif echeck?(payment_method) + action = :purchase_echeck + request = build_xml_transaction_request do |doc| + add_echeck(doc, payment_method) add_contact(doc, payment_method.name, options) add_amount(doc, amount) add_order_number(doc, options) @@ -207,7 +219,7 @@ def purchase(amount, payment_method, options={}) def authorize(amount, payment_method, options={}) if credit_card?(payment_method) request = build_xml_transaction_request do |doc| - add_payment_method(doc, payment_method) + add_credit_card(doc, payment_method) add_contact(doc, payment_method.name, options) add_amount(doc, amount) end @@ -243,14 +255,14 @@ def void(authorization, options={}) end def refund(amount, authorization, options={}) - transaction_id = split_authorization(authorization)[1] + action, transaction_id = split_authorization(authorization) request = build_xml_transaction_request do |doc| - add_amount(doc, amount) + add_amount(doc, amount) unless action == 'purchase_echeck' add_original_transaction_data(doc, transaction_id) end - commit(:refund, request) + commit(refund_type(action), request) end def credit(amount, payment_method, options={}) @@ -264,7 +276,7 @@ def credit(amount, payment_method, options={}) def verify(credit_card, options={}) request = build_xml_transaction_request do |doc| - add_payment_method(doc, credit_card) + add_credit_card(doc, credit_card) add_contact(doc, credit_card.name, options) end @@ -286,7 +298,7 @@ def store(payment_method, options={}) add_customer_id(doc, customer_id) doc["v1"].pmt do doc["v1"].type 0 # add - add_payment_method(doc, payment_method) + add_credit_card(doc, payment_method) end end end @@ -383,8 +395,9 @@ def message_from(succeeded, response) message = RESPONSE_MESSAGES[code] extended = EXTENDED_RESPONSE_MESSAGES[extended_code] + ach_response = response["achResponse"] - [message, extended].compact.join('. ') + [message, extended, ach_response].compact.join('. ') else response["faultstring"] end @@ -401,7 +414,11 @@ def authorization_from(action, response) # -- helper methods ---------------------------------------------------- def credit_card?(payment_method) - payment_method.respond_to?(:number) + payment_method.respond_to?(:verification_value) + end + + def echeck?(payment_method) + payment_method.respond_to?(:routing_number) end def split_authorization(authorization) @@ -409,7 +426,11 @@ def split_authorization(authorization) end def void_type(action) - :"void_#{action}" + action == 'purchase_echeck' ? :void_echeck : :"void_#{action}" + end + + def refund_type(action) + action == 'purchase_echeck' ? :refund_echeck : :refund end # -- request methods --------------------------------------------------- @@ -482,7 +503,7 @@ def add_order_number(doc, options) } end - def add_payment_method(doc, payment_method) + def add_credit_card(doc, payment_method) doc["v1"].card { doc["v1"].pan payment_method.number doc["v1"].sec payment_method.verification_value if payment_method.verification_value? @@ -490,6 +511,13 @@ def add_payment_method(doc, payment_method) } end + def add_echeck(doc, payment_method) + doc["v1"].achEcheck { + doc["v1"].bankRtNr payment_method.routing_number + doc["v1"].acctNr payment_method.account_number + } + end + def expiration_date(payment_method) yy = format(payment_method.year, :two_digits) mm = format(payment_method.month, :two_digits) @@ -540,6 +568,12 @@ def add_contact(doc, fullname, options) end end + def add_name(doc, payment_method) + doc["v1"].contact do + doc["v1"].fullName payment_method.name + end + end + def add_original_transaction_data(doc, authorization) doc["v1"].origTranData do doc["v1"].tranNr authorization diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb index 235b25d8fc1..7c53ebaa968 100644 --- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb +++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb @@ -7,8 +7,8 @@ def setup @amount = 100 @declined_amount = 21 - @partial_amount = 1110 @credit_card = credit_card("4485896261017708") + @check = check billing_address = address({ address1: "450 Main", @@ -79,20 +79,25 @@ def test_successful_purchase_with_empty_string_cvv assert_equal "Succeeded", response.message end - def test_partial_purchase - response = @gateway.purchase(@partial_amount, @credit_card, @options) + def test_successful_purchase_with_echeck + assert response = @gateway.purchase(@amount, @check, @options) assert_success response - assert_equal "Succeeded", response.message - assert_match /0*555$/, response.params["amt"] + assert_equal 'Succeeded', response.message end def test_failed_purchase - response = @gateway.purchase(@rejected_amount, @declined_card, @options) + response = @gateway.purchase(@declined_amount, @credit_card, @options) assert_failure response assert_equal "Not sufficient funds", response.message assert_equal "51", response.params["rspCode"] end + def test_failed_purchase_with_echeck + assert response = @gateway.purchase(@amount, check(routing_number: "121042883"), @options) + assert_failure response + assert_equal 'Error. Bank routing number validation negative (ABA).', response.message + end + def test_successful_authorize_and_capture response = @gateway.authorize(@amount, @credit_card, @options) assert_success response @@ -152,10 +157,19 @@ def test_successful_capture_void end def test_failed_void - response = @gateway.void("") + response = @gateway.void("purchase|000015212561") assert_failure response - assert_equal "Validation Failure", response.message - assert_equal "50011", response.error_code + assert_equal "Invalid transaction", response.message + assert_equal "12", response.error_code + end + + def test_successful_echeck_purchase_void + response = @gateway.purchase(@amount, @check, @options) + assert_success response + + void = @gateway.void(response.authorization) + assert_success void + assert_equal "Succeeded", void.message end # gateway does not settle fast enough to test refunds @@ -185,6 +199,21 @@ def test_failed_refund assert_equal "50011", response.error_code end + def test_successful_refund_with_echeck + purchase = @gateway.purchase(@amount, @check, @options) + assert_success purchase + assert_match /purchase_echeck/, purchase.authorization + + refund = @gateway.refund(@amount, purchase.authorization) + assert_success refund + end + + def test_failed_refund_with_echeck + refund = @gateway.refund(@amount, 'purchase_echeck|000028706091') + assert_failure refund + assert_equal "Invalid transaction", refund.message + end + # Credit is only supported with specific approval from Transaction Express # def test_successful_credit # response = @gateway.credit(@amount, @credit_card, @options) diff --git a/test/unit/gateways/trans_first_transaction_express_test.rb b/test/unit/gateways/trans_first_transaction_express_test.rb index 938c94a71a5..86db994262b 100644 --- a/test/unit/gateways/trans_first_transaction_express_test.rb +++ b/test/unit/gateways/trans_first_transaction_express_test.rb @@ -10,9 +10,9 @@ def setup ) @credit_card = credit_card + @check = check @amount = 100 @declined_amount = 21 - @partial_amount = 1110 end def test_successful_purchase @@ -26,16 +26,6 @@ def test_successful_purchase assert response.test? end - def test_partial_purchase - response = stub_comms do - @gateway.purchase(@partial_amount, @credit_card) - end.respond_with(partial_purchase_response) - - assert_success response - assert_equal "000000000555", response.params["amt"] - assert response.test? - end - def test_failed_purchase response = stub_comms do @gateway.purchase(@declined_amount, @credit_card) @@ -47,6 +37,22 @@ def test_failed_purchase assert response.test? end + def test_successful_purchase_with_echeck + @gateway.stubs(:ssl_post).returns(successful_purchase_echeck_response) + response = @gateway.purchase(@amount, @check) + + assert_success response + assert_equal "purchase_echeck|000028705491", response.authorization + end + + def test_failed_purchase_with_echeck + @gateway.stubs(:ssl_post).returns(failed_purchase_echeck_response) + response = @gateway.purchase(@amount, @check) + + assert_failure response + assert_equal "Error. Bank routing number validation negative (ABA).", response.message + end + def test_successful_authorize_and_capture response = stub_comms do @gateway.authorize(@amount, @credit_card) @@ -137,6 +143,32 @@ def test_failed_refund assert_equal "50011", response.error_code end + def test_successful_refund_with_echeck + response = stub_comms do + @gateway.purchase(@amount, @check) + end.respond_with(successful_purchase_echeck_response) + + assert_success response + assert_equal "purchase_echeck|000028705491", response.authorization + + refund = stub_comms do + @gateway.refund(@amount, response.authorization) + end.check_request do |endpoint, data, headers| + assert_match(/000028705491/, data) + end.respond_with(successful_refund_echeck_response) + + assert_success refund + end + + def test_failed_refund_with_echeck + response = stub_comms do + @gateway.refund(@amount, 'purchase_echeck|000028706091') + end.respond_with(failed_refund_response) + + assert_failure response + assert_equal "50011", response.error_code + end + def test_successful_credit response = stub_comms do @gateway.credit(@amount, @credit_card) @@ -216,10 +248,6 @@ def successful_purchase_response %(00Y0A1009331525B2A2DBFAF771E2E62B0000152125612016-01-19T10:33:57.000-08:00000000000100305156Lexc050300979940268000) end - def partial_purchase_response - %(10MZY0A10092D15279AD062097039A74A150000155261612016-01-25T08:45:28.000-08:00000000000555332604Lexc0503009799402680000057840C000000001110) - end - def failed_purchase_response %(51Y0A1009331525BA8F333FC15F59AB320000152206712016-01-19T12:52:25.000-08:00000000000021305918Lexc050300979940268000) end @@ -272,6 +300,22 @@ def failed_store_response %(S:ServerValidation FailureValidation Faultcvc-type.3.1.3: The value '123' of element 'v1:pan' is not valid.50011) end + def successful_purchase_echeck_response + %(00435508710A09071615AD2403F804EFDA26EA760000287054912017-03-15T06:55:10-07:00000000000100386950Transaction processed.PrevPay: nil +0Score: 100/100) + end + + def failed_purchase_echeck_response + %(060A09071715AD2654A6814EE9ADC0EF0000287057112017-03-15T07:35:38-07:00000000000100386972Bank routing number validation negative (ABA).) + end + + def successful_refund_echeck_response + %( 00435508890A09071715AD2786821E2F357D7E520000287060912017-03-15T07:56:31-07:00000000000100387010Transaction Cancelled.PrevPay: nil +0Score: 100/100Cancellation Notes: RefNumber:28706091) + end + + def failed_refund_echeck_response + %(12B40F435508890A09071615AD285C3E4E0AE3A42CF30000287060912017-03-15T08:11:06-07:00000000000100) + end + def empty_purchase_response %() end From 69d8c0fadc663a286bf5da41fac785c41535923d Mon Sep 17 00:00:00 2001 From: Bart de Water Date: Thu, 6 Apr 2017 14:28:23 -0400 Subject: [PATCH 034/677] Fix 'posting to plaintext endpoint, which is insecure' warning when passing a URI object to ssl_request ```ruby URI('https://foo.com') =~ /^https:/ => nil # would trigger warning ``` --- lib/active_merchant/posts_data.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_merchant/posts_data.rb b/lib/active_merchant/posts_data.rb index ad5e03ebd15..666cadd4fc1 100644 --- a/lib/active_merchant/posts_data.rb +++ b/lib/active_merchant/posts_data.rb @@ -41,7 +41,7 @@ def ssl_request(method, endpoint, data, headers) def raw_ssl_request(method, endpoint, data, headers = {}) logger.warn "#{self.class} using ssl_strict=false, which is insecure" if logger unless ssl_strict - logger.warn "#{self.class} posting to plaintext endpoint, which is insecure" if logger unless endpoint =~ /^https:/ + logger.warn "#{self.class} posting to plaintext endpoint, which is insecure" if logger unless endpoint.to_s =~ /^https:/ connection = new_connection(endpoint) connection.open_timeout = open_timeout From 13425d04c1a0f7377ad956b24cbd66728711ebb9 Mon Sep 17 00:00:00 2001 From: Bart de Water Date: Thu, 12 Jan 2017 22:51:12 -0500 Subject: [PATCH 035/677] Test Ruby 2.4, test w/ release version of Active Support 5 --- .travis.yml | 16 ++++++++++++++-- Gemfile.rails32 | 2 +- Gemfile.rails40 | 2 +- Gemfile.rails41 | 2 +- Gemfile.rails42 | 2 +- Gemfile.rails50 | 2 +- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index e2b674827da..b9d08f78879 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,9 @@ cache: bundler rvm: - 2.1 -- 2.2.3 -- 2.3.3 +- 2.2.7 +- 2.3.4 +- 2.4.1 gemfile: - Gemfile.rails32 @@ -19,6 +20,17 @@ matrix: exclude: - rvm: 2.1 gemfile: Gemfile.rails50 + - rvm: 2.4.1 + gemfile: Gemfile.rails32 + - rvm: 2.4.1 + gemfile: Gemfile.rails40 + - rvm: 2.4.1 + gemfile: Gemfile.rails41 + include: + - rvm: 2.4.1 + gemfile: Gemfile.rails51 + allow_failures: + - gemfile: Gemfile.rails51 notifications: email: diff --git a/Gemfile.rails32 b/Gemfile.rails32 index cc1430f5681..188439ed3d5 100644 --- a/Gemfile.rails32 +++ b/Gemfile.rails32 @@ -8,4 +8,4 @@ group :test, :remote_test do gem 'braintree', '>= 2.50.0' end -gem 'rails', '~> 3.2.0' +gem 'activesupport', '~> 3.2.0' diff --git a/Gemfile.rails40 b/Gemfile.rails40 index 26f25a01cee..6842a77d1ff 100644 --- a/Gemfile.rails40 +++ b/Gemfile.rails40 @@ -8,4 +8,4 @@ group :test, :remote_test do gem 'braintree', '>= 2.50.0' end -gem 'rails', '~> 4.0.0' +gem 'activesupport', '~> 4.0.0' diff --git a/Gemfile.rails41 b/Gemfile.rails41 index 6a44812d025..150a0bfe06b 100644 --- a/Gemfile.rails41 +++ b/Gemfile.rails41 @@ -8,4 +8,4 @@ group :test, :remote_test do gem 'braintree', '>= 2.50.0' end -gem 'rails', '~> 4.1.0' +gem 'activesupport', '~> 4.1.0' diff --git a/Gemfile.rails42 b/Gemfile.rails42 index 7cf96452cdf..fc4470341d5 100644 --- a/Gemfile.rails42 +++ b/Gemfile.rails42 @@ -8,4 +8,4 @@ group :test, :remote_test do gem 'braintree', '>= 2.50.0' end -gem 'rails', '~> 4.2.0' +gem 'activesupport', '~> 4.2.0' diff --git a/Gemfile.rails50 b/Gemfile.rails50 index 5b6ae97c89f..39f1278ff9f 100644 --- a/Gemfile.rails50 +++ b/Gemfile.rails50 @@ -8,4 +8,4 @@ group :test, :remote_test do gem 'braintree', '>= 2.50.0' end -gem 'rails', '~> 5.0.0' +gem 'activesupport', '~> 5.0.0' From 5f42ef1fd10f0357c1f3eb967384c51026c41072 Mon Sep 17 00:00:00 2001 From: Bart de Water Date: Fri, 13 Jan 2017 09:55:36 -0500 Subject: [PATCH 036/677] Add single canary build to matrix for Rails 5.1 --- Gemfile.rails51 | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Gemfile.rails51 diff --git a/Gemfile.rails51 b/Gemfile.rails51 new file mode 100644 index 00000000000..f40849829a3 --- /dev/null +++ b/Gemfile.rails51 @@ -0,0 +1,11 @@ +source 'https://rubygems.org' +gemspec + +gem 'jruby-openssl', :platforms => :jruby + +group :test, :remote_test do + # gateway-specific dependencies, keeping these gems out of the gemspec + gem 'braintree', '>= 2.50.0' +end + +gem 'activesupport', gem 'activesupport', '~> 5.1.0.rc1' From d224dbe1ff98f3fd3e030b93021c8feba00c0167 Mon Sep 17 00:00:00 2001 From: nicolas-maalouf-cko Date: Wed, 5 Apr 2017 09:52:43 +0100 Subject: [PATCH 037/677] Checkout V2: Fix sandbox URL Closes #2391 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/checkout_v2.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a9dd209dad7..76dbb8447e2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * Stripe: Support custom application in X-Stripe-Client-User-Agent header [davidsantoso] * SafeCharge: Add gateway [davidsantoso] * TransFirst Transaction Express: Support ACH [curiousepic] #2389 +* Checkout V2: Fix sandbox URL [nicolas-maalouf-cko] #2391 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb index 571d96a49ee..76343b09317 100644 --- a/lib/active_merchant/billing/gateways/checkout_v2.rb +++ b/lib/active_merchant/billing/gateways/checkout_v2.rb @@ -4,7 +4,7 @@ class CheckoutV2Gateway < Gateway self.display_name = "Checkout.com V2 Gateway" self.homepage_url = "https://www.checkout.com/" self.live_url = "https://api2.checkout.com/v2" - self.test_url = "http://sandbox.checkout.com/api2/v2" + self.test_url = "https://sandbox.checkout.com/api2/v2" self.supported_countries = ['AD', 'AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GI', 'GL', 'GR', 'HR', 'HU', 'IE', 'IS', 'IL', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SM', 'SK', 'SJ', 'TR', 'VA'] self.default_currency = "USD" From c8e7d759f0bda7d439386a92fbea09ef8ef42f39 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Mon, 10 Apr 2017 15:36:02 -0400 Subject: [PATCH 038/677] Checkout V2: Fix success_from not properly checking two possible success codes --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/checkout_v2.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 76dbb8447e2..f626c4276e1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ * SafeCharge: Add gateway [davidsantoso] * TransFirst Transaction Express: Support ACH [curiousepic] #2389 * Checkout V2: Fix sandbox URL [nicolas-maalouf-cko] #2391 +* Checkout V2: Fix success_from not properly checking two possible success codes [davidsantoso] == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb index 76343b09317..e6739abec48 100644 --- a/lib/active_merchant/billing/gateways/checkout_v2.rb +++ b/lib/active_merchant/billing/gateways/checkout_v2.rb @@ -165,7 +165,7 @@ def parse(body) end def success_from(response) - response["responseCode"] == ("10000" || "10100") + response["responseCode"] == "10000" || response["responseCode"] == "10100" end def message_from(succeeded, response) From 54557d805e79973b8914b99dcf8bf5ec818818e4 Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 4 Apr 2017 11:13:54 -0400 Subject: [PATCH 039/677] SagePay: Support Repeat transactions Also deactivates the remote test for a Maestro card since it is not supported for accounts set to use GBP currency, and prevents an order_id conflict for another test. Closes #2395 --- CHANGELOG | 1 + .../billing/gateways/sage_pay.rb | 13 ++++--- test/remote/gateways/remote_sage_pay_test.rb | 37 ++++++++++++------- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f626c4276e1..a6e950e6066 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * TransFirst Transaction Express: Support ACH [curiousepic] #2389 * Checkout V2: Fix sandbox URL [nicolas-maalouf-cko] #2391 * Checkout V2: Fix success_from not properly checking two possible success codes [davidsantoso] +* SagePay: Support Repeat transactions [curiousepic] #2395 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index 788c2ada605..a05dd2a80e5 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -20,7 +20,8 @@ class SagePayGateway < Gateway :void => 'VOID', :abort => 'ABORT', :store => 'TOKEN', - :unstore => 'REMOVETOKEN' + :unstore => 'REMOVETOKEN', + :repeat => 'REPEAT' } CREDIT_CARDS = { @@ -87,7 +88,7 @@ def purchase(money, payment_method, options = {}) add_customer_data(post, options) add_optional_data(post, options) - commit(:purchase, post) + commit((options[:repeat] ? :repeat : :purchase), post) end def authorize(money, payment_method, options = {}) @@ -130,7 +131,7 @@ def refund(money, identification, options = {}) post = {} - add_credit_reference(post, identification) + add_related_reference(post, identification) add_amount(post, money, options) add_invoice(post, options) @@ -195,7 +196,7 @@ def add_reference(post, identification) add_pair(post, :SecurityKey, security_key) end - def add_credit_reference(post, identification) + def add_related_reference(post, identification) order_id, transaction_id, authorization, security_key = identification.split(';') add_pair(post, :RelatedVendorTxCode, order_id) @@ -267,7 +268,9 @@ def add_invoice(post, options) end def add_payment_method(post, payment_method, options) - if payment_method.respond_to?(:number) + if options[:repeat] + add_related_reference(post, payment_method) + elsif payment_method.respond_to?(:number) add_credit_card(post, payment_method) else add_token_details(post, payment_method, options) diff --git a/test/remote/gateways/remote_sage_pay_test.rb b/test/remote/gateways/remote_sage_pay_test.rb index fb3e17c3cdd..7c538ebc2f4 100644 --- a/test/remote/gateways/remote_sage_pay_test.rb +++ b/test/remote/gateways/remote_sage_pay_test.rb @@ -159,12 +159,13 @@ def test_successful_visa_purchase assert !response.authorization.blank? end - def test_successful_maestro_purchase - assert response = @gateway.purchase(@amount, @maestro, @options) - assert_success response - assert response.test? - assert !response.authorization.blank? - end + # Maestro is not available for GBP + # def test_successful_maestro_purchase + # assert response = @gateway.purchase(@amount, @maestro, @options) + # assert_success response + # assert response.test? + # assert !response.authorization.blank? + # end def test_successful_amex_purchase assert response = @gateway.purchase(@amount, @amex, @options) @@ -313,6 +314,14 @@ def test_successful_purchase_with_website assert_success response end + def test_successful_repeat_purchase + response = @gateway.purchase(@amount, @visa, @options) + assert_success response + + repeat = @gateway.purchase(@amount, response.authorization, @options.merge(repeat: true, order_id: generate_unique_id)) + assert_success repeat + end + def test_invalid_login message = SagePayGateway.simulate ? 'VSP Simulator cannot find your vendor name. Ensure you have have supplied a Vendor field with your VSP Vendor name assigned to it.' : '3034 : The Vendor or VendorName value is required.' @@ -337,7 +346,7 @@ def test_successful_store_and_repurchase_with_resupplied_verification_value assert_success response assert !response.authorization.blank? assert purchase = @gateway.purchase(@amount, response.authorization, @options.merge(customer: 1)) - assert purchase = @gateway.purchase(@amount, response.authorization, @options.merge(verification_value: '123', order_id: 'foobar123')) + assert purchase = @gateway.purchase(@amount, response.authorization, @options.merge(verification_value: '123', order_id: generate_unique_id)) assert_success purchase end @@ -417,13 +426,13 @@ def basket_xml # Example from http://www.sagepay.co.uk/support/customer-xml def customer_xml <<-XML - - W - 1983-01-01 - 020 1234567 - 0799 1234567 - 0 - 10 + + W + 1983-01-01 + 020 1234567 + 0799 1234567 + 0 + 10 CUST123 XML From 9652dd29fa8d0a2292af7914b510e6231bae0fb9 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Thu, 13 Apr 2017 12:55:14 -0400 Subject: [PATCH 040/677] PayU LATAM: Fix incorrect capture method definition --- CHANGELOG | 1 + .../billing/gateways/payu_latam.rb | 2 +- .../remote/gateways/remote_payu_latam_test.rb | 15 ++++++ test/unit/gateways/payu_latam_test.rb | 52 +++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a6e950e6066..b6d5508d5c6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * Checkout V2: Fix sandbox URL [nicolas-maalouf-cko] #2391 * Checkout V2: Fix success_from not properly checking two possible success codes [davidsantoso] * SagePay: Support Repeat transactions [curiousepic] #2395 +* PayU LATAM: Fix incorrect capture method definition [davidsantoso] == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index 832a6754e70..f88ea24c167 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -45,7 +45,7 @@ def authorize(amount, payment_method, options={}) commit('auth', post) end - def capture(authorization, options={}) + def capture(amount, authorization, options={}) post = {} add_credentials(post, 'SUBMIT_TRANSACTION') diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index 5685fa8feb1..c7517612da3 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -130,6 +130,21 @@ def test_failed_void assert_match /property: parentTransactionId, message: must not be null/, response.message end + def test_successful_authorize_and_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + assert_equal 'APPROVED', response.message + end + + def test_failed_capture + response = @gateway.capture(@amount, '') + assert_failure response + assert_match /must not be null/, response.message + end + def test_verify_credentials assert @gateway.verify_credentials diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb index 800e7fa36ad..ae4576ce3c7 100644 --- a/test/unit/gateways/payu_latam_test.rb +++ b/test/unit/gateways/payu_latam_test.rb @@ -140,6 +140,22 @@ def test_request_passes_cvv_option assert response.test? end + def test_successful_capture + @gateway.expects(:ssl_post).returns(successful_capture_response) + + response = @gateway.capture(@amount, "4000|authorization", @options) + assert_success response + assert_equal "APPROVED", response.message + end + + def test_failed_capture + @gateway.expects(:ssl_post).returns(failed_void_response) + + response = @gateway.capture(@amount, "") + assert_failure response + assert_equal "property: order.id, message: must not be null property: parentTransactionId, message: must not be null", response.message + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed @@ -390,6 +406,42 @@ def failed_void_response RESPONSE end + def successful_capture_response + <<-RESPONSE + { + "code": "SUCCESS", + "error": null, + "transactionResponse": { + "orderId": 272601, + "transactionId": "66c7bff2-c423-42ed-800a-8be11531e7a1", + "state": "APPROVED", + "paymentNetworkResponseCode": null, + "paymentNetworkResponseErrorMessage": null, + "trazabilityCode": "00000000", + "authorizationCode": "00000000", + "pendingReason": null, + "responseCode": "APPROVED", + "errorCode": null, + "responseMessage": null, + "transactionDate": null, + "transactionTime": null, + "operationDate": 1314012754, + "extraParameters": null + } + } + RESPONSE + end + + def failed_capture_response + <<-RESPONSE + { + "code":"ERROR", + "error":"property: order.id, message: must not be null property: parentTransactionId, message: must not be null", + "transactionResponse": null + } + RESPONSE + end + def credentials_are_legit_response <<-RESPONSE { From 14213df6ede21643b243811341b92293542fffe8 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Tue, 18 Apr 2017 20:32:39 +0530 Subject: [PATCH 041/677] Beanstream: Map ISO province codes for US and CA Closes #2396 --- CHANGELOG | 1 + .../gateways/beanstream/beanstream_core.rb | 70 ++++++++++++++++++- .../remote/gateways/remote_beanstream_test.rb | 33 ++++++++- 3 files changed, 101 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b6d5508d5c6..177aae344f0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ * Checkout V2: Fix success_from not properly checking two possible success codes [davidsantoso] * SagePay: Support Repeat transactions [curiousepic] #2395 * PayU LATAM: Fix incorrect capture method definition [davidsantoso] +* Beanstream: Map ISO province codes for US and CA [shasum] #2396 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index cd7262a4afd..4739602b447 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -59,6 +59,72 @@ module BeanstreamCore :cancel => 'C' } + STATES = { + "ALBERTA" => "AB", + "BRITISH COLUMBIA" => "BC", + "MANITOBA" => "MB", + "NEW BRUNSWICK" => "NB", + "NEWFOUNDLAND AND LABRADOR" => "NL", + "NOVA SCOTIA" => "NS", + "ONTARIO" => "ON", + "PRINCE EDWARD ISLAND" => "PE", + "QUEBEC" => "QC", + "SASKATCHEWAN" => "SK", + "NORTHWEST TERRITORIES" => "NT", + "NUNAVUT" => "NU", + "YUKON" => "YT", + "ALABAMA" => "AL", + "ALASKA" => "AK", + "ARIZONA" => "AZ", + "ARKANSAS" => "AR", + "CALIFORNIA" => "CA", + "COLORADO" => "CO", + "CONNECTICUT" => "CT", + "DELAWARE" => "DE", + "FLORIDA" => "FL", + "GEORGIA" => "GA", + "HAWAII" => "HI", + "IDAHO" => "ID", + "ILLINOIS" => "IL", + "INDIANA" => "IN", + "IOWA" => "IA", + "KANSAS" => "KS", + "KENTUCKY" => "KY", + "LOUISIANA" => "LA", + "MAINE" => "ME", + "MARYLAND" => "MD", + "MASSACHUSETTS" => "MA", + "MICHIGAN" => "MI", + "MINNESOTA" => "MN", + "MISSISSIPPI" => "MS", + "MISSOURI" => "MO", + "MONTANA" => "MT", + "NEBRASKA" => "NE", + "NEVADA" => "NV", + "NEW HAMPSHIRE" => "NH", + "NEW JERSEY" => "NJ", + "NEW MEXICO" => "NM", + "NEW YORK" => "NY", + "NORTH CAROLINA" => "NC", + "NORTH DAKOTA" => "ND", + "OHIO" => "OH", + "OKLAHOMA" => "OK", + "OREGON" => "OR", + "PENNSYLVANIA" => "PA", + "RHODE ISLAND" => "RI", + "SOUTH CAROLINA" => "SC", + "SOUTH DAKOTA" => "SD", + "TENNESSEE" => "TN", + "TEXAS" => "TX", + "UTAH" => "UT", + "VERMONT" => "VT", + "VIRGINIA" => "VA", + "WASHINGTON" => "WA", + "WEST VIRGINIA" => "WV", + "WISCONSIN" => "WI", + "WYOMING" => "WY" + } + def self.included(base) base.default_currency = 'CAD' @@ -161,7 +227,7 @@ def add_address(post, options) post[:ordAddress1] = billing_address[:address1] post[:ordAddress2] = billing_address[:address2] post[:ordCity] = billing_address[:city] - post[:ordProvince] = billing_address[:state] + post[:ordProvince] = STATES[billing_address[:state].upcase] || billing_address[:state] if billing_address[:state] post[:ordPostalCode] = billing_address[:zip] post[:ordCountry] = billing_address[:country] end @@ -172,7 +238,7 @@ def add_address(post, options) post[:shipAddress1] = shipping_address[:address1] post[:shipAddress2] = shipping_address[:address2] post[:shipCity] = shipping_address[:city] - post[:shipProvince] = shipping_address[:state] + post[:shipProvince] = STATES[shipping_address[:state].upcase] || shipping_address[:state] if shipping_address[:state] post[:shipPostalCode] = shipping_address[:zip] post[:shipCountry] = shipping_address[:country] post[:shippingMethod] = shipping_address[:shipping_method] diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb index 2362f197f62..6db19868979 100644 --- a/test/remote/gateways/remote_beanstream_test.rb +++ b/test/remote/gateways/remote_beanstream_test.rb @@ -36,10 +36,20 @@ def setup :address1 => '4444 Levesque St.', :address2 => 'Apt B', :city => 'Montreal', - :state => 'QC', + :state => 'Quebec', :country => 'CA', :zip => 'H2C1X8' }, + :shipping_address => { + :name => 'shippy', + :phone => '888-888-8888', + :address1 => '777 Foster Street', + :address2 => 'Ste #100', + :city => 'Durham', + :state => 'North Carolina', + :country => 'US', + :zip => '27701' + }, :email => 'xiaobozzz@example.com', :subtotal => 800, :shipping => 100, @@ -92,6 +102,27 @@ def test_unsuccessful_amex_purchase assert_equal 'DECLINE', response.message end + def test_successful_purchase_with_state_in_iso_format + assert response = @gateway.purchase(@amount, @visa, @options.merge(billing_address: address, shipping_address: address)) + assert_success response + assert_false response.authorization.blank? + assert_equal "Approved", response.message + end + + def test_failed_purchase_due_to_invalid_billing_state + @options[:billing_address][:state] = "Quebecistan" + assert response = @gateway.purchase(@amount, @visa, @options) + assert_failure response + assert_match %r{province does not match country}, response.message + end + + def test_failed_purchase_due_to_invalid_shipping_state + @options[:shipping_address][:state] = "North" + assert response = @gateway.purchase(@amount, @visa, @options) + assert_failure response + assert_match %r{Invalid shipping province}, response.message + end + def test_authorize_and_capture assert auth = @gateway.authorize(@amount, @visa, @options) assert_success auth From 1ba258f4bc4029983e378f6be83e776b0ded9d2b Mon Sep 17 00:00:00 2001 From: Arbab Ahmed Date: Tue, 18 Apr 2017 12:25:13 -0400 Subject: [PATCH 042/677] Braintree Blue: Force refund of unsettled payments via void --- .../billing/gateways/braintree_blue.rb | 12 +++++++-- test/unit/gateways/braintree_blue_test.rb | 26 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index a56a13cec40..3b2abc8ea9f 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -42,6 +42,10 @@ class BraintreeBlueGateway < Gateway self.display_name = 'Braintree (Blue Platform)' + ERROR_CODES = { + cannot_refund_if_unsettled: 91506 + } + def initialize(options = {}) requires!(options, :merchant_id, :public_key, :private_key) @merchant_account_id = options[:merchant_account_id] @@ -90,11 +94,15 @@ def credit(money, credit_card_or_vault_id, options = {}) def refund(*args) # legacy signature: #refund(transaction_id, options = {}) # new signature: #refund(money, transaction_id, options = {}) - money, transaction_id, _ = extract_refund_args(args) + money, transaction_id, options = extract_refund_args(args) money = amount(money).to_s if money commit do - response_from_result(@braintree_gateway.transaction.refund(transaction_id, money)) + response = response_from_result(@braintree_gateway.transaction.refund(transaction_id, money)) + return response if response.success? + return response unless options[:full_refund] + + void(transaction_id) if response.message =~ /#{ERROR_CODES[:cannot_refund_if_unsettled]}/ end end diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index 489ce3b16b4..1c5e3f8e74c 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -675,6 +675,32 @@ def test_unsuccessful_transaction_returns_message_when_available assert_equal response.message, 'Some error message' end + def test_refund_unsettled_payment + Braintree::TransactionGateway.any_instance. + expects(:refund). + returns(braintree_error_result(message: "Cannot refund a transaction unless it is settled. (91506)")) + + Braintree::TransactionGateway.any_instance. + expects(:void). + never + + response = @gateway.refund(1.00, 'transaction_id') + refute response.success? + end + + def test_refund_unsettled_payment_forces_void_on_full_refund + Braintree::TransactionGateway.any_instance. + expects(:refund). + returns(braintree_error_result(message: "Cannot refund a transaction unless it is settled. (91506)")) + + Braintree::TransactionGateway.any_instance. + expects(:void). + returns(braintree_result) + + response = @gateway.refund(1.00, 'transaction_id', full_refund: true) + assert response.success? + end + private def braintree_result(options = {}) From d05e51375e453c26dc4d1354891fd4b7c1cf9708 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Fri, 21 Apr 2017 00:34:37 +0530 Subject: [PATCH 043/677] Openpay: Support card points Closes #2401 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/openpay.rb | 1 + test/remote/gateways/remote_openpay_test.rb | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 177aae344f0..d117343c800 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,7 @@ * SagePay: Support Repeat transactions [curiousepic] #2395 * PayU LATAM: Fix incorrect capture method definition [davidsantoso] * Beanstream: Map ISO province codes for US and CA [shasum] #2396 +* Openpay: Support card points [shasum] #2401 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/openpay.rb b/lib/active_merchant/billing/gateways/openpay.rb index aea2c4ff98f..7c777a64ffd 100644 --- a/lib/active_merchant/billing/gateways/openpay.rb +++ b/lib/active_merchant/billing/gateways/openpay.rb @@ -113,6 +113,7 @@ def create_post_for_auth_or_purchase(money, creditcard, options) post[:order_id] = options[:order_id] post[:device_session_id] = options[:device_session_id] post[:currency] = (options[:currency] || currency(money)).upcase + post[:use_card_points] = options[:use_card_points] if options[:use_card_points] add_creditcard(post, creditcard, options) post end diff --git a/test/remote/gateways/remote_openpay_test.rb b/test/remote/gateways/remote_openpay_test.rb index bd44baa7b49..78f96ab3bfa 100644 --- a/test/remote/gateways/remote_openpay_test.rb +++ b/test/remote/gateways/remote_openpay_test.rb @@ -106,6 +106,17 @@ def test_successful_purchase_with_device_session_id assert_success response end + def test_successful_purchase_with_card_points + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(use_card_points: 'NONE')) + assert_success response + end + + def test_failed_purchase_with_card_points + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(use_card_points: 'MIXED')) + assert_failure response + assert_match %r{cardNumber not allowed for Card points}, response.message + end + def test_successful_store new_email_address = '%d@example.org' % Time.now assert response = @gateway.store(@credit_card, name: 'Test User', email: new_email_address) From 72e417f283b6c9fa5172c4cec714c01c1abbab40 Mon Sep 17 00:00:00 2001 From: Arbab Ahmed Date: Thu, 20 Apr 2017 13:06:00 -0400 Subject: [PATCH 044/677] Authorize.Net: Force refund of unsettled payments via void Closes #2399 --- CHANGELOG | 2 + .../billing/gateways/authorize_net.rb | 10 +++- test/unit/gateways/authorize_net_test.rb | 50 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index d117343c800..dd5566297ab 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,7 +21,9 @@ * SagePay: Support Repeat transactions [curiousepic] #2395 * PayU LATAM: Fix incorrect capture method definition [davidsantoso] * Beanstream: Map ISO province codes for US and CA [shasum] #2396 +* Braintree Blue: Force refund of unsettled payments via void [bizla] #2398 * Openpay: Support card points [shasum] #2401 +* Authorize.Net: Force refund of unsettled payments via void [bizla] #2399 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index 0b7871f669e..de77c660888 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -92,6 +92,7 @@ class AuthorizeNetGateway < Gateway APPLE_PAY_DATA_DESCRIPTOR = "COMMON.APPLE.INAPP.PAYMENT" PAYMENT_METHOD_NOT_SUPPORTED_ERROR = "155" + INELIGIBLE_FOR_ISSUING_CREDIT_ERROR = "54" def initialize(options={}) requires!(options, :login, :password) @@ -131,11 +132,18 @@ def capture(amount, authorization, options={}) end def refund(amount, authorization, options={}) - if auth_was_for_cim?(authorization) + response = if auth_was_for_cim?(authorization) cim_refund(amount, authorization, options) else normal_refund(amount, authorization, options) end + + return response if response.success? + return response unless options[:force_full_refund_if_unsettled] + + if response.params["response_reason_code"] == INELIGIBLE_FOR_ISSUING_CREDIT_ERROR + void(authorization, options) + end end def void(authorization, options={}) diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 72594dff7bb..56f732e0b17 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -549,6 +549,20 @@ def test_failed_refund_using_stored_card assert_equal "The record cannot be found", refund.message end + def test_failed_refund_due_to_unsettled_payment + @gateway.expects(:ssl_post).returns(failed_refund_for_unsettled_payment_response) + @gateway.expects(:void).never + + @gateway.refund(36.40, '2214269051#XXXX1234') + end + + def test_failed_full_refund_due_to_unsettled_payment_forces_void + @gateway.expects(:ssl_post).returns(failed_refund_for_unsettled_payment_response) + @gateway.expects(:void).once + + @gateway.refund(36.40, '2214269051#XXXX1234', force_full_refund_if_unsettled: true) + end + def test_successful_store @gateway.expects(:ssl_post).returns(successful_store_response) @@ -2182,4 +2196,40 @@ def credentials_are_bogus_response eos end + + def failed_refund_for_unsettled_payment_response + <<-eos + + + + Error + + E00027 + The transaction was unsuccessful. + + + + 3 + + P + + + 0 + + + 0 + XXXX0001 + Visa + + + 54 + The referenced transaction does not meet the criteria for issuing a credit. + + + + + + + eos + end end From 8675eeaae2b1c374ea823b737644b009f13e6625 Mon Sep 17 00:00:00 2001 From: Arbab Ahmed Date: Mon, 24 Apr 2017 09:04:51 -0400 Subject: [PATCH 045/677] Braintree Blue: Change :full_refund option to :force_full_refund_if_unsettled Closes #2403 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/braintree_blue.rb | 2 +- test/unit/gateways/braintree_blue_test.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index dd5566297ab..3f44a5f2cd9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,7 @@ * Braintree Blue: Force refund of unsettled payments via void [bizla] #2398 * Openpay: Support card points [shasum] #2401 * Authorize.Net: Force refund of unsettled payments via void [bizla] #2399 +* Braintree Blue: Change :full_refund option to :force_full_refund_if_unsettled [bizla] #2403 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 3b2abc8ea9f..24d1e695b0c 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -100,7 +100,7 @@ def refund(*args) commit do response = response_from_result(@braintree_gateway.transaction.refund(transaction_id, money)) return response if response.success? - return response unless options[:full_refund] + return response unless options[:force_full_refund_if_unsettled] void(transaction_id) if response.message =~ /#{ERROR_CODES[:cannot_refund_if_unsettled]}/ end diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index 1c5e3f8e74c..3028e08259b 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -697,7 +697,7 @@ def test_refund_unsettled_payment_forces_void_on_full_refund expects(:void). returns(braintree_result) - response = @gateway.refund(1.00, 'transaction_id', full_refund: true) + response = @gateway.refund(1.00, 'transaction_id', force_full_refund_if_unsettled: true) assert response.success? end From 87ad23a1599c3e48737eaeeae2829bc2e6264a34 Mon Sep 17 00:00:00 2001 From: Arbab Ahmed Date: Thu, 20 Apr 2017 16:21:04 -0400 Subject: [PATCH 046/677] Worldpay: Force refund of unsettled payments via void Closes #2402 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/worldpay.rb | 11 ++++++++--- test/unit/gateways/worldpay_test.rb | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3f44a5f2cd9..96da836f5df 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -25,6 +25,7 @@ * Openpay: Support card points [shasum] #2401 * Authorize.Net: Force refund of unsettled payments via void [bizla] #2399 * Braintree Blue: Change :full_refund option to :force_full_refund_if_unsettled [bizla] #2403 +* Worldpay: Force refund of unsettled payments via void [bizla] #2402 == Version 1.64.0 (March 6, 2017) * Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index 56a24fcd5d0..dfa9804ef50 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -60,10 +60,15 @@ def void(authorization, options = {}) end def refund(money, authorization, options = {}) - MultiResponse.run do |r| - r.process{inquire_request(authorization, options, "CAPTURED", "SETTLED", "SETTLED_BY_MERCHANT")} - r.process{refund_request(money, authorization, options)} + response = MultiResponse.run do |r| + r.process { inquire_request(authorization, options, "CAPTURED", "SETTLED", "SETTLED_BY_MERCHANT") } + r.process { refund_request(money, authorization, options) } end + + return response if response.success? + return response unless options[:force_full_refund_if_unsettled] + + void(authorization, options ) if response.params["last_event"] == "AUTHORISED" end def verify(credit_card, options={}) diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index 51d574cb868..78f5f96fb0e 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -132,6 +132,14 @@ def test_successful_refund_for_settled_payment assert_equal "05d9f8c622553b1df1fe3a145ce91ccf", response.params['refund_received_order_code'] end + def test_successful_refund_for_settled_by_merchant_payment + response = stub_comms do + @gateway.refund(@amount, @options[:order_id], @options) + end.respond_with(successful_refund_inquiry_response('SETTLED_BY_MERCHANT'), successful_refund_response) + assert_success response + assert_equal "05d9f8c622553b1df1fe3a145ce91ccf", response.params['refund_received_order_code'] + end + def test_refund_fails_unless_status_is_captured response = stub_comms do @gateway.refund(@amount, @options[:order_id], @options) @@ -140,6 +148,14 @@ def test_refund_fails_unless_status_is_captured assert_equal "A transaction status of 'CAPTURED' or 'SETTLED' or 'SETTLED_BY_MERCHANT' is required.", response.message end + def test_full_refund_for_unsettled_payment_forces_void + response = stub_comms do + @gateway.refund(@amount, @options[:order_id], @options.merge(force_full_refund_if_unsettled: true)) + end.respond_with(failed_refund_inquiry_response, failed_refund_inquiry_response, successful_void_response) + assert_success response + assert "cancel", response.responses.last.params["action"] + end + def test_capture response = stub_comms do response = @gateway.authorize(@amount, @credit_card, @options) From 132ddf50a8a411612c2fce958c4fca6d6e73d33d Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Wed, 26 Apr 2017 10:26:12 -0400 Subject: [PATCH 047/677] Release version 1.65.0 --- CHANGELOG | 38 ++++++++++++++++++---------------- lib/active_merchant/version.rb | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 96da836f5df..0a02dcd1d39 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,30 +1,32 @@ = ActiveMerchant CHANGELOG == HEAD -* Barclays ePDQ: removed because it has been replaced by a new API [bdewater] #2331 -* GlobalCollect: Truncate firstName field to 15 characters [davidsantoso] -* Qvalent: Add soft descriptor fields. Add authorize, capture, and void [davidsantoso] + +== Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 -* Pin: Add metadata optional field [shasum] #2363 +* Authorize.Net: Force refund of unsettled payments via void [bizla] #2399 +* Barclays ePDQ: removed because it has been replaced by a new API [bdewater] #2331 +* Beanstream: Map ISO province codes for US and CA [shasum] #2396 +* Braintree Blue: Change :full_refund option to :force_full_refund_if_unsettled [bizla] #2403 +* Braintree Blue: Force refund of unsettled payments via void [bizla] #2398 +* Checkout V2: Fix sandbox URL [nicolas-maalouf-cko] #2391 +* Checkout V2: Fix success_from not properly checking two possible success codes [davidsantoso] +* Cybersource: Rescue XML parse exception [shasum] #2380 +* GlobalCollect: Make message and error reporting more robust [curiousepic] #2370 * GlobalCollect: Set REJECTED refunds as unsuccessful transactions [davidsantoso] #2365 -* WePay: Support unique_id for idempotent transactions [shasum] #2367 -* Orbital: Don't send CVV indicator if CVV is not present [curiousepic] #2368 +* GlobalCollect: Truncate firstName field to 15 characters [davidsantoso] * JetPay: Pass down authorization payment method token to refund a capture [davidsantoso] -* GlobalCollect: Make message and error reporting more robust [curiousepic] #2370 -* Cybersource: Rescue XML parse exception [shasum] #2380 +* Openpay: Support card points [shasum] #2401 +* Orbital: Don't send CVV indicator if CVV is not present [curiousepic] #2368 +* PayU LATAM: Fix incorrect capture method definition [davidsantoso] * Payeezy: Support dynamic soft descriptors [shasum] #2384 -* Stripe: Support custom application in X-Stripe-Client-User-Agent header [davidsantoso] +* Pin: Add metadata optional field [shasum] #2363 +* Qvalent: Add soft descriptor fields. Add authorize, capture, and void [davidsantoso] * SafeCharge: Add gateway [davidsantoso] -* TransFirst Transaction Express: Support ACH [curiousepic] #2389 -* Checkout V2: Fix sandbox URL [nicolas-maalouf-cko] #2391 -* Checkout V2: Fix success_from not properly checking two possible success codes [davidsantoso] * SagePay: Support Repeat transactions [curiousepic] #2395 -* PayU LATAM: Fix incorrect capture method definition [davidsantoso] -* Beanstream: Map ISO province codes for US and CA [shasum] #2396 -* Braintree Blue: Force refund of unsettled payments via void [bizla] #2398 -* Openpay: Support card points [shasum] #2401 -* Authorize.Net: Force refund of unsettled payments via void [bizla] #2399 -* Braintree Blue: Change :full_refund option to :force_full_refund_if_unsettled [bizla] #2403 +* Stripe: Support custom application in X-Stripe-Client-User-Agent header [davidsantoso] +* TransFirst Transaction Express: Support ACH [curiousepic] #2389 +* WePay: Support unique_id for idempotent transactions [shasum] #2367 * Worldpay: Force refund of unsettled payments via void [bizla] #2402 == Version 1.64.0 (March 6, 2017) diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 016beff7024..90a18fad31a 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.64.0" + VERSION = "1.65.0" end From 72d814109e0bcb5f023fe86d66ae991109781c06 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Wed, 26 Apr 2017 13:43:02 +0530 Subject: [PATCH 048/677] SafeCharge: Support credit transactions Closes #2404 --- CHANGELOG | 1 + .../billing/gateways/safe_charge.rb | 9 +++++ .../gateways/remote_safe_charge_test.rb | 12 +++++++ test/unit/gateways/safe_charge_test.rb | 36 +++++++++++++++++++ 4 files changed, 58 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 0a02dcd1d39..30f2376c4f8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* SafeCharge: Support credit transactions [shasum] #2404 == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index 384a5cdcc33..5bc7409ed9d 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -63,6 +63,15 @@ def refund(money, authorization, options={}) commit(post) end + def credit(money, payment, options={}) + post = {} + add_payment(post, payment) + add_transaction_data("Credit", post, money, options) + post[:sg_CreditType] = 1 + + commit(post) + end + def void(authorization, options={}) post = {} auth, transaction_id, token, exp_month, exp_year, original_amount = authorization.split("|") diff --git a/test/remote/gateways/remote_safe_charge_test.rb b/test/remote/gateways/remote_safe_charge_test.rb index 5569eab9969..2823ce83f8d 100644 --- a/test/remote/gateways/remote_safe_charge_test.rb +++ b/test/remote/gateways/remote_safe_charge_test.rb @@ -89,6 +89,18 @@ def test_failed_refund assert_equal 'Transaction must contain a Card/Token/Account', response.message end + def test_successful_credit + response = @gateway.credit(@amount, @credit_card, @options) + assert_success response + assert_equal 'Success', response.message + end + + def test_failed_credit + response = @gateway.credit(@amount, @declined_card, @options) + assert_failure response + assert_equal 'Decline', response.message + end + def test_successful_void auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth diff --git a/test/unit/gateways/safe_charge_test.rb b/test/unit/gateways/safe_charge_test.rb index 440f42e1e4d..91421ed5e53 100644 --- a/test/unit/gateways/safe_charge_test.rb +++ b/test/unit/gateways/safe_charge_test.rb @@ -74,6 +74,11 @@ def test_failed_capture end def test_successful_refund + @gateway.expects(:ssl_post).returns(successful_refund_response) + + response = @gateway.refund(@amount, 'authorization', @options) + assert_success response + assert_equal 'Success', response.message end def test_failed_refund @@ -84,6 +89,22 @@ def test_failed_refund assert_equal "1163", response.error_code end + def test_successful_credit + @gateway.expects(:ssl_post).returns(successful_credit_response) + + response = @gateway.credit(@amount, @credit_card, @options) + assert_success response + assert_equal 'Success', response.message + end + + def test_failed_credit + @gateway.expects(:ssl_post).returns(failed_credit_response) + + response = @gateway.credit(@amount, @credit_card, @options) + assert_failure response + assert_equal 'Decline', response.message + end + def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) @@ -234,6 +255,9 @@ def failed_capture_response end def successful_refund_response + %( + 4.0.4SpreedlyTestTRX101508440432APPROVED11120700MQBVAG4AUgAwAFcAaABxAGoASABdAE4ALABvAGYANAAmAE8AcQA/AEgAawAkAHYASQBKAFMAegBiACoAcQBBAC8AVABlAD4AKwBkAC0AKwA8ACcAMwA=19SuiMHP60FrDKfyaJs47hqqrR/JU=0 + ) end def failed_refund_response @@ -242,6 +266,18 @@ def failed_refund_response ) end + def successful_credit_response + %( + 4.0.4SpreedlyTestTRX101508440421APPROVED11164400bwA1ADAAcAAwAHUAVABJAFYAUQAlAGcAfAB8AFQAbwBkAHAAbwAjAG4AaABDAHsAUABdACoAYwBaAEsAMQBHAEUAMQBuAHQAdwBXAFUAVABZACMAMwA=19SuiMHP60FrDKfyaJs47hqqrR/JU=0 + ) + end + + def failed_credit_response + %( + 4.0.4SpreedlyTestTRX101508440424DECLINEDDecline-10RwBVAGQAZgAwAFMAbABwAEwASgBNAFMAXABJAGAAeAAsAHsALAA7ADUAOgBUAEMAZwBNAG4AbABQAC4AQAAvAC0APwBpAEAAWQBoACMAdwBvAGEAMwA=19GyueFkuQqW+UL38d57fuA5/RqfQ=0 + ) + end + def successful_void_response %( 4.0.4SpreedlyTestTRX101508208625APPROVED11117100ZQBpAFAAZgBuAHEATgBUAHcASAAwADUAcwBHAHQAVQBLAHAAbgB6AGwAJAA1AEMAfAB2AGYASwBrAHEAeQBOAEwAOwBZAGIAewB4AGwAYwBUAE0AMwA=19University First Federal Credit UnionusSuiMHP60FrDKfyaJs47hqqrR/JU=0Credit From ccb417af61812139f73580f3adcbe7971dc954ac Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Thu, 27 Apr 2017 00:07:38 +0530 Subject: [PATCH 049/677] WePay: Add scrub method Closes #2406 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/wepay.rb | 11 + test/remote/gateways/remote_wepay_test.rb | 11 + test/unit/gateways/wepay_test.rb | 207 ++++++++++++++++++ 4 files changed, 230 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 30f2376c4f8..3e37ae300d3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * SafeCharge: Support credit transactions [shasum] #2404 +* WePay: Add scrub method [shasum] #2406 == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/wepay.rb b/lib/active_merchant/billing/gateways/wepay.rb index 6c6890a157e..796555e97d0 100644 --- a/lib/active_merchant/billing/gateways/wepay.rb +++ b/lib/active_merchant/billing/gateways/wepay.rb @@ -108,6 +108,17 @@ def store(creditcard, options = {}) end end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((\\?"cc_number\\?":\\?")[^\\"]+(\\?"))i, '\1[FILTERED]\2'). + gsub(%r((\\?"cvv\\?":\\?")[^\\"]+(\\?"))i, '\1[FILTERED]\2'). + gsub(%r((Authorization: Bearer )\w+)i, '\1[FILTERED]\2') + end + private def authorize_with_token(post, money, token, options) diff --git a/test/remote/gateways/remote_wepay_test.rb b/test/remote/gateways/remote_wepay_test.rb index 9f19bb1f24d..a1c10848eb6 100644 --- a/test/remote/gateways/remote_wepay_test.rb +++ b/test/remote/gateways/remote_wepay_test.rb @@ -146,4 +146,15 @@ def test_invalid_login response = gateway.purchase(@amount, @credit_card, @options) assert_failure response end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:access_token], transcript) + end end diff --git a/test/unit/gateways/wepay_test.rb b/test/unit/gateways/wepay_test.rb index 61c59b22c59..734e8ac7906 100644 --- a/test/unit/gateways/wepay_test.rb +++ b/test/unit/gateways/wepay_test.rb @@ -147,8 +147,215 @@ def test_invalid_json_response assert_match(/Invalid JSON response received from WePay/, response.message) end + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + private + def pre_scrubbed + %q( + opening connection to stage.wepayapi.com:443... + opened + starting SSL for stage.wepayapi.com:443... + SSL established + <- "POST /v2/credit_card/create HTTP/1.1\r\nContent-Type: application/json\r\nUser-Agent: ActiveMerchantBindings/1.65.0\r\nAuthorization: Bearer STAGE_c91882b0bed3584b8aed0f7f515f2f05a1d40924ee6f394ce82d91018cb0f2d3\r\nApi-Version: 2017-02-01\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nConnection: close\r\nHost: stage.wepayapi.com\r\nContent-Length: 272\r\n\r\n" + <- "{\"client_id\":\"44716\",\"user_name\":\"Longbob Longsen\",\"email\":\"test@example.com\",\"cc_number\":\"5496198584584769\",\"cvv\":\"123\",\"expiration_month\":9,\"expiration_year\":2018,\"address\":{\"address1\":\"456 My Street\",\"city\":\"Ottawa\",\"country\":\"CA\",\"region\":\"ON\",\"postal_code\":\"K1C2N6\"}}" + -> "HTTP/1.1 200 OK\r\n" + -> "Server: nginx\r\n" + -> "Content-Type: application/json\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "Strict-Transport-Security: max-age=31536000; preload\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Accept-Ranges: bytes\r\n" + -> "Date: Wed, 26 Apr 2017 18:27:33 GMT\r\n" + -> "Via: 1.1 varnish\r\n" + -> "Connection: close\r\n" + -> "X-Served-By: cache-fra1231-FRA\r\n" + -> "X-Cache: MISS\r\n" + -> "X-Cache-Hits: 0\r\n" + -> "X-Timer: S1493231252.436069,VS0,VE1258\r\n" + -> "Vary: Authorization\r\n" + -> "\r\n" + -> "2b\r\n" + reading 43 bytes... + -> "{\"credit_card_id\":2559797807,\"state\":\"new\"}" + read 43 bytes + reading 2 bytes... + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + opening connection to stage.wepayapi.com:443... + opened + starting SSL for stage.wepayapi.com:443... + SSL established + <- "POST /v2/checkout/create HTTP/1.1\r\nContent-Type: application/json\r\nUser-Agent: ActiveMerchantBindings/1.65.0\r\nAuthorization: Bearer STAGE_c91882b0bed3584b8aed0f7f515f2f05a1d40924ee6f394ce82d91018cb0f2d3\r\nApi-Version: 2017-02-01\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nConnection: close\r\nHost: stage.wepayapi.com\r\nContent-Length: 202\r\n\r\n" + <- "{\"payment_method\":{\"type\":\"credit_card\",\"credit_card\":{\"id\":\"2559797807\",\"auto_capture\":false}},\"account_id\":\"2080478981\",\"amount\":\"20.00\",\"short_description\":\"Purchase\",\"type\":\"goods\",\"currency\":\"USD\"}" + -> "HTTP/1.1 200 OK\r\n" + -> "Server: nginx\r\n" + -> "Content-Type: application/json\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "Strict-Transport-Security: max-age=31536000; preload\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Accept-Ranges: bytes\r\n" + -> "Date: Wed, 26 Apr 2017 18:27:36 GMT\r\n" + -> "Via: 1.1 varnish\r\n" + -> "Connection: close\r\n" + -> "X-Served-By: cache-fra1247-FRA\r\n" + -> "X-Cache: MISS\r\n" + -> "X-Cache-Hits: 0\r\n" + -> "X-Timer: S1493231255.546126,VS0,VE1713\r\n" + -> "Vary: Authorization\r\n" + -> "\r\n" + -> "324\r\n" + reading 804 bytes... + -> "{\"checkout_id\":1709862829,\"account_id\":2080478981,\"type\":\"goods\",\"short_description\":\"Purchase\",\"currency\":\"USD\",\"amount\":20,\"state\":\"authorized\",\"soft_descriptor\":\"WPY*Spreedly\",\"create_time\":1493231254,\"gross\":20.88,\"reference_id\":null,\"callback_uri\":null,\"long_description\":null,\"delivery_type\":null,\"fee\":{\"app_fee\":0,\"processing_fee\":0.88,\"fee_payer\":\"payer\"},\"chargeback\":{\"amount_charged_back\":0,\"dispute_uri\":null},\"refund\":{\"amount_refunded\":0,\"refund_reason\":null},\"payment_method\":{\"type\":\"credit_card\",\"credit_card\":{\"id\":2559797807,\"data\":{\"emv_receipt\":null,\"signature_url\":null},\"auto_capture\":false}},\"hosted_checkout\":null,\"payer\":{\"email\":\"test@example.com\",\"name\":\"Longbob Longsen\",\"home_address\":null},\"npo_information\":null,\"payment_error\":null,\"in_review\":false,\"auto_release\":true}" + read 804 bytes + reading 2 bytes... + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + opening connection to stage.wepayapi.com:443... + opened + starting SSL for stage.wepayapi.com:443... + SSL established + <- "POST /v2/checkout/capture HTTP/1.1\r\nContent-Type: application/json\r\nUser-Agent: ActiveMerchantBindings/1.65.0\r\nAuthorization: Bearer STAGE_c91882b0bed3584b8aed0f7f515f2f05a1d40924ee6f394ce82d91018cb0f2d3\r\nApi-Version: 2017-02-01\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nConnection: close\r\nHost: stage.wepayapi.com\r\nContent-Length: 28\r\n\r\n" + <- "{\"checkout_id\":\"1709862829\"}" + -> "HTTP/1.1 200 OK\r\n" + -> "Server: nginx\r\n" + -> "Content-Type: application/json\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "Strict-Transport-Security: max-age=31536000; preload\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Accept-Ranges: bytes\r\n" + -> "Date: Wed, 26 Apr 2017 18:27:38 GMT\r\n" + -> "Via: 1.1 varnish\r\n" + -> "Connection: close\r\n" + -> "X-Served-By: cache-fra1239-FRA\r\n" + -> "X-Cache: MISS\r\n" + -> "X-Cache-Hits: 0\r\n" + -> "X-Timer: S1493231257.113609,VS0,VE1136\r\n" + -> "Vary: Authorization\r\n" + -> "\r\n" + -> "324\r\n" + reading 804 bytes... + -> "{\"checkout_id\":1709862829,\"account_id\":2080478981,\"type\":\"goods\",\"short_description\":\"Purchase\",\"currency\":\"USD\",\"amount\":20,\"state\":\"authorized\",\"soft_descriptor\":\"WPY*Spreedly\",\"create_time\":1493231254,\"gross\":20.88,\"reference_id\":null,\"callback_uri\":null,\"long_description\":null,\"delivery_type\":null,\"fee\":{\"app_fee\":0,\"processing_fee\":0.88,\"fee_payer\":\"payer\"},\"chargeback\":{\"amount_charged_back\":0,\"dispute_uri\":null},\"refund\":{\"amount_refunded\":0,\"refund_reason\":null},\"payment_method\":{\"type\":\"credit_card\",\"credit_card\":{\"id\":2559797807,\"data\":{\"emv_receipt\":null,\"signature_url\":null},\"auto_capture\":false}},\"hosted_checkout\":null,\"payer\":{\"email\":\"test@example.com\",\"name\":\"Longbob Longsen\",\"home_address\":null},\"npo_information\":null,\"payment_error\":null,\"in_review\":false,\"auto_release\":true}" + read 804 bytes + reading 2 bytes... + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + ) + end + + def post_scrubbed + %q( + opening connection to stage.wepayapi.com:443... + opened + starting SSL for stage.wepayapi.com:443... + SSL established + <- "POST /v2/credit_card/create HTTP/1.1\r\nContent-Type: application/json\r\nUser-Agent: ActiveMerchantBindings/1.65.0\r\nAuthorization: Bearer [FILTERED]\r\nApi-Version: 2017-02-01\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nConnection: close\r\nHost: stage.wepayapi.com\r\nContent-Length: 272\r\n\r\n" + <- "{\"client_id\":\"44716\",\"user_name\":\"Longbob Longsen\",\"email\":\"test@example.com\",\"cc_number\":\"[FILTERED]\",\"cvv\":\"[FILTERED]\",\"expiration_month\":9,\"expiration_year\":2018,\"address\":{\"address1\":\"456 My Street\",\"city\":\"Ottawa\",\"country\":\"CA\",\"region\":\"ON\",\"postal_code\":\"K1C2N6\"}}" + -> "HTTP/1.1 200 OK\r\n" + -> "Server: nginx\r\n" + -> "Content-Type: application/json\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "Strict-Transport-Security: max-age=31536000; preload\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Accept-Ranges: bytes\r\n" + -> "Date: Wed, 26 Apr 2017 18:27:33 GMT\r\n" + -> "Via: 1.1 varnish\r\n" + -> "Connection: close\r\n" + -> "X-Served-By: cache-fra1231-FRA\r\n" + -> "X-Cache: MISS\r\n" + -> "X-Cache-Hits: 0\r\n" + -> "X-Timer: S1493231252.436069,VS0,VE1258\r\n" + -> "Vary: Authorization\r\n" + -> "\r\n" + -> "2b\r\n" + reading 43 bytes... + -> "{\"credit_card_id\":2559797807,\"state\":\"new\"}" + read 43 bytes + reading 2 bytes... + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + opening connection to stage.wepayapi.com:443... + opened + starting SSL for stage.wepayapi.com:443... + SSL established + <- "POST /v2/checkout/create HTTP/1.1\r\nContent-Type: application/json\r\nUser-Agent: ActiveMerchantBindings/1.65.0\r\nAuthorization: Bearer [FILTERED]\r\nApi-Version: 2017-02-01\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nConnection: close\r\nHost: stage.wepayapi.com\r\nContent-Length: 202\r\n\r\n" + <- "{\"payment_method\":{\"type\":\"credit_card\",\"credit_card\":{\"id\":\"2559797807\",\"auto_capture\":false}},\"account_id\":\"2080478981\",\"amount\":\"20.00\",\"short_description\":\"Purchase\",\"type\":\"goods\",\"currency\":\"USD\"}" + -> "HTTP/1.1 200 OK\r\n" + -> "Server: nginx\r\n" + -> "Content-Type: application/json\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "Strict-Transport-Security: max-age=31536000; preload\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Accept-Ranges: bytes\r\n" + -> "Date: Wed, 26 Apr 2017 18:27:36 GMT\r\n" + -> "Via: 1.1 varnish\r\n" + -> "Connection: close\r\n" + -> "X-Served-By: cache-fra1247-FRA\r\n" + -> "X-Cache: MISS\r\n" + -> "X-Cache-Hits: 0\r\n" + -> "X-Timer: S1493231255.546126,VS0,VE1713\r\n" + -> "Vary: Authorization\r\n" + -> "\r\n" + -> "324\r\n" + reading 804 bytes... + -> "{\"checkout_id\":1709862829,\"account_id\":2080478981,\"type\":\"goods\",\"short_description\":\"Purchase\",\"currency\":\"USD\",\"amount\":20,\"state\":\"authorized\",\"soft_descriptor\":\"WPY*Spreedly\",\"create_time\":1493231254,\"gross\":20.88,\"reference_id\":null,\"callback_uri\":null,\"long_description\":null,\"delivery_type\":null,\"fee\":{\"app_fee\":0,\"processing_fee\":0.88,\"fee_payer\":\"payer\"},\"chargeback\":{\"amount_charged_back\":0,\"dispute_uri\":null},\"refund\":{\"amount_refunded\":0,\"refund_reason\":null},\"payment_method\":{\"type\":\"credit_card\",\"credit_card\":{\"id\":2559797807,\"data\":{\"emv_receipt\":null,\"signature_url\":null},\"auto_capture\":false}},\"hosted_checkout\":null,\"payer\":{\"email\":\"test@example.com\",\"name\":\"Longbob Longsen\",\"home_address\":null},\"npo_information\":null,\"payment_error\":null,\"in_review\":false,\"auto_release\":true}" + read 804 bytes + reading 2 bytes... + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + opening connection to stage.wepayapi.com:443... + opened + starting SSL for stage.wepayapi.com:443... + SSL established + <- "POST /v2/checkout/capture HTTP/1.1\r\nContent-Type: application/json\r\nUser-Agent: ActiveMerchantBindings/1.65.0\r\nAuthorization: Bearer [FILTERED]\r\nApi-Version: 2017-02-01\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nConnection: close\r\nHost: stage.wepayapi.com\r\nContent-Length: 28\r\n\r\n" + <- "{\"checkout_id\":\"1709862829\"}" + -> "HTTP/1.1 200 OK\r\n" + -> "Server: nginx\r\n" + -> "Content-Type: application/json\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "Strict-Transport-Security: max-age=31536000; preload\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Accept-Ranges: bytes\r\n" + -> "Date: Wed, 26 Apr 2017 18:27:38 GMT\r\n" + -> "Via: 1.1 varnish\r\n" + -> "Connection: close\r\n" + -> "X-Served-By: cache-fra1239-FRA\r\n" + -> "X-Cache: MISS\r\n" + -> "X-Cache-Hits: 0\r\n" + -> "X-Timer: S1493231257.113609,VS0,VE1136\r\n" + -> "Vary: Authorization\r\n" + -> "\r\n" + -> "324\r\n" + reading 804 bytes... + -> "{\"checkout_id\":1709862829,\"account_id\":2080478981,\"type\":\"goods\",\"short_description\":\"Purchase\",\"currency\":\"USD\",\"amount\":20,\"state\":\"authorized\",\"soft_descriptor\":\"WPY*Spreedly\",\"create_time\":1493231254,\"gross\":20.88,\"reference_id\":null,\"callback_uri\":null,\"long_description\":null,\"delivery_type\":null,\"fee\":{\"app_fee\":0,\"processing_fee\":0.88,\"fee_payer\":\"payer\"},\"chargeback\":{\"amount_charged_back\":0,\"dispute_uri\":null},\"refund\":{\"amount_refunded\":0,\"refund_reason\":null},\"payment_method\":{\"type\":\"credit_card\",\"credit_card\":{\"id\":2559797807,\"data\":{\"emv_receipt\":null,\"signature_url\":null},\"auto_capture\":false}},\"hosted_checkout\":null,\"payer\":{\"email\":\"test@example.com\",\"name\":\"Longbob Longsen\",\"home_address\":null},\"npo_information\":null,\"payment_error\":null,\"in_review\":false,\"auto_release\":true}" + read 804 bytes + reading 2 bytes... + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + ) + end + def successful_store_response %({"credit_card_id": 3322208138,"state": "new"}) end From 9664796f53c49aa55da6457632ab298f4349c2b8 Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 13 Mar 2017 10:24:55 -0400 Subject: [PATCH 050/677] iVeri: Add gateway support Closes #2400 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/iveri.rb | 240 ++++++++ test/fixtures.yml | 5 + test/remote/gateways/remote_iveri_test.rb | 152 +++++ test/unit/gateways/iveri_test.rb | 553 ++++++++++++++++++ 5 files changed, 951 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/iveri.rb create mode 100644 test/remote/gateways/remote_iveri_test.rb create mode 100644 test/unit/gateways/iveri_test.rb diff --git a/CHANGELOG b/CHANGELOG index 3e37ae300d3..c6857fe186c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * SafeCharge: Support credit transactions [shasum] #2404 * WePay: Add scrub method [shasum] #2406 +* iVeri: Add gateway support [curiousepic] #2400 == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/iveri.rb b/lib/active_merchant/billing/gateways/iveri.rb new file mode 100644 index 00000000000..5d8aa5f753c --- /dev/null +++ b/lib/active_merchant/billing/gateways/iveri.rb @@ -0,0 +1,240 @@ +require 'nokogiri' + +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class IveriGateway < Gateway + self.live_url = self.test_url = 'https://portal.nedsecure.co.za/iVeriWebService/Service.asmx' + + self.supported_countries = ['US', 'ZA', 'GB'] + self.default_currency = 'ZAR' + self.money_format = :cents + self.supported_cardtypes = [:visa, :master, :american_express] + + self.homepage_url = 'http://www.iveri.com' + self.display_name = 'iVeri' + + def initialize(options={}) + requires!(options, :app_id, :cert_id) + super + end + + def purchase(money, payment_method, options={}) + post = build_vxml_request('Debit', options) do |xml| + add_auth_purchase_params(xml, money, payment_method, options) + end + + commit(post) + end + + def authorize(money, payment_method, options={}) + post = build_vxml_request('Authorisation', options) do |xml| + add_auth_purchase_params(xml, money, payment_method, options) + end + + commit(post) + end + + def capture(money, authorization, options={}) + post = build_vxml_request('Debit', options) do |xml| + add_authorization(xml, authorization, options) + end + + commit(post) + end + + def refund(money, authorization, options={}) + post = build_vxml_request('Credit', options) do |xml| + add_amount(xml, money, options) + add_authorization(xml, authorization, options) + end + + commit(post) + end + + def void(authorization, options={}) + post = build_vxml_request('Void', options) do |xml| + add_authorization(xml, authorization, options) + end + + commit(post) + end + + def verify(credit_card, options={}) + authorize(0, credit_card, options) + end + + def verify_credentials + void = void('', options) + return true if void.message == 'Missing OriginalMerchantTrace' + false + end + + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((CertificateID=\\\")[^\\]*), '\1[FILTERED]'). + gsub(%r((<PAN>)[^&]*), '\1[FILTERED]'). + gsub(%r((<CardSecurityCode>)[^&]*), '\1[FILTERED]') + end + + private + + def build_xml_envelope(vxml) + builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| + xml[:soap].Envelope 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' do + xml[:soap].Body do + xml.Execute 'xmlns' => 'http://iveri.com/' do + xml.validateRequest 'true' + xml.protocol 'V_XML' + xml.protocolVersion '2.0' + xml.request vxml + end + end + end + end + + builder.to_xml + end + + def build_vxml_request(action, options) + builder = Nokogiri::XML::Builder.new do |xml| + xml.V_XML('Version' => '2.0', 'CertificateID' => @options[:cert_id], 'Direction' => 'Request') do + xml.Transaction('ApplicationID' => @options[:app_id], 'Command' => action, 'Mode' => mode) do + yield(xml) + end + end + end + + builder.doc.root.to_xml + end + + def add_auth_purchase_params(post, money, payment_method, options) + add_amount(post, money, options) + add_payment_method(post, payment_method, options) + end + + def add_amount(post, money, options) + post.Amount(amount(money)) + post.Currency(options[:currency] || default_currency) + end + + def add_authorization(post, authorization, options) + post.MerchantReference(split_auth(authorization)[2]) + post.TransactionIndex(split_auth(authorization)[1]) + post.OriginalRequestID(split_auth(authorization)[0]) + end + + def add_payment_method(post, payment_method, options) + post.ExpiryDate("#{format(payment_method.month, :two_digits)}#{payment_method.year}") + add_new_reference(post, options) + post.CardSecurityCode(payment_method.verification_value) + post.PAN(payment_method.number) + end + + def add_new_reference(post, options) + post.MerchantReference(options[:order_id] || generate_unique_id) + end + + def commit(post) + raw_response = begin + ssl_post(live_url, build_xml_envelope(post), headers(post)) + rescue ActiveMerchant::ResponseError => e + e.response.body + end + + parsed = parse(raw_response) + succeeded = success_from(parsed) + + Response.new( + succeeded, + message_from(parsed, succeeded), + parsed, + authorization: authorization_from(parsed), + error_code: error_code_from(parsed, succeeded), + test: test? + ) + end + + def mode + test? ? 'Test' : 'Live' + end + + def headers(post) + { + "Content-Type" => "text/xml; charset=utf-8", + "Content-Length" => post.size.to_s, + "SOAPAction" => "http://iveri.com/Execute" + } + end + + def parse(body) + parsed = {} + + vxml = Nokogiri::XML(body).remove_namespaces!.xpath("//Envelope/Body/ExecuteResponse/ExecuteResult").inner_text + doc = Nokogiri::XML(vxml) + doc.xpath("*").each do |node| + if (node.elements.empty?) + parsed[underscore(node.name)] = node.text + else + node.elements.each do |childnode| + parse_element(parsed, childnode) + end + end + end + parsed + end + + def parse_element(parsed, node) + if !node.attributes.empty? + node.attributes.each do |a| + parsed[underscore(node.name)+ "_" + underscore(a[1].name)] = a[1].value + end + end + + if !node.elements.empty? + node.elements.each {|e| parse_element(parsed, e) } + else + parsed[underscore(node.name)] = node.text + end + end + + def success_from(response) + response['result_status'] == '0' + end + + def message_from(response, succeeded) + if succeeded + "Succeeded" + else + response['result_description'] || response['result_acquirer_description'] + end + end + + def authorization_from(response) + "#{response['transaction_request_id']}|#{response['transaction_index']}|#{response['merchant_reference']}" + end + + def split_auth(authorization) + request_id, transaction_index, merchant_reference = authorization.to_s.split('|') + [request_id, transaction_index, merchant_reference] + end + + def error_code_from(response, succeeded) + unless succeeded + response['result_code'] + end + end + + def underscore(camel_cased_word) + camel_cased_word.to_s.gsub(/::/, '/'). + gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). + gsub(/([a-z\d])([A-Z])/,'\1_\2'). + tr("-", "_"). + downcase + end + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index 3d53bb0c999..a0b23e1c68f 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -390,6 +390,11 @@ itransact: password: API_ACCESS_KEY gateway_id: GATEWAY_ID +# Working credentials, no need to replace +iveri: + cert_id: CB69E68D-C7E7-46B9-9B7A-025DCABAD6EF + app_id: d10a603d-4ade-405b-93f1-826dfc0181e8 + jetpay: login: TESTTERMINAL diff --git a/test/remote/gateways/remote_iveri_test.rb b/test/remote/gateways/remote_iveri_test.rb new file mode 100644 index 00000000000..3248184444d --- /dev/null +++ b/test/remote/gateways/remote_iveri_test.rb @@ -0,0 +1,152 @@ +require 'test_helper' + +class RemoteIveriTest < Test::Unit::TestCase + def setup + @gateway = IveriGateway.new(fixtures(:iveri)) + + @amount = 100 + @credit_card = credit_card('4242424242424242') + @bad_card = credit_card('2121212121212121') + @timeout_card = credit_card('5454545454545454') + @invalid_card = credit_card('1111222233334444') + @options = { + order_id: generate_unique_id, + billing_address: address, + description: 'Store Purchase' + } + end + + def test_successful_purchase + response = @gateway.purchase(@amount, @credit_card, @options) + + assert_success response + assert_equal 'Succeeded', response.message + assert_equal '100', response.params['amount'] + end + + def test_successful_purchase_with_more_options + options = { + ip: "127.0.0.1", + email: "joe@example.com", + currency: 'ZAR' + } + + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_equal 'Succeeded', response.message + end + + def test_failed_purchase + response = @gateway.purchase(@amount, @bad_card, @options) + assert_failure response + assert_includes ['Denied', 'Hot card', 'Please call'], response.message + end + + def test_successful_authorize_and_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + assert_equal 'Succeeded', capture.message + end + + def test_failed_authorize + response = @gateway.authorize(@amount, @bad_card, @options) + assert_failure response + assert_includes ['Denied', 'Hot card', 'Please call'], response.message + end + + def test_partial_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount-1, auth.authorization) + assert_success capture + end + + def test_failed_capture + response = @gateway.capture(@amount, '') + assert_failure response + assert_equal 'Missing PAN', response.message + end + + def test_successful_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount, purchase.authorization, @options) + assert_success refund + assert_equal 'Succeeded', refund.message + end + + def test_partial_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount-1, purchase.authorization) + assert_success refund + end + + def test_failed_refund + response = @gateway.refund(@amount, '', @options) + assert_failure response + assert_match %r{Credit is not supported}, response.message + end + + def test_successful_void + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert void = @gateway.void(auth.authorization) + assert_success void + assert_equal 'Succeeded', void.message + end + + def test_failed_void + response = @gateway.void('') + assert_failure response + assert_equal 'Missing OriginalMerchantTrace', response.message + end + + def test_successful_verify + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_equal 'Succeeded', response.message + end + + def test_failed_verify + response = @gateway.verify(@bad_card, @options) + assert_failure response + assert_includes ['Denied', 'Hot card', 'Please call'], response.message + end + + def test_successful_verify_credentials + assert @gateway.verify_credentials + end + + def test_failed_verify_credentials + gateway = IveriGateway.new(app_id: '11111111-1111-1111-1111-111111111111', cert_id: '11111111-1111-1111-1111-111111111111') + assert !gateway.verify_credentials + end + + def test_invalid_login + gateway = IveriGateway.new(app_id: '', cert_id: '') + + response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal 'No CertificateID specified', response.message + end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:cert_id], transcript) + end + +end diff --git a/test/unit/gateways/iveri_test.rb b/test/unit/gateways/iveri_test.rb new file mode 100644 index 00000000000..c48b6d60591 --- /dev/null +++ b/test/unit/gateways/iveri_test.rb @@ -0,0 +1,553 @@ +require 'test_helper' + +class IveriTest < Test::Unit::TestCase + def setup + @gateway = IveriGateway.new(app_id: '123', cert_id: '321') + @credit_card = credit_card('4242424242424242') + @amount = 100 + + @options = { + order_id: generate_unique_id, + billing_address: address, + description: 'Store Purchase', + currency: 'ZAR' + } + end + + def test_successful_purchase + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal "{F0568958-D10B-4093-A3BF-663168B06140}|{5CEF96FD-960E-4EA5-811F-D02CE6E36A96}|48b63446223ce91451fc3c1641a9ec03", response.authorization + assert response.test? + end + + def test_failed_purchase + @gateway.expects(:ssl_post).returns(failed_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal '4', response.error_code + end + + def test_successful_authorize + @gateway.expects(:ssl_post).returns(successful_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + assert_equal "{B90D7CDB-C8E8-4477-BDF2-695F28137874}|{EF0DC64E-2D00-4B6C-BDA0-2AD265391317}|23b4125c3b8e2777bffee52e196a863b", response.authorization + assert response.test? + end + + def test_failed_authorize + @gateway.expects(:ssl_post).returns(failed_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_equal '4', response.error_code + end + + def test_successful_capture + @gateway.expects(:ssl_post).returns(successful_capture_response) + + response = @gateway.capture(@amount, '{B90D7CDB-C8E8-4477-BDF2-695F28137874}|{EF0DC64E-2D00-4B6C-BDA0-2AD265391317}|23b4125c3b8e2777bffee52e196a863b') + assert_success response + assert_equal "{7C91245F-607D-44AE-8958-C26E447BAEB7}|{EF0DC64E-2D00-4B6C-BDA0-2AD265391317}|23b4125c3b8e2777bffee52e196a863b", response.authorization + assert response.test? + end + + def test_failed_capture + @gateway.expects(:ssl_post).returns(failed_capture_response) + + response = @gateway.capture(@amount, '', @options) + assert_failure response + assert_equal '14', response.error_code + end + + def test_successful_refund + @gateway.expects(:ssl_post).returns(successful_refund_response) + + response = @gateway.refund(@amount, '{33C8274D-6811-409A-BF86-661F24084A2F}|{D50DB1B4-B6EC-4AF1-AFF7-71C2AA4A957B}|5be2c040bd46b7eebc70274659779acf') + assert_success response + assert_equal "{097C55B5-D020-40AD-8949-F9F5E4102F1D}|{D50DB1B4-B6EC-4AF1-AFF7-71C2AA4A957B}|5be2c040bd46b7eebc70274659779acf", response.authorization + assert response.test? + end + + def test_failed_refund + @gateway.expects(:ssl_post).returns(failed_refund_response) + + response = @gateway.refund(@amount, '', @options) + assert_failure response + assert_equal '255', response.error_code + end + + def test_successful_void + @gateway.expects(:ssl_post).returns(successful_void_response) + + response = @gateway.void('{230390C8-4A9E-4426-BDD3-15D072F135FE}|{3CC6E6A8-13E0-41A6-AB1E-71BE1AEEAE58}|1435f1a008137cd8508bf43751e07495') + assert_success response + assert_equal "{0A1A3FFF-C2A3-4B91-85FD-10D1C25B765B}||", response.authorization + assert response.test? + end + + def test_failed_void + @gateway.expects(:ssl_post).returns(failed_void_response) + + response = @gateway.void('', @options) + assert_failure response + assert_equal '255', response.error_code + end + + def test_successful_verify + @gateway.expects(:ssl_post).returns(successful_verify_response) + + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_equal "{F4337D04-B526-4A7E-A400-2A6DEADDCF57}|{5D5F8BF7-2D9D-42C3-AF32-08C5E62CD45E}|c0006d1d739905afc9e70beaf4194ea3", response.authorization + assert response.test? + end + + def test_failed_verify + @gateway.expects(:ssl_post).returns(failed_verify_response) + + response = @gateway.verify(credit_card('2121212121212121'), @options) + assert_failure response + assert_equal '4', response.error_code + end + + def test_successful_verify_credentials + @gateway.expects(:ssl_post).returns(successful_verify_credentials_response) + assert @gateway.verify_credentials + end + + def test_failed_verify_credentials + @gateway.expects(:ssl_post).returns(failed_verify_credentials_response) + assert !@gateway.verify_credentials + end + + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + + private + + def pre_scrubbed + %q( +opening connection to portal.nedsecure.co.za:443... +opened +starting SSL for portal.nedsecure.co.za:443... +SSL established +<- "POST /iVeriWebService/Service.asmx HTTP/1.1\r\nContent-Type: text/xml; charset=utf-8\r\nContent-Length: 1016\r\nSoapaction: http://iveri.com/Execute\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: portal.nedsecure.co.za\r\n\r\n" +<- "\n\n \n \n true\n V_XML\n 2.0\n <V_XML Version=\"2.0\" CertificateID=\"CB69E68D-C7E7-46B9-9B7A-025DCABAD6EF\" Direction=\"Request\">\n <Transaction ApplicationID=\"D10A603D-4ADE-405B-93F1-826DFC0181E8\" Command=\"Debit\" Mode=\"Test\">\n <Amount>100</Amount>\n <Currency>ZAR</Currency>\n <ExpiryDate>092018</ExpiryDate>\n <MerchantReference>b3ceea8b93d5611cbde7d162baef1245</MerchantReference>\n <CardSecurityCode>123</CardSecurityCode>\n <PAN>4242424242424242</PAN>\n </Transaction>\n</V_XML>\n \n \n\n" +-> "HTTP/1.1 200 OK\r\n" +-> "Cache-Control: private, max-age=0\r\n" +-> "Content-Type: text/xml; charset=utf-8\r\n" +-> "Server: Microsoft-IIS/8.0\r\n" +-> "X-AspNet-Version: 4.0.30319\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "Date: Wed, 12 Apr 2017 19:46:44 GMT\r\n" +-> "Connection: close\r\n" +-> "Content-Length: 2377\r\n" +-> "\r\n" +reading 2377 bytes... +-> "<V_XML Version=\"2.0\" Direction=\"Response\">\r\n <Transaction ApplicationID=\"{D10A603D-4ADE-405B-93F1-826DFC0181E8}\" Command=\"Debit\" Mode=\"Test\" RequestID=\"{5485B5EA-2661-4436-BAA9-CD6DD546FA0D}\">\r\n <Result Status=\"0\" AppServer=\"105IVERIAPPPR02\" DBServer=\"105iveridbpr01\" Gateway=\"Nedbank\" AcquirerCode=\"00\" />\r\n <Amount>100</Amount>\r\n <AuthorisationCode>115205</AuthorisationCode>\r\n <Currency>ZAR</Currency>\r\n <ExpiryDate>092018</ExpiryDate>\r\n <MerchantReference>b3ceea8b93d5611cbde7d162baef1245</MerchantReference>\r\n <Terminal>Default</Terminal>\r\n <TransactionIndex>{10418186-FE90-44F9-AB7A-FEC11C9027F8}</TransactionIndex>\r\n <MerchantName>iVeri Payment Technology</MerchantName>\r\n <MerchantUSN>7771777</MerchantUSN>\r\n <Acquirer>NBPostilionBICISONBSouthAfrica</Acquirer>\r\n <AcquirerReference>70412:04077382</AcquirerReference>\r\n <AcquirerDate>20170412</AcquirerDate>\r\n <AcquirerTime>214645</AcquirerTime>\r\n <DisplayAmount>R 1.00</DisplayAmount>\r\n <BIN>4</BIN>\r\n <Association>VISA</Association>\r\n <CardType>Unknown CardType</CardType>\r\n <Issuer>Unknown</Issuer>\r\n <Jurisdiction>International</Jurisdiction>\r\n <PANMode>Keyed,CVV</PANMode>\r\n <ReconReference>04077382</ReconReference>\r\n <CardHolderPresence>CardNotPresent</CardHolderPresence>\r\n <MerchantAddress>MERCHANT ADDRESS</MerchantAddress>\r\n <MerchantCity>Sandton</MerchantCity>\r\n <MerchantCountryCode>ZA</MerchantCountryCode>\r\n <MerchantCountry>South Africa</MerchantCountry>\r\n <DistributorName>Nedbank</DistributorName>\r\n <CCNumber>4242........4242</CCNumber>\r\n <PAN>[4242........4242]</PAN>\r\n </Transaction>\r\n</V_XML>" +read 2377 bytes +Conn close +) + end + + def post_scrubbed + %q( +opening connection to portal.nedsecure.co.za:443... +opened +starting SSL for portal.nedsecure.co.za:443... +SSL established +<- "POST /iVeriWebService/Service.asmx HTTP/1.1\r\nContent-Type: text/xml; charset=utf-8\r\nContent-Length: 1016\r\nSoapaction: http://iveri.com/Execute\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: portal.nedsecure.co.za\r\n\r\n" +<- "\n\n \n \n true\n V_XML\n 2.0\n <V_XML Version=\"2.0\" CertificateID=\"[FILTERED]\" Direction=\"Request\">\n <Transaction ApplicationID=\"D10A603D-4ADE-405B-93F1-826DFC0181E8\" Command=\"Debit\" Mode=\"Test\">\n <Amount>100</Amount>\n <Currency>ZAR</Currency>\n <ExpiryDate>092018</ExpiryDate>\n <MerchantReference>b3ceea8b93d5611cbde7d162baef1245</MerchantReference>\n <CardSecurityCode>[FILTERED]</CardSecurityCode>\n <PAN>[FILTERED]</PAN>\n </Transaction>\n</V_XML>\n \n \n\n" +-> "HTTP/1.1 200 OK\r\n" +-> "Cache-Control: private, max-age=0\r\n" +-> "Content-Type: text/xml; charset=utf-8\r\n" +-> "Server: Microsoft-IIS/8.0\r\n" +-> "X-AspNet-Version: 4.0.30319\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "Date: Wed, 12 Apr 2017 19:46:44 GMT\r\n" +-> "Connection: close\r\n" +-> "Content-Length: 2377\r\n" +-> "\r\n" +reading 2377 bytes... +-> "<V_XML Version=\"2.0\" Direction=\"Response\">\r\n <Transaction ApplicationID=\"{D10A603D-4ADE-405B-93F1-826DFC0181E8}\" Command=\"Debit\" Mode=\"Test\" RequestID=\"{5485B5EA-2661-4436-BAA9-CD6DD546FA0D}\">\r\n <Result Status=\"0\" AppServer=\"105IVERIAPPPR02\" DBServer=\"105iveridbpr01\" Gateway=\"Nedbank\" AcquirerCode=\"00\" />\r\n <Amount>100</Amount>\r\n <AuthorisationCode>115205</AuthorisationCode>\r\n <Currency>ZAR</Currency>\r\n <ExpiryDate>092018</ExpiryDate>\r\n <MerchantReference>b3ceea8b93d5611cbde7d162baef1245</MerchantReference>\r\n <Terminal>Default</Terminal>\r\n <TransactionIndex>{10418186-FE90-44F9-AB7A-FEC11C9027F8}</TransactionIndex>\r\n <MerchantName>iVeri Payment Technology</MerchantName>\r\n <MerchantUSN>7771777</MerchantUSN>\r\n <Acquirer>NBPostilionBICISONBSouthAfrica</Acquirer>\r\n <AcquirerReference>70412:04077382</AcquirerReference>\r\n <AcquirerDate>20170412</AcquirerDate>\r\n <AcquirerTime>214645</AcquirerTime>\r\n <DisplayAmount>R 1.00</DisplayAmount>\r\n <BIN>4</BIN>\r\n <Association>VISA</Association>\r\n <CardType>Unknown CardType</CardType>\r\n <Issuer>Unknown</Issuer>\r\n <Jurisdiction>International</Jurisdiction>\r\n <PANMode>Keyed,CVV</PANMode>\r\n <ReconReference>04077382</ReconReference>\r\n <CardHolderPresence>CardNotPresent</CardHolderPresence>\r\n <MerchantAddress>MERCHANT ADDRESS</MerchantAddress>\r\n <MerchantCity>Sandton</MerchantCity>\r\n <MerchantCountryCode>ZA</MerchantCountryCode>\r\n <MerchantCountry>South Africa</MerchantCountry>\r\n <DistributorName>Nedbank</DistributorName>\r\n <CCNumber>4242........4242</CCNumber>\r\n <PAN>[FILTERED]</PAN>\r\n </Transaction>\r\n</V_XML>" +read 2377 bytes +Conn close +) + end + + def successful_purchase_response + <<-XML +<V_XML Version="2.0" Direction="Response"> +<Transaction ApplicationID="{D10A603D-4ADE-405B-93F1-826DFC0181E8}" Command="Debit" Mode="Test" RequestID="{F0568958-D10B-4093-A3BF-663168B06140}"> + <Result Status="0" AppServer="105IVERIAPPPR01" DBServer="105IVERIDBPR01" Gateway="Nedbank" AcquirerCode="00" /> + <Amount>100</Amount> + <AuthorisationCode>537473</AuthorisationCode> + <Currency>ZAR</Currency> + <ExpiryDate>092018</ExpiryDate> + <MerchantReference>48b63446223ce91451fc3c1641a9ec03</MerchantReference> + <Terminal>Default</Terminal> + <TransactionIndex>{5CEF96FD-960E-4EA5-811F-D02CE6E36A96}</TransactionIndex> + <MerchantName>iVeri Payment Technology</MerchantName> + <MerchantUSN>7771777</MerchantUSN> + <Acquirer>NBPostilionBICISONBSouthAfrica</Acquirer> + <AcquirerReference>70417:04077982</AcquirerReference> + <AcquirerDate>20170417</AcquirerDate> + <AcquirerTime>190433</AcquirerTime> + <DisplayAmount>R 1.00</DisplayAmount> + <BIN>4</BIN> + <Association>VISA</Association> + <CardType>Unknown CardType</CardType> + <Issuer>Unknown</Issuer> + <Jurisdiction>International</Jurisdiction> + <PANMode>Keyed,CVV</PANMode> + <ReconReference>04077982</ReconReference> + <CardHolderPresence>CardNotPresent</CardHolderPresence> + <MerchantAddress>MERCHANT ADDRESS</MerchantAddress> + <MerchantCity>Sandton</MerchantCity> + <MerchantCountryCode>ZA</MerchantCountryCode> + <MerchantCountry>South Africa</MerchantCountry> + <DistributorName>Nedbank</DistributorName> + <CCNumber>4242........4242</CCNumber> + <PAN>4242........4242</PAN> +</Transaction> +</V_XML> + XML + end + + def failed_purchase_response + <<-XML +<V_XML Version="2.0" Direction="Response"> + <Transaction ApplicationID="{D10A603D-4ADE-405B-93F1-826DFC0181E8}" Command="Debit" Mode="Test" RequestID="{B14C3834-72B9-4ACA-B362-B3C9EC96E8C0}"> + <Result Status="-1" Code="4" Description="Denied" Source="NBPostilionBICISONBSouthAfrica" AppServer="105IVERIAPPPR01" DBServer="105IVERIDBPR01" Gateway="Nedbank" AcquirerCode="05" AcquirerDescription="Do not Honour" /> + <Amount>100</Amount> + <Currency>ZAR</Currency> + <ExpiryDate>092018</ExpiryDate> + <MerchantReference>435a5d60b5fe874840c34e2e0504626b</MerchantReference> + <Terminal>Default</Terminal> + <TransactionIndex>{B35872A9-39C7-4DB8-9774-A5E34FFA519E}</TransactionIndex> + <MerchantName>iVeri Payment Technology</MerchantName> + <MerchantUSN>7771777</MerchantUSN> + <Acquirer>NBPostilionBICISONBSouthAfrica</Acquirer> + <AcquirerReference>70417:04077988</AcquirerReference> + <AcquirerDate>20170417</AcquirerDate> + <AcquirerTime>192038</AcquirerTime> + <DisplayAmount>R 1.00</DisplayAmount> + <BIN>2</BIN> + <Association>Unknown Association</Association> + <CardType>Unknown CardType</CardType> + <Issuer>Unknown</Issuer> + <Jurisdiction>Local</Jurisdiction> + <PANMode>Keyed,CVV</PANMode> + <ReconReference>04077988</ReconReference> + <CardHolderPresence>CardNotPresent</CardHolderPresence> + <MerchantAddress>MERCHANT ADDRESS</MerchantAddress> + <MerchantCity>Sandton</MerchantCity> + <MerchantCountryCode>ZA</MerchantCountryCode> + <MerchantCountry>South Africa</MerchantCountry> + <DistributorName>Nedbank</DistributorName> + <CCNumber>2121........2121</CCNumber> + <PAN>2121........2121</PAN> + </Transaction> +</V_XML> + XML + end + + def successful_authorize_response + <<-XML +<V_XML Version="2.0" Direction="Response"> + <Transaction ApplicationID="{D10A603D-4ADE-405B-93F1-826DFC0181E8}" Command="Authorisation" Mode="Test" RequestID="{B90D7CDB-C8E8-4477-BDF2-695F28137874}"> + <Result Status="0" AppServer="105IVERIAPPPR01" DBServer="105IVERIDBPR01" Gateway="Nedbank" AcquirerCode="00" /> + <Amount>100</Amount> + <AuthorisationCode>541267</AuthorisationCode> + <Currency>ZAR</Currency> + <ExpiryDate>092018</ExpiryDate> + <MerchantReference>23b4125c3b8e2777bffee52e196a863b</MerchantReference> + <Terminal>Default</Terminal> + <TransactionIndex>{EF0DC64E-2D00-4B6C-BDA0-2AD265391317}</TransactionIndex> + <MerchantName>iVeri Payment Technology</MerchantName> + <MerchantUSN>7771777</MerchantUSN> + <Acquirer>NBPostilionBICISONBSouthAfrica</Acquirer> + <AcquirerReference>70417:04078057</AcquirerReference> + <AcquirerDate>20170417</AcquirerDate> + <AcquirerTime>200747</AcquirerTime> + <DisplayAmount>R 1.00</DisplayAmount> + <BIN>4</BIN> + <Association>VISA</Association> + <CardType>Unknown CardType</CardType> + <Issuer>Unknown</Issuer> + <Jurisdiction>International</Jurisdiction> + <PANMode>Keyed,CVV</PANMode> + <ReconReference>04078057</ReconReference> + <CardHolderPresence>CardNotPresent</CardHolderPresence> + <MerchantAddress>MERCHANT ADDRESS</MerchantAddress> + <MerchantCity>Sandton</MerchantCity> + <MerchantCountryCode>ZA</MerchantCountryCode> + <MerchantCountry>South Africa</MerchantCountry> + <DistributorName>Nedbank</DistributorName> + <CCNumber>4242........4242</CCNumber> + <PAN>4242........4242</PAN> + </Transaction> +</V_XML> + XML + end + + def failed_authorize_response + <<-XML +<V_XML Version="2.0" Direction="Response"> + <Transaction ApplicationID="{D10A603D-4ADE-405B-93F1-826DFC0181E8}" Command="Authorisation" Mode="Test" RequestID="{3A1A29BE-288F-4FEE-8C15-B3BB8A207544}"> + <Result Status="-1" Code="4" Description="Denied" Source="NBPostilionBICISONBSouthAfrica" AppServer="105IVERIAPPPR01" DBServer="105IVERIDBPR01" Gateway="Nedbank" AcquirerCode="05" AcquirerDescription="Do not Honour" /> + <Amount>100</Amount> + <Currency>ZAR</Currency> + <ExpiryDate>092018</ExpiryDate> + <MerchantReference>3d12442ea042e78fd33057b7b50c76f7</MerchantReference> + <Terminal>Default</Terminal> + <TransactionIndex>{8AC33FB1-0D2E-42C7-A0DB-CF8B20279825}</TransactionIndex> + <MerchantName>iVeri Payment Technology</MerchantName> + <MerchantUSN>7771777</MerchantUSN> + <Acquirer>NBPostilionBICISONBSouthAfrica</Acquirer> + <AcquirerReference>70417:04078062</AcquirerReference> + <AcquirerDate>20170417</AcquirerDate> + <AcquirerTime>202648</AcquirerTime> + <DisplayAmount>R 1.00</DisplayAmount> + <BIN>2</BIN> + <Association>Unknown Association</Association> + <CardType>Unknown CardType</CardType> + <Issuer>Unknown</Issuer> + <Jurisdiction>Local</Jurisdiction> + <PANMode>Keyed,CVV</PANMode> + <ReconReference>04078062</ReconReference> + <CardHolderPresence>CardNotPresent</CardHolderPresence> + <MerchantAddress>MERCHANT ADDRESS</MerchantAddress> + <MerchantCity>Sandton</MerchantCity> + <MerchantCountryCode>ZA</MerchantCountryCode> + <MerchantCountry>South Africa</MerchantCountry> + <DistributorName>Nedbank</DistributorName> + <CCNumber>2121........2121</CCNumber> + <PAN>2121........2121</PAN> + </Transaction> +</V_XML> + XML + end + + def successful_capture_response + <<-XML +<V_XML Version="2.0" Direction="Response"> + <Transaction ApplicationID="{D10A603D-4ADE-405B-93F1-826DFC0181E8}" Command="Debit" Mode="Test" RequestID="{7C91245F-607D-44AE-8958-C26E447BAEB7}"> + <Result Status="0" AppServer="105IVERIAPPPR02" DBServer="105iveridbpr01" Gateway="Nedbank" AcquirerCode="00" /> + <Amount>100</Amount> + <AuthorisationCode>541268</AuthorisationCode> + <Currency>ZAR</Currency> + <ExpiryDate>092018</ExpiryDate> + <MerchantReference>23b4125c3b8e2777bffee52e196a863b</MerchantReference> + <Terminal>Default</Terminal> + <TransactionIndex>{EF0DC64E-2D00-4B6C-BDA0-2AD265391317}</TransactionIndex> + <MerchantName>iVeri Payment Technology</MerchantName> + <MerchantUSN>7771777</MerchantUSN> + <Acquirer>NBPostilionBICISONBSouthAfrica</Acquirer> + <AcquirerReference>70417:04078057</AcquirerReference> + <AcquirerDate>20170417</AcquirerDate> + <AcquirerTime>200748</AcquirerTime> + <DisplayAmount>R 1.00</DisplayAmount> + <BIN>4</BIN> + <Association>VISA</Association> + <CardType>Unknown CardType</CardType> + <Issuer>Unknown</Issuer> + <Jurisdiction>International</Jurisdiction> + <PANMode>Keyed,CVV</PANMode> + <ReconReference>04078057</ReconReference> + <CardHolderPresence>CardNotPresent</CardHolderPresence> + <MerchantAddress>MERCHANT ADDRESS</MerchantAddress> + <MerchantCity>Sandton</MerchantCity> + <MerchantCountryCode>ZA</MerchantCountryCode> + <MerchantCountry>South Africa</MerchantCountry> + <DistributorName>Nedbank</DistributorName> + <CCNumber>4242........4242</CCNumber> + <PAN>4242........4242</PAN> + </Transaction> +</V_XML> + XML + end + + def failed_capture_response + <<-XML +<V_XML Version="2.0" Direction="Response"> + <Transaction ApplicationID="{D10A603D-4ADE-405B-93F1-826DFC0181E8}" Command="Debit" Mode="Test" RequestID="{9DAAA002-0EF9-46DC-A440-8DCD9E78B36F}"> + <Result Status="-1" Code="14" Description="Missing PAN" Source="NBPostilionBICISONBSouthAfricaTestProvider" AppServer="105IVERIAPPPR02" DBServer="105iveridbpr01" Gateway="Nedbank" AcquirerCode="" AcquirerDescription="" /> + </Transaction> +</V_XML> + XML + end + + def successful_refund_response + <<-XML +<V_XML Version="2.0" Direction="Response"> + <Transaction ApplicationID="{D10A603D-4ADE-405B-93F1-826DFC0181E8}" Command="Credit" Mode="Test" RequestID="{097C55B5-D020-40AD-8949-F9F5E4102F1D}"> + <Result Status="0" AppServer="105IVERIAPPPR02" DBServer="105iveridbpr01" Gateway="Nedbank" AcquirerCode="00" /> + <Amount>100</Amount> + <AuthorisationCode>541996</AuthorisationCode> + <Currency>ZAR</Currency> + <ExpiryDate>092018</ExpiryDate> + <MerchantReference>5be2c040bd46b7eebc70274659779acf</MerchantReference> + <Terminal>Default</Terminal> + <TransactionIndex>{D50DB1B4-B6EC-4AF1-AFF7-71C2AA4A957B}</TransactionIndex> + <MerchantName>iVeri Payment Technology</MerchantName> + <MerchantUSN>7771777</MerchantUSN> + <Acquirer>NBPostilionBICISONBSouthAfrica</Acquirer> + <AcquirerReference>70417:04078059</AcquirerReference> + <AcquirerDate>20170417</AcquirerDate> + <AcquirerTime>201956</AcquirerTime> + <DisplayAmount>R 1.00</DisplayAmount> + <BIN>4</BIN> + <Association>VISA</Association> + <CardType>Unknown CardType</CardType> + <Issuer>Unknown</Issuer> + <Jurisdiction>International</Jurisdiction> + <PANMode /> + <ReconReference>04078059</ReconReference> + <CardHolderPresence>CardNotPresent</CardHolderPresence> + <MerchantAddress>MERCHANT ADDRESS</MerchantAddress> + <MerchantCity>Sandton</MerchantCity> + <MerchantCountryCode>ZA</MerchantCountryCode> + <MerchantCountry>South Africa</MerchantCountry> + <DistributorName>Nedbank</DistributorName> + <CCNumber>4242........4242</CCNumber> + <PAN>4242........4242</PAN> + </Transaction> +</V_XML> + XML + end + + def failed_refund_response + <<-XML +<V_XML Version="2.0" Direction="Response"> + <Transaction ApplicationID="{D10A603D-4ADE-405B-93F1-826DFC0181E8}" Command="Credit" Mode="Test" RequestID="{5097A60A-A112-42F1-9490-FA17A859E7A3}"> + <Result Status="-1" Code="255" Description="Credit is not supported for ApplicationID (D10A603D-4ADE-405B-93F1-826DFC0181E8)" Source="PortalService" AppServer="105IVERIAPPPR02" DBServer="105iveridbpr01" Gateway="Nedbank" AcquirerCode="" AcquirerDescription="" /> + </Transaction> +</V_XML> + XML + end + + def successful_void_response + <<-XML +<V_XML Version="2.0" Direction="Response"> + <Transaction ApplicationID="{D10A603D-4ADE-405B-93F1-826DFC0181E8}" Command="Void" Mode="Test" RequestID="{0A1A3FFF-C2A3-4B91-85FD-10D1C25B765B}"> + <Result Status="0" AppServer="105IVERIAPPPR02" DBServer="105iveridbpr01" Gateway="Nedbank" /> + <OriginalRequestID>{230390C8-4A9E-4426-BDD3-15D072F135FE}</OriginalRequestID> + </Transaction> +</V_XML> + XML + end + + def failed_void_response + <<-XML +<V_XML Version="2.0" Direction="Response"> + <Transaction ApplicationID="{D10A603D-4ADE-405B-93F1-826DFC0181E8}" Command="Void" Mode="Test" RequestID="{AE97CCE4-0631-4F08-AB47-9C2698ABEC75}"> + <Result Status="-1" Code="255" Description="Missing OriginalMerchantTrace" Source="NBPostilionBICISONBSouthAfricaTestProvider" AppServer="105IVERIAPPPR01" DBServer="105IVERIDBPR01" Gateway="Nedbank" AcquirerCode="" AcquirerDescription="" /> + </Transaction> +</V_XML> + XML + end + + def successful_verify_response + <<-XML +<V_XML Version="2.0" Direction="Response"> + <Transaction ApplicationID="{D10A603D-4ADE-405B-93F1-826DFC0181E8}" Command="Authorisation" Mode="Test" RequestID="{F4337D04-B526-4A7E-A400-2A6DEADDCF57}"> + <Result Status="0" AppServer="105IVERIAPPPR01" DBServer="105IVERIDBPR01" Gateway="Nedbank" AcquirerCode="00" /> + <Amount>0</Amount> + <AuthorisationCode>613755</AuthorisationCode> + <Currency>ZAR</Currency> + <ExpiryDate>092018</ExpiryDate> + <MerchantReference>c0006d1d739905afc9e70beaf4194ea3</MerchantReference> + <Terminal>Default</Terminal> + <TransactionIndex>{5D5F8BF7-2D9D-42C3-AF32-08C5E62CD45E}</TransactionIndex> + <MerchantName>iVeri Payment Technology</MerchantName> + <MerchantUSN>7771777</MerchantUSN> + <Acquirer>NBPostilionBICISONBSouthAfrica</Acquirer> + <AcquirerReference>70418:04078335</AcquirerReference> + <AcquirerDate>20170418</AcquirerDate> + <AcquirerTime>161555</AcquirerTime> + <DisplayAmount>R 0.00</DisplayAmount> + <BIN>4</BIN> + <Association>VISA</Association> + <CardType>Unknown CardType</CardType> + <Issuer>Unknown</Issuer> + <Jurisdiction>International</Jurisdiction> + <PANMode>Keyed,CVV</PANMode> + <ReconReference>04078335</ReconReference> + <CardHolderPresence>CardNotPresent</CardHolderPresence> + <MerchantAddress>MERCHANT ADDRESS</MerchantAddress> + <MerchantCity>Sandton</MerchantCity> + <MerchantCountryCode>ZA</MerchantCountryCode> + <MerchantCountry>South Africa</MerchantCountry> + <DistributorName>Nedbank</DistributorName> + <CCNumber>4242........4242</CCNumber> + <PAN>4242........4242</PAN> + </Transaction> +</V_XML> + XML + end + + def failed_verify_response + <<-XML +<V_XML Version="2.0" Direction="Response"> + <Transaction ApplicationID="{D10A603D-4ADE-405B-93F1-826DFC0181E8}" Command="Authorisation" Mode="Test" RequestID="{A700FAE2-2A76-407D-A540-B41668E2B703}"> + <Result Status="-1" Code="4" Description="Denied" Source="NBPostilionBICISONBSouthAfrica" AppServer="105IVERIAPPPR02" DBServer="105iveridbpr01" Gateway="Nedbank" AcquirerCode="05" AcquirerDescription="Do not Honour" /> + <Amount>0</Amount> + <Currency>ZAR</Currency> + <ExpiryDate>092018</ExpiryDate> + <MerchantReference>e955afb03f224284b09ad6ae7e9b4683</MerchantReference> + <Terminal>Default</Terminal> + <TransactionIndex>{2A378547-AEA4-48E1-8A3E-29F9BBEA954D}</TransactionIndex> + <MerchantName>iVeri Payment Technology</MerchantName> + <MerchantUSN>7771777</MerchantUSN> + <Acquirer>NBPostilionBICISONBSouthAfrica</Acquirer> + <AcquirerReference>70418:04078337</AcquirerReference> + <AcquirerDate>20170418</AcquirerDate> + <AcquirerTime>161716</AcquirerTime> + <DisplayAmount>R 0.00</DisplayAmount> + <BIN>2</BIN> + <Association>Unknown Association</Association> + <CardType>Unknown CardType</CardType> + <Issuer>Unknown</Issuer> + <Jurisdiction>Local</Jurisdiction> + <PANMode>Keyed,CVV</PANMode> + <ReconReference>04078337</ReconReference> + <CardHolderPresence>CardNotPresent</CardHolderPresence> + <MerchantAddress>MERCHANT ADDRESS</MerchantAddress> + <MerchantCity>Sandton</MerchantCity> + <MerchantCountryCode>ZA</MerchantCountryCode> + <MerchantCountry>South Africa</MerchantCountry> + <DistributorName>Nedbank</DistributorName> + <CCNumber>2121........2121</CCNumber> + <PAN>2121........2121</PAN> + </Transaction> +</V_XML> + XML + end + + def successful_verify_credentials_response + <<-XML +<V_XML Version="2.0" Direction="Response"> + <Transaction ApplicationID="{D10A603D-4ADE-405B-93F1-826DFC0181E8}" Command="Void" Mode="Test" RequestID="{5ED922D0-92AD-40DF-9019-320591A4BA59}"> + <Result Status="-1" Code="255" Description="Missing OriginalMerchantTrace" Source="NBPostilionBICISONBSouthAfricaTestProvider" AppServer="105IVERIAPPPR01" DBServer="105IVERIDBPR01" Gateway="Nedbank" AcquirerCode="" AcquirerDescription="" /> + </Transaction> +</V_XML> + XML + end + + def failed_verify_credentials_response + <<-XML +<V_XML Version="2.0" Direction="Response"> + <Result Status="-1" Code="255" Description="The ApplicationID {11111111-1111-1111-1111-111111111111} is not valid for the current CertificateID {11111111-1111-1111-1111-111111111111}" Source="RequestHandler" RequestID="{EE6E5B39-63AD-402C-8331-F25082AD8564}" AppServer="105IVERIAPPPR01" DBServer="105IVERIDBPR01" Gateway="Nedbank" AcquirerCode="" AcquirerDescription="" /> +</V_XML> + XML + end +end From edaef2d13a064274bb200f9740c6fb43be1c7b72 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Wed, 19 Apr 2017 19:36:21 -0400 Subject: [PATCH 051/677] ProPay: Add gateway support Closes #2405 --- CHANGELOG | 1 + .../billing/gateways/pro_pay.rb | 326 ++++++++++++++++++ test/fixtures.yml | 4 + test/remote/gateways/remote_pro_pay_test.rb | 160 +++++++++ test/unit/gateways/pro_pay_test.rb | 291 ++++++++++++++++ 5 files changed, 782 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/pro_pay.rb create mode 100644 test/remote/gateways/remote_pro_pay_test.rb create mode 100644 test/unit/gateways/pro_pay_test.rb diff --git a/CHANGELOG b/CHANGELOG index c6857fe186c..59ebecd1c61 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * SafeCharge: Support credit transactions [shasum] #2404 * WePay: Add scrub method [shasum] #2406 * iVeri: Add gateway support [curiousepic] #2400 +* ProPay: Add gateway support [davidsantoso] #2405 == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/pro_pay.rb b/lib/active_merchant/billing/gateways/pro_pay.rb new file mode 100644 index 00000000000..2d4e1bb8b64 --- /dev/null +++ b/lib/active_merchant/billing/gateways/pro_pay.rb @@ -0,0 +1,326 @@ +require 'nokogiri' + +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class ProPayGateway < Gateway + self.test_url = 'https://xmltest.propay.com/API/PropayAPI.aspx' + self.live_url = 'https://epay.propay.com/api/propayapi.aspx' + + self.supported_countries = ['US'] + self.default_currency = 'USD' + self.money_format = :cents + self.supported_cardtypes = [:visa, :master, :american_express, :discover] + + self.homepage_url = 'https://www.propay.com/' + self.display_name = 'ProPay' + + STATUS_RESPONSE_CODES = { + "00" => "Success", + "20" => "Invalid username", + "21" => "Invalid transType", + "22" => "Invalid Currency Code", + "23" => "Invalid accountType", + "24" => "Invalid sourceEmail", + "25" => "Invalid firstName", + "26" => "Invalid mInitial", + "27" => "Invalid lastName", + "28" => "Invalid billAddr", + "29" => "Invalid aptNum", + "30" => "Invalid city", + "31" => "Invalid state", + "32" => "Invalid billZip", + "33" => "Invalid mailAddr", + "34" => "Invalid mailApt", + "35" => "Invalid mailCity", + "36" => "Invalid mailState", + "37" => "Invalid mailZip", + "38" => "Invalid dayPhone", + "39" => "Invalid evenPhone", + "40" => "Invalid ssn", + "41" => "Invalid dob", + "42" => "Invalid recEmail", + "43" => "Invalid knownAccount", + "44" => "Invalid amount", + "45" => "Invalid invNum", + "46" => "Invalid rtNum", + "47" => "Invalid accntNum", + "48" => "Invalid ccNum", + "49" => "Invalid expDate", + "50" => "Invalid cvv2", + "51" => "Invalid transNum and/or Unable to act perform actions on transNum due to funding", + "52" => "Invalid splitNum", + "53" => "A ProPay account with this email address already exists AND/OR User has no account number", + "54" => "A ProPay account with this social security number already exists", + "55" => "The email address provided does not correspond to a ProPay account.", + "56" => "Recipient’s email address shouldn’t have a ProPay account and does", + "57" => "Cannot settle transaction because it already expired", + "58" => "Credit card declined", + "59" => "Invalid Credential or IP address not allowed", + "60" => "Credit card authorization timed out; retry at a later time", + "61" => "Amount exceeds single transaction limit", + "62" => "Amount exceeds monthly volume limit", + "63" => "Insufficient funds in account", + "64" => "Over credit card use limit", + "65" => "Miscellaneous error", + "66" => "Denied a ProPay account", + "67" => "Unauthorized service requested", + "68" => "Account not affiliated", + "69" => "Duplicate invoice number (The same card was charged for the same amount with the same invoice number (including blank invoices) in a 1 minute period. Details about the original transaction are included whenever a 69 response is returned. These details include a repeat of the auth code, the original AVS response, and the original CVV response.)", + "70" => "Duplicate external ID", + "71" => "Account previously set up, but problem affiliating it with partner", + "72" => "The ProPay Account has already been upgraded to a Premium Account", + "73" => "Invalid Destination Account", + "74" => "Account or Trans Error", + "75" => "Money already pulled", + "76" => "Not Premium (used only for push/pull transactions)", + "77" => "Empty results", + "78" => "Invalid Authentication", + "79" => "Generic account status error", + "80" => "Invalid Password", + "81" => "Account Expired", + "82" => "InvalidUserID", + "83" => "BatchTransCountError", + "84" => "InvalidBeginDate", + "85" => "InvalidEndDate", + "86" => "InvalidExternalID", + "87" => "DuplicateUserID", + "88" => "Invalid track 1", + "89" => "Invalid track 2", + "90" => "Transaction already refunded", + "91" => "Duplicate Batch ID" + } + + TRANSACTION_RESPONSE_CODES = { + "00" => "Success", + "1" => "Transaction blocked by issuer", + "4" => "Pick up card and deny transaction", + "5" => "Problem with the account", + "6" => "Customer requested stop to recurring payment", + "7" => "Customer requested stop to all recurring payments", + "8" => "Honor with ID only", + "9" => "Unpaid items on customer account", + "12" => "Invalid transaction", + "13" => "Amount Error", + "14" => "Invalid card number", + "15" => "No such issuer. Could not route transaction", + "16" => "Refund error", + "17" => "Over limit", + "19" => "Reenter transaction or the merchant account may be boarded incorrectly", + "25" => "Invalid terminal 41 Lost card", + "43" => "Stolen card", + "51" => "Insufficient funds", + "52" => "No such account", + "54" => "Expired card", + "55" => "Incorrect PIN", + "57" => "Bank does not allow this type of purchase", + "58" => "Credit card network does not allow this type of purchase for your merchant account.", + "61" => "Exceeds issuer withdrawal limit", + "62" => "Issuer does not allow this card to be charged for your business.", + "63" => "Security Violation", + "65" => "Activity limit exceeded", + "75" => "PIN tries exceeded", + "76" => "Unable to locate account", + "78" => "Account not recognized", + "80" => "Invalid Date", + "82" => "Invalid CVV2", + "83" => "Cannot verify the PIN", + "85" => "Service not supported for this card", + "93" => "Cannot complete transaction. Customer should call 800 number.", + "95" => "Misc Error Transaction failure", + "96" => "Issuer system malfunction or timeout.", + "97" => "Approved for a lesser amount. ProPay will not settle and consider this a decline.", + "98" => "Failure HV", + "99" => "Generic decline or unable to parse issuer response code" + } + + def initialize(options={}) + requires!(options, :cert_str) + super + end + + def purchase(money, payment, options={}) + request = build_xml_request do |xml| + add_invoice(xml, money, options) + add_payment(xml, payment, options) + add_address(xml, options) + add_account(xml, options) + add_recurring(xml, options) + xml.transType "04" + end + + commit(request) + end + + def authorize(money, payment, options={}) + request = build_xml_request do |xml| + add_invoice(xml, money, options) + add_payment(xml, payment, options) + add_address(xml, options) + add_account(xml, options) + add_recurring(xml, options) + xml.transType "05" + end + + commit(request) + end + + def capture(money, authorization, options={}) + request = build_xml_request do |xml| + add_invoice(xml, money, options) + add_account(xml, options) + xml.transNum authorization + xml.transType "06" + end + + commit(request) + end + + def refund(money, authorization, options={}) + request = build_xml_request do |xml| + add_invoice(xml, money, options) + add_account(xml, options) + xml.transNum authorization + xml.transType "07" + end + + commit(request) + end + + def void(authorization, options={}) + refund(nil, authorization, options) + end + + def credit(money, payment, options={}) + request = build_xml_request do |xml| + add_invoice(xml, money, options) + add_payment(xml, payment, options) + add_account(xml, options) + xml.transType "35" + end + + commit(request) + end + + def verify(credit_card, options={}) + MultiResponse.run(:use_first_response) do |r| + r.process { authorize(100, credit_card, options) } + r.process(:ignore_result) { void(r.authorization, options) } + end + end + + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r(().+()), '\1[FILTERED]\2'). + gsub(%r(().+()), '\1[FILTERED]\2'). + gsub(%r(().+()), '\1[FILTERED]\2') + end + + private + + def add_payment(xml, payment, options) + xml.ccNum payment.number + xml.expDate "#{format(payment.month, :two_digits)}#{format(payment.year, :two_digits)}" + xml.CVV2 payment.verification_value + xml.cardholderName payment.name + end + + def add_address(xml, options) + if address = options[:billing_address] || options[:address] + xml.addr address[:address1] + xml.aptNum address[:address2] + xml.city address[:city] + xml.state address[:state] + xml.zip address[:zip] + end + end + + def add_account(xml, options) + xml.accountNum options[:account_num] + end + + def add_invoice(xml, money, options) + xml.amount amount(money) + xml.currencyCode options[:currency] || currency(money) + xml.invNum options[:order_id] || SecureRandom.hex(25) + end + + def add_recurring(xml, options) + xml.recurringPayment options[:recurring_payment] + end + + def parse(body) + results = {} + xml = Nokogiri::XML(body) + resp = xml.xpath("//XMLResponse/XMLTrans") + resp.children.each do |element| + results[element.name.underscore.downcase.to_sym] = element.text + end + results + end + + def commit(parameters) + url = (test? ? test_url : live_url) + response = parse(ssl_post(url, parameters)) + + Response.new( + success_from(response), + message_from(response), + response, + authorization: authorization_from(response), + avs_result: AVSResult.new(code: response[:avs]), + cvv_result: CVVResult.new(response[:cvv2_resp]), + test: test?, + error_code: error_code_from(response) + ) + end + + def success_from(response) + response[:status] == "00" + end + + def message_from(response) + return "Success" if success_from(response) + message = STATUS_RESPONSE_CODES[response[:status]] + message += " - #{TRANSACTION_RESPONSE_CODES[response[:response_code]]}" if response[:response_code] + + message + end + + def authorization_from(response) + response[:trans_num] + end + + def error_code_from(response) + unless success_from(response) + response[:status] + end + end + + def build_xml_request + builder = Nokogiri::XML::Builder.new do |xml| + xml.XMLRequest do + xml.certStr @options[:cert_str] + xml.class_ "partner" + xml.XMLTrans do + yield(xml) + end + end + end + + builder.to_xml + end + end + + def underscore(camel_cased_word) + camel_cased_word.to_s.gsub(/::/, '/'). + gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). + gsub(/([a-z\d])([A-Z])/,'\1_\2'). + tr("-", "_"). + downcase + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index a0b23e1c68f..43b83568389 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -735,6 +735,10 @@ plugnpay: login: LOGIN password: PASSWORD +# Working credentials, no need to replace +pro_pay: + cert_str: "5ab9cddef2e4911b77e0c4ffb70f03" + # Working credentials, no need to replace psigate: login: teststore diff --git a/test/remote/gateways/remote_pro_pay_test.rb b/test/remote/gateways/remote_pro_pay_test.rb new file mode 100644 index 00000000000..f08bd6e9176 --- /dev/null +++ b/test/remote/gateways/remote_pro_pay_test.rb @@ -0,0 +1,160 @@ +require 'test_helper' + +class RemoteProPayTest < Test::Unit::TestCase + def setup + @gateway = ProPayGateway.new(fixtures(:pro_pay)) + + @amount = 100 + @credit_card = credit_card('4747474747474747', verification_value: 999) + @declined_card = credit_card('4616161616161616') + @credit_card_without_cvv = credit_card('4747474747474747', verification_value: nil) + @options = { + billing_address: address, + account_num: "32287391" + } + end + + def test_successful_purchase + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Success', response.message + end + + def test_successful_purchase_with_more_options + options = { + order_id: '1', + ip: "127.0.0.1", + email: "joe@example.com", + account_num: "32287391" + } + + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_equal 'Success', response.message + end + + def test_successful_recurring_purchase_without_cvv + @options.merge!({recurring_payment: 'Y'}) + response = @gateway.purchase(@amount, @credit_card_without_cvv, @options) + assert_success response + assert_equal 'Success', response.message + end + + def test_failed_purchase + response = @gateway.purchase(@amount, @declined_card, @options) + assert_failure response + assert_match(/declined/, response.message) + assert_match(/Insufficient funds/, response.message) + end + + def test_successful_authorize_and_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount, auth.authorization, @options) + assert_success capture + assert_equal 'Success', capture.message + end + + def test_failed_authorize + response = @gateway.authorize(@amount, @declined_card, @options) + assert_failure response + assert_match(/declined/, response.message) + assert_match(/Insufficient funds/, response.message) + end + + def test_partial_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount-1, auth.authorization, @options) + assert_success capture + end + + def test_failed_capture + response = @gateway.capture(@amount, '', @options) + assert_failure response + assert_match(/Invalid/, response.message) + end + + def test_successful_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount, purchase.authorization, @options) + assert_success refund + assert_equal 'Success', refund.message + end + + def test_partial_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount-1, purchase.authorization, @options) + assert_success refund + end + + def test_failed_refund + response = @gateway.refund(@amount, '', @options) + assert_failure response + assert_match(/Invalid/, response.message) + end + + def test_successful_void + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert void = @gateway.void(auth.authorization, @options) + assert_success void + assert_equal 'Success', void.message + end + + def test_failed_void + response = @gateway.void('', @options) + assert_failure response + assert_match(/Invalid/, response.message) + end + + def test_successful_credit + response = @gateway.credit(@amount, @credit_card, @options) + assert_success response + assert_equal 'Success', response.message + end + + def test_failed_credit + response = @gateway.credit(@amount, credit_card(''), @options) + assert_failure response + assert_equal 'Invalid ccNum', response.message + end + + def test_successful_verify + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_match "Success", response.message + end + + def test_failed_verify + response = @gateway.verify(@declined_card, @options) + assert_failure response + assert_match(/declined/, response.message) + assert_match(/Insufficient funds/, response.message) + end + + def test_invalid_login + gateway = ProPayGateway.new(cert_str: 'bad_cert_str') + + response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:cert_str], transcript) + end +end diff --git a/test/unit/gateways/pro_pay_test.rb b/test/unit/gateways/pro_pay_test.rb new file mode 100644 index 00000000000..ae462de87f3 --- /dev/null +++ b/test/unit/gateways/pro_pay_test.rb @@ -0,0 +1,291 @@ +require 'test_helper' + +class ProPayTest < Test::Unit::TestCase + include CommStub + + def setup + @gateway = ProPayGateway.new(cert_str: 'certStr') + @credit_card = credit_card + @amount = 100 + + @options = { + order_id: '1', + billing_address: address, + description: 'Store Purchase' + } + end + + def test_successful_purchase + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + + assert_equal '16', response.authorization + assert_equal 'Success', response.message + end + + def test_failed_purchase + @gateway.expects(:ssl_post).returns(failed_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal '58', response.error_code + assert_equal 'Credit card declined - Insufficient funds', response.message + end + + def test_successful_authorize + @gateway.expects(:ssl_post).returns(successful_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + + assert_equal '24', response.authorization + assert_equal 'Success', response.message + end + + def test_failed_authorize + @gateway.expects(:ssl_post).returns(failed_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_equal '58', response.error_code + assert_equal 'Credit card declined - Insufficient funds', response.message + end + + def test_successful_capture + @gateway.expects(:ssl_post).returns(successful_capture_response) + + response = @gateway.capture(@amount, "auth", @options) + assert_success response + + assert_equal '24', response.authorization + assert_equal 'Success', response.message + end + + def test_failed_capture + @gateway.expects(:ssl_post).returns(failed_capture_response) + + response = @gateway.capture(@amount, "invalid-auth", @options) + assert_failure response + assert_equal '51', response.error_code + assert_equal 'Invalid transNum and/or Unable to act perform actions on transNum due to funding', response.message + end + + def test_successful_refund + @gateway.expects(:ssl_post).returns(successful_refund_response) + + response = @gateway.refund(@amount, 'auth', @options) + assert_success response + end + + def test_failed_refund + @gateway.expects(:ssl_post).returns(failed_refund_response) + + response = @gateway.refund(@amount, 'invalid-auth', @options) + assert_failure response + assert_equal 'Invalid transNum and/or Unable to act perform actions on transNum due to funding', response.message + end + + def test_successful_void + response = stub_comms do + @gateway.void('auth', @options) + end.check_request do |endpoint, data, headers| + assert_match(%r(07), data) + end.respond_with(successful_void_response) + + assert_success response + end + + def test_failed_void + response = stub_comms do + @gateway.void('invalid-auth', @options) + end.check_request do |endpoint, data, headers| + assert_match(%r(07), data) + end.respond_with(failed_void_response) + + assert_failure response + end + + def test_successful_verify + @gateway.expects(:ssl_post).times(2).returns(successful_authorize_response, successful_void_response) + + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_equal 'Success', response.message + end + + def test_successful_verify_with_failed_void + @gateway.expects(:ssl_post).times(2).returns(successful_authorize_response, failed_void_response) + + response = @gateway.verify(@credit_card, @options) + assert_success response + end + + def test_successful_credit + @gateway.expects(:ssl_post).returns(successful_credit_response) + + response = @gateway.credit(@amount, @credit_card, @options) + assert_success response + + assert_equal '103', response.authorization + assert_equal 'Success', response.message + end + + def test_failed_credit + @gateway.expects(:ssl_post).returns(failed_credit_response) + + response = @gateway.credit(@amount, @credit_card, @options) + assert_failure response + assert_equal 'Invalid ccNum', response.message + end + + def test_failed_verify + @gateway.expects(:ssl_post).returns(failed_authorize_response) + + response = @gateway.verify(@credit_card, @options) + assert_failure response + assert_equal "58", response.error_code + end + + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + + private + + def pre_scrubbed + <<-RESPONSE +opening connection to xmltest.propay.com:443... +opened +starting SSL for xmltest.propay.com:443... +SSL established +<- "POST /API/PropayAPI.aspx 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: xmltest.propay.com\r\nContent-Length: 547\r\n\r\n" +<- "\n\n 5ab9cddef2e4911b77e0c4ffb70f03\n partner\n \n 100\n USD\n 4747474747474747\n 0918\n 999\n Longbob Longsen\n 456 My Street\n Apt 1\n Ottawa\n ON\n K1C2N6\n 32287391\n 04\n \n\n" +-> "HTTP/1.1 200 OK\r\n" +-> "Cache-Control: max-age=0,no-cache,no-store,must-revalidate\r\n" +-> "Pragma: no-cache\r\n" +-> "Content-Type: text/xml; charset=utf-8\r\n" +-> "Content-Encoding: gzip\r\n" +-> "Expires: Thu, 01 Jan 1970 00:00:00 GMT\r\n" +-> "Vary: Accept-Encoding\r\n" +-> "Server: Microsoft-IIS/7.5\r\n" +-> "Set-Cookie: ASP.NET_SessionId=hn1orxwu31yeoym5fkdhac4o; path=/; secure; HttpOnly\r\n" +-> "Set-Cookie: sessionValidation=1a1d69b6-6e53-408b-b054-602593da00e7; path=/; secure; HttpOnly\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "X-Frame-Options: SAMEORIGIN\r\n" +-> "Date: Tue, 25 Apr 2017 19:44:03 GMT\r\n" +-> "Connection: close\r\n" +-> "Content-Length: 343\r\n" +-> "\r\n" +reading 343 bytes... +-> "" +read 343 bytes +Conn close + RESPONSE + end + + def post_scrubbed + <<-POST_SCRUBBED +opening connection to xmltest.propay.com:443... +opened +starting SSL for xmltest.propay.com:443... +SSL established +<- "POST /API/PropayAPI.aspx 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: xmltest.propay.com\r\nContent-Length: 547\r\n\r\n" +<- "\n\n [FILTERED]\n partner\n \n 100\n USD\n [FILTERED]\n 0918\n [FILTERED]\n Longbob Longsen\n 456 My Street\n Apt 1\n Ottawa\n ON\n K1C2N6\n 32287391\n 04\n \n\n" +-> "HTTP/1.1 200 OK\r\n" +-> "Cache-Control: max-age=0,no-cache,no-store,must-revalidate\r\n" +-> "Pragma: no-cache\r\n" +-> "Content-Type: text/xml; charset=utf-8\r\n" +-> "Content-Encoding: gzip\r\n" +-> "Expires: Thu, 01 Jan 1970 00:00:00 GMT\r\n" +-> "Vary: Accept-Encoding\r\n" +-> "Server: Microsoft-IIS/7.5\r\n" +-> "Set-Cookie: ASP.NET_SessionId=hn1orxwu31yeoym5fkdhac4o; path=/; secure; HttpOnly\r\n" +-> "Set-Cookie: sessionValidation=1a1d69b6-6e53-408b-b054-602593da00e7; path=/; secure; HttpOnly\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "X-Frame-Options: SAMEORIGIN\r\n" +-> "Date: Tue, 25 Apr 2017 19:44:03 GMT\r\n" +-> "Connection: close\r\n" +-> "Content-Length: 343\r\n" +-> "\r\n" +reading 343 bytes... +-> "" +read 343 bytes +Conn close + POST_SCRUBBED + end + + def successful_purchase_response + %( + 04003228739116A11111TM06710033303.25 + ) + end + + def failed_purchase_response + %( + 04583228739122A11111T51 + ) + end + + def successful_authorize_response + %( + 05003228739124A11111TM0010010000.00 + ) + end + + def failed_authorize_response + %( + 05583228739126A11111T51 + ) + end + + def successful_capture_response + %( + 060032287391246710033303.25 + ) + end + + def failed_capture_response + %( + 065132287391 + ) + end + + def successful_refund_response + %( + 0700322873915 + ) + end + + def failed_refund_response + %( + 075132287391 + ) + end + + def successful_void_response + %( + 07003228739144 + ) + end + + def failed_void_response + %( + 075132287391 + ) + end + + def successful_credit_response + %( + 350032287391103 + ) + end + + def failed_credit_response + %( + 354832287391 + ) + end +end From 07a85f1d4f029fbb3f92c8e82fd37b5ebe7d5285 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Fri, 28 Apr 2017 20:44:55 +0530 Subject: [PATCH 052/677] ANet: Fix remote tests Mandatory email and billing address was breaking a bunch of tests which is fixed in this commit. --- .../gateways/remote_authorize_net_test.rb | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb index 79921c148ca..56bbb1f533b 100644 --- a/test/remote/gateways/remote_authorize_net_test.rb +++ b/test/remote/gateways/remote_authorize_net_test.rb @@ -11,6 +11,7 @@ def setup @options = { order_id: '1', + email: 'anet@example.com', duplicate_window: 0, billing_address: address, description: 'Store Purchase' @@ -26,7 +27,7 @@ def test_successful_purchase end def test_successful_purchase_with_minimal_options - response = @gateway.purchase(@amount, @credit_card, duplicate_window: 0) + response = @gateway.purchase(@amount, @credit_card, duplicate_window: 0, email: 'anet@example.com', billing_address: address) assert_success response assert response.test? assert_equal 'This transaction has been approved', response.message @@ -34,7 +35,7 @@ def test_successful_purchase_with_minimal_options end def test_successful_purchase_with_email_customer - response = @gateway.purchase(@amount, @credit_card, duplicate_window: 0, email_customer: true) + response = @gateway.purchase(@amount, @credit_card, duplicate_window: 0, email_customer: true, email: 'anet@example.com', billing_address: address) assert_success response assert response.test? assert_equal 'This transaction has been approved', response.message @@ -42,7 +43,7 @@ def test_successful_purchase_with_email_customer end def test_successful_purchase_with_header_email_receipt - response = @gateway.purchase(@amount, @credit_card, duplicate_window: 0, header_email_receipt: "subject line") + response = @gateway.purchase(@amount, @credit_card, duplicate_window: 0, header_email_receipt: "subject line", email: 'anet@example.com', billing_address: address) assert_success response assert response.test? assert_equal 'This transaction has been approved', response.message @@ -273,7 +274,7 @@ def test_failed_store end def test_successful_purchase_using_stored_card - response = @gateway.store(@credit_card) + response = @gateway.store(@credit_card, @options) assert_success response response = @gateway.purchase(@amount, response.authorization, @options) @@ -295,14 +296,14 @@ def test_failed_purchase_using_stored_card end def test_successful_purchase_using_stored_card_new_payment_profile - assert store = @gateway.store(@credit_card) + assert store = @gateway.store(@credit_card, @options) assert_success store assert store.authorization new_card = credit_card('4007000000027') customer_profile_id, _, _ = store.authorization.split("#") - assert response = @gateway.store(new_card, customer_profile_id: customer_profile_id) + assert response = @gateway.store(new_card, customer_profile_id: customer_profile_id, email: 'anet@example.com', billing_address: address) assert_success response response = @gateway.purchase(@amount, response.authorization, @options) @@ -311,14 +312,14 @@ def test_successful_purchase_using_stored_card_new_payment_profile end def test_successful_authorize_and_capture_using_stored_card - store = @gateway.store(@credit_card) + store = @gateway.store(@credit_card, @options) assert_success store auth = @gateway.authorize(@amount, store.authorization, @options) assert_success auth assert_equal "This transaction has been approved.", auth.message - capture = @gateway.capture(@amount, auth.authorization) + capture = @gateway.capture(@amount, auth.authorization, @options) assert_success capture assert_equal "This transaction has been approved.", capture.message end @@ -338,19 +339,19 @@ def test_failed_authorize_using_stored_card end def test_failed_capture_using_stored_card - store = @gateway.store(@credit_card) + store = @gateway.store(@credit_card, @options) assert_success store auth = @gateway.authorize(@amount, store.authorization, @options) assert_success auth - capture = @gateway.capture(@amount + 4000, auth.authorization) + capture = @gateway.capture(@amount + 4000, auth.authorization, @options) assert_failure capture assert_match %r{The amount requested for settlement cannot be greater}, capture.message end def test_faux_successful_refund_using_stored_card - store = @gateway.store(@credit_card) + store = @gateway.store(@credit_card, @options) assert_success store purchase = @gateway.purchase(@amount, store.authorization, @options) @@ -362,7 +363,7 @@ def test_faux_successful_refund_using_stored_card end def test_failed_refund_using_stored_card - store = @gateway.store(@credit_card) + store = @gateway.store(@credit_card, @options) assert_success store purchase = @gateway.purchase(@amount, store.authorization, @options) @@ -375,28 +376,28 @@ def test_failed_refund_using_stored_card end def test_successful_void_using_stored_card - store = @gateway.store(@credit_card) + store = @gateway.store(@credit_card, @options) assert_success store auth = @gateway.authorize(@amount, store.authorization, @options) assert_success auth - void = @gateway.void(auth.authorization) + void = @gateway.void(auth.authorization, @options) assert_success void assert_equal "This transaction has been approved.", void.message end def test_failed_void_using_stored_card - store = @gateway.store(@credit_card) + store = @gateway.store(@credit_card, @options) assert_success store auth = @gateway.authorize(@amount, store.authorization, @options) assert_success auth - void = @gateway.void(auth.authorization) + void = @gateway.void(auth.authorization, @options) assert_success void - another_void = @gateway.void(auth.authorization) + another_void = @gateway.void(auth.authorization, @options) assert_failure another_void assert_equal "This transaction has already been voided.", another_void.message end From 0e047a69e64f39e704eb3c825b35e84558b7b55c Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 1 May 2017 06:11:28 -0700 Subject: [PATCH 053/677] Add Rails 5.1 support (#2407) * Fix syntax in Gemfile.rails51 * Test Rails 5.1 release on travis * Add Rails 5.1 support * Losen activesupport dependency to < 6.x This will allow any 5.x.x version of Rails, but will forbid any future Rails 6.0.0.beta. --- .travis.yml | 8 +++----- Gemfile.rails51 | 2 +- activemerchant.gemspec | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index b9d08f78879..94450c38b5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,22 +15,20 @@ gemfile: - Gemfile.rails41 - Gemfile.rails42 - Gemfile.rails50 +- Gemfile.rails51 matrix: exclude: - rvm: 2.1 gemfile: Gemfile.rails50 + - rvm: 2.1 + gemfile: Gemfile.rails51 - rvm: 2.4.1 gemfile: Gemfile.rails32 - rvm: 2.4.1 gemfile: Gemfile.rails40 - rvm: 2.4.1 gemfile: Gemfile.rails41 - include: - - rvm: 2.4.1 - gemfile: Gemfile.rails51 - allow_failures: - - gemfile: Gemfile.rails51 notifications: email: diff --git a/Gemfile.rails51 b/Gemfile.rails51 index f40849829a3..100dfb1ff95 100644 --- a/Gemfile.rails51 +++ b/Gemfile.rails51 @@ -8,4 +8,4 @@ group :test, :remote_test do gem 'braintree', '>= 2.50.0' end -gem 'activesupport', gem 'activesupport', '~> 5.1.0.rc1' +gem 'activesupport', '~> 5.1.0' diff --git a/activemerchant.gemspec b/activemerchant.gemspec index 3ed9f110385..23f420287b3 100644 --- a/activemerchant.gemspec +++ b/activemerchant.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.has_rdoc = true if Gem::VERSION < '1.7.0' - s.add_dependency('activesupport', '>= 3.2.14', '< 5.1') + s.add_dependency('activesupport', '>= 3.2.14', '< 6.x') s.add_dependency('i18n', '>= 0.6.9') s.add_dependency('builder', '>= 2.1.2', '< 4.0.0') s.add_dependency('nokogiri', "~> 1.4") From d61abc0bee1bba90fbb71798217cc78a3566451a Mon Sep 17 00:00:00 2001 From: David Santoso Date: Mon, 1 May 2017 11:34:07 -0400 Subject: [PATCH 054/677] ProPay: Add Canada as supported country --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/pro_pay.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 59ebecd1c61..273d35b0e2a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * WePay: Add scrub method [shasum] #2406 * iVeri: Add gateway support [curiousepic] #2400 * ProPay: Add gateway support [davidsantoso] #2405 +* ProPay: Add Canada as supported country [davidsantoso] == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/pro_pay.rb b/lib/active_merchant/billing/gateways/pro_pay.rb index 2d4e1bb8b64..73bc14ed749 100644 --- a/lib/active_merchant/billing/gateways/pro_pay.rb +++ b/lib/active_merchant/billing/gateways/pro_pay.rb @@ -6,7 +6,7 @@ class ProPayGateway < Gateway self.test_url = 'https://xmltest.propay.com/API/PropayAPI.aspx' self.live_url = 'https://epay.propay.com/api/propayapi.aspx' - self.supported_countries = ['US'] + self.supported_countries = ['US', 'CA'] self.default_currency = 'USD' self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express, :discover] From 7d4231cb01134595ce0168a045b872b781c50e31 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Tue, 2 May 2017 10:19:40 -0400 Subject: [PATCH 055/677] Stub Authorize.Net unit test to fix Travis build failure --- test/unit/gateways/authorize_net_test.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 56f732e0b17..eae3f37ea5f 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -660,7 +660,9 @@ def test_duplicate_window def test_duplicate_window_class_attribute_deprecated @gateway.class.duplicate_window = 0 assert_deprecation_warning("Using the duplicate_window class_attribute is deprecated. Use the transaction options hash instead.") do - @gateway.purchase(@amount, @credit_card) + stub_comms do + @gateway.purchase(@amount, @credit_card) + end.respond_with(successful_purchase_response) end ensure @gateway.class.duplicate_window = nil From 4a13ef6c3750853b3e589a545c4fc9377261471f Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Tue, 2 May 2017 01:23:11 +0530 Subject: [PATCH 056/677] JetPay: Update XML API to 2.2 Closes #2409 --- CHANGELOG | 1 + .../billing/gateways/jetpay.rb | 56 +++++++++++-------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 273d35b0e2a..2b3a8f30469 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * iVeri: Add gateway support [curiousepic] #2400 * ProPay: Add gateway support [davidsantoso] #2405 * ProPay: Add Canada as supported country [davidsantoso] +* JetPay: Update XML API to 2.2 [shasum] #2409 == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/jetpay.rb b/lib/active_merchant/billing/gateways/jetpay.rb index 9dfdefe2b2a..d4abf854d62 100644 --- a/lib/active_merchant/billing/gateways/jetpay.rb +++ b/lib/active_merchant/billing/gateways/jetpay.rb @@ -22,6 +22,8 @@ class JetpayGateway < Gateway # all transactions are in cents self.money_format = :cents + API_VERSION = '2.2' + ACTION_CODE_MESSAGES = { "000" => "Approved.", "001" => "Refer to card issuer.", @@ -208,14 +210,19 @@ def scrub(transcript) def build_xml_request(transaction_type, options = {}, transaction_id = nil, &block) xml = Builder::XmlMarkup.new - xml.tag! 'JetPay' do + xml.tag! 'JetPay', 'Version' => API_VERSION do # The basic values needed for any request xml.tag! 'TerminalID', @options[:login] xml.tag! 'TransactionType', transaction_type xml.tag! 'TransactionID', transaction_id.nil? ? generate_unique_id.slice(0, 18) : transaction_id - if options && options[:origin] - xml.tag! 'Origin', options[:origin] - end + xml.tag! 'Origin', options[:origin] || 'INTERNET' + xml.tag! 'IndustryInfo', 'Type' => options[:industry_info] || 'ECOMMERCE' + xml.tag! 'ReaderUsed', options[:reader_used] || 'CHIP' + xml.tag! 'Application', 'VirtPOS', 'Version' => '4.2' + xml.tag! 'Device', 'Fake POS', 'Version' => '1.0' + xml.tag! 'Library', 'ActiveMerchant', 'Version' => '1.x' + xml.tag! 'Gateway', 'JetPay' + xml.tag! 'DeveloperID', options[:developer_id] || 'n/a' if block_given? yield xml @@ -339,7 +346,7 @@ def authorization_from(response, money, previous_token) end def add_credit_card(xml, credit_card) - xml.tag! 'CardNum', credit_card.number, "Tokenize" => true + xml.tag! 'CardNum', credit_card.number, "CardPresent" => false, "Tokenize" => true xml.tag! 'CardExpMonth', format_exp(credit_card.month) xml.tag! 'CardExpYear', format_exp(credit_card.year) @@ -354,37 +361,40 @@ def add_credit_card(xml, credit_card) def add_addresses(xml, options) if billing_address = options[:billing_address] || options[:address] - xml.tag! 'BillingAddress', [billing_address[:address1], billing_address[:address2]].compact.join(" ") - xml.tag! 'BillingCity', billing_address[:city] - xml.tag! 'BillingStateProv', billing_address[:state] - xml.tag! 'BillingPostalCode', billing_address[:zip] - xml.tag! 'BillingCountry', lookup_country_code(billing_address[:country]) - xml.tag! 'BillingPhone', billing_address[:phone] + xml.tag! 'Billing' do + xml.tag! 'Address', [billing_address[:address1], billing_address[:address2]].compact.join(" ") + xml.tag! 'City', billing_address[:city] + xml.tag! 'StateProv', billing_address[:state] + xml.tag! 'PostalCode', billing_address[:zip] + xml.tag! 'Country', lookup_country_code(billing_address[:country]) + xml.tag! 'Phone', billing_address[:phone] + xml.tag! 'Email', options[:email] if options[:email] + end end if shipping_address = options[:shipping_address] - xml.tag! 'ShippingInfo' do - xml.tag! 'ShippingName', shipping_address[:name] - - xml.tag! 'ShippingAddr' do - xml.tag! 'Address', [shipping_address[:address1], shipping_address[:address2]].compact.join(" ") - xml.tag! 'City', shipping_address[:city] - xml.tag! 'StateProv', shipping_address[:state] - xml.tag! 'PostalCode', shipping_address[:zip] - xml.tag! 'Country', lookup_country_code(shipping_address[:country]) - end + xml.tag! 'Shipping' do + xml.tag! 'Name', shipping_address[:name] + xml.tag! 'Address', [shipping_address[:address1], shipping_address[:address2]].compact.join(" ") + xml.tag! 'City', shipping_address[:city] + xml.tag! 'StateProv', shipping_address[:state] + xml.tag! 'PostalCode', shipping_address[:zip] + xml.tag! 'Country', lookup_country_code(shipping_address[:country]) + xml.tag! 'Phone', shipping_address[:phone] end end end def add_customer_data(xml, options) - xml.tag! 'Email', options[:email] if options[:email] xml.tag! 'UserIPAddress', options[:ip] if options[:ip] end def add_invoice_data(xml, options) xml.tag! 'OrderNumber', options[:order_id] if options[:order_id] - xml.tag! 'TaxAmount', amount(options[:tax]) if options[:tax] + if tax = options[:tax] + exemption = options[:exemption] || false + xml.tag! 'TaxAmount', amount(tax), 'ExemptInd' => exemption + end end def add_user_defined_fields(xml, options) From f7daceeb8d0b27811a13da6618b2a29173d21f66 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Wed, 3 May 2017 13:15:47 -0400 Subject: [PATCH 057/677] Revert "JetPay: Update XML API to 2.2" This reverts commit 4a13ef6c3750853b3e589a545c4fc9377261471f. Unfortunately upgrading to Jetpay's v2.2 API requires a certification process that is not apparent while testing transactions against the sandbox. Once certification happens, merchants are given a couple extra fields that act as additional authentication values for requests. The sandbox does not/did not surface those requirements. This is being reverted for now to prevent any users of the Jetpay adapter from confusion or accidental upgrades. We're currently speaking with Jetpay support and reassessing the v2.2 upgrade to find the best path forward. At this point it seems likely that we will need to break off to a new JetpayV2 adapter similar to how the Checkout.com version 2 API was supported with a CheckoutV2 adapter. It should be noted that the original intent to upgrade was to allow merchants to pass in level 2 data for processing which is not available in the current Jetpay API version in Active Merchant. --- CHANGELOG | 1 - .../billing/gateways/jetpay.rb | 56 ++++++++----------- 2 files changed, 23 insertions(+), 34 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2b3a8f30469..273d35b0e2a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,7 +6,6 @@ * iVeri: Add gateway support [curiousepic] #2400 * ProPay: Add gateway support [davidsantoso] #2405 * ProPay: Add Canada as supported country [davidsantoso] -* JetPay: Update XML API to 2.2 [shasum] #2409 == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/jetpay.rb b/lib/active_merchant/billing/gateways/jetpay.rb index d4abf854d62..9dfdefe2b2a 100644 --- a/lib/active_merchant/billing/gateways/jetpay.rb +++ b/lib/active_merchant/billing/gateways/jetpay.rb @@ -22,8 +22,6 @@ class JetpayGateway < Gateway # all transactions are in cents self.money_format = :cents - API_VERSION = '2.2' - ACTION_CODE_MESSAGES = { "000" => "Approved.", "001" => "Refer to card issuer.", @@ -210,19 +208,14 @@ def scrub(transcript) def build_xml_request(transaction_type, options = {}, transaction_id = nil, &block) xml = Builder::XmlMarkup.new - xml.tag! 'JetPay', 'Version' => API_VERSION do + xml.tag! 'JetPay' do # The basic values needed for any request xml.tag! 'TerminalID', @options[:login] xml.tag! 'TransactionType', transaction_type xml.tag! 'TransactionID', transaction_id.nil? ? generate_unique_id.slice(0, 18) : transaction_id - xml.tag! 'Origin', options[:origin] || 'INTERNET' - xml.tag! 'IndustryInfo', 'Type' => options[:industry_info] || 'ECOMMERCE' - xml.tag! 'ReaderUsed', options[:reader_used] || 'CHIP' - xml.tag! 'Application', 'VirtPOS', 'Version' => '4.2' - xml.tag! 'Device', 'Fake POS', 'Version' => '1.0' - xml.tag! 'Library', 'ActiveMerchant', 'Version' => '1.x' - xml.tag! 'Gateway', 'JetPay' - xml.tag! 'DeveloperID', options[:developer_id] || 'n/a' + if options && options[:origin] + xml.tag! 'Origin', options[:origin] + end if block_given? yield xml @@ -346,7 +339,7 @@ def authorization_from(response, money, previous_token) end def add_credit_card(xml, credit_card) - xml.tag! 'CardNum', credit_card.number, "CardPresent" => false, "Tokenize" => true + xml.tag! 'CardNum', credit_card.number, "Tokenize" => true xml.tag! 'CardExpMonth', format_exp(credit_card.month) xml.tag! 'CardExpYear', format_exp(credit_card.year) @@ -361,40 +354,37 @@ def add_credit_card(xml, credit_card) def add_addresses(xml, options) if billing_address = options[:billing_address] || options[:address] - xml.tag! 'Billing' do - xml.tag! 'Address', [billing_address[:address1], billing_address[:address2]].compact.join(" ") - xml.tag! 'City', billing_address[:city] - xml.tag! 'StateProv', billing_address[:state] - xml.tag! 'PostalCode', billing_address[:zip] - xml.tag! 'Country', lookup_country_code(billing_address[:country]) - xml.tag! 'Phone', billing_address[:phone] - xml.tag! 'Email', options[:email] if options[:email] - end + xml.tag! 'BillingAddress', [billing_address[:address1], billing_address[:address2]].compact.join(" ") + xml.tag! 'BillingCity', billing_address[:city] + xml.tag! 'BillingStateProv', billing_address[:state] + xml.tag! 'BillingPostalCode', billing_address[:zip] + xml.tag! 'BillingCountry', lookup_country_code(billing_address[:country]) + xml.tag! 'BillingPhone', billing_address[:phone] end if shipping_address = options[:shipping_address] - xml.tag! 'Shipping' do - xml.tag! 'Name', shipping_address[:name] - xml.tag! 'Address', [shipping_address[:address1], shipping_address[:address2]].compact.join(" ") - xml.tag! 'City', shipping_address[:city] - xml.tag! 'StateProv', shipping_address[:state] - xml.tag! 'PostalCode', shipping_address[:zip] - xml.tag! 'Country', lookup_country_code(shipping_address[:country]) - xml.tag! 'Phone', shipping_address[:phone] + xml.tag! 'ShippingInfo' do + xml.tag! 'ShippingName', shipping_address[:name] + + xml.tag! 'ShippingAddr' do + xml.tag! 'Address', [shipping_address[:address1], shipping_address[:address2]].compact.join(" ") + xml.tag! 'City', shipping_address[:city] + xml.tag! 'StateProv', shipping_address[:state] + xml.tag! 'PostalCode', shipping_address[:zip] + xml.tag! 'Country', lookup_country_code(shipping_address[:country]) + end end end end def add_customer_data(xml, options) + xml.tag! 'Email', options[:email] if options[:email] xml.tag! 'UserIPAddress', options[:ip] if options[:ip] end def add_invoice_data(xml, options) xml.tag! 'OrderNumber', options[:order_id] if options[:order_id] - if tax = options[:tax] - exemption = options[:exemption] || false - xml.tag! 'TaxAmount', amount(tax), 'ExemptInd' => exemption - end + xml.tag! 'TaxAmount', amount(options[:tax]) if options[:tax] end def add_user_defined_fields(xml, options) From bf900a35ecd6281a8756add0e8a4d725d34edc9c Mon Sep 17 00:00:00 2001 From: David Santoso Date: Wed, 3 May 2017 10:52:44 -0400 Subject: [PATCH 058/677] iVeri: Support 3DSecure data fields Closes #2412 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/iveri.rb | 11 +++++++++++ test/remote/gateways/remote_iveri_test.rb | 13 +++++++++++++ 3 files changed, 25 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 273d35b0e2a..e72a998e2d5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * iVeri: Add gateway support [curiousepic] #2400 * ProPay: Add gateway support [davidsantoso] #2405 * ProPay: Add Canada as supported country [davidsantoso] +* iVeri: Support 3DSecure data fields [davidsantoso] #2412 == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/iveri.rb b/lib/active_merchant/billing/gateways/iveri.rb index 5d8aa5f753c..a1ec20624cc 100644 --- a/lib/active_merchant/billing/gateways/iveri.rb +++ b/lib/active_merchant/billing/gateways/iveri.rb @@ -112,7 +112,9 @@ def build_vxml_request(action, options) end def add_auth_purchase_params(post, money, payment_method, options) + add_card_holder_authentication(post, options) add_amount(post, money, options) + add_electronic_commerce_indicator(post, options) add_payment_method(post, payment_method, options) end @@ -121,6 +123,10 @@ def add_amount(post, money, options) post.Currency(options[:currency] || default_currency) end + def add_electronic_commerce_indicator(post, options) + post.ElectronicCommerceIndicator(options[:eci]) if options[:eci] + end + def add_authorization(post, authorization, options) post.MerchantReference(split_auth(authorization)[2]) post.TransactionIndex(split_auth(authorization)[1]) @@ -138,6 +144,11 @@ def add_new_reference(post, options) post.MerchantReference(options[:order_id] || generate_unique_id) end + def add_card_holder_authentication(post, options) + post.CardHolderAuthenticationID(options[:xid]) if options[:xid] + post.CardHolderAuthenticationData(options[:cavv]) if options[:cavv] + end + def commit(post) raw_response = begin ssl_post(live_url, build_xml_envelope(post), headers(post)) diff --git a/test/remote/gateways/remote_iveri_test.rb b/test/remote/gateways/remote_iveri_test.rb index 3248184444d..2a9ef82ff49 100644 --- a/test/remote/gateways/remote_iveri_test.rb +++ b/test/remote/gateways/remote_iveri_test.rb @@ -36,6 +36,19 @@ def test_successful_purchase_with_more_options assert_equal 'Succeeded', response.message end + def test_successful_purchase_with_3ds_params + options = { + eci: "ThreeDSecure", + xid: SecureRandom.hex(14), + cavv: SecureRandom.hex(14) + } + + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_equal 'Succeeded', response.message + end + + def test_failed_purchase response = @gateway.purchase(@amount, @bad_card, @options) assert_failure response From 58e0f7c63aaf08668115e9678ecd0df0c1496b3e Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Thu, 4 May 2017 14:54:56 -0400 Subject: [PATCH 059/677] Release version 1.66.0 --- CHANGELOG | 7 +++++-- lib/active_merchant/version.rb | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e72a998e2d5..53d44b50c69 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,11 +1,14 @@ = ActiveMerchant CHANGELOG == HEAD + +== Version 1.66.0 (May 4, 2017) +* Support Rails 5.1 [jhawthorn] #2407 +* ProPay: Add Canada as supported country [davidsantoso] +* ProPay: Add gateway support [davidsantoso] #2405 * SafeCharge: Support credit transactions [shasum] #2404 * WePay: Add scrub method [shasum] #2406 * iVeri: Add gateway support [curiousepic] #2400 -* ProPay: Add gateway support [davidsantoso] #2405 -* ProPay: Add Canada as supported country [davidsantoso] * iVeri: Support 3DSecure data fields [davidsantoso] #2412 == Version 1.65.0 (April 26, 2017) diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 90a18fad31a..03038b6a665 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.65.0" + VERSION = "1.66.0" end From f0ccc71a5750a5dcaeb42e110a960f62c06d0da2 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Thu, 4 May 2017 22:03:18 +0530 Subject: [PATCH 060/677] Opp: Modify success criteria and other changes Change success criteria to look at transaction result code within the response and not just the http result code. Clean up options to stick to standard Active Merchant ones such as `currency`, `ip` and `email`. Also, modify the way http and json exceptions are handled. Closes #2414 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/opp.rb | 176 ++++++++++---------- test/remote/gateways/remote_opp_test.rb | 68 ++++++-- test/unit/gateways/opp_test.rb | 50 +++--- 4 files changed, 164 insertions(+), 131 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 53d44b50c69..c9bfa990db9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * WePay: Add scrub method [shasum] #2406 * iVeri: Add gateway support [curiousepic] #2400 * iVeri: Support 3DSecure data fields [davidsantoso] #2412 +* Opp: Fix transaction success criteria and clean up options [shasum] #2414 == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb index 6c36a8963b2..911d74cb5aa 100644 --- a/lib/active_merchant/billing/gateways/opp.rb +++ b/lib/active_merchant/billing/gateways/opp.rb @@ -3,19 +3,19 @@ module Billing #:nodoc: class OppGateway < Gateway # = Open Payment Platform # - # The Open Payment Platform includes a powerful omni-channel transaction processing API, - # enabling you to quickly and flexibly build new applications and services on the platform. - # - # This plugin enables connectivity to the Open Payment Platform for activemerchant. + # The Open Payment Platform includes a powerful omni-channel transaction processing API, + # enabling you to quickly and flexibly build new applications and services on the platform. + # + # This plugin enables connectivity to the Open Payment Platform for activemerchant. # # For any questions or comments please contact support@payon.com # # == Usage # # gateway = ActiveMerchant::Billing::OppGateway.new( - # user_id: 'merchant user id', + # user_id: 'merchant user id', # password: 'password', - # entity_id: 'entity id', + # entity_id: 'entity id', # ) # # # set up credit card object as in main ActiveMerchant example @@ -30,7 +30,7 @@ class OppGateway < Gateway # # # Request: complete example, including address, billing address, shipping address # complete_request_options = { - # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId + # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId # merchant_transaction_id: "your merchant/shop transaction id", # address: address, # description: 'Store Purchase - Books', @@ -67,34 +67,34 @@ class OppGateway < Gateway # ip: 101.102.103.104, # }, # } - # + # # # Request: minimal example # minimal_request_options = { - # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId + # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId # description: 'Store Purchase - Books', # } # - # options = + # options = # # run request # response = gateway.purchase(754, creditcard, options) # charge 7,54 EUR # # response.success? # Check whether the transaction was successful - # response.error_code # Retrieve the error message - it's mapped to Gateway::STANDARD_ERROR_CODE + # response.error_code # Retrieve the error message - it's mapped to Gateway::STANDARD_ERROR_CODE # response.message # Retrieve the message returned by opp # response.authorization # Retrieve the unique transaction ID returned by opp # response.params['result']['code'] # Retrieve original return code returned by opp server # # == Errors - # If transaction is not successful, response.error_code contains mapped to Gateway::STANDARD_ERROR_CODE error message. - # Complete list of opp error codes can be viewed on https://docs.oppwa.com/ - # Because this list is much bigger than Gateway::STANDARD_ERROR_CODE, only fraction is mapped to Gateway::STANDARD_ERROR_CODE. - # All other codes are mapped as Gateway::STANDARD_ERROR_CODE[:processing_error], so if this is the case, + # If transaction is not successful, response.error_code contains mapped to Gateway::STANDARD_ERROR_CODE error message. + # Complete list of opp error codes can be viewed on https://docs.oppwa.com/ + # Because this list is much bigger than Gateway::STANDARD_ERROR_CODE, only fraction is mapped to Gateway::STANDARD_ERROR_CODE. + # All other codes are mapped as Gateway::STANDARD_ERROR_CODE[:processing_error], so if this is the case, # you may check the original result code from OPP that can be found in response.params['result']['code'] - # + # # == Special features - # For purchase method risk check can be forced when options[:risk_workflow] = true - # This will split (on OPP server side) the transaction into two separate transactions: authorize and capture, - # but capture will be executed only if risk checks are successful. + # For purchase method risk check can be forced when options[:risk_workflow] = true + # This will split (on OPP server side) the transaction into two separate transactions: authorize and capture, + # but capture will be executed only if risk checks are successful. # # For testing you may use the test account details listed fixtures.yml under opp. It is important to note that there are two test modes available: # options[:test_mode]='EXTERNAL' causes test transactions to be forwarded to the processor's test system for 'end-to-end' testing @@ -102,10 +102,10 @@ class OppGateway < Gateway # If no test_mode parameter is sent, test_mode=INTERNAL is the default behaviour. # # Billing Address, Shipping Address, Custom Parameters are supported as described under https://docs.oppwa.com/parameters - # See complete example above for details. + # See complete example above for details. # # == Tokenization - # When create_registration is set to true, the payment details will be stored and a token will be returned in registrationId response field, + # When create_registration is set to true, the payment details will be stored and a token will be returned in registrationId response field, # which can subsequently be used to reference the stored payment. self.test_url = 'https://test.oppwa.com/v1/payments' @@ -113,7 +113,7 @@ class OppGateway < Gateway self.supported_countries = %w(AD AI AG AR AU AT BS BB BE BZ BM BR BN BG CA HR CY CZ DK DM EE FI FR DE GR GD GY HK HU IS IN IL IT JP LV LI LT LU MY MT MX MC MS NL PA PL PT KN LC MF VC SM SG SK SI ZA ES SR SE CH TR GB US UY) self.default_currency = 'EUR' - self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro, :dankort] + self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro, :dankort] self.homepage_url = 'https://docs.oppwa.com' self.display_name = 'Open Payment Platform' @@ -125,7 +125,7 @@ def initialize(options={}) def purchase(money, payment, options={}) # debit - execute_dbpa(options[:risk_workflow] ? 'PA.CP': 'DB', + execute_dbpa(options[:risk_workflow] ? 'PA.CP': 'DB', money, payment, options) end @@ -133,7 +133,7 @@ def authorize(money, payment, options={}) # preauthorization PA execute_dbpa('PA', money, payment, options) end - + def capture(money, authorization, options={}) # capture CP execute_referencing('CP', money, authorization, options) @@ -163,8 +163,6 @@ def supports_scrubbing? def scrub(transcript) transcript. gsub(%r((authentication\.password=)\w+), '\1[FILTERED]'). - gsub(%r((authentication\.userId=)\w+), '\1[FILTERED]'). - gsub(%r((authentication\.entityId=)\w+), '\1[FILTERED]'). gsub(%r((card\.number=)\d+), '\1[FILTERED]'). gsub(%r((card\.cvv=)\d+), '\1[FILTERED]') end @@ -173,11 +171,11 @@ def scrub(transcript) def execute_dbpa(txtype, money, payment, options) post = {} - post[:paymentType] = txtype + post[:paymentType] = txtype add_invoice(post, money, options) add_payment_method(post, payment, options) add_address(post, options) - add_customer_data(post, options) + add_customer_data(post, payment, options) add_options(post, options) commit(post, nil, options) end @@ -189,38 +187,38 @@ def execute_referencing(txtype, money, authorization, options) commit(post, authorization, options) end - def add_authentication(post) - post[:authentication] = { entityId: @options[:entity_id], password: @options[:password], userId: @options[:user_id]} + def add_authentication(post) + post[:authentication] = { entityId: @options[:entity_id], password: @options[:password], userId: @options[:user_id]} end - def add_customer_data(post, options) + def add_customer_data(post, payment, options) if options[:customer] post[:customer] = { merchantCustomerId: options[:customer][:merchant_customer_id], - givenName: options[:customer][:givenname], - surname: options[:customer][:surname], + givenName: options[:customer][:givenname] || payment.first_name, + surname: options[:customer][:surname] || payment.last_name, birthDate: options[:customer][:birth_date], phone: options[:customer][:phone], mobile: options[:customer][:mobile], - email: options[:customer][:email], + email: options[:customer][:email] || options[:email], companyName: options[:customer][:company_name], identificationDocType: options[:customer][:identification_doctype], identificationDocId: options[:customer][:identification_docid], - ip: options[:customer][:ip], + ip: options[:customer][:ip] || options[:ip] } end end def add_address(post, options) - if billing_address = options[:billing_address] + if billing_address = options[:billing_address] || options[:address] address(post, billing_address, 'billing') end if shipping_address = options[:shipping_address] - address(post, billing_address, 'shipping') + address(post, shipping_address, 'shipping') if shipping_address[:name] - firstname, lastname = shipping_address[:name].split(' ') - post[:shipping] = { givenName: firstname, surname: lastname } - end + firstname, lastname = shipping_address[:name].split(' ') + post[:shipping] = { givenName: firstname, surname: lastname } + end end end @@ -232,15 +230,15 @@ def address(post, address, prefix) state: address[:state], postcode: address[:zip], country: address[:country], - } + } end def add_invoice(post, money, options) post[:amount] = amount(money) - post[:currency] = (currency(money) || @options[:currency]) if 'RV'!=(post[:paymentType]) - post[:descriptor] = options[:description] || options[:descriptor] - post[:merchantInvoiceId] = options[:merchantInvoiceId] || options[:order_id] - post[:merchantTransactionId] = options[:merchant_transaction_id] + post[:currency] = options[:currency] || currency(money) unless post[:paymentType] == 'RV' + post[:descriptor] = options[:description] || options[:descriptor] + post[:merchantInvoiceId] = options[:merchantInvoiceId] || options[:order_id] + post[:merchantTransactionId] = options[:merchant_transaction_id] || generate_unique_id end def add_payment_method(post, payment, options) @@ -271,31 +269,32 @@ def add_options(post, options) def build_url(url, authorization, options) if options[:registrationId] "#{url.gsub(/payments/, 'registrations')}/#{options[:registrationId]}/payments" - elsif authorization + elsif authorization "#{url}/#{authorization}" else url end end - + def commit(post, authorization, options) - url = (test? ? test_url : live_url) + url = build_url(test? ? test_url : live_url, authorization, options) add_authentication(post) post = flatten_hash(post) - url = build_url(url, authorization, options) - raw_response = raw_ssl_request(:post, url, - post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&"), - "Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8") - - success = success_from(raw_response) - response = raw_response.body - begin - response = JSON.parse(response) - rescue JSON::ParserError - response = json_error(response) + response = begin + parse( + ssl_post( + url, + post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&"), + "Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8" + ) + ) + rescue ResponseError => e + parse(e.response.body) end + success = success_from(response) + Response.new( success, message_from(response), @@ -306,11 +305,34 @@ def commit(post, authorization, options) ) end - def success_from(raw_response) - raw_response.code.to_i.between?(200,299) + def parse(body) + begin + JSON.parse(body) + rescue JSON::ParserError + json_error(body) + end + end + + def json_error(body) + message = "Invalid response received #{body.inspect}" + { 'result' => {'description' => message, 'code' => 'unknown' } } + end + + def success_from(response) + return false unless response['result'] + + success_regex = /^(000\.000\.|000\.100\.1|000\.[36])/ + + if success_regex =~ response['result']['code'] + true + else + false + end end def message_from(response) + return 'Failed' unless response['result'] + response['result']['description'] end @@ -319,44 +341,20 @@ def authorization_from(response) end def error_code_from(response) - case response['result']['code'] - when '100.100.101' - Gateway::STANDARD_ERROR_CODE[:incorrect_number] - when '100.400.317' - Gateway::STANDARD_ERROR_CODE[:invalid_number] - when '100.100.600', '100.100.601', '800.100.153', '800.100.192' - Gateway::STANDARD_ERROR_CODE[:invalid_cvc] - when '100.100.303' - Gateway::STANDARD_ERROR_CODE[:expired_card] - when '100.800.200', '100.800.201', '100.800.202', '800.800.202' - Gateway::STANDARD_ERROR_CODE[:incorrect_zip] - when '100.400.000', '100.400.086', '100.400.305', '800.400.150' - Gateway::STANDARD_ERROR_CODE[:incorrect_address] - when '800.100.159' - Gateway::STANDARD_ERROR_CODE[:pickup_card] - when '800.100.151', '800.100.158', '800.100.160' - Gateway::STANDARD_ERROR_CODE[:card_declined] - else - Gateway::STANDARD_ERROR_CODE[:processing_error] - end - end - - def json_error(raw_response) - message = "Invalid response received #{raw_response.inspect}" - { 'result' => {'description' => message, 'code' => 'unknown' } } + response['result']['code'] end - + def flatten_hash(hash) hash.each_with_object({}) do |(k, v), h| if v.is_a? Hash flatten_hash(v).map do |h_k, h_v| h["#{k}.#{h_k}".to_sym] = h_v end - else + else h[k] = v end end - end + end end end end diff --git a/test/remote/gateways/remote_opp_test.rb b/test/remote/gateways/remote_opp_test.rb index e5f00172bcd..5b96b7a5c4f 100644 --- a/test/remote/gateways/remote_opp_test.rb +++ b/test/remote/gateways/remote_opp_test.rb @@ -10,7 +10,7 @@ def setup @invalid_card = credit_card("4444444444444444", month: 05, year: 2018) @amex_card = credit_card("377777777777770 ", month: 05, year: 2018, brand: 'amex', verification_value: '1234') - request_type = 'complete' # 'minimal' || 'complete' + request_type = 'complete' # 'minimal' || 'complete' time = Time.now.to_i ip = '101.102.103.104' @complete_request_options = { @@ -50,29 +50,38 @@ def setup ip: ip, }, } - + @minimal_request_options = { order_id: "Order #{time}", description: 'Store Purchase - Books', } - @complete_request_options['customParameters[SHOPPER_test124TestName009]'] = 'customParameters_test' - @complete_request_options['customParameters[SHOPPER_otherCustomerParameter]'] = 'otherCustomerParameter_test' + @complete_request_options['customParameters[SHOPPER_test124TestName009]'] = 'customParameters_test' + @complete_request_options['customParameters[SHOPPER_otherCustomerParameter]'] = 'otherCustomerParameter_test' @test_success_id = "8a82944a4e008ca9014e1273e0696122" @test_failure_id = "8a8294494e0078a6014e12b371fb6a8e" @test_wrong_reference_id = "8a8444494a0033a6014e12b371fb6a1e" - + @options = @minimal_request_options if request_type == 'minimal' @options = @complete_request_options if request_type == 'complete' end - + # ****************************************** SUCCESSFUL TESTS ****************************************** def test_successful_purchase @options[:description] = __method__ - + response = @gateway.purchase(@amount, @valid_card, @options) assert_success response, "Failed purchase" + assert_match %r{Request successfully processed}, response.message + + assert response.test? + end + + def test_successful_purchase_sans_options + response = @gateway.purchase(@amount, @valid_card) + assert_success response + assert_match %r{Request successfully processed}, response.message assert response.test? end @@ -81,7 +90,9 @@ def test_successful_authorize @options[:description] = __method__ response = @gateway.authorize(@amount, @valid_card, @options) - assert_success response, "Authorization Failed" + assert_success response, "Authorization Failed" + assert_match %r{Request successfully processed}, response.message + assert response.test? end @@ -90,31 +101,37 @@ def test_successful_capture auth = @gateway.authorize(@amount, @valid_card, @options) assert_success auth, "Authorization Failed" assert auth.test? - + capt = @gateway.capture(@amount, auth.authorization, @options) assert_success capt, "Capture failed" + assert_match %r{Request successfully processed}, capt.message + assert capt.test? end def test_successful_refund @options[:description] = __method__ purchase = @gateway.purchase(@amount, @valid_card, @options) - assert_success purchase, "Purchase failed" + assert_success purchase, "Purchase failed" assert purchase.test? refund = @gateway.refund(@amount, purchase.authorization, @options) assert_success refund, "Refund failed" + assert_match %r{Request successfully processed}, refund.message + assert refund.test? end def test_successful_void @options[:description] = __method__ purchase = @gateway.purchase(@amount, @valid_card, @options) - assert_success purchase, "Purchase failed" + assert_success purchase, "Purchase failed" assert purchase.test? void = @gateway.void(purchase.authorization, @options) assert_success void, "Void failed" + assert_match %r{Request successfully processed}, void.message + assert void.test? end @@ -125,6 +142,7 @@ def test_successful_partial_capture assert capture = @gateway.capture(@amount-1, auth.authorization) assert_success capture + assert_match %r{Request successfully processed}, capture.message end def test_successful_partial_refund @@ -134,49 +152,65 @@ def test_successful_partial_refund assert refund = @gateway.refund(@amount-1, purchase.authorization) assert_success refund + assert_match %r{Request successfully processed}, refund.message end def test_successful_verify @options[:description] = __method__ response = @gateway.verify(@valid_card, @options) assert_success response + assert_match %r{Request successfully processed}, response.message end -# ****************************************** FAILURE TESTS ****************************************** +# ****************************************** FAILURE TESTS ****************************************** def test_failed_purchase @options[:description] = __method__ response = @gateway.purchase(@amount, @invalid_card, @options) assert_failure response - assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + assert_match %r{invalid creditcard}, response.message end def test_failed_authorize @options[:description] = __method__ response = @gateway.authorize(@amount, @invalid_card, @options) assert_failure response - assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + assert_match %r{invalid creditcard}, response.message end def test_failed_capture @options[:description] = __method__ response = @gateway.capture(@amount, @test_wrong_reference_id) assert_failure response - assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code + assert_match %r{capture needs at least one successful transaction}, response.message end def test_failed_refund @options[:description] = __method__ response = @gateway.refund(@amount, @test_wrong_reference_id) assert_failure response - assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code + assert_match %r{Invalid payment data}, response.message end def test_failed_void @options[:description] = __method__ response = @gateway.void(@test_wrong_reference_id, @options) assert_failure response - assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code + assert_match %r{reversal needs at least one successful transaction}, response.message end +# ************************************** TRANSCRIPT SCRUB ****************************************** + + def test_transcript_scrubbing + assert @gateway.supports_scrubbing? + + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @valid_card) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@valid_card.number, transcript) + assert_scrubbed(@valid_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end end diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb index 8225e3c7a91..64d2e823b83 100644 --- a/test/unit/gateways/opp_test.rb +++ b/test/unit/gateways/opp_test.rb @@ -8,7 +8,7 @@ def setup @valid_card = credit_card("4200000000000000", month: 05, year: 2018, verification_value: '123') @invalid_card = credit_card("4444444444444444", month: 05, year: 2018, verification_value: '123') - request_type = 'complete' # 'minimal' || 'complete' + request_type = 'complete' # 'minimal' || 'complete' time = Time.now.to_i ip = '101.102.103.104' @complete_request_options = { @@ -49,23 +49,23 @@ def setup ip: ip, }, } - + @minimal_request_options = { order_id: "Order #{time}", description: 'Store Purchase - Books', } - @complete_request_options['customParameters[SHOPPER_test124TestName009]'] = 'customParameters_test' - @complete_request_options['customParameters[SHOPPER_otherCustomerParameter]'] = 'otherCustomerParameter_test' + @complete_request_options['customParameters[SHOPPER_test124TestName009]'] = 'customParameters_test' + @complete_request_options['customParameters[SHOPPER_otherCustomerParameter]'] = 'otherCustomerParameter_test' @test_success_id = "8a82944a4e008ca9014e1273e0696122" @test_failure_id = "8a8294494e0078a6014e12b371fb6a8e" - + @options = @minimal_request_options if request_type == 'minimal' @options = @complete_request_options if request_type == 'complete' end - -# ****************************************** SUCCESSFUL TESTS ****************************************** + +# ****************************************** SUCCESSFUL TESTS ****************************************** def test_successful_purchase @gateway.expects(:raw_ssl_request).returns(successful_response('DB', @test_success_id)) response = @gateway.purchase(@amount, @valid_card, @options) @@ -77,7 +77,7 @@ def test_successful_purchase def test_successful_authorize @gateway.expects(:raw_ssl_request).returns(successful_response('PA', @test_success_id)) response = @gateway.authorize(@amount, @valid_card, @options) - assert_success response, "Authorization Failed" + assert_success response, "Authorization Failed" assert_equal @test_success_id, response.authorization assert response.test? end @@ -98,7 +98,7 @@ def test_successful_capture def test_successful_refund @gateway.expects(:raw_ssl_request).returns(successful_response('DB', @test_success_id)) purchase = @gateway.purchase(@amount, @valid_card, @options) - assert_success purchase, "Purchase failed" + assert_success purchase, "Purchase failed" assert purchase.test? @gateway.expects(:raw_ssl_request).returns(successful_response('RF', @test_success_id)) refund = @gateway.refund(@amount, purchase.authorization, @options) @@ -110,7 +110,7 @@ def test_successful_refund def test_successful_void @gateway.expects(:raw_ssl_request).returns(successful_response('DB', @test_success_id)) purchase = @gateway.purchase(@amount, @valid_card, @options) - assert_success purchase, "Purchase failed" + assert_success purchase, "Purchase failed" assert purchase.test? @gateway.expects(:raw_ssl_request).returns(successful_response('RV', @test_success_id)) void = @gateway.void(purchase.authorization, @options) @@ -119,40 +119,40 @@ def test_successful_void assert void.test? end -# ****************************************** FAILURE TESTS ****************************************** +# ****************************************** FAILURE TESTS ****************************************** def test_failed_purchase @gateway.expects(:raw_ssl_request).returns(failed_response('DB', @test_failure_id)) response = @gateway.purchase(@amount, @invalid_card, @options) assert_failure response - assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + assert_equal '100.100.101', response.error_code end def test_failed_authorize @gateway.expects(:raw_ssl_request).returns(failed_response('PA', @test_failure_id)) response = @gateway.authorize(@amount, @invalid_card, @options) assert_failure response - assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + assert_equal '100.100.101', response.error_code end def test_failed_capture @gateway.expects(:raw_ssl_request).returns(failed_response('CP', @test_failure_id)) response = @gateway.capture(@amount, @invalid_card) assert_failure response - assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + assert_equal '100.100.101', response.error_code end def test_failed_refund @gateway.expects(:raw_ssl_request).returns(failed_response('PF', @test_failure_id)) response = @gateway.refund(@amount, @test_success_id) assert_failure response - assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + assert_equal '100.100.101', response.error_code end def test_failed_void @gateway.expects(:raw_ssl_request).returns(failed_response('RV', @test_failure_id)) response = @gateway.void(@test_success_id, @options) assert_failure response - assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + assert_equal '100.100.101', response.error_code end def test_scrub @@ -167,11 +167,11 @@ def pre_scrubbed end def post_scrubbed - "paymentType=DB&amount=1.00¤cy=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=[FILTERED]&card.expiryMonth=05&card.expiryYear=2018& card.cvv=[FILTERED]&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=[FILTERED]&authentication.password=[FILTERED]&authentication.userId=[FILTERED]" + "paymentType=DB&amount=1.00¤cy=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=[FILTERED]&card.expiryMonth=05&card.expiryYear=2018& card.cvv=[FILTERED]&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=8a8294174b7ecb28014b9699220015ca&authentication.password=[FILTERED]&authentication.userId=8a8294174b7ecb28014b9699220015cc" end def successful_response(type, id) - OppMockResponse.new(200, + OppMockResponse.new(200, JSON.generate({"id" => id,"paymentType" => type,"paymentBrand" => "VISA","amount" => "1.00","currency" => "EUR","des criptor" => "5410.9959.0306 OPP_Channel ","result" => {"code" => "000.100.110","description" => "Request successfully processed in 'Merchant in Integrator Test Mode'"},"card" => {"bin " => "420000","last4Digits" => "0000","holder" => "Longbob Longsen","expiryMonth" => "05","expiryYear" => "2018"},"buildNumber" => "20150618-111601.r185004.opp-tags-20150618_stage","time @@ -180,7 +180,7 @@ def successful_response(type, id) end def failed_response(type, id, code='100.100.101') - OppMockResponse.new(400, + OppMockResponse.new(400, JSON.generate({"id" => id,"paymentType" => type,"paymentBrand" => "VISA","result" => {"code" => code,"des cription" => "invalid creditcard, bank account number or bank name"},"card" => {"bin" => "444444","last4Digits" => "4444","holder" => "Longbob Longsen","expiryMonth" => "05","expiryYear" => "2018"}, "buildNumber" => "20150618-111601.r185004.opp-tags-20150618_stage","timestamp" => "2015-06-20 20:40:26+0000","ndc" => "8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d"}) @@ -192,14 +192,14 @@ def initialize(code, body) @code = code @body = body end - - def code + + def code @code - end - - def body + end + + def body @body - end + end end end From 530d03c1327cc8bb08ad8896e2323a6b69f432ba Mon Sep 17 00:00:00 2001 From: David Perry Date: Wed, 15 Mar 2017 09:44:17 -0400 Subject: [PATCH 061/677] Elavon: Support custom fields Also updates test card number to work with changes on Elavon's end, and cleans up reference comments. Remote: 23 tests, 102 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 28 tests, 138 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2416 --- .../billing/gateways/elavon.rb | 115 ++++-------------- test/remote/gateways/remote_elavon_test.rb | 13 +- test/unit/gateways/elavon_test.rb | 16 ++- 3 files changed, 47 insertions(+), 97 deletions(-) diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb index 655e8b58de6..d1ae68d609a 100644 --- a/lib/active_merchant/billing/gateways/elavon.rb +++ b/lib/active_merchant/billing/gateways/elavon.rb @@ -2,33 +2,6 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: - # = Elavon Virtual Merchant Gateway - # - # == Example use: - # - # gateway = ActiveMerchant::Billing::ElavonGateway.new( - # :login => "my_virtual_merchant_id", - # :password => "my_virtual_merchant_pin", - # :user => "my_virtual_merchant_user_id" # optional - # ) - # - # # set up credit card obj as in main ActiveMerchant example - # creditcard = ActiveMerchant::Billing::CreditCard.new( - # :type => 'visa', - # :number => '41111111111111111', - # :month => 10, - # :year => 2011, - # :first_name => 'Bob', - # :last_name => 'Bobsen' - # ) - # - # # run request - # response = gateway.purchase(1000, creditcard) # authorize and capture 10 USD - # - # puts response.success? # Check whether the transaction was successful - # puts response.message # Retrieve the message returned by Elavon - # puts response.authorization # Retrieve the unique transaction ID returned by Elavon - # class ElavonGateway < Gateway include Empty @@ -55,23 +28,11 @@ class ElavonGateway < Gateway :update => 'CCUPDATETOKEN', } - # Initialize the Gateway - # - # The gateway requires that a valid login and password be passed - # in the +options+ hash. - # - # ==== Options - # - # * :login -- Merchant ID - # * :password -- PIN - # * :user -- Specify a subuser of the account (optional) - # * :test => +true+ or +false+ -- Force test transactions def initialize(options = {}) requires!(options, :login, :password) super end - # Make a purchase def purchase(money, payment_method, options = {}) form = {} add_salestax(form, options) @@ -85,16 +46,9 @@ def purchase(money, payment_method, options = {}) add_customer_data(form, options) add_test_mode(form, options) add_ip(form, options) - commit(:purchase, money, form) + commit(:purchase, money, form, options) end - # Authorize a credit card for a given amount. - # - # ==== Parameters - # * money - The amount to be authorized as an Integer value in cents. - # * credit_card - The CreditCard details for the transaction. - # * options - # * :billing_address - The billing address for the cardholder. def authorize(money, creditcard, options = {}) form = {} add_salestax(form, options) @@ -104,16 +58,9 @@ def authorize(money, creditcard, options = {}) add_customer_data(form, options) add_test_mode(form, options) add_ip(form, options) - commit(:authorize, money, form) + commit(:authorize, money, form, options) end - # Capture authorized funds from a credit card. - # - # ==== Parameters - # * money - The amount to be captured as an Integer value in cents. - # * authorization - The approval code returned from the initial authorization. - # * options - # * :credit_card - The CreditCard details from the initial transaction (required). def capture(money, authorization, options = {}) form = {} if options[:credit_card] @@ -130,45 +77,23 @@ def capture(money, authorization, options = {}) add_partial_shipment_flag(form, options) add_test_mode(form, options) end - commit(action, money, form) - end - - # Refund a transaction. - # - # This transaction indicates to the gateway that - # money should flow from the merchant to the customer. - # - # ==== Parameters - # - # * money -- The amount to be credited to the customer as an Integer value in cents. - # * identification -- The ID of the original transaction against which the refund is being issued. - # * options -- A hash of parameters. + commit(action, money, form, options) + end + def refund(money, identification, options = {}) form = {} add_txn_id(form, identification) add_test_mode(form, options) - commit(:refund, money, form) + commit(:refund, money, form, options) end - # Void a previous transaction - # - # ==== Parameters - # - # * authorization - The authorization returned from the previous request. def void(identification, options = {}) form = {} add_txn_id(form, identification) add_test_mode(form, options) - commit(:void, nil, form) + commit(:void, nil, form, options) end - # Make a credit to a card. Use the refund method if you'd like to credit using - # previous transaction - # - # ==== Parameters - # * money - The amount to be credited as an Integer value in cents. - # * creditcard - The credit card to be credited. - # * options def credit(money, creditcard, options = {}) if creditcard.is_a?(String) raise ArgumentError, "Reference credits are not supported. Please supply the original credit card or use the #refund method." @@ -180,7 +105,7 @@ def credit(money, creditcard, options = {}) add_address(form, options) add_customer_data(form, options) add_test_mode(form, options) - commit(:credit, money, form) + commit(:credit, money, form, options) end def verify(credit_card, options = {}) @@ -198,7 +123,7 @@ def store(creditcard, options = {}) add_test_mode(form, options) add_verification(form, options) form[:add_token] = 'Y' - commit(:store, nil, form) + commit(:store, nil, form, options) end def update(token, creditcard, options = {}) @@ -208,7 +133,7 @@ def update(token, creditcard, options = {}) add_address(form, options) add_customer_data(form, options) add_test_mode(form, options) - commit(:update, nil, form) + commit(:update, nil, form, options) end private @@ -255,6 +180,11 @@ def add_customer_data(form, options) form[:email] = truncate(options[:email], 100) unless empty?(options[:email]) form[:customer_code] = truncate(options[:customer], 10) unless empty?(options[:customer]) form[:customer_number] = options[:customer_number] unless empty?(options[:customer_number]) + if options[:custom_fields] + options[:custom_fields].each do |key, value| + form[key.to_s] = value + end + end end def add_salestax(form, options) @@ -313,11 +243,11 @@ def success?(response) !response.has_key?('errorMessage') end - def commit(action, money, parameters) + def commit(action, money, parameters, options) parameters[:amount] = amount(money) parameters[:transaction_type] = self.actions[action] - response = parse( ssl_post(test? ? self.test_url : self.live_url, post_data(parameters)) ) + response = parse( ssl_post(test? ? self.test_url : self.live_url, post_data(parameters, options)) ) Response.new(response['result'] == '0', message_from(response), response, :test => @options[:test] || test?, @@ -327,21 +257,22 @@ def commit(action, money, parameters) ) end - def post_data(parameters) + def post_data(parameters, options) result = preamble result.merge!(parameters) - result.collect { |key, value| post_data_string(key, value) }.join("&") + result.collect { |key, value| post_data_string(key, value, options) }.join("&") end - def post_data_string(key, value) - if custom_field?(key) + def post_data_string(key, value, options) + if custom_field?(key, options) "#{key}=#{CGI.escape(value.to_s)}" else "ssl_#{key}=#{CGI.escape(value.to_s)}" end end - def custom_field?(field_name) + def custom_field?(field_name, options) + return true if options[:custom_fields] && options[:custom_fields].include?(field_name.to_sym) field_name == :customer_number end diff --git a/test/remote/gateways/remote_elavon_test.rb b/test/remote/gateways/remote_elavon_test.rb index fefb5f3fe1c..00e8f5bd55c 100644 --- a/test/remote/gateways/remote_elavon_test.rb +++ b/test/remote/gateways/remote_elavon_test.rb @@ -4,7 +4,7 @@ class RemoteElavonTest < Test::Unit::TestCase def setup @gateway = ElavonGateway.new(fixtures(:elavon)) - @credit_card = credit_card('4111111111111111') + @credit_card = credit_card('4124939999999990') @bad_credit_card = credit_card('invalid') @options = { @@ -168,7 +168,7 @@ def test_unsuccessful_store def test_successful_update store_response = @gateway.store(@credit_card, @options) token = store_response.params["token"] - credit_card = credit_card('4111111111111111', :month => 10) + credit_card = credit_card('4124939999999990', :month => 10) assert response = @gateway.update(token, credit_card, @options) assert_success response assert response.test? @@ -196,4 +196,13 @@ def test_failed_purchase_with_token assert response.test? assert_match %r{invalid}i, response.message end + + def test_successful_purchase_with_custom_fields + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(custom_fields: {a_key: "a value"})) + + assert_success response + assert response.test? + assert_equal 'APPROVAL', response.message + assert response.authorization + end end diff --git a/test/unit/gateways/elavon_test.rb b/test/unit/gateways/elavon_test.rb index 26f384dbdf7..8d0164aeded 100644 --- a/test/unit/gateways/elavon_test.rb +++ b/test/unit/gateways/elavon_test.rb @@ -252,7 +252,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)) + @gateway.expects(:commit).with(anything, anything, has_entries(:avs_zip => stripped_zip), anything) @gateway.purchase(@amount, @credit_card, @options) end @@ -260,11 +260,21 @@ 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')) + @gateway.expects(:commit).with(anything, anything, has_entries(:avs_zip => 'K1Z5E3'), anything) @gateway.purchase(@amount, @credit_card, @options) 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) + end.respond_with(successful_purchase_response) + end + private def successful_purchase_response "ssl_card_number=42********4242 @@ -383,7 +393,7 @@ def failed_authorization_response errorName=Credit Card Number Invalid errorMessage=The Credit Card Number supplied in the authorization request appears to be invalid." end - + def successful_capture_response "ssl_card_number=42********4242 ssl_exp_date=0910 From 7ed66f71d7a4c796f851695a06e9adf9dfc5e62e Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Mon, 8 May 2017 23:18:26 +0530 Subject: [PATCH 062/677] WePay: Support risk headers Closes #2419 --- lib/active_merchant/billing/gateways/wepay.rb | 15 ++++++++++----- test/remote/gateways/remote_wepay_test.rb | 6 ++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/active_merchant/billing/gateways/wepay.rb b/lib/active_merchant/billing/gateways/wepay.rb index 796555e97d0..bb0fd43e1b9 100644 --- a/lib/active_merchant/billing/gateways/wepay.rb +++ b/lib/active_merchant/billing/gateways/wepay.rb @@ -224,12 +224,17 @@ def unparsable_response(raw_response) end def headers(options) - { - "Content-Type" => "application/json", - "User-Agent" => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}", - "Authorization" => "Bearer #{@options[:access_token]}", - "Api-Version" => api_version(options) + headers = { + "Content-Type" => "application/json", + "User-Agent" => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}", + "Authorization" => "Bearer #{@options[:access_token]}", + "Api-Version" => api_version(options) } + + headers["Client-IP"] = options[:ip] if options[:ip] + headers["WePay-Risk-Token"] = options[:risk_token] if options[:risk_token] + + headers end def api_version(options) diff --git a/test/remote/gateways/remote_wepay_test.rb b/test/remote/gateways/remote_wepay_test.rb index a1c10848eb6..26b87584c66 100644 --- a/test/remote/gateways/remote_wepay_test.rb +++ b/test/remote/gateways/remote_wepay_test.rb @@ -72,6 +72,12 @@ def test_successful_purchase_with_unique_id assert_equal 'Success', response.message end + def test_successful_purchase_with_ip_and_risk_token + response = @gateway.purchase(@amount, @credit_card, @options.merge(ip: "100.166.99.123", risk_token: "123e4567-e89b-12d3-a456-426655440000")) + assert_success response + assert_equal 'Success', response.message + end + def test_successful_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_success response From 27edf4331392cf71194c7c21bbb40c9a7741134f Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Mon, 8 May 2017 23:19:42 +0530 Subject: [PATCH 063/677] WePay: Add Canada to supported countries Closes #2419 --- CHANGELOG | 2 ++ lib/active_merchant/billing/gateways/wepay.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index c9bfa990db9..c90b5546f0f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,8 @@ * iVeri: Add gateway support [curiousepic] #2400 * iVeri: Support 3DSecure data fields [davidsantoso] #2412 * Opp: Fix transaction success criteria and clean up options [shasum] #2414 +* WePay: Support risk headers [shasum] #2419 +* WePay: Add Canada as supported country [shasum] #2419 == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/wepay.rb b/lib/active_merchant/billing/gateways/wepay.rb index bb0fd43e1b9..d16c91d8a22 100644 --- a/lib/active_merchant/billing/gateways/wepay.rb +++ b/lib/active_merchant/billing/gateways/wepay.rb @@ -4,7 +4,7 @@ class WepayGateway < Gateway self.test_url = 'https://stage.wepayapi.com/v2' self.live_url = 'https://wepayapi.com/v2' - self.supported_countries = ['US'] + self.supported_countries = ['US', 'CA'] self.supported_cardtypes = [:visa, :master, :american_express, :discover] self.homepage_url = 'https://www.wepay.com/' self.default_currency = 'USD' From c1a4284d1bb9503cbe1212b7186dc4e8bbeaf1bd Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 8 May 2017 15:10:52 -0400 Subject: [PATCH 064/677] Fix changelog --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index c90b5546f0f..c38997940fe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * iVeri: Add gateway support [curiousepic] #2400 * iVeri: Support 3DSecure data fields [davidsantoso] #2412 * Opp: Fix transaction success criteria and clean up options [shasum] #2414 +* Elavon: Support custom fields [curiousepic] #2416 * WePay: Support risk headers [shasum] #2419 * WePay: Add Canada as supported country [shasum] #2419 From fbbd8c6c78809462c3941eec0b006b6787477cc5 Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 9 May 2017 16:28:22 -0400 Subject: [PATCH 065/677] Fat Zebra: Fix xid 3D Secure field Previously, the cavv field was passed into the request as the xid. Also cleans up reference comments. Unit: 17 tests, 89 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 18 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 2 ++ .../billing/gateways/fat_zebra.rb | 28 +------------------ 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c38997940fe..3de0e142d71 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,8 @@ * Elavon: Support custom fields [curiousepic] #2416 * WePay: Support risk headers [shasum] #2419 * WePay: Add Canada as supported country [shasum] #2419 +* Fat Zebra: Fix xid 3D Secure field [curiousepic] + == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/fat_zebra.rb b/lib/active_merchant/billing/gateways/fat_zebra.rb index a06fe59fe6a..fadbbaa35c0 100644 --- a/lib/active_merchant/billing/gateways/fat_zebra.rb +++ b/lib/active_merchant/billing/gateways/fat_zebra.rb @@ -14,23 +14,11 @@ class FatZebraGateway < Gateway self.homepage_url = 'https://www.fatzebra.com.au/' self.display_name = 'Fat Zebra' - # Setup a new instance of the gateway. - # - # The options hash should include :username and :token - # You can find your username and token at https://dashboard.fatzebra.com.au - # Under the Your Account section def initialize(options = {}) requires!(options, :username, :token) super end - # To create a purchase on a credit card use: - # - # purchase(money, creditcard) - # - # To charge a tokenized card - # - # purchase(money, "abzy87u", :cvv => "123") def purchase(money, creditcard, options = {}) post = {} @@ -65,11 +53,6 @@ def capture(money, authorization, options = {}) commit(:post, "purchases/#{CGI.escape(authorization)}/capture", post) end - # Refund a transaction - # - # amount - Integer - the amount to refund - # txn_id - String - the original transaction to be refunded - # reference - String - your transaction reference def refund(money, txn_id, options={}) post = {} @@ -81,9 +64,6 @@ def refund(money, txn_id, options={}) commit(:post, "refunds", post) end - # Tokenize a credit card - # - # The token is returned in the Response#authorization def store(creditcard, options={}) post = {} add_creditcard(post, creditcard) @@ -104,14 +84,12 @@ def scrub(transcript) private - # Add the money details to the request def add_amount(post, money, options) post[:currency] = (options[:currency] || currency(money)) post[:currency] = post[:currency].upcase if post[:currency] post[:amount] = money end - # Add the credit card details to the request def add_creditcard(post, creditcard, options = {}) if creditcard.respond_to?(:number) post[:card_number] = creditcard.number @@ -134,7 +112,7 @@ def add_extra_options(post, options) extra = {} extra[:ecm] = "32" if options[:recurring] extra[:cavv] = options[:cavv] if options[:cavv] - extra[:xid] = options[:cavv] if options[:xid] + extra[:xid] = options[:xid] if options[:xid] extra[:sli] = options[:sli] if options[:sli] extra[:name] = options[:merchant] if options[:merchant] extra[:location] = options[:merchant_location] if options[:merchant_location] @@ -149,7 +127,6 @@ def add_ip(post, options) post[:customer_ip] = options[:ip] || "127.0.0.1" end - # Post the data to the gateway def commit(method, uri, parameters=nil) response = begin parse(ssl_request(method, get_url(uri), parameters.to_json, headers)) @@ -194,7 +171,6 @@ def message_from(response) end end - # Parse the returned JSON, if parse errors are raised then return a detailed error. def parse(response) begin JSON.parse(response) @@ -209,13 +185,11 @@ def parse(response) end end - # Build the URL based on the AM mode and the URI def get_url(uri) base = test? ? self.test_url : self.live_url base + "/" + uri end - # Builds the auth and U-A headers for the request def headers { "Authorization" => "Basic " + Base64.strict_encode64(@options[:username].to_s + ":" + @options[:token].to_s).strip, From 767ea20fd6687da9825a519a243a4da277b672d0 Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 9 May 2017 17:04:30 -0400 Subject: [PATCH 066/677] SafeCharge: Mark support for European countries Unit: 16 tests, 52 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/safe_charge.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 3de0e142d71..1a7e6f1a4d8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * WePay: Support risk headers [shasum] #2419 * WePay: Add Canada as supported country [shasum] #2419 * Fat Zebra: Fix xid 3D Secure field [curiousepic] +* SafeCharge: Mark support for European countries [curiousepic] == Version 1.65.0 (April 26, 2017) diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index 5bc7409ed9d..9a2eb8565bc 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -6,7 +6,7 @@ class SafeChargeGateway < Gateway self.test_url = 'https://process.sandbox.safecharge.com/service.asmx/Process' self.live_url = 'https://process.safecharge.com/service.asmx/Process' - self.supported_countries = ['US'] + self.supported_countries = ['AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'GR', 'ES', 'FI', 'FR', 'HR', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SE', 'SI', 'SK', 'GB', 'US'] self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master] From c28dddd261d0906af68f11a72a1ff8f1ea0586e7 Mon Sep 17 00:00:00 2001 From: Michael Elfassy Date: Wed, 10 May 2017 13:57:21 -0400 Subject: [PATCH 067/677] cybersource handle nested AuthReply with different reasonCode --- .../billing/gateways/cyber_source.rb | 12 +++- test/unit/gateways/cyber_source_test.rb | 68 +++++++++++++++++++ 2 files changed, 77 insertions(+), 3 deletions(-) diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 92791e56d4f..b6df95d9fee 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -691,7 +691,8 @@ def commit(request, action, amount, options) end success = response[:decision] == "ACCEPT" - message = @@response_codes[('r' + response[:reasonCode]).to_sym] rescue response[:message] + message = response[:message] + authorization = success ? [ options[:order_id], response[:requestID], response[:requestToken], action, amount, options[:currency]].compact.join(";") : nil Response.new(success, message, response, @@ -709,9 +710,9 @@ def parse(xml) xml = REXML::Document.new(xml) if root = REXML::XPath.first(xml, "//c:replyMessage") root.elements.to_a.each do |node| - case node.name + case node.expanded_name when 'c:reasonCode' - reply[:message] = reply(node.text) + reply[:message] = reason_message(node.text) else parse_element(reply, node) end @@ -736,6 +737,11 @@ def parse_element(reply, node) end return reply end + + def reason_message(reason_code) + return if reason_code.blank? + message = @@response_codes[:"r#{reason_code}"] + end end end end diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index dba909fff4c..95a46d4d366 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -175,6 +175,16 @@ def test_unsuccessful_authorization @gateway.expects(:ssl_post).returns(unsuccessful_authorization_response) assert response = @gateway.purchase(@amount, @credit_card, @options) + refute_equal 'Successful transaction', response.message + assert_instance_of Response, response + assert_failure response + end + + def test_unsuccessful_authorization_with_reply + @gateway.expects(:ssl_post).returns(unsuccessful_authorization_response_with_reply) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_equal 'The authorization request was declined by the issuing bank', response.message assert_instance_of Response, response assert_failure response end @@ -499,6 +509,64 @@ def unsuccessful_authorization_response XML end + def unsuccessful_authorization_response_with_reply + <<-XML + + + + + + 2017-05-10T01:15:14.835Z + + + + + TEST11111111111 + 1841784762620176127166 + REJECT + 481 + AMYJY9fl62i+vx2OEQYAx9zv/9UBZAAA5h5D + + USD + + + 100 + 1186.43 + 123456 + N + N + M + M + 2017-05-10T01:15:14Z + 00 + 013445773WW7EWMB0RYI9 + + + 100 + 96 + 1 + 20:15:14 + C^H + MM-IPBST + MUL-EM + VEL-ADDR^VEL-CC^VEL-NAME + us + nvlas vegas + fixed + default + 540510 + US + PURCHASING + MASTERCARD CREDIT + werewrewrew. + + 3 + + + + XML + end + def successful_tax_response <<-XML From 1254114dacb37fac4ee583161771782dc602d621 Mon Sep 17 00:00:00 2001 From: Michael Elfassy Date: Wed, 10 May 2017 14:05:53 -0400 Subject: [PATCH 068/677] Revert "cybersource handle nested AuthReply with different reasonCode" This reverts commit c28dddd261d0906af68f11a72a1ff8f1ea0586e7. --- .../billing/gateways/cyber_source.rb | 12 +--- test/unit/gateways/cyber_source_test.rb | 68 ------------------- 2 files changed, 3 insertions(+), 77 deletions(-) diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index b6df95d9fee..92791e56d4f 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -691,8 +691,7 @@ def commit(request, action, amount, options) end success = response[:decision] == "ACCEPT" - message = response[:message] - + message = @@response_codes[('r' + response[:reasonCode]).to_sym] rescue response[:message] authorization = success ? [ options[:order_id], response[:requestID], response[:requestToken], action, amount, options[:currency]].compact.join(";") : nil Response.new(success, message, response, @@ -710,9 +709,9 @@ def parse(xml) xml = REXML::Document.new(xml) if root = REXML::XPath.first(xml, "//c:replyMessage") root.elements.to_a.each do |node| - case node.expanded_name + case node.name when 'c:reasonCode' - reply[:message] = reason_message(node.text) + reply[:message] = reply(node.text) else parse_element(reply, node) end @@ -737,11 +736,6 @@ def parse_element(reply, node) end return reply end - - def reason_message(reason_code) - return if reason_code.blank? - message = @@response_codes[:"r#{reason_code}"] - end end end end diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index 95a46d4d366..dba909fff4c 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -175,16 +175,6 @@ def test_unsuccessful_authorization @gateway.expects(:ssl_post).returns(unsuccessful_authorization_response) assert response = @gateway.purchase(@amount, @credit_card, @options) - refute_equal 'Successful transaction', response.message - assert_instance_of Response, response - assert_failure response - end - - def test_unsuccessful_authorization_with_reply - @gateway.expects(:ssl_post).returns(unsuccessful_authorization_response_with_reply) - - assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal 'The authorization request was declined by the issuing bank', response.message assert_instance_of Response, response assert_failure response end @@ -509,64 +499,6 @@ def unsuccessful_authorization_response XML end - def unsuccessful_authorization_response_with_reply - <<-XML - - - - - - 2017-05-10T01:15:14.835Z - - - - - TEST11111111111 - 1841784762620176127166 - REJECT - 481 - AMYJY9fl62i+vx2OEQYAx9zv/9UBZAAA5h5D - - USD - - - 100 - 1186.43 - 123456 - N - N - M - M - 2017-05-10T01:15:14Z - 00 - 013445773WW7EWMB0RYI9 - - - 100 - 96 - 1 - 20:15:14 - C^H - MM-IPBST - MUL-EM - VEL-ADDR^VEL-CC^VEL-NAME - us - nvlas vegas - fixed - default - 540510 - US - PURCHASING - MASTERCARD CREDIT - werewrewrew. - - 3 - - - - XML - end - def successful_tax_response <<-XML From 9ac7709a55df277c33c72177bce9a37879bc896d Mon Sep 17 00:00:00 2001 From: Michael Elfassy Date: Wed, 10 May 2017 14:08:47 -0400 Subject: [PATCH 069/677] cybersource handle nested AuthReply with different reasonCode --- .../billing/gateways/cyber_source.rb | 21 ++++-- test/unit/gateways/cyber_source_test.rb | 69 +++++++++++++++++++ 2 files changed, 83 insertions(+), 7 deletions(-) diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 92791e56d4f..9a0d4afa979 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -691,7 +691,8 @@ def commit(request, action, amount, options) end success = response[:decision] == "ACCEPT" - message = @@response_codes[('r' + response[:reasonCode]).to_sym] rescue response[:message] + message = response[:message] + authorization = success ? [ options[:order_id], response[:requestID], response[:requestToken], action, amount, options[:currency]].compact.join(";") : nil Response.new(success, message, response, @@ -709,9 +710,10 @@ def parse(xml) xml = REXML::Document.new(xml) if root = REXML::XPath.first(xml, "//c:replyMessage") root.elements.to_a.each do |node| - case node.name + case node.expanded_name when 'c:reasonCode' - reply[:message] = reply(node.text) + reply[:reasonCode] = node.text + reply[:message] = reason_message(node.text) else parse_element(reply, node) end @@ -728,14 +730,19 @@ def parse_element(reply, node) node.elements.each{|e| parse_element(reply, e) } else if node.parent.name =~ /item/ - parent = node.parent.name + (node.parent.attributes["id"] ? "_" + node.parent.attributes["id"] : '') - reply[(parent + '_' + node.name).to_sym] = node.text - else - reply[node.name.to_sym] = node.text + parent = node.parent.name + parent += '_' + node.parent.attributes["id"] if node.parent.attributes["id"] + parent += '_' end + reply["#{parent}#{node.name}".to_sym] ||= node.text end return reply end + + def reason_message(reason_code) + return if reason_code.blank? + @@response_codes[:"r#{reason_code}"] + end end end end diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index dba909fff4c..b94d51dce62 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -175,6 +175,17 @@ def test_unsuccessful_authorization @gateway.expects(:ssl_post).returns(unsuccessful_authorization_response) assert response = @gateway.purchase(@amount, @credit_card, @options) + refute_equal 'Successful transaction', response.message + assert_instance_of Response, response + assert_failure response + end + + def test_unsuccessful_authorization_with_reply + @gateway.expects(:ssl_post).returns(unsuccessful_authorization_response_with_reply) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + refute_equal 'Successful transaction', response.message + assert_equal '481', response.params['reasonCode'] assert_instance_of Response, response assert_failure response end @@ -499,6 +510,64 @@ def unsuccessful_authorization_response XML end + def unsuccessful_authorization_response_with_reply + <<-XML + + + + + + 2017-05-10T01:15:14.835Z + + + + + TEST11111111111 + 1841784762620176127166 + REJECT + 481 + AMYJY9fl62i+vx2OEQYAx9zv/9UBZAAA5h5D + + USD + + + 100 + 1186.43 + 123456 + N + N + M + M + 2017-05-10T01:15:14Z + 00 + 013445773WW7EWMB0RYI9 + + + 100 + 96 + 1 + 20:15:14 + C^H + MM-IPBST + MUL-EM + VEL-ADDR^VEL-CC^VEL-NAME + us + nvlas vegas + fixed + default + 540510 + US + PURCHASING + MASTERCARD CREDIT + werewrewrew. + + 3 + + + + XML + end + def successful_tax_response <<-XML From 03aeb528c131cc0bdd32a999cf0f675a9e8bc077 Mon Sep 17 00:00:00 2001 From: Michael Elfassy Date: Thu, 11 May 2017 16:55:56 -0400 Subject: [PATCH 070/677] delete RemoteBarclaysEpdqTest --- .../gateways/remote_barclays_epdq_test.rb | 212 ------------------ 1 file changed, 212 deletions(-) delete mode 100644 test/remote/gateways/remote_barclays_epdq_test.rb diff --git a/test/remote/gateways/remote_barclays_epdq_test.rb b/test/remote/gateways/remote_barclays_epdq_test.rb deleted file mode 100644 index 346390280c8..00000000000 --- a/test/remote/gateways/remote_barclays_epdq_test.rb +++ /dev/null @@ -1,212 +0,0 @@ -require 'test_helper' - -class RemoteBarclaysEpdqTest < Test::Unit::TestCase - def setup - @gateway = BarclaysEpdqGateway.new(fixtures(:barclays_epdq).merge(:test => true)) - - @approved_amount = 3900 - @declined_amount = 4205 - @approved_card = credit_card('4715320629000001') - @declined_card = credit_card('4715320629000027') - - @options = { - :order_id => generate_unique_id, - :billing_address => address, - :description => 'Store Purchase' - } - - @periodic_options = @options.merge( - :payment_number => 1, - :total_payments => 3, - :group_id => 'MyTestPaymentGroup' - ) - end - - def test_successful_purchase - assert response = @gateway.purchase(@approved_amount, @approved_card, @options) - assert_success response - assert_equal 'Approved.', response.message - assert_equal @options[:order_id], response.authorization - assert_no_match(/PaymentNoFraud/, response.params["raw_response"]) - end - - def test_successful_purchase_with_mastercard - assert response = @gateway.purchase(@approved_amount, credit_card('5301250070000050', :brand => :master), @options) - assert_success response - end - - def test_successful_purchase_with_maestro - assert response = @gateway.purchase(@approved_amount, credit_card('675938410597000022', :brand => :maestro, :issue_number => '5'), @options) - assert_success response - end - - def test_successful_purchase_with_switch - assert response = @gateway.purchase(@approved_amount, credit_card('6759560045005727054', :brand => :switch, :issue_number => '1'), @options) - assert_success response - end - - def test_successful_purchase_with_minimal_options - delete_address_details! - - assert response = @gateway.purchase(@approved_amount, @approved_card, @options) - assert_success response - assert_equal 'Approved.', response.message - assert_equal @options[:order_id], response.authorization - assert_no_match(/PaymentNoFraud/, response.params["raw_response"]) - end - - def test_successful_purchase_with_no_fraud - @options[:no_fraud] = true - assert response = @gateway.purchase(@approved_amount, @approved_card, @options) - assert_success response - assert_equal 'Approved.', response.message - assert_equal @options[:order_id], response.authorization - assert_match(/PaymentNoFraud/, response.params["raw_response"]) - end - - def test_successful_purchase_with_no_fraud_and_minimal_options - delete_address_details! - - @options[:no_fraud] = true - assert response = @gateway.purchase(@approved_amount, @approved_card, @options) - assert_success response - assert_equal 'Approved.', response.message - assert_equal @options[:order_id], response.authorization - assert_match(/PaymentNoFraud/, response.params["raw_response"]) - end - - def test_successful_purchase_with_no_address_or_order_id_or_description - assert response = @gateway.purchase(@approved_amount, @approved_card, {}) - assert_success response - assert_equal 'Approved.', response.message - end - - def test_unsuccessful_purchase - assert response = @gateway.purchase(@declined_amount, @declined_card, @options) - assert_failure response - assert_match(/^Declined/, response.message) - end - - def test_credit_new_order - assert response = @gateway.credit(@approved_amount, @approved_card, @options) - assert_success response - assert_equal 'Approved.', response.message - end - - def test_refund_existing_order - assert response = @gateway.purchase(@approved_amount, @approved_card, @options) - assert_success response - - assert refund = @gateway.refund(@approved_amount, response.authorization) - assert_success refund - assert_equal 'Approved.', refund.message - end - - def test_refund_nonexisting_order_fails - assert refund = @gateway.refund(@approved_amount, "DOESNOTEXIST", @options) - assert_failure refund - assert_match(/^Payment Mechanism CreditCard information not found/, refund.message) - end - - def test_authorize_and_capture - amount = @approved_amount - assert auth = @gateway.authorize(amount, @approved_card, @options) - assert_success auth - assert_equal 'Approved.', auth.message - assert auth.authorization - assert_equal @options[:order_id], auth.authorization - - assert capture = @gateway.capture(amount, auth.authorization) - assert_success capture - assert_equal 'Approved.', capture.message - end - - def test_authorize_and_capture_without_order_id - @options.delete(:order_id) - amount = @approved_amount - assert auth = @gateway.authorize(amount, @approved_card, @options) - assert_success auth - assert_equal 'Approved.', auth.message - assert auth.authorization - assert_match(/[0-9a-f\-]{36}/, auth.authorization) - - assert capture = @gateway.capture(amount, auth.authorization) - assert_success capture - assert_equal 'Approved.', capture.message - end - - def test_authorize_void_and_failed_capture - amount = @approved_amount - assert auth = @gateway.authorize(amount, @approved_card, @options) - assert_success auth - - assert void = @gateway.void(auth.authorization) - assert_success void - assert_equal 'Approved.', void.message - - assert capture = @gateway.capture(amount, auth.authorization) - assert_failure capture - assert_match(/^Did not find a unique, qualifying transaction for Order/, capture.message) - end - - def test_failed_authorize - assert auth = @gateway.authorize(@declined_amount, @approved_card, @options) - assert_failure auth - assert_match(/^Declined/, auth.message) - end - - def test_failed_capture - amount = @approved_amount - assert auth = @gateway.authorize(amount, @approved_card, @options) - assert_success auth - - @too_much = amount * 10 - assert capture = @gateway.capture(@too_much, auth.authorization) - assert_success capture - assert_match(/^The PostAuth is not valid because the amount/, capture.message) - end - - def test_three_successful_periodic_orders - amount = @approved_amount - assert auth1 = @gateway.purchase(amount, @approved_card, @periodic_options) - assert auth1.success? - assert_equal 'Approved.', auth1.message - - @periodic_options[:payment_number] = 2 - @periodic_options[:order_id] = generate_unique_id - assert auth2 = @gateway.purchase(amount, @approved_card, @periodic_options) - assert auth2.success? - assert_equal 'Approved.', auth2.message - - @periodic_options[:payment_number] = 3 - @periodic_options[:order_id] = generate_unique_id - assert auth3 = @gateway.purchase(amount, @approved_card, @periodic_options) - assert auth3.success? - assert_equal 'Approved.', auth3.message - end - - def test_invalid_login - gateway = BarclaysEpdqGateway.new( - :login => 'NOBODY', - :password => 'HOME', - :client_id => '1234' - ) - assert response = gateway.purchase(@approved_amount, @approved_card, @options) - assert_failure response - assert_equal 'Insufficient permissions to perform requested operation.', response.message - end - - protected - def delete_address_details! - @options[:billing_address].delete :city - @options[:billing_address].delete :state - @options[:billing_address].delete :country - @options[:billing_address].delete :address1 - @options[:billing_address].delete :phone - @options[:billing_address].delete :address1 - @options[:billing_address].delete :address2 - @options[:billing_address].delete :name - @options[:billing_address].delete :fax - @options[:billing_address].delete :company - end -end From bad83ed0b0e9bece19fe96af576bb18015406a68 Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Fri, 12 May 2017 09:34:51 -0400 Subject: [PATCH 071/677] Rename invalid province in remote beanstream test --- test/remote/gateways/remote_beanstream_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb index 6db19868979..b2dba6dd0d0 100644 --- a/test/remote/gateways/remote_beanstream_test.rb +++ b/test/remote/gateways/remote_beanstream_test.rb @@ -110,7 +110,7 @@ def test_successful_purchase_with_state_in_iso_format end def test_failed_purchase_due_to_invalid_billing_state - @options[:billing_address][:state] = "Quebecistan" + @options[:billing_address][:state] = "Invalid" assert response = @gateway.purchase(@amount, @visa, @options) assert_failure response assert_match %r{province does not match country}, response.message From 88da65269810fe9c82e16ab1f8c50303a4d9ac36 Mon Sep 17 00:00:00 2001 From: David Perry Date: Fri, 12 May 2017 13:42:46 -0400 Subject: [PATCH 072/677] Checkout V2: Pass customer ip option Unit: 14 tests, 60 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 18 tests, 39 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/checkout_v2.rb | 1 + test/remote/gateways/remote_checkout_v2_test.rb | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 1a7e6f1a4d8..8df56159332 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * WePay: Add Canada as supported country [shasum] #2419 * Fat Zebra: Fix xid 3D Secure field [curiousepic] * SafeCharge: Mark support for European countries [curiousepic] +* Checkout V2: Pass customer ip option [curiousepic] == Version 1.65.0 (April 26, 2017) diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb index e6739abec48..a4fa1fa8798 100644 --- a/lib/active_merchant/billing/gateways/checkout_v2.rb +++ b/lib/active_merchant/billing/gateways/checkout_v2.rb @@ -94,6 +94,7 @@ def add_payment_method(post, payment_method) def add_customer_data(post, options) post[:email] = options[:email] || "unspecified@example.com" + post[:customerIp] = options[:ip] if options[:ip] address = options[:billing_address] if(address && post[:card]) post[:card][:billingDetails] = {} diff --git a/test/remote/gateways/remote_checkout_v2_test.rb b/test/remote/gateways/remote_checkout_v2_test.rb index e196c849134..d7f58773a2f 100644 --- a/test/remote/gateways/remote_checkout_v2_test.rb +++ b/test/remote/gateways/remote_checkout_v2_test.rb @@ -52,6 +52,12 @@ def test_successful_purchase_without_phone_number assert_equal 'Succeeded', response.message end + def test_successful_purchase_with_ip + response = @gateway.purchase(@amount, @credit_card, ip: "96.125.185.52") + assert_success response + assert_equal 'Succeeded', response.message + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response From 835e557b5faea1bd22ae489dc2e00f316e64e965 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Thu, 11 May 2017 09:37:33 -0400 Subject: [PATCH 073/677] Realex: Map AVS and CVV response codes Closes #2424 --- CHANGELOG | 2 +- .../billing/gateways/realex.rb | 7 ++--- test/remote/gateways/remote_realex_test.rb | 26 +++++++++++++++---- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8df56159332..37447501ff2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,7 +17,7 @@ * Fat Zebra: Fix xid 3D Secure field [curiousepic] * SafeCharge: Mark support for European countries [curiousepic] * Checkout V2: Pass customer ip option [curiousepic] - +* Realex: Map AVS and CVV response codes [davidsantoso] #2424 == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index 7411f87e087..65767cf8e27 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -103,11 +103,8 @@ def commit(request) response, :test => (response[:message] =~ %r{\[ test system \]}), :authorization => authorization_from(response), - :cvv_result => response[:cvnresult], - :avs_result => { - :street_match => response[:avspostcoderesponse], - :postal_match => response[:avspostcoderesponse] - } + avs_result: AVSResult.new(code: response[:avspostcoderesponse]), + cvv_result: CVVResult.new(response[:cvnresult]) ) end diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb index 2cd9c6ff568..33c863f334f 100644 --- a/test/remote/gateways/remote_realex_test.rb +++ b/test/remote/gateways/remote_realex_test.rb @@ -57,7 +57,7 @@ def test_realex_purchase_with_invalid_login assert_not_nil response assert_failure response - assert_equal '506', response.params['result'] + assert_equal '504', response.params['result'] assert_match %r{no such}i, response.message end @@ -75,7 +75,6 @@ def test_realex_purchase_with_invalid_account end def test_realex_purchase_declined - [ @visa_declined, @mastercard_declined ].each do |card| response = @gateway.purchase(@amount, card, @@ -122,7 +121,6 @@ def test_realex_purchase_referral_a end def test_realex_purchase_coms_error - [ @visa_coms_error, @mastercard_coms_error ].each do |card| response = @gateway.purchase(@amount, card, @@ -178,8 +176,8 @@ def test_invalid_credit_card_name assert_not_nil response assert_failure response - assert_equal '502', response.params['result'] - assert_match(/missing/i, response.message) + assert_equal '506', response.params['result'] + assert_match(/does not conform/i, response.message) end def test_cvn @@ -289,6 +287,24 @@ def test_realex_purchase_then_refund assert_equal 'Successful', rebate_response.message end + def test_maps_avs_and_cvv_response_codes + [ @visa, @mastercard ].each do |card| + + response = @gateway.purchase(@amount, card, + :order_id => generate_unique_id, + :description => 'Test Realex Purchase', + :billing_address => { + :zip => '90210', + :country => 'US' + } + ) + assert_not_nil response + assert_success response + assert_equal "M", response.avs_result["code"] + assert_equal "M", response.cvv_result["code"] + end + end + def test_transcript_scrubbing transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @visa_declined, From 653b1d1cc5e89442cda502cf258e0c28be8f0ad4 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Wed, 17 May 2017 10:16:10 -0400 Subject: [PATCH 074/677] Opp: Send disable3DSecure custom parameter if present Closes #2432 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/opp.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 37447501ff2..77a15b872f1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * SafeCharge: Mark support for European countries [curiousepic] * Checkout V2: Pass customer ip option [curiousepic] * Realex: Map AVS and CVV response codes [davidsantoso] #2424 +* Opp: Send disable3DSecure custom parameter if present [davidsantoso] #2432 == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb index 911d74cb5aa..b8c1fea78de 100644 --- a/lib/active_merchant/billing/gateways/opp.rb +++ b/lib/active_merchant/billing/gateways/opp.rb @@ -264,6 +264,7 @@ def add_options(post, options) post[:testMode] = options[:test_mode] if test? && options[:test_mode] options.each {|key, value| post[key] = value if key.to_s.match('customParameters\[[a-zA-Z0-9\._]{3,64}\]') } post['customParameters[SHOPPER_pluginId]'] = 'activemerchant' + post['customParameters[disable3DSecure]'] = options[:disable_3d_secure] if options[:disable_3d_secure] end def build_url(url, authorization, options) From 806f0a9449369f751f237ed750f931e9eb265b8c Mon Sep 17 00:00:00 2001 From: David Santoso Date: Wed, 17 May 2017 15:34:23 -0400 Subject: [PATCH 075/677] SafeCharge: Map standard Active Merchant order_id field Closes #2434 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/safe_charge.rb | 1 + test/remote/gateways/remote_safe_charge_test.rb | 1 + 3 files changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 77a15b872f1..c1c7edd7086 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * Checkout V2: Pass customer ip option [curiousepic] * Realex: Map AVS and CVV response codes [davidsantoso] #2424 * Opp: Send disable3DSecure custom parameter if present [davidsantoso] #2432 +* SafeCharge: Map standard Active Merchant order_id field [davidsantoso] #2434 == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index 9a2eb8565bc..02883e7adda 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -114,6 +114,7 @@ def add_transaction_data(trans_type, post, money, options) post[:sg_ClientPassword] = @options[:client_password] post[:sg_ResponseFormat] = "4" post[:sg_Version] = VERSION + post[:sg_ClientUniqueID] = options[:order_id] if options[:order_id] end def add_payment(post, payment) diff --git a/test/remote/gateways/remote_safe_charge_test.rb b/test/remote/gateways/remote_safe_charge_test.rb index 2823ce83f8d..844f2cf1ef3 100644 --- a/test/remote/gateways/remote_safe_charge_test.rb +++ b/test/remote/gateways/remote_safe_charge_test.rb @@ -8,6 +8,7 @@ def setup @credit_card = credit_card('4000100011112224') @declined_card = credit_card('4000300011112220') @options = { + order_id: generate_unique_id, billing_address: address, description: 'Store Purchase' } From 67665313b92cc9a3bfb30724e5e7c8d9178c89b6 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Tue, 16 May 2017 20:14:59 +0530 Subject: [PATCH 076/677] NMI: Add Network Tokenization support Closes #2431 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/nmi.rb | 11 +++++- test/remote/gateways/remote_nmi_test.rb | 37 +++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index c1c7edd7086..f43ad828287 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* NMI: Add Network Tokenization support [shasum] #2431 == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb index b2e0f38862c..d923cbd6ab5 100644 --- a/lib/active_merchant/billing/gateways/nmi.rb +++ b/lib/active_merchant/billing/gateways/nmi.rb @@ -116,7 +116,12 @@ def scrub(transcript) gsub(%r((ccnumber=)\d+), '\1[FILTERED]'). gsub(%r((cvv=)\d+), '\1[FILTERED]'). gsub(%r((checkaba=)\d+), '\1[FILTERED]'). - gsub(%r((checkaccount=)\d+), '\1[FILTERED]') + gsub(%r((checkaccount=)\d+), '\1[FILTERED]'). + gsub(%r((cryptogram=)[^&]+(&?)), '\1[FILTERED]\2') + end + + def supports_network_tokenization? + true end private @@ -135,6 +140,10 @@ def add_invoice(post, money, options) def add_payment_method(post, payment_method, options) if(payment_method.is_a?(String)) post[:customer_vault_id] = payment_method + elsif (payment_method.is_a?(NetworkTokenizationCreditCard)) + post[:ccnumber] = payment_method.number + post[:ccexp] = exp_date(payment_method) + post[:token_cryptogram] = payment_method.payment_cryptogram elsif(card_brand(payment_method) == 'check') post[:payment] = 'check' post[:checkname] = payment_method.name diff --git a/test/remote/gateways/remote_nmi_test.rb b/test/remote/gateways/remote_nmi_test.rb index 241b0f819b5..acf13461d44 100644 --- a/test/remote/gateways/remote_nmi_test.rb +++ b/test/remote/gateways/remote_nmi_test.rb @@ -9,6 +9,14 @@ def setup :routing_number => '123123123', :account_number => '123123123' ) + @apple_pay_card = network_tokenization_credit_card('4111111111111111', + :payment_cryptogram => "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + :month => "01", + :year => "2024", + :source => :apple_pay, + :eci => "5", + :transaction_id => "123456789" + ) @options = { :order_id => generate_unique_id, :billing_address => address, @@ -62,6 +70,22 @@ def test_failed_purchase_with_echeck assert_equal 'FAILED', response.message end + def test_successful_purchase_with_apple_pay_card + assert @gateway.supports_network_tokenization? + assert response = @gateway.purchase(@amount, @apple_pay_card, @options) + assert_success response + assert response.test? + assert_equal 'Succeeded', response.message + assert response.authorization + end + + def test_failed_purchase_with_apple_pay_card + assert response = @gateway.purchase(99, @apple_pay_card, @options) + assert_failure response + assert response.test? + assert_equal 'DECLINE', response.message + end + def test_successful_authorization assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response @@ -243,4 +267,17 @@ def test_check_transcript_scrubbing # "password=password is filtered, but can't be tested b/c of key match" # assert_scrubbed(@gateway.options[:password], clean_transcript) end + + def test_network_tokenization_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @apple_pay_card, @options) + end + clean_transcript = @gateway.scrub(transcript) + + assert_scrubbed(@apple_pay_card.number, clean_transcript) + assert_scrubbed(@apple_pay_card.payment_cryptogram, clean_transcript) + + # "password=password is filtered, but can't be tested b/c of key match" + # assert_scrubbed(@gateway.options[:password], clean_transcript) + end end From 50a2d34d3ab4161936437d6c90358e8f8cb80d5f Mon Sep 17 00:00:00 2001 From: David Santoso Date: Tue, 23 May 2017 11:10:14 -0400 Subject: [PATCH 077/677] Payeezy: Default check number to 001 if not present Payeezy requires a check number when paying via echeck. This defaults the check number to 001, providing the ability to also pay with a bank account which uses the same fields, but does not have a "check number" attribute. Closes #2439 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/payeezy.rb | 2 +- test/unit/gateways/payeezy_test.rb | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index f43ad828287..87d1aac145f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,7 @@ * Realex: Map AVS and CVV response codes [davidsantoso] #2424 * Opp: Send disable3DSecure custom parameter if present [davidsantoso] #2432 * SafeCharge: Map standard Active Merchant order_id field [davidsantoso] #2434 +* Payeezy: Default check number to 001 if not present [davidsantoso] #2439 == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index 22b886d44b1..3cafb5727f5 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -143,7 +143,7 @@ def add_creditcard(params, creditcard) def add_echeck(params, echeck) tele_check = {} - tele_check[:check_number] = echeck.number + tele_check[:check_number] = echeck.number || "001" tele_check[:check_type] = "P" tele_check[:routing_number] = echeck.routing_number tele_check[:account_number] = echeck.account_number diff --git a/test/unit/gateways/payeezy_test.rb b/test/unit/gateways/payeezy_test.rb index 131f3b4d33d..acf27ab22e2 100644 --- a/test/unit/gateways/payeezy_test.rb +++ b/test/unit/gateways/payeezy_test.rb @@ -68,6 +68,21 @@ def test_successful_purchase_with_echeck assert_equal 'Transaction Normal - Approved', response.message end + def test_successful_purchase_defaulting_check_number + check_without_number = check(number: nil) + + response = stub_comms do + @gateway.purchase(@amount, check_without_number, @options) + end.check_request do |endpoint, data, headers| + assert_match(/001/, data) + end.respond_with(successful_purchase_echeck_response) + + assert_success response + assert_equal 'ET133078|69864362|tele_check|100', response.authorization + assert response.test? + assert_equal 'Transaction Normal - Approved', response.message + end + def test_failed_purchase @gateway.expects(:ssl_post).raises(failed_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) From 62fa6d7d30f00f1cc3faccadbd961a546b650c81 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Tue, 23 May 2017 13:50:40 -0400 Subject: [PATCH 078/677] Opp: Fix incorrect customParameter key to disable 3DS Unfortunately there was a bit of miscommunication with Opp support on the exact customParameter key to disable 3DS. Correct field includes a `custom_` prefix in this particular case. --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/opp.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 87d1aac145f..a85e8ad4ad3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,6 +22,7 @@ * Opp: Send disable3DSecure custom parameter if present [davidsantoso] #2432 * SafeCharge: Map standard Active Merchant order_id field [davidsantoso] #2434 * Payeezy: Default check number to 001 if not present [davidsantoso] #2439 +* Opp: Fix incorrect customParameter key to disable 3DS [davidsantoso] == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb index b8c1fea78de..865bd43559b 100644 --- a/lib/active_merchant/billing/gateways/opp.rb +++ b/lib/active_merchant/billing/gateways/opp.rb @@ -264,7 +264,7 @@ def add_options(post, options) post[:testMode] = options[:test_mode] if test? && options[:test_mode] options.each {|key, value| post[key] = value if key.to_s.match('customParameters\[[a-zA-Z0-9\._]{3,64}\]') } post['customParameters[SHOPPER_pluginId]'] = 'activemerchant' - post['customParameters[disable3DSecure]'] = options[:disable_3d_secure] if options[:disable_3d_secure] + post['customParameters[custom_disable3DSecure]'] = options[:disable_3d_secure] if options[:disable_3d_secure] end def build_url(url, authorization, options) From f3ba4781205d358052c8eaf170a875af094066d2 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Fri, 26 May 2017 04:23:43 +0530 Subject: [PATCH 079/677] JetPay V2: Add new gateway New adapter that talks to JetPay XML 2.2 interface. Closes #2442 --- CHANGELOG | 1 + .../billing/gateways/jetpay_v2.rb | 406 ++++++++++++++++++ test/fixtures.yml | 3 + test/remote/gateways/remote_jetpay_v2_test.rb | 196 +++++++++ test/unit/gateways/jetpay_v2_test.rb | 308 +++++++++++++ 5 files changed, 914 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/jetpay_v2.rb create mode 100644 test/remote/gateways/remote_jetpay_v2_test.rb create mode 100644 test/unit/gateways/jetpay_v2_test.rb diff --git a/CHANGELOG b/CHANGELOG index a85e8ad4ad3..e660e52ee29 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * NMI: Add Network Tokenization support [shasum] #2431 +* JetPay V2: Add new gateway [shasum] #2442 == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 diff --git a/lib/active_merchant/billing/gateways/jetpay_v2.rb b/lib/active_merchant/billing/gateways/jetpay_v2.rb new file mode 100644 index 00000000000..691d2765d1d --- /dev/null +++ b/lib/active_merchant/billing/gateways/jetpay_v2.rb @@ -0,0 +1,406 @@ +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class JetpayV2Gateway < Gateway + self.test_url = 'https://test1.jetpay.com/jetpay' + self.live_url = 'https://gateway20.jetpay.com/jetpay' + + self.money_format = :cents + self.default_currency = 'USD' + self.supported_countries = ['US', 'CA'] + self.supported_cardtypes = [:visa, :master, :american_express, :discover] + + self.homepage_url = 'http://www.jetpay.com' + self.display_name = 'JetPay' + + API_VERSION = '2.2' + + ACTION_CODE_MESSAGES = { + "000" => "Approved.", + "001" => "Refer to card issuer.", + "002" => "Refer to card issuer, special condition.", + "003" => "Invalid merchant or service provider.", + "004" => "Pick up card.", + "005" => "Do not honor.", + "006" => "Error.", + "007" => "Pick up card, special condition.", + "008" => "Honor with ID (Show ID).", + "010" => "Partial approval.", + "011" => "VIP approval.", + "012" => "Invalid transaction.", + "013" => "Invalid amount or exceeds maximum for card program.", + "014" => "Invalid account number (no such number).", + "015" => "No such issuer.", + "019" => "Re-enter Transaction.", + "021" => "No action taken (unable to back out prior transaction).", + "025" => "Transaction Not Found.", + "027" => "File update field edit error.", + "028" => "File is temporarily unavailable.", + "030" => "Format error.", + "039" => "No credit account.", + "041" => "Pick up card (lost card).", + "043" => "Pick up card (stolen card).", + "051" => "Insufficient funds.", + "052" => "No checking account.", + "053" => "Mp savomgs accpimt.", + "054" => "Expired Card.", + "055" => "Incorrect PIN.", + "057" => "Transaction not permitted to cardholder.", + "058" => "Transaction not allowed at terminal.", + "061" => "Exceeds withdrawal limit.", + "062" => "Restricted card (eg, Country Exclusion).", + "063" => "Security violation.", + "065" => "Activity count limit exceeded.", + "068" => "Response late.", + "070" => "Contact card issuer.", + "071" => "PIN not changed.", + "075" => "Allowable number of PIN-entry tries exceeded.", + "076" => "Unable to locate previous message (no matching retrieval reference number).", + "077" => "Repeat or reversal data are inconsistent with original message.", + "078" => "Blocked (first use), or non-existent account.", + "079" => "Key exchange validation failed.", + "080" => "Credit issuer unavailable or invalid date.", + "081" => "PIN cryptographic error found.", + "082" => "Negative online CVV results.", + "084" => "Invalid auth life cycle.", + "085" => "No reason to decline - CVV or AVS approved.", + "086" => "Cannot verify PIN.", + "087" => "Cashback not allowed.", + "089" => "Issuer Down.", + "091" => "Issuer Down.", + "092" => "Unable to route transaction.", + "093" => "Transaction cannot be completed - violation of law.", + "094" => "Duplicate transmission.", + "096" => "System error.", + "100" => "Deny.", + "101" => "Expired Card.", + "103" => "Deny - Invalid manual Entry 4DBC.", + "104" => "Deny - New card issued.", + "105" => "Deny - Account Cancelled.", + "106" => "Exceeded PIN Attempts.", + "107" => "Please Call Issuer.", + "109" => "Invalid merchant.", + "110" => "Invalid amount.", + "111" => "Invalid account.", + "115" => "Service not permitted.", + "117" => "Invalid PIN.", + "119" => "Card member not enrolled.", + "122" => "Invalid card (CID) security code.", + "125" => "Invalid effective date.", + "181" => "Format error.", + "182" => "Please wait.", + "183" => "Invalid currency code.", + "187" => "Deny - new card issued.", + "188" => "Deny - Expiration date required.", + "189" => "Deny - Cancelled or Closed Merchant/SE.", + "200" => "Deny - Pick up card.", + "400" => "Reversal accepted.", + "601" => "Reject - EMV Chip Declined Transaction.", + "602" => "Reject - Suspected Fraud.", + "603" => "Reject - Communications Error.", + "604" => "Reject - Insufficient Approval.", + "750" => "Velocity Check Fail.", + "899" => "Misc Decline.", + "900" => "Invalid Message Type.", + "901" => "Invalid Merchant ID.", + "903" => "Debit not supported.", + "904" => "Private label not supported.", + "905" => "Invalid card type.", + "906" => "Unit not active.", + "908" => "Manual card entry invalid.", + "909" => "Invalid track information.", + "911" => "Master merchant not found.", + "912" => "Invalid card format.", + "913" => "Invalid card type.", + "914" => "Invalid card length.", + "917" => "Expired card.", + "919" => "Invalid entry type.", + "920" => "Invalid amount.", + "921" => "Invalid messge format.", + "923" => "Invalid ABA.", + "924" => "Invalid DDA.", + "925" => "Invalid TID.", + "926" => "Invalid Password.", + "930" => "Invalid zipcode.", + "931" => "Invalid Address.", + "932" => "Invalid ZIP and Address.", + "933" => "Invalid CVV2.", + "934" => "Program Not Allowed.", + "935" => "Invalid Device/App.", + "940" => "Record Not Found.", + "941" => "Merchant ID error.", + "942" => "Refund Not Allowed.", + "943" => "Refund denied.", + "955" => "Invalid PIN block.", + "956" => "Invalid KSN.", + "958" => "Bad Status.", + "959" => "Seek Record limit exceeded.", + "960" => "Internal Key Database Error.", + "961" => "TRANS not Supported. Cash Disbursement required a specific MCC.", + "962" => "Invalid PIN key (Unknown KSN).", + "981" => "Invalid AVS.", + "987" => "Issuer Unavailable.", + "988" => "System error SD.", + "989" => "Database Error.", + "992" => "Transaction Timeout.", + "996" => "Bad Terminal ID.", + "997" => "Message rejected by association.", + "999" => "Communication failure", + nil => "No response returned (missing credentials?)." + } + + def initialize(options = {}) + requires!(options, :login) + super + end + + def purchase(money, credit_card, options = {}) + commit(money, build_sale_request(money, credit_card, options)) + end + + def authorize(money, credit_card, options = {}) + commit(money, build_authonly_request(money, credit_card, options)) + end + + def capture(money, reference, options = {}) + split_authorization = reference.split(";") + transaction_id = split_authorization[0] + token = split_authorization[3] + commit(money, build_capture_request(transaction_id, money, options), token) + end + + def void(reference, options = {}) + transaction_id, approval, amount, token = reference.split(";") + commit(amount.to_i, build_void_request(amount.to_i, transaction_id, approval, token, options), token) + end + + def credit(money, credit_card, options = {}) + commit(money, build_credit_request(money, nil, credit_card, nil, options)) + end + + def refund(money, reference, options = {}) + split_authorization = reference.split(";") + transaction_id = split_authorization[0] + token = split_authorization[3] + commit(money, build_credit_request(money, transaction_id, nil, token, options)) + end + + def verify(credit_card, options={}) + authorize(0, credit_card, options) + end + + def supports_scrubbing + true + end + + def scrub(transcript) + transcript. + gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). + gsub(%r((>)\d+()), '\1[FILTERED]\2'). + gsub(%r(()\d+()), '\1[FILTERED]\2') + end + + private + + def build_xml_request(transaction_type, options = {}, transaction_id = nil, &block) + xml = Builder::XmlMarkup.new + xml.tag! 'JetPay', 'Version' => API_VERSION do + # Basic values needed for any request + xml.tag! 'TerminalID', @options[:login] + xml.tag! 'TransactionType', transaction_type + xml.tag! 'TransactionID', transaction_id.nil? ? generate_unique_id.slice(0, 18) : transaction_id + xml.tag! 'Origin', options[:origin] || 'INTERNET' + xml.tag! 'IndustryInfo', 'Type' => options[:industry_info] || 'ECOMMERCE' + xml.tag! 'Application', (options[:application] || 'n/a'), {'Version' => options[:application_version] || '1.0'} + xml.tag! 'Device', (options[:device] || 'n/a'), {'Version' => options[:device_version] || '1.0'} + xml.tag! 'Library', 'VirtPOS SDK', 'Version' => '1.5' + xml.tag! 'Gateway', 'JetPay' + xml.tag! 'DeveloperID', options[:developer_id] || 'n/a' + + if block_given? + yield xml + else + xml.target! + end + end + end + + def build_sale_request(money, credit_card, options) + build_xml_request('SALE', options) do |xml| + add_credit_card(xml, credit_card) + add_addresses(xml, options) + add_customer_data(xml, options) + add_invoice_data(xml, options) + add_user_defined_fields(xml, options) + xml.tag! 'TotalAmount', amount(money) + + xml.target! + end + end + + def build_authonly_request(money, credit_card, options) + build_xml_request('AUTHONLY', options) do |xml| + add_credit_card(xml, credit_card) + add_addresses(xml, options) + add_customer_data(xml, options) + add_invoice_data(xml, options) + add_user_defined_fields(xml, options) + xml.tag! 'TotalAmount', amount(money) + + xml.target! + end + end + + def build_capture_request(transaction_id, money, options) + build_xml_request('CAPT', options, transaction_id) do |xml| + xml.tag! 'TotalAmount', amount(money) + add_user_defined_fields(xml, options) + end + end + + def build_void_request(money, transaction_id, approval, token, options) + build_xml_request('VOID', options, transaction_id) do |xml| + xml.tag! 'Approval', approval + xml.tag! 'TotalAmount', amount(money) + xml.tag! 'Token', token if token + xml.target! + end + end + + def build_credit_request(money, transaction_id, card, token, options) + build_xml_request('CREDIT', options, transaction_id) do |xml| + add_credit_card(xml, card) if card + add_invoice_data(xml, options) + add_addresses(xml, options) + add_customer_data(xml, options) + add_user_defined_fields(xml, options) + xml.tag! 'TotalAmount', amount(money) + xml.tag! 'Token', token if token + + xml.target! + end + end + + def commit(money, request, token = nil) + response = parse(ssl_post(url, request)) + + success = success?(response) + Response.new(success, + success ? 'APPROVED' : message_from(response), + response, + :test => test?, + :authorization => authorization_from(response, money, token), + :avs_result => AVSResult.new(:code => response[:avs]), + :cvv_result => CVVResult.new(response[:cvv2]), + :error_code => success ? nil : error_code_from(response) + ) + end + + def url + test? ? test_url : live_url + end + + def parse(body) + return {} if body.blank? + + xml = REXML::Document.new(body) + + response = {} + xml.root.elements.to_a.each do |node| + parse_element(response, node) + end + response + end + + def parse_element(response, node) + if node.has_elements? + node.elements.each{|element| parse_element(response, element) } + else + response[node.name.underscore.to_sym] = node.text + end + end + + def format_exp(value) + format(value, :two_digits) + end + + def success?(response) + response[:action_code] == "000" + end + + def message_from(response) + ACTION_CODE_MESSAGES[response[:action_code]] + end + + def authorization_from(response, money, previous_token) + original_amount = amount(money) if money + [ response[:transaction_id], response[:approval], original_amount, (response[:token] || previous_token)].join(";") + end + + def error_code_from(response) + response[:action_code] + end + + def add_credit_card(xml, credit_card) + xml.tag! 'CardNum', credit_card.number, "CardPresent" => false, "Tokenize" => true + xml.tag! 'CardExpMonth', format_exp(credit_card.month) + xml.tag! 'CardExpYear', format_exp(credit_card.year) + + if credit_card.first_name || credit_card.last_name + xml.tag! 'CardName', [credit_card.first_name,credit_card.last_name].compact.join(' ') + end + + unless credit_card.verification_value.nil? || (credit_card.verification_value.length == 0) + xml.tag! 'CVV2', credit_card.verification_value + end + end + + def add_addresses(xml, options) + if billing_address = options[:billing_address] || options[:address] + xml.tag! 'Billing' do + xml.tag! 'Address', [billing_address[:address1], billing_address[:address2]].compact.join(" ") + xml.tag! 'City', billing_address[:city] + xml.tag! 'StateProv', billing_address[:state] + xml.tag! 'PostalCode', billing_address[:zip] + xml.tag! 'Country', lookup_country_code(billing_address[:country]) + xml.tag! 'Phone', billing_address[:phone] + xml.tag! 'Email', options[:email] if options[:email] + end + end + + if shipping_address = options[:shipping_address] + xml.tag! 'Shipping' do + xml.tag! 'Name', shipping_address[:name] + xml.tag! 'Address', [shipping_address[:address1], shipping_address[:address2]].compact.join(" ") + xml.tag! 'City', shipping_address[:city] + xml.tag! 'StateProv', shipping_address[:state] + xml.tag! 'PostalCode', shipping_address[:zip] + xml.tag! 'Country', lookup_country_code(shipping_address[:country]) + xml.tag! 'Phone', shipping_address[:phone] + end + end + end + + def add_customer_data(xml, options) + xml.tag! 'UserIPAddress', options[:ip] if options[:ip] + end + + def add_invoice_data(xml, options) + xml.tag! 'OrderNumber', options[:order_id] if options[:order_id] + if tax = options[:tax] + xml.tag! 'TaxAmount', tax, {'ExemptInd' => options[:tax_exemption] || "false"} + end + end + + def add_user_defined_fields(xml, options) + xml.tag! 'UDField1', options[:ud_field_1] if options[:ud_field_1] + xml.tag! 'UDField2', options[:ud_field_2] if options[:ud_field_2] + xml.tag! 'UDField3', options[:ud_field_3] if options[:ud_field_3] + end + + def lookup_country_code(code) + country = Country.find(code) rescue nil + country && country.code(:alpha3) + end + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index 43b83568389..99e26d138e0 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -398,6 +398,9 @@ iveri: jetpay: login: TESTTERMINAL +jetpay_v2: + login: TESTMCC3136X + komoju: login: sk_f1dd75ce3d5cad477eac0c827c1cac8eaa51ede3 diff --git a/test/remote/gateways/remote_jetpay_v2_test.rb b/test/remote/gateways/remote_jetpay_v2_test.rb new file mode 100644 index 00000000000..5c06d948393 --- /dev/null +++ b/test/remote/gateways/remote_jetpay_v2_test.rb @@ -0,0 +1,196 @@ +require 'test_helper' + +class RemoteJetpayV2Test < Test::Unit::TestCase + + def setup + @gateway = JetpayV2Gateway.new(fixtures(:jetpay_v2)) + + @credit_card = credit_card('4000300020001000') + + @amount_approved = 9900 + @amount_declined = 5205 + + @options = { + :device => 'spreedly', + :application => 'spreedly', + :developer_id => 'GenkID', + :billing_address => address(:city => 'Durham', :state => 'NC', :country => 'US', :zip => '27701'), + :shipping_address => address(:city => 'Durham', :state => 'NC', :country => 'US', :zip => '27701'), + :email => 'test@test.com', + :ip => '127.0.0.1', + :order_id => '12345' + } + end + + def test_successful_purchase + assert response = @gateway.purchase(@amount_approved, @credit_card, @options) + assert_success response + assert_equal "APPROVED", response.message + assert_not_nil response.authorization + assert_not_nil response.params["approval"] + end + + def test_failed_purchase + assert response = @gateway.purchase(@amount_declined, @credit_card, @options) + assert_failure response + assert_equal "Do not honor.", response.message + end + + def test_successful_purchase_with_minimal_options + assert response = @gateway.purchase(@amount_approved, @credit_card, {:device => 'spreedly', :application => 'spreedly'}) + assert_success response + assert_equal "APPROVED", response.message + assert_not_nil response.authorization + assert_not_nil response.params["approval"] + end + + def test_successful_purchase_with_additional_options + options = @options.merge( + ud_field_1: "Value1", + ud_field_2: "Value2", + ud_field_3: "Value3", + tax: '777' + ) + assert response = @gateway.purchase(@amount_approved, @credit_card, options) + assert_success response + end + + def test_authorize_and_capture + assert auth = @gateway.authorize(@amount_approved, @credit_card, @options) + assert_success auth + assert_equal 'APPROVED', auth.message + assert_not_nil auth.authorization + assert_not_nil auth.params["approval"] + + assert capture = @gateway.capture(@amount_approved, auth.authorization, @options) + assert_success capture + end + + def test_partial_capture + assert auth = @gateway.authorize(9900, @credit_card, @options) + assert_success auth + assert_equal 'APPROVED', auth.message + assert_not_nil auth.authorization + assert_not_nil auth.params["approval"] + + assert capture = @gateway.capture(4400, auth.authorization, @options) + assert_success capture + end + + def test_failed_capture + assert response = @gateway.capture(@amount_approved, '7605f7c5d6e8f74deb', @options) + assert_failure response + assert_equal 'Transaction Not Found.', response.message + end + + def test_successful_void + assert auth = @gateway.authorize(@amount_approved, @credit_card, @options) + assert_success auth + assert_equal 'APPROVED', auth.message + assert_not_nil auth.authorization + assert_not_nil auth.params["approval"] + + + assert void = @gateway.void(auth.authorization, @options) + assert_success void + end + + def test_failed_void + assert void = @gateway.void('bogus', @options) + assert_failure void + end + + def test_purchase_refund + assert response = @gateway.purchase(@amount_approved, @credit_card, @options) + assert_success response + assert_equal "APPROVED", response.message + assert_not_nil response.authorization + assert_not_nil response.params["approval"] + + assert refund = @gateway.refund(@amount_approved, response.authorization, @options) + assert_success refund + assert_not_nil(refund.authorization) + assert_not_nil(response.params["approval"]) + assert_equal [response.params['transaction_id'], response.params["approval"], @amount_approved, response.params["token"]].join(";"), response.authorization + end + + def test_capture_refund + assert auth = @gateway.authorize(@amount_approved, @credit_card, @options) + assert_success auth + assert_equal 'APPROVED', auth.message + assert_not_nil auth.authorization + assert_not_nil auth.params["approval"] + assert_equal [auth.params['transaction_id'], auth.params["approval"], @amount_approved, auth.params["token"]].join(";"), auth.authorization + + assert capture = @gateway.capture(@amount_approved, auth.authorization, @options) + assert_success capture + assert_equal [capture.params['transaction_id'], capture.params["approval"], @amount_approved, auth.params["token"]].join(";"), capture.authorization + + assert refund = @gateway.refund(@amount_approved, capture.authorization, @options) + assert_success refund + assert_not_nil(refund.authorization) + assert_not_nil(refund.params["approval"]) + end + + def test_failed_refund + assert refund = @gateway.refund(@amount_approved, 'bogus', @options) + assert_failure refund + end + + def test_successful_credit + card = credit_card('4242424242424242', :verification_value => nil) + + assert credit = @gateway.credit(@amount_approved, card, @options) + assert_success credit + assert_not_nil(credit.authorization) + assert_not_nil(credit.params["approval"]) + end + + def test_failed_credit + card = credit_card('2424242424242424', :verification_value => nil) + + assert credit = @gateway.credit(@amount_approved, card, @options) + assert_failure credit + assert_match %r{Invalid card format}, credit.message + end + + def test_successful_verify + assert verify = @gateway.verify(@credit_card, @options) + assert_success verify + end + + def test_failed_verify + card = credit_card('2424242424242424', :verification_value => nil) + + assert verify = @gateway.verify(card, @options) + assert_failure verify + assert_match %r{Invalid card format}, verify.message + end + + def test_invalid_login + gateway = JetpayV2Gateway.new(:login => 'bogus') + assert response = gateway.purchase(@amount_approved, @credit_card, @options) + assert_failure response + + assert_equal 'Bad Terminal ID.', response.message + end + + def test_missing_login + gateway = JetpayV2Gateway.new(:login => '') + assert response = gateway.purchase(@amount_approved, @credit_card, @options) + assert_failure response + + assert_equal 'No response returned (missing credentials?).', response.message + end + + def test_transcript_scrubbing + @credit_card.verification_value = "421" + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + clean_transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, clean_transcript) + assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript) + end +end diff --git a/test/unit/gateways/jetpay_v2_test.rb b/test/unit/gateways/jetpay_v2_test.rb new file mode 100644 index 00000000000..9c317bc41ff --- /dev/null +++ b/test/unit/gateways/jetpay_v2_test.rb @@ -0,0 +1,308 @@ +require 'test_helper' + +class JetpayV2Test < Test::Unit::TestCase + + def setup + @gateway = JetpayV2Gateway.new(:login => 'login') + + @credit_card = credit_card + @amount = 100 + + @options = { + :device => 'spreedly', + :application => 'spreedly', + :developer_id => 'GenkID', + :billing_address => address(:country => 'US'), + :shipping_address => address(:country => 'US'), + :email => 'test@test.com', + :ip => '127.0.0.1', + :order_id => '12345' + } + end + + def test_successful_purchase + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + + assert_equal '8afa688fd002821362;TEST97;100;KKLIHOJKKNKKHJKONJHOLHOL', response.authorization + assert_equal('TEST97', response.params["approval"]) + assert response.test? + end + + def test_failed_purchase + @gateway.expects(:ssl_post).returns(failed_purchase_response) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal('7605f7c5d6e8f74deb;;100;', response.authorization) + assert response.test? + end + + def test_successful_authorize + @gateway.expects(:ssl_post).returns(successful_authorize_response) + + assert response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + + assert_equal('cbf902091334a0b1aa;TEST01;100;KKLIHOJKKNKKHJKONOHCLOIO', response.authorization) + assert_equal('TEST01', response.params["approval"]) + assert response.test? + end + + def test_successful_capture + @gateway.expects(:ssl_post).returns(successful_capture_response) + + assert response = @gateway.capture(1111, "010327153017T10018;502F7B;1111", @options) + assert_success response + + assert_equal('010327153017T10018;502F6B;1111;', response.authorization) + assert_equal('502F6B', response.params["approval"]) + assert response.test? + end + + def test_failed_capture + @gateway.expects(:ssl_post).returns(failed_capture_response) + + assert response = @gateway.capture(@amount, '7605f7c5d6e8f74deb', @options) + assert_failure response + assert_equal 'Transaction Not Found.', response.message + end + + def test_successful_void + @gateway.expects(:ssl_post).returns(successful_void_response) + + assert response = @gateway.void('010327153x17T10418;502F7B;500', @options) + assert_success response + + assert_equal('010327153x17T10418;502F7B;500;', response.authorization) + assert_equal('502F7B', response.params["approval"]) + assert response.test? + end + + def test_failed_void + @gateway.expects(:ssl_post).returns(failed_void_response) + + assert void = @gateway.void('bogus', @options) + assert_failure void + end + + def test_successful_credit + card = credit_card('4242424242424242', :verification_value => nil) + + @gateway.expects(:ssl_post).returns(successful_credit_response) + + assert response = @gateway.credit(@amount, card, @options) + assert_success response + end + + def test_failed_credit + card = credit_card('2424242424242424', :verification_value => nil) + + @gateway.expects(:ssl_post).returns(failed_credit_response) + + assert credit = @gateway.credit(@amount, card, @options) + assert_failure credit + assert_match %r{Invalid card format}, credit.message + end + + def test_successful_refund + @gateway.expects(:ssl_post).returns(successful_credit_response) + + assert response = @gateway.refund(9900, '010327153017T10017', @options) + assert_success response + + assert_equal('010327153017T10017;002F6B;9900;', response.authorization) + assert_equal('002F6B', response.params['approval']) + assert response.test? + end + + def test_failed_refund + @gateway.expects(:ssl_post).returns(failed_void_response) + + assert refund = @gateway.refund(@amount_approved, 'bogus', @options) + assert_failure refund + end + + def test_successful_verify + @gateway.expects(:ssl_post).returns(successful_authorize_response) + + assert verify = @gateway.verify(@credit_card, @options) + assert_success verify + end + + def test_failed_verify + card = credit_card('2424242424242424', :verification_value => nil) + + @gateway.expects(:ssl_post).returns(failed_credit_response) + + assert verify = @gateway.verify(card, @options) + assert_failure verify + assert_match %r{Invalid card format}, verify.message + end + + def test_avs_result + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_equal 'D', response.avs_result['code'] + end + + def test_cvv_result + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_equal 'P', response.cvv_result['code'] + end + + def test_transcript_scrubbing + assert @gateway.supports_scrubbing + assert_equal scrubbed_transcript, @gateway.scrub(transcript) + end + + def test_purchase_sends_additional_options + @gateway.expects(:ssl_post). + with(anything, regexp_matches(/777<\/TaxAmount>/)). + with(anything, regexp_matches(/Value1<\/UDField1>/)). + with(anything, regexp_matches(/Value2<\/UDField2>/)). + with(anything, regexp_matches(/Value3<\/UDField3>/)). + returns(successful_purchase_response) + + @gateway.purchase(@amount, @credit_card, {:tax => '777', :ud_field_1 => 'Value1', :ud_field_2 => 'Value2', :ud_field_3 => 'Value3'}) + end + + private + + def successful_purchase_response + <<-EOF + + 8afa688fd002821362 + 000 + TEST97 + P + APPROVED + KKLIHOJKKNKKHJKONJHOLHOL + Y + Y + D + + EOF + end + + def failed_purchase_response + <<-EOF + + 7605f7c5d6e8f74deb + 005 + DECLINED + + EOF + end + + def successful_authorize_response + <<-EOF + + cbf902091334a0b1aa + 000 + TEST01 + P + APPROVED + KKLIHOJKKNKKHJKONOHCLOIO + Y + Y + D + + EOF + end + + def successful_capture_response + <<-EOF + + 010327153017T10018 + 000 + 502F6B + APPROVED + + EOF + end + + def failed_capture_response + <<-EOF + + 010327153017T10018 + 025 + REJECT + ED + + EOF + end + + def successful_void_response + <<-EOF + + 010327153x17T10418 + 000 + 502F7B + VOID PROCESSED + + EOF + end + + def failed_void_response + <<-EOF + + 010327153x17T10418 + 900 + INVALID MESSAGE TYPE + + EOF + end + + def successful_credit_response + <<-EOF + + 010327153017T10017 + 000 + 002F6B + APPROVED + + EOF + end + + def failed_credit_response + <<-EOF + + 010327153017T10017 + 912 + INVALID CARD NUMBER + + EOF + end + + def transcript + <<-EOF + TESTMCC3136X + SALE + e23c963a1247fd7aad + 4000300020001000 + 09 + 16 + Longbob Longsen + 123 + EOF + end + + def scrubbed_transcript + <<-EOF + TESTMCC3136X + SALE + e23c963a1247fd7aad + [FILTERED] + 09 + 16 + Longbob Longsen + [FILTERED] + EOF + end +end From fb202b7960351a09e9e5cdd6502cf72bdc467d58 Mon Sep 17 00:00:00 2001 From: jcowhigjr Date: Mon, 29 May 2017 09:48:25 -0400 Subject: [PATCH 080/677] =?UTF-8?q?Orbital=20gateway=20now=20requires=20ne?= =?UTF-8?q?w=20test=20and=20production=20urls=20=E2=80=A6=20(#2436)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Orbital gateway now requires us to use these new test and production urls for connections as part of a certificate upgrade process, deadline May 31, 2017 * orbital_update_test_and_prod_urls - fixes indentation --- lib/active_merchant/billing/gateways/orbital.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index fcddf4d5cce..d5605a3eb51 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -65,11 +65,11 @@ class OrbitalGateway < Gateway class_attribute :secondary_test_url, :secondary_live_url - self.test_url = "https://orbitalvar1.paymentech.net/authorize" - self.secondary_test_url = "https://orbitalvar2.paymentech.net/authorize" + self.test_url = "https://orbitalvar1.chasepaymentech.com/authorize" + self.secondary_test_url = "https://orbitalvar2.chasepaymentech.com/authorize" - self.live_url = "https://orbital1.paymentech.net/authorize" - self.secondary_live_url = "https://orbital2.paymentech.net/authorize" + self.live_url = "https://orbital1.chasepaymentech.com/authorize" + self.secondary_live_url = "https://orbital2.chasepaymentech.com/authorize" self.supported_countries = ["US", "CA"] self.default_currency = "CAD" From 9e403892118eba19c4b89415197198d069cd560b Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Mon, 29 May 2017 09:51:42 -0400 Subject: [PATCH 081/677] Add CHANGELOG entry for updated orbital urls --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index e660e52ee29..e3c69279ddb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * NMI: Add Network Tokenization support [shasum] #2431 * JetPay V2: Add new gateway [shasum] #2442 +* Orbital: Update test and production urls [jcowhigjr] #2436 == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 From f26024df7b47ee6403abff1cdf04740cd9ff6bae Mon Sep 17 00:00:00 2001 From: David Santoso Date: Tue, 30 May 2017 13:19:49 -0400 Subject: [PATCH 082/677] Orbital: Update stale remote test data After the URL update I ran the remote tests to verify everything was still working as expected with the new test URL (and hopefully production URL) and noticed some tests were failing. Most of the failures were due to invalid credit card number so it seems as though the previously used test credit card number is no longer a valid. --- test/remote/gateways/remote_orbital_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb index 67f9cd4c628..8108383583e 100644 --- a/test/remote/gateways/remote_orbital_test.rb +++ b/test/remote/gateways/remote_orbital_test.rb @@ -6,7 +6,7 @@ def setup @gateway = ActiveMerchant::Billing::OrbitalGateway.new(fixtures(:orbital_gateway)) @amount = 100 - @credit_card = credit_card('4111111111111111') + @credit_card = credit_card('4112344112344113') @declined_card = credit_card('4000300011112220') @options = { @@ -44,7 +44,7 @@ def test_successful_purchase def test_unsuccessful_purchase assert response = @gateway.purchase(101, @declined_card, @options) assert_failure response - assert_equal 'AUTH DECLINED 12001', response.message + assert_equal 'Invalid CC Number', response.message end def test_authorize_and_capture @@ -173,7 +173,7 @@ def test_successful_verify def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal 'AUTH DECLINED 12001', response.message + assert_equal 'Invalid CC Number', response.message end def test_transcript_scrubbing From 410071eae093a297a90ed12a4379daf95bdefd8a Mon Sep 17 00:00:00 2001 From: David Santoso Date: Tue, 30 May 2017 16:02:31 -0400 Subject: [PATCH 083/677] Fix incorrect reference in gateway remote test generator --- generators/gateway/templates/remote_gateway_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/gateway/templates/remote_gateway_test.rb b/generators/gateway/templates/remote_gateway_test.rb index f397794e4e6..08262a97c93 100644 --- a/generators/gateway/templates/remote_gateway_test.rb +++ b/generators/gateway/templates/remote_gateway_test.rb @@ -43,7 +43,7 @@ def test_successful_authorize_and_capture assert capture = @gateway.capture(@amount, auth.authorization) assert_success capture - assert_equal 'REPLACE WITH SUCCESS MESSAGE', response.message + assert_equal 'REPLACE WITH SUCCESS MESSAGE', capture.message end def test_failed_authorize From a4cea9e82f1afdd6211c71f41f1f61a7b06b690e Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 29 May 2017 16:57:37 -0400 Subject: [PATCH 084/677] Orbital: Pass soft descriptors from options hash Support for passing soft descriptors into options as a hash, instead of an OrbitalSoftDescriptor object. Unit: 67 tests, 397 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 15 tests, 111 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 2 +- lib/active_merchant/billing/gateways/orbital.rb | 11 +++++++++++ test/remote/gateways/remote_orbital_test.rb | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index e3c69279ddb..7363b5c908f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,7 +4,7 @@ * NMI: Add Network Tokenization support [shasum] #2431 * JetPay V2: Add new gateway [shasum] #2442 * Orbital: Update test and production urls [jcowhigjr] #2436 - +* Orbital: Pass soft descriptors from options hash [curiousepic] == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 * ProPay: Add Canada as supported country [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index d5605a3eb51..300b9ad245f 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -345,6 +345,15 @@ def add_soft_descriptors(xml, soft_desc) xml.tag! :SDMerchantEmail, soft_desc.merchant_email if soft_desc.merchant_email end + def add_soft_descriptors_from_hash(xml, soft_desc) + xml.tag! :SDMerchantName, soft_desc[:merchant_name] || nil + xml.tag! :SDProductDescription, soft_desc[:product_description] || nil + xml.tag! :SDMerchantCity, soft_desc[:merchant_city] || nil + xml.tag! :SDMerchantPhone, soft_desc[:merchant_phone] || nil + xml.tag! :SDMerchantURL, soft_desc[:merchant_url] || nil + xml.tag! :SDMerchantEmail, soft_desc[:merchant_email] || nil + end + def add_address(xml, creditcard, options) if(address = (options[:billing_address] || options[:address])) avs_supported = AVS_SUPPORTED_COUNTRIES.include?(address[:country].to_s) || empty?(address[:country]) @@ -560,6 +569,8 @@ def build_new_order_xml(action, money, parameters = {}) if parameters[:soft_descriptors].is_a?(OrbitalSoftDescriptors) add_soft_descriptors(xml, parameters[:soft_descriptors]) + elsif parameters[:soft_descriptors].is_a?(Hash) + add_soft_descriptors_from_hash(xml, parameters[:soft_descriptors]) end set_recurring_ind(xml, parameters) diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb index 8108383583e..bdca36ce97b 100644 --- a/test/remote/gateways/remote_orbital_test.rb +++ b/test/remote/gateways/remote_orbital_test.rb @@ -40,6 +40,20 @@ def test_successful_purchase assert_equal 'Approved', response.message end + def test_successful_purchase_with_soft_descriptor_hash + assert response = @gateway.purchase( + @amount, @credit_card, @options.merge( + soft_descriptors: { + merchant_name: 'Merch', + product_description: 'Description', + merchant_email: 'email@example', + } + ) + ) + assert_success response + assert_equal 'Approved', response.message + end + # Amounts of x.01 will fail def test_unsuccessful_purchase assert response = @gateway.purchase(101, @declined_card, @options) From 72e9bf0a99d269c7b53d22f23d263958a466dc63 Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Wed, 31 May 2017 23:38:36 +0530 Subject: [PATCH 085/677] JetPay V2: Add optional tax data to capture calls Closes #2445 --- CHANGELOG | 4 +++- .../billing/gateways/jetpay_v2.rb | 10 +++++--- test/remote/gateways/remote_jetpay_v2_test.rb | 24 +++++++++++++------ test/unit/gateways/jetpay_v2_test.rb | 2 +- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7363b5c908f..5a29cce4f39 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,7 +4,9 @@ * NMI: Add Network Tokenization support [shasum] #2431 * JetPay V2: Add new gateway [shasum] #2442 * Orbital: Update test and production urls [jcowhigjr] #2436 -* Orbital: Pass soft descriptors from options hash [curiousepic] +* Orbital: Pass soft descriptors from options hash [curiousepic] +* JetPay V2: Add optional tax data to capture calls [shasum] #2445 + == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 * ProPay: Add Canada as supported country [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/jetpay_v2.rb b/lib/active_merchant/billing/gateways/jetpay_v2.rb index 691d2765d1d..f29cacd02b2 100644 --- a/lib/active_merchant/billing/gateways/jetpay_v2.rb +++ b/lib/active_merchant/billing/gateways/jetpay_v2.rb @@ -252,8 +252,11 @@ def build_authonly_request(money, credit_card, options) def build_capture_request(transaction_id, money, options) build_xml_request('CAPT', options, transaction_id) do |xml| - xml.tag! 'TotalAmount', amount(money) + add_invoice_data(xml, options) add_user_defined_fields(xml, options) + xml.tag! 'TotalAmount', amount(money) + + xml.target! end end @@ -262,6 +265,7 @@ def build_void_request(money, transaction_id, approval, token, options) xml.tag! 'Approval', approval xml.tag! 'TotalAmount', amount(money) xml.tag! 'Token', token if token + xml.target! end end @@ -386,8 +390,8 @@ def add_customer_data(xml, options) def add_invoice_data(xml, options) xml.tag! 'OrderNumber', options[:order_id] if options[:order_id] - if tax = options[:tax] - xml.tag! 'TaxAmount', tax, {'ExemptInd' => options[:tax_exemption] || "false"} + if tax_amount = options[:tax_amount] + xml.tag! 'TaxAmount', tax_amount, {'ExemptInd' => options[:tax_exemption] || "false"} end end diff --git a/test/remote/gateways/remote_jetpay_v2_test.rb b/test/remote/gateways/remote_jetpay_v2_test.rb index 5c06d948393..df1e15d9c10 100644 --- a/test/remote/gateways/remote_jetpay_v2_test.rb +++ b/test/remote/gateways/remote_jetpay_v2_test.rb @@ -48,14 +48,13 @@ def test_successful_purchase_with_additional_options options = @options.merge( ud_field_1: "Value1", ud_field_2: "Value2", - ud_field_3: "Value3", - tax: '777' + ud_field_3: "Value3" ) assert response = @gateway.purchase(@amount_approved, @credit_card, options) assert_success response end - def test_authorize_and_capture + def test_successful_authorize_and_capture assert auth = @gateway.authorize(@amount_approved, @credit_card, @options) assert_success auth assert_equal 'APPROVED', auth.message @@ -66,7 +65,18 @@ def test_authorize_and_capture assert_success capture end - def test_partial_capture + def test_successful_authorize_and_capture_with_tax + assert auth = @gateway.authorize(@amount_approved, @credit_card, @options) + assert_success auth + assert_equal 'APPROVED', auth.message + assert_not_nil auth.authorization + assert_not_nil auth.params["approval"] + + assert capture = @gateway.capture(@amount_approved, auth.authorization, @options.merge(:tax_amount => '900', :tax_exemption => 'true')) + assert_success capture + end + + def test_successful_partial_capture assert auth = @gateway.authorize(9900, @credit_card, @options) assert_success auth assert_equal 'APPROVED', auth.message @@ -100,7 +110,7 @@ def test_failed_void assert_failure void end - def test_purchase_refund + def test_successful_purchase_refund assert response = @gateway.purchase(@amount_approved, @credit_card, @options) assert_success response assert_equal "APPROVED", response.message @@ -114,7 +124,7 @@ def test_purchase_refund assert_equal [response.params['transaction_id'], response.params["approval"], @amount_approved, response.params["token"]].join(";"), response.authorization end - def test_capture_refund + def test_successful_capture_refund assert auth = @gateway.authorize(@amount_approved, @credit_card, @options) assert_success auth assert_equal 'APPROVED', auth.message @@ -186,7 +196,7 @@ def test_missing_login def test_transcript_scrubbing @credit_card.verification_value = "421" transcript = capture_transcript(@gateway) do - @gateway.purchase(@amount, @credit_card, @options) + @gateway.purchase(@amount_approved, @credit_card, @options) end clean_transcript = @gateway.scrub(transcript) diff --git a/test/unit/gateways/jetpay_v2_test.rb b/test/unit/gateways/jetpay_v2_test.rb index 9c317bc41ff..b1250dbdc55 100644 --- a/test/unit/gateways/jetpay_v2_test.rb +++ b/test/unit/gateways/jetpay_v2_test.rb @@ -121,7 +121,7 @@ def test_successful_refund def test_failed_refund @gateway.expects(:ssl_post).returns(failed_void_response) - assert refund = @gateway.refund(@amount_approved, 'bogus', @options) + assert refund = @gateway.refund(@amount, 'bogus', @options) assert_failure refund end From f29682d05d41b7dbda740a7e72d4a36fb3072cff Mon Sep 17 00:00:00 2001 From: David Santoso Date: Tue, 23 May 2017 11:31:54 -0400 Subject: [PATCH 086/677] Credorax: Add 3D Secure authentication fields Closes #2446 --- CHANGELOG | 1 + .../billing/gateways/credorax.rb | 9 +- test/unit/gateways/credorax_test.rb | 474 ++++++++++-------- 3 files changed, 262 insertions(+), 222 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5a29cce4f39..b8934c3b129 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * Orbital: Update test and production urls [jcowhigjr] #2436 * Orbital: Pass soft descriptors from options hash [curiousepic] * JetPay V2: Add optional tax data to capture calls [shasum] #2445 +* Credorax: Add 3D Secure authentication fields [davidsantoso] #2446 == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb index ae9ae730bad..a7a35ea4798 100644 --- a/lib/active_merchant/billing/gateways/credorax.rb +++ b/lib/active_merchant/billing/gateways/credorax.rb @@ -108,6 +108,7 @@ def purchase(amount, payment_method, options={}) add_payment_method(post, payment_method) add_customer_data(post, options) add_email(post, options) + add_3d_secure(post, options) add_echo(post, options) commit(:purchase, post) @@ -119,6 +120,7 @@ def authorize(amount, payment_method, options={}) add_payment_method(post, payment_method) add_customer_data(post, options) add_email(post, options) + add_3d_secure(post, options) add_echo(post, options) commit(:authorize, post) @@ -230,6 +232,11 @@ def add_email(post, options) post[:c3] = options[:email] || 'unspecified@example.com' end + def add_3d_secure(post, options) + return unless options[:eci] && options[:xid] + post[:i8] = "#{options[:eci]}:#{(options[:cavv] || "none")}:#{options[:xid]}" + end + def add_echo(post, options) # The d2 parameter is used during the certification process # See remote tests for full certification test suite @@ -240,7 +247,7 @@ def add_echo(post, options) purchase: '1', authorize: '2', capture: '3', - authorize_void:'4', + authorize_void: '4', refund: '5', credit: '6', purchase_void: '7', diff --git a/test/unit/gateways/credorax_test.rb b/test/unit/gateways/credorax_test.rb index 29066e966bd..fca8590f741 100644 --- a/test/unit/gateways/credorax_test.rb +++ b/test/unit/gateways/credorax_test.rb @@ -14,221 +14,253 @@ def setup } end - def test_successful_purchase - 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 - assert response.test? - end - - def test_failed_purchase - response = stub_comms do - @gateway.purchase(@amount, @credit_card) - end.respond_with(failed_purchase_response) - - assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message - assert response.test? - end - - def test_successful_authorize_and_capture - response = stub_comms do - @gateway.authorize(@amount, @credit_card) - end.respond_with(successful_authorize_response) - - assert_success response - assert_equal "8a829449535154bc0153595952a2517a;006597;90f7449d555f7bed0a2c5d780475f0bf;authorize", response.authorization - - capture = stub_comms do - @gateway.capture(@amount, response.authorization) - end.check_request do |endpoint, data, headers| - assert_match(/8a829449535154bc0153595952a2517a/, data) - end.respond_with(successful_capture_response) - - assert_success capture - end - - def test_failed_authorize - response = stub_comms do - @gateway.authorize(@amount, @credit_card) - end.respond_with(failed_authorize_response) - - assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message - assert response.test? - end - - def test_failed_capture - response = stub_comms do - @gateway.capture(100, "") - end.respond_with(failed_capture_response) - - assert_failure response - end - - def test_successful_void - response = stub_comms do - @gateway.purchase(@amount, @credit_card) - end.respond_with(successful_authorize_response) - - assert_success response - assert_equal "8a829449535154bc0153595952a2517a;006597;90f7449d555f7bed0a2c5d780475f0bf;purchase", response.authorization - - void = stub_comms do - @gateway.void(response.authorization) - end.check_request do |endpoint, data, headers| - assert_match(/8a829449535154bc0153595952a2517a/, data) - end.respond_with(successful_void_response) - - assert_success void - end - - def test_failed_void - response = stub_comms do - @gateway.void("5d53a33d960c46d00f5dc061947d998c") - end.check_request do |endpoint, data, headers| - assert_match(/5d53a33d960c46d00f5dc061947d998c/, data) - end.respond_with(failed_void_response) - - assert_failure response - end - - def test_successful_refund - 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 - - refund = stub_comms do - @gateway.refund(@amount, response.authorization) - end.check_request do |endpoint, data, headers| - assert_match(/8a82944a5351570601535955efeb513c/, data) - end.respond_with(successful_refund_response) - - assert_success refund - end - - def test_failed_refund - response = stub_comms do - @gateway.refund(nil, "") - end.respond_with(failed_refund_response) - - assert_failure response - end - - def test_successful_credit - response = stub_comms do - @gateway.credit(@amount, @credit_card) - end.respond_with(successful_credit_response) - - assert_success response - - assert_equal "8a82944a53515706015359604c135301;;868f8b942fae639d28e27e8933d575d4;credit", response.authorization - assert response.test? - end - - def test_failed_credit - response = stub_comms do - @gateway.credit(@amount, @credit_card) - end.respond_with(failed_credit_response) - - assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message - assert response.test? - end - - def test_successful_verify - response = stub_comms do - @gateway.verify(@credit_card) - end.respond_with(successful_authorize_response, failed_void_response) - assert_success response - assert_equal "Succeeded", response.message - end - - def test_failed_verify - response = stub_comms do - @gateway.verify(@credit_card) - end.respond_with(failed_authorize_response, successful_void_response) - assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message - end - - def test_empty_response_fails - response = stub_comms do - @gateway.purchase(@amount, @credit_card) - end.respond_with(empty_purchase_response) - - assert_failure response - assert_equal "Unable to read error message", response.message - end - - def test_transcript_scrubbing - assert_equal scrubbed_transcript, @gateway.scrub(transcript) - end - - private - - def successful_purchase_response - "M=SPREE978&O=1&T=03%2F09%2F2016+03%3A05%3A16&V=413&a1=02617cf5f02ccaed239b6521748298c5&a2=2&a4=100&a9=6&z1=8a82944a5351570601535955efeb513c&z13=606944188282&z14=U&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006596&z5=0&z6=00&z9=X&K=057e123af2fba5a37b4df76a7cb5cfb6" - end - - def failed_purchase_response - "M=SPREE978&O=1&T=03%2F09%2F2016+03%3A05%3A47&V=413&a1=92176aca194ceafdb4a679389b77f207&a2=2&a4=100&a9=6&z1=8a82944a535157060153595668fd5162&z13=606944188283&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=2d44820a5a907ff820f928696e460ce1" - end - - def successful_authorize_response - "M=SPREE978&O=2&T=03%2F09%2F2016+03%3A08%3A58&V=413&a1=90f7449d555f7bed0a2c5d780475f0bf&a2=2&a4=100&a9=6&z1=8a829449535154bc0153595952a2517a&z13=606944188284&z14=U&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006597&z5=0&z6=00&z9=X&K=00effd2c80ab7ecd45b499c0bbea3d20" - end - - def failed_authorize_response - "M=SPREE978&O=2&T=03%2F09%2F2016+03%3A10%3A02&V=413&a1=9bd85e23639ffcd5206f8e7fe4e3d365&a2=2&a4=100&a9=6&z1=8a829449535154bc0153595a4bb051ac&z13=606944188285&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=2fe3ee6b975d1e4ba542c1e7549056f6" - end - - def successful_capture_response - "M=SPREE978&O=3&T=03%2F09%2F2016+03%3A09%3A03&V=413&a1=2a349969e0ed61fb0db59fc9f32d2fb3&a2=2&a4=100&g2=8a829449535154bc0153595952a2517a&g3=006597&g4=90f7449d555f7bed0a2c5d780475f0bf&z1=8a82944a535157060153595966ba51f9&z13=606944188284&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006597&z5=0&z6=00&K=4ad979199490a8d000302735220edfa6" - end - - def failed_capture_response - "M=SPREE978&O=3&T=03%2F09%2F2016+03%3A10%3A33&V=413&a1=eed7c896e1355dc4007c0c8df44d5852&a2=2&a4=100&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=8d1d8f2f9feeb7909aa3e6c428903d57" - end - - def successful_void_response - "M=SPREE978&O=4&T=03%2F09%2F2016+03%3A11%3A11&V=413&a1=&a2=2&a4=100&g2=8a82944a535157060153595b484a524d&g3=006598&g4=0d600bf50198059dbe61979f8c28aab2&z1=8a829449535154bc0153595b57c351d2&z13=606944188287&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006598&z5=0&z6=00&K=e643b9e88b35fd69d5421b59c611a6c9" - end - - def failed_void_response - "M=SPREE978&O=4&T=03%2F09%2F2016+03%3A11%3A37&V=413&a1=-&a2=2&a4=-&a5=-&b1=-&z1=1A-1&z2=-9&z3=2.+At+least+one+of+input+parameters+is+malformed.%3A+Parameter+%5Bg4%5D+cannot+be+empty.&K=1e6683cd7b1d01712f12ce7bfc9a5ad2" - end - - def successful_refund_response - "M=SPREE978&O=5&T=03%2F09%2F2016+03%3A15%3A32&V=413&a1=b449bb41af3eb09fd483e7629eb2266f&a2=2&a4=100&g2=8a82944a535157060153595f3ea352c2&g3=006600&g4=78141b277cfadba072a0bcb90745faef&z1=8a82944a535157060153595f553a52de&z13=606944188288&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006600&z5=0&z6=00&K=bfdfd8b0dcee974c07c3c85cfea753fe" - end - - 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_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 - - def failed_credit_response - "M=SPREE978&O=6&T=03%2F09%2F2016+03%3A16%3A59&V=413&a1=ff28246cfc811b1c686a52d08d075d9c&a2=2&a4=100&z1=8a829449535154bc01535960a962524f&z13=606944188290&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=cf34816d5c25dc007ef3525505c4c610" - end - - def empty_purchase_response - %( - ) - end - - def transcript - %( + def test_successful_purchase + response = stub_comms do + @gateway.purchase(@amount, @credit_card) + 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 response.test? + end + + def test_failed_purchase + response = stub_comms do + @gateway.purchase(@amount, @credit_card) + end.respond_with(failed_purchase_response) + + assert_failure response + assert_equal "Transaction not allowed for cardholder", response.message + assert response.test? + end + + def test_successful_authorize_and_capture + response = stub_comms do + @gateway.authorize(@amount, @credit_card) + end.respond_with(successful_authorize_response) + + assert_success response + assert_equal "8a829449535154bc0153595952a2517a;006597;90f7449d555f7bed0a2c5d780475f0bf;authorize", response.authorization + + capture = stub_comms do + @gateway.capture(@amount, response.authorization) + end.check_request do |endpoint, data, headers| + assert_match(/8a829449535154bc0153595952a2517a/, data) + end.respond_with(successful_capture_response) + + assert_success capture + end + + def test_failed_authorize + response = stub_comms do + @gateway.authorize(@amount, @credit_card) + end.respond_with(failed_authorize_response) + + assert_failure response + assert_equal "Transaction not allowed for cardholder", response.message + assert response.test? + end + + def test_failed_capture + response = stub_comms do + @gateway.capture(100, "") + end.respond_with(failed_capture_response) + + assert_failure response + end + + def test_successful_void + response = stub_comms do + @gateway.purchase(@amount, @credit_card) + end.respond_with(successful_authorize_response) + + assert_success response + assert_equal "8a829449535154bc0153595952a2517a;006597;90f7449d555f7bed0a2c5d780475f0bf;purchase", response.authorization + + void = stub_comms do + @gateway.void(response.authorization) + end.check_request do |endpoint, data, headers| + assert_match(/8a829449535154bc0153595952a2517a/, data) + end.respond_with(successful_void_response) + + assert_success void + end + + def test_failed_void + response = stub_comms do + @gateway.void("5d53a33d960c46d00f5dc061947d998c") + end.check_request do |endpoint, data, headers| + assert_match(/5d53a33d960c46d00f5dc061947d998c/, data) + end.respond_with(failed_void_response) + + assert_failure response + end + + def test_successful_refund + 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 + + refund = stub_comms do + @gateway.refund(@amount, response.authorization) + end.check_request do |endpoint, data, headers| + assert_match(/8a82944a5351570601535955efeb513c/, data) + end.respond_with(successful_refund_response) + + assert_success refund + end + + def test_failed_refund + response = stub_comms do + @gateway.refund(nil, "") + end.respond_with(failed_refund_response) + + assert_failure response + end + + def test_successful_credit + response = stub_comms do + @gateway.credit(@amount, @credit_card) + end.respond_with(successful_credit_response) + + assert_success response + + assert_equal "8a82944a53515706015359604c135301;;868f8b942fae639d28e27e8933d575d4;credit", response.authorization + assert response.test? + end + + def test_failed_credit + response = stub_comms do + @gateway.credit(@amount, @credit_card) + end.respond_with(failed_credit_response) + + assert_failure response + assert_equal "Transaction not allowed for cardholder", response.message + assert response.test? + end + + def test_successful_verify + response = stub_comms do + @gateway.verify(@credit_card) + end.respond_with(successful_authorize_response, failed_void_response) + assert_success response + assert_equal "Succeeded", response.message + end + + def test_failed_verify + response = stub_comms do + @gateway.verify(@credit_card) + end.respond_with(failed_authorize_response, successful_void_response) + assert_failure response + assert_equal "Transaction not allowed for cardholder", response.message + end + + def test_empty_response_fails + response = stub_comms do + @gateway.purchase(@amount, @credit_card) + end.respond_with(empty_purchase_response) + + assert_failure response + assert_equal "Unable to read error message", response.message + end + + def test_transcript_scrubbing + assert_equal scrubbed_transcript, @gateway.scrub(transcript) + end + + def test_adds_3d_secure_fields + options_with_3ds = @options.merge({eci: "sample-eci", cavv: "sample-cavv", xid: "sample-xid"}) + + response = stub_comms do + @gateway.purchase(@amount, @credit_card, options_with_3ds) + end.check_request do |endpoint, data, headers| + assert_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 response.test? + end + + def test_defaults_3d_secure_cavv_field_to_none_if_not_present + 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| + assert_match(/i8=sample-eci%3Anone%3Asample-xid/, data) + end.respond_with(successful_purchase_response) + + assert_success response + + assert_equal "8a82944a5351570601535955efeb513c;006596;02617cf5f02ccaed239b6521748298c5;purchase", response.authorization + assert response.test? + end + + private + + def successful_purchase_response + "M=SPREE978&O=1&T=03%2F09%2F2016+03%3A05%3A16&V=413&a1=02617cf5f02ccaed239b6521748298c5&a2=2&a4=100&a9=6&z1=8a82944a5351570601535955efeb513c&z13=606944188282&z14=U&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006596&z5=0&z6=00&z9=X&K=057e123af2fba5a37b4df76a7cb5cfb6" + end + + def failed_purchase_response + "M=SPREE978&O=1&T=03%2F09%2F2016+03%3A05%3A47&V=413&a1=92176aca194ceafdb4a679389b77f207&a2=2&a4=100&a9=6&z1=8a82944a535157060153595668fd5162&z13=606944188283&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=2d44820a5a907ff820f928696e460ce1" + end + + def successful_authorize_response + "M=SPREE978&O=2&T=03%2F09%2F2016+03%3A08%3A58&V=413&a1=90f7449d555f7bed0a2c5d780475f0bf&a2=2&a4=100&a9=6&z1=8a829449535154bc0153595952a2517a&z13=606944188284&z14=U&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006597&z5=0&z6=00&z9=X&K=00effd2c80ab7ecd45b499c0bbea3d20" + end + + def failed_authorize_response + "M=SPREE978&O=2&T=03%2F09%2F2016+03%3A10%3A02&V=413&a1=9bd85e23639ffcd5206f8e7fe4e3d365&a2=2&a4=100&a9=6&z1=8a829449535154bc0153595a4bb051ac&z13=606944188285&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=2fe3ee6b975d1e4ba542c1e7549056f6" + end + + def successful_capture_response + "M=SPREE978&O=3&T=03%2F09%2F2016+03%3A09%3A03&V=413&a1=2a349969e0ed61fb0db59fc9f32d2fb3&a2=2&a4=100&g2=8a829449535154bc0153595952a2517a&g3=006597&g4=90f7449d555f7bed0a2c5d780475f0bf&z1=8a82944a535157060153595966ba51f9&z13=606944188284&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006597&z5=0&z6=00&K=4ad979199490a8d000302735220edfa6" + end + + def failed_capture_response + "M=SPREE978&O=3&T=03%2F09%2F2016+03%3A10%3A33&V=413&a1=eed7c896e1355dc4007c0c8df44d5852&a2=2&a4=100&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=8d1d8f2f9feeb7909aa3e6c428903d57" + end + + def successful_void_response + "M=SPREE978&O=4&T=03%2F09%2F2016+03%3A11%3A11&V=413&a1=&a2=2&a4=100&g2=8a82944a535157060153595b484a524d&g3=006598&g4=0d600bf50198059dbe61979f8c28aab2&z1=8a829449535154bc0153595b57c351d2&z13=606944188287&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006598&z5=0&z6=00&K=e643b9e88b35fd69d5421b59c611a6c9" + end + + def failed_void_response + "M=SPREE978&O=4&T=03%2F09%2F2016+03%3A11%3A37&V=413&a1=-&a2=2&a4=-&a5=-&b1=-&z1=1A-1&z2=-9&z3=2.+At+least+one+of+input+parameters+is+malformed.%3A+Parameter+%5Bg4%5D+cannot+be+empty.&K=1e6683cd7b1d01712f12ce7bfc9a5ad2" + end + + def successful_refund_response + "M=SPREE978&O=5&T=03%2F09%2F2016+03%3A15%3A32&V=413&a1=b449bb41af3eb09fd483e7629eb2266f&a2=2&a4=100&g2=8a82944a535157060153595f3ea352c2&g3=006600&g4=78141b277cfadba072a0bcb90745faef&z1=8a82944a535157060153595f553a52de&z13=606944188288&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006600&z5=0&z6=00&K=bfdfd8b0dcee974c07c3c85cfea753fe" + end + + 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_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 + + def failed_credit_response + "M=SPREE978&O=6&T=03%2F09%2F2016+03%3A16%3A59&V=413&a1=ff28246cfc811b1c686a52d08d075d9c&a2=2&a4=100&z1=8a829449535154bc01535960a962524f&z13=606944188290&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=cf34816d5c25dc007ef3525505c4c610" + end + + def empty_purchase_response + %( + ) + end + + def transcript + %( opening connection to intconsole.credorax.com:443... opened starting SSL for intconsole.credorax.com:443... @@ -245,11 +277,11 @@ def transcript -> "M=SPREE978&O=1&T=03%2F09%2F2016+03%3A03%3A01&V=413&a1=335ebb08c489e6d361108a7eb7d8b92a&a2=2&a4=100&a9=6&z1=8a829449535154bc01535953dd235043&z13=606944188276&z14=U&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006592&z5=0&z6=00&z9=X&K=4061e16f39915297827af1586635015a" read 283 bytes Conn close - ) - end + ) + end - def scrubbed_transcript - %( + def scrubbed_transcript + %( opening connection to intconsole.credorax.com:443... opened starting SSL for intconsole.credorax.com:443... @@ -266,6 +298,6 @@ def scrubbed_transcript -> "M=SPREE978&O=1&T=03%2F09%2F2016+03%3A03%3A01&V=413&a1=335ebb08c489e6d361108a7eb7d8b92a&a2=2&a4=100&a9=6&z1=8a829449535154bc01535953dd235043&z13=606944188276&z14=U&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006592&z5=0&z6=00&z9=X&K=4061e16f39915297827af1586635015a" read 283 bytes Conn close - ) - end + ) + end end From a7bf55caea9df1789d97d7ecd6509fe3a3915e08 Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 29 May 2017 14:49:27 -0400 Subject: [PATCH 087/677] Authorize.net: Pass Level 2 Data Fields This required some shifting of the existing request building flow due to strange element ordering/structuring requirements from ANET. Unit: 83 tests, 473 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 59 tests, 204 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/authorize_net.rb | 81 +++++++++++++++++-- .../gateways/remote_authorize_net_test.rb | 60 ++++++++++++++ 3 files changed, 135 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b8934c3b129..922a600c39e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * Orbital: Pass soft descriptors from options hash [curiousepic] * JetPay V2: Add optional tax data to capture calls [shasum] #2445 * Credorax: Add 3D Secure authentication fields [davidsantoso] #2446 +* Authorize.net: Pass Level 2 Data Fields [curiousepic] #2444 == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index de77c660888..cb7c1e56491 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -166,7 +166,7 @@ def credit(amount, payment, options={}) xml.amount(amount(amount)) add_payment_source(xml, payment) - add_invoice(xml, options) + add_invoice(xml, 'refundTransaction', options) add_customer_data(xml, payment, options) add_settings(xml, payment, options) add_user_fields(xml, amount, options) @@ -244,7 +244,12 @@ def add_auth_purchase(xml, transaction_type, amount, payment, options) xml.transactionType(transaction_type) xml.amount(amount(amount)) add_payment_source(xml, payment) - add_invoice(xml, options) + add_invoice(xml, transaction_type, options) + add_tax_fields(xml, options) + add_duty_fields(xml, options) + add_shipping_fields(xml, options) + add_tax_exempt_status(xml, options) + add_po_number(xml, options) add_customer_data(xml, payment, options) add_market_type_device_type(xml, payment, options) add_settings(xml, payment, options) @@ -257,8 +262,12 @@ def add_cim_auth_purchase(xml, transaction_type, amount, payment, options) xml.transaction do xml.send(transaction_type) do xml.amount(amount(amount)) + add_tax_fields(xml, options) + add_shipping_fields(xml, options) + add_duty_fields(xml, options) add_payment_source(xml, payment) - add_invoice(xml, options) + add_invoice(xml, transaction_type, options) + add_tax_exempt_status(xml, options) end end end @@ -269,6 +278,9 @@ def cim_capture(amount, authorization, options) xml.transaction do xml.profileTransPriorAuthCapture do xml.amount(amount(amount)) + add_tax_fields(xml, options) + add_shipping_fields(xml, options) + add_duty_fields(xml, options) xml.transId(transaction_id_from(authorization)) end end @@ -281,8 +293,13 @@ def normal_capture(amount, authorization, options) xml.transactionRequest do xml.transactionType('priorAuthCaptureTransaction') xml.amount(amount(amount)) + add_tax_fields(xml, options) + add_duty_fields(xml, options) + add_shipping_fields(xml, options) + add_tax_exempt_status(xml, options) + add_po_number(xml, options) xml.refTransId(transaction_id_from(authorization)) - add_invoice(xml, options) + add_invoice(xml, "capture", options) add_user_fields(xml, amount, options) end end @@ -296,8 +313,11 @@ def cim_refund(amount, authorization, options) xml.transaction do xml.profileTransRefund do xml.amount(amount(amount)) + add_tax_fields(xml, options) + add_shipping_fields(xml, options) + add_duty_fields(xml, options) xml.creditCardNumberMasked(card_number) - add_invoice(xml, options) + add_invoice(xml, "profileTransRefund", options) xml.transId(transaction_id) end end @@ -319,7 +339,12 @@ def normal_refund(amount, authorization, options) end xml.refTransId(transaction_id) - add_invoice(xml, options) + add_invoice(xml, 'refundTransaction', options) + add_tax_fields(xml, options) + add_duty_fields(xml, options) + add_shipping_fields(xml, options) + add_tax_exempt_status(xml, options) + add_po_number(xml, options) add_customer_data(xml, nil, options) add_user_fields(xml, amount, options) end @@ -570,10 +595,11 @@ def add_order_id(xml, options) xml.refId(truncate(options[:order_id], 20)) end - def add_invoice(xml, options) + def add_invoice(xml, transaction_type, options) xml.order do xml.invoiceNumber(truncate(options[:order_id], 20)) xml.description(truncate(options[:description], 255)) + xml.purchaseOrderNumber(options[:po_number]) if options[:po_number] && transaction_type.start_with?("profileTrans") end # Authorize.net API requires lineItems to be placed directly after order tag @@ -590,6 +616,47 @@ def add_invoice(xml, options) end end + def add_tax_fields(xml, options) + tax = options[:tax] + if tax.is_a?(Hash) + xml.tax do + xml.amount(amount(tax[:amount].to_i)) + xml.name(tax[:name]) + xml.description(tax[:description]) + end + end + end + + def add_duty_fields(xml, options) + duty = options[:duty] + if duty.is_a?(Hash) + xml.duty do + xml.amount(amount(duty[:amount].to_i)) + xml.name(duty[:name]) + xml.description(duty[:description]) + end + end + end + + def add_shipping_fields(xml, options) + shipping = options[:shipping] + if shipping.is_a?(Hash) + xml.shipping do + xml.amount(amount(shipping[:amount].to_i)) + xml.name(shipping[:name]) + xml.description(shipping[:description]) + end + end + end + + def add_tax_exempt_status(xml, options) + xml.taxExempt(options[:tax_exempt]) if options[:tax_exempt] + end + + def add_po_number(xml, options) + xml.poNumber(options[:po_number]) if options[:po_number] + end + def create_customer_payment_profile(credit_card, options) commit(:cim_store_update) do |xml| xml.customerProfileId options[:customer_profile_id] diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb index 56bbb1f533b..56369d97a85 100644 --- a/test/remote/gateways/remote_authorize_net_test.rb +++ b/test/remote/gateways/remote_authorize_net_test.rb @@ -16,6 +16,26 @@ def setup billing_address: address, description: 'Store Purchase' } + + @level_2_options = { + tax: { + amount: "100", + name: "tax name", + description: "tax description" + }, + duty: { + amount: "200", + name: "duty name", + description: "duty description" + }, + shipping: { + amount: "300", + name: "shipping name", + description: "shipping description", + }, + tax_exempt: "false", + po_number: "123" + } end def test_successful_purchase @@ -77,6 +97,12 @@ def test_successful_purchase_with_line_items assert response.authorization end + def test_successful_purchase_with_level_2_data + response = @gateway.purchase(@amount, @credit_card, @options.merge(@level_2_options)) + assert_success response + assert_equal 'This transaction has been approved', response.message + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response @@ -311,6 +337,15 @@ def test_successful_purchase_using_stored_card_new_payment_profile assert_equal "This transaction has been approved.", response.message end + def test_successful_purchase_with_stored_card_and_level_2_data + store_response = @gateway.store(@credit_card, @options) + assert_success store_response + + response = @gateway.purchase(@amount, store_response.authorization, @options.merge(@level_2_options)) + assert_success response + assert_equal 'This transaction has been approved.', response.message + end + def test_successful_authorize_and_capture_using_stored_card store = @gateway.store(@credit_card, @options) assert_success store @@ -324,6 +359,19 @@ def test_successful_authorize_and_capture_using_stored_card assert_equal "This transaction has been approved.", capture.message end + def test_successful_authorize_and_capture_using_stored_card_with_level_2_data + store = @gateway.store(@credit_card, @options) + assert_success store + + auth = @gateway.authorize(@amount, store.authorization, @options.merge(@level_2_options)) + assert_success auth + assert_equal "This transaction has been approved.", auth.message + + capture = @gateway.capture(@amount, auth.authorization, @options.merge(@level_2_options)) + assert_success capture + assert_equal "This transaction has been approved.", capture.message + end + def test_failed_authorize_using_stored_card response = @gateway.store(@declined_card) assert_success response @@ -362,6 +410,18 @@ def test_faux_successful_refund_using_stored_card assert_match %r{does not meet the criteria for issuing a credit}, refund.message, "Only allowed to refund transactions that have settled. This is the best we can do for now testing wise." end + def test_faux_successful_refund_using_stored_card_and_level_2_data + store = @gateway.store(@credit_card, @options) + assert_success store + + purchase = @gateway.purchase(@amount, store.authorization, @options.merge(@level_2_options)) + assert_success purchase + + refund = @gateway.refund(@amount, purchase.authorization, @options.merge(@level_2_options)) + assert_failure refund + assert_match %r{does not meet the criteria for issuing a credit}, refund.message, "Only allowed to refund transactions that have settled. This is the best we can do for now testing wise." + end + def test_failed_refund_using_stored_card store = @gateway.store(@credit_card, @options) assert_success store From ed4ed2d03837a3a7db6a22fc37861c22f3779c90 Mon Sep 17 00:00:00 2001 From: Wendy Smoak Date: Thu, 21 Jul 2016 11:35:23 -0400 Subject: [PATCH 088/677] Quickpay V10: Fix store and token use for recurring payments Previously, Store was erroneously calling for a token that is single- use only, and any recurring payments after the first were failing. Now, Store returns only the card's id, and Purchase and Authorize with a stored card first calls for a single-use token via the stored id, for the actual transaction. Connect #2172 Closes #2180 Unit: 14 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 24 tests, 106 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/quickpay/quickpay_v10.rb | 33 +++++++++++-------- .../gateways/remote_quickpay_v10_test.rb | 19 ++++++++++- test/unit/gateways/quickpay_v10_test.rb | 4 +-- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 922a600c39e..f5eb6ce4f47 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * JetPay V2: Add optional tax data to capture calls [shasum] #2445 * Credorax: Add 3D Secure authentication fields [davidsantoso] #2446 * Authorize.net: Pass Level 2 Data Fields [curiousepic] #2444 +* Quickpay V10: Fix store and token use for recurring payments [wsmoak] #2180 == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb index 586eec8711c..9333927c7f2 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb @@ -16,25 +16,33 @@ def initialize(options = {}) def purchase(money, credit_card_or_reference, options = {}) MultiResponse.run(true) do |r| + if credit_card_or_reference.is_a?(String) + r.process { create_token(credit_card_or_reference, options) } + credit_card_or_reference = r.authorization + end r.process { create_payment(money, options) } r.process { post = authorization_params(money, credit_card_or_reference, options) add_autocapture(post, false) - commit(synchronized_path("/payments/#{r.authorization}/authorize"), post) + commit(synchronized_path("/payments/#{r.responses.last.params["id"]}/authorize"), post) } r.process { post = capture_params(money, credit_card_or_reference, options) - commit(synchronized_path("/payments/#{r.authorization}/capture"), post) + commit(synchronized_path("/payments/#{r.responses.last.params["id"]}/capture"), post) } end end def authorize(money, credit_card_or_reference, options = {}) MultiResponse.run(true) do |r| + if credit_card_or_reference.is_a?(String) + r.process { create_token(credit_card_or_reference, options) } + credit_card_or_reference = r.authorization + end r.process { create_payment(money, options) } r.process { post = authorization_params(money, credit_card_or_reference, options) - commit(synchronized_path("/payments/#{r.authorization}/authorize"), post) + commit(synchronized_path("/payments/#{r.responses.last.params["id"]}/authorize"), post) } end end @@ -71,12 +79,10 @@ def store(credit_card, options = {}) MultiResponse.run do |r| r.process { create_store(options) } r.process { authorize_store(r.authorization, credit_card, options)} - r.process { create_token(r.authorization, options.merge({id: r.authorization}))} end end def unstore(identification) - identification = identification.split(";").last commit(synchronized_path "/cards/#{identification}/cancel") end @@ -93,11 +99,11 @@ def scrub(transcript) private - def authorization_params(money, credit_card, options = {}) + def authorization_params(money, credit_card_or_reference, options = {}) post = {} add_amount(post, money, options) - add_credit_card_or_reference(post, credit_card) + add_credit_card_or_reference(post, credit_card_or_reference) add_additional_params(:authorize, post, options) post @@ -126,7 +132,7 @@ def authorize_store(identification, credit_card, options = {}) def create_token(identification, options) post = {} - post[:id] = options[:id] + # post[:id] = options[:id] commit(synchronized_path("/cards/#{identification}/tokens"), post) end @@ -150,15 +156,15 @@ def commit(action, params = {}) Response.new(success, message_from(success, response), response, :test => test?, - :authorization => authorization_from(response, params[:id]) + :authorization => authorization_from(response) ) end - def authorization_from(response, auth_id) + def authorization_from(response) if response["token"] - "#{response["token"]};#{auth_id}" + response["token"].to_s else - response["id"] + response["id"].to_s end end @@ -205,8 +211,7 @@ def add_additional_params(action, post, options = {}) def add_credit_card_or_reference(post, credit_card_or_reference, options = {}) post[:card] ||= {} if credit_card_or_reference.is_a?(String) - reference = credit_card_or_reference.split(";").first - post[:card][:token] = reference + post[:card][:token] = credit_card_or_reference else post[:card][:number] = credit_card_or_reference.number post[:card][:cvd] = credit_card_or_reference.verification_value diff --git a/test/remote/gateways/remote_quickpay_v10_test.rb b/test/remote/gateways/remote_quickpay_v10_test.rb index fe87601ddd7..fa3ea6fe222 100644 --- a/test/remote/gateways/remote_quickpay_v10_test.rb +++ b/test/remote/gateways/remote_quickpay_v10_test.rb @@ -108,7 +108,7 @@ def test_unsuccessful_authorize_and_capture def test_failed_capture assert response = @gateway.capture(@amount, '1111') assert_failure response - assert_equal 'Unknown error - please contact QuickPay', response.message + assert_equal 'Not found: No Payment with id 1111', response.message end def test_successful_purchase_and_void @@ -174,6 +174,23 @@ def test_successful_store_and_reference_purchase assert_success purchase end + def test_successful_store_and_reference_recurring_purchase + assert store = @gateway.store(@valid_card, @options) + assert_success store + assert signup = @gateway.purchase(@amount, store.authorization, @options) + assert_success signup + @options[:order_id] = generate_unique_id[0...10] + assert renewal = @gateway.purchase(@amount, store.authorization, @options) + assert_success renewal + end + + def test_successful_store_and_reference_authorize + assert store = @gateway.store(@valid_card, @options) + assert_success store + assert authorization = @gateway.authorize(@amount, store.authorization, @options) + assert_success authorization + end + def test_successful_unstore assert response = @gateway.store(@valid_card, @options) assert_success response diff --git a/test/unit/gateways/quickpay_v10_test.rb b/test/unit/gateways/quickpay_v10_test.rb index e87ba7f3b0e..cdd88a1938f 100644 --- a/test/unit/gateways/quickpay_v10_test.rb +++ b/test/unit/gateways/quickpay_v10_test.rb @@ -26,7 +26,7 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert response assert_success response - assert_equal 1145, response.authorization + assert_equal "1145", response.authorization assert response.test? end.check_request do |endpoint, data, headers| parsed = parse(data) @@ -45,7 +45,7 @@ def test_successful_authorization stub_comms do assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal 1145, response.authorization + assert_equal "1145", response.authorization assert response.test? end.check_request do |endpoint, data, headers| parsed_data = parse(data) From f8f2be7cf6fbb98c271a43a84956231aaf2adb52 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Wed, 24 May 2017 13:53:16 -0400 Subject: [PATCH 089/677] Ebanx: Add gateway support Closes #2447 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/ebanx.rb | 234 ++++++++++++++++++ test/fixtures.yml | 4 + test/remote/gateways/remote_ebanx_test.rb | 151 +++++++++++ test/unit/gateways/ebanx_test.rb | 208 ++++++++++++++++ 5 files changed, 598 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/ebanx.rb create mode 100644 test/remote/gateways/remote_ebanx_test.rb create mode 100644 test/unit/gateways/ebanx_test.rb diff --git a/CHANGELOG b/CHANGELOG index f5eb6ce4f47..d4b40bd6483 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * Credorax: Add 3D Secure authentication fields [davidsantoso] #2446 * Authorize.net: Pass Level 2 Data Fields [curiousepic] #2444 * Quickpay V10: Fix store and token use for recurring payments [wsmoak] #2180 +* Ebanx: Add gateway support [davidsantoso] #2447 == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb new file mode 100644 index 00000000000..b7a25744bc0 --- /dev/null +++ b/lib/active_merchant/billing/gateways/ebanx.rb @@ -0,0 +1,234 @@ +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class EbanxGateway < Gateway + self.test_url = 'https://sandbox.ebanx.com/ws/' + self.live_url = 'https://api.ebanx.com/ws/' + + self.supported_countries = ['BR', 'CL', 'MX', 'CO', 'PE'] + self.default_currency = 'USD' + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club] + + self.homepage_url = 'http://www.ebanx.com/' + self.display_name = 'Ebanx' + + CARD_BRAND = { + visa: "visa", + master: "master_card", + american_express: "amex", + discover: "discover", + diners_club: "diners" + } + + URL_MAP = { + purchase: "direct", + authorize: "direct", + capture: "capture", + refund: "refund", + void: "cancel" + } + + HTTP_METHOD = { + purchase: :post, + authorize: :post, + capture: :get, + refund: :post, + void: :get + } + + def initialize(options={}) + requires!(options, :integration_key) + super + end + + def purchase(money, payment, options={}) + post = { payment: {} } + add_integration_key(post) + add_operation(post) + add_invoice(post, money, options) + add_customer_data(post, payment, options) + add_payment(post, payment) + add_address(post, options) + + commit(:purchase, post) + end + + def authorize(money, payment, options={}) + post = { payment: {} } + add_integration_key(post) + add_operation(post) + add_invoice(post, money, options) + add_customer_data(post, payment, options) + add_payment(post, payment) + add_address(post, options) + post[:payment][:creditcard][:auto_capture] = false + + commit(:authorize, post) + end + + def capture(money, authorization, options={}) + post = {} + add_integration_key(post) + post[:hash] = authorization + post[:amount] = amount(money) + + commit(:capture, post) + end + + def refund(money, authorization, options={}) + post = {} + add_integration_key(post) + add_operation(post) + add_authorization(post, authorization) + post[:amount] = amount(money) + post[:description] = options[:description] + + commit(:refund, post) + end + + def void(authorization, options={}) + post = {} + add_integration_key(post) + add_authorization(post, authorization) + + commit(:void, post) + end + + def verify(credit_card, options={}) + MultiResponse.run(:use_first_response) do |r| + r.process { authorize(100, credit_card, options) } + r.process(:ignore_result) { void(r.authorization, options) } + end + end + + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(/(integration_key\\?":\\?")(\d*)/, '\1[FILTERED]'). + gsub(/(card_number\\?":\\?")(\d*)/, '\1[FILTERED]'). + gsub(/(card_cvv\\?":\\?")(\d*)/, '\1[FILTERED]') + end + + private + + def add_integration_key(post) + post[:integration_key] = @options[:integration_key].to_s + end + + def add_operation(post) + post[:operation] = "request" + end + + def add_authorization(post, authorization) + post[:hash] = authorization + end + + def add_customer_data(post, payment, options) + post[:payment][:name] = payment.name + post[:payment][:email] = options[:email] || "unspecified@example.com" + post[:payment][:document] = options[:document] + end + + def add_address(post, options) + if address = options[:billing_address] || options[:address] + post[:payment][:address] = address[:address1].split[1..-1].join(" ") if address[:address1] + post[:payment][:street_number] = address[:address1].split.first if address[:address1] + post[:payment][:city] = address[:city] + post[:payment][:state] = address[:state] + post[:payment][:zipcode] = address[:zip] + post[:payment][:country] = address[:country] + post[:payment][:phone_number] = address[:phone] + end + end + + def add_invoice(post, money, options) + post[:payment][:amount_total] = amount(money) + post[:payment][:currency_code] = (options[:currency] || currency(money)) + post[:payment][:merchant_payment_code] = options[:order_id] + end + + def add_payment(post, payment) + post[:payment][:payment_type_code] = CARD_BRAND[payment.brand.to_sym] + post[:payment][:creditcard] = { + card_number: payment.number, + card_name: payment.name, + card_due_date: "#{payment.month}/#{payment.year}", + card_cvv: payment.verification_value + } + end + + def parse(body) + JSON.parse(body) + end + + def commit(action, parameters) + url = url_for((test? ? test_url : live_url), action, parameters) + response = parse(ssl_request(HTTP_METHOD[action], url, post_data(action, parameters), {})) + + success = success_from(action, response) + + Response.new( + success, + message_from(response), + response, + authorization: authorization_from(response), + test: test?, + error_code: error_code_from(response, success) + ) + end + + def success_from(action, response) + if [:purchase, :capture, :refund].include?(action) + response.try(:[], "payment").try(:[], "status") == "CO" + elsif action == :authorize + response.try(:[], "payment").try(:[], "status") == "PE" + elsif action == :void + response.try(:[], "payment").try(:[], "status") == "CA" + else + false + end + end + + def message_from(response) + return response["status_message"] if response["status"] == "ERROR" + response.try(:[], "payment").try(:[], "transaction_status").try(:[], "description") + end + + def authorization_from(response) + response.try(:[], "payment").try(:[], "hash") + end + + def post_data(action, parameters = {}) + return nil if requires_http_get(action) + return convert_to_url_form_encoded(parameters) if action == :refund + "request_body=#{parameters.to_json}" + end + + def url_for(hostname, action, parameters) + return hostname + URL_MAP[action] + "?#{convert_to_url_form_encoded(parameters)}" if requires_http_get(action) + hostname + URL_MAP[action] + end + + def requires_http_get(action) + return true if [:capture, :void].include?(action) + false + end + + def convert_to_url_form_encoded(parameters) + parameters.map do |key, value| + next if value != false && value.blank? + "#{key}=#{value}" + end.compact.join("&") + end + + def error_code_from(response, success) + unless success + return response["status_code"] if response["status"] == "ERROR" + response.try(:[], "payment").try(:[], "transaction_status").try(:[], "code") + end + end + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index 99e26d138e0..7a974464df0 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -238,6 +238,10 @@ digitzs: direc_pay: login: 200904281000001 +# Working credentials, no need to replace +ebanx: + integration_key: 1231000 + efsnet: login: X password: Y diff --git a/test/remote/gateways/remote_ebanx_test.rb b/test/remote/gateways/remote_ebanx_test.rb new file mode 100644 index 00000000000..fdf599bfd75 --- /dev/null +++ b/test/remote/gateways/remote_ebanx_test.rb @@ -0,0 +1,151 @@ +require 'test_helper' + +class RemoteEbanxTest < Test::Unit::TestCase + def setup + @gateway = EbanxGateway.new(fixtures(:ebanx)) + + @amount = 100 + @credit_card = credit_card('4111111111111111') + @declined_card = credit_card('4716909774636285') + @options = { + billing_address: address({ + address1: '1040 Rua E', + city: 'Maracanaú', + state: 'CE', + zip: '61919-230', + country: 'BR', + phone_number: '8522847035' + }), + order_id: generate_unique_id, + document: "853.513.468-93" + } + end + + def test_successful_purchase + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Sandbox - Test credit card, transaction captured', response.message + end + + def test_successful_purchase_with_more_options + options = @options.merge({ + order_id: generate_unique_id, + ip: "127.0.0.1", + email: "joe@example.com" + }) + + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_equal 'Sandbox - Test credit card, transaction captured', response.message + end + + def test_failed_purchase + response = @gateway.purchase(@amount, @declined_card, @options) + assert_failure response + assert_equal 'Sandbox - Test credit card, transaction declined reason insufficientFunds', response.message + assert_equal 'NOK', response.error_code + end + + def test_successful_authorize_and_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + assert_equal 'Sandbox - Test credit card, transaction will be approved', auth.message + + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + assert_equal 'Sandbox - Test credit card, transaction captured', capture.message + end + + def test_failed_authorize + response = @gateway.authorize(@amount, @declined_card, @options) + assert_failure response + assert_equal 'Sandbox - Test credit card, transaction declined reason insufficientFunds', response.message + assert_equal 'NOK', response.error_code + end + + def test_partial_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount-1, auth.authorization) + assert_success capture + end + + def test_failed_capture + response = @gateway.capture(@amount, '') + assert_failure response + assert_equal 'Parameters hash or merchant_payment_code not informed', response.message + end + + def test_successful_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + refund_options = @options.merge({description: "full refund"}) + assert refund = @gateway.refund(@amount, purchase.authorization, refund_options) + assert_success refund + assert_equal 'Sandbox - Test credit card, transaction captured', refund.message + end + + def test_partial_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + refund_options = @options.merge(description: "refund due to returned item") + assert refund = @gateway.refund(@amount-1, purchase.authorization, refund_options) + assert_success refund + end + + def test_failed_refund + response = @gateway.refund(@amount, '') + assert_failure response + assert_match('Parameter hash not informed', response.message) + end + + def test_successful_void + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert void = @gateway.void(auth.authorization) + assert_success void + assert_equal 'Sandbox - Test credit card, transaction cancelled', void.message + end + + def test_failed_void + response = @gateway.void('') + assert_failure response + assert_equal 'Parameter hash not informed', response.message + end + + def test_successful_verify + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_match %r{Sandbox - Test credit card, transaction will be approved}, response.message + end + + def test_failed_verify + response = @gateway.verify(@declined_card, @options) + assert_failure response + assert_match %r{Sandbox - Test credit card, transaction declined reason insufficientFunds}, response.message + end + + def test_invalid_login + gateway = EbanxGateway.new(integration_key: '') + + response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_match %r{Field integration_key is required}, response.message + end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:integration_key], transcript) + end + +end diff --git a/test/unit/gateways/ebanx_test.rb b/test/unit/gateways/ebanx_test.rb new file mode 100644 index 00000000000..35cf38cec91 --- /dev/null +++ b/test/unit/gateways/ebanx_test.rb @@ -0,0 +1,208 @@ +require 'test_helper' + +class EbanxTest < Test::Unit::TestCase + def setup + @gateway = EbanxGateway.new(integration_key: 'key') + @credit_card = credit_card + @amount = 100 + + @options = { + order_id: '1', + billing_address: address, + description: 'Store Purchase' + } + end + + def test_successful_purchase + @gateway.expects(:ssl_request).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + + assert_equal '592db57ad6933455efbb62a48d1dfa091dd7cd092109db99', response.authorization + assert response.test? + end + + def test_failed_purchase + @gateway.expects(:ssl_request).returns(failed_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal "NOK", response.error_code + end + + def test_successful_authorize + @gateway.expects(:ssl_request).returns(successful_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + + assert_equal '592dc02dbe421478a132bf5c2ecfe52c86ac01b454ae799b', response.authorization + assert response.test? + end + + def test_failed_authorize + @gateway.expects(:ssl_request).returns(failed_authorize_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal "NOK", response.error_code + end + + def test_successful_capture + @gateway.expects(:ssl_request).returns(successful_capture_response) + + response = @gateway.capture(@amount, "authorization", @options) + assert_success response + + assert_equal 'Sandbox - Test credit card, transaction captured', response.message + assert response.test? + end + + def test_failed_capture + @gateway.expects(:ssl_request).returns(failed_capture_response) + + response = @gateway.capture(@amount, "", @options) + assert_failure response + assert_equal "BP-CAP-1", response.error_code + end + + def test_successful_refund + @gateway.expects(:ssl_request).returns(successful_refund_response) + + response = @gateway.refund(@amount, "authorization", @options) + assert_success response + + assert_equal '59306246f2a0c5f327a15dd6492687e197aca7eda179da08', response.authorization + assert response.test? + end + + def test_failed_refund + @gateway.expects(:ssl_request).returns(failed_refund_response) + + response = @gateway.refund(@amount, "", @options) + assert_failure response + assert_equal "BP-REF-CAN-2", response.error_code + end + + def test_successful_void + @gateway.expects(:ssl_request).returns(successful_void_response) + + response = @gateway.void("authorization", @options) + assert_success response + + assert_equal '5930629dde0899dc53b3557ea9887aa8f3d264a91d115d40', response.authorization + assert response.test? + end + + def test_failed_void + @gateway.expects(:ssl_request).returns(failed_void_response) + + response = @gateway.void("", @options) + assert_failure response + assert_equal "BP-CAN-1", response.error_code + end + + def test_successful_verify + @gateway.expects(:ssl_request).times(2).returns(successful_authorize_response, successful_void_response) + + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_equal nil, response.error_code + end + + def test_successful_verify_with_failed_void + @gateway.expects(:ssl_request).times(2).returns(successful_authorize_response, failed_void_response) + + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_equal nil, response.error_code + end + + def test_failed_verify + @gateway.expects(:ssl_request).returns(failed_authorize_response) + + response = @gateway.verify(@credit_card, @options) + assert_failure response + assert_equal "NOK", response.error_code + end + + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + + private + + def pre_scrubbed + %q( + 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\"}} + ) + end + + def post_scrubbed + %q( + request_body={\"integration_key\":\"[FILTERED]\",\"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\":\"[FILTERED]\",\"card_name\":\"Longbob Longsen\",\"card_due_date\":\"9/2018\",\"card_cvv\":\"[FILTERED]\"},\"address\":\"Rua E\",\"street_number\":\"1040\",\"city\":\"Maracana\u{fa}\",\"state\":\"CE\",\"zipcode\":\"61919-230\",\"country\":\"BR\",\"phone_number\":\"(555)555-5555\"}} + ) + end + + def successful_purchase_response + %( + {"payment":{"hash":"592db57ad6933455efbb62a48d1dfa091dd7cd092109db99","pin":"081043552","merchant_payment_code":"ca2251ed6ac582162b17d77dfd7fb98a","order_number":null,"status":"CO","status_date":"2017-05-30 15:10:01","open_date":"2017-05-30 15:10:01","confirm_date":"2017-05-30 15:10:01","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"} + ) + end + + def failed_purchase_response + %( + {"payment":{"hash":"592dd2f17965cd3d7a17e71a3fe943b8363c72d60caffacc","pin":"655998606","merchant_payment_code":"e71e467805aef9064599bc5a76e98e23","order_number":null,"status":"CA","status_date":"2017-05-30 17:15:45","open_date":"2017-05-30 17:15:45","confirm_date":null,"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":"NOK","description":"Sandbox - Test credit card, transaction declined reason insufficientFunds"},"pre_approved":false,"capture_available":false,"customer":{"document":"85351346893","email":"unspecified@example.com","name":"LONGBOB LONGSEN","birth_date":null}},"status":"SUCCESS"} + ) + end + + def successful_authorize_response + %( + {"payment":{"hash":"592dc02dbe421478a132bf5c2ecfe52c86ac01b454ae799b","pin":"296389224","merchant_payment_code":"8e5c943c3c93adbed8d8a7347ca333fe","order_number":null,"status":"PE","status_date":null,"open_date":"2017-05-30 15:55:40","confirm_date":null,"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 will be approved"},"pre_approved":true,"capture_available":true,"customer":{"document":"85351346893","email":"unspecified@example.com","name":"LONGBOB LONGSEN","birth_date":null}},"status":"SUCCESS"} + ) + end + + def failed_authorize_response + %( + {"payment":{"hash":"592dd2146d5b8a27924daaa0f0248d8c582cb2ce6b67495e","pin":"467618452","merchant_payment_code":"7883bdbbdfa961ce753247fbeb4ff99d","order_number":null,"status":"CA","status_date":"2017-05-30 17:12:03","open_date":"2017-05-30 17:12:03","confirm_date":null,"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":"NOK","description":"Sandbox - Test credit card, transaction declined reason insufficientFunds"},"pre_approved":false,"capture_available":false,"customer":{"document":"85351346893","email":"unspecified@example.com","name":"LONGBOB LONGSEN","birth_date":null}},"status":"SUCCESS"} + ) + end + + 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"} + ) + end + + def failed_capture_response + %( + {"status":"ERROR","status_code":"BP-CAP-1","status_message":"Parameters hash or merchant_payment_code not informed"} + ) + end + + def successful_refund_response + %( + {"payment":{"hash":"59306246f2a0c5f327a15dd6492687e197aca7eda179da08","pin":"446189033","merchant_payment_code":"b5e1f7298f8fa645e8a903fbdc5ce44a","order_number":null,"status":"CO","status_date":"2017-06-01 15:51:49","open_date":"2017-06-01 15:51:49","confirm_date":"2017-06-01 15:51:49","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-04","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,"refunds":[{"id":"20739","merchant_refund_code":null,"status":"RE","request_date":"2017-06-01 15:51:50","pending_date":null,"confirm_date":null,"cancel_date":null,"amount_ext":"1.00","description":"full refund"}],"customer":{"document":"85351346893","email":"unspecified@example.com","name":"LONGBOB LONGSEN","birth_date":null}},"refund":{"id":"20739","merchant_refund_code":null,"status":"RE","request_date":"2017-06-01 15:51:50","pending_date":null,"confirm_date":null,"cancel_date":null,"amount_ext":"1.00","description":"full refund"},"operation":"refund","status":"SUCCESS"} + ) + end + + def failed_refund_response + %( + {"status":"ERROR","status_code":"BP-REF-CAN-2","status_message":"Payment not found with this hash: "} + ) + end + + def successful_void_response + %( + {"payment":{"hash":"5930629dde0899dc53b3557ea9887aa8f3d264a91d115d40","pin":"465556618","merchant_payment_code":"8b97c49aecffbb309dadd08c87ccbdd0","order_number":null,"status":"CA","status_date":"2017-06-01 15:53:18","open_date":"2017-06-01 15:53:17","confirm_date":null,"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-04","instalments":"1","payment_type_code":"visa","transaction_status":{"acquirer":"EBANX","code":"NOK","description":"Sandbox - Test credit card, transaction cancelled"},"pre_approved":false,"capture_available":false,"customer":{"document":"85351346893","email":"unspecified@example.com","name":"LONGBOB LONGSEN","birth_date":null}},"operation":"cancel","status":"SUCCESS"} + ) + end + + def failed_void_response + %( + {"status":"ERROR","status_code":"BP-CAN-1","status_message":"Parameter hash not informed"} + ) + end +end From a2095cf4d7ade90015c99877059a0e633f287fb2 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Tue, 6 Jun 2017 16:36:18 -0400 Subject: [PATCH 090/677] Acapture: Pass 3D Secure fields Closes #2451 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/opp.rb | 71 ++++++++++++--------- test/unit/gateways/opp_test.rb | 16 +++++ 3 files changed, 58 insertions(+), 30 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d4b40bd6483..66678c8333d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * Authorize.net: Pass Level 2 Data Fields [curiousepic] #2444 * Quickpay V10: Fix store and token use for recurring payments [wsmoak] #2180 * Ebanx: Add gateway support [davidsantoso] #2447 +* Acapture: Pass 3D Secure fields [davidsantoso] #2451 == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb index 865bd43559b..2640ad7f925 100644 --- a/lib/active_merchant/billing/gateways/opp.rb +++ b/lib/active_merchant/billing/gateways/opp.rb @@ -1,7 +1,7 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class OppGateway < Gateway -# = Open Payment Platform + # = Open Payment Platform # # The Open Payment Platform includes a powerful omni-channel transaction processing API, # enabling you to quickly and flexibly build new applications and services on the platform. @@ -20,7 +20,7 @@ class OppGateway < Gateway # # # set up credit card object as in main ActiveMerchant example # creditcard = ActiveMerchant::Billing::CreditCard.new( - # :type => 'visa', + # :type => 'visa', # :number => '4242424242424242', # :month => 8, # :year => 2009, @@ -177,6 +177,7 @@ def execute_dbpa(txtype, money, payment, options) add_address(post, options) add_customer_data(post, payment, options) add_options(post, options) + add_3d_secure(post, options) commit(post, nil, options) end @@ -223,40 +224,50 @@ def add_address(post, options) end def address(post, address, prefix) - post[prefix] = { - street1: address[:address1], - street2: address[:address2], - city: address[:city], - state: address[:state], - postcode: address[:zip], - country: address[:country], - } + post[prefix] = { + street1: address[:address1], + street2: address[:address2], + city: address[:city], + state: address[:state], + postcode: address[:zip], + country: address[:country], + } end def add_invoice(post, money, options) - post[:amount] = amount(money) - post[:currency] = options[:currency] || currency(money) unless post[:paymentType] == 'RV' - post[:descriptor] = options[:description] || options[:descriptor] - post[:merchantInvoiceId] = options[:merchantInvoiceId] || options[:order_id] - post[:merchantTransactionId] = options[:merchant_transaction_id] || generate_unique_id + post[:amount] = amount(money) + post[:currency] = options[:currency] || currency(money) unless post[:paymentType] == 'RV' + post[:descriptor] = options[:description] || options[:descriptor] + post[:merchantInvoiceId] = options[:merchantInvoiceId] || options[:order_id] + post[:merchantTransactionId] = options[:merchant_transaction_id] || generate_unique_id end def add_payment_method(post, payment, options) - if options[:registrationId] - #post[:recurringType] = 'REPEATED' - post[:card] = { - cvv: payment.verification_value, - } - else - post[:paymentBrand] = payment.brand.upcase - post[:card] = { - holder: payment.name, - number: payment.number, - expiryMonth: "%02d" % payment.month, - expiryYear: payment.year, - cvv: payment.verification_value, - } - end + if options[:registrationId] + #post[:recurringType] = 'REPEATED' + post[:card] = { + cvv: payment.verification_value, + } + else + post[:paymentBrand] = payment.brand.upcase + post[:card] = { + holder: payment.name, + number: payment.number, + expiryMonth: "%02d" % payment.month, + expiryYear: payment.year, + cvv: payment.verification_value, + } + end + end + + def add_3d_secure(post, options) + return unless options[:eci] && options[:cavv] && options[:xid] + + post[:threeDSecure] = { + eci: options[:eci], + verificationId: options[:cavv], + xid: options[:xid] + } end def add_options(post, options) diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb index 64d2e823b83..783d34e887c 100644 --- a/test/unit/gateways/opp_test.rb +++ b/test/unit/gateways/opp_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class OppTest < Test::Unit::TestCase + include CommStub + def setup @gateway = OppGateway.new(fixtures(:opp)) @amount = 100 @@ -155,6 +157,20 @@ def test_failed_void assert_equal '100.100.101', response.error_code end + def test_passes_3d_secure_fields + options = @complete_request_options.merge({eci: "eci", cavv: "cavv", xid: "xid"}) + + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.purchase(@amount, @valid_card, options) + end.check_request do |method, endpoint, data, headers| + assert_match(/threeDSecure.eci=eci/, data) + assert_match(/threeDSecure.verificationId=cavv/, data) + assert_match(/threeDSecure.xid=xid/, data) + end.respond_with(successful_response('DB', @test_success_id)) + + assert_success response + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed From 2dd0ef02709e160ca71773ae118dff33838771d0 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Wed, 7 Jun 2017 11:19:34 -0400 Subject: [PATCH 091/677] Ebanx: Reduce supported countries to Brazil and Mexico In Colombia, Chile, and Peru Ebanx only supports alternative payment methods which are not supported in Active Merchant. This reduces the supported countries list to only Brazil and Mexico where Ebanx supports plain credit card data. --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/ebanx.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 66678c8333d..186536aadcb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Quickpay V10: Fix store and token use for recurring payments [wsmoak] #2180 * Ebanx: Add gateway support [davidsantoso] #2447 * Acapture: Pass 3D Secure fields [davidsantoso] #2451 +* Ebanx: Reduce supported countries to Brazil and Mexico [davidsantoso] == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb index b7a25744bc0..8d00800b335 100644 --- a/lib/active_merchant/billing/gateways/ebanx.rb +++ b/lib/active_merchant/billing/gateways/ebanx.rb @@ -4,7 +4,7 @@ class EbanxGateway < Gateway self.test_url = 'https://sandbox.ebanx.com/ws/' self.live_url = 'https://api.ebanx.com/ws/' - self.supported_countries = ['BR', 'CL', 'MX', 'CO', 'PE'] + self.supported_countries = ['BR', 'MX'] self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club] From 85996676bcc9c49b85dafa6837bfd1d2b335be60 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Thu, 25 May 2017 13:25:18 -0400 Subject: [PATCH 092/677] Payeezy: Add customer_id_type and customer_id_number fields For some merchant accounts, Payeezy requires these fields to be sent if the payment method type is an eCheck. Unfortunately Payeezy has a pretty strong definition of what an eCheck is vs a bank account and eCheck being interchangeable. For merchants who's accounts require these fields, this allows them to pass them along with their eCheck transaction. Closes #2454 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/payeezy.rb | 12 +++++++----- test/remote/gateways/remote_payeezy_test.rb | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 186536aadcb..44ec4b6cd1b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * Ebanx: Add gateway support [davidsantoso] #2447 * Acapture: Pass 3D Secure fields [davidsantoso] #2451 * Ebanx: Reduce supported countries to Brazil and Mexico [davidsantoso] +* Payeezy: Add customer_id_type and customer_id_number fields [davidsantoso] #2454 == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index 3cafb5727f5..3eec4240491 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -34,7 +34,7 @@ def purchase(amount, payment_method, options = {}) params = {transaction_type: 'purchase'} add_invoice(params, options) - add_payment_method(params, payment_method) + add_payment_method(params, payment_method, options) add_address(params, options) add_amount(params, amount, options) add_soft_descriptors(params, options) @@ -46,7 +46,7 @@ def authorize(amount, payment_method, options = {}) params = {transaction_type: 'authorize'} add_invoice(params, options) - add_payment_method(params, payment_method) + add_payment_method(params, payment_method, options) add_address(params, options) add_amount(params, amount, options) add_soft_descriptors(params, options) @@ -119,9 +119,9 @@ def add_authorization_info(params, authorization) params[:method] = method end - def add_payment_method(params, payment_method) + def add_payment_method(params, payment_method, options) if payment_method.is_a? Check - add_echeck(params, payment_method) + add_echeck(params, payment_method, options) else add_creditcard(params, payment_method) end @@ -140,7 +140,7 @@ def add_creditcard(params, creditcard) params[:credit_card] = credit_card end - def add_echeck(params, echeck) + def add_echeck(params, echeck, options) tele_check = {} tele_check[:check_number] = echeck.number || "001" @@ -148,6 +148,8 @@ def add_echeck(params, echeck) tele_check[:routing_number] = echeck.routing_number tele_check[:account_number] = echeck.account_number tele_check[:accountholder_name] = "#{echeck.first_name} #{echeck.last_name}" + tele_check[:customer_id_type] = options[:customer_id_type] if options[:customer_id_type] + tele_check[:customer_id_number] = options[:customer_id_number] if options[:customer_id_number] params[:method] = 'tele_check' params[:tele_check] = tele_check diff --git a/test/remote/gateways/remote_payeezy_test.rb b/test/remote/gateways/remote_payeezy_test.rb index 09cba168374..ee7e841edce 100644 --- a/test/remote/gateways/remote_payeezy_test.rb +++ b/test/remote/gateways/remote_payeezy_test.rb @@ -33,7 +33,8 @@ def test_successful_purchase end def test_successful_purchase_with_echeck - assert response = @gateway.purchase(@amount, @check, @options) + options = @options.merge({customer_id_type: "1", customer_id_number: "1"}) + assert response = @gateway.purchase(@amount, @check, options) assert_match(/Transaction Normal/, response.message) assert_success response end From ccfc678b3ce06ce650328bcc88ff850b5aa1fbd0 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Wed, 7 Jun 2017 17:08:59 -0400 Subject: [PATCH 093/677] Payeezy: Add client_email field for telecheck Closes #2455 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/payeezy.rb | 1 + test/remote/gateways/remote_payeezy_test.rb | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 44ec4b6cd1b..c86b80df844 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * Acapture: Pass 3D Secure fields [davidsantoso] #2451 * Ebanx: Reduce supported countries to Brazil and Mexico [davidsantoso] * Payeezy: Add customer_id_type and customer_id_number fields [davidsantoso] #2454 +* Payeezy: Add client_email field for telecheck [davidsantoso] #2455 == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index 3eec4240491..206b122442f 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -150,6 +150,7 @@ def add_echeck(params, echeck, options) tele_check[:accountholder_name] = "#{echeck.first_name} #{echeck.last_name}" tele_check[:customer_id_type] = options[:customer_id_type] if options[:customer_id_type] tele_check[:customer_id_number] = options[:customer_id_number] if options[:customer_id_number] + tele_check[:client_email] = options[:client_email] if options[:client_email] params[:method] = 'tele_check' params[:tele_check] = tele_check diff --git a/test/remote/gateways/remote_payeezy_test.rb b/test/remote/gateways/remote_payeezy_test.rb index ee7e841edce..ebfa6cb36a6 100644 --- a/test/remote/gateways/remote_payeezy_test.rb +++ b/test/remote/gateways/remote_payeezy_test.rb @@ -33,7 +33,7 @@ def test_successful_purchase end def test_successful_purchase_with_echeck - options = @options.merge({customer_id_type: "1", customer_id_number: "1"}) + options = @options.merge({customer_id_type: "1", customer_id_number: "1", client_email: "test@example.com"}) assert response = @gateway.purchase(@amount, @check, options) assert_match(/Transaction Normal/, response.message) assert_success response From b70159ab14fbb934efe035f5bf61bf65537f313e Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Mon, 5 Jun 2017 14:04:19 -0400 Subject: [PATCH 094/677] FirstData Payeezy: Set default ECI value for auth/purchase transactions I've heard from a few users that this gateway (and/or their processors behind it) are now soft-requiring the ECI indicator to always be set. Typical of this gateway, [documentation is unclear at best](https://support.payeezy.com/hc/en-us/articles/206601408-First-Data-Payeezy-Gateway-Web-Service-API-Reference-Guide). I've done this in such a way that all previous cases were accounted for, and a 3DS/network transaction's embedded value will always take precedence. Closes #2448 --- CHANGELOG | 1 + .../billing/gateways/firstdata_e4.rb | 8 +++++--- test/unit/gateways/firstdata_e4_test.rb | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c86b80df844..76256190012 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * Ebanx: Reduce supported countries to Brazil and Mexico [davidsantoso] * Payeezy: Add customer_id_type and customer_id_number fields [davidsantoso] #2454 * Payeezy: Add client_email field for telecheck [davidsantoso] #2455 +* FirstData Payeezy: Set default ECI value for auth/purchase transactions [jasonwebster] #2448 == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index 27e5c94cfec..f31427bc773 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -34,6 +34,8 @@ class FirstdataE4Gateway < Gateway E4_BRANDS = BRANDS.merge({:mastercard => "Mastercard"}) + DEFAULT_ECI = "07" + self.supported_cardtypes = BRANDS.keys self.supported_countries = ["CA", "US"] self.default_currency = "USD" @@ -235,6 +237,9 @@ def add_credit_card(xml, credit_card, options) xml.tag! "CardHoldersName", credit_card.name xml.tag! "CardType", card_type(credit_card.brand) + eci = (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI + xml.tag! "Ecommerce_Flag", eci + add_credit_card_verification_strings(xml, credit_card, options) end end @@ -256,8 +261,6 @@ def add_credit_card_verification_strings(xml, credit_card, options) end def add_network_tokenization_credit_card(xml, credit_card) - xml.tag!("Ecommerce_Flag", credit_card.eci) - case card_brand(credit_card).to_sym when :visa xml.tag!("XID", credit_card.transaction_id) if credit_card.transaction_id @@ -275,7 +278,6 @@ def add_network_tokenization_credit_card(xml, credit_card) def add_card_authentication_data(xml, options) xml.tag! "CAVV", options[:cavv] xml.tag! "XID", options[:xid] - xml.tag! "Ecommerce_Flag", options[:eci] end def add_credit_card_token(xml, store_authorization) diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb index 67739fd4b43..7b832be6e24 100755 --- a/test/unit/gateways/firstdata_e4_test.rb +++ b/test/unit/gateways/firstdata_e4_test.rb @@ -181,6 +181,22 @@ def test_customer_ref_is_sent end.respond_with(successful_purchase_response) end + def test_eci_default_value + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match "07", data + end.respond_with(successful_purchase_response) + end + + def test_eci_option_value + stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(eci: "05")) + end.check_request do |endpoint, data, headers| + assert_match "05", data + end.respond_with(successful_purchase_response) + end + def test_network_tokenization_requests_with_visa stub_comms do credit_card = network_tokenization_credit_card('4111111111111111', From ad9be46617e6958f9a9c7e594f33ed8a4af47db8 Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Thu, 8 Jun 2017 10:46:20 -0400 Subject: [PATCH 095/677] Release version 1.67.0 --- CHANGELOG | 22 ++++++++++++---------- lib/active_merchant/version.rb | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 76256190012..fe90d0e8160 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,20 +1,22 @@ = ActiveMerchant CHANGELOG == HEAD -* NMI: Add Network Tokenization support [shasum] #2431 -* JetPay V2: Add new gateway [shasum] #2442 -* Orbital: Update test and production urls [jcowhigjr] #2436 -* Orbital: Pass soft descriptors from options hash [curiousepic] -* JetPay V2: Add optional tax data to capture calls [shasum] #2445 -* Credorax: Add 3D Secure authentication fields [davidsantoso] #2446 + +== Version 1.67.0 (June 8, 2017) +* Acapture: Pass 3D Secure fields [davidsantoso] #2451 * Authorize.net: Pass Level 2 Data Fields [curiousepic] #2444 -* Quickpay V10: Fix store and token use for recurring payments [wsmoak] #2180 +* Credorax: Add 3D Secure authentication fields [davidsantoso] #2446 * Ebanx: Add gateway support [davidsantoso] #2447 -* Acapture: Pass 3D Secure fields [davidsantoso] #2451 * Ebanx: Reduce supported countries to Brazil and Mexico [davidsantoso] -* Payeezy: Add customer_id_type and customer_id_number fields [davidsantoso] #2454 -* Payeezy: Add client_email field for telecheck [davidsantoso] #2455 * FirstData Payeezy: Set default ECI value for auth/purchase transactions [jasonwebster] #2448 +* JetPay V2: Add new gateway [shasum] #2442 +* JetPay V2: Add optional tax data to capture calls [shasum] #2445 +* NMI: Add Network Tokenization support [shasum] #2431 +* Orbital: Pass soft descriptors from options hash [curiousepic] +* Orbital: Update test and production urls [jcowhigjr] #2436 +* Payeezy: Add client_email field for telecheck [davidsantoso] #2455 +* Payeezy: Add customer_id_type and customer_id_number fields [davidsantoso] #2454 +* Quickpay V10: Fix store and token use for recurring payments [wsmoak] #2180 == Version 1.66.0 (May 4, 2017) * Support Rails 5.1 [jhawthorn] #2407 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 03038b6a665..fed970f4dc2 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.66.0" + VERSION = "1.67.0" end From 217245061fd051df96465369c0acf2f540ea709c Mon Sep 17 00:00:00 2001 From: David Santoso Date: Thu, 8 Jun 2017 15:12:18 -0400 Subject: [PATCH 096/677] Moneris: Add 3DS fields for decrypted Apple and Android Pay data Closes #2457 --- CHANGELOG | 1 + .../billing/gateways/moneris.rb | 32 ++++++++++++------- test/remote/gateways/remote_moneris_test.rb | 12 +++++++ 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fe90d0e8160..66171abd133 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Moneris: Add 3DS fields for decrypted Apple and Android Pay data [davidsantoso] #2457 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb index 5449d553fb8..cb98b443d2a 100644 --- a/lib/active_merchant/billing/gateways/moneris.rb +++ b/lib/active_merchant/billing/gateways/moneris.rb @@ -181,21 +181,23 @@ def expdate(creditcard) sprintf("%.4i", creditcard.year)[-2..-1] + sprintf("%.2i", creditcard.month) end - def add_payment_source(post, source, options) - if source.is_a?(String) - post[:data_key] = source + def add_payment_source(post, payment_method, options) + if payment_method.is_a?(String) + post[:data_key] = payment_method post[:cust_id] = options[:customer] else - if source.respond_to?(:track_data) && source.track_data.present? + if payment_method.respond_to?(:track_data) && payment_method.track_data.present? post[:pos_code] = '00' - post[:track2] = source.track_data + post[:track2] = payment_method.track_data else - post[:pan] = source.number - post[:expdate] = expdate(source) - post[:cvd_value] = source.verification_value if source.verification_value? - post[:cavv] = source.payment_cryptogram if source.is_a?(NetworkTokenizationCreditCard) + post[:pan] = payment_method.number + post[:expdate] = expdate(payment_method) + post[:cvd_value] = payment_method.verification_value if payment_method.verification_value? + post[:cavv] = payment_method.payment_cryptogram if payment_method.is_a?(NetworkTokenizationCreditCard) + post[:wallet_indicator] = wallet_indicator(payment_method.source.to_s) if payment_method.is_a?(NetworkTokenizationCreditCard) + post[:crypt_type] = (payment_method.eci || 7) if payment_method.is_a?(NetworkTokenizationCreditCard) end - post[:cust_id] = options[:customer] || source.name + post[:cust_id] = options[:customer] || payment_method.name end end @@ -310,6 +312,12 @@ def cvd_element(cvd_value) element end + def wallet_indicator(token_source) + return 'APP' if token_source == 'apple_pay' + return 'ANP' if token_source == 'android_pay' + nil + end + def message_from(message) return 'Unspecified error' if message.blank? message.gsub(/[^\w]/, ' ').split.join(" ").capitalize @@ -324,8 +332,8 @@ def actions "indrefund" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], "completion" => [:order_id, :comp_amount, :txn_number, :crypt_type], "purchasecorrection" => [:order_id, :txn_number, :crypt_type], - "cavv_preauth" => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv], - "cavv_purchase" => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv], + "cavv_preauth" => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator], + "cavv_purchase" => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator], "transact" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], "Batchcloseall" => [], "opentotals" => [:ecr_number], diff --git a/test/remote/gateways/remote_moneris_test.rb b/test/remote/gateways/remote_moneris_test.rb index 8d0bc4cc103..59be37db9eb 100644 --- a/test/remote/gateways/remote_moneris_test.rb +++ b/test/remote/gateways/remote_moneris_test.rb @@ -32,6 +32,18 @@ def test_successful_purchase_with_network_tokenization assert_false response.authorization.blank? end + def test_successful_purchase_with_network_tokenization_apple_pay_source + @credit_card = network_tokenization_credit_card('4242424242424242', + payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + verification_value: nil, + source: :apple_pay + ) + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Approved', response.message + assert_false response.authorization.blank? + end + def test_successful_authorization response = @gateway.authorize(@amount, @credit_card, @options) assert_success response From f0e267bbfdc430fa72574a826a2ecb87dca19e55 Mon Sep 17 00:00:00 2001 From: Hossam Hossny Date: Mon, 6 Mar 2017 20:16:12 +0200 Subject: [PATCH 097/677] Trexle: Add gateway support Closes #2351 --- CHANGELOG | 1 + .../billing/gateways/trexle.rb | 217 +++++++++ test/fixtures.yml | 4 + test/remote/gateways/remote_trexle_test.rb | 170 +++++++ test/unit/gateways/trexle_test.rb | 444 ++++++++++++++++++ 5 files changed, 836 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/trexle.rb create mode 100644 test/remote/gateways/remote_trexle_test.rb create mode 100644 test/unit/gateways/trexle_test.rb diff --git a/CHANGELOG b/CHANGELOG index 66171abd133..af6e36c22eb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * Moneris: Add 3DS fields for decrypted Apple and Android Pay data [davidsantoso] #2457 +* Trexle: Add gateway support [hossamhossny] #2351 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/trexle.rb b/lib/active_merchant/billing/gateways/trexle.rb new file mode 100644 index 00000000000..e50c72d481c --- /dev/null +++ b/lib/active_merchant/billing/gateways/trexle.rb @@ -0,0 +1,217 @@ +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class TrexleGateway < Gateway + self.test_url = 'https://core.trexle.com/api/v1' + self.live_url = 'https://core.trexle.com/api/v1' + + self.default_currency = 'USD' + self.money_format = :cents + self.supported_countries = %w(AD AE AT AU BD BE BG BN CA CH CY CZ DE DK EE EG ES FI FR GB + GI GR HK HU ID IE IL IM IN IS IT JO KW LB LI LK LT LU LV MC + MT MU MV MX MY NL NO NZ OM PH PL PT QA RO SA SE SG SI SK SM + TR TT UM US VA VN ZA) + self.supported_cardtypes = [:visa, :master, :american_express] + self.homepage_url = 'https://trexle.com' + self.display_name = 'Trexle' + + def initialize(options = {}) + requires!(options, :api_key) + super + end + + # Create a charge using a credit card, card token or customer token + # + # To charge a credit card: purchase([money], [creditcard hash], ...) + # To charge a customer: purchase([money], [token], ...) + def purchase(money, creditcard, options = {}) + post = {} + + add_amount(post, money, options) + add_customer_data(post, options) + add_invoice(post, options) + add_creditcard(post, creditcard) + add_address(post, creditcard, options) + commit(:post, 'charges', post, options) + end + + # Create a customer and associated credit card. The token that is returned + # can be used instead of a credit card parameter in the purchase method + def store(creditcard, options = {}) + post = {} + + add_creditcard(post, creditcard) + add_customer_data(post, options) + add_address(post, creditcard, options) + commit(:post, 'customers', post, options) + end + + # Refund a transaction + def refund(money, token, options = {}) + commit(:post, "charges/#{CGI.escape(token)}/refunds", { amount: amount(money) }, options) + end + + # Authorize an amount on a credit card. Once authorized, you can later + # capture this charge using the charge token that is returned. + def authorize(money, creditcard, options = {}) + post = {} + + add_amount(post, money, options) + add_customer_data(post, options) + add_invoice(post, options) + add_creditcard(post, creditcard) + add_address(post, creditcard, options) + post[:capture] = false + commit(:post, 'charges', post, options) + end + + # Captures a previously authorized charge. Capturing only part of the original + # authorization is currently not supported. + def capture(money, token, options = {}) + commit(:put, "charges/#{CGI.escape(token)}/capture", { amount: amount(money) }, options) + end + + # Updates the credit card for the customer. + def update(token, creditcard, options = {}) + post = {} + + add_creditcard(post, creditcard) + add_customer_data(post, options) + add_address(post, creditcard, options) + commit(:put, "customers/#{CGI.escape(token)}", post, options) + end + + def supports_scrubbing + true + end + + def scrub(transcript) + transcript. + gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). + gsub(/(number\\?":\\?")(\d*)/, '\1[FILTERED]'). + gsub(/(cvc\\?":\\?")(\d*)/, '\1[FILTERED]') + end + private + + def add_amount(post, money, options) + post[:amount] = amount(money) + post[:currency] = (options[:currency] || currency(money)) + post[:currency] = post[:currency].upcase if post[:currency] + end + + def add_customer_data(post, options) + post[:email] = options[:email] if options[:email] + post[:ip_address] = options[:ip] if options[:ip] + end + + def add_address(post, creditcard, options) + return if creditcard.kind_of?(String) + address = (options[:billing_address] || options[:address]) + return unless address + + post[:card] ||= {} + post[:card].merge!( + address_line1: address[:address1], + address_line2: address[:address_line2], + address_city: address[:city], + address_postcode: address[:zip], + address_state: address[:state], + address_country: address[:country] + ) + end + + def add_invoice(post, options) + post[:description] = options[:description] || "Active Merchant Purchase" + end + + def add_creditcard(post, creditcard) + if creditcard.respond_to?(:number) + post[:card] ||= {} + + post[:card].merge!( + number: creditcard.number, + expiry_month: creditcard.month, + expiry_year: creditcard.year, + cvc: creditcard.verification_value, + name: creditcard.name + ) + elsif creditcard.kind_of?(String) + if creditcard =~ /^token_/ + post[:card_token] = creditcard + else + post[:customer_token] = creditcard + end + end + end + + def headers(params = {}) + result = { + "Content-Type" => "application/json", + "Authorization" => "Basic #{Base64.strict_encode64(options[:api_key] + ':').strip}" + } + + result['X-Partner-Key'] = params[:partner_key] if params[:partner_key] + result['X-Safe-Card'] = params[:safe_card] if params[:safe_card] + result + end + + def commit(method, action, params, options) + url = "#{test? ? test_url : live_url}/#{action}" + raw_response = ssl_request(method, url, post_data(params), headers(options)) + parsed_response = parse(raw_response) + success_response(parsed_response) + rescue ResponseError => e + error_response(parse(e.response.body)) + rescue JSON::ParserError + unparsable_response(raw_response) + end + + def success_response(body) + return invalid_response unless body['response'] + + response = body['response'] + Response.new( + true, + response['status_message'], + body, + authorization: token(response), + test: test? + ) + end + + def error_response(body) + return invalid_response unless body['error'] + Response.new( + false, + body['error'], + body, + authorization: nil, + test: test? + ) + end + + def unparsable_response(raw_response) + message = "Invalid JSON response received from Trexle. Please contact support@trexle.com if you continue to receive this message." + message += " (The raw response returned by the API was #{raw_response.inspect})" + return Response.new(false, message) + end + + def invalid_response + message = "Invalid response." + return Response.new(false, message) + end + + def token(response) + response['token'] + end + + def parse(body) + return {} if body.blank? + JSON.parse(body) + end + + def post_data(parameters = {}) + parameters.to_json + end + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index 7a974464df0..7d6ee6ffa5f 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -1151,6 +1151,10 @@ transax: login: transaxdemo password: nelix123 +# Working credentials, no need to replace +trexle: + api_key: "J5RGMpDlFlTfv9mEFvNWYoqHufyukPP4" + # Working credentials, no need to replace trust_commerce: login: 'TestMerchant' diff --git a/test/remote/gateways/remote_trexle_test.rb b/test/remote/gateways/remote_trexle_test.rb new file mode 100644 index 00000000000..c0d3fcf09cf --- /dev/null +++ b/test/remote/gateways/remote_trexle_test.rb @@ -0,0 +1,170 @@ +require 'test_helper' + +class RemoteTrexleTest < Test::Unit::TestCase + def setup + @gateway = TrexleGateway.new(fixtures(:trexle)) + + @amount = 100 + @credit_card = credit_card('5555555555554444', year: Time.now.year + 2) + @visa_credit_card = credit_card('4242424242424242', year: Time.now.year + 3) + @declined_card = credit_card('4000000000000119') + + @options = { + email: 'john@trexle.com', + ip: '66.249.79.118', + order_id: '1', + billing_address: address, + description: "ActiveMerchant Demo Purchase #{DateTime.now.to_i}" + } + end + + def test_successful_purchase + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal true, response.params['response']['captured'] + end + + def test_successful_authorize_and_capture + authorization = @gateway.authorize(@amount, @credit_card, @options) + assert_success authorization + assert_equal false, authorization.params['response']['captured'] + + response = @gateway.capture(@amount, authorization.authorization, @options) + assert_success response + assert_equal true, response.params['response']['captured'] + end + + def test_failed_authorize + response = @gateway.authorize(@amount, @declined_card, @options) + assert_failure response + end + + def test_failed_capture_due_to_invalid_token + response = @gateway.capture(@amount, "bogus", @options) + assert_failure response + end + + def test_failed_capture_due_to_invalid_amount + authorization = @gateway.authorize(@amount, @credit_card, @options) + assert_success authorization + assert_equal authorization.params['response']['captured'], false + + response = @gateway.capture(@amount + 1, authorization.authorization, @options) + assert_failure response + assert_equal 'Payment failed', response.params['error'] + end + + def test_successful_purchase_without_description + @options.delete(:description) + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + end + + def test_unsuccessful_purchase + response = @gateway.purchase(@amount, @declined_card, @options) + assert_failure response + end + + # This is a bit manual as we have to create a working card token as + # would be returned from trexle.js / the card tokens API which + # falls outside of active merchant + def test_store_and_charge_with_trexle_js_card_token + headers = { + "Content-Type" => "application/json", + "Authorization" => "Basic #{Base64.strict_encode64(@gateway.options[:api_key] + ':').strip}" + } + # Get a token equivalent to what is returned by trexle.js + card_attrs = { + number: @credit_card.number, + expiry_month: @credit_card.month, + expiry_year: @credit_card.year, + cvc: @credit_card.verification_value, + name: "#{@credit_card.first_name} #{@credit_card.last_name}", + address_line1: "321 Shoreline Park", + address_line2: "suite #7", + address_city: "Mountain View", + address_postcode: "94043", + address_state: "CA", + address_country: "United States" + } + url = @gateway.test_url + "/tokens" + + body = JSON.parse(@gateway.ssl_post(url, card_attrs.to_json, headers)) + + card_token = body["response"]["token"] + + store = @gateway.store(card_token, @options) + assert_success store + assert_not_nil store.authorization + + purchase = @gateway.purchase(@amount, card_token, @options) + assert_success purchase + assert_not_nil purchase.authorization + end + + def test_store_and_customer_token_charge + response = @gateway.store(@credit_card, @options) + assert_success response + assert_not_nil response.authorization + + token = response.params['response']['card']['token'] + + assert response1 = @gateway.purchase(@amount, token, @options) + assert_success response1 + + assert response2 = @gateway.purchase(@amount, token, @options) + assert_success response2 + assert_not_equal response1.authorization, response2.authorization + end + + def test_store_and_update + response = @gateway.store(@credit_card, @options) + assert_success response + assert_not_nil response.authorization + assert_equal @credit_card.year, response.params['response']['card']['expiry_year'] + + response = @gateway.update(response.authorization, @credit_card, address: address) + assert_success response + assert_not_nil response.authorization + assert_equal @credit_card.year, response.params['response']['card']['expiry_year'] + end + + def test_refund + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_not_nil response.authorization + + token = response.authorization + + response = @gateway.refund(@amount, token, @options) + assert_success response + assert_not_nil response.authorization + end + + def test_failed_refund + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_not_nil response.authorization + + token = response.authorization + + response = @gateway.refund(@amount, token.reverse, @options) + assert_failure response + end + + def test_invalid_login + gateway = TrexleGateway.new(api_key: '') + response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + clean_transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, clean_transcript) + assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript) + end +end diff --git a/test/unit/gateways/trexle_test.rb b/test/unit/gateways/trexle_test.rb new file mode 100644 index 00000000000..b07bbc55393 --- /dev/null +++ b/test/unit/gateways/trexle_test.rb @@ -0,0 +1,444 @@ +require 'test_helper' + +class TrexleTest < Test::Unit::TestCase + def setup + @gateway = TrexleGateway.new(api_key: 'THIS_IS_NOT_A_REAL_API_KEY') + + @credit_card = credit_card + @amount = 100 + + @options = { + email: 'john@trexle.com', + billing_address: address, + description: 'Store Purchase', + ip: '127.0.0.1' + } + end + + def test_required_api_key_on_initialization + assert_raises ArgumentError do + TrexleGateway.new + end + end + + def test_default_currency + assert_equal 'USD', TrexleGateway.default_currency + end + + def test_money_format + assert_equal :cents, TrexleGateway.money_format + end + + def test_url + assert_equal 'https://core.trexle.com/api/v1', TrexleGateway.test_url + end + + def test_live_url + assert_equal 'https://core.trexle.com/api/v1', TrexleGateway.live_url + end + + def test_supported_countries + expected_supported_countries = %w(AD AE AT AU BD BE BG BN CA CH CY CZ DE DK EE EG ES FI FR GB + GI GR HK HU ID IE IL IM IN IS IT JO KW LB LI LK LT LU LV MC + MT MU MV MX MY NL NO NZ OM PH PL PT QA RO SA SE SG SI SK SM + TR TT UM US VA VN ZA) + assert_equal expected_supported_countries, TrexleGateway.supported_countries + end + + def test_supported_cardtypes + assert_equal [:visa, :master, :american_express], TrexleGateway.supported_cardtypes + end + + def test_display_name + assert_equal 'Trexle', TrexleGateway.display_name + end + + def test_setup_purchase_parameters + @gateway.expects(:add_amount).with(instance_of(Hash), @amount, @options) + @gateway.expects(:add_customer_data).with(instance_of(Hash), @options) + @gateway.expects(:add_invoice).with(instance_of(Hash), @options) + @gateway.expects(:add_creditcard).with(instance_of(Hash), @credit_card) + @gateway.expects(:add_address).with(instance_of(Hash), @credit_card, @options) + + @gateway.stubs(:ssl_request).returns(successful_purchase_response) + assert_success @gateway.purchase(@amount, @credit_card, @options) + end + + def test_successful_purchase + post_data = {} + headers = {} + @gateway.stubs(:headers).returns(headers) + @gateway.stubs(:post_data).returns(post_data) + @gateway.expects(:ssl_request).with(:post, 'https://core.trexle.com/api/v1/charges', post_data, headers).returns(successful_purchase_response) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'charge_0cfad7ee5ffe75f58222bff214bfa5cc7ad7c367', response.authorization + assert_equal JSON.parse(successful_purchase_response), response.params + assert response.test? + end + + def test_unsuccessful_request + @gateway.expects(:ssl_request).returns(failed_purchase_response) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal "Invalid response.", response.message + end + + def test_unparsable_body_of_successful_response + @gateway.stubs(:raw_ssl_request).returns(MockResponse.succeeded("not-json")) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_match(/Invalid JSON response received/, response.message) + end + + def test_successful_store + @gateway.expects(:ssl_request).returns(successful_store_response) + assert response = @gateway.store(@credit_card, @options) + assert_success response + assert_equal 'token_2cb443cf26b6ecdadd8144d1fac8240710aa41f1', response.authorization + assert_equal JSON.parse(successful_store_response), response.params + assert response.test? + end + + def test_unsuccessful_store + @gateway.expects(:ssl_request).returns(failed_store_response) + + assert response = @gateway.store(@credit_card, @options) + assert_failure response + assert_equal "Invalid response.", response.message + end + + def test_successful_update + token = 'token_940ade441a23d53e04017f53af6c3a1eae9978ae' + @gateway.expects(:ssl_request).with(:put, "https://core.trexle.com/api/v1/customers/#{token}", instance_of(String), instance_of(Hash)).returns(successful_customer_store_response) + assert response = @gateway.update('token_940ade441a23d53e04017f53af6c3a1eae9978ae', @credit_card, @options) + assert_success response + assert_equal 'token_940ade441a23d53e04017f53af6c3a1eae9978ae', response.authorization + assert_equal JSON.parse(successful_customer_store_response), response.params + assert response.test? + end + + def test_successful_refund + token = 'charge_0cfad7ee5ffe75f58222bff214bfa5cc7ad7c367' + @gateway.expects(:ssl_request).with(:post, "https://core.trexle.com/api/v1/charges/#{token}/refunds", {amount: '100'}.to_json, instance_of(Hash)).returns(successful_refund_response) + + assert response = @gateway.refund(100, token) + assert_equal 'refund_7f696a86f9cb136520c51ea90c17f687b8df40b0', response.authorization + assert_success response + assert response.test? + end + + def test_unsuccessful_refund + token = 'charge_0cfad7ee5ffe75f58222bff214bfa5cc7ad7c367' + @gateway.expects(:ssl_request).with(:post, "https://core.trexle.com/api/v1/charges/#{token}/refunds", {amount: '100'}.to_json, instance_of(Hash)).returns(failed_refund_response) + + assert response = @gateway.refund(100, token) + assert_failure response + assert_equal "Invalid response.", response.message + end + + def test_successful_authorize + post_data = {} + headers = {} + @gateway.stubs(:headers).returns(headers) + @gateway.stubs(:post_data).returns(post_data) + @gateway.expects(:ssl_request).with(:post, 'https://core.trexle.com/api/v1/charges', post_data, headers).returns(successful_purchase_response) + + assert response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + assert_equal 'charge_0cfad7ee5ffe75f58222bff214bfa5cc7ad7c367', response.authorization + assert_equal JSON.parse(successful_purchase_response), response.params + assert response.test? + end + + def test_successful_capture + post_data = {} + headers = {} + token = 'charge_6e47a330dca67ec7f696e8b650db22fe69bb8499' + @gateway.stubs(:headers).returns(headers) + @gateway.stubs(:post_data).returns(post_data) + @gateway.expects(:ssl_request).with(:put, "https://core.trexle.com/api/v1/charges/#{token}/capture", post_data, headers).returns(successful_capture_response) + + assert response = @gateway.capture(100, token) + assert_success response + assert_equal token, response.authorization + assert response.test? + end + + def test_store_parameters + @gateway.expects(:add_creditcard).with(instance_of(Hash), @credit_card) + @gateway.expects(:add_address).with(instance_of(Hash), @credit_card, @options) + @gateway.expects(:ssl_request).returns(successful_store_response) + assert_success @gateway.store(@credit_card, @options) + end + + def test_update_parameters + @gateway.expects(:add_creditcard).with(instance_of(Hash), @credit_card) + @gateway.expects(:add_address).with(instance_of(Hash), @credit_card, @options) + @gateway.expects(:ssl_request).returns(successful_store_response) + assert_success @gateway.update('token_6b5d89f723d1aeee8ff0c588fd4ccbaae223b9aa', @credit_card, @options) + end + + def test_add_amount + @gateway.expects(:amount).with(100).returns('100') + post = {} + @gateway.send(:add_amount, post, 100, @options) + assert_equal '100', post[:amount] + end + + def test_set_default_currency + @gateway.expects(:currency).with(100).returns('USD') + post = {} + @gateway.send(:add_amount, post, 100, @options) + assert_equal 'USD', post[:currency] + end + + def test_set_currency + @gateway.expects(:currency).never + post = {} + @options[:currency] = 'USD' + @gateway.send(:add_amount, post, 100, @options) + assert_equal 'USD', post[:currency] + end + + def test_set_currency_case + @gateway.expects(:currency).never + post = {} + @options[:currency] = 'usd' + @gateway.send(:add_amount, post, 100, @options) + assert_equal 'USD', post[:currency] + end + + def test_add_customer_data + post = {} + + @gateway.send(:add_customer_data, post, @options) + + assert_equal 'john@trexle.com', post[:email] + assert_equal '127.0.0.1', post[:ip_address] + end + + def test_add_address + post = {} + + @gateway.send(:add_address, post, @credit_card, @options) + + assert_equal @options[:billing_address][:address1], post[:card][:address_line1] + assert_equal @options[:billing_address][:city], post[:card][:address_city] + assert_equal @options[:billing_address][:zip], post[:card][:address_postcode] + assert_equal @options[:billing_address][:state], post[:card][:address_state] + assert_equal @options[:billing_address][:country], post[:card][:address_country] + end + + def test_add_address_with_card_token + post = {} + + @gateway.send(:add_address, post, 'somecreditcardtoken', @options) + + assert_equal false, post.has_key?(:card) + end + + def test_add_invoice + post = {} + @gateway.send(:add_invoice, post, @options) + + assert_equal @options[:description], post[:description] + end + + def test_add_creditcard + post = {} + @gateway.send(:add_creditcard, post, @credit_card) + + assert_equal @credit_card.number, post[:card][:number] + assert_equal @credit_card.month, post[:card][:expiry_month] + assert_equal @credit_card.year, post[:card][:expiry_year] + assert_equal @credit_card.verification_value, post[:card][:cvc] + assert_equal @credit_card.name, post[:card][:name] + end + + def test_add_creditcard_with_card_token + post = {} + @gateway.send(:add_creditcard, post, 'token_f974687e4e866d6cca534e1cd42236817d315b3a') + assert_equal 'token_f974687e4e866d6cca534e1cd42236817d315b3a', post[:card_token] + assert_false post.has_key?(:card) + end + + def test_add_creditcard_with_customer_token + post = {} + @gateway.send(:add_creditcard, post, 'token_2cb443cf26b6ecdadd8144d1fac8240710aa41f1') + assert_equal 'token_2cb443cf26b6ecdadd8144d1fac8240710aa41f1', post[:card_token] + assert_false post.has_key?(:card) + end + + def test_post_data + post = {} + @gateway.send(:add_creditcard, post, @credit_card) + assert_equal post.to_json, @gateway.send(:post_data, post) + end + + def test_headers + expected_headers = { + "Content-Type" => "application/json", + "Authorization" => "Basic #{Base64.strict_encode64('THIS_IS_NOT_A_REAL_API_KEY:').strip}" + } + + @gateway.expects(:ssl_request).with(:post, anything, anything, expected_headers).returns(successful_purchase_response) + assert response = @gateway.purchase(@amount, @credit_card, {}) + + expected_headers['X-Partner-Key'] = 'MyPartnerKey' + expected_headers['X-Safe-Card'] = '1' + + @gateway.expects(:ssl_request).with(:post, anything, anything, expected_headers).returns(successful_purchase_response) + assert response = @gateway.purchase(@amount, @credit_card, partner_key: 'MyPartnerKey', safe_card: '1') + end + + def test_transcript_scrubbing + assert_equal scrubbed_transcript, @gateway.scrub(transcript) + end + + private + + def successful_purchase_response + '{ + "response":{ + "token":"charge_0cfad7ee5ffe75f58222bff214bfa5cc7ad7c367", + "success":true, + "captured":true + } + }' + end + + def failed_purchase_response + '{ + "error":"Payment failed", + "detail":"An error occurred while processing your card. Try again in a little bit." + }' + end + + def successful_store_response + '{ + "response":{ + "token":"token_2cb443cf26b6ecdadd8144d1fac8240710aa41f1", + "card":{ + "token":"token_f974687e4e866d6cca534e1cd42236817d315b3a", + "primary":true + } + } + }' + end + + def failed_store_response + '{ + "error":"an error has occured", + "detail":"invalid token" + }' + end + + def successful_customer_store_response + '{ + "response":{ + "token":"token_940ade441a23d53e04017f53af6c3a1eae9978ae", + "card":{ + "token":"token_9a3f559962cbf6828e2cc38a02023565b0294548", + "scheme":"master", + "display_number":"XXXX-XXXX-XXXX-4444", + "expiry_year":2019, + "expiry_month":9, + "cvc":123, + "name":"Longbob Longsen", + "address_line1":"456 My Street", + "address_line2":null, + "address_city":"Ottawa", + "address_state":"ON", + "address_postcode":"K1C2N6", + "address_country":"CA", + "primary":true + } + } + }' + end + + def failed_customer_store_response + '{ + "error":"an error has occured", + "detail":"invalid token" + }' + end + + def successful_refund_response + '{ + "response":{ + "token":"refund_7f696a86f9cb136520c51ea90c17f687b8df40b0", + "success":true, + "amount":100, + "charge":"charge_ee4542e9f4d2c50f7fea55b694423a53991a323a", + "status_message":"Transaction approved" + } + }' + end + + def failed_refund_response + '{ + "error":"Refund failed", + "detail":"invalid token" + }' + end + + def successful_capture_response + '{ + "response":{ + "token":"charge_6e47a330dca67ec7f696e8b650db22fe69bb8499", + "success":true, + "captured":true + } + }' + end + + def transcript + '{ + "amount":"100", + "currency":"USD", + "email":"john@trexle.com", + "ip_address":"66.249.79.118", + "description":"Store Purchase 1437598192", + "card":{ + "number":"5555555555554444", + "expiry_month":9, + "expiry_year":2017, + "cvc":"123", + "name":"Longbob Longsen", + "address_line1":"456 My Street", + "address_city":"Ottawa", + "address_postcode":"K1C2N6", + "address_state":"ON", + "address_country":"CA" + } + }' + end + + def scrubbed_transcript + '{ + "amount":"100", + "currency":"USD", + "email":"john@trexle.com", + "ip_address":"66.249.79.118", + "description":"Store Purchase 1437598192", + "card":{ + "number":"[FILTERED]", + "expiry_month":9, + "expiry_year":2017, + "cvc":"[FILTERED]", + "name":"Longbob Longsen", + "address_line1":"456 My Street", + "address_city":"Ottawa", + "address_postcode":"K1C2N6", + "address_state":"ON", + "address_country":"CA" + } + }' + end + +end From 484afcb2025819622cb18f475afe80c9e80f0396 Mon Sep 17 00:00:00 2001 From: Anthony Clark Date: Tue, 13 Jun 2017 15:33:49 -0400 Subject: [PATCH 098/677] Attribute changelog entries to the correct release (#2460) --- CHANGELOG | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index af6e36c22eb..20ab82f50a0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,16 +19,6 @@ * Payeezy: Add client_email field for telecheck [davidsantoso] #2455 * Payeezy: Add customer_id_type and customer_id_number fields [davidsantoso] #2454 * Quickpay V10: Fix store and token use for recurring payments [wsmoak] #2180 - -== Version 1.66.0 (May 4, 2017) -* Support Rails 5.1 [jhawthorn] #2407 -* ProPay: Add Canada as supported country [davidsantoso] -* ProPay: Add gateway support [davidsantoso] #2405 -* SafeCharge: Support credit transactions [shasum] #2404 -* WePay: Add scrub method [shasum] #2406 -* iVeri: Add gateway support [curiousepic] #2400 -* iVeri: Support 3DSecure data fields [davidsantoso] #2412 -* Opp: Fix transaction success criteria and clean up options [shasum] #2414 * Elavon: Support custom fields [curiousepic] #2416 * WePay: Support risk headers [shasum] #2419 * WePay: Add Canada as supported country [shasum] #2419 @@ -41,6 +31,16 @@ * Payeezy: Default check number to 001 if not present [davidsantoso] #2439 * Opp: Fix incorrect customParameter key to disable 3DS [davidsantoso] +== Version 1.66.0 (May 4, 2017) +* Support Rails 5.1 [jhawthorn] #2407 +* ProPay: Add Canada as supported country [davidsantoso] +* ProPay: Add gateway support [davidsantoso] #2405 +* SafeCharge: Support credit transactions [shasum] #2404 +* WePay: Add scrub method [shasum] #2406 +* iVeri: Add gateway support [curiousepic] #2400 +* iVeri: Support 3DSecure data fields [davidsantoso] #2412 +* Opp: Fix transaction success criteria and clean up options [shasum] #2414 + == Version 1.65.0 (April 26, 2017) * Adyen: Add Adyen v18 gateway [adyenpayments] #2272 * Authorize.Net: Force refund of unsettled payments via void [bizla] #2399 From 07b3f10249ad6b0eddd05051a556595b1e3e1497 Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 13 Jun 2017 15:52:32 -0400 Subject: [PATCH 099/677] QuickPay V10: Return last response for purchase and authorize Previously, the MultiResponse used for Authorize and Purchase were "using first response", which meant that for stored cards, this was returning the single-use token for its authorization, causing refunds and voids of auths and purchases by stored cards to fail. Authorize and Purchase now let the multi-response return the last result, allowing id to be properly set as the authorization for those actions. Unit: 14 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 28 tests, 129 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2461 --- CHANGELOG | 1 + .../billing/gateways/quickpay/quickpay_v10.rb | 7 ++-- .../gateways/remote_quickpay_v10_test.rb | 35 +++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 20ab82f50a0..5846153f70e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * Moneris: Add 3DS fields for decrypted Apple and Android Pay data [davidsantoso] #2457 * Trexle: Add gateway support [hossamhossny] #2351 +* QuickPay V10: Return last response for purchase and authorize [curiousepic] #2461 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb index 9333927c7f2..ca185b8ccdf 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb @@ -15,7 +15,7 @@ def initialize(options = {}) end def purchase(money, credit_card_or_reference, options = {}) - MultiResponse.run(true) do |r| + MultiResponse.run do |r| if credit_card_or_reference.is_a?(String) r.process { create_token(credit_card_or_reference, options) } credit_card_or_reference = r.authorization @@ -34,7 +34,7 @@ def purchase(money, credit_card_or_reference, options = {}) end def authorize(money, credit_card_or_reference, options = {}) - MultiResponse.run(true) do |r| + MultiResponse.run do |r| if credit_card_or_reference.is_a?(String) r.process { create_token(credit_card_or_reference, options) } credit_card_or_reference = r.authorization @@ -132,7 +132,6 @@ def authorize_store(identification, credit_card, options = {}) def create_token(identification, options) post = {} - # post[:id] = options[:id] commit(synchronized_path("/cards/#{identification}/tokens"), post) end @@ -196,7 +195,7 @@ def add_invoice(post, options) post[:shipping_address] = map_address(options[:shipping_address]) end - [:metadata, :brading_id, :variables].each do |field| + [:metadata, :branding_id, :variables].each do |field| post[field] = options[field] if options[field] end end diff --git a/test/remote/gateways/remote_quickpay_v10_test.rb b/test/remote/gateways/remote_quickpay_v10_test.rb index fa3ea6fe222..0d887c8ae93 100644 --- a/test/remote/gateways/remote_quickpay_v10_test.rb +++ b/test/remote/gateways/remote_quickpay_v10_test.rb @@ -121,6 +121,12 @@ def test_successful_purchase_and_void assert_equal 'OK', void.message end + def test_unsuccessful_void + assert void = @gateway.void('123') + assert_failure void + assert_equal 'Not found: No Payment with id 123', void.message + end + def test_successful_authorization_capture_and_credit assert auth = @gateway.authorize(@amount, @valid_card, @options) assert_success auth @@ -191,6 +197,35 @@ def test_successful_store_and_reference_authorize assert_success authorization end + def test_successful_store_and_credit + assert store = @gateway.store(@valid_card, @options) + assert_success store + assert purchase = @gateway.purchase(@amount, store.authorization, @options) + assert_success purchase + assert credit = @gateway.refund(@amount, purchase.authorization) + assert_success credit + end + + def test_unsuccessful_store_and_credit + assert store = @gateway.store(@refund_rejected_card, @options) + assert_success store + assert purchase = @gateway.purchase(@amount, store.authorization, @options) + assert_success purchase + assert credit = @gateway.refund(@amount, purchase.authorization) + assert_failure credit + assert_match(/Rejected test operation/, credit.message) + end + + def test_successful_store_and_void_authorize + assert store = @gateway.store(@valid_card, @options) + assert_success store + assert authorize = @gateway.authorize(@amount, store.authorization, @options) + assert_success authorize + assert void = @gateway.void(authorize.authorization) + assert_success void + assert_equal 'OK', void.message + end + def test_successful_unstore assert response = @gateway.store(@valid_card, @options) assert_success response From 7b563ee6c651452e3fc8077fb6e78d803ee20e0f Mon Sep 17 00:00:00 2001 From: David Perry Date: Wed, 14 Jun 2017 16:54:26 -0400 Subject: [PATCH 100/677] Support three-decimal currencies Similar to non-fractional currency support, gateways can override which currencies should be treated as three-decimal. No default currencies are added to the gateway class, so it is currently an opt-in feature. Closes #2466 Unit tests: 3615 tests, 66645 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateway.rb | 26 +++++++++++++++++++------- test/unit/gateways/gateway_test.rb | 12 ++++++++++++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5846153f70e..8df0c25ecec 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * Moneris: Add 3DS fields for decrypted Apple and Android Pay data [davidsantoso] #2457 * Trexle: Add gateway support [hossamhossny] #2351 * QuickPay V10: Return last response for purchase and authorize [curiousepic] #2461 +* Support three-decimal currencies [curiousepic] #2466 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateway.rb b/lib/active_merchant/billing/gateway.rb index 52c945c0774..b0f7cc8b65d 100644 --- a/lib/active_merchant/billing/gateway.rb +++ b/lib/active_merchant/billing/gateway.rb @@ -125,8 +125,9 @@ def generate_unique_id class_attribute :supported_cardtypes self.supported_cardtypes = [] - class_attribute :currencies_without_fractions + class_attribute :currencies_without_fractions, :currencies_with_three_decimal_places self.currencies_without_fractions = %w(BIF BYR CLP CVE DJF GNF HUF ISK JPY KMF KRW PYG RWF UGX VND VUV XAF XOF XPF) + self.currencies_with_three_decimal_places = %w() class_attribute :homepage_url class_attribute :display_name @@ -263,15 +264,26 @@ def non_fractional_currency?(currency) self.currencies_without_fractions.include?(currency.to_s) end + def three_decimal_currency?(currency) + self.currencies_with_three_decimal_places.include?(currency.to_s) + end + def localized_amount(money, currency) amount = amount(money) - return amount unless non_fractional_currency?(currency) - - if self.money_format == :cents - sprintf("%.0f", amount.to_f / 100) - else - amount.split('.').first + return amount unless non_fractional_currency?(currency) || three_decimal_currency?(currency) + if non_fractional_currency?(currency) + if self.money_format == :cents + sprintf("%.0f", amount.to_f / 100) + else + amount.split('.').first + end + elsif three_decimal_currency?(currency) + if self.money_format == :cents + (amount.to_i * 10).to_s + else + sprintf("%.3f", amount.to_f) + end end end diff --git a/test/unit/gateways/gateway_test.rb b/test/unit/gateways/gateway_test.rb index e2554bf98c5..5454bea75b5 100644 --- a/test/unit/gateways/gateway_test.rb +++ b/test/unit/gateways/gateway_test.rb @@ -90,6 +90,18 @@ def test_localized_amount_should_ignore_money_format_for_non_fractional_currenci assert_equal '12', @gateway.send(:localized_amount, 1234, 'HUF') end + def test_localized_amount_returns_three_decimal_places_for_three_decimal_currencies + @gateway.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND) + + Gateway.money_format = :dollars + assert_equal '1.000', @gateway.send(:localized_amount, 100, 'OMR') + assert_equal '12.340', @gateway.send(:localized_amount, 1234, 'BHD') + + Gateway.money_format = :cents + assert_equal '1000', @gateway.send(:localized_amount, 100, 'OMR') + assert_equal '12340', @gateway.send(:localized_amount, 1234, 'BHD') + end + def test_split_names assert_equal ["Longbob", "Longsen"], @gateway.send(:split_names, "Longbob Longsen") end From 383d6d25468cd55c2b149e032c2beb0fd304468f Mon Sep 17 00:00:00 2001 From: David Perry Date: Thu, 15 Jun 2017 11:07:34 -0400 Subject: [PATCH 101/677] Credorax: Support 0- and 3-exponent currencies The 7 failed remote tests are negative cases failing due to stale test card data, unrelated to this change. Remote: 18 tests, 50 assertions, 7 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 61.1111% passed Unit: 17 tests, 83 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/credorax.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8df0c25ecec..395b05df368 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Trexle: Add gateway support [hossamhossny] #2351 * QuickPay V10: Return last response for purchase and authorize [curiousepic] #2461 * Support three-decimal currencies [curiousepic] #2466 +* Credorax: Support 0- and 3-exponent currencies [curiousepic] == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb index a7a35ea4798..61e4b95196d 100644 --- a/lib/active_merchant/billing/gateways/credorax.rb +++ b/lib/active_merchant/billing/gateways/credorax.rb @@ -17,6 +17,9 @@ class CredoraxGateway < Gateway self.supported_countries = %w(DE GB FR IT ES PL NL BE GR CZ PT SE HU RS AT CH BG DK FI SK NO IE HR BA AL LT MK SI LV EE ME LU MT IS AD MC LI SM) self.default_currency = "EUR" + self.currencies_without_fractions = %w(CLP JPY KRW PYG VND) + self.currencies_with_three_decimal_places = %w(BHD JOD KWD OMR RSD TND) + self.money_format = :cents self.supported_cardtypes = [:visa, :master, :maestro] @@ -187,9 +190,11 @@ def scrub(transcript) private def add_invoice(post, money, options) - post[:a4] = amount(money) + currency = options[:currency] || currency(money) + + post[:a4] = localized_amount(money, currency) post[:a1] = generate_unique_id - post[:a5] = options[:currency] || currency(money) + post[:a5] = currency post[:h9] = options[:order_id] end From 24ab863736dd1136655055a63e05108baafb3ffb Mon Sep 17 00:00:00 2001 From: David Santoso Date: Tue, 13 Jun 2017 12:28:55 -0400 Subject: [PATCH 102/677] SafeCharge: Map billing address fields Closes #2464 --- CHANGELOG | 1 + .../billing/gateways/safe_charge.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 395b05df368..7e73496df5f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * QuickPay V10: Return last response for purchase and authorize [curiousepic] #2461 * Support three-decimal currencies [curiousepic] #2466 * Credorax: Support 0- and 3-exponent currencies [curiousepic] +* SafeCharge: Map billing address fields [davidsantoso] #2464 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index 02883e7adda..8f37c34cba6 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -24,6 +24,7 @@ def purchase(money, payment, options={}) post = {} add_transaction_data("Sale", post, money, options) add_payment(post, payment) + add_customer_details(post, payment, options) commit(post) end @@ -32,6 +33,7 @@ def authorize(money, payment, options={}) post = {} add_transaction_data("Auth", post, money, options) add_payment(post, payment) + add_customer_details(post, payment, options) commit(post) end @@ -125,6 +127,21 @@ def add_payment(post, payment) post[:sg_CVV2] = payment.verification_value end + def add_customer_details(post, payment, options) + if address = options[:billing_address] || options[:address] + post[:sg_FirstName] = payment.first_name + post[:sg_LastName] = payment.last_name + post[:sg_Address] = address[:address1] if address[:address1] + post[:sg_City] = address[:city] if address[:city] + post[:sg_State] = address[:state] if address[:state] + post[:sg_Zip] = address[:zip] if address[:zip] + post[:sg_Country] = address[:country] if address[:country] + post[:sg_Phone] = address[:phone] if address[:phone] + end + + post[:sg_Email] = options[:email] + end + def parse(xml) response = {} From 96b71f4ca3c1959d25f8995fc5981354c5b0bad2 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Wed, 14 Jun 2017 11:40:25 -0400 Subject: [PATCH 103/677] Openpay: Send customer name and email in authorize and purchase Previously only name and email were sent to Openpay when storing a card. This adds support for sending the customer's name and email when performing authorize or purchase transactions. Closes #2468 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/openpay.rb | 12 ++++++++++++ test/remote/gateways/remote_openpay_test.rb | 14 ++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 7e73496df5f..0af53b0b5e0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * Support three-decimal currencies [curiousepic] #2466 * Credorax: Support 0- and 3-exponent currencies [curiousepic] * SafeCharge: Map billing address fields [davidsantoso] #2464 +* Openpay: Send customer name and email in authorize and purchase [dtykocki] #2468 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/openpay.rb b/lib/active_merchant/billing/gateways/openpay.rb index 7c777a64ffd..811656cb075 100644 --- a/lib/active_merchant/billing/gateways/openpay.rb +++ b/lib/active_merchant/billing/gateways/openpay.rb @@ -130,10 +130,22 @@ def add_creditcard(post, creditcard, options) holder_name: creditcard.name } add_address(card, options) + add_customer_data(post, creditcard, options) post[:card] = card end end + def add_customer_data(post, creditcard, options) + if options[:email] + customer = { + name: creditcard.name || options[:name], + email: options[:email] + } + post[:customer] = customer + end + post + end + def add_address(card, options) return unless card.kind_of?(Hash) if address = (options[:billing_address] || options[:address]) diff --git a/test/remote/gateways/remote_openpay_test.rb b/test/remote/gateways/remote_openpay_test.rb index 78f96ab3bfa..01cc9fab432 100644 --- a/test/remote/gateways/remote_openpay_test.rb +++ b/test/remote/gateways/remote_openpay_test.rb @@ -21,6 +21,13 @@ def test_successful_purchase assert_nil response.message end + def test_successful_purchase_with_email + @options[:email] = '%d@example.org' % Time.now + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_nil response.message + end + def test_unsuccessful_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response @@ -52,6 +59,13 @@ def test_successful_authorize assert_nil response.message end + def test_successful_authorize_with_email + @options[:email] = '%d@example.org' % Time.now + assert response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + assert_nil response.message + end + def test_unsuccessful_authorize assert response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response From 49d863aabd144f831ec2ac8d800a640c7294b3ca Mon Sep 17 00:00:00 2001 From: David Santoso Date: Fri, 16 Jun 2017 14:04:22 -0400 Subject: [PATCH 104/677] SafeCharge: Track currency from original transaction Sending in a currency is required for all SafeCharge transaction types. Moreover, SafeCharge does not keep track of the original currency used for an authorize or purchase so if an authorize is done using EUR and then a subsequent capture is run on that authorization, the capture will be done in USD instead of EUR since the adapter defaults to USD. Of course this could be mitigated by sending in a currency code into the options hash for a void/refund/capture, but it's a bit silly to need to remember that and pass that in when you'll most likely want to run subsequent transaction requests (e.g. refund, void, and capture) on the same currency. This add the currency code used in the original transaction to the authorization response field so running a void/refund/capture will always do so in the original currency used vs defaulting to USD. Closes #2470 --- CHANGELOG | 1 + .../billing/gateways/safe_charge.rb | 15 ++++++++------- test/remote/gateways/remote_safe_charge_test.rb | 3 ++- test/unit/gateways/safe_charge_test.rb | 16 +++++++--------- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0af53b0b5e0..283dd5c4f12 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * Credorax: Support 0- and 3-exponent currencies [curiousepic] * SafeCharge: Map billing address fields [davidsantoso] #2464 * Openpay: Send customer name and email in authorize and purchase [dtykocki] #2468 +* SafeCharge: Track currency from original transaction [davidsantoso] #2470 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index 8f37c34cba6..9b4d30836ef 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -40,8 +40,8 @@ def authorize(money, payment, options={}) def capture(money, authorization, options={}) post = {} - add_transaction_data("Settle", post, money, options) - auth, transaction_id, token, exp_month, exp_year, _ = authorization.split("|") + auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split("|") + add_transaction_data("Settle", post, money, (options.merge!({currency: original_currency}))) post[:sg_AuthCode] = auth post[:sg_TransactionID] = transaction_id post[:sg_CCToken] = token @@ -53,8 +53,8 @@ def capture(money, authorization, options={}) def refund(money, authorization, options={}) post = {} - add_transaction_data("Credit", post, money, options) - auth, transaction_id, token, exp_month, exp_year, _ = authorization.split("|") + auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split("|") + add_transaction_data("Credit", post, money, (options.merge!({currency: original_currency}))) post[:sg_CreditType] = 2 post[:sg_AuthCode] = auth post[:sg_TransactionID] = transaction_id @@ -76,8 +76,8 @@ def credit(money, payment, options={}) def void(authorization, options={}) post = {} - auth, transaction_id, token, exp_month, exp_year, original_amount = authorization.split("|") - add_transaction_data("Void", post, (original_amount.to_f * 100), options) + auth, transaction_id, token, exp_month, exp_year, original_amount, original_currency = authorization.split("|") + add_transaction_data("Void", post, (original_amount.to_f * 100), (options.merge!({currency: original_currency}))) post[:sg_CreditType] = 2 post[:sg_AuthCode] = auth post[:sg_TransactionID] = transaction_id @@ -194,7 +194,8 @@ def authorization_from(response, parameters) response[:token], parameters[:sg_ExpMonth], parameters[:sg_ExpYear], - parameters[:sg_Amount] + parameters[:sg_Amount], + parameters[:sg_Currency] ].join("|") end diff --git a/test/remote/gateways/remote_safe_charge_test.rb b/test/remote/gateways/remote_safe_charge_test.rb index 844f2cf1ef3..abc29edbd0e 100644 --- a/test/remote/gateways/remote_safe_charge_test.rb +++ b/test/remote/gateways/remote_safe_charge_test.rb @@ -10,7 +10,8 @@ def setup @options = { order_id: generate_unique_id, billing_address: address, - description: 'Store Purchase' + description: 'Store Purchase', + currency: "EUR" } end diff --git a/test/unit/gateways/safe_charge_test.rb b/test/unit/gateways/safe_charge_test.rb index 91421ed5e53..264f5bd98a2 100644 --- a/test/unit/gateways/safe_charge_test.rb +++ b/test/unit/gateways/safe_charge_test.rb @@ -21,7 +21,7 @@ def test_successful_purchase assert_equal '111951|101508189567|ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAd' \ 'AAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAF' \ - 'UAbQBYAFIAMwA=|09|18|1.00', response.authorization + 'UAbQBYAFIAMwA=|09|18|1.00|USD', response.authorization assert response.test? end @@ -41,7 +41,7 @@ def test_successful_authorize assert_equal '111534|101508189855|MQBVAG4ASABkAEgAagB3AEsAbgAtACoAWgAzAFwAW' \ 'wBNAF8ATQBUAD0AegBQAGwAQAAtAD0AXAB5AFkALwBtAFAALABaAHoAOgBFAE' \ - 'wAUAA1AFUAMwA=|09|18|1.00', response.authorization + 'wAUAA1AFUAMwA=|09|18|1.00|USD', response.authorization assert response.test? end @@ -56,12 +56,12 @@ def test_failed_authorize def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - response = @gateway.capture(@amount, "auth|transaction_id|token|month|year") + response = @gateway.capture(@amount, "auth|transaction_id|token|month|year|amount|currency") assert_success response assert_equal '111301|101508190200|RwA1AGQAMgAwAEkAWABKADkAcABjAHYAQQA4AC8AZ' \ 'AAlAHMAfABoADEALAA8ADQAewB8ADsAewBiADsANQBoACwAeAA/AGQAXQAjAF' \ - 'EAYgBVAHIAMwA=|month|year|1.00', response.authorization + 'EAYgBVAHIAMwA=|month|year|1.00|currency', response.authorization assert response.test? end @@ -108,12 +108,12 @@ def test_failed_credit def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) - response = @gateway.void("auth|transaction_id|token|month|year") + response = @gateway.void("auth|transaction_id|token|month|year|amount|currency") assert_success response assert_equal '111171|101508208625|ZQBpAFAAZgBuAHEATgBUAHcASAAwADUAcwBHAHQAV' \ 'QBLAHAAbgB6AGwAJAA1AEMAfAB2AGYASwBrAHEAeQBOAEwAOwBZAGIAewB4AG' \ - 'wAYwBUAE0AMwA=|month|year|0.00', response.authorization + 'wAYwBUAE0AMwA=|month|year|0.00|currency', response.authorization assert response.test? end @@ -134,7 +134,7 @@ def test_successful_verify assert_equal '111534|101508189855|MQBVAG4ASABkAEgAagB3AEsAbgAtACoAWgAzAFwAW' \ 'wBNAF8ATQBUAD0AegBQAGwAQAAtAD0AXAB5AFkALwBtAFAALABaAHoAOgBFAE' \ - 'wAUAA1AFUAMwA=|09|18|1.00', response.authorization + 'wAUAA1AFUAMwA=|09|18|1.00|USD', response.authorization assert response.test? end @@ -145,8 +145,6 @@ def test_successful_verify_with_failed_void assert_success response end - - def test_failed_verify @gateway.expects(:ssl_post).returns(failed_authorize_response) From 39894b833680ade291864d8fb32b60d8c5dcc838 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Mon, 19 Jun 2017 21:36:31 -0400 Subject: [PATCH 105/677] Braintree Blue: Add ECI indicator to Android Pay transactions Closes #2474 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/braintree_blue.rb | 3 ++- test/remote/gateways/remote_braintree_blue_test.rb | 5 +++-- test/unit/gateways/braintree_blue_test.rb | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 283dd5c4f12..08750cb26cc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * SafeCharge: Map billing address fields [davidsantoso] #2464 * Openpay: Send customer name and email in authorize and purchase [dtykocki] #2468 * SafeCharge: Track currency from original transaction [davidsantoso] #2470 +* Braintree Blue: Braintree Blue: Add ECI indicator to Android Pay transactions [davidsantoso] #2474 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 24d1e695b0c..10752e71e1b 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -592,7 +592,8 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) :expiration_year => credit_card_or_vault_id.year.to_s, :google_transaction_id => credit_card_or_vault_id.transaction_id, :source_card_type => credit_card_or_vault_id.brand, - :source_card_last_four => credit_card_or_vault_id.last_digits + :source_card_last_four => credit_card_or_vault_id.last_digits, + :eci_indicator => credit_card_or_vault_id.eci } end else diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index 973c4eae67e..17b70fda99b 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -390,7 +390,8 @@ def test_authorize_and_capture_with_android_pay_card :month => "01", :year => "2024", :source => :android_pay, - :transaction_id => "123456789" + :transaction_id => "123456789", + :eci => "05" ) assert auth = @gateway.authorize(@amount, credit_card, @options) @@ -441,7 +442,7 @@ def test_failed_void assert_equal 'voided', void.params["braintree_transaction"]["status"] assert failed_void = @gateway.void(auth.authorization) assert_failure failed_void - assert_equal 'Transaction can only be voided if status is authorized or submitted_for_settlement. (91504)', failed_void.message + assert_match('Transaction can only be voided if status is authorized', failed_void.message) assert_equal({"processor_response_code"=>"91504"}, failed_void.params["braintree_transaction"]) end diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index 3028e08259b..cfc9c64ca90 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -637,14 +637,14 @@ def test_android_pay_card :cryptogram => '111111111100cryptogram', :google_transaction_id => '1234567890', :source_card_type => "visa", - :source_card_last_four => "1111" + :source_card_last_four => "1111", + :eci_indicator => '05' } ). returns(braintree_result(:id => "transaction_id")) credit_card = network_tokenization_credit_card('4111111111111111', :brand => 'visa', - :transaction_id => "123", :eci => "05", :payment_cryptogram => "111111111100cryptogram", :source => :android_pay, From d1cdde418182f91a527f96f5a2dbbdce7afff30b Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Tue, 20 Jun 2017 19:30:55 +0530 Subject: [PATCH 106/677] JetPay V2: Support `store` and token based payments Also commit certification tests to the repo Closes #2475 --- CHANGELOG | 1 + .../billing/gateways/jetpay_v2.rb | 87 +++-- .../remote_jetpay_v2_certification_test.rb | 348 ++++++++++++++++++ test/remote/gateways/remote_jetpay_v2_test.rb | 2 +- 4 files changed, 407 insertions(+), 31 deletions(-) create mode 100644 test/remote/gateways/remote_jetpay_v2_certification_test.rb diff --git a/CHANGELOG b/CHANGELOG index 08750cb26cc..397f027f366 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * Openpay: Send customer name and email in authorize and purchase [dtykocki] #2468 * SafeCharge: Track currency from original transaction [davidsantoso] #2470 * Braintree Blue: Braintree Blue: Add ECI indicator to Android Pay transactions [davidsantoso] #2474 +* JetPay V2: Support store transactions and token based payments [shasum] #2475 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/jetpay_v2.rb b/lib/active_merchant/billing/gateways/jetpay_v2.rb index f29cacd02b2..9ca46601a2f 100644 --- a/lib/active_merchant/billing/gateways/jetpay_v2.rb +++ b/lib/active_merchant/billing/gateways/jetpay_v2.rb @@ -153,41 +153,41 @@ def initialize(options = {}) super end - def purchase(money, credit_card, options = {}) - commit(money, build_sale_request(money, credit_card, options)) + def purchase(money, payment, options = {}) + commit(money, build_sale_request(money, payment, options)) end - def authorize(money, credit_card, options = {}) - commit(money, build_authonly_request(money, credit_card, options)) + def authorize(money, payment, options = {}) + commit(money, build_authonly_request(money, payment, options)) end def capture(money, reference, options = {}) - split_authorization = reference.split(";") - transaction_id = split_authorization[0] - token = split_authorization[3] - commit(money, build_capture_request(transaction_id, money, options), token) + transaction_id, _, _, token = reference.split(";") + commit(money, build_capture_request(money, transaction_id, options), token) end def void(reference, options = {}) - transaction_id, approval, amount, token = reference.split(";") - commit(amount.to_i, build_void_request(amount.to_i, transaction_id, approval, token, options), token) + transaction_id, _, amount, token = reference.split(";") + commit(amount.to_i, build_void_request(amount.to_i, transaction_id, options), token) end - def credit(money, credit_card, options = {}) - commit(money, build_credit_request(money, nil, credit_card, nil, options)) + def credit(money, payment, options = {}) + commit(money, build_credit_request(money, nil, payment, options)) end def refund(money, reference, options = {}) - split_authorization = reference.split(";") - transaction_id = split_authorization[0] - token = split_authorization[3] - commit(money, build_credit_request(money, transaction_id, nil, token, options)) + transaction_id, _, _, token = reference.split(";") + commit(money, build_credit_request(money, transaction_id, token, options), token) end - def verify(credit_card, options={}) + def verify(credit_card, options = {}) authorize(0, credit_card, options) end + def store(credit_card, options = {}) + commit(nil, build_store_request(credit_card, options)) + end + def supports_scrubbing true end @@ -224,9 +224,9 @@ def build_xml_request(transaction_type, options = {}, transaction_id = nil, &blo end end - def build_sale_request(money, credit_card, options) + def build_sale_request(money, payment, options) build_xml_request('SALE', options) do |xml| - add_credit_card(xml, credit_card) + add_payment(xml, payment) add_addresses(xml, options) add_customer_data(xml, options) add_invoice_data(xml, options) @@ -237,9 +237,9 @@ def build_sale_request(money, credit_card, options) end end - def build_authonly_request(money, credit_card, options) + def build_authonly_request(money, payment, options) build_xml_request('AUTHONLY', options) do |xml| - add_credit_card(xml, credit_card) + add_payment(xml, payment) add_addresses(xml, options) add_customer_data(xml, options) add_invoice_data(xml, options) @@ -250,9 +250,10 @@ def build_authonly_request(money, credit_card, options) end end - def build_capture_request(transaction_id, money, options) + def build_capture_request(money, transaction_id, options) build_xml_request('CAPT', options, transaction_id) do |xml| add_invoice_data(xml, options) + add_purchase_order(xml, options) add_user_defined_fields(xml, options) xml.tag! 'TotalAmount', amount(money) @@ -260,25 +261,31 @@ def build_capture_request(transaction_id, money, options) end end - def build_void_request(money, transaction_id, approval, token, options) + def build_void_request(money, transaction_id, options) build_xml_request('VOID', options, transaction_id) do |xml| - xml.tag! 'Approval', approval xml.tag! 'TotalAmount', amount(money) - xml.tag! 'Token', token if token - xml.target! end end - def build_credit_request(money, transaction_id, card, token, options) + def build_credit_request(money, transaction_id, payment, options) build_xml_request('CREDIT', options, transaction_id) do |xml| - add_credit_card(xml, card) if card + add_payment(xml, payment) add_invoice_data(xml, options) add_addresses(xml, options) add_customer_data(xml, options) add_user_defined_fields(xml, options) xml.tag! 'TotalAmount', amount(money) - xml.tag! 'Token', token if token + + xml.target! + end + end + + def build_store_request(credit_card, options) + build_xml_request('TOKENIZE', options) do |xml| + add_payment(xml, credit_card) + add_addresses(xml, options) + add_customer_data(xml, options) xml.target! end @@ -344,6 +351,18 @@ def error_code_from(response) response[:action_code] end + def add_payment(xml, payment) + return unless payment + + if payment.is_a? String + token = payment + _, _, _, token = payment.split(";") if payment.include? ";" + xml.tag! 'Token', token if token + else + add_credit_card(xml, payment) + end + end + def add_credit_card(xml, credit_card) xml.tag! 'CardNum', credit_card.number, "CardPresent" => false, "Tokenize" => true xml.tag! 'CardExpMonth', format_exp(credit_card.month) @@ -391,7 +410,15 @@ def add_customer_data(xml, options) def add_invoice_data(xml, options) xml.tag! 'OrderNumber', options[:order_id] if options[:order_id] if tax_amount = options[:tax_amount] - xml.tag! 'TaxAmount', tax_amount, {'ExemptInd' => options[:tax_exemption] || "false"} + xml.tag! 'TaxAmount', tax_amount, {'ExemptInd' => options[:tax_exempt] || "false"} + end + end + + def add_purchase_order(xml, options) + if purchase_order = options[:purchase_order] + xml.tag! 'Billing' do + xml.tag! 'CustomerPO', purchase_order + end end end diff --git a/test/remote/gateways/remote_jetpay_v2_certification_test.rb b/test/remote/gateways/remote_jetpay_v2_certification_test.rb new file mode 100644 index 00000000000..4aef90a5de4 --- /dev/null +++ b/test/remote/gateways/remote_jetpay_v2_certification_test.rb @@ -0,0 +1,348 @@ +require 'test_helper' + +class RemoteJetpayV2CertificationTest < Test::Unit::TestCase + + def setup + @gateway = JetpayV2Gateway.new(fixtures(:jetpay_v2)) + + @unique_id = '' + + @options = { + :device => 'spreedly', + :application => 'spreedly', + :developer_id => 'GenkID', + :billing_address => address(:address1 => '1234 Fifth Street', :address2 => '', :city => 'Beaumont', :state => 'TX', :country => 'US', :zip => '77708'), + :shipping_address => address(:address1 => '1234 Fifth Street', :address2 => '', :city => 'Beaumont', :state => 'TX', :country => 'US', :zip => '77708'), + :email => 'test@test.com', + :ip => '127.0.0.1' + } + end + + def teardown + puts "\n#{@options[:order_id]}: #{@unique_id}" + end + + def test_certification_cnp1_authorize_mastercard + @options[:order_id] = "CNP1" + amount = 1000 + master = credit_card('5111111111111118', :month => 12, :year => 2017, :brand => 'master', :verification_value => '121') + assert response = @gateway.authorize(amount, master, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + end + + def test_certification_cnp2_authorize_visa + @options[:order_id] = "CNP2" + amount = 1105 + visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '121') + assert response = @gateway.authorize(amount, visa, @options) + assert_failure response + assert_equal "Do not honor.", response.message + @unique_id = response.params['unique_id'] + end + + def test_certification_cnp3_cnp4_authorize_and_capture_amex + @options[:order_id] = "CNP3" + amount = 1200 + amex = credit_card('378282246310005', :month => 12, :year => 2017, :brand => 'american_express', :verification_value => '1221') + assert response = @gateway.authorize(amount, amex, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + puts "\n#{@options[:order_id]}: #{@unique_id}" + + @options[:order_id] = "CNP4" + assert response = @gateway.capture(amount, response.authorization, @options) + assert_success response + @unique_id = response.params['unique_id'] + end + + def test_certification_cnp5_purchase_discover + @options[:order_id] = "CNP5" + amount = 1300 + discover = credit_card('6011111111111117', :month => 12, :year => 2017, :brand => 'discover', :verification_value => '121') + assert response = @gateway.purchase(amount, discover, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + end + + def test_certification_cnp6_purchase_visa + @options[:order_id] = "CNP6" + amount = 1405 + visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '120') + assert response = @gateway.purchase(amount, visa, @options) + assert_failure response + assert_equal "Do not honor.", response.message + @unique_id = response.params['unique_id'] + end + + def test_certification_cnp7_authorize_mastercard + @options[:order_id] = "CNP7" + amount = 1500 + master = credit_card('5111111111111118', :month => 12, :year => 2017, :brand => 'master', :verification_value => '120') + assert response = @gateway.authorize(amount, master, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + end + + def test_certification_cnp8_authorize_visa + @options[:order_id] = "CNP8" + amount = 1605 + visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '120') + assert response = @gateway.authorize(amount, visa, @options) + assert_failure response + assert_equal "Do not honor.", response.message + @unique_id = response.params['unique_id'] + end + + def test_certification_cnp9_cnp10_authorize_and_capture_amex + @options[:order_id] = "CNP9" + amount = 1700 + amex = credit_card('378282246310005', :month => 12, :year => 2017, :brand => 'american_express', :verification_value => '1220') + assert response = @gateway.authorize(amount, amex, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + puts "\n#{@options[:order_id]}: #{@unique_id}" + + @options[:order_id] = "CNP10" + assert response = @gateway.capture(amount, response.authorization, @options) + assert_success response + @unique_id = response.params['unique_id'] + end + + def test_certification_cnp11_purchase_discover + @options[:order_id] = "CNP11" + amount = 1800 + discover = credit_card('6011111111111117', :month => 12, :year => 2017, :brand => 'discover', :verification_value => '120') + assert response = @gateway.purchase(amount, discover, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + end + + def test_certification_rec01_recurring_mastercard + @options[:order_id] = "REC01" + @options[:origin] = "RECURRING" + @options[:billing_address] = nil + @options[:shipping_address] = nil + amount = 2000 + master = credit_card('5111111111111118', :month => 12, :year => 2017, :brand => 'master', :verification_value => '120') + assert response = @gateway.purchase(amount, master, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + end + + def test_certification_rec02_recurring_visa + @options[:order_id] = "REC02" + @options[:origin] = "RECURRING" + amount = 2100 + visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '') + assert response = @gateway.purchase(amount, visa, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + end + + def test_certification_rec03_recurring_amex + @options[:order_id] = "REC03" + @options[:origin] = "RECURRING" + amount = 2200 + amex = credit_card('378282246310005', :month => 12, :year => 2017, :brand => 'american_express', :verification_value => '1221') + assert response = @gateway.purchase(amount, amex, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + end + + def test_certification_corp07_corp08_authorize_and_capture_discover + @options[:order_id] = "CORP07" + amount = 2500 + discover = credit_card('6011111111111117', :month => 12, :year => 2018, :brand => 'discover', :verification_value => '120') + assert response = @gateway.authorize(amount, discover, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + puts "\n#{@options[:order_id]}: #{@unique_id}" + + @options[:order_id] = "CORP08" + assert response = @gateway.capture(amount, response.authorization, @options.merge(:tax_amount => "200")) + assert_success response + @unique_id = response.params['unique_id'] + end + + def test_certification_corp09_corp10_authorize_and_capture_visa + @options[:order_id] = "CORP09" + amount = 5000 + visa = credit_card('4111111111111111', :month => 12, :year => 2018, :brand => 'visa', :verification_value => '120') + assert response = @gateway.authorize(amount, visa, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + puts "\n#{@options[:order_id]}: #{@unique_id}" + + @options[:order_id] = "CORP10" + assert response = @gateway.capture(amount, response.authorization, @options.merge(:tax_amount => "0", :tax_exempt => "true")) + assert_success response + @unique_id = response.params['unique_id'] + end + + def test_certification_corp11_corp12_authorize_and_capture_mastercard + @options[:order_id] = "CORP11" + amount = 7500 + master = credit_card('5111111111111118', :month => 12, :year => 2018, :brand => 'master', :verification_value => '120') + assert response = @gateway.authorize(amount, master, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + puts "\n#{@options[:order_id]}: #{@unique_id}" + + @options[:order_id] = "CORP12" + assert response = @gateway.capture(amount, response.authorization, @options.merge(:tax_amount => "0", :tax_exempt => "false", :purchase_order => '456456')) + assert_success response + @unique_id = response.params['unique_id'] + end + + def test_certification_cred02_credit_visa + @options[:order_id] = "CRED02" + amount = 100 + visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '120') + assert response = @gateway.credit(amount, visa, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + end + + def test_certification_cred03_credit_amex + @options[:order_id] = "CRED03" + amount = 200 + amex = credit_card('378282246310005', :month => 12, :year => 2017, :brand => 'american_express', :verification_value => '1220') + assert response = @gateway.credit(amount, amex, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + end + + def test_certification_void03_void04_purchase_void_visa + @options[:order_id] = "VOID03" + amount = 300 + visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '120') + assert response = @gateway.purchase(amount, visa, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + puts "\n#{@options[:order_id]}: #{@unique_id}" + + @options[:order_id] = "VOID04" + transaction_id, approval, amount, token = response.authorization.split(";") + amount = 500 + authorization = [transaction_id, approval, amount, token].join(";") + assert response = @gateway.void(authorization, @options) + assert_failure response + @unique_id = response.params['unique_id'] + end + + def test_certification_void07_void08_void09_authorize_capture_void_discover + @options[:order_id] = "VOID07" + amount = 400 + discover = credit_card('6011111111111117', :month => 12, :year => 2017, :brand => 'discover', :verification_value => '120') + assert response = @gateway.authorize(amount, discover, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + puts "\n#{@options[:order_id]}: #{@unique_id}" + + @options[:order_id] = "VOID08" + amount = 600 + assert response = @gateway.capture(amount, response.authorization, @options) + assert_success response + @unique_id = response.params['unique_id'] + puts "\n#{@options[:order_id]}: #{@unique_id}" + + @options[:order_id] = "VOID09" + assert response = @gateway.void(response.authorization, @options) + assert_success response + @unique_id = response.params['unique_id'] + end + + def test_certification_void12_void13_credit_void_visa + @options[:order_id] = "VOID12" + amount = 800 + visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '120') + assert response = @gateway.credit(amount, visa, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + puts "\n#{@options[:order_id]}: #{@unique_id}" + + @options[:order_id] = "VOID13" + assert response = @gateway.void(response.authorization, @options) + assert_success response + @unique_id = response.params['unique_id'] + end + + def test_certification_tok15_tokenize_mastercard + @options[:order_id] = "TOK15" + master = credit_card('5111111111111118', :month => 12, :year => 2017, :brand => 'master', :verification_value => '101') + assert response = @gateway.store(master, @options) + assert_success response + assert_equal "APPROVED", response.message + assert_equal "TOKENIZED", response.params["response_text"] + @unique_id = response.params['unique_id'] + end + + def test_certification_tok16_authorize_with_token_request_visa + @options[:order_id] = "TOK16" + amount = 3100 + visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '101') + assert response = @gateway.authorize(amount, visa, @options) + assert_success response + assert_equal "APPROVED", response.message + transaction_id, approval, amount, token = response.authorization.split(";") + assert_equal token, response.params["token"] + @unique_id = response.params['unique_id'] + end + + def test_certification_tok17_purchase_with_token_request_amex + @options[:order_id] = "TOK17" + amount = 3200 + amex = credit_card('378282246310005', :month => 12, :year => 2017, :brand => 'american_express', :verification_value => '1001') + assert response = @gateway.purchase(amount, amex, @options) + assert_success response + assert_equal "APPROVED", response.message + transaction_id, approval, amount, token = response.authorization.split(";") + assert_equal token, response.params["token"] + @unique_id = response.params['unique_id'] + end + + def test_certification_tok18_authorize_using_token_mastercard + master = credit_card('5111111111111118', :month => 12, :year => 2017, :brand => 'master', :verification_value => '101') + assert response = @gateway.store(master, @options) + assert_success response + + @options[:order_id] = "TOK18" + amount = 3300 + assert response = @gateway.authorize(amount, response.authorization, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + end + + def test_certification_tok19_purchase_using_token_visa + visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '101') + assert response = @gateway.store(visa, @options) + assert_success response + + @options[:order_id] = "TOK19" + amount = 3400 + assert response = @gateway.purchase(amount, response.authorization, @options) + assert_success response + assert_equal "APPROVED", response.message + @unique_id = response.params['unique_id'] + end + +end diff --git a/test/remote/gateways/remote_jetpay_v2_test.rb b/test/remote/gateways/remote_jetpay_v2_test.rb index df1e15d9c10..9e35bd228f6 100644 --- a/test/remote/gateways/remote_jetpay_v2_test.rb +++ b/test/remote/gateways/remote_jetpay_v2_test.rb @@ -72,7 +72,7 @@ def test_successful_authorize_and_capture_with_tax assert_not_nil auth.authorization assert_not_nil auth.params["approval"] - assert capture = @gateway.capture(@amount_approved, auth.authorization, @options.merge(:tax_amount => '900', :tax_exemption => 'true')) + assert capture = @gateway.capture(@amount_approved, auth.authorization, @options.merge(:tax_amount => '990', :purchase_order => 'ABC12345')) assert_success capture end From 353b672fa2ae8b90fdee95c289174e631cb27235 Mon Sep 17 00:00:00 2001 From: Bart de Water Date: Wed, 21 Jun 2017 13:27:00 -0400 Subject: [PATCH 107/677] Cybersource: update supported card types --- lib/active_merchant/billing/gateways/cyber_source.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 9a0d4afa979..29d7087dcb9 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -26,7 +26,7 @@ class CyberSourceGateway < Gateway XSD_VERSION = "1.121" - self.supported_cardtypes = [:visa, :master, :american_express, :discover] + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :switch, :dankort, :maestro] self.supported_countries = %w(US BR CA CN DK FI FR DE JP MX NO SE GB SG LB) self.default_currency = 'USD' @@ -39,7 +39,12 @@ class CyberSourceGateway < Gateway :visa => '001', :master => '002', :american_express => '003', - :discover => '004' + :discover => '004', + :diners_club => '005', + :jcb => '007', + :switch => '024', + :dankort => '034', + :maestro => '042' } @@response_codes = { From d51bfa5512c95694aedfb2e48db3c1a98082493c Mon Sep 17 00:00:00 2001 From: Bart de Water Date: Wed, 21 Jun 2017 14:59:05 -0400 Subject: [PATCH 108/677] Add changelog entry for cybersource card update --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 397f027f366..db54b078897 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Cybersource: update supported card types [bdewater] #2477 * Moneris: Add 3DS fields for decrypted Apple and Android Pay data [davidsantoso] #2457 * Trexle: Add gateway support [hossamhossny] #2351 * QuickPay V10: Return last response for purchase and authorize [curiousepic] #2461 From 4d9263b3e9fd607a261724479a411893877a2848 Mon Sep 17 00:00:00 2001 From: Arbab Ahmed Date: Wed, 21 Jun 2017 13:58:50 -0400 Subject: [PATCH 109/677] Authorize.Net: Return failed response if forced refund settlement fails Closes #2476 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/authorize_net.rb | 2 ++ test/unit/gateways/authorize_net_test.rb | 9 +++++++++ 3 files changed, 12 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index db54b078897..9b3d9e4a67a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * SafeCharge: Track currency from original transaction [davidsantoso] #2470 * Braintree Blue: Braintree Blue: Add ECI indicator to Android Pay transactions [davidsantoso] #2474 * JetPay V2: Support store transactions and token based payments [shasum] #2475 +* Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index cb7c1e56491..ad42acb90f0 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -143,6 +143,8 @@ def refund(amount, authorization, options={}) if response.params["response_reason_code"] == INELIGIBLE_FOR_ISSUING_CREDIT_ERROR void(authorization, options) + else + response end end diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index eae3f37ea5f..61a16e1b416 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -563,6 +563,15 @@ def test_failed_full_refund_due_to_unsettled_payment_forces_void @gateway.refund(36.40, '2214269051#XXXX1234', force_full_refund_if_unsettled: true) end + def test_failed_full_refund_returns_failed_response_if_reason_code_is_not_unsettled_error + @gateway.expects(:ssl_post).returns(failed_refund_response) + @gateway.expects(:void).never + + response = @gateway.refund(36.40, '2214269051#XXXX1234', force_full_refund_if_unsettled: true) + assert response.present? + assert_failure response + end + def test_successful_store @gateway.expects(:ssl_post).returns(successful_store_response) From 66ca4da3fe38ff3daf1e42c936f714a5c451c07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Justin=20L=C3=A9ger?= Date: Tue, 13 Jun 2017 17:16:34 -0400 Subject: [PATCH 110/677] Payflow: Moved to name value pair (NVP) with payflow --- CHANGELOG | 1 + .../billing/gateways/payflow/payflow_common_api.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 9b3d9e4a67a..a4d8edd2f61 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * Braintree Blue: Braintree Blue: Add ECI indicator to Android Pay transactions [davidsantoso] #2474 * JetPay V2: Support store transactions and token based payments [shasum] #2475 * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 +* Payflow: Moved to name value pair (NVP) with payflow [jusleg] #2462 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb index e7ff8684417..768fb340f43 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb @@ -187,7 +187,8 @@ def build_headers(content_length) "X-VPS-Client-Timeout" => timeout.to_s, "X-VPS-VIT-Integration-Product" => "ActiveMerchant", "X-VPS-VIT-Runtime-Version" => RUBY_VERSION, - "X-VPS-Request-ID" => SecureRandom.hex(16) + "X-VPS-Request-ID" => SecureRandom.hex(16), + "PAYPAL-NVP" => "Y" } end From c14ef6108d547f4ade60e6d6a3e56424f4f6ea17 Mon Sep 17 00:00:00 2001 From: Krystian Czesak Date: Mon, 19 Jun 2017 15:24:24 -0400 Subject: [PATCH 111/677] FirstData: Add a default network tokenization strategy for FirstData E4 Right now, if you'd pass in any credit card type other than visa, mastercard or amex, the gateway would set the ECI value, without the cryptogram. This is actually causing a problem in the case where you'd be passing in a Discover card as: - Discover now supports network tokenization - FirstData E4 supports Discover So rather than passing in no XID or CAVV values, we'll revert on the default strategy which is to pass in the `transaction_id` and `payment_cryptogram` as the `XID` and `CAVV` parameters respectively, amex being the exception. Closes #2473 --- CHANGELOG | 1 + .../billing/gateways/firstdata_e4.rb | 9 +-- test/unit/gateways/firstdata_e4_test.rb | 69 ++++++++----------- 3 files changed, 32 insertions(+), 47 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a4d8edd2f61..5371cc6cdd6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * JetPay V2: Support store transactions and token based payments [shasum] #2475 * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 * Payflow: Moved to name value pair (NVP) with payflow [jusleg] #2462 +* FirstData: Add a default network tokenization strategy for FirstData E4 [krystosterone] #2473 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index f31427bc773..45039338773 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -262,16 +262,13 @@ def add_credit_card_verification_strings(xml, credit_card, options) def add_network_tokenization_credit_card(xml, credit_card) case card_brand(credit_card).to_sym - when :visa - xml.tag!("XID", credit_card.transaction_id) if credit_card.transaction_id - xml.tag!("CAVV", credit_card.payment_cryptogram) - when :mastercard - xml.tag!("XID", credit_card.transaction_id) if credit_card.transaction_id - xml.tag!("CAVV", credit_card.payment_cryptogram) when :american_express cryptogram = Base64.decode64(credit_card.payment_cryptogram) xml.tag!("XID", Base64.encode64(cryptogram[20...40])) xml.tag!("CAVV", Base64.encode64(cryptogram[0...20])) + else + xml.tag!("XID", credit_card.transaction_id) if credit_card.transaction_id + xml.tag!("CAVV", credit_card.payment_cryptogram) end end diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb index 7b832be6e24..7de7efb61e5 100755 --- a/test/unit/gateways/firstdata_e4_test.rb +++ b/test/unit/gateways/firstdata_e4_test.rb @@ -197,55 +197,42 @@ def test_eci_option_value end.respond_with(successful_purchase_response) end - def test_network_tokenization_requests_with_visa - stub_comms do - credit_card = network_tokenization_credit_card('4111111111111111', - :brand => 'visa', - :transaction_id => "123", - :eci => "05", - :payment_cryptogram => "111111111100cryptogram" - ) - - @gateway.purchase(@amount, credit_card, @options) - end.check_request do |endpoint, data, headers| - assert_match "05", data - assert_match "123", data - assert_match "111111111100cryptogram", data - end.respond_with(successful_purchase_response) - end - - def test_network_tokenization_requests_with_mastercard + def test_network_tokenization_requests_with_amex stub_comms do - credit_card = network_tokenization_credit_card('5555555555554444', - :brand => 'mastercard', - :transaction_id => "123", - :eci => "05", - :payment_cryptogram => "111111111100cryptogram" + credit_card = network_tokenization_credit_card( + "378282246310005", + brand: "american_express", + transaction_id: "123", + eci: "05", + payment_cryptogram: "whatever_the_cryptogram_of_at_least_20_characters_is", ) @gateway.purchase(@amount, credit_card, @options) - end.check_request do |endpoint, data, headers| + end.check_request do |_, data, _| assert_match "05", data - assert_match "123", data - assert_match "111111111100cryptogram", data + assert_match "mrLdtHIWq2nLXq7IrA==\n", data + assert_match "whateverthecryptogramofatlc=\n", data end.respond_with(successful_purchase_response) end - def test_network_tokenization_requests_with_amex - stub_comms do - credit_card = network_tokenization_credit_card('378282246310005', - :brand => 'american_express', - :transaction_id => "123", - :eci => "05", - :payment_cryptogram => Base64.encode64("111111111100cryptogram") - ) - - @gateway.purchase(@amount, credit_card, @options) - end.check_request do |endpoint, data, headers| - assert_match "05", data - assert_match "YW0=\n", data - assert_match "MTExMTExMTExMTAwY3J5cHRvZ3I=\n", data - end.respond_with(successful_purchase_response) + def test_network_tokenization_requests_with_other_brands + %w(visa mastercard other).each do |brand| + stub_comms do + credit_card = network_tokenization_credit_card( + "378282246310005", + brand: brand, + transaction_id: "123", + eci: "05", + payment_cryptogram: "whatever_the_cryptogram_is", + ) + + @gateway.purchase(@amount, credit_card, @options) + end.check_request do |_, data, _| + assert_match "05", data + assert_match "123", data + assert_match "whatever_the_cryptogram_is", data + end.respond_with(successful_purchase_response) + end end def test_requests_include_card_authentication_data From 61371011a92211a0f4572afe6aa9c328afc9d271 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Thu, 22 Jun 2017 15:56:39 -0400 Subject: [PATCH 112/677] FirstPay: Update hostname and force TLSv1 minimum Force TLSv1 since FirstPay doesn't support SSLv3. Additionally, the previous hostname used was returning certificate verification errors. After speaking with First Pay support, they pointed me to updated docs which listed a different hostname. FirstPay support confirmed that the secure.goemerchant.com hostname could/should be used instead and internally reported the certificate verification errors. Closes #2478 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/first_pay.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 5371cc6cdd6..9860991756a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 * Payflow: Moved to name value pair (NVP) with payflow [jusleg] #2462 * FirstData: Add a default network tokenization strategy for FirstData E4 [krystosterone] #2473 +* FirstPay: FirstPay: Update hostname and force TLSv1 minimum [davidsantoso] #2478 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb index fdf83cb0167..631304cbffd 100644 --- a/lib/active_merchant/billing/gateways/first_pay.rb +++ b/lib/active_merchant/billing/gateways/first_pay.rb @@ -3,7 +3,7 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class FirstPayGateway < Gateway - self.live_url = 'https://secure.1stpaygateway.net/secure/gateway/xmlgateway.aspx' + self.live_url = 'https://secure.goemerchant.com/secure/gateway/xmlgateway.aspx' self.supported_countries = ['US'] self.default_currency = 'USD' @@ -12,6 +12,7 @@ class FirstPayGateway < Gateway self.homepage_url = 'http://1stpaygateway.net/' self.display_name = '1stPayGateway.Net' + self.ssl_version = :TLSv1 def initialize(options={}) requires!(options, :transaction_center_id, :gateway_id) From 8ccfbcc1f251ffa79ca6830c5f84a63b68d2fe73 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Mon, 26 Jun 2017 13:29:10 -0400 Subject: [PATCH 113/677] Payflow: Set PAYPAL_NVP header as optional Closes #2480 --- CHANGELOG | 1 + .../billing/gateways/payflow/payflow_common_api.rb | 14 ++++++++------ test/unit/gateways/payflow_test.rb | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9860991756a..d132a7621fd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * Payflow: Moved to name value pair (NVP) with payflow [jusleg] #2462 * FirstData: Add a default network tokenization strategy for FirstData E4 [krystosterone] #2473 * FirstPay: FirstPay: Update hostname and force TLSv1 minimum [davidsantoso] #2478 +* Payflow: Set PAYPAL_NVP header as optional [davidsantoso] #2480 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb index 768fb340f43..0378042c4e6 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb @@ -180,21 +180,23 @@ def parse_element(response, node) end end - def build_headers(content_length) - { + def build_headers(content_length, options = {}) + headers = { "Content-Type" => "text/xml", "Content-Length" => content_length.to_s, "X-VPS-Client-Timeout" => timeout.to_s, "X-VPS-VIT-Integration-Product" => "ActiveMerchant", "X-VPS-VIT-Runtime-Version" => RUBY_VERSION, - "X-VPS-Request-ID" => SecureRandom.hex(16), - "PAYPAL-NVP" => "Y" + "X-VPS-Request-ID" => SecureRandom.hex(16) } + + headers.merge!("PAYPAL-NVP" => options[:paypal_nvp]) if options[:paypal_nvp] + headers end - def commit(request_body, options = {}) + def commit(request_body, options = {}) request = build_request(request_body, options) - headers = build_headers(request.size) + headers = build_headers(request.size, options) response = parse(ssl_post(test? ? self.test_url : self.live_url, request, headers)) diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb index bed9c171ebd..6faf786e741 100644 --- a/test/unit/gateways/payflow_test.rb +++ b/test/unit/gateways/payflow_test.rb @@ -376,7 +376,7 @@ def test_ensure_gateway_uses_safe_retry def test_timeout_is_same_in_header_and_xml timeout = PayflowGateway.timeout.to_s - headers = @gateway.send(:build_headers, 1) + headers = @gateway.send(:build_headers, 1, {}) assert_equal timeout, headers['X-VPS-Client-Timeout'] xml = @gateway.send(:build_request, 'dummy body') From 9c8f59ab5dfee384f0d793e42311d7acee6b04d5 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Mon, 26 Jun 2017 08:03:34 -0400 Subject: [PATCH 114/677] Authorize.net: Concatenate address1 and address2 Authorize.net does not provide a field for just address2. This combines address1 and address2 for both the `billTo` and `shipTo` elements. Remote: ``` ruby -Itest test/remote/gateways/remote_authorize_net_test.rb Loaded suite test/remote/gateways/remote_authorize_net_test Started ........................................................... Finished in 63.003082 seconds. ------------------------------------------------------------------------------------------------------------------------------------------------------- 59 tests, 204 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ------------------------------------------------------------------------------------------------------------------------------------------------------- 0.94 tests/s, 3.24 assertions/s ``` Unit: ``` ruby -Itest test/unit/gateways/authorize_net_test.rb Loaded suite test/unit/gateways/authorize_net_test Started ...................................................................................... Finished in 0.337633 seconds. ------------------------------------------------------------------------------------------------------------------------------------------------------- 86 tests, 490 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ------------------------------------------------------------------------------------------------------------------------------------------------------- 254.71 tests/s, 1451.28 assertions/s ``` Closes https://github.com/activemerchant/active_merchant/pull/2479 --- CHANGELOG | 1 + .../billing/gateways/authorize_net.rb | 9 ++++--- test/unit/gateways/authorize_net_test.rb | 26 +++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d132a7621fd..8f2cf3523b5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ * FirstData: Add a default network tokenization strategy for FirstData E4 [krystosterone] #2473 * FirstPay: FirstPay: Update hostname and force TLSv1 minimum [davidsantoso] #2478 * Payflow: Set PAYPAL_NVP header as optional [davidsantoso] #2480 +* Authorize.net: Concatenate address1 and address2 [dtykocki] #2479 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index ad42acb90f0..3eede82ac62 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -555,11 +555,12 @@ def add_billing_address(xml, payment_source, options) xml.billTo do first_name, last_name = names_from(payment_source, address, options) + full_address = "#{address[:address1]} #{address[:address2]}".strip + xml.firstName(truncate(first_name, 50)) unless empty?(first_name) xml.lastName(truncate(last_name, 50)) unless empty?(last_name) - xml.company(truncate(address[:company], 50)) unless empty?(address[:company]) - xml.address(truncate(address[:address1], 60)) + xml.address(truncate(full_address, 60)) xml.city(truncate(address[:city], 40)) xml.state(empty?(address[:state]) ? 'n/a' : truncate(address[:state], 40)) xml.zip(truncate((address[:zip] || options[:zip]), 20)) @@ -579,12 +580,12 @@ def add_shipping_address(xml, options, root_node="shipTo") else [address[:first_name], address[:last_name]] end + full_address = "#{address[:address1]} #{address[:address2]}".strip xml.firstName(truncate(first_name, 50)) unless empty?(first_name) xml.lastName(truncate(last_name, 50)) unless empty?(last_name) - xml.company(truncate(address[:company], 50)) unless empty?(address[:company]) - xml.address(truncate(address[:address1], 60)) + xml.address(truncate(full_address, 60)) xml.city(truncate(address[:city], 40)) xml.state(truncate(address[:state], 40)) xml.zip(truncate(address[:zip], 20)) diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 61a16e1b416..1a242d2a874 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -646,6 +646,20 @@ def test_address end.respond_with(successful_authorize_response) end + def test_address_with_address2_present + stub_comms do + @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', address2: 'Apt 1234', country: 'US', state: 'CO', phone: '(555)555-5555', fax: '(555)555-4444'}) + end.check_request do |endpoint, data, headers| + parse(data) do |doc| + assert_equal "CO", doc.at_xpath("//billTo/state").content, data + assert_equal "164 Waverley Street Apt 1234", doc.at_xpath("//billTo/address").content, data + assert_equal "US", doc.at_xpath("//billTo/country").content, data + assert_equal "(555)555-5555", doc.at_xpath("//billTo/phoneNumber").content + assert_equal "(555)555-4444", doc.at_xpath("//billTo/faxNumber").content + end + end.respond_with(successful_authorize_response) + end + def test_address_outsite_north_america stub_comms do @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', country: 'DE', state: ''}) @@ -658,6 +672,18 @@ def test_address_outsite_north_america end.respond_with(successful_authorize_response) end + def test_address_outsite_north_america_with_address2_present + stub_comms do + @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', address2: 'Apt 1234', country: 'DE', state: ''}) + end.check_request do |endpoint, data, headers| + parse(data) do |doc| + assert_equal "n/a", doc.at_xpath("//billTo/state").content, data + assert_equal "164 Waverley Street Apt 1234", doc.at_xpath("//billTo/address").content, data + assert_equal "DE", doc.at_xpath("//billTo/country").content, data + end + end.respond_with(successful_authorize_response) + end + def test_duplicate_window stub_comms do @gateway.purchase(@amount, @credit_card, duplicate_window: 0) From c90e9a4f9ffeede6f97fae01707af6ab1d76ec61 Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Tue, 27 Jun 2017 09:19:43 -0400 Subject: [PATCH 115/677] Release version 1.68.0 --- CHANGELOG | 26 ++++++++++++++------------ lib/active_merchant/version.rb | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8f2cf3523b5..4267b3b1c74 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,23 +1,25 @@ = ActiveMerchant CHANGELOG == HEAD + +== Version 1.68.0 (June 27, 2017) +* Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 +* Authorize.net: Concatenate address1 and address2 [dtykocki] #2479 +* Braintree Blue: Braintree Blue: Add ECI indicator to Android Pay transactions [davidsantoso] #2474 +* Credorax: Support 0- and 3-exponent currencies [curiousepic] * Cybersource: update supported card types [bdewater] #2477 +* FirstData: Add a default network tokenization strategy for FirstData E4 [krystosterone] #2473 +* FirstPay: FirstPay: Update hostname and force TLSv1 minimum [davidsantoso] #2478 +* JetPay V2: Support store transactions and token based payments [shasum] #2475 * Moneris: Add 3DS fields for decrypted Apple and Android Pay data [davidsantoso] #2457 -* Trexle: Add gateway support [hossamhossny] #2351 -* QuickPay V10: Return last response for purchase and authorize [curiousepic] #2461 -* Support three-decimal currencies [curiousepic] #2466 -* Credorax: Support 0- and 3-exponent currencies [curiousepic] -* SafeCharge: Map billing address fields [davidsantoso] #2464 * Openpay: Send customer name and email in authorize and purchase [dtykocki] #2468 -* SafeCharge: Track currency from original transaction [davidsantoso] #2470 -* Braintree Blue: Braintree Blue: Add ECI indicator to Android Pay transactions [davidsantoso] #2474 -* JetPay V2: Support store transactions and token based payments [shasum] #2475 -* Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 * Payflow: Moved to name value pair (NVP) with payflow [jusleg] #2462 -* FirstData: Add a default network tokenization strategy for FirstData E4 [krystosterone] #2473 -* FirstPay: FirstPay: Update hostname and force TLSv1 minimum [davidsantoso] #2478 * Payflow: Set PAYPAL_NVP header as optional [davidsantoso] #2480 -* Authorize.net: Concatenate address1 and address2 [dtykocki] #2479 +* QuickPay V10: Return last response for purchase and authorize [curiousepic] #2461 +* SafeCharge: Map billing address fields [davidsantoso] #2464 +* SafeCharge: Track currency from original transaction [davidsantoso] #2470 +* Support three-decimal currencies [curiousepic] #2466 +* Trexle: Add gateway support [hossamhossny] #2351 == Version 1.67.0 (June 8, 2017) * Acapture: Pass 3D Secure fields [davidsantoso] #2451 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index fed970f4dc2..de80e17172c 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.67.0" + VERSION = "1.68.0" end From 182ad376cafe199b8969829423097eeda4cf5b9a Mon Sep 17 00:00:00 2001 From: David Santoso Date: Wed, 28 Jun 2017 13:31:55 -0400 Subject: [PATCH 116/677] WePay: Add payer_rbits and transaction_rbits optional fields Closes #2482 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/wepay.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 4267b3b1c74..517d23d3a77 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/wepay.rb b/lib/active_merchant/billing/gateways/wepay.rb index d16c91d8a22..6b86c5efd7f 100644 --- a/lib/active_merchant/billing/gateways/wepay.rb +++ b/lib/active_merchant/billing/gateways/wepay.rb @@ -148,6 +148,8 @@ def add_product_data(post, money, options) post[:preapproval_id] = options[:preapproval_id] if options[:preapproval_id] post[:prefill_info] = options[:prefill_info] if options[:prefill_info] post[:funding_sources] = options[:funding_sources] if options[:funding_sources] + post[:payer_rbits] = options[:payer_rbits] if options[:payer_rbits] + post[:transaction_rbits] = options[:transaction_rbits] if options[:transaction_rbits] add_fee(post, options) end From 9321be0495dd6da2e27764841a4bdd27b3783b14 Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Wed, 28 Jun 2017 13:45:51 -0400 Subject: [PATCH 117/677] Adyen: Use Active Merchant standard order_id option for reference From https://docs.adyen.com/developers/api-reference/payments-api#paymentrequest > A reference to uniquely identify the payment. This reference is used > in all communication with you about the payment status. We recommend > using a unique value per payment; however, it is not a requirement. The `order_id` option is what is used for this throughout Active Merchant. Let's do that for the Adyen gateway too instead of requiring a gateway specific option. Merges #2483 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 6 +++--- test/unit/gateways/adyen_test.rb | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 517d23d3a77..93bfd10b7b8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] +* Adyen: Use Active Merchant standard order_id option for reference [jasonwebster] #2483 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index 744331a0245..1b387bd5cb4 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -40,7 +40,7 @@ def purchase(money, payment, options={}) end def authorize(money, payment, options={}) - requires!(options, :reference) + requires!(options, :order_id) post = init_post(options) add_invoice(post, money, options) add_payment(post, payment) @@ -118,7 +118,7 @@ def add_invoice(post, money, options) value: amount(money), currency: options[:currency] || currency(money) } - post[:reference] = options[:reference] + post[:reference] = options[:order_id] post[:amount] = amount end @@ -145,7 +145,7 @@ def add_payment(post, payment) def add_references(post, authorization, options = {}) post[:originalReference] = authorization - post[:reference] = options[:reference] + post[:reference] = options[:order_id] end def parse(body) diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index 488b2f3025c..63b042f3a5a 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -22,8 +22,8 @@ def setup @amount = 100 @options = { - :billing_address => address(), - reference: '345123' + billing_address: address(), + order_id: '345123' } end From cc52e7418ac550ffc5b2daa5d7cb4374446243d2 Mon Sep 17 00:00:00 2001 From: David Perry Date: Thu, 29 Jun 2017 11:59:09 -0400 Subject: [PATCH 118/677] Correct calculation for three-exponent currencies The first implementation of support for three-exponent currencies used both incorrect calculations and incorrect tests. These have been corrected. Closes #2486 --- CHANGELOG | 1 + lib/active_merchant/billing/gateway.rb | 4 ++-- test/unit/gateways/gateway_test.rb | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 93bfd10b7b8..4dd0f3bff14 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] * Adyen: Use Active Merchant standard order_id option for reference [jasonwebster] #2483 +* Correct calculation for three-exponent currencies [curiousepic] #2486 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateway.rb b/lib/active_merchant/billing/gateway.rb index b0f7cc8b65d..1b7461e1387 100644 --- a/lib/active_merchant/billing/gateway.rb +++ b/lib/active_merchant/billing/gateway.rb @@ -280,9 +280,9 @@ def localized_amount(money, currency) end elsif three_decimal_currency?(currency) if self.money_format == :cents - (amount.to_i * 10).to_s + amount.to_s else - sprintf("%.3f", amount.to_f) + sprintf("%.3f", (amount.to_f / 10)) end end end diff --git a/test/unit/gateways/gateway_test.rb b/test/unit/gateways/gateway_test.rb index 5454bea75b5..465c513d76b 100644 --- a/test/unit/gateways/gateway_test.rb +++ b/test/unit/gateways/gateway_test.rb @@ -94,12 +94,12 @@ def test_localized_amount_returns_three_decimal_places_for_three_decimal_currenc @gateway.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND) Gateway.money_format = :dollars - assert_equal '1.000', @gateway.send(:localized_amount, 100, 'OMR') - assert_equal '12.340', @gateway.send(:localized_amount, 1234, 'BHD') + assert_equal '0.100', @gateway.send(:localized_amount, 100, 'OMR') + assert_equal '1.234', @gateway.send(:localized_amount, 1234, 'BHD') Gateway.money_format = :cents - assert_equal '1000', @gateway.send(:localized_amount, 100, 'OMR') - assert_equal '12340', @gateway.send(:localized_amount, 1234, 'BHD') + assert_equal '100', @gateway.send(:localized_amount, 100, 'OMR') + assert_equal '1234', @gateway.send(:localized_amount, 1234, 'BHD') end def test_split_names From 86e0c7060074c8a44ed9d7c1d946791ecbd35897 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Fri, 30 Jun 2017 12:57:50 -0400 Subject: [PATCH 119/677] SagePay: Use VPSTxId from authorization for refunds SagePay does not return the `VPSTxId` field in the response of successful capture transactions. For refunds, the `VPSTxId` field from authorization transactions must be used instead. Closes #2489 --- CHANGELOG | 1 + .../billing/gateways/sage_pay.rb | 4 +- test/fixtures.yml | 2 +- test/remote/gateways/remote_sage_pay_test.rb | 22 +++++++---- test/unit/gateways/sage_pay_test.rb | 39 +++++++++++++++++++ 5 files changed, 57 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4dd0f3bff14..b12a5705888 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] * Adyen: Use Active Merchant standard order_id option for reference [jasonwebster] #2483 * Correct calculation for three-exponent currencies [curiousepic] #2486 +* SagePay: Use VPSTxId from authorization for refunds [dtykocki] #2489 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index a05dd2a80e5..5ff3f869ea9 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -359,9 +359,9 @@ def authorization_from(response, params, action) response['Token'] else [ params[:VendorTxCode], - response["VPSTxId"], + response["VPSTxId"] || params[:VPSTxId], response["TxAuthNo"], - response["SecurityKey"], + response["SecurityKey"] || params[:SecurityKey], action ].join(";") end end diff --git a/test/fixtures.yml b/test/fixtures.yml index 7d6ee6ffa5f..25ce67b376b 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -1047,7 +1047,7 @@ sage: password: 'Z5W2S8J7X8T5' sage_pay: - login: LOGIN + login: spreedly sallie_mae: login: TEST0 diff --git a/test/remote/gateways/remote_sage_pay_test.rb b/test/remote/gateways/remote_sage_pay_test.rb index 7c538ebc2f4..1c469dbedaf 100644 --- a/test/remote/gateways/remote_sage_pay_test.rb +++ b/test/remote/gateways/remote_sage_pay_test.rb @@ -124,6 +124,20 @@ def test_successful_authorization_and_capture assert_success capture end + def test_successful_authorization_and_capture_and_refund + assert auth = @gateway.authorize(@amount, @mastercard, @options) + assert_success auth + + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + + assert refund = @gateway.refund(@amount, capture.authorization, + :description => 'Crediting trx', + :order_id => generate_unique_id + ) + assert_success refund + end + def test_successful_authorization_and_void assert auth = @gateway.authorize(@amount, @mastercard, @options) assert_success auth @@ -159,14 +173,6 @@ def test_successful_visa_purchase assert !response.authorization.blank? end - # Maestro is not available for GBP - # def test_successful_maestro_purchase - # assert response = @gateway.purchase(@amount, @maestro, @options) - # assert_success response - # assert response.test? - # assert !response.authorization.blank? - # end - def test_successful_amex_purchase assert response = @gateway.purchase(@amount, @amex, @options) assert_success response diff --git a/test/unit/gateways/sage_pay_test.rb b/test/unit/gateways/sage_pay_test.rb index 439b1483577..c81bea7356a 100644 --- a/test/unit/gateways/sage_pay_test.rb +++ b/test/unit/gateways/sage_pay_test.rb @@ -285,6 +285,26 @@ def test_truncate_accounts_for_url_encoding assert_equal "Joikam Lomström", @gateway.send(:truncate, "Joikam Lomström Rate", 20) end + def test_successful_authorization_and_capture_and_refund + auth = stub_comms do + @gateway.authorize(@amount, @credit_card, @options) + end.respond_with(successful_authorize_response) + assert_success auth + + capture = stub_comms do + @gateway.capture(@amount, auth.authorization) + end.respond_with(successful_capture_response) + assert_success capture + + refund = stub_comms do + @gateway.refund(@amount, capture.authorization, + order_id: generate_unique_id, + description: "Refund txn" + ) + end.respond_with(successful_refund_response) + assert_success refund + end + private def purchase_with_options(optional) @@ -339,6 +359,25 @@ def successful_authorize_response RESP end + def successful_refund_response + <<-RESP +VPSProtocol=3.00 +Status=OK +StatusDetail=0000 : The Authorisation was Successful. +SecurityKey=KUMJBP02HM +TxAuthNo=15282432 +VPSTxId={08C870A9-1E53-3852-BA44-CBC91612CBCA} + RESP + end + + def successful_capture_response + <<-RESP +VPSProtocol=3.00 +Status=OK +StatusDetail=2004 : The Release was Successful. + RESP + end + def unsuccessful_authorize_response <<-RESP VPSProtocol=2.23 From 6f8ad33cead0d1cf83ca210c947a911038c73cc2 Mon Sep 17 00:00:00 2001 From: Philippe Gauthier Date: Tue, 4 Jul 2017 14:11:08 -0400 Subject: [PATCH 120/677] Payflow: Move PAYPAL-NVP header option to a class attribute on the payment gateway Closes #2492 --- CHANGELOG | 1 + .../billing/gateways/payflow/payflow_common_api.rb | 13 ++++++++++--- test/unit/gateways/payflow_test.rb | 13 ++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b12a5705888..045f0fb8bed 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Adyen: Use Active Merchant standard order_id option for reference [jasonwebster] #2483 * Correct calculation for three-exponent currencies [curiousepic] #2486 * SagePay: Use VPSTxId from authorization for refunds [dtykocki] #2489 +* Payflow: Move PAYPAL-NVP header option to a class attribute on the payment gateway [deuxpi] #2492 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb index 0378042c4e6..225f746eaea 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb @@ -25,6 +25,13 @@ def self.included(base) # subsequent Responses will have a :duplicate parameter set in the params # hash. base.retry_safe = true + + # Send Payflow requests to PayPal directly by activating the NVP protocol. + # Valid XMLPay documents may have issues being parsed correctly by + # Payflow but will be accepted by PayPal if a PAYPAL-NVP request header + # is declared. + base.class_attribute :use_paypal_nvp + base.use_paypal_nvp = false end XMLNS = 'http://www.paypal.com/XMLPay' @@ -180,7 +187,7 @@ def parse_element(response, node) end end - def build_headers(content_length, options = {}) + def build_headers(content_length) headers = { "Content-Type" => "text/xml", "Content-Length" => content_length.to_s, @@ -190,13 +197,13 @@ def build_headers(content_length, options = {}) "X-VPS-Request-ID" => SecureRandom.hex(16) } - headers.merge!("PAYPAL-NVP" => options[:paypal_nvp]) if options[:paypal_nvp] + headers.merge!("PAYPAL-NVP" => "Y") if self.use_paypal_nvp headers end def commit(request_body, options = {}) request = build_request(request_body, options) - headers = build_headers(request.size, options) + headers = build_headers(request.size) response = parse(ssl_post(test? ? self.test_url : self.live_url, request, headers)) diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb index 6faf786e741..b2dc750d51f 100644 --- a/test/unit/gateways/payflow_test.rb +++ b/test/unit/gateways/payflow_test.rb @@ -376,7 +376,7 @@ def test_ensure_gateway_uses_safe_retry def test_timeout_is_same_in_header_and_xml timeout = PayflowGateway.timeout.to_s - headers = @gateway.send(:build_headers, 1, {}) + headers = @gateway.send(:build_headers, 1) assert_equal timeout, headers['X-VPS-Client-Timeout'] xml = @gateway.send(:build_request, 'dummy body') @@ -401,6 +401,17 @@ def test_passed_in_verbosity assert_equal '2014-06-25 09:33:41', response.params['transaction_time'] end + def test_paypal_nvp_option_sends_header + headers = @gateway.send(:build_headers, 1) + assert_not_include headers, 'PAYPAL-NVP' + + old_use_paypal_nvp = PayflowGateway.use_paypal_nvp + PayflowGateway.use_paypal_nvp = true + headers = @gateway.send(:build_headers, 1) + assert_equal 'Y', headers['PAYPAL-NVP'] + PayflowGateway.use_paypal_nvp = old_use_paypal_nvp + end + private def successful_recurring_response <<-XML From baf12f1473537e4cf032c7a8ec994a1d06fe717d Mon Sep 17 00:00:00 2001 From: David Perry Date: Fri, 23 Jun 2017 13:56:50 -0400 Subject: [PATCH 121/677] Optimal Payments: Pass CVD indicator accurately Previously, CVD Indicator was sent as '1' along with a blank CVD field, if a CVV was not present, causing a schema error failure. Now, CVD Indicator is properly passed as '0' with no CVD field when CVV is not present, which appears to allow CVV-less transactions to be accepted, at least in the test environment. Unit: 18 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 14 tests, 68 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2491 --- CHANGELOG | 1 + .../billing/gateways/optimal_payment.rb | 4 +++- .../gateways/remote_optimal_payment_test.rb | 9 ++++++- test/unit/gateways/optimal_payment_test.rb | 24 +++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 045f0fb8bed..110f62f90cf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * Correct calculation for three-exponent currencies [curiousepic] #2486 * SagePay: Use VPSTxId from authorization for refunds [dtykocki] #2489 * Payflow: Move PAYPAL-NVP header option to a class attribute on the payment gateway [deuxpi] #2492 +* Optimal Payments: Pass CVD indicator accurately [curiousepic] #2491 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb index 9604335381d..c1d2ced8671 100644 --- a/lib/active_merchant/billing/gateways/optimal_payment.rb +++ b/lib/active_merchant/billing/gateways/optimal_payment.rb @@ -259,9 +259,11 @@ def build_card(xml, opts) if brand = card_type(@credit_card.brand) xml.tag! 'cardType' , brand end - if @credit_card.verification_value + if @credit_card.verification_value? xml.tag! 'cvdIndicator' , '1' # Value Provided xml.tag! 'cvd' , @credit_card.verification_value + else + xml.tag! 'cvdIndicator' , '0' end end end diff --git a/test/remote/gateways/remote_optimal_payment_test.rb b/test/remote/gateways/remote_optimal_payment_test.rb index fa034da690d..f4a84194904 100644 --- a/test/remote/gateways/remote_optimal_payment_test.rb +++ b/test/remote/gateways/remote_optimal_payment_test.rb @@ -44,6 +44,13 @@ def test_unsuccessful_purchase assert_equal 'auth declined', response.message end + def test_purchase_with_no_cvv + @credit_card.verification_value = '' + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'no_error', response.message + end + def test_authorize_and_capture assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth @@ -134,6 +141,6 @@ def test_invalid_login ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal 'invalid credentials', response.message + assert_equal 'invalid merchant account', response.message end end diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb index 2beade96c86..1e0ddb93914 100644 --- a/test/unit/gateways/optimal_payment_test.rb +++ b/test/unit/gateways/optimal_payment_test.rb @@ -128,6 +128,29 @@ def test_purchase_without_billing_address assert_success response end + def test_cvd_fields_pass_correctly + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match (/cvdIndicator%3E1%3C\/cvdIndicator%3E%0A%20%20%20%20%3Ccvd%3E123%3C\/cvd/), data + end.respond_with(successful_purchase_response) + + credit_card = CreditCard.new( + :number => '4242424242424242', + :month => 9, + :year => Time.now.year + 1, + :first_name => 'Longbob', + :last_name => 'Longsen', + :brand => 'visa' + ) + + stub_comms do + @gateway.purchase(@amount, credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match (/cvdIndicator%3E0%3C\/cvdIndicator%3E%0A%20%20%3C\/card/), data + end.respond_with(failed_purchase_response) + end + def test_successful_void @gateway.expects(:ssl_post).returns(successful_purchase_response) @@ -266,6 +289,7 @@ def minimal_request #{Time.now.year + 1} VI + 0 WEB From 2bc76048c9a161339d160e85775f8d160f5c626e Mon Sep 17 00:00:00 2001 From: David Perry Date: Wed, 5 Jul 2017 15:42:41 -0400 Subject: [PATCH 122/677] SagePay: Make Repeat purchase if payment is a past authorization The previous implementation of Repeat purchases required a flag to be passed in as an option. Now, the payment method is checked and if it is a past purchase authorization string, the transaction will automatically be sent as a Repeat purchase. Unit: 35 tests, 117 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 36 tests, 101 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2495 --- CHANGELOG | 1 + .../billing/gateways/sage_pay.rb | 18 ++++++++++++------ test/remote/gateways/remote_sage_pay_test.rb | 3 +-- test/unit/gateways/sage_pay_test.rb | 9 +++++++++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 110f62f90cf..e8d111e4cd0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * SagePay: Use VPSTxId from authorization for refunds [dtykocki] #2489 * Payflow: Move PAYPAL-NVP header option to a class attribute on the payment gateway [deuxpi] #2492 * Optimal Payments: Pass CVD indicator accurately [curiousepic] #2491 +* SagePay: Make Repeat purchase if payment is a past authorization [curiousepic] #2495 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index 5ff3f869ea9..dabac8358aa 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -88,7 +88,7 @@ def purchase(money, payment_method, options = {}) add_customer_data(post, options) add_optional_data(post, options) - commit((options[:repeat] ? :repeat : :purchase), post) + commit((past_purchase_reference?(payment_method) ? :repeat : :purchase), post) end def authorize(money, payment_method, options = {}) @@ -268,12 +268,14 @@ def add_invoice(post, options) end def add_payment_method(post, payment_method, options) - if options[:repeat] - add_related_reference(post, payment_method) - elsif payment_method.respond_to?(:number) - add_credit_card(post, payment_method) + if payment_method.is_a?(String) + if past_purchase_reference?(payment_method) + add_related_reference(post, payment_method) + else + add_token_details(post, payment_method, options) + end else - add_token_details(post, payment_method, options) + add_credit_card(post, payment_method) end end @@ -422,6 +424,10 @@ def add_pair(post, key, value, options = {}) post[key] = value if !value.blank? || options[:required] end + def past_purchase_reference?(payment_method) + return false unless payment_method.is_a?(String) + payment_method.split(';').last == 'purchase' + end end end diff --git a/test/remote/gateways/remote_sage_pay_test.rb b/test/remote/gateways/remote_sage_pay_test.rb index 1c469dbedaf..7826d0074e4 100644 --- a/test/remote/gateways/remote_sage_pay_test.rb +++ b/test/remote/gateways/remote_sage_pay_test.rb @@ -323,8 +323,7 @@ def test_successful_purchase_with_website def test_successful_repeat_purchase response = @gateway.purchase(@amount, @visa, @options) assert_success response - - repeat = @gateway.purchase(@amount, response.authorization, @options.merge(repeat: true, order_id: generate_unique_id)) + repeat = @gateway.purchase(@amount, response.authorization, @options.merge(order_id: generate_unique_id)) assert_success repeat end diff --git a/test/unit/gateways/sage_pay_test.rb b/test/unit/gateways/sage_pay_test.rb index c81bea7356a..7932dae938e 100644 --- a/test/unit/gateways/sage_pay_test.rb +++ b/test/unit/gateways/sage_pay_test.rb @@ -305,6 +305,15 @@ def test_successful_authorization_and_capture_and_refund assert_success refund end + def test_repeat_purchase_with_reference_token + stub_comms(@gateway, :ssl_request) do + @gateway.purchase(@amount, "1455548a8d178beecd88fe6a285f50ff;{0D2ACAF0-FA64-6DFF-3869-7ADDDC1E0474};15353766;BS231FNE14;purchase", @options) + end.check_request do |method, endpoint, data, headers| + assert_match(/RelatedVPSTxId=%7B0D2ACAF0-FA64-6DFF-3869-7ADDDC1E0474%/, data) + assert_match(/TxType=REPEAT/, data) + end.respond_with(successful_purchase_response) + end + private def purchase_with_options(optional) From 0b6c76db24342f9e589644d8fc40cb65512c8653 Mon Sep 17 00:00:00 2001 From: Ian Irving Date: Fri, 2 Jun 2017 18:01:09 -0400 Subject: [PATCH 123/677] Netbanx: Update supported countries and cardtypes --- lib/active_merchant/billing/gateways/netbanx.rb | 17 ++++++++++------- test/unit/gateways/netbanx_test.rb | 16 ---------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/lib/active_merchant/billing/gateways/netbanx.rb b/lib/active_merchant/billing/gateways/netbanx.rb index 7c7ee9e2db1..3804ec10092 100644 --- a/lib/active_merchant/billing/gateways/netbanx.rb +++ b/lib/active_merchant/billing/gateways/netbanx.rb @@ -5,16 +5,22 @@ class NetbanxGateway < Gateway self.test_url = 'https://api.test.netbanx.com/' self.live_url = 'https://api.netbanx.com/' - self.supported_countries = ['CA', 'US', 'GB'] + self.supported_countries = %w(AF AX AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE BZ BJ BM BT BO BQ BA BW BV BR IO BN BG BF BI KH CM CA CV KY CF TD CL CN CX CC CO KM CG CD CK CR CI HR CU CW CY CZ DK DJ DM DO EC EG SV GQ ER EE ET FK FO FJ FI FR GF PF TF GA GM GE DE GH GI GR GL GD GP GU GT GG GN GW GY HT HM HN HK HU IS IN ID IR IQ IE IM IL IT JM JP JE JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU MO MK MG MW MY MV ML MT MH MQ MR MU YT MX FM MD MC MN ME MS MA MZ MM NA NR NP NC NZ NI NE NG NU NF MP NO OM PK PW PS PA PG PY PE PH PN PL PT PR QA RE RO RU RW BL SH KN LC MF VC WS SM ST SA SN RS SC SL SG SX SK SI SB SO ZA GS SS ES LK PM SD SR SJ SZ SE CH SY TW TJ TZ TH NL TL TG TK TO TT TN TR TM TC TV UG UA AE GB US UM UY UZ VU VA VE VN VG VI WF EH YE ZM ZW) self.default_currency = 'CAD' - self.supported_cardtypes = [:visa, :master, :american_express, :discover] + self.supported_cardtypes = [ + :american_express, + :diners_club, + :discover, + :jcb, + :master, + :maestro, + :visa + ] self.money_format = :cents self.homepage_url = 'https://processing.paysafe.com/' self.display_name = 'Netbanx by PaySafe' - STANDARD_ERROR_CODE_MAPPING = {} - def initialize(options={}) requires!(options, :account_number, :api_key) super @@ -110,9 +116,6 @@ def add_settle_with_auth(post) def add_customer_data(post, options) post[:merchantCustomerId] = (options[:merchant_customer_id] || SecureRandom.uuid) post[:locale] = options[:locale] - # if options[:billing_address] - # post[:address] = map_address(options[:billing_address]) - # end end def add_credit_card(post, credit_card, options = {}) diff --git a/test/unit/gateways/netbanx_test.rb b/test/unit/gateways/netbanx_test.rb index e1130d469b7..7140bbd85f8 100644 --- a/test/unit/gateways/netbanx_test.rb +++ b/test/unit/gateways/netbanx_test.rb @@ -138,18 +138,6 @@ def test_successful_purchase_with_token assert response.test? end - def test_successful_unstore - @gateway.expects(:ssl_request).twice.returns(successful_unstore_response) - - response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015|e4a3cd5a-56db-4d9b-97d3-fdd9ab3bd0f4') - assert_success response - assert response.test? - - response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015') - assert_success response - assert response.test? - end - def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed @@ -603,8 +591,4 @@ def successful_store_response } RESPONSE end - - # just returns a 200 when successful - def successful_unstore_response - end end From 3fe217db3fc5dffe75dc112239cacccbdcd9b602 Mon Sep 17 00:00:00 2001 From: Ian Irving Date: Tue, 4 Jul 2017 16:40:53 -0400 Subject: [PATCH 124/677] Netbanx: map response errorCodes onto standard error code Closes #2456 --- CHANGELOG | 2 + .../billing/gateways/netbanx.rb | 44 +++++++++++++++++++ test/unit/gateways/netbanx_test.rb | 42 ++++++++++++++++++ 3 files changed, 88 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index e8d111e4cd0..25030658eeb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,8 @@ * Payflow: Move PAYPAL-NVP header option to a class attribute on the payment gateway [deuxpi] #2492 * Optimal Payments: Pass CVD indicator accurately [curiousepic] #2491 * SagePay: Make Repeat purchase if payment is a past authorization [curiousepic] #2495 +* Netbanx: map response errorCodes onto standard error code [iirving] #2456 +* Netbanx: Update supported countries and cardtypes [iirving] #2456 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/netbanx.rb b/lib/active_merchant/billing/gateways/netbanx.rb index 3804ec10092..2f88291c6f5 100644 --- a/lib/active_merchant/billing/gateways/netbanx.rb +++ b/lib/active_merchant/billing/gateways/netbanx.rb @@ -16,6 +16,7 @@ class NetbanxGateway < Gateway :maestro, :visa ] + self.money_format = :cents self.homepage_url = 'https://processing.paysafe.com/' @@ -195,6 +196,7 @@ def commit(method, uri, parameters) message_from(success, response), response, :test => test?, + :error_code => error_code_from(response), :authorization => authorization_from(success, get_url(uri), method, response) ) end @@ -243,6 +245,48 @@ def headers 'User-Agent' => "Netbanx-Paysafe v1.0/ActiveMerchant #{ActiveMerchant::VERSION}" } end + + def error_code_from(response) + unless success_from(response) + case response['errorCode'] + when '3002' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid card number or brand or combination of card number and brand with your request. + when '3004' then STANDARD_ERROR_CODE[:incorrect_zip] # The zip/postal code must be provided for an AVS check request. + when '3005' then STANDARD_ERROR_CODE[:incorrect_cvc] # You submitted an incorrect CVC value with your request. + when '3006' then STANDARD_ERROR_CODE[:expired_card] # You submitted an expired credit card number with your request. + when '3009' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank. + when '3011' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the card used is a restricted card. Contact the cardholder's credit card company for further investigation. + when '3012' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the credit card expiry date submitted is invalid. + when '3013' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to problems with the credit card account. + when '3014' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined - the issuing bank has returned an unknown response. Contact the card holder's credit card company for further investigation. + when '3015' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you process the transaction manually by calling the cardholder's credit card company. + when '3016' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – it may be a lost or stolen card. + when '3017' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid credit card number with your request. + when '3022' then STANDARD_ERROR_CODE[:card_declined] # The card has been declined due to insufficient funds. + when '3023' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to its proprietary card activity regulations. + when '3024' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the issuing bank does not permit the transaction for this card. + when '3032' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank or external gateway because the card is probably in one of their negative databases. + when '3035' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to exceeded PIN attempts. + when '3036' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid issuer. + when '3037' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because it is invalid. + when '3038' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to customer cancellation. + when '3039' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid authentication value. + when '3040' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the request type is not permitted on the card. + when '3041' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a timeout. + when '3042' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a cryptographic error. + when '3045' then STANDARD_ERROR_CODE[:invalid_expiry_date] # You submitted an invalid date format for this request. + when '3046' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount was set to zero. + when '3047' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount exceeds the floor limit. + when '3048' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount is less than the floor limit. + when '3049' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card has expired. + when '3050' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – fraudulent activity is suspected. + when '3051' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – contact the acquirer for more information. + when '3052' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card is restricted. + when '3053' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – please call the acquirer. + when '3054' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined due to suspected fraud. + else STANDARD_ERROR_CODE[:processing_error] + end + end + end end end end diff --git a/test/unit/gateways/netbanx_test.rb b/test/unit/gateways/netbanx_test.rb index 7140bbd85f8..509effac9e9 100644 --- a/test/unit/gateways/netbanx_test.rb +++ b/test/unit/gateways/netbanx_test.rb @@ -138,6 +138,19 @@ def test_successful_purchase_with_token assert response.test? end + def test_successful_unstore + @gateway.expects(:ssl_request).twice.returns(successful_unstore_response) + + response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015|e4a3cd5a-56db-4d9b-97d3-fdd9ab3bd0f4') + assert_success response + assert response.test? + + response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015') + assert_success response + assert response.test? + end + + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed @@ -591,4 +604,33 @@ def successful_store_response } RESPONSE end + + def successful_unstore_response + <<-RESPONSE + { + "id": "2f840ab3-0e71-4387-bad3-4705e6f4b015", + "status": "ACTIVE", + "merchantCustomerId": "5e9d1ab0f847d147ffe872a9faf76d98", + "locale": "en_GB", + "paymentToken": "PJzuA8s6c6pSIs4", + "addresses": [], + "cards": [ + { + "status": "ACTIVE", + "id": "e4a3cd5a-56db-4d9b-97d3-fdd9ab3bd0f4", + "cardBin": "453091", + "lastDigits": "2345", + "cardExpiry": { + "year": 2017, + "month": 9 + }, + "holderName": "Longbob Longsen", + "cardType": "VI", + "paymentToken": "C6gmdUA1xWT8RsC", + "defaultCardIndicator": true + } + ] + } + RESPONSE + end end From 8315b8e09beb329b7efab0f451e29d2a9a4ad57e Mon Sep 17 00:00:00 2001 From: David Perry Date: Fri, 30 Jun 2017 10:54:09 -0400 Subject: [PATCH 125/677] Barclaycard Smartpay: Support 0- and 3-exponent currencies Unit: 17 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 22 tests, 45 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2498 --- CHANGELOG | 1 + .../billing/gateways/barclaycard_smartpay.rb | 6 +++-- .../remote_barclaycard_smartpay_test.rb | 16 +++++++++++ .../gateways/barclaycard_smartpay_test.rb | 27 ++++++++++++++----- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 25030658eeb..897342132c6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * SagePay: Make Repeat purchase if payment is a past authorization [curiousepic] #2495 * Netbanx: map response errorCodes onto standard error code [iirving] #2456 * Netbanx: Update supported countries and cardtypes [iirving] #2456 +* Barclaycard Smartpay: Support 0- and 3-exponent currencies [curiousepic] #2498 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index d62014232a5..77e4b94c60e 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -6,6 +6,7 @@ class BarclaycardSmartpayGateway < Gateway self.supported_countries = ['AL', 'AD', 'AM', 'AT', 'AZ', 'BY', 'BE', 'BA', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'GE', 'DE', 'GR', 'HU', 'IS', 'IE', 'IT', 'KZ', 'LV', 'LI', 'LT', 'LU', 'MK', 'MT', 'MD', 'MC', 'ME', 'NL', 'NO', 'PL', 'PT', 'RO', 'RU', 'SM', 'RS', 'SK', 'SI', 'ES', 'SE', 'CH', 'TR', 'UA', 'GB', 'VA'] self.default_currency = 'EUR' + self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND) self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro] @@ -238,9 +239,10 @@ def address_hash(address) end def amount_hash(money, currency) + currency = currency || currency(money) hash = {} - hash[:currency] = currency || currency(money) - hash[:value] = amount(money) if money + hash[:currency] = currency + hash[:value] = localized_amount(money, currency) if money hash end diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index d7d7e7bec06..3831434921e 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -166,6 +166,22 @@ def test_avs_result assert_equal 'N', response.avs_result['code'] end + def test_nonfractional_currency + response = @gateway.authorize(1234, @credit_card, @options.merge(:currency => 'JPY')) + assert_success response + + response = @gateway.purchase(1234, @credit_card, @options.merge(:currency => 'JPY')) + assert_success response + end + + def test_three_decimal_currency + response = @gateway.authorize(1234, @credit_card, @options.merge(:currency => 'OMR')) + assert_success response + + response = @gateway.purchase(1234, @credit_card, @options.merge(:currency => 'OMR')) + assert_success response + end + def test_transcript_scrubbing transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb index 0febeb7ce32..e7f93a0950c 100644 --- a/test/unit/gateways/barclaycard_smartpay_test.rb +++ b/test/unit/gateways/barclaycard_smartpay_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class BarclaycardSmartpayTest < Test::Unit::TestCase + include CommStub + def setup @gateway = BarclaycardSmartpayGateway.new( company: 'company', @@ -116,15 +118,26 @@ def test_unsuccessful_verify assert_equal "Refused", response.message end - def test_fractional_currency - @gateway.expects(:ssl_post).returns(successful_authorize_response) - @gateway.expects(:post_data).with do |params| - '100' == params['amount.value'] && 'JPY' == params['amount.currency'] - end + 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| + assert_match(/amount.value=1/, data) + assert_match(/amount.currency=JPY/, data) + end.respond_with(successful_authorize_response) + + assert_success response + end - @options[:currency] = 'JPY' + 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| + assert_match(/amount.value=100/, data) + assert_match(/amount.currency=OMR/, data) + end.respond_with(successful_authorize_response) - @gateway.authorize(@amount, @credit_card, @options) + assert_success response end def test_successful_store From 34e44db06b95fbdadf199747ad148d8bc8d73f83 Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Thu, 6 Jul 2017 11:17:31 -0400 Subject: [PATCH 126/677] Add XSD schema validation to CyberSource requests The CyberSource Simple (heh) Order API has some strict element ordering requirements around auths, captures and network tokenization fields. This adds a schema validator to ensure that we're always compliant. c/o @bdewater --- .../CyberSourceTransaction_1.121.xsd | 3627 +++++++++++++++++ test/unit/gateways/cyber_source_test.rb | 41 +- 2 files changed, 3663 insertions(+), 5 deletions(-) create mode 100644 test/schema/cyber_source/CyberSourceTransaction_1.121.xsd diff --git a/test/schema/cyber_source/CyberSourceTransaction_1.121.xsd b/test/schema/cyber_source/CyberSourceTransaction_1.121.xsd new file mode 100644 index 00000000000..dbf57b71011 --- /dev/null +++ b/test/schema/cyber_source/CyberSourceTransaction_1.121.xsd @@ -0,0 +1,3627 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index b94d51dce62..0df3df0a91e 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -1,4 +1,5 @@ require 'test_helper' +require 'nokogiri' class CyberSourceTest < Test::Unit::TestCase include CommStub @@ -354,11 +355,24 @@ def test_unsuccessful_verify end def test_successful_auth_with_network_tokenization_for_visa - @gateway.expects(:ssl_post).with do |host, request_body| - assert_match %r'\n 111111111100cryptogram\n vbv\n 111111111100cryptogram\n\n\n 1\n', request_body - true - end.returns(successful_purchase_response) + credit_card = network_tokenization_credit_card('4111111111111111', + :brand => 'visa', + :transaction_id => "123", + :eci => "05", + :payment_cryptogram => "111111111100cryptogram" + ) + response = stub_comms do + @gateway.authorize(@amount, credit_card, @options) + end.check_request do |_endpoint, body, _headers| + assert_xml_valid_to_xsd(body) + assert_match %r'\n 111111111100cryptogram\n vbv\n 111111111100cryptogram\n\n\n 1\n', body + end.respond_with(successful_purchase_response) + + assert_success response + end + + def test_successful_purchase_with_network_tokenization_for_visa credit_card = network_tokenization_credit_card('4111111111111111', :brand => 'visa', :transaction_id => "123", @@ -366,12 +380,19 @@ def test_successful_auth_with_network_tokenization_for_visa :payment_cryptogram => "111111111100cryptogram" ) - assert response = @gateway.authorize(@amount, credit_card, @options) + 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 + 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| + 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) @@ -389,6 +410,7 @@ def test_successful_auth_with_network_tokenization_for_mastercard def test_successful_auth_with_network_tokenization_for_amex @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) @@ -669,4 +691,13 @@ def malformed_xml_response 2008-01-15T21:42:03.343Zb0a6cf9aa07f1a8495f89c364bbd6a9a2004333231260008401927ACCEPT100Afvvj7Ke2Fmsbq0wHFE2sM6R4GAptYZ0jwPSA+R9PhkyhFTb0KRjoE4+ynthZrG6tMBwjAtTUSD1001.00123456YYMM2008-01-15T21:42:03Z00U

XML end + + def assert_xml_valid_to_xsd(data, root_element = '//s:Body/*') + schema_file = File.open("#{File.dirname(__FILE__)}/../../schema/cyber_source/CyberSourceTransaction_#{CyberSourceGateway::XSD_VERSION}.xsd") + doc = Nokogiri::XML(data) + root = Nokogiri::XML(doc.xpath(root_element).to_s) + xsd = Nokogiri::XML::Schema(schema_file) + errors = xsd.validate(root) + assert_empty errors, "XSD validation errors in the following XML:\n#{root}" + end end From 69a2628ae70087ec5c9571a4d85a23d0686c076f Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Thu, 6 Jul 2017 11:19:54 -0400 Subject: [PATCH 127/677] Fix CyberSource request schema validation issues As per an email exchange we had with CyberSource support, the `paymentNetworkToken` element must always come after the `ccCaptureService` element. This was not the case for us for purchase transactions, as we set it in the `add_auth_service` method, which means it was sandwiched between `ccAuthService` and `ccCaptureService`. This also cleans up a few other XSD validation violations, none of which should be significant--just some empty tags here and there. Also, I renamed `add_network_tokenization` to `add_auth_network_tokenization`, since that's actually what it was doing--it was only used for authorization transactions (as it was responsible to for adding the `ccAuthService` commands to the request). Closes #2497 --- CHANGELOG | 1 + .../billing/gateways/cyber_source.rb | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 897342132c6..5ab04dc2406 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Netbanx: map response errorCodes onto standard error code [iirving] #2456 * Netbanx: Update supported countries and cardtypes [iirving] #2456 * Barclaycard Smartpay: Support 0- and 3-exponent currencies [curiousepic] #2498 +* CyberSource: Fix XSD schema validation issues [jasonwebster] #2497 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 29d7087dcb9..8ac9201df0b 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -258,6 +258,7 @@ def build_auth_request(money, creditcard_or_reference, options) add_decision_manager_fields(xml, options) add_mdd_fields(xml, options) add_auth_service(xml, creditcard_or_reference, options) + add_payment_network_token(xml) if network_tokenization?(creditcard_or_reference) add_business_rules_data(xml, creditcard_or_reference, options) xml.target! end @@ -293,6 +294,7 @@ def build_purchase_request(money, payment_method_or_reference, options) add_check_service(xml) else add_purchase_service(xml, payment_method_or_reference, options) + add_payment_network_token(xml) if network_tokenization?(payment_method_or_reference) add_business_rules_data(xml, payment_method_or_reference, options) unless options[:pinless_debit_card] end xml.target! @@ -355,6 +357,7 @@ def build_create_subscription_request(payment_method, options) add_check_service(xml, options) else add_purchase_service(xml, payment_method, options) + add_payment_network_token(xml) if network_tokenization?(payment_method) end end add_subscription_create_service(xml, options) @@ -471,6 +474,8 @@ def add_creditcard(xml, creditcard) end def add_decision_manager_fields(xml, options) + return unless options[:decision_manager_enabled] + xml.tag! 'decisionManager' do xml.tag! 'enabled', options[:decision_manager_enabled] if options[:decision_manager_enabled] xml.tag! 'profile', options[:decision_manager_profile] if options[:decision_manager_profile] @@ -478,6 +483,8 @@ def add_decision_manager_fields(xml, options) end def add_mdd_fields(xml, options) + return unless options.keys.any? { |key| key.to_s.start_with?("mdd_field") } + xml.tag! 'merchantDefinedData' do (1..100).each do |each| key = "mdd_field_#{each}".to_sym @@ -503,7 +510,7 @@ def add_tax_service(xml) def add_auth_service(xml, payment_method, options) if network_tokenization?(payment_method) - add_network_tokenization(xml, payment_method, options) + add_auth_network_tokenization(xml, payment_method, options) else xml.tag! 'ccAuthService', {'run' => 'true'} end @@ -513,7 +520,7 @@ def network_tokenization?(payment_method) payment_method.is_a?(NetworkTokenizationCreditCard) end - def add_network_tokenization(xml, payment_method, options) + def add_auth_network_tokenization(xml, payment_method, options) return unless network_tokenization?(payment_method) case card_brand(payment_method).to_sym @@ -539,9 +546,11 @@ def add_network_tokenization(xml, payment_method, options) xml.tag!("xid", Base64.encode64(cryptogram[20...40])) end end + end + def add_payment_network_token(xml) xml.tag! 'paymentNetworkToken' do - xml.tag!('transactionType', "1") + xml.tag!('transactionType', '1') end end From 2a13e950c00c7d352284d32bc30d336ba390ebd1 Mon Sep 17 00:00:00 2001 From: David Perry Date: Wed, 21 Jun 2017 13:20:51 -0400 Subject: [PATCH 128/677] WorldPay: Support three-decimal currencies Unit: 36 tests, 205 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 22 tests, 75 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2501 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/worldpay.rb | 9 ++++++++- test/remote/gateways/remote_worldpay_test.rb | 7 +++++++ test/unit/gateways/worldpay_test.rb | 8 ++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 5ab04dc2406..3da231903d5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * Netbanx: Update supported countries and cardtypes [iirving] #2456 * Barclaycard Smartpay: Support 0- and 3-exponent currencies [curiousepic] #2498 * CyberSource: Fix XSD schema validation issues [jasonwebster] #2497 +* WorldPay: Support three-decimal currencies [curiousepic] #2501 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index dfa9804ef50..4a7a1cb1d07 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -9,6 +9,7 @@ class WorldpayGateway < Gateway self.supported_countries = %w(HK GB AU AD BE CH CY CZ DE DK ES FI FR GI GR HU IE IL IT LI LU MC MT NL NO NZ PL PT SE SG SI SM TR UM VA) self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :laser, :switch] self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW) + self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND) self.homepage_url = 'http://www.worldpay.com/' self.display_name = 'Worldpay Global' @@ -194,7 +195,7 @@ def add_amount(xml, money, options) amount_hash = { :value => localized_amount(money, currency), 'currencyCode' => currency, - 'exponent' => non_fractional_currency?(currency) ? 0 : 2 + 'exponent' => currency_exponent(currency) } if options[:debit_credit_indicator] @@ -369,6 +370,12 @@ def encoded_credentials credentials = "#{@options[:login]}:#{@options[:password]}" "Basic #{[credentials].pack('m').strip}" end + + def currency_exponent(currency) + return 0 if non_fractional_currency?(currency) + return 3 if three_decimal_currency?(currency) + return 2 + end end end end diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index 3d9769abf17..6fe5d6efe94 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -123,6 +123,13 @@ def test_authorize_nonfractional_currency assert_equal "0", result.params['amount_exponent'] end + def test_authorize_three_decimal_currency + assert_success(result = @gateway.authorize(1234, @credit_card, @options.merge(:currency => 'OMR'))) + assert_equal "OMR", result.params['amount_currency_code'] + assert_equal "1234", result.params['amount_value'] + assert_equal "3", result.params['amount_exponent'] + end + def test_reference_transaction assert_success(original = @gateway.authorize(100, @credit_card, @options)) assert_success(@gateway.authorize(200, original.authorization, :order_id => generate_unique_id)) diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index 78f5f96fb0e..a9443a29bfd 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -223,6 +223,14 @@ def test_currency_exponent_handling {'value' => '100', 'exponent' => '0', 'currencyCode' => 'JPY'}, data end.respond_with(successful_authorize_response) + + stub_comms do + @gateway.authorize(10000, @credit_card, @options.merge(currency: :OMR)) + end.check_request do |endpoint, data, headers| + assert_tag_with_attributes 'amount', + {'value' => '10000', 'exponent' => '3', 'currencyCode' => 'OMR'}, + data + end.respond_with(successful_authorize_response) end def test_address_handling From 58b7141feedeb331f01661f99cf5fea08e75dcf3 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Thu, 6 Jul 2017 15:51:27 -0400 Subject: [PATCH 129/677] NMI: Add first and lastname to echeck transactions Closes #2499 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/nmi.rb | 2 ++ test/unit/gateways/nmi_test.rb | 2 ++ 3 files changed, 5 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 3da231903d5..a90fb693e19 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * Barclaycard Smartpay: Support 0- and 3-exponent currencies [curiousepic] #2498 * CyberSource: Fix XSD schema validation issues [jasonwebster] #2497 * WorldPay: Support three-decimal currencies [curiousepic] #2501 +* NMI: Add first and lastname to echeck transactions [dtykocki] #2499 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb index d923cbd6ab5..3af76b0150f 100644 --- a/lib/active_merchant/billing/gateways/nmi.rb +++ b/lib/active_merchant/billing/gateways/nmi.rb @@ -146,6 +146,8 @@ def add_payment_method(post, payment_method, options) post[:token_cryptogram] = payment_method.payment_cryptogram elsif(card_brand(payment_method) == 'check') post[:payment] = 'check' + post[:firstname] = payment_method.first_name + post[:lastname] = payment_method.last_name post[:checkname] = payment_method.name post[:checkaba] = payment_method.routing_number post[:checkaccount] = payment_method.account_number diff --git a/test/unit/gateways/nmi_test.rb b/test/unit/gateways/nmi_test.rb index c2d01a04cef..e5ad32ae22c 100644 --- a/test/unit/gateways/nmi_test.rb +++ b/test/unit/gateways/nmi_test.rb @@ -70,6 +70,8 @@ def test_successful_purchase_with_echeck assert_match(/type=sale/, data) assert_match(/amount=1.00/, data) assert_match(/payment=check/, data) + assert_match(/firstname=#{@check.first_name}/, data) + assert_match(/lastname=#{@check.last_name}/, data) assert_match(/checkname=#{@check.name}/, CGI.unescape(data)) assert_match(/checkaba=#{@check.routing_number}/, data) assert_match(/checkaccount=#{@check.account_number}/, data) From 5373ed002471b857269dcf824bd0db26c941d541 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Tue, 27 Jun 2017 09:36:48 -0400 Subject: [PATCH 130/677] PayFlow: Add optional email field Payflow includes an optional email field outside of the address block. This allows the email address to still be sent with authorize and purchase transactions even if a billing address isn't included. Closes #2505 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/payflow.rb | 1 + test/fixtures.yml | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a90fb693e19..12a777bc5c7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * CyberSource: Fix XSD schema validation issues [jasonwebster] #2497 * WorldPay: Support three-decimal currencies [curiousepic] #2501 * NMI: Add first and lastname to echeck transactions [dtykocki] #2499 +* PayFlow: Add optional email field [davidsantoso] #2505 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb index 817ff39712d..6e7d0e6f1b6 100644 --- a/lib/active_merchant/billing/gateways/payflow.rb +++ b/lib/active_merchant/billing/gateways/payflow.rb @@ -152,6 +152,7 @@ def build_credit_card_request(action, money, credit_card, options) xml.tag! 'FreightAmt', options[:freightamt] unless options[:freightamt].blank? xml.tag! 'DutyAmt', options[:dutyamt] unless options[:dutyamt].blank? xml.tag! 'DiscountAmt', options[:discountamt] unless options[:discountamt].blank? + xml.tag! 'EMail', options[:email] unless options[:email].nil? billing_address = options[:billing_address] || options[:address] add_address(xml, 'BillTo', billing_address, options) if billing_address diff --git a/test/fixtures.yml b/test/fixtures.yml index 25ce67b376b..4cda70e0730 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -651,9 +651,9 @@ payex: # Working credentials, no need to replace payflow: - login: spreedly - password: 'ibB4Z8=d;G' - partner: PayPal + login: 'spreedlyIntegrations' + password: 'y9q)(j7H' + partner: 'PayPal' payflow_uk: login: LOGIN From 54614ede05ebdfe9f8a2b5c0d1824269287e245a Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 27 Jun 2017 15:08:39 -0400 Subject: [PATCH 131/677] Worldpay: Support Credit on CFT-enabled merchant IDs Worldpay only supports Credits (aka Payouts) by sending a transaction with the same structure as an Authorization, but with its action flagged as REFUND and a Merchant ID (login credential) that has been flagged by Worldpay to treat these transactions as a Credit (they call it a Credit Fund Transfer or CFT). Purchases, normal Refunds, and other transactions should only be performed with the separate Merchant ID flagged as eCom. Unit: 37 tests, 205 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 22 tests, 73 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2503 --- CHANGELOG | 1 + .../billing/gateways/worldpay.rb | 19 ++++++++++++- test/fixtures.yml | 8 ++++-- test/remote/gateways/remote_worldpay_test.rb | 19 ++++++++++--- test/unit/gateways/worldpay_test.rb | 27 +++++++++++++++++++ 5 files changed, 67 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 12a777bc5c7..808b19e17de 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * WorldPay: Support three-decimal currencies [curiousepic] #2501 * NMI: Add first and lastname to echeck transactions [dtykocki] #2499 * PayFlow: Add optional email field [davidsantoso] #2505 +* Worldpay: Support Credit on CFT-enabled merchant IDs [curiousepic] #2503 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index 4a7a1cb1d07..54746246ef7 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -72,6 +72,14 @@ def refund(money, authorization, options = {}) void(authorization, options ) if response.params["last_event"] == "AUTHORISED" end + # Credits only function on a Merchant ID/login/profile flagged for Payouts + # aka Credit Fund Transfers (CFT), whereas normal purchases, refunds, + # and other transactions should be performed on a normal eCom-flagged + # merchant ID. + def credit(money, payment_method, options = {}) + credit_request(money, payment_method, options.merge(:credit => true)) + end + def verify(credit_card, options={}) MultiResponse.run(:use_first_response) do |r| r.process { authorize(100, credit_card, options) } @@ -112,6 +120,10 @@ def refund_request(money, authorization, options) commit('refund', build_refund_request(money, authorization, options), :ok) end + def credit_request(money, payment_method, options) + commit('credit', build_authorization_request(money, payment_method, options), :ok) + end + def build_request xml = Builder::XmlMarkup.new :indent => 2 xml.instruct! :xml, :encoding => 'UTF-8' @@ -217,7 +229,7 @@ def add_payment_method(xml, amount, payment_method, options) end end else - xml.tag! 'paymentDetails' do + xml.tag! 'paymentDetails', credit_fund_transfer_attribute(options) do xml.tag! CARD_CODES[card_brand(payment_method)] do xml.tag! 'cardNumber', payment_method.number xml.tag! 'expiryDate' do @@ -366,6 +378,11 @@ def authorization_from(raw) (pair ? pair.last : nil) end + def credit_fund_transfer_attribute(options) + return unless options[:credit] + {'action' => "REFUND"} + end + def encoded_credentials credentials = "#{@options[:login]}:#{@options[:password]}" "Basic #{[credentials].pack('m').strip}" diff --git a/test/fixtures.yml b/test/fixtures.yml index 4cda70e0730..d7a24fa9fc9 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -1223,8 +1223,12 @@ world_net: secret: 'sandboxEUR' world_pay_gateway: - login: LOGIN - password: PASSWORD + login: 'SPREEDLY' + password: 'KZ#P2aR+' + +world_pay_gateway_cft: + login: 'SPREEDLYCFT' + password: 'Xbf+6#pD' worldpay_online_payments: client_key: "T_C_b9f629e7-cea7-4edb-8206-24bbe351d699" diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index 6fe5d6efe94..d4473dbe40d 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -4,6 +4,7 @@ class RemoteWorldpayTest < Test::Unit::TestCase def setup @gateway = WorldpayGateway.new(fixtures(:world_pay_gateway)) + @cftgateway = WorldpayGateway.new(fixtures(:world_pay_gateway_cft)) @amount = 100 @credit_card = credit_card('4111111111111111') @@ -168,6 +169,12 @@ def test_failed_verify assert_match %r{REFUSED}, response.message end + def test_successful_credit_on_cft_gateway + credit = @cftgateway.credit(@amount, @credit_card, @options) + assert_success credit + assert_equal "SUCCESS", credit.message + end + def test_transcript_scrubbing transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) @@ -180,18 +187,22 @@ def test_transcript_scrubbing # Worldpay has a delay between asking for a transaction to be captured and actually marking it as captured - # These 2 tests work if you take the auth code, wait some time and then perform the next operation. + # These 2 tests work if you get authorizations from a purchase, wait some time and then perform the refund/void operation. - # def test_refund + # def get_authorization # assert_success(response = @gateway.purchase(@amount, @credit_card, @options)) # assert response.authorization - # refund = @gateway.refund(@amount, capture.authorization) + # puts "auth: " + response.authorization + # end + + # def test_refund + # refund = @gateway.refund(@amount, 'replace_with_authorization') # assert_success refund # assert_equal "SUCCESS", refund.message # end # def test_void_fails_unless_status_is_authorised - # response = @gateway.void("33d6dfa9726198d44a743488cf611d3b") # existing transaction in CAPTURED state + # response = @gateway.void('replace_with_authorization') # existing transaction in CAPTURED state # assert_failure response # assert_equal "A transaction status of 'AUTHORISED' is required.", response.message # end diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index a9443a29bfd..560aebba69b 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -164,6 +164,16 @@ def test_capture assert_success response end + def test_successful_credit + response = stub_comms do + @gateway.credit(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match(//, data) + end.respond_with(successful_credit_response) + assert_success response + assert_equal '3d4187536044bd39ad6a289c4339c41c', response.authorization + end + def test_description stub_comms do @gateway.authorize(@amount, @credit_card, @options) @@ -704,6 +714,23 @@ def failed_void_response REQUEST end + def successful_credit_response + <<-RESPONSE + + + + + + + + + + + + RESPONSE + end + def sample_authorization_request <<-REQUEST From 65ec5dcf5d7636721fad8fa56bd54120c8c498be Mon Sep 17 00:00:00 2001 From: David Santoso Date: Wed, 12 Jul 2017 11:01:14 -0400 Subject: [PATCH 132/677] FirstPay: Add processor_id field For context- this field is used to identify the processor to run the transaction under. I should also note the lack of remote tests since this field is on a per merchant account basis so unfortunately there isn't really any test data to exercise a specific response. Closes #2506 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/first_pay.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 808b19e17de..36fbb5d16b7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * NMI: Add first and lastname to echeck transactions [dtykocki] #2499 * PayFlow: Add optional email field [davidsantoso] #2505 * Worldpay: Support Credit on CFT-enabled merchant IDs [curiousepic] #2503 +* FirstPay: Add processor_id field [davidsantoso] #2506 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb index 631304cbffd..3627b37cc44 100644 --- a/lib/active_merchant/billing/gateways/first_pay.rb +++ b/lib/active_merchant/billing/gateways/first_pay.rb @@ -67,6 +67,7 @@ def add_authentication(post, options) def add_customer_data(post, options) post[:owner_email] = options[:email] if options[:email] post[:remote_ip_address] = options[:ip] if options[:ip] + post[:processor_id] = options[:processor_id] if options[:processor_id] end def add_address(post, creditcard, options) From 2f91be6fc53a5d68dfc31dc4dd09d519ce8bc5c6 Mon Sep 17 00:00:00 2001 From: Michael Elfassy Date: Wed, 12 Jul 2017 11:30:50 -0400 Subject: [PATCH 133/677] Release version 1.69.0 --- CHANGELOG | 2 ++ lib/active_merchant/version.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 36fbb5d16b7..f8963d91fd9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ = ActiveMerchant CHANGELOG == HEAD + +== Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] * Adyen: Use Active Merchant standard order_id option for reference [jasonwebster] #2483 * Correct calculation for three-exponent currencies [curiousepic] #2486 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index de80e17172c..b9b0fadca9c 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.68.0" + VERSION = "1.69.0" end From 496fdac8c808429d4342e7a83bb162ed23aaaaa6 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Thu, 6 Jul 2017 10:37:32 -0400 Subject: [PATCH 134/677] Auth.Net: Use two character default for billing state For addresses in North America, billing state is a required field, should not contain any symbols, and must be a valid two-character state code. Instead of defaulting to "N/A", now default to "NC". Closes #2496 --- CHANGELOG | 1 + .../billing/gateways/authorize_net.rb | 11 +++++- .../gateways/remote_authorize_net_test.rb | 20 +++++++++++ test/unit/gateways/authorize_net_test.rb | 34 ++++++++++++++++--- 4 files changed, 61 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f8963d91fd9..2111204867a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * PayFlow: Add optional email field [davidsantoso] #2505 * Worldpay: Support Credit on CFT-enabled merchant IDs [curiousepic] #2503 * FirstPay: Add processor_id field [davidsantoso] #2506 +* Authorize.Net: Use two character default for billing state [dtykocki] #2496 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index 3eede82ac62..1e28da97e97 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -555,6 +555,7 @@ def add_billing_address(xml, payment_source, options) xml.billTo do first_name, last_name = names_from(payment_source, address, options) + state = state_from(address, options) full_address = "#{address[:address1]} #{address[:address2]}".strip xml.firstName(truncate(first_name, 50)) unless empty?(first_name) @@ -562,7 +563,7 @@ def add_billing_address(xml, payment_source, options) xml.company(truncate(address[:company], 50)) unless empty?(address[:company]) xml.address(truncate(full_address, 60)) xml.city(truncate(address[:city], 40)) - xml.state(empty?(address[:state]) ? 'n/a' : truncate(address[:state], 40)) + xml.state(truncate(state, 40)) xml.zip(truncate((address[:zip] || options[:zip]), 20)) xml.country(truncate(address[:country], 60)) xml.phoneNumber(truncate(address[:phone], 25)) unless empty?(address[:phone]) @@ -714,6 +715,14 @@ def names_from(payment_source, address, options) end end + def state_from(address, options) + if ["US", "CA"].include?(address[:country]) + address[:state] || 'NC' + else + address[:state] + end + end + def headers { 'Content-Type' => 'text/xml' } end diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb index 56369d97a85..3f3c6a4cb70 100644 --- a/test/remote/gateways/remote_authorize_net_test.rb +++ b/test/remote/gateways/remote_authorize_net_test.rb @@ -398,6 +398,26 @@ def test_failed_capture_using_stored_card assert_match %r{The amount requested for settlement cannot be greater}, capture.message end + def test_faux_successful_refund_with_billing_address + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + refund = @gateway.refund(@amount, purchase.authorization, @options.merge(first_name: 'Jim', last_name: 'Smith')) + assert_failure refund + assert_match %r{does not meet the criteria for issuing a credit}, refund.message, "Only allowed to refund transactions that have settled. This is the best we can do for now testing wise." + end + + def test_faux_successful_refund_without_billing_address + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + @options[:billing_address] = nil + + refund = @gateway.refund(@amount, purchase.authorization, @options.merge(first_name: 'Jim', last_name: 'Smith')) + assert_failure refund + assert_match %r{does not meet the criteria for issuing a credit}, refund.message, "Only allowed to refund transactions that have settled. This is the best we can do for now testing wise." + end + def test_faux_successful_refund_using_stored_card store = @gateway.store(@credit_card, @options) assert_success store diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 1a242d2a874..33d82b83ed6 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -646,6 +646,20 @@ def test_address end.respond_with(successful_authorize_response) end + def test_address_with_empty_billing_address + stub_comms do + @gateway.authorize(@amount, @credit_card) + end.check_request do |endpoint, data, headers| + parse(data) do |doc| + assert_equal "", doc.at_xpath("//billTo/address").content, data + assert_equal "", doc.at_xpath("//billTo/city").content, data + assert_equal "", doc.at_xpath("//billTo/state").content, data + assert_equal "", doc.at_xpath("//billTo/zip").content, data + assert_equal "", doc.at_xpath("//billTo/country").content, data + end + end.respond_with(successful_authorize_response) + end + def test_address_with_address2_present stub_comms do @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', address2: 'Apt 1234', country: 'US', state: 'CO', phone: '(555)555-5555', fax: '(555)555-4444'}) @@ -660,12 +674,24 @@ def test_address_with_address2_present end.respond_with(successful_authorize_response) end + def test_address_north_america_with_defaults + stub_comms do + @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', country: 'US'}) + end.check_request do |endpoint, data, headers| + parse(data) do |doc| + assert_equal "NC", doc.at_xpath("//billTo/state").content, data + assert_equal "164 Waverley Street", doc.at_xpath("//billTo/address").content, data + assert_equal "US", doc.at_xpath("//billTo/country").content, data + end + end.respond_with(successful_authorize_response) + end + def test_address_outsite_north_america stub_comms do - @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', country: 'DE', state: ''}) + @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', country: 'DE'}) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "n/a", doc.at_xpath("//billTo/state").content, data + assert_equal "", doc.at_xpath("//billTo/state").content, data assert_equal "164 Waverley Street", doc.at_xpath("//billTo/address").content, data assert_equal "DE", doc.at_xpath("//billTo/country").content, data end @@ -674,10 +700,10 @@ def test_address_outsite_north_america def test_address_outsite_north_america_with_address2_present stub_comms do - @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', address2: 'Apt 1234', country: 'DE', state: ''}) + @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', address2: 'Apt 1234', country: 'DE'}) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "n/a", doc.at_xpath("//billTo/state").content, data + assert_equal "", doc.at_xpath("//billTo/state").content, data assert_equal "164 Waverley Street Apt 1234", doc.at_xpath("//billTo/address").content, data assert_equal "DE", doc.at_xpath("//billTo/country").content, data end From f83d873cac5af9459f339bbbf09ae18c0166c2b2 Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 3 Jul 2017 15:50:03 -0400 Subject: [PATCH 135/677] SafeCharge: Pass UserID field Unit: 16 tests, 52 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 18 tests, 45 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2507 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/safe_charge.rb | 1 + test/remote/gateways/remote_safe_charge_test.rb | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2111204867a..bcbadc8a23e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ * Worldpay: Support Credit on CFT-enabled merchant IDs [curiousepic] #2503 * FirstPay: Add processor_id field [davidsantoso] #2506 * Authorize.Net: Use two character default for billing state [dtykocki] #2496 +* SafeCharge: Pass UserID field [curiousepic] #2507 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index 9b4d30836ef..2263380324c 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -117,6 +117,7 @@ def add_transaction_data(trans_type, post, money, options) post[:sg_ResponseFormat] = "4" post[:sg_Version] = VERSION post[:sg_ClientUniqueID] = options[:order_id] if options[:order_id] + post[:sg_User_ID] = options[:user_id] if options[:user_id] end def add_payment(post, payment) diff --git a/test/remote/gateways/remote_safe_charge_test.rb b/test/remote/gateways/remote_safe_charge_test.rb index abc29edbd0e..b176719de48 100644 --- a/test/remote/gateways/remote_safe_charge_test.rb +++ b/test/remote/gateways/remote_safe_charge_test.rb @@ -25,7 +25,8 @@ def test_successful_purchase_with_more_options options = { order_id: '1', ip: "127.0.0.1", - email: "joe@example.com" + email: "joe@example.com", + user_id: '123' } response = @gateway.purchase(@amount, @credit_card, options) @@ -92,7 +93,7 @@ def test_failed_refund end def test_successful_credit - response = @gateway.credit(@amount, @credit_card, @options) + response = @gateway.credit(@amount, credit_card('4444436501403986'), @options) assert_success response assert_equal 'Success', response.message end From 5bb4aeb36d9347dcf21e680330a11eae33a71d64 Mon Sep 17 00:00:00 2001 From: David Perry Date: Thu, 13 Jul 2017 13:51:42 -0400 Subject: [PATCH 136/677] Correct changelog --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index bcbadc8a23e..3e12a8badac 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* SafeCharge: Pass UserID field [curiousepic] #2507 == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] @@ -20,7 +21,6 @@ * Worldpay: Support Credit on CFT-enabled merchant IDs [curiousepic] #2503 * FirstPay: Add processor_id field [davidsantoso] #2506 * Authorize.Net: Use two character default for billing state [dtykocki] #2496 -* SafeCharge: Pass UserID field [curiousepic] #2507 == Version 1.68.0 (June 27, 2017) * Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 From 795fa7ede01c4e22f1253ce810f7c612f94a689a Mon Sep 17 00:00:00 2001 From: David Perry Date: Thu, 13 Jul 2017 13:57:48 -0400 Subject: [PATCH 137/677] SafeCharge: Correct UserID field name Unit: 16 tests, 52 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 18 tests, 45 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/safe_charge.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 3e12a8badac..43c36096324 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * SafeCharge: Pass UserID field [curiousepic] #2507 +* SafeCharge: Correct UserID field name [curiousepic] == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index 2263380324c..ae19fd11bc4 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -117,7 +117,7 @@ def add_transaction_data(trans_type, post, money, options) post[:sg_ResponseFormat] = "4" post[:sg_Version] = VERSION post[:sg_ClientUniqueID] = options[:order_id] if options[:order_id] - post[:sg_User_ID] = options[:user_id] if options[:user_id] + post[:sg_UserID] = options[:user_id] if options[:user_id] end def add_payment(post, payment) From 33b6b42c8e8f642027ab9f488cb1bba266538cd1 Mon Sep 17 00:00:00 2001 From: David Perry Date: Fri, 14 Jul 2017 11:04:34 -0400 Subject: [PATCH 138/677] Qvalent: Pass 3dSecure fields Unit: 15 tests, 75 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 17 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2508 --- CHANGELOG | 1 + .../billing/gateways/qvalent.rb | 4 +++- test/remote/gateways/remote_qvalent_test.rb | 19 +++++++++++++++++-- test/unit/gateways/qvalent_test.rb | 12 ++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 43c36096324..226cf0e5d1d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * SafeCharge: Pass UserID field [curiousepic] #2507 * SafeCharge: Correct UserID field name [curiousepic] +* Qvalent: Pass 3dSecure fields [curiousepic] #2508 == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/qvalent.rb b/lib/active_merchant/billing/gateways/qvalent.rb index 539c5d1514f..20c48d8b183 100644 --- a/lib/active_merchant/billing/gateways/qvalent.rb +++ b/lib/active_merchant/billing/gateways/qvalent.rb @@ -108,7 +108,7 @@ def add_soft_descriptors(post, options) def add_invoice(post, money, options) post["order.amount"] = amount(money) post["card.currency"] = CURRENCY_CODES[options[:currency] || currency(money)] - post["order.ECI"] = "SSL" + post["order.ECI"] = options[:eci] ? options[:eci] : "SSL" end def add_payment_method(post, payment_method) @@ -137,6 +137,8 @@ def add_order_number(post, options) def add_customer_data(post, options) post["order.ipAddress"] = options[:ip] + post["order.xid"] = options[:xid] if options[:xid] + post["order.cavv"] = options[:cavv] if options[:cavv] end def commit(action, post) diff --git a/test/remote/gateways/remote_qvalent_test.rb b/test/remote/gateways/remote_qvalent_test.rb index 2c596497839..614d60fb2ea 100644 --- a/test/remote/gateways/remote_qvalent_test.rb +++ b/test/remote/gateways/remote_qvalent_test.rb @@ -54,6 +54,21 @@ def test_successful_purchase_with_soft_descriptors assert_equal "Succeeded", response.message end + def test_successful_purchase_with_3d_secure + options = { + order_id: generate_unique_id, + billing_address: address, + description: "Store Purchase", + xid: "123", + cavv: "456", + eci: "5" + } + + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_equal "Succeeded", response.message + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response @@ -68,9 +83,9 @@ def test_successful_authorize end def test_failed_authorize - response = @gateway.authorize(@amount, @expired_card, @options) + response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal "Expired card", response.message + assert_equal "Invalid card number (no such number)", response.message end def test_successful_capture diff --git a/test/unit/gateways/qvalent_test.rb b/test/unit/gateways/qvalent_test.rb index d58d10e3f81..bbb46a9178f 100644 --- a/test/unit/gateways/qvalent_test.rb +++ b/test/unit/gateways/qvalent_test.rb @@ -158,6 +158,18 @@ def test_empty_response_fails assert_equal "Unable to read error message", response.message end + def test_3d_secure_fields + response = stub_comms(@gateway, :ssl_request) do + @gateway.purchase(@amount, @credit_card, {xid: '123', cavv: '456', eci: '5'}) + end.check_request do |method, endpoint, data, headers| + assert_match(/xid=123/, data) + assert_match(/cavv=456/, data) + assert_match(/ECI=5/, data) + end.respond_with(successful_purchase_response) + + assert_success response + end + def test_transcript_scrubbing assert_equal scrubbed_transcript, @gateway.scrub(transcript) end From 374e6f3b3626c52df6f9dfa7bc4c72c71fbec0c3 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Mon, 17 Jul 2017 13:49:30 -0400 Subject: [PATCH 139/677] GlobalTransport: Support partial authorizations This adds support for partial authorizations when using a pre-paid credit card. Additional, this exposes `ApprovedAmount` and `BalanceDue` in order to provide more information when using a pre-paid credit card. Closes #2511 --- CHANGELOG | 1 + .../billing/gateways/global_transport.rb | 6 +- .../gateways/remote_global_transport_test.rb | 15 ++- test/unit/gateways/global_transport_test.rb | 91 ++++++++++++++++++- 4 files changed, 108 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 226cf0e5d1d..26ac38e2703 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * SafeCharge: Pass UserID field [curiousepic] #2507 * SafeCharge: Correct UserID field name [curiousepic] * Qvalent: Pass 3dSecure fields [curiousepic] #2508 +* GlobalTransport: Support partial authorizations [dtykocki] #2511 == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/global_transport.rb b/lib/active_merchant/billing/gateways/global_transport.rb index d88f2feaee5..3db9092cd26 100644 --- a/lib/active_merchant/billing/gateways/global_transport.rb +++ b/lib/active_merchant/billing/gateways/global_transport.rb @@ -109,6 +109,10 @@ def parse(body) response[node.name.downcase.to_sym] = node.text end + ext_data = Nokogiri::HTML.parse(response[:extdata]) + response[:approved_amount] = ext_data.xpath("//approvedamount").text + response[:balance_due] = ext_data.xpath("//balancedue").text + response end @@ -140,7 +144,7 @@ def url end def success_from(response) - (response[:result] == "0") + response[:result] == "0" || response[:result] == "200" end def message_from(response) diff --git a/test/remote/gateways/remote_global_transport_test.rb b/test/remote/gateways/remote_global_transport_test.rb index 476d89f3a3c..94afca9b67a 100644 --- a/test/remote/gateways/remote_global_transport_test.rb +++ b/test/remote/gateways/remote_global_transport_test.rb @@ -19,6 +19,13 @@ def test_successful_purchase assert_equal 'Approved', response.message end + def test_successful_partial_purchase + @credit_card = credit_card('4111111111111111') + response = @gateway.purchase(2354, @credit_card, @options) + assert_success response + assert_equal 'Partial Approval', response.message + end + def test_failed_purchase response = @gateway.purchase(2304, @credit_card, @options) assert_failure response @@ -40,11 +47,13 @@ def test_failed_authorize assert_equal "Declined", response.message end - def test_partial_capture - auth = @gateway.authorize(500, @credit_card, @options) + def test_successful_partial_authorize_and_capture + @credit_card = credit_card('4111111111111111') + auth = @gateway.authorize(2354, @credit_card, @options) assert_success auth + assert_equal "Partial Approval", auth.message - assert capture = @gateway.capture(499, auth.authorization) + assert capture = @gateway.capture(2000, auth.authorization) assert_success capture end diff --git a/test/unit/gateways/global_transport_test.rb b/test/unit/gateways/global_transport_test.rb index a5956436d26..878ef975ab0 100644 --- a/test/unit/gateways/global_transport_test.rb +++ b/test/unit/gateways/global_transport_test.rb @@ -31,6 +31,17 @@ def test_failed_purchase assert_failure response end + def test_successful_partial_purchase + @gateway.expects(:ssl_post).returns(successful_partial_purchase_response) + + response = @gateway.purchase(200, credit_card, @options) + assert_success response + assert_equal '8869188', response.authorization + assert_equal 'Partial Approval', response.message + assert_equal '3.54', response.params["balance_due"] + assert_equal '20.00', response.params["approved_amount"] + end + def test_successful_authorize_and_capture response = stub_comms do @gateway.authorize(100, credit_card) @@ -48,6 +59,24 @@ def test_successful_authorize_and_capture assert_success capture end + def test_successful_partial_authorize_and_capture + response = stub_comms do + @gateway.authorize(200, credit_card, @options) + end.respond_with(successful_partial_authorize_response) + + assert_success response + assert_equal "8869269", response.authorization + assert_equal "Partial Approval", response.message + + capture = stub_comms do + @gateway.capture(150, response.authorization) + end.check_request do |endpoint, data, headers| + assert_match(/PNRef=8869269/, data) + end.respond_with(successful_partial_capture_response) + + assert_success capture + end + def test_failed_authorize @gateway.expects(:ssl_post).returns(failed_authorize_response) @@ -138,8 +167,8 @@ def test_truncation end.respond_with(successful_purchase_response) end - private + def successful_purchase_response %( @@ -180,6 +209,66 @@ def failed_purchase_response ) end + def successful_partial_purchase_response + %( + + 200 + Partial Approval + PARTIAL AP + VI2000 + 8869188 + 0004 + N + No Match + No Match + No Match + M + Match + False + InvNum=1,CardType=Visa,BatchNum=0005<BatchNum>0005</BatchNum><ReceiptData><MID>332518545311149</MID><Trans_Id>017198190587855</Trans_Id><Val_Code>AABC</Val_Code></ReceiptData><ApprovedAmount>20.00</ApprovedAmount><BalanceDue>3.54</BalanceDue> + aWb017198190587855cAABCd5e10fJj470993170717112415k0057840C000000002354lA m000005 + + ) + end + + def successful_partial_authorize_response + %( + + 200 + Partial Approval + PARTIAL AP + VI2000 + 8869269 + N + No Match + No Match + No Match + M + Match + False + InvNum=1,CardType=Visa<ReceiptData><MID>332518545311149</MID><Trans_Id>017198190582649</Trans_Id><Val_Code>AABC</Val_Code></ReceiptData><ApprovedAmount>20.00</ApprovedAmount><BalanceDue>3.54</BalanceDue> + aWb017198190582649cAABCd5e10fJj471048170717124409k0057840C000000002354lA m000005 + + ) + end + + def successful_partial_capture_response + %( + + 0 + Approved + AP + VI2000 + 8869275 + 0034 + Service Not Requested + False + InvNum=1,CardType=Visa,BatchNum=0005<ExtReceiptData><AccountNumber>************1111</AccountNumber><Issuer>Visa</Issuer><Amount>20.00</Amount><AuthAmount>20.00</AuthAmount><TicketNumber>1</TicketNumber><EntryMode>Manual CNP</EntryMode></ExtReceiptData><BatchNum>0005</BatchNum><ReceiptData><MID>332518545311149</MID><Trans_Id>017198190583609</Trans_Id><Val_Code>AABC</Val_Code></ReceiptData> + aWb017198190583609cAABCd5e10fJj471054170717130009lA m000005 + + ) + end + def successful_authorize_response %( From a92f52801b94e9cbaa750f4eae291a872d95b1f3 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Thu, 20 Jul 2017 16:20:05 -0400 Subject: [PATCH 140/677] Orbital: Add support for level 2 data This adds support for all level 2 data fields on authorize, capture, purchase, and refund transactions. Since Orbital enforces strict ordering of XML elements (see test/schema/orbital/Request_PTI54.xsd), there are three methods used to add the fields in their entirety. Closes #2515 --- CHANGELOG | 1 + .../billing/gateways/orbital.rb | 36 ++++++++++++++++ test/remote/gateways/remote_orbital_test.rb | 41 +++++++++++++++++++ test/unit/gateways/orbital_test.rb | 36 ++++++++++++++++ 4 files changed, 114 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 26ac38e2703..6a0f7513051 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * SafeCharge: Correct UserID field name [curiousepic] * Qvalent: Pass 3dSecure fields [curiousepic] #2508 * GlobalTransport: Support partial authorizations [dtykocki] #2511 +* Orbital: Add support for level 2 data [dtykocki] #2515 == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index 300b9ad245f..0c62e1d881d 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -354,6 +354,34 @@ def add_soft_descriptors_from_hash(xml, soft_desc) xml.tag! :SDMerchantEmail, soft_desc[:merchant_email] || nil end + def add_level_2_tax(xml, options={}) + if (level_2 = options[:level_2_data]) + xml.tag! :TaxInd, level_2[:tax_indicator] if [TAX_NOT_PROVIDED, TAX_INCLUDED, NON_TAXABLE_TRANSACTION].include?(level_2[:tax_indicator]) + xml.tag! :Tax, amount(level_2[:tax]) if level_2[:tax] + end + end + + def add_level_2_advice_addendum(xml, options={}) + if (level_2 = options[:level_2_data]) + xml.tag! :AMEXTranAdvAddn1, byte_limit(level_2[:advice_addendum_1], 40) if level_2[:advice_addendum_1] + xml.tag! :AMEXTranAdvAddn2, byte_limit(level_2[:advice_addendum_2], 40) if level_2[:advice_addendum_2] + xml.tag! :AMEXTranAdvAddn3, byte_limit(level_2[:advice_addendum_3], 40) if level_2[:advice_addendum_3] + xml.tag! :AMEXTranAdvAddn4, byte_limit(level_2[:advice_addendum_4], 40) if level_2[:advice_addendum_4] + end + end + + def add_level_2_purchase(xml, options={}) + if (level_2 = options[:level_2_data]) + xml.tag! :PCOrderNum, byte_limit(level_2[:purchase_order], 17) if level_2[:purchase_order] + xml.tag! :PCDestZip, byte_limit(format_address_field(level_2[:zip]), 10) if level_2[:zip] + xml.tag! :PCDestName, byte_limit(format_address_field(level_2[:name]), 30) if level_2[:name] + xml.tag! :PCDestAddress1, byte_limit(format_address_field(level_2[:address1]), 30) if level_2[:address1] + xml.tag! :PCDestAddress2, byte_limit(format_address_field(level_2[:address2]), 30) if level_2[:address2] + xml.tag! :PCDestCity, byte_limit(format_address_field(level_2[:city]), 20) if level_2[:city] + xml.tag! :PCDestState, byte_limit(format_address_field(level_2[:state]), 2) if level_2[:state] + end + end + def add_address(xml, creditcard, options) if(address = (options[:billing_address] || options[:address])) avs_supported = AVS_SUPPORTED_COUNTRIES.include?(address[:country].to_s) || empty?(address[:country]) @@ -565,6 +593,9 @@ def build_new_order_xml(action, money, parameters = {}) xml.tag! :Amount, amount(money) xml.tag! :Comments, parameters[:comments] if parameters[:comments] + add_level_2_tax(xml, parameters) + add_level_2_advice_addendum(xml, parameters) + # CustomerAni, AVSPhoneType and AVSDestPhoneType could be added here. if parameters[:soft_descriptors].is_a?(OrbitalSoftDescriptors) @@ -580,6 +611,8 @@ def build_new_order_xml(action, money, parameters = {}) tx_ref_num, _ = split_authorization(parameters[:authorization]) xml.tag! :TxRefNum, tx_ref_num end + + add_level_2_purchase(xml, parameters) end end xml.target! @@ -603,8 +636,11 @@ def build_mark_for_capture_xml(money, authorization, parameters = {}) add_xml_credentials(xml) xml.tag! :OrderID, format_order_id(order_id) xml.tag! :Amount, amount(money) + add_level_2_tax(xml, parameters) add_bin_merchant_and_terminal(xml, parameters) xml.tag! :TxRefNum, tx_ref_num + add_level_2_purchase(xml, parameters) + add_level_2_advice_addendum(xml, parameters) end end xml.target! diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb index bdca36ce97b..bdccb58492f 100644 --- a/test/remote/gateways/remote_orbital_test.rb +++ b/test/remote/gateways/remote_orbital_test.rb @@ -22,6 +22,22 @@ def setup :diners => "36438999960016", :jcb => "3566002020140006"} + @level_2_options = { + tax_indicator: 1, + tax: 10, + advice_addendum_1: 'taa1 - test', + advice_addendum_2: 'taa2 - test', + advice_addendum_3: 'taa3 - test', + advice_addendum_4: 'taa4 - test', + purchase_order: '123abc', + name: address[:name], + address1: address[:address1], + address2: address[:address2], + city: address[:city], + state: address[:state], + zip: address[:zip], + } + @test_suite = [ {:card => :visa, :AVSzip => 11111, :CVD => 111, :amount => 3000}, {:card => :visa, :AVSzip => 33333, :CVD => nil, :amount => 3801}, @@ -54,6 +70,13 @@ def test_successful_purchase_with_soft_descriptor_hash assert_equal 'Approved', response.message end + def test_successful_purchase_with_level_2_data + response = @gateway.purchase(@amount, @credit_card, @options.merge(level_2_data: @level_2_options)) + + assert_success response + assert_equal 'Approved', response.message + end + # Amounts of x.01 will fail def test_unsuccessful_purchase assert response = @gateway.purchase(101, @declined_card, @options) @@ -71,6 +94,15 @@ def test_authorize_and_capture assert_success capture end + def test_successful_authorize_and_capture_with_level_2_data + auth = @gateway.authorize(@amount, @credit_card, @options.merge(level_2_data: @level_2_options)) + assert_success auth + assert_equal "Approved", auth.message + + capture = @gateway.capture(@amount, auth.authorization, @options.merge(level_2_data: @level_2_options)) + assert_success capture + end + def test_authorize_and_void assert auth = @gateway.authorize(@amount, @credit_card, @options.merge(:order_id => '2')) assert_success auth @@ -89,6 +121,15 @@ def test_refund assert_success refund end + def test_successful_refund_with_level_2_data + amount = @amount + assert response = @gateway.purchase(amount, @credit_card, @options.merge(level_2_data: @level_2_options)) + assert_success response + assert response.authorization + assert refund = @gateway.refund(amount, response.authorization, @options.merge(level_2_data: @level_2_options)) + assert_success refund + end + def test_failed_capture assert response = @gateway.capture(@amount, '') assert_failure response diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index 5e528bac39e..6d2c2c5877d 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -14,6 +14,22 @@ def setup ) @customer_ref_num = "ABC" + @level_2 = { + tax_indicator: 1, + tax: 10, + advice_addendum_1: 'taa1 - test', + advice_addendum_2: 'taa2 - test', + advice_addendum_3: 'taa3 - test', + advice_addendum_4: 'taa4 - test', + purchase_order: '123abc', + name: address[:name], + address1: address[:address1], + address2: address[:address2], + city: address[:city], + state: address[:state], + zip: address[:zip], + } + @options = { :order_id => '1'} end @@ -26,6 +42,26 @@ def test_successful_purchase assert_equal '4A5398CF9B87744GG84A1D30F2F2321C66249416;1', response.authorization end + def test_level_2_data + stub_comms do + @gateway.purchase(50, credit_card, @options.merge(level_2_data: @level_2)) + end.check_request do |endpoint, data, headers| + assert_match %{#{@level_2[:tax_indicator]}}, data + assert_match %{#{@level_2[:tax]}}, data + assert_match %{#{@level_2[:advice_addendum_1]}}, data + assert_match %{#{@level_2[:advice_addendum_2]}}, data + assert_match %{#{@level_2[:advice_addendum_3]}}, data + assert_match %{#{@level_2[:advice_addendum_4]}}, data + assert_match %{#{@level_2[:purchase_order]}}, data + assert_match %{#{@level_2[:zip]}}, data + assert_match %{#{@level_2[:name]}}, data + assert_match %{#{@level_2[:address1]}}, data + assert_match %{#{@level_2[:address2]}}, data + assert_match %{#{@level_2[:city]}}, data + assert_match %{#{@level_2[:state]}}, data + end.respond_with(successful_purchase_response) + end + def test_currency_exponents stub_comms do @gateway.purchase(50, credit_card, :order_id => '1') From 74c2b9d072d1bb30b53c2db3df8f8506da9bbed2 Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 24 Jul 2017 15:49:06 -0400 Subject: [PATCH 141/677] PayU Latam: Pass DNI Number Closes #2517 Remote: 15 tests, 39 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 86.6667% passed Unit: 17 tests, 71 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/payu_latam.rb | 2 ++ test/remote/gateways/remote_payu_latam_test.rb | 1 + test/unit/gateways/payu_latam_test.rb | 11 +++++++++++ 4 files changed, 15 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 6a0f7513051..81e4e6137dc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * Qvalent: Pass 3dSecure fields [curiousepic] #2508 * GlobalTransport: Support partial authorizations [dtykocki] #2511 * Orbital: Add support for level 2 data [dtykocki] #2515 +* PayU Latam: Pass DNI Number [curiousepic] #2517 == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index f88ea24c167..5df6b983877 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -155,6 +155,7 @@ def add_buyer(post, options) if address = options[:shipping_address] buyer = {} buyer[:fullName] = address[:name] + buyer[:dniNumber] = options[:dni_number] shipping_address = {} shipping_address[:street1] = address[:address1] shipping_address[:street2] = address[:address2] @@ -234,6 +235,7 @@ def add_payer(post, options) post[:transaction][:paymentCountry] = address[:country] payer[:fullName] = address[:name] payer[:contactPhone] = address[:phone] + payer[:dniNumber] = options[:dni_number] billing_address = {} billing_address[:street1] = address[:address1] billing_address[:street2] = address[:address2] diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index c7517612da3..15fa32f9bd7 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -10,6 +10,7 @@ def setup @pending_card = credit_card("4097440000000004", verification_value: "222", first_name: "PENDING", last_name: "") @options = { + dni_number: '5415668464654', currency: "ARS", order_id: generate_unique_id, description: "Active Merchant Transaction", diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb index ae4576ce3c7..119cf71ebac 100644 --- a/test/unit/gateways/payu_latam_test.rb +++ b/test/unit/gateways/payu_latam_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class PayuLatamTest < Test::Unit::TestCase + include CommStub + def setup @gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key') @@ -12,6 +14,7 @@ def setup @no_cvv_amex_card = credit_card("4097440000000004", verification_value: " ", brand: "american_express") @options = { + dni_number: '5415668464654', currency: "ARS", order_id: generate_unique_id, description: "Active Merchant Transaction", @@ -96,6 +99,14 @@ def test_failed_void assert_equal "property: order.id, message: must not be null property: parentTransactionId, message: must not be null", response.message end + def test_successful_purchase_with_dni_number + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match(/"dniNumber":"5415668464654"/, data) + end.respond_with(successful_purchase_response) + end + def test_verify_good_credentials @gateway.expects(:ssl_post).returns(credentials_are_legit_response) assert @gateway.verify_credentials From a719fb4767354a050d8982e2cc5e7f76afc3b249 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Fri, 23 Jun 2017 14:56:16 -0400 Subject: [PATCH 142/677] Mercado Pago: Add gateway support Closes #2518 --- CHANGELOG | 1 + .../billing/gateways/mercado_pago.rb | 229 +++++++++++++ test/fixtures.yml | 4 + .../gateways/remote_mercado_pago_test.rb | 130 +++++++ test/unit/gateways/mercado_pago_test.rb | 321 ++++++++++++++++++ 5 files changed, 685 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/mercado_pago.rb create mode 100644 test/remote/gateways/remote_mercado_pago_test.rb create mode 100644 test/unit/gateways/mercado_pago_test.rb diff --git a/CHANGELOG b/CHANGELOG index 81e4e6137dc..b811d93cecd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * GlobalTransport: Support partial authorizations [dtykocki] #2511 * Orbital: Add support for level 2 data [dtykocki] #2515 * PayU Latam: Pass DNI Number [curiousepic] #2517 +* Mercado Pago: Add gateway support [davidsantoso] #2518 == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb new file mode 100644 index 00000000000..32a3295f0c9 --- /dev/null +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -0,0 +1,229 @@ +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class MercadoPagoGateway < Gateway + self.live_url = self.test_url = 'https://api.mercadopago.com/v1' + + self.supported_countries = ['AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY'] + self.supported_cardtypes = [:visa, :master, :american_express] + + self.homepage_url = 'https://www.mercadopago.com/' + self.display_name = 'Mercado Pago' + self.money_format = :dollars + + def initialize(options={}) + requires!(options, :access_token) + super + end + + def purchase(money, payment, options={}) + MultiResponse.run do |r| + r.process { commit("tokenize", "card_tokens", card_token_request(money, payment, options)) } + options.merge!(card_brand: payment.brand) + options.merge!(card_token: r.authorization.split("|").first) + r.process { commit("purchase", "payments", purchase_request(money, payment, options) ) } + end + end + + def authorize(money, payment, options={}) + MultiResponse.run do |r| + r.process { commit("tokenize", "card_tokens", card_token_request(money, payment, options)) } + options.merge!(card_brand: payment.brand) + options.merge!(card_token: r.authorization.split("|").first) + r.process { commit("authorize", "payments", authorize_request(money, payment, options) ) } + end + end + + def capture(money, authorization, options={}) + post = {} + authorization, _ = authorization.split("|") + post[:capture] = true + post[:transaction_amount] = amount(money).to_f + commit("capture", "payments/#{authorization}", post) + end + + def refund(money, authorization, options={}) + post = {} + authorization, original_amount = authorization.split("|") + post[:amount] = amount(money).to_f if original_amount && original_amount.to_f > amount(money).to_f + commit("refund", "payments/#{authorization}/refunds", post) + end + + def void(authorization, options={}) + authorization, _ = authorization.split("|") + post = { status: "cancelled" } + commit("void", "payments/#{authorization}", post) + end + + def verify(credit_card, options={}) + MultiResponse.run(:use_first_response) do |r| + r.process { authorize(100, credit_card, options) } + r.process(:ignore_result) { void(r.authorization, options) } + end + end + + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((access_token=).*?([^\s]+)), '\1[FILTERED]'). + gsub(%r((\"card_number\\\":\\\")\d+), '\1[FILTERED]'). + gsub(%r((\"security_code\\\":\\\")\d+), '\1[FILTERED]') + end + + private + + def card_token_request(money, payment, options = {}) + post = {} + post[:card_number] = payment.number + post[:security_code] = payment.verification_value + post[:expiration_month] = payment.month + post[:expiration_year] = payment.year + post[:cardholder] = { name: payment.name } + post + end + + def purchase_request(money, payment, options = {}) + post = {} + add_invoice(post, money, options) + add_payment(post, options) + add_additional_data(post, options) + add_customer_data(post, payment, options) + add_address(post, options) + post + end + + def authorize_request(money, payment, options = {}) + post = purchase_request(money, payment, options) + post.merge!(capture: false) + post + end + + def add_additional_data(post, options) + post[:sponsor_id] = options["sponsor_id"] + post[:additional_info] = { + ip_address: options[:ip_address] + } + + add_address(post, options) + end + + def add_customer_data(post, payment, options) + post[:payer] = { + email: options[:email], + first_name: payment.first_name, + last_name: payment.last_name + } + end + + def add_address(post, options) + if address = (options[:billing_address] || options[:address]) + street_number = address[:address1].split(" ").first + street_name = address[:address1].split(" ")[1..-1].join(" ") + + post[:additional_info] = { + payer: { + address: { + zip_code: address[:zip], + street_number: street_number, + street_name: street_name, + } + } + } + end + end + + def add_invoice(post, money, options) + post[:transaction_amount] = amount(money).to_f + post[:description] = options[:description] + post[:installments] = options[:installments] ? options[:installments].to_i : 1 + post[:statement_descriptor] = options[:statement_descriptor] if options[:statement_descriptor] + post[:order] = { + type: options[:order_type] || "mercadopago", + id: options[:order_id] || generate_integer_only_order_id + } + end + + def add_payment(post, options) + post[:token] = options[:card_token] + post[:payment_method_id] = options[:card_brand] + end + + def parse(body) + JSON.parse(body) + end + + def commit(action, path, parameters) + if ["capture", "void"].include?(action) + response = parse(ssl_request(:put, url(path), post_data(parameters), headers)) + else + response = parse(ssl_post(url(path), post_data(parameters), headers)) + end + + Response.new( + success_from(action, response), + message_from(response), + response, + authorization: authorization_from(response, parameters), + test: test?, + error_code: error_code_from(action, response) + ) + end + + def success_from(action, response) + if action == "refund" + response["error"].nil? + else + ["active", "approved", "authorized", "cancelled"].include?(response["status"]) + end + end + + def message_from(response) + (response["status_detail"]) || (response["message"]) + end + + def authorization_from(response, params) + [response["id"], params[:transaction_amount]].join("|") + end + + def post_data(parameters = {}) + parameters.to_json + end + + def error_code_from(action, response) + unless success_from(action, response) + if cause = response["cause"] + cause.empty? ? nil : cause.first["code"] + else + response["status"] + end + end + end + + def url(action) + full_url = (test? ? test_url : live_url) + full_url + "/#{action}?access_token=#{@options[:access_token]}" + end + + def headers + { + "Content-Type" => "application/json" + } + end + + def handle_response(response) + case response.code.to_i + when 200..499 + response.body + else + raise ResponseError.new(response) + end + end + + def generate_integer_only_order_id + Time.now.to_i + rand(0..1000) + end + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index d7a24fa9fc9..8f64da8a5cd 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -432,6 +432,10 @@ maxipago: login: "100" password: "21g8u6gh6szw1gywfs165vui" +# Working credentials, no need to replace +mercado_pago: + access_token: "TEST-8527269031909288-071213-0fc96cb7cd3633189bfbe29f63722700__LB_LA__-263489584" + # Working test credentials, no need to replace merchant_esolutions: login: "94100008043900000004" diff --git a/test/remote/gateways/remote_mercado_pago_test.rb b/test/remote/gateways/remote_mercado_pago_test.rb new file mode 100644 index 00000000000..4d60297fa66 --- /dev/null +++ b/test/remote/gateways/remote_mercado_pago_test.rb @@ -0,0 +1,130 @@ +require 'test_helper' + +class RemoteMercadoPagoTest < Test::Unit::TestCase + def setup + @gateway = MercadoPagoGateway.new(fixtures(:mercado_pago)) + + @amount = 500 + @credit_card = credit_card('4509953566233704') + @declined_card = credit_card('4000300011112220') + @options = { + billing_address: address, + email: "user+br@example.com", + description: 'Store Purchase' + } + end + + def test_successful_purchase + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'accredited', response.message + end + + def test_failed_purchase + response = @gateway.purchase(@amount, @declined_card, @options) + assert_failure response + assert_equal "rejected", response.error_code + assert_equal 'cc_rejected_other_reason', response.message + end + + def test_successful_authorize_and_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + assert_equal 'pending_capture', auth.message + + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + assert_equal 'accredited', capture.message + end + + def test_failed_authorize + response = @gateway.authorize(@amount, @declined_card, @options) + assert_failure response + assert_equal 'cc_rejected_other_reason', response.message + end + + def test_partial_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount-1, auth.authorization) + assert_success capture + assert_equal 'accredited', capture.message + end + + def test_failed_capture + response = @gateway.capture(@amount, '') + assert_failure response + assert_equal 'Method not allowed', response.message + end + + def test_successful_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount, purchase.authorization) + assert_success refund + assert_equal nil, refund.message + end + + def test_partial_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount-1, purchase.authorization) + assert_success refund + end + + def test_failed_refund + response = @gateway.refund(@amount, '') + assert_failure response + assert_equal 'Resource /payments/refunds not found.', response.message + end + + def test_successful_void + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert void = @gateway.void(auth.authorization) + assert_success void + assert_equal 'by_collector', void.message + end + + def test_failed_void + response = @gateway.void('') + assert_failure response + assert_equal 'Method not allowed', response.message + end + + def test_successful_verify + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_match %r{pending_capture}, response.message + end + + def test_failed_verify + response = @gateway.verify(@declined_card, @options) + assert_failure response + assert_match %r{cc_rejected_other_reason}, response.message + end + + def test_invalid_login + gateway = MercadoPagoGateway.new(access_token: '') + + response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_match %r{Invalid access parameters}, response.message + end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:access_token], transcript) + end + +end diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb new file mode 100644 index 00000000000..860e9b7d0a0 --- /dev/null +++ b/test/unit/gateways/mercado_pago_test.rb @@ -0,0 +1,321 @@ +require 'test_helper' + +class MercadoPagoTest < Test::Unit::TestCase + def setup + @gateway = MercadoPagoGateway.new(access_token: 'access_token') + @credit_card = credit_card + @amount = 100 + + @options = { + order_id: '1', + billing_address: address, + description: 'Store Purchase' + } + end + + def test_successful_purchase + @gateway.expects(:ssl_post).at_most(2).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + + assert_equal "4141491|1.0", response.authorization + assert_equal "accredited", response.message + assert response.test? + end + + def test_failed_purchase + @gateway.expects(:ssl_post).at_most(2).returns(failed_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal "rejected", response.error_code + assert_equal "cc_rejected_other_reason", response.message + end + + def test_successful_authorize + @gateway.expects(:ssl_post).at_most(2).returns(successful_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + + assert_equal "4261941|1.0", response.authorization + assert_equal "pending_capture", response.message + assert response.test? + end + + def test_failed_authorize + @gateway.expects(:ssl_post).at_most(2).returns(failed_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_equal "rejected", response.error_code + assert_equal "cc_rejected_other_reason", response.message + end + + def test_successful_capture + @gateway.expects(:ssl_request).returns(successful_capture_response) + + response = @gateway.capture(@amount, "authorization|amount") + assert_success response + + assert_equal "4261941|1.0", response.authorization + assert_equal "accredited", response.message + assert response.test? + end + + def test_failed_capture + @gateway.expects(:ssl_request).returns(failed_capture_response) + + response = @gateway.capture(@amount, "") + assert_failure response + + assert_equal "|1.0", response.authorization + assert_equal "Method not allowed", response.message + assert response.test? + end + + def test_successful_refund + @gateway.expects(:ssl_post).returns(successful_refund_response) + + response = @gateway.refund(@amount, 'authorization|1.0', @options) + assert_success response + end + + def test_failed_refund + @gateway.expects(:ssl_post).returns(failed_refund_response) + + response = @gateway.refund(@amount, '', @options) + assert_failure response + assert_equal nil, response.error_code + end + + def test_successful_void + @gateway.expects(:ssl_request).returns(successful_void_response) + + response = @gateway.void("authorization|amount") + assert_success response + + assert_equal "4261966|", response.authorization + assert_equal "by_collector", response.message + assert response.test? + end + + def test_failed_void + @gateway.expects(:ssl_request).returns(failed_void_response) + + response = @gateway.void("") + assert_failure response + + assert_equal "|", response.authorization + assert_equal "Method not allowed", response.message + assert response.test? + end + + def test_successful_verify + @gateway.expects(:ssl_request).at_most(3).returns(successful_void_response) + + response = @gateway.verify(@credit_card, @options) + assert_success response + + assert_equal "by_collector", response.message + assert response.test? + end + + def test_successful_verify_with_failed_void + @gateway.expects(:ssl_request).at_most(3).returns(failed_void_response) + + response = @gateway.verify(@credit_card, @options) + assert_failure response + + assert_equal "Method not allowed", response.message + assert response.test? + end + + def test_failed_verify + @gateway.expects(:ssl_request).at_most(2).returns(failed_authorize_response) + + response = @gateway.verify(@credit_card, @options) + assert_failure response + + assert_equal "cc_rejected_other_reason", response.message + assert response.test? + end + + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + + private + + def pre_scrubbed + %q( + opening connection to api.mercadopago.com:443... + opened + starting SSL for api.mercadopago.com:443... + SSL established + <- "POST /v1/card_tokens?access_token=TEST-8527269031909288-071213-0fc96cb7cd3633189bfbe29f63722700__LB_LA__-263489584 HTTP/1.1\r\nContent-Type: application/json\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.mercadopago.com\r\nContent-Length: 140\r\n\r\n" + <- "{\"card_number\":\"4509953566233704\",\"security_code\":\"123\",\"expiration_month\":9,\"expiration_year\":2018,\"cardholder\":{\"name\":\"Longbob Longsen\"}}" + -> "HTTP/1.1 201 Created\r\n" + -> "Access-Control-Allow-Origin: *\r\n" + -> "X-Request-Id: eb7a95a0-dccb-4580-9a69-534f6faf0bd6\r\n" + -> "Content-Type: application/json;charset=utf-8\r\n" + -> "Date: Thu, 13 Jul 2017 17:37:58 GMT\r\n" + -> "Connection: close\r\n" + -> "X-XSS-Protection: 1; mode=block\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "Strict-Transport-Security: max-age=16070400\r\n" + -> "Set-Cookie: TS016da221=0119b547a2244bba3789910575ac019d7d44d644026217ca433918a8c8fd9ff83de9d4b3c095adc76ee58870b56cd33041797db9e2; Path=/; Secure; HTTPOnly\r\n" + -> "Vary: Accept-Encoding, User-Agent\r\n" + -> "Content-Encoding: gzip\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "\r\n" + Conn close + opening connection to api.mercadopago.com:443... + opened + starting SSL for api.mercadopago.com:443... + SSL established + <- "POST /v1/payments?access_token=TEST-8527269031909288-071213-0fc96cb7cd3633189bfbe29f63722700__LB_LA__-263489584 HTTP/1.1\r\nContent-Type: application/json\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.mercadopago.com\r\nContent-Length: 395\r\n\r\n" + <- "{\"transaction_amount\":5.0,\"description\":\"Store Purchase\",\"installments\":1,\"order\":{\"type\":\"mercadopago\",\"id\":2554731505684667137},\"token\":\"02ed9760103508d54361da8741a22a9e\",\"payment_method_id\":\"visa\",\"additional_info\":{\"payer\":{\"address\":{\"zip_code\":\"K1C2N6\",\"street_number\":\"456\",\"street_name\":\"My Street\"}}},\"payer\":{\"email\":\"user+br@example.com\",\"first_name\":\"Longbob\",\"last_name\":\"Longsen\"}}" + -> "HTTP/1.1 201 Created\r\n" + -> "Date: Thu, 13 Jul 2017 17:37:59 GMT\r\n" + -> "Content-Type: application/json;charset=UTF-8\r\n" + -> "Connection: close\r\n" + -> "X-Response-Status: approved/accredited\r\n" + -> "X-Caller-Id: 263489584\r\n" + -> "Vary: Accept,Accept-Encoding, User-Agent\r\n" + -> "Cache-Control: max-age=0\r\n" + -> "ETag: 1deee4b03ae344416c5863ac0d92c13e\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "X-Frame-Options: DENY\r\n" + -> "X-Request-Id: ccb324d1-8365-42dd-8e9a-734488220777\r\n" + -> "X-XSS-Protection: 1; mode=block\r\n" + -> "Strict-Transport-Security: max-age=15724800\r\n" + -> "Access-Control-Allow-Origin: *\r\n" + -> "Access-Control-Allow-Headers: Content-Type\r\n" + -> "Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS\r\n" + -> "Access-Control-Max-Age: 86400\r\n" + -> "Set-Cookie: TS016da221=0119b547a287375accd901052e4871cecbc881599be32e9bcb508701e62cabee4424801a25969778d1c93e2c57c2fd0a8a934c9817; Path=/; Secure; HTTPOnly\r\n" + -> "Content-Encoding: gzip\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "\r\n" + Conn close + ) + end + + def post_scrubbed + %q( + opening connection to api.mercadopago.com:443... + opened + starting SSL for api.mercadopago.com:443... + SSL established + <- "POST /v1/card_tokens?access_token=[FILTERED] HTTP/1.1\r\nContent-Type: application/json\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.mercadopago.com\r\nContent-Length: 140\r\n\r\n" + <- "{\"card_number\":\"[FILTERED]\",\"security_code\":\"[FILTERED]\",\"expiration_month\":9,\"expiration_year\":2018,\"cardholder\":{\"name\":\"Longbob Longsen\"}}" + -> "HTTP/1.1 201 Created\r\n" + -> "Access-Control-Allow-Origin: *\r\n" + -> "X-Request-Id: eb7a95a0-dccb-4580-9a69-534f6faf0bd6\r\n" + -> "Content-Type: application/json;charset=utf-8\r\n" + -> "Date: Thu, 13 Jul 2017 17:37:58 GMT\r\n" + -> "Connection: close\r\n" + -> "X-XSS-Protection: 1; mode=block\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "Strict-Transport-Security: max-age=16070400\r\n" + -> "Set-Cookie: TS016da221=0119b547a2244bba3789910575ac019d7d44d644026217ca433918a8c8fd9ff83de9d4b3c095adc76ee58870b56cd33041797db9e2; Path=/; Secure; HTTPOnly\r\n" + -> "Vary: Accept-Encoding, User-Agent\r\n" + -> "Content-Encoding: gzip\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "\r\n" + Conn close + opening connection to api.mercadopago.com:443... + opened + starting SSL for api.mercadopago.com:443... + SSL established + <- "POST /v1/payments?access_token=[FILTERED] HTTP/1.1\r\nContent-Type: application/json\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.mercadopago.com\r\nContent-Length: 395\r\n\r\n" + <- "{\"transaction_amount\":5.0,\"description\":\"Store Purchase\",\"installments\":1,\"order\":{\"type\":\"mercadopago\",\"id\":2554731505684667137},\"token\":\"02ed9760103508d54361da8741a22a9e\",\"payment_method_id\":\"visa\",\"additional_info\":{\"payer\":{\"address\":{\"zip_code\":\"K1C2N6\",\"street_number\":\"456\",\"street_name\":\"My Street\"}}},\"payer\":{\"email\":\"user+br@example.com\",\"first_name\":\"Longbob\",\"last_name\":\"Longsen\"}}" + -> "HTTP/1.1 201 Created\r\n" + -> "Date: Thu, 13 Jul 2017 17:37:59 GMT\r\n" + -> "Content-Type: application/json;charset=UTF-8\r\n" + -> "Connection: close\r\n" + -> "X-Response-Status: approved/accredited\r\n" + -> "X-Caller-Id: 263489584\r\n" + -> "Vary: Accept,Accept-Encoding, User-Agent\r\n" + -> "Cache-Control: max-age=0\r\n" + -> "ETag: 1deee4b03ae344416c5863ac0d92c13e\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "X-Frame-Options: DENY\r\n" + -> "X-Request-Id: ccb324d1-8365-42dd-8e9a-734488220777\r\n" + -> "X-XSS-Protection: 1; mode=block\r\n" + -> "Strict-Transport-Security: max-age=15724800\r\n" + -> "Access-Control-Allow-Origin: *\r\n" + -> "Access-Control-Allow-Headers: Content-Type\r\n" + -> "Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS\r\n" + -> "Access-Control-Max-Age: 86400\r\n" + -> "Set-Cookie: TS016da221=0119b547a287375accd901052e4871cecbc881599be32e9bcb508701e62cabee4424801a25969778d1c93e2c57c2fd0a8a934c9817; Path=/; Secure; HTTPOnly\r\n" + -> "Content-Encoding: gzip\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "\r\n" + Conn close + ) + end + + def successful_purchase_response + %( + {"id":4141491,"date_created":"2017-07-06T09:49:35.000-04:00","date_approved":"2017-07-06T09:49:35.000-04:00","date_last_updated":"2017-07-06T09:49:35.000-04:00","date_of_expiration":null,"money_release_date":"2017-07-18T09:49:35.000-04:00","operation_type":"regular_payment","issuer_id":"166","payment_method_id":"visa","payment_type_id":"credit_card","status":"approved","status_detail":"accredited","currency_id":"MXN","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"related_exchange_rate":null,"collector_id":261735089,"payer":{"type":"guest","id":null,"email":"user@example.com","identification":{"type":null,"number":null},"phone":{"area_code":null,"number":null,"extension":""},"first_name":"First User","last_name":"User","entity_type":null},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"My Street","street_number":"456"}}},"order":{"type":"mercadopago","id":"2326513804447055222"},"external_reference":null,"transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":0.14,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[{"type":"mercadopago_fee","amount":4.86,"fee_payer":"collector"}],"captured":true,"binary_mode":false,"call_for_authorize_id":null,"statement_descriptor":"WWW.MERCADOPAGO.COM","installments":1,"card":{"id":null,"first_six_digits":"450995","last_four_digits":"3704","expiration_month":9,"expiration_year":2018,"date_created":"2017-07-06T09:49:35.000-04:00","date_last_updated":"2017-07-06T09:49:35.000-04:00","cardholder":{"name":"Longbob Longsen","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":null,"merchant_account_id":null,"acquirer":null,"merchant_number":null} + ) + end + + def failed_purchase_response + %( + {"id":4142297,"date_created":"2017-07-06T10:13:32.000-04:00","date_approved":null,"date_last_updated":"2017-07-06T10:13:32.000-04:00","date_of_expiration":null,"money_release_date":null,"operation_type":"regular_payment","issuer_id":"166","payment_method_id":"visa","payment_type_id":"credit_card","status":"rejected","status_detail":"cc_rejected_other_reason","currency_id":"MXN","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"related_exchange_rate":null,"collector_id":261735089,"payer":{"type":"guest","id":null,"email":"user@example.com","identification":{"type":null,"number":null},"phone":{"area_code":null,"number":null,"extension":""},"first_name":"First User","last_name":"User","entity_type":null},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"My Street","street_number":"456"}}},"order":{"type":"mercadopago","id":"830943860538524456"},"external_reference":null,"transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":0,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[],"captured":true,"binary_mode":false,"call_for_authorize_id":null,"statement_descriptor":"WWW.MERCADOPAGO.COM","installments":1,"card":{"id":null,"first_six_digits":"400030","last_four_digits":"2220","expiration_month":9,"expiration_year":2018,"date_created":"2017-07-06T10:13:32.000-04:00","date_last_updated":"2017-07-06T10:13:32.000-04:00","cardholder":{"name":"Longbob Longsen","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":null,"merchant_account_id":null,"acquirer":null,"merchant_number":null} + ) + end + + def successful_authorize_response + %( + {"id":4261941,"date_created":"2017-07-13T14:24:46.000-04:00","date_approved":null,"date_last_updated":"2017-07-13T14:24:46.000-04:00","date_of_expiration":null,"money_release_date":null,"operation_type":"regular_payment","issuer_id":"25","payment_method_id":"visa","payment_type_id":"credit_card","status":"authorized","status_detail":"pending_capture","currency_id":"BRL","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"related_exchange_rate":null,"collector_id":263489584,"payer":{"type":"guest","id":null,"email":"user+br@example.com","identification":{"type":null,"number":null},"phone":{"area_code":null,"number":null,"extension":null},"first_name":null,"last_name":null,"entity_type":null},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"My Street","street_number":"456"}}},"order":{"type":"mercadopago","id":"2294029672081601730"},"external_reference":null,"transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":0,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[],"captured":false,"binary_mode":false,"call_for_authorize_id":null,"statement_descriptor":"WWW.MERCADOPAGO.COM","installments":1,"card":{"id":null,"first_six_digits":"450995","last_four_digits":"3704","expiration_month":9,"expiration_year":2018,"date_created":"2017-07-13T14:24:46.000-04:00","date_last_updated":"2017-07-13T14:24:46.000-04:00","cardholder":{"name":"Longbob Longsen","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null} + ) + end + + def failed_authorize_response + %( + {"id":4261953,"date_created":"2017-07-13T14:25:33.000-04:00","date_approved":null,"date_last_updated":"2017-07-13T14:25:33.000-04:00","date_of_expiration":null,"money_release_date":null,"operation_type":"regular_payment","issuer_id":"25","payment_method_id":"visa","payment_type_id":"credit_card","status":"rejected","status_detail":"cc_rejected_other_reason","currency_id":"BRL","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"related_exchange_rate":null,"collector_id":263489584,"payer":{"type":"guest","id":null,"email":"user+br@example.com","identification":{"type":null,"number":null},"phone":{"area_code":null,"number":null,"extension":null},"first_name":null,"last_name":null,"entity_type":null},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"My Street","street_number":"456"}}},"order":{"type":"mercadopago","id":"7528376941458928221"},"external_reference":null,"transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":0,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[],"captured":false,"binary_mode":false,"call_for_authorize_id":null,"statement_descriptor":"WWW.MERCADOPAGO.COM","installments":1,"card":{"id":null,"first_six_digits":"400030","last_four_digits":"2220","expiration_month":9,"expiration_year":2018,"date_created":"2017-07-13T14:25:33.000-04:00","date_last_updated":"2017-07-13T14:25:33.000-04:00","cardholder":{"name":"Longbob Longsen","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null} + ) + end + + def successful_capture_response + %( + {"id":4261941,"date_created":"2017-07-13T14:24:46.000-04:00","date_approved":"2017-07-13T14:24:47.000-04:00","date_last_updated":"2017-07-13T14:24:47.000-04:00","date_of_expiration":null,"money_release_date":"2017-07-27T14:24:47.000-04:00","operation_type":"regular_payment","issuer_id":"25","payment_method_id":"visa","payment_type_id":"credit_card","status":"approved","status_detail":"accredited","currency_id":"BRL","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"related_exchange_rate":null,"collector_id":263489584,"payer":{"type":"guest","id":null,"email":"user+br@example.com","identification":{"type":null,"number":null},"phone":{"area_code":null,"number":null,"extension":null},"first_name":null,"last_name":null,"entity_type":null},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"My Street","street_number":"456"}}},"order":{"type":"mercadopago","id":"2294029672081601730"},"external_reference":null,"transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":4.75,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[{"type":"mercadopago_fee","amount":0.25,"fee_payer":"collector"}],"captured":true,"binary_mode":false,"call_for_authorize_id":null,"statement_descriptor":"WWW.MERCADOPAGO.COM","installments":1,"card":{"id":null,"first_six_digits":"450995","last_four_digits":"3704","expiration_month":9,"expiration_year":2018,"date_created":"2017-07-13T14:24:46.000-04:00","date_last_updated":"2017-07-13T14:24:46.000-04:00","cardholder":{"name":"Longbob Longsen","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null} + ) + end + + def failed_capture_response + %( + {"message":"Method not allowed","error":"method_not_allowed","status":405,"cause":[{"code":"Method not allowed","description":"Method not allowed","data":null}]} + ) + end + + def successful_refund_response + %( + {"id":4247757,"payment_id":4247751,"amount":5,"metadata":{},"source":{"id":"261735089","name":"Spreedly Integrations","type":"collector"},"date_created":"2017-07-12T14:45:08.752-04:00","unique_sequence_number":null} + ) + end + + def failed_refund_response + %( + {"message":"Resource /payments/refunds/ not found.","error":"not_found","status":404,"cause":[]} + ) + end + + def successful_void_response + %( + {"id":4261966,"date_created":"2017-07-13T14:26:56.000-04:00","date_approved":null,"date_last_updated":"2017-07-13T14:26:57.000-04:00","date_of_expiration":null,"money_release_date":null,"operation_type":"regular_payment","issuer_id":"25","payment_method_id":"visa","payment_type_id":"credit_card","status":"cancelled","status_detail":"by_collector","currency_id":"BRL","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"related_exchange_rate":null,"collector_id":263489584,"payer":{"type":"guest","id":null,"email":"user+br@example.com","identification":{"type":null,"number":null},"phone":{"area_code":null,"number":null,"extension":null},"first_name":null,"last_name":null,"entity_type":null},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"My Street","street_number":"456"}}},"order":{"type":"mercadopago","id":"6688620487994029432"},"external_reference":null,"transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":0,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[],"captured":false,"binary_mode":false,"call_for_authorize_id":null,"statement_descriptor":"WWW.MERCADOPAGO.COM","installments":1,"card":{"id":null,"first_six_digits":"450995","last_four_digits":"3704","expiration_month":9,"expiration_year":2018,"date_created":"2017-07-13T14:26:56.000-04:00","date_last_updated":"2017-07-13T14:26:56.000-04:00","cardholder":{"name":"Longbob Longsen","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null} + ) + end + + def failed_void_response + %( + {"message":"Method not allowed","error":"method_not_allowed","status":405,"cause":[{"code":"Method not allowed","description":"Method not allowed","data":null}]} + ) + end +end From 5ae7c7aba97326b5bc1f71ef6095a5619ecdef1b Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 27 Jun 2017 10:20:15 -0400 Subject: [PATCH 143/677] Litle: Update schema and certification tests to v9.12 Also updates Android Pay support to pass the ordersource correctly. Unit: 32 tests, 137 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 28 tests, 117 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2522 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/litle.rb | 10 +- .../remote_litle_certification_test.rb | 520 +++++++++++++----- test/remote/gateways/remote_litle_test.rb | 15 + test/unit/gateways/litle_test.rb | 16 + 5 files changed, 403 insertions(+), 159 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b811d93cecd..885a28c9f92 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * Orbital: Add support for level 2 data [dtykocki] #2515 * PayU Latam: Pass DNI Number [curiousepic] #2517 * Mercado Pago: Add gateway support [davidsantoso] #2518 +* Litle: Update schema and certification tests to v9.12 [curiousepic] #2522 == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index e46ab85a06b..14f4d53545b 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -3,7 +3,7 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class LitleGateway < Gateway - SCHEMA_VERSION = '9.4' + SCHEMA_VERSION = '9.12' self.test_url = 'https://www.testlitle.com/sandbox/communicator/online' self.live_url = 'https://payments.litle.com/vap/communicator/online' @@ -15,12 +15,6 @@ class LitleGateway < Gateway self.homepage_url = 'http://www.litle.com/' self.display_name = 'Litle & Co.' - # Public: Create a new Litle gateway. - # - # options - A hash of options: - # :login - The user. - # :password - The password. - # :merchant_id - The merchant id. def initialize(options={}) requires!(options, :login, :password, :merchant_id) super @@ -261,6 +255,8 @@ def add_order_source(doc, payment_method, options) doc.orderSource(options[:order_source]) elsif payment_method.is_a?(NetworkTokenizationCreditCard) && payment_method.source == :apple_pay doc.orderSource('applepay') + elsif payment_method.is_a?(NetworkTokenizationCreditCard) && payment_method.source == :android_pay + doc.orderSource('androidpay') elsif payment_method.respond_to?(:track_data) && payment_method.track_data.present? doc.orderSource('retail') else diff --git a/test/remote/gateways/remote_litle_certification_test.rb b/test/remote/gateways/remote_litle_certification_test.rb index 1c55f9b3182..ba03f28de48 100644 --- a/test/remote/gateways/remote_litle_certification_test.rb +++ b/test/remote/gateways/remote_litle_certification_test.rb @@ -3,14 +3,15 @@ class RemoteLitleCertification < Test::Unit::TestCase def setup Base.mode = :test - @gateway = LitleGateway.new(fixtures(:litle).merge(:url => "https://cert.litle.com/vap/communicator/online")) + @gateway = LitleGateway.new(fixtures(:litle)) + @gateway.test_url = "https://payments.vantivprelive.com/vap/communicator/online" end def test1 credit_card = CreditCard.new( :number => '4457010000000009', :month => '01', - :year => '2014', + :year => '2021', :verification_value => '349', :brand => 'visa' ) @@ -18,7 +19,7 @@ def test1 options = { :order_id => '1', :billing_address => { - :name => 'John Smith', + :name => 'John & Mary Smith', :address1 => '1 Main St.', :city => 'Burlington', :state => 'MA', @@ -27,24 +28,24 @@ def test1 } } - auth_assertions(10010, credit_card, options, :avs => "X", :cvv => "M") + auth_assertions(10100, credit_card, options, :avs => "X", :cvv => "M") - # 1: authorize avs authorize_avs_assertions(credit_card, options, :avs => "X", :cvv => "M") - sale_assertions(10010, credit_card, options, :avs => "X", :cvv => "M") + sale_assertions(10100, credit_card, options, :avs => "X", :cvv => "M") end def test2 credit_card = CreditCard.new(:number => '5112010000000003', :month => '02', - :year => '2014', :brand => 'master', - :verification_value => '261') + :year => '2021', :brand => 'master', + :verification_value => '261', + :name => 'Mike J. Hammer') options = { :order_id => '2', :billing_address => { - :name => 'Mike J. Hammer', :address1 => '2 Main St.', + :address2 => 'Apt. 222', :city => 'Riverside', :state => 'RI', :zip => '02915', @@ -52,19 +53,18 @@ def test2 } } - auth_assertions(20020, credit_card, options, :avs => "Z", :cvv => "M") + auth_assertions(10100, credit_card, options, :avs => "Z", :cvv => "M") - # 2: authorize avs authorize_avs_assertions(credit_card, options, :avs => "Z", :cvv => "M") - sale_assertions(20020, credit_card, options, :avs => "Z", :cvv => "M") + sale_assertions(10100, credit_card, options, :avs => "Z", :cvv => "M") end def test3 credit_card = CreditCard.new( :number => '6011010000000003', :month => '03', - :year => '2014', + :year => '2021', :verification_value => '758', :brand => 'discover' ) @@ -80,19 +80,18 @@ def test3 :country => 'US' } } - auth_assertions(30030, credit_card, options, :avs => "Z", :cvv => "M") + auth_assertions(10100, credit_card, options, :avs => "Z", :cvv => "M") - # 3: authorize avs authorize_avs_assertions(credit_card, options, :avs => "Z", :cvv => "M") - sale_assertions(30030, credit_card, options, :avs => "Z", :cvv => "M") + sale_assertions(10100, credit_card, options, :avs => "Z", :cvv => "M") end def test4 credit_card = CreditCard.new( :number => '375001000000005', :month => '04', - :year => '2014', + :year => '2021', :brand => 'american_express' ) @@ -108,17 +107,37 @@ def test4 } } - auth_assertions(40040, credit_card, options, :avs => "A", :cvv => nil) + auth_assertions(10100, credit_card, options, :avs => "A", :cvv => nil) - # 4: authorize avs authorize_avs_assertions(credit_card, options, :avs => "A") - sale_assertions(40040, credit_card, options, :avs => "A", :cvv => nil) + sale_assertions(10100, credit_card, options, :avs => "A", :cvv => nil) + end + + def test5 + credit_card = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new( + :number => '4100200300011001', + :month => '05', + :year => '2021', + :verification_value => '463', + :brand => 'visa', + :payment_cryptogram => 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=' + ) + + options = { + :order_id => '5' + } + + auth_assertions(10100, credit_card, options, :avs => "U", :cvv => "M") + + authorize_avs_assertions(credit_card, options, :avs => "U", :cvv => "M") + + sale_assertions(10100, credit_card, options, :avs => "U", :cvv => "M") end def test6 credit_card = CreditCard.new(:number => '4457010100000008', :month => '06', - :year => '2014', :brand => 'visa', + :year => '2021', :brand => 'visa', :verification_value => '992') options = { @@ -134,30 +153,35 @@ def test6 } # 6: authorize - assert response = @gateway.authorize(60060, credit_card, options) + assert response = @gateway.authorize(10100, credit_card, options) assert !response.success? - assert_equal '110', response.params['litleOnlineResponse']['authorizationResponse']['response'] + assert_equal '110', response.params['response'] assert_equal 'Insufficient Funds', response.message assert_equal "I", response.avs_result["code"] assert_equal "P", response.cvv_result["code"] + puts "Test #{options[:order_id]} Authorize: #{txn_id(response)}" # 6. sale - assert response = @gateway.purchase(60060, credit_card, options) + assert response = @gateway.purchase(10100, credit_card, options) assert !response.success? - assert_equal '110', response.params['litleOnlineResponse']['saleResponse']['response'] + assert_equal '110', response.params['response'] assert_equal 'Insufficient Funds', response.message assert_equal "I", response.avs_result["code"] assert_equal "P", response.cvv_result["code"] + puts "Test #{options[:order_id]} Sale: #{txn_id(response)}" + # 6A. void assert response = @gateway.void(response.authorization, {:order_id => '6A'}) - assert_equal '360', response.params['litleOnlineResponse']['voidResponse']['response'] - assert_equal 'No transaction found with specified litleTxnId', response.message + assert_equal '360', response.params['response'] + assert_equal 'No transaction found with specified transaction Id', response.message + puts "Test #{options[:order_id]}A: #{txn_id(response)}" + end def test7 credit_card = CreditCard.new(:number => '5112010100000002', :month => '07', - :year => '2014', :brand => 'master', + :year => '2021', :brand => 'master', :verification_value => '251') options = { @@ -173,28 +197,30 @@ def test7 } # 7: authorize - assert response = @gateway.authorize(70070, credit_card, options) + assert response = @gateway.authorize(10100, credit_card, options) assert !response.success? - assert_equal '301', response.params['litleOnlineResponse']['authorizationResponse']['response'] + assert_equal '301', response.params['response'] assert_equal 'Invalid Account Number', response.message assert_equal "I", response.avs_result["code"] assert_equal "N", response.cvv_result["code"] + puts "Test #{options[:order_id]} Authorize: #{txn_id(response)}" # 7: authorize avs authorize_avs_assertions(credit_card, options, :avs => "I", :cvv => "N", :message => "Invalid Account Number", :success => false) # 7. sale - assert response = @gateway.purchase(70070, credit_card, options) + assert response = @gateway.purchase(10100, credit_card, options) assert !response.success? - assert_equal '301', response.params['litleOnlineResponse']['saleResponse']['response'] + assert_equal '301', response.params['response'] assert_equal 'Invalid Account Number', response.message assert_equal "I", response.avs_result["code"] assert_equal "N", response.cvv_result["code"] + puts "Test #{options[:order_id]} Sale: #{txn_id(response)}" end def test8 credit_card = CreditCard.new(:number => '6011010100000002', :month => '08', - :year => '2014', :brand => 'discover', + :year => '2021', :brand => 'discover', :verification_value => '184') options = { @@ -210,12 +236,13 @@ def test8 } # 8: authorize - assert response = @gateway.authorize(80080, credit_card, options) + assert response = @gateway.authorize(10100, credit_card, options) assert !response.success? - assert_equal '123', response.params['litleOnlineResponse']['authorizationResponse']['response'] + assert_equal '123', response.params['response'] assert_equal 'Call Discover', response.message assert_equal "I", response.avs_result["code"] assert_equal "P", response.cvv_result["code"] + puts "Test #{options[:order_id]} Authorize: #{txn_id(response)}" # 8: authorize avs authorize_avs_assertions(credit_card, options, :avs => "I", :cvv => "P", :message => "Call Discover", :success => false) @@ -223,15 +250,16 @@ def test8 # 8: sale assert response = @gateway.purchase(80080, credit_card, options) assert !response.success? - assert_equal '123', response.params['litleOnlineResponse']['saleResponse']['response'] + assert_equal '123', response.params['response'] assert_equal 'Call Discover', response.message assert_equal "I", response.avs_result["code"] assert_equal "P", response.cvv_result["code"] + puts "Test #{options[:order_id]} Sale: #{txn_id(response)}" end def test9 credit_card = CreditCard.new(:number => '375001010000003', :month => '09', - :year => '2014', :brand => 'american_express', + :year => '2021', :brand => 'american_express', :verification_value => '0421') options = { @@ -247,92 +275,187 @@ def test9 } # 9: authorize - assert response = @gateway.authorize(90090, credit_card, options) - + assert response = @gateway.authorize(10100, credit_card, options) assert !response.success? - assert_equal '303', response.params['litleOnlineResponse']['authorizationResponse']['response'] + assert_equal '303', response.params['response'] assert_equal 'Pick Up Card', response.message assert_equal "I", response.avs_result["code"] + puts "Test #{options[:order_id]} Authorize: #{txn_id(response)}" # 9: authorize avs authorize_avs_assertions(credit_card, options, :avs => "I", :message => "Pick Up Card", :success => false) # 9: sale - assert response = @gateway.purchase(90090, credit_card, options) + assert response = @gateway.purchase(10100, credit_card, options) assert !response.success? - assert_equal '303', response.params['litleOnlineResponse']['saleResponse']['response'] + assert_equal '303', response.params['response'] assert_equal 'Pick Up Card', response.message assert_equal "I", response.avs_result["code"] + puts "Test #{options[:order_id]} Sale: #{txn_id(response)}" end # Authorization Reversal Tests + def test32 + credit_card = CreditCard.new(:number => '4457010000000009', :month => '01', + :year => '2021', :brand => 'visa', + :verification_value => '349') + + options = { + :order_id => '32', + :billing_address => { + :name => 'John Smith', + :address1 => '1 Main St.', + :city => 'Burlington', + :state => 'MA', + :zip => '01803-3747', + :country => 'US' + } + } + + assert auth_response = @gateway.authorize(10010, credit_card, options) + assert_success auth_response + assert_equal '11111 ', auth_response.params['authCode'] + puts "Test #{options[:order_id]}: #{txn_id(auth_response)}" + + assert capture_response = @gateway.capture(5050, auth_response.authorization, options) + assert_success capture_response + puts "Test #{options[:order_id]}A: #{txn_id(capture_response)}" + + assert reversal_response = @gateway.void(auth_response.authorization, options) + assert_failure reversal_response + assert 'Authorization amount has already been depleted', reversal_response.message + puts "Test #{options[:order_id]}B: #{txn_id(reversal_response)}" + end + + def test33 + credit_card = CreditCard.new(:number => '5112010000000003', :month => '01', + :year => '2021', :brand => 'master', + :verification_value => '261') + + options = { + :order_id => '33', + :billing_address => { + :name => 'Mike J. Hammer', + :address1 => '2 Main St.', + :address2 => 'Apt. 222', + :city => 'Riverside', + :state => 'RI', + :zip => '02915', + :country => 'US', + :payment_cryptogram => 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=' + } + } + + assert auth_response = @gateway.authorize(20020, credit_card, options) + assert_success auth_response + assert_equal '22222 ', auth_response.params['authCode'] + puts "Test #{options[:order_id]}: #{txn_id(auth_response)}" + + assert reversal_response = @gateway.void(auth_response.authorization, options) + assert_success reversal_response + puts "Test #{options[:order_id]}A: #{txn_id(reversal_response)}" + end + def test34 - credit_card = CreditCard.new(:number => '6011010000000003', :month => '03', - :year => '2014', :brand => 'discover', + credit_card = CreditCard.new(:number => '6011010000000003', :month => '01', + :year => '2021', :brand => 'discover', :verification_value => '758') options = { - :order_id => '34', - :billing_address => { - :name => 'Eileen Jones', - :address1 => '3 Main St.', - :city => 'Bloomfield', - :state => 'CT', - :zip => '06002', - :country => 'US' - } + :order_id => '34', + :billing_address => { + :name => 'Eileen Jones', + :address1 => '3 Main St.', + :city => 'Bloomfield', + :state => 'CT', + :zip => '06002', + :country => 'US' + } } assert auth_response = @gateway.authorize(30030, credit_card, options) assert_success auth_response + assert '33333 ', auth_response.params['authCode'] + puts "Test #{options[:order_id]}: #{txn_id(auth_response)}" - credit_card = CreditCard.new(:number => '4024720001231239', :month => '12', - :year => '2014', :brand => 'visa') - assert auth_response2 = @gateway.authorize(18699, credit_card, :order_id => '29') - - assert reversal_response = @gateway.void(auth_response2.authorization) + assert reversal_response = @gateway.void(auth_response.authorization, options) assert_success reversal_response + puts "Test #{options[:order_id]}A: #{txn_id(reversal_response)}" end - def test36 + def test35 + credit_card = CreditCard.new(:number => '375001000000005', :month => '01', + :year => '2021', :brand => 'american_express') + options = { - :order_id => '36' + :order_id => '35', + :billing_address => { + :name => 'Bob Black', + :address1 => '4 Main St.', + :city => 'Laurel', + :state => 'MD', + :zip => '20708', + :country => 'US' + } } - credit_card = CreditCard.new(:number => '375000026600004', :month => '05', - :year => '2014', :brand => 'american_express', - :verification_value => '261') + assert auth_response = @gateway.authorize(10100, credit_card, options) + assert_success auth_response + assert_equal '44444 ', auth_response.params['authCode'] + assert_equal 'A', auth_response.avs_result["code"] + puts "Test #{options[:order_id]}: #{txn_id(auth_response)}" + + assert capture_response = @gateway.capture(5050, auth_response.authorization, options) + assert_success capture_response + puts "Test #{options[:order_id]}A: #{txn_id(capture_response)}" + + assert reversal_response = @gateway.void(auth_response.authorization, options) + assert_failure reversal_response + assert 'Reversal amount does not match Authorization amount', reversal_response.message + puts "Test #{options[:order_id]}B: #{txn_id(reversal_response)}" + end + + def test36 + credit_card = CreditCard.new(:number => '375000026600004', :month => '01', + :year => '2021', :brand => 'american_express') + + options = { + :order_id => '36' + } assert auth_response = @gateway.authorize(20500, credit_card, options) assert_success auth_response + puts "Test #{options[:order_id]}: #{txn_id(auth_response)}" - assert reversal_response = @gateway.void(auth_response.authorization, amount: 10000) - assert !reversal_response.success? - assert_equal '336', reversal_response.params['litleOnlineResponse']['authReversalResponse']['response'] + assert reversal_response = @gateway.void(auth_response.authorization, options) + assert_failure reversal_response + assert 'Reversal amount does not match Authorization amount', reversal_response.message + puts "Test #{options[:order_id]}A: #{txn_id(reversal_response)}" end # Explicit Token Registration Tests def test50 credit_card = CreditCard.new(:number => '4457119922390123') options = { - :order_id => '50' + :order_id => '50' } # store store_response = @gateway.store(credit_card, options) assert_success store_response + assert_equal '445711', store_response.params['bin'] + assert_equal 'VI', store_response.params['type'] + assert_equal '0123', store_response.params['litleToken'][-4,4] + assert_equal '801', store_response.params['response'] assert_equal 'Account number was successfully registered', store_response.message - assert_equal '445711', store_response.params['litleOnlineResponse']['registerTokenResponse']['bin'] - assert_equal 'VI', store_response.params['litleOnlineResponse']['registerTokenResponse']['type'] #type is on Object in 1.8.7 - later versions can use .registerTokenResponse.type - assert_equal '801', store_response.params['litleOnlineResponse']['registerTokenResponse']['response'] - assert_equal '0123', store_response.params['litleOnlineResponse']['registerTokenResponse']['litleToken'][-4,4] + puts "Test #{options[:order_id]}: #{txn_id(response)}" end def test51 credit_card = CreditCard.new(:number => '4457119999999999') - options = { - :order_id => '51' + options = { + :order_id => '51' } # store @@ -340,14 +463,14 @@ def test51 assert_failure store_response assert_equal 'Credit card number was invalid', store_response.message - assert_equal '820', store_response.params['litleOnlineResponse']['registerTokenResponse']['response'] - assert_equal nil, store_response.params['litleOnlineResponse']['registerTokenResponse']['litleToken'] + assert_equal '820', store_response.params['response'] + assert_equal nil, store_response.params['litleToken'] end def test52 credit_card = CreditCard.new(:number => '4457119922390123') - options = { - :order_id => '52' + options = { + :order_id => '52' } # store @@ -355,10 +478,11 @@ def test52 assert_success store_response assert_equal 'Account number was previously registered', store_response.message - assert_equal '445711', store_response.params['litleOnlineResponse']['registerTokenResponse']['bin'] - assert_equal 'VI', store_response.params['litleOnlineResponse']['registerTokenResponse']['type'] #type is on Object in 1.8.7 - later versions can use .registerTokenResponse.type - assert_equal '802', store_response.params['litleOnlineResponse']['registerTokenResponse']['response'] - assert_equal '0123', store_response.params['litleOnlineResponse']['registerTokenResponse']['litleToken'][-4,4] + assert_equal '445711', store_response.params['bin'] + assert_equal 'VI', store_response.params['type'] + assert_equal '802', store_response.params['response'] + assert_equal '0123', store_response.params['litleToken'][-4,4] + puts "Test #{options[:order_id]}: #{txn_id(store_response)}" end # Implicit Token Registration Tests @@ -368,23 +492,19 @@ def test55 :year => '2014', :brand => 'master', :verification_value => '987') - options = { - :order_id => '55' + options = { + :order_id => '55' } # authorize assert response = @gateway.authorize(15000, credit_card, options) - #"tokenResponse" => { "litleToken" => "1712000118270196", - # "tokenResponseCode" => "802", - # "tokenMessage" => "Account number was previously registered", - # "type" => "MC", - # "bin" => "543510" } assert_success response assert_equal 'Approved', response.message - assert_equal '0196', response.params['litleOnlineResponse']['authorizationResponse']['tokenResponse']['litleToken'][-4,4] - assert %w(801 802).include? response.params['litleOnlineResponse']['authorizationResponse']['tokenResponse']['tokenResponseCode'] - assert_equal 'MC', response.params['litleOnlineResponse']['authorizationResponse']['tokenResponse']['type'] - assert_equal '543510', response.params['litleOnlineResponse']['authorizationResponse']['tokenResponse']['bin'] + assert_equal '0196', response.params['tokenResponse_litleToken'][-4,4] + assert %w(801 802).include? response.params['tokenResponse_tokenResponseCode'] + assert_equal 'MC', response.params['tokenResponse_type'] + assert_equal '543510', response.params['tokenResponse_bin'] + puts "Test #{options[:order_id]}: #{txn_id(response)}" end def test56 @@ -393,15 +513,16 @@ def test56 :year => '2014', :brand => 'master', :verification_value => '987') - options = { - :order_id => '56' + options = { + :order_id => '56' } # authorize assert response = @gateway.authorize(15000, credit_card, options) assert_failure response - assert_equal '301', response.params['litleOnlineResponse']['authorizationResponse']['response'] + assert_equal '301', response.params['response'] + puts "Test #{options[:order_id]}: #{txn_id(response)}" end def test57_58 @@ -410,8 +531,8 @@ def test57_58 :year => '2014', :brand => 'master', :verification_value => '987') - options = { - :order_id => '57' + options = { + :order_id => '57' } # authorize card @@ -419,19 +540,20 @@ def test57_58 assert_success response assert_equal 'Approved', response.message - assert_equal '0196', response.params['litleOnlineResponse']['authorizationResponse']['tokenResponse']['litleToken'][-4,4] - assert %w(801 802).include? response.params['litleOnlineResponse']['authorizationResponse']['tokenResponse']['tokenResponseCode'] - assert_equal 'MC', response.params['litleOnlineResponse']['authorizationResponse']['tokenResponse']['type'] - assert_equal '543510', response.params['litleOnlineResponse']['authorizationResponse']['tokenResponse']['bin'] + assert_equal '0196', response.params['tokenResponse_litleToken'][-4,4] + assert %w(801 802).include? response.params['tokenResponse_tokenResponseCode'] + assert_equal 'MC', response.params['tokenResponse_type'] + assert_equal '543510', response.params['tokenResponse_bin'] + puts "Test #{options[:order_id]}: #{txn_id(response)}" # authorize token - token = response.params['litleOnlineResponse']['authorizationResponse']['tokenResponse']['litleToken'] + token = response.params['tokenResponse_litleToken'] options = { - :order_id => '58', - :token => { - :month => credit_card.month, - :year => credit_card.year - } + :order_id => '58', + :token => { + :month => credit_card.month, + :year => credit_card.year + } } # authorize @@ -439,55 +561,95 @@ def test57_58 assert_success response assert_equal 'Approved', response.message + puts "Test #{options[:order_id]}: #{txn_id(response)}" end def test59 - token = '1712990000040196' + token = '1111000100092332' options = { - :order_id => '59', - :token => { - :month => '11', - :year => '2014' - } + :order_id => '59', + :token => { + :month => '11', + :year => '2021' + } } # authorize assert response = @gateway.authorize(15000, token, options) assert_failure response - assert_equal '822', response.params['litleOnlineResponse']['authorizationResponse']['response'] + assert_equal '822', response.params['response'] assert_equal 'Token was not found', response.message + puts "Test #{options[:order_id]}: #{txn_id(response)}" end def test60 token = '171299999999999' options = { - :order_id => '60', - :token => { - :month => '11', - :year => '2014' - } + :order_id => '60', + :token => { + :month => '11', + :year => '2014' + } } # authorize assert response = @gateway.authorize(15000, token, options) assert_failure response - assert_equal '823', response.params['litleOnlineResponse']['authorizationResponse']['response'] + assert_equal '823', response.params['response'] assert_equal 'Token was invalid', response.message + puts "Test #{options[:order_id]}: #{txn_id(response)}" + end + + def test_apple_pay_purchase + options = { + :order_id => transaction_id, + } + decrypted_apple_pay = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new( + { + month: '01', + year: '2021', + brand: "visa", + number: "4457000300000007", + payment_cryptogram: "BwABBJQ1AgAAAAAgJDUCAAAAAAA=" + }) + + assert response = @gateway.purchase(10010, decrypted_apple_pay, options) + assert_success response + assert_equal 'Approved', response.message + end + + def test_android_pay_purchase + options = { + :order_id => transaction_id, + } + decrypted_android_pay = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new( + { + source: :android_pay, + month: '01', + year: '2021', + brand: "visa", + number: "4457000300000007", + payment_cryptogram: "BwABBJQ1AgAAAAAgJDUCAAAAAAA=" + }) + + assert response = @gateway.purchase(10010, decrypted_android_pay, options) + assert_success response + assert_equal 'Approved', response.message end def test_authorize_and_purchase_and_credit_with_token options = { - :order_id => transaction_id, - :billing_address => { - :name => 'John Smith', - :address1 => '1 Main St.', - :city => 'Burlington', - :state => 'MA', - :zip => '01803-3747', - :country => 'US' - } + :order_id => transaction_id, + :billing_address => { + :name => 'John Smith', + :address1 => '1 Main St.', + :city => 'Burlington', + :state => 'MA', + :zip => '01803-3747', + :country => 'US' + } } credit_card = CreditCard.new(:number => '5435101234510196', @@ -536,63 +698,109 @@ def test_authorize_and_purchase_and_credit_with_token private - def auth_assertions(amount, card, options, assertions) + def auth_assertions(amount, card, options, assertions={}) # 1: authorize assert response = @gateway.authorize(amount, card, options) assert_success response assert_equal 'Approved', response.message - assert_equal assertions[:avs], response.avs_result["code"] + assert_equal assertions[:avs], response.avs_result["code"] if assertions[:avs] assert_equal assertions[:cvv], response.cvv_result["code"] if assertions[:cvv] - assert_equal options[:order_id], response.params['litleOnlineResponse']['authorizationResponse']['id'] + assert_equal auth_code(options[:order_id]), response.params['authCode'] + puts "Test #{options[:order_id]} Authorize: #{txn_id(response)}" # 1A: capture - id = transaction_id - assert response = @gateway.capture(amount, response.authorization, {:id => id}) + assert response = @gateway.capture(amount, response.authorization, {:id => transaction_id}) assert_equal 'Approved', response.message - assert_equal id, response.params['litleOnlineResponse']['captureResponse']['id'] + puts "Test #{options[:order_id]}A: #{txn_id(response)}" # 1B: credit - id = transaction_id - assert response = @gateway.credit(amount, response.authorization, {:id => id}) + assert response = @gateway.credit(amount, response.authorization, {:id => transaction_id}) assert_equal 'Approved', response.message - assert_equal id, response.params['litleOnlineResponse']['creditResponse']['id'] + puts "Test #{options[:order_id]}B: #{txn_id(response)}" # 1C: void - id = transaction_id - assert response = @gateway.void(response.authorization, {:id => id}) + assert response = @gateway.void(response.authorization, {:id => transaction_id}) assert_equal 'Approved', response.message - assert_equal id, response.params['litleOnlineResponse']['voidResponse']['id'] + puts "Test #{options[:order_id]}C: #{txn_id(response)}" end def authorize_avs_assertions(credit_card, options, assertions={}) - assert response = @gateway.authorize(0, credit_card, options) + assert response = @gateway.authorize(000, credit_card, options) assert_equal assertions.key?(:success) ? assertions[:success] : true, response.success? assert_equal assertions[:message] || 'Approved', response.message assert_equal assertions[:avs], response.avs_result["code"], caller.inspect assert_equal assertions[:cvv], response.cvv_result["code"], caller.inspect if assertions[:cvv] - assert_equal options[:order_id], response.params['litleOnlineResponse']['authorizationResponse']['id'] + puts "Test #{options[:order_id]} AVS Only: #{txn_id(response)}" end - def sale_assertions(amount, card, options, assertions) + def sale_assertions(amount, card, options, assertions={}) # 1: sale assert response = @gateway.purchase(amount, card, options) assert_success response assert_equal 'Approved', response.message - assert_equal assertions[:avs], response.avs_result["code"] + assert_equal assertions[:avs], response.avs_result["code"] if assertions[:avs] assert_equal assertions[:cvv], response.cvv_result["code"] if assertions[:cvv] - assert_equal options[:order_id], response.params['litleOnlineResponse']['saleResponse']['id'] + assert_equal auth_code(options[:order_id]), response.params['authCode'] + puts "Test #{options[:order_id]} Sale: #{txn_id(response)}" + # 1B: credit - id = transaction_id - assert response = @gateway.credit(amount, response.authorization, {:id => id}) + assert response = @gateway.credit(amount, response.authorization, {:id => transaction_id}) assert_equal 'Approved', response.message - assert_equal id, response.params['litleOnlineResponse']['creditResponse']['id'] + puts "Test #{options[:order_id]}B Sale: #{txn_id(response)}" # 1C: void - id = transaction_id - assert response = @gateway.void(response.authorization, {:id => id}) + assert response = @gateway.void(response.authorization, {:id => transaction_id}) + assert_equal 'Approved', response.message + puts "Test #{options[:order_id]}C Sale: #{txn_id(response)}" + end + + def auth_assertions(amount, card, options, assertions={}) + # 1: authorize + assert response = @gateway.authorize(amount, card, options) + assert_success response + assert_equal 'Approved', response.message + assert_equal assertions[:avs], response.avs_result["code"] if assertions[:avs] + assert_equal assertions[:cvv], response.cvv_result["code"] if assertions[:cvv] + assert_equal auth_code(options[:order_id]), response.params['authCode'] + + # 1A: capture + assert response = @gateway.capture(amount, response.authorization, {:id => transaction_id}) + assert_equal 'Approved', response.message + + # 1B: credit + assert response = @gateway.credit(amount, response.authorization, {:id => transaction_id}) + assert_equal 'Approved', response.message + + # 1C: void + assert response = @gateway.void(response.authorization, {:id => transaction_id}) + assert_equal 'Approved', response.message + end + + def authorize_avs_assertions(credit_card, options, assertions={}) + assert response = @gateway.authorize(000, credit_card, options) + assert_equal assertions.key?(:success) ? assertions[:success] : true, response.success? + assert_equal assertions[:message] || 'Approved', response.message + assert_equal assertions[:avs], response.avs_result["code"], caller.inspect + assert_equal assertions[:cvv], response.cvv_result["code"], caller.inspect if assertions[:cvv] + end + + def sale_assertions(amount, card, options, assertions={}) + # 1: sale + assert response = @gateway.purchase(amount, card, options) + assert_success response + assert_equal 'Approved', response.message + assert_equal assertions[:avs], response.avs_result["code"] if assertions[:avs] + assert_equal assertions[:cvv], response.cvv_result["code"] if assertions[:cvv] + # assert_equal auth_code(options[:order_id]), response.params['authCode'] + + # 1B: credit + assert response = @gateway.credit(amount, response.authorization, {:id => transaction_id}) + assert_equal 'Approved', response.message + + # 1C: void + assert response = @gateway.void(response.authorization, {:id => transaction_id}) assert_equal 'Approved', response.message - assert_equal id, response.params['litleOnlineResponse']['voidResponse']['id'] end def transaction_id @@ -604,4 +812,12 @@ def transaction_id # minLength = N/A maxLength = 25 generate_unique_id[0, 24] end + + def auth_code(order_id) + order_id * 5 + ' ' + end + + def txn_id(response) + response.authorization.split(";")[0] + end end diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb index aa3c62ac9c3..6921a024e53 100644 --- a/test/remote/gateways/remote_litle_test.rb +++ b/test/remote/gateways/remote_litle_test.rb @@ -54,6 +54,15 @@ def setup number: "44444444400009", payment_cryptogram: "BwABBJQ1AgAAAAAgJDUCAAAAAAA=" }) + @decrypted_android_pay = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new( + { + source: :android_pay, + month: '01', + year: '2021', + brand: "visa", + number: "4457000300000007", + payment_cryptogram: "BwABBJQ1AgAAAAAgJDUCAAAAAAA=" + }) end def test_successful_authorization @@ -115,6 +124,12 @@ def test_successful_purchase_with_apple_pay assert_equal 'Approved', response.message end + def test_successful_purchase_with_android_pay + assert response = @gateway.purchase(10000, @decrypted_android_pay) + assert_success response + assert_equal 'Approved', response.message + end + def test_unsuccessful_purchase assert response = @gateway.purchase(60060, @credit_card2, { :order_id=>'6', diff --git a/test/unit/gateways/litle_test.rb b/test/unit/gateways/litle_test.rb index b3c64744ac1..425af365acb 100644 --- a/test/unit/gateways/litle_test.rb +++ b/test/unit/gateways/litle_test.rb @@ -21,6 +21,15 @@ def setup number: "44444444400009", payment_cryptogram: "BwABBJQ1AgAAAAAgJDUCAAAAAAA=" }) + @decrypted_android_pay = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new( + { + source: :android_pay, + month: '01', + year: '2021', + brand: "visa", + number: "4457000300000007", + payment_cryptogram: "BwABBJQ1AgAAAAAgJDUCAAAAAAA=" + }) @amount = 100 @options = {} end @@ -114,6 +123,13 @@ def test_add_applepay_order_source end.respond_with(successful_purchase_response) end + def test_add_android_pay_order_source + stub_comms do + @gateway.purchase(@amount, @decrypted_android_pay) + end.check_request do |endpoint, data, headers| + assert_match "androidpay", data + end.respond_with(successful_purchase_response) + end def test_successful_authorize_and_capture response = stub_comms do From 256848f1b34755b7bebd035145e3fd46cc126576 Mon Sep 17 00:00:00 2001 From: Niaja Date: Mon, 31 Jul 2017 15:31:52 -0400 Subject: [PATCH 144/677] Barclaycard must populate a billing address house number One half of the fix for "Unprocessable Entity" error raised when no houseNumberOrName is used for AVS transcation. Default value is set as "Not Provided" Closes #2520 --- CHANGELOG | 1 + .../billing/gateways/barclaycard_smartpay.rb | 4 ++-- test/remote/gateways/remote_barclaycard_smartpay_test.rb | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 885a28c9f92..441ae05b353 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * PayU Latam: Pass DNI Number [curiousepic] #2517 * Mercado Pago: Add gateway support [davidsantoso] #2518 * Litle: Update schema and certification tests to v9.12 [curiousepic] #2522 +* Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index 77e4b94c60e..a95ef270e65 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -226,12 +226,12 @@ def build_url(action) def address_hash(address) full_address = "#{address[:address1]} #{address[:address2]}" if address street = address[:street] if address[:street] - house = address[:houseNumberOrName] if address[:houseNumberOrName] + house = address[:houseNumberOrName] ? address[:houseNumberOrName] : full_address.split(/\s+/).keep_if { |x| x =~ /\d/ }.join(' ') hash = {} hash[:city] = address[:city] if address[:city] hash[:street] = street || full_address.split(/\s+/).keep_if { |x| x !~ /\d/ }.join(' ') - hash[:houseNumberOrName] = house || full_address.split(/\s+/).keep_if { |x| x =~ /\d/ }.join(' ') + hash[:houseNumberOrName] = house.empty? ? "Not Provided" : house hash[:postalCode] = address[:zip] if address[:zip] hash[:stateOrProvince] = address[:state] if address[:state] hash[:country] = address[:country] if address[:country] diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index 3831434921e..ec7c805f4bc 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -166,10 +166,16 @@ def test_avs_result assert_equal 'N', response.avs_result['code'] end + def test_avs_no_with_house_number + avs_nohousenumber = @avs_address + avs_nohousenumber[:billing_address].delete(:houseNumberOrName) + response = @gateway.authorize(@amount, @avs_credit_card, avs_nohousenumber) + assert_equal 'Z', response.avs_result['code'] + end + def test_nonfractional_currency response = @gateway.authorize(1234, @credit_card, @options.merge(:currency => 'JPY')) assert_success response - response = @gateway.purchase(1234, @credit_card, @options.merge(:currency => 'JPY')) assert_success response end From 07856f6dbf6291f29b0d6446494f4ba682387bb2 Mon Sep 17 00:00:00 2001 From: David Perry Date: Thu, 3 Aug 2017 09:35:27 -0400 Subject: [PATCH 145/677] Litle: Update urls and name to Vantiv Vantiv, which now owns Litle, is rebranding the Litle API. This includes changing the endpoint urls. The new live endpoint url is already active. Replacement for the Sandbox test environment url is forthcoming. The deadline for this change is August 31 2017, when the previous live url will no longer function. Unit: 32 tests, 137 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 28 tests, 117 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2531 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/litle.rb | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 441ae05b353..aa6ad715816 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * Mercado Pago: Add gateway support [davidsantoso] #2518 * Litle: Update schema and certification tests to v9.12 [curiousepic] #2522 * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 +* Litle: Update urls and name to Vantiv [curiousepic] #2531 == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index 14f4d53545b..91bd7744b65 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -6,14 +6,14 @@ class LitleGateway < Gateway SCHEMA_VERSION = '9.12' self.test_url = 'https://www.testlitle.com/sandbox/communicator/online' - self.live_url = 'https://payments.litle.com/vap/communicator/online' + self.live_url = 'https://payments.vantivcnp.com/vap/communicator/online' self.supported_countries = ['US'] self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb] - self.homepage_url = 'http://www.litle.com/' - self.display_name = 'Litle & Co.' + self.homepage_url = 'http://www.vantiv.com/' + self.display_name = 'Vantiv eCommerce' def initialize(options={}) requires!(options, :login, :password, :merchant_id) From 18cef8e158297d4368abaa654ba76fc49d27a764 Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Mon, 31 Jul 2017 16:52:15 -0400 Subject: [PATCH 146/677] FirstData E4: Loose XSD validation for Payeezy (FirstData E4) I've extracted this from the official WSDL for the version we use, which you can find here: https://api.globalgatewaye4.firstdata.com/transaction/v11/wsdl I've made some changes to the `Transaction` object to _not_ define a sequence. We do not send the elements in the order that the schema defines, but that doesn't appear to have ever been a problem. Now, This isn't great, but it avoids a significant refactor of the code to get elements in the correct sequence. --- .../billing/gateways/firstdata_e4.rb | 2 +- test/schema/firstdata_e4/v11.xsd | 126 ++++++++++++++++++ test/unit/gateways/firstdata_e4_test.rb | 11 ++ 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 test/schema/firstdata_e4/v11.xsd diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index 45039338773..7ff1bed28b0 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -156,7 +156,7 @@ def build_request(action, body) xml = Builder::XmlMarkup.new xml.instruct! - xml.tag! "Transaction" do + xml.tag! "Transaction", xmlns: "http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes" do add_credentials(xml) add_transaction_type(xml, action) xml << body diff --git a/test/schema/firstdata_e4/v11.xsd b/test/schema/firstdata_e4/v11.xsd new file mode 100644 index 00000000000..b2bbc2996f6 --- /dev/null +++ b/test/schema/firstdata_e4/v11.xsd @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb index 7de7efb61e5..548d8795353 100755 --- a/test/unit/gateways/firstdata_e4_test.rb +++ b/test/unit/gateways/firstdata_e4_test.rb @@ -1,4 +1,5 @@ require 'test_helper' +require 'nokogiri' require 'yaml' class FirstdataE4Test < Test::Unit::TestCase @@ -212,6 +213,7 @@ def test_network_tokenization_requests_with_amex assert_match "05", data assert_match "mrLdtHIWq2nLXq7IrA==\n", data assert_match "whateverthecryptogramofatlc=\n", data + assert_xml_valid_to_wsdl(data) end.respond_with(successful_purchase_response) end @@ -231,6 +233,7 @@ def test_network_tokenization_requests_with_other_brands assert_match "05", data assert_match "123", data assert_match "whatever_the_cryptogram_is", data + assert_xml_valid_to_wsdl(data) end.respond_with(successful_purchase_response) end end @@ -249,6 +252,7 @@ def test_requests_include_card_authentication_data assert_match "06", data assert_match "SAMPLECAVV", data assert_match "SAMPLEXID", data + assert_xml_valid_to_wsdl(data) end.respond_with(successful_purchase_response) end @@ -286,6 +290,13 @@ def test_supports_network_tokenization private + def assert_xml_valid_to_wsdl(data) + xsd = Nokogiri::XML::Schema(File.open("#{File.dirname(__FILE__)}/../../schema/firstdata_e4/v11.xsd")) + doc = Nokogiri::XML(data) + errors = xsd.validate(doc) + assert_empty errors, "XSD validation errors in the following XML:\n#{doc}" + end + def pre_scrubbed <<-PRE_SCRUBBED opening connection to api.demo.globalgatewaye4.firstdata.com:443... From e8befeb685a9701da0e2b899e1a2d360b81e09ef Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Tue, 1 Aug 2017 08:48:07 -0400 Subject: [PATCH 147/677] FirstData E4: Fix duplicate XID and CAVV values in tokenized transactions These were being added twice, once with the correct values and again empty. Before: ```xml A00427-01 testus 00 1.00 USD 378282246310005 0918 Longbob Longsen American Express 05 456 My Street|K1C2N6|Ottawa|ON|CA mrLdtHIWq2nLXq7IrA== whateverthecryptogramofatlc= 1 Store Purchase ``` After: ``` A00427-01 testus 00 1.00 USD 378282246310005 0918 Longbob Longsen American Express 05 456 My Street|K1C2N6|Ottawa|ON|CA mrLdtHIWq2nLXq7IrA== whateverthecryptogramofatlc= 1 Store Purchase ``` Closes #2529 --- CHANGELOG | 2 ++ .../billing/gateways/firstdata_e4.rb | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index aa6ad715816..941bc727d22 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,8 @@ * Litle: Update schema and certification tests to v9.12 [curiousepic] #2522 * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 * Litle: Update urls and name to Vantiv [curiousepic] #2531 +* FirstData E4: Loose XSD validation for Payeezy (FirstData E4) +* FirstData E4: Fix duplicate XID and CAVV values in tokenized transactions == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index 7ff1bed28b0..f8f48ccc774 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -171,14 +171,13 @@ def build_sale_or_authorization_request(money, credit_card_or_store_authorizatio add_amount(xml, money, options) if credit_card_or_store_authorization.is_a? String - add_credit_card_token(xml, credit_card_or_store_authorization) + add_credit_card_token(xml, credit_card_or_store_authorization, options) else add_credit_card(xml, credit_card_or_store_authorization, options) end add_customer_data(xml, options) add_invoice(xml, options) - add_card_authentication_data(xml, options) add_tax_fields(xml, options) add_level_3(xml, options) @@ -254,9 +253,13 @@ def add_credit_card_verification_strings(xml, credit_card, options) if credit_card.is_a?(NetworkTokenizationCreditCard) add_network_tokenization_credit_card(xml, credit_card) - elsif credit_card.verification_value? - xml.tag! "CVD_Presence_Ind", "1" - xml.tag! "VerificationStr2", credit_card.verification_value + else + if credit_card.verification_value? + xml.tag! "CVD_Presence_Ind", "1" + xml.tag! "VerificationStr2", credit_card.verification_value + end + + add_card_authentication_data(xml, options) end end @@ -277,7 +280,7 @@ def add_card_authentication_data(xml, options) xml.tag! "XID", options[:xid] end - def add_credit_card_token(xml, store_authorization) + def add_credit_card_token(xml, store_authorization, options) params = store_authorization.split(";") credit_card = CreditCard.new( :brand => params[1], @@ -290,6 +293,7 @@ def add_credit_card_token(xml, store_authorization) xml.tag! "Expiry_Date", expdate(credit_card) xml.tag! "CardHoldersName", credit_card.name xml.tag! "CardType", card_type(credit_card.brand) + add_card_authentication_data(xml, options) end def add_customer_data(xml, options) From ee8f82a7fe310d04fafd2a7dd2673f7e89dece8e Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Fri, 4 Aug 2017 08:36:55 -0400 Subject: [PATCH 148/677] Release version 1.70.0 --- CHANGELOG | 20 +++++++++++--------- lib/active_merchant/version.rb | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 941bc727d22..251300c003f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,18 +1,20 @@ = ActiveMerchant CHANGELOG == HEAD -* SafeCharge: Pass UserID field [curiousepic] #2507 -* SafeCharge: Correct UserID field name [curiousepic] -* Qvalent: Pass 3dSecure fields [curiousepic] #2508 + +== Version 1.70.0 (August 4, 2017) +* Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 +* FirstData E4: Fix duplicate XID and CAVV values in tokenized transactions [jasonwebster] #2529 +* FirstData E4: Loose XSD validation for Payeezy (FirstData E4) [jasonwebster] #2529 * GlobalTransport: Support partial authorizations [dtykocki] #2511 -* Orbital: Add support for level 2 data [dtykocki] #2515 -* PayU Latam: Pass DNI Number [curiousepic] #2517 -* Mercado Pago: Add gateway support [davidsantoso] #2518 * Litle: Update schema and certification tests to v9.12 [curiousepic] #2522 -* Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 * Litle: Update urls and name to Vantiv [curiousepic] #2531 -* FirstData E4: Loose XSD validation for Payeezy (FirstData E4) -* FirstData E4: Fix duplicate XID and CAVV values in tokenized transactions +* Mercado Pago: Add gateway support [davidsantoso] #2518 +* Orbital: Add support for level 2 data [dtykocki] #2515 +* PayU Latam: Pass DNI Number [curiousepic] #2517 +* Qvalent: Pass 3dSecure fields [curiousepic] #2508 +* SafeCharge: Correct UserID field name [curiousepic] +* SafeCharge: Pass UserID field [curiousepic] #2507 == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index b9b0fadca9c..8b51ca942a0 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.69.0" + VERSION = "1.70.0" end From 5c479110b2b55807b1d1bbd281a4ab28f1d249f0 Mon Sep 17 00:00:00 2001 From: Niaja Date: Wed, 2 Aug 2017 14:15:22 -0400 Subject: [PATCH 149/677] Allow Response Code 4 to be returned as successful Currently only response code 1 is being recorded as a successful transaction, however response_code 4 is also successful but held for fraud review. Loaded suite test/remote/gateways/remote_authorize_net_test Started ............................................................. Finished in 40.926721 seconds. 61 tests, 210 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 1.49 tests/s, 5.13 assertions/s Closes #2530 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/authorize_net.rb | 2 +- test/unit/gateways/authorize_net_test.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 251300c003f..ccdf7f9c89c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * Qvalent: Pass 3dSecure fields [curiousepic] #2508 * SafeCharge: Correct UserID field name [curiousepic] * SafeCharge: Pass UserID field [curiousepic] #2507 +* AuthorizeNet: Allow Response Code 4 to be returned as successful [nfarve] #2530 == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index 1e28da97e97..d4b9868ad14 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -898,7 +898,7 @@ def success_from(action, response) if cim?(action) || (action == :verify_credentials) response[:result_code] == "Ok" else - response[:response_code] == APPROVED && TRANSACTION_ALREADY_ACTIONED.exclude?(response[:response_reason_code]) + [APPROVED, FRAUD_REVIEW].include?(response[:response_code]) && TRANSACTION_ALREADY_ACTIONED.exclude?(response[:response_reason_code]) end end diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 33d82b83ed6..64b3f82dcb3 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -826,7 +826,7 @@ def test_response_under_review_by_fraud_service @gateway.expects(:ssl_post).returns(fraud_review_response) response = @gateway.purchase(@amount, @credit_card) - assert_failure response + assert_success response assert response.fraud_review? assert_equal "Thank you! For security reasons your order is currently being reviewed", response.message end From d74fe92450a59591752f13d877febb9048c73604 Mon Sep 17 00:00:00 2001 From: Niaja Date: Thu, 3 Aug 2017 11:02:35 -0400 Subject: [PATCH 150/677] Remove param[:order_number] from captures in Forte Gateway When processing captures in the forte gateway only admin messages are allowed. Adding the param[:order_number] produces an F03 invalid field name error. Loaded suite test/remote/gateways/remote_forte_test Started Finished in 40.85056 seconds. 18 tests, 45 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2532 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/forte.rb | 1 - test/remote/gateways/remote_forte_test.rb | 10 ++++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ccdf7f9c89c..4f14e69f693 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * SafeCharge: Correct UserID field name [curiousepic] * SafeCharge: Pass UserID field [curiousepic] #2507 * AuthorizeNet: Allow Response Code 4 to be returned as successful [nfarve] #2530 +* Forte: Remove order number from captures in Forte Gateway [nfarve] #2532 == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/forte.rb b/lib/active_merchant/billing/gateways/forte.rb index 7417d69a61a..fd50c83a3cc 100644 --- a/lib/active_merchant/billing/gateways/forte.rb +++ b/lib/active_merchant/billing/gateways/forte.rb @@ -46,7 +46,6 @@ def authorize(money, payment_method, options={}) def capture(money, authorization, options={}) post = {} - add_invoice(post, options) post[:transaction_id] = transaction_id_from(authorization) post[:authorization_code] = authorization_code_from(authorization) || "" post[:action] = "capture" diff --git a/test/remote/gateways/remote_forte_test.rb b/test/remote/gateways/remote_forte_test.rb index 3e8a3a13740..f54bb27f623 100644 --- a/test/remote/gateways/remote_forte_test.rb +++ b/test/remote/gateways/remote_forte_test.rb @@ -21,8 +21,10 @@ def setup @options = { billing_address: address, - description: 'Store Purchase' + description: 'Store Purchase', + order_id: '1' } + end def test_invalid_login @@ -76,7 +78,7 @@ def test_successful_authorize_and_capture wait_for_authorization_to_clear - assert capture = @gateway.capture(@amount, auth.authorization) + assert capture = @gateway.capture(@amount, auth.authorization, @options) assert_success capture assert_equal 'APPROVED', capture.message end @@ -94,12 +96,12 @@ def test_partial_capture wait_for_authorization_to_clear - assert capture = @gateway.capture(@amount-1, auth.authorization) + assert capture = @gateway.capture(@amount-1, auth.authorization, @options) assert_success capture end def test_failed_capture - response = @gateway.capture(@amount, '') + response = @gateway.capture(@amount, '', @options) assert_failure response assert_match 'field transaction_id', response.message end From 611f93c3faaca283675d08d626bb0e7ce00911b0 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Tue, 1 Aug 2017 16:50:35 -0400 Subject: [PATCH 151/677] PayU Latam: Add additional mandatory fields. Remote: 15 tests, 39 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 86.6667% passed (These two failures both have a responseCode of 'INTERNAL_PAYMENT_PROVIDER_ERROR' and pre-date these changes.) Unit: 17 tests, 71 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2528 --- CHANGELOG | 1 + .../billing/gateways/payu_latam.rb | 34 +++++++++++++++---- .../remote/gateways/remote_payu_latam_test.rb | 12 +++++-- test/unit/gateways/payu_latam_test.rb | 8 +++++ 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4f14e69f693..c0b9055fcc2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ * SafeCharge: Pass UserID field [curiousepic] #2507 * AuthorizeNet: Allow Response Code 4 to be returned as successful [nfarve] #2530 * Forte: Remove order number from captures in Forte Gateway [nfarve] #2532 +* PayU Latam: Add additional mandatory fields [deedeelavinder] #2528 == Version 1.69.0 (July 12, 2017) * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index 5df6b983877..0f029fbfa1f 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -49,7 +49,7 @@ def capture(amount, authorization, options={}) post = {} add_credentials(post, 'SUBMIT_TRANSACTION') - add_transaction_type(post, 'CAPTURE') + add_transaction_elements(post, 'CAPTURE', options) add_reference(post, authorization) commit('capture', post) @@ -59,7 +59,7 @@ def void(authorization, options={}) post = {} add_credentials(post, 'SUBMIT_TRANSACTION') - add_transaction_type(post, 'VOID') + add_transaction_elements(post, 'VOID', options) add_reference(post, authorization) commit('void', post) @@ -69,7 +69,7 @@ def refund(amount, authorization, options={}) post = {} add_credentials(post, 'SUBMIT_TRANSACTION') - add_transaction_type(post, 'REFUND') + add_transaction_elements(post, 'REFUND', options) add_reference(post, authorization) commit('refund', post) @@ -116,7 +116,7 @@ def scrub(transcript) def auth_or_sale(post, transaction_type, amount, payment_method, options) add_credentials(post, 'SUBMIT_TRANSACTION') - add_transaction_type(post, transaction_type) + add_transaction_elements(post, transaction_type, options) add_order(post, options) add_buyer(post, options) add_invoice(post, amount, options) @@ -136,9 +136,13 @@ def add_credentials(post, command) post[:merchant] = merchant end - def add_transaction_type(post, type) + def add_transaction_elements(post, type, options) transaction = {} transaction[:type] = type + transaction[:ipAddress] = options[:ip] if options[:ip] + transaction[:userAgent] = options[:user_agent] if options[:user_agent] + transaction[:cookie] = options[:cookie] if options[:cookie] + transaction[:deviceSessionId] = options[:device_session_id] if options[:device_session_id] post[:transaction] = transaction end @@ -155,7 +159,10 @@ def add_buyer(post, options) if address = options[:shipping_address] buyer = {} buyer[:fullName] = address[:name] - buyer[:dniNumber] = options[:dni_number] + buyer[:dniNumber] = options[:dni_number] if options[:dni_number] + buyer[:dniType] = options[:dni_type] if options[:dni_type] + buyer[:emailAddress] = options[:email] if options[:email] + buyer[:contactPhone] = address[:phone] shipping_address = {} shipping_address[:street1] = address[:address1] shipping_address[:street2] = address[:address2] @@ -174,8 +181,18 @@ def add_invoice(post, money, options) tx_value[:value] = amount(money) tx_value[:currency] = options[:currency] || currency(money) + tx_tax = {} + tx_tax[:value] = options[:tax] || '0' + tx_tax[:currency] = options[:currency] || currency(money) + + tx_tax_return_base = {} + tx_tax_return_base[:value] = options[:tax_return_base] || '0' + tx_tax_return_base[:currency] = options[:currency] || currency(money) + additional_values = {} additional_values[:TX_VALUE] = tx_value + additional_values[:TX_TAX] = tx_tax + additional_values[:TX_TAX_RETURN_BASE] = tx_tax_return_base post[:transaction][:order][:additionalValues] = additional_values end @@ -235,7 +252,10 @@ def add_payer(post, options) post[:transaction][:paymentCountry] = address[:country] payer[:fullName] = address[:name] payer[:contactPhone] = address[:phone] - payer[:dniNumber] = options[:dni_number] + payer[:dniNumber] = options[:dni_number] if options[:dni_number] + payer[:dniType] = options[:dni_type] if options[:dni_type] + payer[:emailAddress] = options[:email] if options[:email] + payer[:contactPhone] = address[:phone] billing_address = {} billing_address[:street1] = address[:address1] billing_address[:street2] = address[:address2] diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index 15fa32f9bd7..5561cbf1486 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -6,15 +6,23 @@ def setup @amount = 4000 @credit_card = credit_card("4097440000000004", verification_value: "444", first_name: "APPROVED", last_name: "") - @declined_card = credit_card("4097440000000004", verification_value: "333", first_name: "REJECTED", last_name: "") - @pending_card = credit_card("4097440000000004", verification_value: "222", first_name: "PENDING", last_name: "") + @declined_card = credit_card("4097440000000004", verification_value: "444", first_name: "REJECTED", last_name: "") + @pending_card = credit_card("4097440000000004", verification_value: "444", first_name: "PENDING", last_name: "") @options = { dni_number: '5415668464654', + dni_type: 'TI', currency: "ARS", order_id: generate_unique_id, description: "Active Merchant Transaction", installments_number: 1, + tax: 0, + tax_return_base: 0, + email: "username@domain.com", + ip: "127.0.0.1", + device_session_id: 'vghs6tvkcle931686k1900o6e1', + cookie: 'pt1t38347bs6jc9ruv2ecpv7o2', + user_agent: 'Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0', billing_address: address( address1: "Viamonte", address2: "1366", diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb index 119cf71ebac..3d496ad3ddd 100644 --- a/test/unit/gateways/payu_latam_test.rb +++ b/test/unit/gateways/payu_latam_test.rb @@ -15,10 +15,18 @@ def setup @options = { dni_number: '5415668464654', + dni_type: 'TI', currency: "ARS", order_id: generate_unique_id, description: "Active Merchant Transaction", installments_number: 1, + tax: 0, + tax_return_base: 0, + email: "username@domain.com", + ip: "127.0.0.1", + device_session_id: 'vghs6tvkcle931686k1900o6e1', + cookie: 'pt1t38347bs6jc9ruv2ecpv7o2', + user_agent: 'Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0', billing_address: address( address1: "Viamonte", address2: "1366", From d59aab0ec95992b6a6ca23f4926256a849757252 Mon Sep 17 00:00:00 2001 From: David Perry Date: Thu, 3 Aug 2017 09:27:14 -0400 Subject: [PATCH 152/677] Vantiv (Litle): Pass 3DS fields Remote: 29 tests, 120 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 32 tests, 137 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2536 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/litle.rb | 9 ++++- .../remote_litle_certification_test.rb | 38 +++++++++++++++++++ test/remote/gateways/remote_litle_test.rb | 11 ++++++ 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c0b9055fcc2..a9571a52548 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Vantiv (Litle): Pass 3DS fields [curiousepic] #2536 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index 91bd7744b65..c79cf263399 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -175,7 +175,7 @@ def add_auth_purchase_params(doc, money, payment_method, options) add_order_source(doc, payment_method, options) add_billing_address(doc, payment_method, options) add_shipping_address(doc, payment_method, options) - add_payment_method(doc, payment_method) + add_payment_method(doc, payment_method, options) add_pos(doc, payment_method) add_descriptor(doc, options) add_debt_repayment(doc, options) @@ -194,7 +194,7 @@ def add_debt_repayment(doc, options) doc.debtRepayment(true) if options[:debt_repayment] == true end - def add_payment_method(doc, payment_method) + def add_payment_method(doc, payment_method, options) if payment_method.is_a?(String) doc.token do doc.litleToken(payment_method) @@ -214,6 +214,11 @@ def add_payment_method(doc, payment_method) doc.cardholderAuthentication do doc.authenticationValue(payment_method.payment_cryptogram) end + elsif options[:order_source] && options[:order_source].start_with?('3ds') + doc.cardholderAuthentication do + doc.authenticationValue(options[:cavv]) if options[:cavv] + doc.authenticationTransactionId(options[:xid]) if options[:xid] + end end end end diff --git a/test/remote/gateways/remote_litle_certification_test.rb b/test/remote/gateways/remote_litle_certification_test.rb index ba03f28de48..f7bfe2b5704 100644 --- a/test/remote/gateways/remote_litle_certification_test.rb +++ b/test/remote/gateways/remote_litle_certification_test.rb @@ -639,6 +639,25 @@ def test_android_pay_purchase assert_equal 'Approved', response.message end + def test_three_d_secure + three_d_secure_assertions('3DS1', '4100200300000004', 'visa', '3dsAuthenticated', '0') + three_d_secure_assertions('3DS2', '4100200300000012', 'visa', '3dsAuthenticated', '1') + three_d_secure_assertions('3DS3', '4100200300000103', 'visa', '3dsAuthenticated', '2') + three_d_secure_assertions('3DS4', '4100200300001002', 'visa', '3dsAuthenticated', 'A') + three_d_secure_assertions('3DS5', '4100200300000020', 'visa', '3dsAuthenticated', '3') + three_d_secure_assertions('3DS6', '4100200300000038', 'visa', '3dsAuthenticated', '4') + three_d_secure_assertions('3DS7', '4100200300000046', 'visa', '3dsAuthenticated', '5') + three_d_secure_assertions('3DS8', '4100200300000053', 'visa', '3dsAuthenticated', '6') + three_d_secure_assertions('3DS9', '4100200300000061', 'visa', '3dsAuthenticated', '7') + three_d_secure_assertions('3DS10', '4100200300000079', 'visa', '3dsAuthenticated', '8') + three_d_secure_assertions('3DS11', '4100200300000087', 'visa', '3dsAuthenticated', '9') + three_d_secure_assertions('3DS12', '4100200300000095', 'visa', '3dsAuthenticated', 'B') + three_d_secure_assertions('3DS13', '4100200300000111', 'visa', '3dsAuthenticated', 'C') + three_d_secure_assertions('3DS14', '4100200300000129', 'visa', '3dsAuthenticated', 'D') + three_d_secure_assertions('3DS15', '5112010200000001', 'master', '3dsAttempted', nil) + three_d_secure_assertions('3DS16', '5112010200000001', 'master', '3dsAttempted', nil) + end + def test_authorize_and_purchase_and_credit_with_token options = { :order_id => transaction_id, @@ -803,6 +822,25 @@ def sale_assertions(amount, card, options, assertions={}) assert_equal 'Approved', response.message end + def three_d_secure_assertions(test_id, card, type, source, result) + credit_card = CreditCard.new(:number => card, :month => '01', + :year => '2021', :brand => type, + :verification_value => '261', + :name => 'Mike J. Hammer') + + options = { + order_id: test_id, + order_source: source, + cavv: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=', + xid: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=' + } + + assert response = @gateway.authorize(10100, credit_card, options) + assert_success response + assert_equal result, response.params['fraudResult_authenticationResult'] + puts "Test #{test_id}: #{txn_id(response)}" + end + def transaction_id # A unique identifier assigned by the presenter and mirrored back in the response. # This attribute is also used for Duplicate Transaction Detection. diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb index 6921a024e53..05b43f1d781 100644 --- a/test/remote/gateways/remote_litle_test.rb +++ b/test/remote/gateways/remote_litle_test.rb @@ -118,6 +118,17 @@ def test_successful_purchase_with_debt_repayment_flag assert_equal 'Approved', response.message end + def test_successful_purchase_with_3ds_fields + options = @options.merge({ + order_source: '3dsAuthenticated', + xid: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=', + cavv: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=' + }) + assert response = @gateway.purchase(10010, @credit_card1, options) + assert_success response + assert_equal 'Approved', response.message + end + def test_successful_purchase_with_apple_pay assert response = @gateway.purchase(10010, @decrypted_apple_pay) assert_success response From 12447750f632e66adfb71bf383958ce71395d91f Mon Sep 17 00:00:00 2001 From: nicolas-maalouf-cko Date: Wed, 24 May 2017 23:12:11 +0100 Subject: [PATCH 153/677] Checkout V2: Fix success response code validation This is to cater to an edge case that can happen with Checkout.com's Gateway: When using AVS risk rules, a transaction can be handled as "Void Authorize". In such cases the responseCode would be 10000, but the responseMessage shows the error code and description instead of "Approved". See https://github.com/activemerchant/active_merchant/pull/2452 --- lib/active_merchant/billing/gateways/checkout_v2.rb | 2 +- test/remote/gateways/remote_checkout_v2_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb index a4fa1fa8798..3d0770c5282 100644 --- a/lib/active_merchant/billing/gateways/checkout_v2.rb +++ b/lib/active_merchant/billing/gateways/checkout_v2.rb @@ -166,7 +166,7 @@ def parse(body) end def success_from(response) - response["responseCode"] == "10000" || response["responseCode"] == "10100" + (response["responseCode"] == "10000" && !response["responseMessage"].start_with?("40")) || response["responseCode"] == "10100" end def message_from(succeeded, response) diff --git a/test/remote/gateways/remote_checkout_v2_test.rb b/test/remote/gateways/remote_checkout_v2_test.rb index d7f58773a2f..965f249453f 100644 --- a/test/remote/gateways/remote_checkout_v2_test.rb +++ b/test/remote/gateways/remote_checkout_v2_test.rb @@ -64,6 +64,12 @@ def test_failed_purchase assert_equal 'Invalid Card Number', response.message end + def test_avs_failed_purchase + response = @gateway.purchase(@amount, @credit_card, billing_address: address.update(address1: 'Test_A')) + assert_failure response + assert_equal '40111 - Street Match Only', response.message + end + def test_successful_authorize_and_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth From 43abf87236a8b7ff73039482494e0511129a1739 Mon Sep 17 00:00:00 2001 From: nicolas-maalouf-cko Date: Thu, 8 Jun 2017 10:52:08 +0100 Subject: [PATCH 154/677] Checkout V2: Add localized_amount support to add_invoice function Closes https://github.com/activemerchant/active_merchant/pull/2452 --- CHANGELOG | 2 ++ lib/active_merchant/billing/gateways/checkout_v2.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a9571a52548..2a273586d71 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,8 @@ == HEAD * Vantiv (Litle): Pass 3DS fields [curiousepic] #2536 +* Checkout V2: Add localized_amount support to add_invoice function [nicolas-maalouf-cko] #2452 +* Checkout V2: Fix success response code validation [nicolas-maalouf-cko] #2452 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb index 3d0770c5282..81a60d95cc1 100644 --- a/lib/active_merchant/billing/gateways/checkout_v2.rb +++ b/lib/active_merchant/billing/gateways/checkout_v2.rb @@ -75,7 +75,7 @@ def scrub(transcript) private def add_invoice(post, money, options) - post[:value] = amount(money) + post[:value] = localized_amount(money, options[:currency]) post[:trackId] = options[:order_id] post[:currency] = options[:currency] || currency(money) post[:descriptor] = {} From d27c34e9e0e714afbf03d5eacf2a8cb20dc5b3da Mon Sep 17 00:00:00 2001 From: Malcolm Mergulhao Date: Tue, 1 Aug 2017 11:45:23 -0400 Subject: [PATCH 155/677] stripe emv transactions send statement_addess parameters. Closes #2524 clean up guard clause for add_statement_address respond to code review feedback --- CHANGELOG | 1 + .../billing/gateways/stripe.rb | 16 ++++++++++- test/test_helper.rb | 10 +++++++ test/unit/gateways/stripe_test.rb | 27 +++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 2a273586d71..21bddfd09f5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Stripe: Add support for statement_address parameters for EMV transactions [malcolm-mergulhao] #2524 * Vantiv (Litle): Pass 3DS fields [curiousepic] #2536 * Checkout V2: Add localized_amount support to add_invoice function [nicolas-maalouf-cko] #2452 * Checkout V2: Fix success response code validation [nicolas-maalouf-cko] #2452 diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 95155347e8b..10a23be6f0b 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -303,7 +303,9 @@ def create_post_for_auth_or_purchase(money, payment, options) add_creditcard(post, payment, options) end - unless emv_payment?(payment) + if emv_payment?(payment) + add_statement_address(post, options) + else add_amount(post, money, options, true) add_customer_data(post, options) post[:description] = options[:description] @@ -365,6 +367,18 @@ def add_address(post, options) end end + def add_statement_address(post, options) + return unless statement_address = options[:statement_address] + return unless [:address1, :city, :zip, :state].all? { |key| statement_address[key].present? } + + post[:statement_address] = {} + post[:statement_address][:line1] = statement_address[:address1] + post[:statement_address][:line2] = statement_address[:address2] if statement_address[:address2].present? + post[:statement_address][:city] = statement_address[:city] + post[:statement_address][:postal_code] = statement_address[:zip] + post[:statement_address][:state] = statement_address[:state] + end + def add_creditcard(post, creditcard, options) card = {} if emv_payment?(creditcard) diff --git a/test/test_helper.rb b/test/test_helper.rb index b866558cd96..929e5d8df59 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -234,6 +234,16 @@ def address(options = {}) }.update(options) end + def statement_address(options = {}) + { + address1: '456 My Street', + address2: 'Apt 1', + city: 'Ottawa', + state: 'ON', + zip: 'K1C2N6' + }.update(options) + end + def generate_unique_id SecureRandom.hex(16) end diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index c9a217d8c64..599d644595e 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -12,6 +12,7 @@ def setup @options = { :billing_address => address(), + :statement_address => statement_address(), :description => 'Test Purchase' } @@ -898,6 +899,32 @@ def test_add_address assert_equal @options[:billing_address][:city], post[:card][:address_city] end + def test_add_statement_address + post = {} + + @gateway.send(:add_statement_address, post, @options) + + assert_equal @options[:statement_address][:zip], post[:statement_address][:postal_code] + assert_equal @options[:statement_address][:state], post[:statement_address][:state] + assert_equal @options[:statement_address][:address1], post[:statement_address][:line1] + assert_equal @options[:statement_address][:address2], post[:statement_address][:line2] + assert_equal @options[:statement_address][:country], post[:statement_address][:country] + assert_equal @options[:statement_address][:city], post[:statement_address][:city] + end + + def test_add_statement_address_returns_nil_if_required_fields_missing + post = {} + [:address1, :city, :zip, :state].each do |required_key| + missing_required = @options.tap do |options| + options[:statement_address].delete_if { |k| k == required_key } + end + + @gateway.send(:add_statement_address, post, missing_required) + + assert_equal nil, post[:statement_address] + end + end + def test_ensure_does_not_respond_to_credit assert !@gateway.respond_to?(:credit) end From 7f8bfa59abb59153fca50e8146e3897adfd1e308 Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 8 Aug 2017 16:22:53 -0400 Subject: [PATCH 156/677] Remove HUF from default non-fractional currencies HUF is not a true non-fractional currency, but was included in the default list of non-fractional currencies in the Gateway class. After changing Barclaycard Smartpay to use localized_amount, this was causing it to send incorrect amounts for HUF. This removes it from the Gateway class's default list of non-fractional currencies. Paypal Express and Worldpay seem to be the only gateways that consider HUF to be non-fractional, and those already override the default list. It's possible other gateways consider HUF to be non- fractional, in which case those gateways should have their own over- riding list. Full Unit: 3648 tests, 66870 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2538 --- CHANGELOG | 1 + lib/active_merchant/billing/gateway.rb | 2 +- test/unit/gateways/gateway_test.rb | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 21bddfd09f5..3f9b7bdda63 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Vantiv (Litle): Pass 3DS fields [curiousepic] #2536 * Checkout V2: Add localized_amount support to add_invoice function [nicolas-maalouf-cko] #2452 * Checkout V2: Fix success response code validation [nicolas-maalouf-cko] #2452 +* Remove HUF from default non-fractional currencies [curiousepic] #2538 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateway.rb b/lib/active_merchant/billing/gateway.rb index 1b7461e1387..6a150f9f9bd 100644 --- a/lib/active_merchant/billing/gateway.rb +++ b/lib/active_merchant/billing/gateway.rb @@ -126,7 +126,7 @@ def generate_unique_id self.supported_cardtypes = [] class_attribute :currencies_without_fractions, :currencies_with_three_decimal_places - self.currencies_without_fractions = %w(BIF BYR CLP CVE DJF GNF HUF ISK JPY KMF KRW PYG RWF UGX VND VUV XAF XOF XPF) + self.currencies_without_fractions = %w(BIF BYR CLP CVE DJF GNF ISK JPY KMF KRW PYG RWF UGX VND VUV XAF XOF XPF) self.currencies_with_three_decimal_places = %w() class_attribute :homepage_url diff --git a/test/unit/gateways/gateway_test.rb b/test/unit/gateways/gateway_test.rb index 465c513d76b..a96c3c506c7 100644 --- a/test/unit/gateways/gateway_test.rb +++ b/test/unit/gateways/gateway_test.rb @@ -83,11 +83,11 @@ def test_localized_amount_should_not_modify_for_fractional_currencies def test_localized_amount_should_ignore_money_format_for_non_fractional_currencies Gateway.money_format = :dollars assert_equal '1', @gateway.send(:localized_amount, 100, 'JPY') - assert_equal '12', @gateway.send(:localized_amount, 1234, 'HUF') + assert_equal '12', @gateway.send(:localized_amount, 1234, 'ISK') Gateway.money_format = :cents assert_equal '1', @gateway.send(:localized_amount, 100, 'JPY') - assert_equal '12', @gateway.send(:localized_amount, 1234, 'HUF') + assert_equal '12', @gateway.send(:localized_amount, 1234, 'ISK') end def test_localized_amount_returns_three_decimal_places_for_three_decimal_currencies From 6655ec2e3d4e3dea44eaa8030758e90344ae8ed8 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Fri, 11 Aug 2017 09:17:16 -0400 Subject: [PATCH 157/677] MercadoPago: Use symbol for sponsor_id field --- lib/active_merchant/billing/gateways/mercado_pago.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index 32a3295f0c9..da2cbbe3741 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -101,7 +101,7 @@ def authorize_request(money, payment, options = {}) end def add_additional_data(post, options) - post[:sponsor_id] = options["sponsor_id"] + post[:sponsor_id] = options[:sponsor_id] post[:additional_info] = { ip_address: options[:ip_address] } From 43dfe0a15e98a8761c34ed29d96a057ec307a8f6 Mon Sep 17 00:00:00 2001 From: Niaja Date: Mon, 14 Aug 2017 08:52:34 -0400 Subject: [PATCH 158/677] TransFirst Express: Don't send address2 without value Removed the address2 field unless a value is given. Closes #2545 Loaded suite test/remote/gateways/remote_trans_first_transaction_express_test Started Finished in 23.362846 seconds. 30 tests, 105 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 1.28 tests/s, 4.49 assertions/s Loaded suite test/unit/gateways/trans_first_transaction_express_test Started Finished in 0.068235 seconds. 21 tests, 103 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 307.76 tests/s, 1509.49 assertions/s --- CHANGELOG | 1 + .../gateways/trans_first_transaction_express.rb | 2 +- .../remote_trans_first_transaction_express_test.rb | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 3f9b7bdda63..e9e0c6601a1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * Checkout V2: Add localized_amount support to add_invoice function [nicolas-maalouf-cko] #2452 * Checkout V2: Fix success response code validation [nicolas-maalouf-cko] #2452 * Remove HUF from default non-fractional currencies [curiousepic] #2538 +* TransFirst Express: Don't send address2 without value [nfarve] #2545 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb index 577147199cc..6f949998034 100644 --- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb @@ -542,7 +542,7 @@ def add_contact(doc, fullname, options) doc["v1"].nr billing_address[:phone].gsub(/\D/, '') if billing_address[:phone] end doc["v1"].addrLn1 billing_address[:address1] - doc["v1"].addrLn2 billing_address[:address2] + doc["v1"].addrLn2 billing_address[:address2] if billing_address[:address2] doc["v1"].city billing_address[:city] doc["v1"].state billing_address[:state] doc["v1"].zipCode billing_address[:zip] diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb index 7c53ebaa968..33c2c4ae5bd 100644 --- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb +++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb @@ -45,6 +45,20 @@ def test_successful_purchase assert_equal "Street address does not match, but 5-digit postal code matches.", response.avs_result["message"] assert_equal "CVV matches", response.cvv_result["message"] end + + def test_successful_purchase_with_no_address2 + options = @options.dup + options[:shipping_address][:address2] = nil + options[:billing_address][:address2] = nil + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_equal "Succeeded", response.message + assert_not_nil response.avs_result + assert_not_nil response.cvv_result + assert_equal "Street address does not match, but 5-digit postal code matches.", response.avs_result["message"] + assert_equal "CVV matches", response.cvv_result["message"] + end + def test_successful_purchase_without_cvv credit_card_opts = { From 35878d846849f320dd4b00e3b41aa7fd05006ef3 Mon Sep 17 00:00:00 2001 From: Niaja Date: Wed, 9 Aug 2017 17:10:10 -0400 Subject: [PATCH 159/677] TransFirst: Fix partial refund The incorrect endpoint was being used for refunds. This updates the refund method so that a partial refund can be done. Remote tests are not possible since refunds can only be done on settled transctions. A unit test was updated to check the amount returned. Closes #2541 Remote tests: Finished in 0.016094 seconds. 11 tests, 25 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 683.48 tests/s, 1553.37 assertions/s Remote tests: Finished in 8.146803 seconds. 12 tests, 41 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 1.47 tests/s, 5.03 assertions/s --- CHANGELOG | 1 + .../billing/gateways/trans_first.rb | 5 +- .../gateways/remote_trans_first_test.rb | 25 ++++++++-- test/unit/gateways/trans_first_test.rb | 47 +++++++++++++++++++ 4 files changed, 73 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e9e0c6601a1..54541f9b839 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * Checkout V2: Fix success response code validation [nicolas-maalouf-cko] #2452 * Remove HUF from default non-fractional currencies [curiousepic] #2538 * TransFirst Express: Don't send address2 without value [nfarve] #2545 +* TransFirst: Fix partial refund [nfarve] #2541 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/trans_first.rb b/lib/active_merchant/billing/gateways/trans_first.rb index cc2c8c084bf..c79d5fab0b2 100644 --- a/lib/active_merchant/billing/gateways/trans_first.rb +++ b/lib/active_merchant/billing/gateways/trans_first.rb @@ -1,4 +1,5 @@ module ActiveMerchant #:nodoc: + module Billing #:nodoc: class TransFirstGateway < Gateway self.test_url = 'https://ws.cert.transfirst.com' @@ -16,7 +17,7 @@ class TransFirstGateway < Gateway ACTIONS = { purchase: "CCSale", purchase_echeck: "ACHDebit", - refund: "CreditCardAutoRefundorVoid", + refund: "CreditCardCredit", refund_echeck: "ACHVoidTransaction", void: "CreditCardAutoRefundorVoid", } @@ -52,6 +53,7 @@ def refund(money, authorization, options={}) transaction_id, payment_type = split_authorization(authorization) add_amount(post, money) add_pair(post, :TransID, transaction_id) + add_pair(post, :RefID, options[:order_id], required: true) commit((payment_type == "check" ? :refund_echeck : :refund), post) end @@ -169,7 +171,6 @@ def parse(data) def commit(action, params) response = parse(ssl_post(url(action), post_data(action, params))) - Response.new( success_from(response), message_from(response), diff --git a/test/remote/gateways/remote_trans_first_test.rb b/test/remote/gateways/remote_trans_first_test.rb index 46e3946ef89..a6036eacf10 100644 --- a/test/remote/gateways/remote_trans_first_test.rb +++ b/test/remote/gateways/remote_trans_first_test.rb @@ -70,14 +70,33 @@ def test_failed_purchase assert_equal 'Insufficient funds', response.message end - def test_successful_refund + def test_successful_void assert purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase - assert refund = @gateway.refund(@amount, purchase.authorization) - assert_success refund + assert void = @gateway.void(purchase.authorization) + assert_success void end + # Refunds can only be successfully run on settled transactions which take 24 hours + # def test_successful_refund + # assert purchase = @gateway.purchase(@amount, @credit_card, @options) + # assert_success purchase + + # assert refund = @gateway.refund(@amount, purchase.authorization) + # assert_equal @amount, refund.params["amount"].to_i*100 + # assert_success refund + # end + + # def test_successful_partial_refund + # assert purchase = @gateway.purchase(@amount, @credit_card, @options) + # assert_success purchase + + # assert refund = @gateway.refund(@amount-1, purchase.authorization) + # assert_equal @amount-1, refund.params["amount"].to_i*100 + # assert_success refund + # end + def test_successful_refund_with_echeck assert purchase = @gateway.purchase(@amount, @check, @options) assert_success purchase diff --git a/test/unit/gateways/trans_first_test.rb b/test/unit/gateways/trans_first_test.rb index c9f10c3f810..2cfd7cc3b72 100644 --- a/test/unit/gateways/trans_first_test.rb +++ b/test/unit/gateways/trans_first_test.rb @@ -68,6 +68,7 @@ def test_successful_refund response = @gateway.refund(@amount, "TransID") assert_success response assert_equal '207686608|creditcard', response.authorization + assert_equal @amount, response.params["amount"].to_i*100 end def test_failed_refund @@ -76,6 +77,20 @@ def test_failed_refund response = @gateway.refund(@amount, "TransID") assert_failure response end + + def test_successful_void + @gateway.stubs(:ssl_post).returns(successful_void_response) + + response = @gateway.void("TransID") + assert_success response + end + + def test_failed_void + @gateway.stubs(:ssl_post).returns(failed_void_response) + + response = @gateway.void("TransID") + assert_failure response + end def test_avs_result @gateway.expects(:ssl_post).returns(successful_purchase_response) @@ -320,4 +335,36 @@ def failed_refund_response XML end + + def successful_void_response + <<-XML + + + 0 + 207616632 + 0 + 123 + 2010-08-09T12:25:00 0001-01-01T00:00:00 + 1.3100 + 012921 + Voided + N + + + XML + end + + def failed_void_response + <<-XML + + + 0 + 0 + 0001-01-01T00:00:00 0001-01-01T00:00:00 + 0 + Canceled + Transaction Is Not Allowed To Void or Refund + + XML + end end From f513e15be05d0c74b6c68fe0dfe401257593a10d Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani Date: Wed, 16 Aug 2017 18:44:50 +0530 Subject: [PATCH 160/677] Checkout V2: Add UAE to country list Closes #2548 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/checkout_v2.rb | 2 +- test/unit/gateways/checkout_v2_test.rb | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 54541f9b839..c2fbbe39820 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * Remove HUF from default non-fractional currencies [curiousepic] #2538 * TransFirst Express: Don't send address2 without value [nfarve] #2545 * TransFirst: Fix partial refund [nfarve] #2541 +* Checkout V2: Add UAE to country list [shasum] #2548 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb index 81a60d95cc1..cf56dbdded1 100644 --- a/lib/active_merchant/billing/gateways/checkout_v2.rb +++ b/lib/active_merchant/billing/gateways/checkout_v2.rb @@ -6,7 +6,7 @@ class CheckoutV2Gateway < Gateway self.live_url = "https://api2.checkout.com/v2" self.test_url = "https://sandbox.checkout.com/api2/v2" - self.supported_countries = ['AD', 'AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GI', 'GL', 'GR', 'HR', 'HU', 'IE', 'IS', 'IL', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SM', 'SK', 'SJ', 'TR', 'VA'] + self.supported_countries = ['AD', 'AE', 'AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GI', 'GL', 'GR', 'HR', 'HU', 'IE', 'IS', 'IL', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SM', 'SK', 'SJ', 'TR', 'VA'] self.default_currency = "USD" self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express, :diners_club] diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb index 2ee60065908..b51d265c5b4 100644 --- a/test/unit/gateways/checkout_v2_test.rb +++ b/test/unit/gateways/checkout_v2_test.rb @@ -149,6 +149,9 @@ def test_invalid_json assert_match %r{Invalid JSON response}, 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 + end private From 92a442ef01b32d49e6a3d44f2f9af50e7294e11e Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 15 Aug 2017 16:15:30 -0400 Subject: [PATCH 161/677] Orbital: Upgrade schema version to 7.1 Also dynamically converts API_VERSION constant to the Content-Type header which actually specifies the version. Closes #2546 Unit: 68 tests, 412 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 18 tests, 121 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/orbital.rb | 4 ++-- test/unit/gateways/orbital_test.rb | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c2fbbe39820..733014713aa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * TransFirst Express: Don't send address2 without value [nfarve] #2545 * TransFirst: Fix partial refund [nfarve] #2541 * Checkout V2: Add UAE to country list [shasum] #2548 +* Orbital: Updgrade schema version to 7.1 [curiousepic] #2546 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index 0c62e1d881d..14ec38a2568 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -30,11 +30,11 @@ module Billing #:nodoc: class OrbitalGateway < Gateway include Empty - API_VERSION = "5.6" + API_VERSION = "7.1" POST_HEADERS = { "MIME-Version" => "1.1", - "Content-Type" => "application/PTI56", + "Content-Type" => "application/PTI#{API_VERSION.gsub(/\./, '')}", "Content-transfer-encoding" => "text", "Request-number" => '1', "Document-type" => "Request", diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index 6d2c2c5877d..634c3ec0ffd 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -759,7 +759,7 @@ def pre_scrubbed opened starting SSL for orbitalvar1.paymentech.net:443... SSL established -<- "POST /authorize HTTP/1.1\r\nContent-Type: application/PTI56\r\nMime-Version: 1.1\r\nContent-Transfer-Encoding: text\r\nRequest-Number: 1\r\nDocument-Type: Request\r\nInterface-Version: Ruby|ActiveMerchant|Proprietary Gateway\r\nContent-Length: 964\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: orbitalvar1.paymentech.net\r\n\r\n" +<- "POST /authorize HTTP/1.1\r\nContent-Type: application/PTI71\r\nMime-Version: 1.1\r\nContent-Transfer-Encoding: text\r\nRequest-Number: 1\r\nDocument-Type: Request\r\nInterface-Version: Ruby|ActiveMerchant|Proprietary Gateway\r\nContent-Length: 964\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: orbitalvar1.paymentech.net\r\n\r\n" <- "\n\n \n T16WAYSACT\n zbp8X1ykGZ\n EC\n AC\n 000001\n 041756\n 001\n 4112344112344113\n 0917\n 840\n 2\n 1\n 123\n K1C2N6\n 456 My Street\n Apt 1\n Ottawa\n ON\n 5555555555\n Longbob Longsen\n CA\n b141cf3ce2a442732e1906\n 100\n \n\n" -> "HTTP/1.1 200 OK\r\n" -> "Date: Thu, 02 Jun 2016 07:04:44 GMT\r\n" @@ -783,7 +783,7 @@ def post_scrubbed opened starting SSL for orbitalvar1.paymentech.net:443... SSL established -<- "POST /authorize HTTP/1.1\r\nContent-Type: application/PTI56\r\nMime-Version: 1.1\r\nContent-Transfer-Encoding: text\r\nRequest-Number: 1\r\nDocument-Type: Request\r\nInterface-Version: Ruby|ActiveMerchant|Proprietary Gateway\r\nContent-Length: 964\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: orbitalvar1.paymentech.net\r\n\r\n" +<- "POST /authorize HTTP/1.1\r\nContent-Type: application/PTI71\r\nMime-Version: 1.1\r\nContent-Transfer-Encoding: text\r\nRequest-Number: 1\r\nDocument-Type: Request\r\nInterface-Version: Ruby|ActiveMerchant|Proprietary Gateway\r\nContent-Length: 964\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: orbitalvar1.paymentech.net\r\n\r\n" <- "\n\n \n [FILTERED]\n [FILTERED]\n EC\n AC\n 000001\n [FILTERED]\n 001\n [FILTERED]\n 0917\n 840\n 2\n 1\n [FILTERED]\n K1C2N6\n 456 My Street\n Apt 1\n Ottawa\n ON\n 5555555555\n Longbob Longsen\n CA\n b141cf3ce2a442732e1906\n 100\n \n\n" -> "HTTP/1.1 200 OK\r\n" -> "Date: Thu, 02 Jun 2016 07:04:44 GMT\r\n" From 97c4a125705ca119a94e014fac558add98dba377 Mon Sep 17 00:00:00 2001 From: Niaja Date: Fri, 11 Aug 2017 15:27:08 -0400 Subject: [PATCH 162/677] CreditCall: Parse more response params Currently we are not parsing the CardDetails from the response message, which is passed on auth and refund transactions. Closes #2543 Loaded suite test/remote/gateways/remote_creditcall_test Started Finished in 45.137631 seconds. 18 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 0.40 tests/s, 1.02 assertions/s Loaded suite test/unit/gateways/creditcall_test Started Finished in 0.099526 seconds. 16 tests, 50 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 160.76 tests/s, 502.38 assertions/s --- CHANGELOG | 1 + .../billing/gateways/creditcall.rb | 18 +++++++++++++++++- test/unit/gateways/creditcall_test.rb | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 733014713aa..17f9fc763c5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * TransFirst: Fix partial refund [nfarve] #2541 * Checkout V2: Add UAE to country list [shasum] #2548 * Orbital: Updgrade schema version to 7.1 [curiousepic] #2546 +* CreditCall: Parse more response params [nfavre] #2543 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/creditcall.rb b/lib/active_merchant/billing/gateways/creditcall.rb index c9ae198bfe4..0b9de2bd4da 100644 --- a/lib/active_merchant/billing/gateways/creditcall.rb +++ b/lib/active_merchant/billing/gateways/creditcall.rb @@ -26,10 +26,16 @@ def purchase(money, payment_method, options={}) r.process { capture(money, r.authorization, options) } end + if multi_response.responses[1].nil? + merged_params = multi_response.primary_response.params + else + merged_params = multi_response.responses[0].params.merge(multi_response.responses[1].params) + end + Response.new( multi_response.primary_response.success?, multi_response.primary_response.message, - multi_response.primary_response.params, + merged_params, authorization: multi_response.responses.first.authorization, test: test? ) @@ -157,6 +163,16 @@ def parse(body) end end + node = xml.xpath("//Response/CardDetails") + node.children.each do |childnode| + if childnode.elements.empty? + response[childnode.name] = childnode.text + else + childnode_to_response(response, childnode) + end + end + + response end diff --git a/test/unit/gateways/creditcall_test.rb b/test/unit/gateways/creditcall_test.rb index 855fda0056d..37856176f67 100644 --- a/test/unit/gateways/creditcall_test.rb +++ b/test/unit/gateways/creditcall_test.rb @@ -147,7 +147,7 @@ def post_scrubbed def successful_purchase_response %( - 0999da90-b342-e511-b302-00505692354f20150814143753201508141837530Unknown + 0999da90-b342-e511-b302-00505692354f20150814143753201508141837530Unknownc2c5fa63-3dd1-da11-8531-01422187e378CtuNPQnryhFt6amPWtp6PLZYXI=341111xxxxx10022012AMEX ) end From 31c0c13b0be955682da1b0f8abf6aaca55aad8ee Mon Sep 17 00:00:00 2001 From: David Perry Date: Wed, 16 Aug 2017 13:07:14 -0400 Subject: [PATCH 163/677] CreditCall: Only allow AVS when specified This disables AVS checking by default, and only sends the AdditionalVerification element if either verify_zip or verify_address flags are sent in options. It also exposes `manual_type` to an option field. These options can help with decline rates. Closes #2549 Remote: 20 tests, 56 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 17 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/creditcall.rb | 20 +++++++++----- .../remote/gateways/remote_creditcall_test.rb | 21 ++++++++++++++- test/unit/gateways/creditcall_test.rb | 26 +++++++++++++++++++ 4 files changed, 61 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 17f9fc763c5..6a9b1242e05 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Checkout V2: Add UAE to country list [shasum] #2548 * Orbital: Updgrade schema version to 7.1 [curiousepic] #2546 * CreditCall: Parse more response params [nfavre] #2543 +* CreditCall: Only allow AVS when specified [curiousepic] #2549 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/creditcall.rb b/lib/active_merchant/billing/gateways/creditcall.rb index 0b9de2bd4da..0ae96856bd3 100644 --- a/lib/active_merchant/billing/gateways/creditcall.rb +++ b/lib/active_merchant/billing/gateways/creditcall.rb @@ -126,17 +126,22 @@ def add_terminal_details(xml, options={}) def add_card_details(xml, payment_method, options={}) xml.CardDetails do - xml.Manual(type: "ecommerce") do + xml.Manual(type: manual_type(options)) do xml.PAN payment_method.number xml.ExpiryDate exp_date(payment_method) xml.CSC payment_method.verification_value unless empty?(payment_method.verification_value) end - if address = options[:billing_address] - xml.AdditionalVerification do - xml.Address address[:address1] - xml.Zip address[:zip] - end + add_additional_verification(xml, options) + end + end + + def add_additional_verification(xml, options) + return unless (options[:verify_zip].to_s == 'true') || (options[:verify_address].to_s == 'true') + if address = options[:billing_address] + xml.AdditionalVerification do + xml.Zip address[:zip] if options[:verify_zip].to_s == 'true' + xml.Address address[:address1] if options[:verify_address].to_s == 'true' end end end @@ -221,6 +226,9 @@ def authorization_from(response) response["CardEaseReference"] end + def manual_type(options) + options[:manual_type] ? options[:manual_type] : "ecommerce" + end end end end diff --git a/test/remote/gateways/remote_creditcall_test.rb b/test/remote/gateways/remote_creditcall_test.rb index abf6c18ff49..fc599ff8b7a 100644 --- a/test/remote/gateways/remote_creditcall_test.rb +++ b/test/remote/gateways/remote_creditcall_test.rb @@ -22,6 +22,8 @@ def test_successful_purchase def test_successful_purchase_sans_options response = @gateway.purchase(@amount, @credit_card) assert_success response + assert_equal response.params['Zip'], 'notchecked' + assert_equal response.params['Address'], 'notchecked' assert_equal 'Succeeded', response.message end @@ -29,7 +31,8 @@ def test_successful_purchase_with_more_options options = { order_id: '1', ip: "127.0.0.1", - email: "joe@example.com" + email: "joe@example.com", + manual_type: "cnp" } response = @gateway.purchase(@amount, @credit_card, options) @@ -50,6 +53,22 @@ def test_successful_authorize assert_equal 'Succeeded', auth.message end + def test_successful_authorize_with_zip_verification + response = @gateway.authorize(@amount, @credit_card, @options.merge(verify_zip: 'true')) + assert_success response + assert_equal response.params['Zip'], 'matched' + assert_equal response.params['Address'], 'notchecked' + assert_equal 'Succeeded', response.message + end + + def test_successful_authorize_with_address_verification + response = @gateway.authorize(@amount, @credit_card, @options.merge(verify_address: 'true')) + assert_success response + assert_equal response.params['Zip'], 'notchecked' + assert_equal response.params['Address'], 'matched' + assert_equal 'Succeeded', response.message + end + def test_successful_authorize_and_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth diff --git a/test/unit/gateways/creditcall_test.rb b/test/unit/gateways/creditcall_test.rb index 37856176f67..e0bf6105673 100644 --- a/test/unit/gateways/creditcall_test.rb +++ b/test/unit/gateways/creditcall_test.rb @@ -126,6 +126,32 @@ def test_verification_value_not_sent end.respond_with(successful_authorize_response) end + def test_options_add_avs_additional_verification_fields + stub_comms do + @gateway.authorize(@amount, @credit_card, @options) + 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| + 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| + 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| + assert_match(/ \n K1C2N6<\/Zip>\n <\/AdditionalVerification>\n/, data) + end.respond_with(successful_authorize_response) + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed From 1f810df2c406779841c0216ffa57c3c5b50ed733 Mon Sep 17 00:00:00 2001 From: Niaja Date: Fri, 11 Aug 2017 15:27:08 -0400 Subject: [PATCH 164/677] CreditCall: Parse additional params from responses Currently we are not parsing the CardDetails from the response message, which is passed on auth and refund transactions. This information is now being passed in the response object as well. Closes #2552 Loaded suite test/remote/gateways/remote_creditcall_test Finished in 45.137631 seconds. 18 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/creditcall_test Finished in 0.099526 seconds. 16 tests, 50 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/creditcall.rb | 54 ++++++++++++++++--- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6a9b1242e05..09d21428caa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * Orbital: Updgrade schema version to 7.1 [curiousepic] #2546 * CreditCall: Parse more response params [nfavre] #2543 * CreditCall: Only allow AVS when specified [curiousepic] #2549 +* CreditCall: Parse additional params from responses [nfarve] #2552 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/creditcall.rb b/lib/active_merchant/billing/gateways/creditcall.rb index 0ae96856bd3..c961f999d85 100644 --- a/lib/active_merchant/billing/gateways/creditcall.rb +++ b/lib/active_merchant/billing/gateways/creditcall.rb @@ -14,6 +14,32 @@ class CreditcallGateway < Gateway self.homepage_url = 'https://www.creditcall.com' self.display_name = 'Creditcall' + + CVV_CODE = { + "matched" => "M", + "notmatched" => "N", + "notchecked" => "P", + "partialmatch" => "N" + } + + AVS_CODE = { + "matched;matched" => "D", + "matched;notchecked" =>"B", + "matched;notmatched" => "A", + "matched;partialmatch" => "A", + "notchecked;matched" => "P", + "notchecked;notchecked" =>"I", + "notchecked;notmatched" => "I", + "notchecked;partialmatch" => "I", + "notmatched;matched" => "W", + "notmatched;notchecked" =>"C", + "notmatched;notmatched" => "C", + "notmatched;partialmatch" => "C", + "partialmatched;matched" => "W", + "partialmatched;notchecked" =>"C", + "partialmatched;notmatched" => "C", + "partialmatched;partialmatch" => "C" + } def initialize(options={}) requires!(options, :terminal_id, :transaction_key) @@ -26,17 +52,16 @@ def purchase(money, payment_method, options={}) r.process { capture(money, r.authorization, options) } end - if multi_response.responses[1].nil? - merged_params = multi_response.primary_response.params - else - merged_params = multi_response.responses[0].params.merge(multi_response.responses[1].params) - end - + merged_params = multi_response.responses.map { |r| r.params }.reduce({}, :merge) + Response.new( multi_response.primary_response.success?, multi_response.primary_response.message, merged_params, authorization: multi_response.responses.first.authorization, + avs_result: AVSResult.new(code: avs_result_code_from(merged_params)), + cvv_result: CVVResult.new(cvv_result_code_from(merged_params)), + error_code: error_result_code_from(merged_params), test: test? ) end @@ -98,6 +123,18 @@ def scrub(transcript) private + def avs_result_code_from(params) + AVS_CODE["#{params['Address']};#{params['Zip']}"] + end + + def cvv_result_code_from(params) + CVV_CODE[params["CSC"]] + end + + def error_result_code_from(params) + params["ErrorCode"] + end + def build_xml_request builder = Nokogiri::XML::Builder.new do |xml| xml.Request(type: "CardEaseXML", version: "1.0.0") do @@ -200,8 +237,9 @@ def commit(parameters) message_from(response), response, authorization: authorization_from(response), - avs_result: AVSResult.new(code: response["some_avs_response_key"]), - cvv_result: CVVResult.new(response["some_cvv_response_key"]), + avs_result: AVSResult.new(code: avs_result_code_from(response)), + cvv_result: CVVResult.new(cvv_result_code_from(response)), + error_code: error_result_code_from(response), test: test? ) end From 1c01c7857a8052eaec76e9df650184858f312f3a Mon Sep 17 00:00:00 2001 From: Niaja Date: Wed, 16 Aug 2017 16:43:53 -0400 Subject: [PATCH 165/677] TransFirst Express: Fix Optional Fields Being Passed Blank Continuation of issue where address2 field being passed as an empty string caused an error. Currently, only address1 and zip are required for AVS. Previous fix to only pass address2 if is present doesn't fix the larger issue that none of the optional fields should be passed blank. Updated previous remote test to not only remove address2 but everything in shipping and billing that is not required. Closes #2550 Loaded suite test/remote/gateways/remote_trans_first_transaction_express_test Started Finished in 25.935593 seconds. 30 tests, 105 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 1.16 tests/s, 4.05 assertions/s Loaded suite test/unit/gateways/trans_first_transaction_express_test Started Finished in 0.104014 seconds. 21 tests, 103 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 201.90 tests/s, 990.25 assertions/s --- CHANGELOG | 1 + .../trans_first_transaction_express.rb | 24 ++++++++++--------- ...te_trans_first_transaction_express_test.rb | 23 +++++++++++++++--- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 09d21428caa..6f714b20f70 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * CreditCall: Parse more response params [nfavre] #2543 * CreditCall: Only allow AVS when specified [curiousepic] #2549 * CreditCall: Parse additional params from responses [nfarve] #2552 +* TransFirst Express: Fix Optional Fields Being Passed Blank [nfarve] #2550 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb index 6f949998034..388ff8b575c 100644 --- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb @@ -537,15 +537,17 @@ def add_contact(doc, fullname, options) doc["v1"].title options[:title] if options[:title] if (billing_address = options[:billing_address]) - doc["v1"].phone do - doc["v1"].type (options[:phone_number_type] || "4") - doc["v1"].nr billing_address[:phone].gsub(/\D/, '') if billing_address[:phone] + if billing_address[:phone] + doc["v1"].phone do + doc["v1"].type (options[:phone_number_type] || "4") + doc["v1"].nr billing_address[:phone].gsub(/\D/, '') + end end - doc["v1"].addrLn1 billing_address[:address1] + doc["v1"].addrLn1 billing_address[:address1] if billing_address[:address1] doc["v1"].addrLn2 billing_address[:address2] if billing_address[:address2] - doc["v1"].city billing_address[:city] - doc["v1"].state billing_address[:state] - doc["v1"].zipCode billing_address[:zip] + doc["v1"].city billing_address[:city] if billing_address[:city] + doc["v1"].state billing_address[:state] if billing_address[:state] + doc["v1"].zipCode billing_address[:zip] if billing_address[:zip] doc["v1"].ctry "US" end @@ -556,11 +558,11 @@ def add_contact(doc, fullname, options) if (shipping_address = options[:shipping_address]) doc["v1"].ship do doc["v1"].fullName fullname - doc["v1"].addrLn1 shipping_address[:address1] + doc["v1"].addrLn1 shipping_address[:address1] if shipping_address[:address1] doc["v1"].addrLn2 shipping_address[:address2] if shipping_address[:address2] - doc["v1"].city shipping_address[:city] - doc["v1"].state shipping_address[:state] - doc["v1"].zipCode shipping_address[:zip] + doc["v1"].city shipping_address[:city] if shipping_address[:city] + doc["v1"].state shipping_address[:state] if shipping_address[:state] + doc["v1"].zipCode shipping_address[:zip] if shipping_address[:zip] doc["v1"].phone shipping_address[:phone].gsub(/\D/, '') if shipping_address[:phone] doc["v1"].email shipping_address[:email] if shipping_address[:email] end diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb index 33c2c4ae5bd..2f4488d9823 100644 --- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb +++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb @@ -46,10 +46,27 @@ def test_successful_purchase assert_equal "CVV matches", response.cvv_result["message"] end - def test_successful_purchase_with_no_address2 + def test_successful_purchase_no_avs options = @options.dup - options[:shipping_address][:address2] = nil - options[:billing_address][:address2] = nil + options[:shipping_address] = nil + options[:billing_address] = nil + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + end + + def test_successful_purchase_with_only_required + # Test the purchase with only the required billing and shipping information + options = @options.dup + options[:shipping_address] = { + address1: "450 Main", + zip: "85284", + } + + options[:billing_address] = { + address1: "450 Main", + zip: "85284", + } + response = @gateway.purchase(@amount, @credit_card, options) assert_success response assert_equal "Succeeded", response.message From 77e6f8aad14a566b0446d683073b9eda29938f4d Mon Sep 17 00:00:00 2001 From: Aengus Bates Date: Thu, 17 Aug 2017 10:38:38 -0700 Subject: [PATCH 166/677] Bambora formerly Beanstream: Change casing on customerIp variable Closes #2544. --- CHANGELOG | 1 + .../billing/gateways/beanstream/beanstream_core.rb | 2 +- test/unit/gateways/beanstream_test.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6f714b20f70..a97940c492d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * CreditCall: Only allow AVS when specified [curiousepic] #2549 * CreditCall: Parse additional params from responses [nfarve] #2552 * TransFirst Express: Fix Optional Fields Being Passed Blank [nfarve] #2550 +* Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index 4739602b447..a94bc858e8e 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -186,7 +186,7 @@ def purchase_action(source) end def add_customer_ip(post, options) - post[:customerIP] = options[:ip] if options[:ip] + post[:customerIp] = options[:ip] if options[:ip] end def void_action(original_transaction_type) diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb index d57e52afb98..bd0595ee3e1 100644 --- a/test/unit/gateways/beanstream_test.rb +++ b/test/unit/gateways/beanstream_test.rb @@ -213,7 +213,7 @@ def test_successful_cancel_recurring def test_ip_is_being_sent @gateway.expects(:ssl_post).with do |url, data| - data =~ /customerIP=123\.123\.123\.123/ + data =~ /customerIp=123\.123\.123\.123/ end.returns(successful_purchase_response) @options[:ip] = "123.123.123.123" From b348fd0d4de130621ac82f6351708337c8ab9bc2 Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 7 Aug 2017 10:51:08 -0400 Subject: [PATCH 167/677] Orbital: Support Network Tokenization Credit Cards Closes #2553 Remote: 22 tests, 137 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 69 tests, 417 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/orbital.rb | 26 +++++++-- test/remote/gateways/remote_orbital_test.rb | 53 +++++++++++++++++++ test/unit/gateways/orbital_test.rb | 11 ++++ 4 files changed, 87 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a97940c492d..4bad7eda2e0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * CreditCall: Parse additional params from responses [nfarve] #2552 * TransFirst Express: Fix Optional Fields Being Passed Blank [nfarve] #2550 * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 +* Orbital: Support Network Tokenization Credit Cards [curiousepic] #2553 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index 14ec38a2568..f9f3db25de7 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -191,7 +191,7 @@ def initialize(options = {}) # A – Authorization request def authorize(money, creditcard, options = {}) - order = build_new_order_xml(AUTH_ONLY, money, options) do |xml| + order = build_new_order_xml(AUTH_ONLY, money, creditcard, options) do |xml| add_creditcard(xml, creditcard, options[:currency]) add_address(xml, creditcard, options) if @options[:customer_profiles] @@ -211,7 +211,7 @@ def verify(creditcard, options = {}) # AC – Authorization and Capture def purchase(money, creditcard, options = {}) - order = build_new_order_xml(AUTH_AND_CAPTURE, money, options) do |xml| + order = build_new_order_xml(AUTH_AND_CAPTURE, money, creditcard, options) do |xml| add_creditcard(xml, creditcard, options[:currency]) add_address(xml, creditcard, options) if @options[:customer_profiles] @@ -229,7 +229,7 @@ def capture(money, authorization, options = {}) # R – Refund request def refund(money, authorization, options = {}) - order = build_new_order_xml(REFUND, money, options.merge(:authorization => authorization)) do |xml| + order = build_new_order_xml(REFUND, money, nil, options.merge(:authorization => authorization)) do |xml| add_refund(xml, options[:currency]) xml.tag! :CustomerRefNum, options[:customer_ref_num] if @options[:customer_profiles] && options[:profile_txn] end @@ -463,6 +463,16 @@ def add_creditcard(xml, creditcard, currency=nil) end end + def add_cdpt_eci_and_xid(xml, creditcard) + xml.tag! :AuthenticationECIInd, creditcard.eci + xml.tag! :XID, creditcard.transaction_id if creditcard.transaction_id + end + + def add_cdpt_payment_cryptogram(xml, creditcard) + xml.tag! :DPANInd, 'Y' + xml.tag! :DigitalTokenCryptogram, creditcard.payment_cryptogram + end + def add_refund(xml, currency=nil) xml.tag! :AccountNum, nil @@ -566,7 +576,7 @@ def ip_authentication? @options[:ip_authentication] == true end - def build_new_order_xml(action, money, parameters = {}) + def build_new_order_xml(action, money, creditcard, parameters = {}) requires!(parameters, :order_id) xml = xml_envelope xml.tag! :Request do @@ -589,6 +599,10 @@ def build_new_order_xml(action, money, parameters = {}) yield xml if block_given? + if creditcard.is_a?(NetworkTokenizationCreditCard) + add_cdpt_eci_and_xid(xml, creditcard) + end + xml.tag! :OrderID, format_order_id(parameters[:order_id]) xml.tag! :Amount, amount(money) xml.tag! :Comments, parameters[:comments] if parameters[:comments] @@ -598,6 +612,10 @@ def build_new_order_xml(action, money, parameters = {}) # CustomerAni, AVSPhoneType and AVSDestPhoneType could be added here. + if creditcard.is_a?(NetworkTokenizationCreditCard) + add_cdpt_payment_cryptogram(xml, creditcard) + end + if parameters[:soft_descriptors].is_a?(OrbitalSoftDescriptors) add_soft_descriptors(xml, parameters[:soft_descriptors]) elsif parameters[:soft_descriptors].is_a?(Hash) diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb index bdccb58492f..c5329b1be40 100644 --- a/test/remote/gateways/remote_orbital_test.rb +++ b/test/remote/gateways/remote_orbital_test.rb @@ -77,6 +77,59 @@ def test_successful_purchase_with_level_2_data assert_equal 'Approved', response.message end + def test_successful_purchase_with_visa_network_tokenization_credit_card_with_eci + network_card = network_tokenization_credit_card('4788250000028291', + payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + transaction_id: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + verification_value: '111', + brand: 'visa', + eci: '5' + ) + assert response = @gateway.purchase(3000, network_card, @options) + assert_success response + assert_equal 'Approved', response.message + assert_false response.authorization.blank? + end + + def test_successful_purchase_with_master_card_network_tokenization_credit_card + network_card = network_tokenization_credit_card('4788250000028291', + payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + transaction_id: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + verification_value: '111', + brand: 'master' + ) + assert response = @gateway.purchase(3000, network_card, @options) + assert_success response + assert_equal 'Approved', response.message + assert_false response.authorization.blank? + end + + def test_successful_purchase_with_american_express_network_tokenization_credit_card + network_card = network_tokenization_credit_card('4788250000028291', + payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + transaction_id: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + verification_value: '111', + brand: 'american_express' + ) + assert response = @gateway.purchase(3000, network_card, @options) + assert_success response + assert_equal 'Approved', response.message + assert_false response.authorization.blank? + end + + def test_successful_purchase_with_discover_network_tokenization_credit_card + network_card = network_tokenization_credit_card('4788250000028291', + payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + transaction_id: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + verification_value: '111', + brand: 'discover' + ) + assert response = @gateway.purchase(3000, network_card, @options) + assert_success response + assert_equal 'Approved', response.message + assert_false response.authorization.blank? + end + # Amounts of x.01 will fail def test_unsuccessful_purchase assert response = @gateway.purchase(101, @declined_card, @options) diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index 634c3ec0ffd..c029f71dcf9 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -62,6 +62,17 @@ def test_level_2_data end.respond_with(successful_purchase_response) end + def test_network_tokenization_credit_card_data + stub_comms do + @gateway.purchase(50, network_tokenization_credit_card(nil, eci: '5', transaction_id: 'BwABB4JRdgAAAAAAiFF2AAAAAAA='), @options) + end.check_request do |endpoint, data, headers| + assert_match %{5}, data + assert_match %{Y}, data + assert_match %{DigitalTokenCryptogram}, data + assert_match %{XID}, data + end.respond_with(successful_purchase_response) + end + def test_currency_exponents stub_comms do @gateway.purchase(50, credit_card, :order_id => '1') From 585a2c8044b291c3e115dea00afb0f70f55a9dfe Mon Sep 17 00:00:00 2001 From: David Santoso Date: Mon, 21 Aug 2017 09:21:58 -0400 Subject: [PATCH 168/677] MercadoPago: Small tweaks to building requests After working with MercadoPago engineering for a bit there were a couple tweaks that needed to be made in order for the integration to process smoothly: - use "binary_mode" to avoid a notification URL for transaction states - send American Express cards as "amex" instead of "american_express" - send shipping address if available I should note that I also noticed that the `additional_info` field was getting overwritten each time a new field was getting added so that needed to be fixed to be merged instead. Closes #2555 --- CHANGELOG | 1 + .../billing/gateways/mercado_pago.rb | 42 +++++++++++++++---- .../gateways/remote_mercado_pago_test.rb | 1 + test/unit/gateways/mercado_pago_test.rb | 17 ++++++++ 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4bad7eda2e0..db0114a297b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * TransFirst Express: Fix Optional Fields Being Passed Blank [nfarve] #2550 * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 * Orbital: Support Network Tokenization Credit Cards [curiousepic] #2553 +* MercadoPago: Small tweaks to building requests [davidsantoso] #2555 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index da2cbbe3741..5b8b178cd6f 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -91,6 +91,7 @@ def purchase_request(money, payment, options = {}) add_additional_data(post, options) add_customer_data(post, payment, options) add_address(post, options) + post[:binary_mode] = true post end @@ -107,6 +108,7 @@ def add_additional_data(post, options) } add_address(post, options) + add_shipping_address(post, options) end def add_customer_data(post, payment, options) @@ -119,21 +121,47 @@ def add_customer_data(post, payment, options) def add_address(post, options) if address = (options[:billing_address] || options[:address]) - street_number = address[:address1].split(" ").first - street_name = address[:address1].split(" ")[1..-1].join(" ") - post[:additional_info] = { + post[:additional_info].merge!({ payer: { address: { zip_code: address[:zip], - street_number: street_number, - street_name: street_name, + street_number: split_street_address(address[:address1]).first, + street_name: split_street_address(address[:address1]).last } } - } + }) end end + def add_shipping_address(post, options) + if address = options[:shipping_address] + + post[:additional_info].merge!({ + shipments: { + receiver_address: { + zip_code: address[:zip], + street_number: split_street_address(address[:address1]).first, + street_name: split_street_address(address[:address1]).last, + apartment: address[:address2] + } + } + }) + end + end + + def split_street_address(address1) + street_number = address1.split(" ").first + + if street_name = address1.split(" ")[1..-1] + street_name = street_name.join(" ") + else + nil + end + + [street_number, street_name] + end + def add_invoice(post, money, options) post[:transaction_amount] = amount(money).to_f post[:description] = options[:description] @@ -147,7 +175,7 @@ def add_invoice(post, money, options) def add_payment(post, options) post[:token] = options[:card_token] - post[:payment_method_id] = options[:card_brand] + post[:payment_method_id] = options[:card_brand] == "american_express" ? "amex" : options[:card_brand] end def parse(body) diff --git a/test/remote/gateways/remote_mercado_pago_test.rb b/test/remote/gateways/remote_mercado_pago_test.rb index 4d60297fa66..a8b0171f65c 100644 --- a/test/remote/gateways/remote_mercado_pago_test.rb +++ b/test/remote/gateways/remote_mercado_pago_test.rb @@ -9,6 +9,7 @@ def setup @declined_card = credit_card('4000300011112220') @options = { billing_address: address, + shipping_address: address, email: "user+br@example.com", description: 'Store Purchase' } diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb index 860e9b7d0a0..0febc27339b 100644 --- a/test/unit/gateways/mercado_pago_test.rb +++ b/test/unit/gateways/mercado_pago_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class MercadoPagoTest < Test::Unit::TestCase + include CommStub + def setup @gateway = MercadoPagoGateway.new(access_token: 'access_token') @credit_card = credit_card @@ -147,6 +149,21 @@ def test_scrub assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed end + def test_sends_american_express_as_amex + credit_card = credit_card('378282246310005', brand: 'american_express') + + response = stub_comms do + @gateway.purchase(@amount, credit_card, @options) + end.check_request do |endpoint, data, headers| + if data =~ /"payment_method_id"/ + assert_match(%r(amex), data) + end + end.respond_with(successful_purchase_response) + + assert_success response + assert_equal '4141491|1.0', response.authorization + end + private def pre_scrubbed From 0c15cf7a5b1efae6b9dd4a8eee7c9ff7d78a8e1c Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Tue, 22 Aug 2017 12:30:18 -0400 Subject: [PATCH 169/677] Release version 1.71.0 --- CHANGELOG | 24 +++++++++++++----------- lib/active_merchant/version.rb | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index db0114a297b..8de3e03d3dc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,22 +1,24 @@ = ActiveMerchant CHANGELOG == HEAD -* Stripe: Add support for statement_address parameters for EMV transactions [malcolm-mergulhao] #2524 -* Vantiv (Litle): Pass 3DS fields [curiousepic] #2536 + +== Version 1.71.0 (August 22, 2017) +* Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 * Checkout V2: Add localized_amount support to add_invoice function [nicolas-maalouf-cko] #2452 -* Checkout V2: Fix success response code validation [nicolas-maalouf-cko] #2452 -* Remove HUF from default non-fractional currencies [curiousepic] #2538 -* TransFirst Express: Don't send address2 without value [nfarve] #2545 -* TransFirst: Fix partial refund [nfarve] #2541 * Checkout V2: Add UAE to country list [shasum] #2548 -* Orbital: Updgrade schema version to 7.1 [curiousepic] #2546 -* CreditCall: Parse more response params [nfavre] #2543 +* Checkout V2: Fix success response code validation [nicolas-maalouf-cko] #2452 * CreditCall: Only allow AVS when specified [curiousepic] #2549 * CreditCall: Parse additional params from responses [nfarve] #2552 -* TransFirst Express: Fix Optional Fields Being Passed Blank [nfarve] #2550 -* Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 -* Orbital: Support Network Tokenization Credit Cards [curiousepic] #2553 +* CreditCall: Parse more response params [nfavre] #2543 * MercadoPago: Small tweaks to building requests [davidsantoso] #2555 +* Orbital: Support Network Tokenization Credit Cards [curiousepic] #2553 +* Orbital: Updgrade schema version to 7.1 [curiousepic] #2546 +* Remove HUF from default non-fractional currencies [curiousepic] #2538 +* Stripe: Add support for statement_address parameters for EMV transactions [malcolm-mergulhao] #2524 +* TransFirst Express: Don't send address2 without value [nfarve] #2545 +* TransFirst Express: Fix Optional Fields Being Passed Blank [nfarve] #2550 +* TransFirst: Fix partial refund [nfarve] #2541 +* Vantiv (Litle): Pass 3DS fields [curiousepic] #2536 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 8b51ca942a0..a357fecf6b1 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.70.0" + VERSION = "1.71.0" end From 69a867f64bd0a3a88fe18052771b419ad2103c5e Mon Sep 17 00:00:00 2001 From: Niaja Date: Tue, 22 Aug 2017 14:39:57 -0400 Subject: [PATCH 170/677] SafeCharge: Update to Version 4.1.0 Updating SafeCharge to API Version 4.1.0. Includes adding the optional passing of two additional parameters for auth transactions. Closes #2556 Loaded suite test/remote/gateways/remote_safe_charge_test 18 tests, 45 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/safe_charge_test 16 tests, 52 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/safe_charge.rb | 4 ++- .../gateways/remote_safe_charge_test.rb | 4 ++- test/unit/gateways/safe_charge_test.rb | 28 +++++++++---------- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8de3e03d3dc..3b7a20ee453 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* SafeCharge: Update to Version 4.1.0 [nfarve] #2556 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index ae19fd11bc4..e7e8bd74088 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -13,7 +13,7 @@ class SafeChargeGateway < Gateway self.homepage_url = 'https://www.safecharge.com' self.display_name = 'SafeCharge' - VERSION = '4.0.4' + VERSION = '4.1.0' def initialize(options={}) requires!(options, :client_login_id, :client_password) @@ -118,6 +118,8 @@ def add_transaction_data(trans_type, post, money, options) post[:sg_Version] = VERSION post[:sg_ClientUniqueID] = options[:order_id] if options[:order_id] post[:sg_UserID] = options[:user_id] if options[:user_id] + post[:sg_AuthType] = options[:auth_type] if options[:auth_type] + post[:sg_ExpectedFulfillmentCount] = options[:expected_fulfillment_count] if options[:expected_fulfillment_count] end def add_payment(post, payment) diff --git a/test/remote/gateways/remote_safe_charge_test.rb b/test/remote/gateways/remote_safe_charge_test.rb index b176719de48..d51b0ba550f 100644 --- a/test/remote/gateways/remote_safe_charge_test.rb +++ b/test/remote/gateways/remote_safe_charge_test.rb @@ -26,7 +26,9 @@ def test_successful_purchase_with_more_options order_id: '1', ip: "127.0.0.1", email: "joe@example.com", - user_id: '123' + user_id: '123', + auth_type: '2', + expected_fulfillment_count: '3' } response = @gateway.purchase(@amount, @credit_card, options) diff --git a/test/unit/gateways/safe_charge_test.rb b/test/unit/gateways/safe_charge_test.rb index 264f5bd98a2..ce86ab35e72 100644 --- a/test/unit/gateways/safe_charge_test.rb +++ b/test/unit/gateways/safe_charge_test.rb @@ -167,7 +167,7 @@ def pre_scrubbed starting SSL for process.sandbox.safecharge.com:443... SSL established <- "POST /service.asmx/Process 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: process.sandbox.safecharge.com\r\nContent-Length: 249\r\n\r\n" -<- "sg_TransType=Sale&sg_Currency=USD&sg_Amount=1.00&sg_ClientLoginID=SpreedlyTestTRX&sg_ClientPassword=5Jp5xKmgqY&sg_ResponseFormat=4&sg_Version=4.0.4&sg_NameOnCard=Longbob+Longsen&sg_CardNumber=4000100011112224&sg_ExpMonth=09&sg_ExpYear=18&sg_CVV2=123" +<- "sg_TransType=Sale&sg_Currency=USD&sg_Amount=1.00&sg_ClientLoginID=SpreedlyTestTRX&sg_ClientPassword=5Jp5xKmgqY&sg_ResponseFormat=4&sg_Version=4.1.0&sg_NameOnCard=Longbob+Longsen&sg_CardNumber=4000100011112224&sg_ExpMonth=09&sg_ExpYear=18&sg_CVV2=123" -> "HTTP/1.1 200 OK\r\n" -> "Cache-Control: private, max-age=0\r\n" -> "Content-Type: text/xml; charset=utf-8\r\n" @@ -195,7 +195,7 @@ def post_scrubbed starting SSL for process.sandbox.safecharge.com:443... SSL established <- "POST /service.asmx/Process 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: process.sandbox.safecharge.com\r\nContent-Length: 249\r\n\r\n" -<- "sg_TransType=Sale&sg_Currency=USD&sg_Amount=1.00&sg_ClientLoginID=SpreedlyTestTRX&sg_ClientPassword=[FILTERED]&sg_ResponseFormat=4&sg_Version=4.0.4&sg_NameOnCard=Longbob+Longsen&sg_CardNumber=[FILTERED]&sg_ExpMonth=09&sg_ExpYear=18&sg_CVV2=[FILTERED]" +<- "sg_TransType=Sale&sg_Currency=USD&sg_Amount=1.00&sg_ClientLoginID=SpreedlyTestTRX&sg_ClientPassword=[FILTERED]&sg_ResponseFormat=4&sg_Version=4.1.0&sg_NameOnCard=Longbob+Longsen&sg_CardNumber=[FILTERED]&sg_ExpMonth=09&sg_ExpYear=18&sg_CVV2=[FILTERED]" -> "HTTP/1.1 200 OK\r\n" -> "Cache-Control: private, max-age=0\r\n" -> "Content-Type: text/xml; charset=utf-8\r\n" @@ -218,73 +218,73 @@ def post_scrubbed def successful_purchase_response %( - 4.0.4SpreedlyTestTRX101508189567APPROVED11195100ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAdAAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAFUAbQBYAFIAMwA=19University First Federal Credit UnionusSuiMHP60FrDKfyaJs47hqqrR/JU=0CreditAccept + 4.1.0SpreedlyTestTRX101508189567APPROVED11195100ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAdAAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAFUAbQBYAFIAMwA=19University First Federal Credit UnionusSuiMHP60FrDKfyaJs47hqqrR/JU=0CreditAccept ) end def failed_purchase_response %( - 4.0.4SpreedlyTestTRX101508189637DECLINEDDecline-10bwBVAEYAUgBuAGcAbABSAFYASgB5AEAAMgA/ACsAUQBIAC4AbgB1AHgAdABAAE8ARgBRAGoAbwApACQAWwBKAFwATwAxAEcAMwBZAG4AdwBmACgAMwA=19GyueFkuQqW+UL38d57fuA5/RqfQ=0Accept + 4.1.0SpreedlyTestTRX101508189637DECLINEDDecline-10bwBVAEYAUgBuAGcAbABSAFYASgB5AEAAMgA/ACsAUQBIAC4AbgB1AHgAdABAAE8ARgBRAGoAbwApACQAWwBKAFwATwAxAEcAMwBZAG4AdwBmACgAMwA=19GyueFkuQqW+UL38d57fuA5/RqfQ=0Accept ) end def successful_authorize_response %( - 4.0.4SpreedlyTestTRX101508189855APPROVED11153400MQBVAG4ASABkAEgAagB3AEsAbgAtACoAWgAzAFwAWwBNAF8ATQBUAD0AegBQAGwAQAAtAD0AXAB5AFkALwBtAFAALABaAHoAOgBFAEwAUAA1AFUAMwA=19University First Federal Credit UnionusSuiMHP60FrDKfyaJs47hqqrR/JU=0CreditAccept + 4.1.0SpreedlyTestTRX101508189855APPROVED11153400MQBVAG4ASABkAEgAagB3AEsAbgAtACoAWgAzAFwAWwBNAF8ATQBUAD0AegBQAGwAQAAtAD0AXAB5AFkALwBtAFAALABaAHoAOgBFAEwAUAA1AFUAMwA=19University First Federal Credit UnionusSuiMHP60FrDKfyaJs47hqqrR/JU=0CreditAccept ) end def failed_authorize_response %( - 4.0.4SpreedlyTestTRX101508190604DECLINEDDecline-10MQBLAG4AMgAwADMAOABmAFYANABbAGYAcwA+ACMAVgBXAD0AUQBQAEoANQBrAHQAWABsAFEAeABQAF8ARwA6ACsALgBHADUALwBTAEAARwBIACgAMwA=19GyueFkuQqW+UL38d57fuA5/RqfQ=0Accept + 4.1.0SpreedlyTestTRX101508190604DECLINEDDecline-10MQBLAG4AMgAwADMAOABmAFYANABbAGYAcwA+ACMAVgBXAD0AUQBQAEoANQBrAHQAWABsAFEAeABQAF8ARwA6ACsALgBHADUALwBTAEAARwBIACgAMwA=19GyueFkuQqW+UL38d57fuA5/RqfQ=0Accept ) end def successful_capture_response %( - 4.0.4SpreedlyTestTRX101508190200APPROVED11130100RwA1AGQAMgAwAEkAWABKADkAcABjAHYAQQA4AC8AZAAlAHMAfABoADEALAA8ADQAewB8ADsAewBiADsANQBoACwAeAA/AGQAXQAjAFEAYgBVAHIAMwA=19University First Federal Credit UnionusSuiMHP60FrDKfyaJs47hqqrR/JU=0Credit + 4.1.0SpreedlyTestTRX101508190200APPROVED11130100RwA1AGQAMgAwAEkAWABKADkAcABjAHYAQQA4AC8AZAAlAHMAfABoADEALAA8ADQAewB8ADsAewBiADsANQBoACwAeAA/AGQAXQAjAFEAYgBVAHIAMwA=19University First Federal Credit UnionusSuiMHP60FrDKfyaJs47hqqrR/JU=0Credit ) end def failed_capture_response %( - 4.0.4SpreedlyTestTRX101508190627ERRORTransaction must contain a Card/Token/Account-11001163-12jmj7l5rSw0yVb/vlWAYkK/YBwk=0 + 4.1.0SpreedlyTestTRX101508190627ERRORTransaction must contain a Card/Token/Account-11001163-12jmj7l5rSw0yVb/vlWAYkK/YBwk=0 ) end def successful_refund_response %( - 4.0.4SpreedlyTestTRX101508440432APPROVED11120700MQBVAG4AUgAwAFcAaABxAGoASABdAE4ALABvAGYANAAmAE8AcQA/AEgAawAkAHYASQBKAFMAegBiACoAcQBBAC8AVABlAD4AKwBkAC0AKwA8ACcAMwA=19SuiMHP60FrDKfyaJs47hqqrR/JU=0 + 4.1.0SpreedlyTestTRX101508440432APPROVED11120700MQBVAG4AUgAwAFcAaABxAGoASABdAE4ALABvAGYANAAmAE8AcQA/AEgAawAkAHYASQBKAFMAegBiACoAcQBBAC8AVABlAD4AKwBkAC0AKwA8ACcAMwA=19SuiMHP60FrDKfyaJs47hqqrR/JU=0 ) end def failed_refund_response %( - 4.0.4SpreedlyTestTRX101508208595ERRORTransaction must contain a Card/Token/Account-11001163-12jmj7l5rSw0yVb/vlWAYkK/YBwk=0 + 4.1.0SpreedlyTestTRX101508208595ERRORTransaction must contain a Card/Token/Account-11001163-12jmj7l5rSw0yVb/vlWAYkK/YBwk=0 ) end def successful_credit_response %( - 4.0.4SpreedlyTestTRX101508440421APPROVED11164400bwA1ADAAcAAwAHUAVABJAFYAUQAlAGcAfAB8AFQAbwBkAHAAbwAjAG4AaABDAHsAUABdACoAYwBaAEsAMQBHAEUAMQBuAHQAdwBXAFUAVABZACMAMwA=19SuiMHP60FrDKfyaJs47hqqrR/JU=0 + 4.1.0SpreedlyTestTRX101508440421APPROVED11164400bwA1ADAAcAAwAHUAVABJAFYAUQAlAGcAfAB8AFQAbwBkAHAAbwAjAG4AaABDAHsAUABdACoAYwBaAEsAMQBHAEUAMQBuAHQAdwBXAFUAVABZACMAMwA=19SuiMHP60FrDKfyaJs47hqqrR/JU=0 ) end def failed_credit_response %( - 4.0.4SpreedlyTestTRX101508440424DECLINEDDecline-10RwBVAGQAZgAwAFMAbABwAEwASgBNAFMAXABJAGAAeAAsAHsALAA7ADUAOgBUAEMAZwBNAG4AbABQAC4AQAAvAC0APwBpAEAAWQBoACMAdwBvAGEAMwA=19GyueFkuQqW+UL38d57fuA5/RqfQ=0 + 4.1.0SpreedlyTestTRX101508440424DECLINEDDecline-10RwBVAGQAZgAwAFMAbABwAEwASgBNAFMAXABJAGAAeAAsAHsALAA7ADUAOgBUAEMAZwBNAG4AbABQAC4AQAAvAC0APwBpAEAAWQBoACMAdwBvAGEAMwA=19GyueFkuQqW+UL38d57fuA5/RqfQ=0 ) end def successful_void_response %( - 4.0.4SpreedlyTestTRX101508208625APPROVED11117100ZQBpAFAAZgBuAHEATgBUAHcASAAwADUAcwBHAHQAVQBLAHAAbgB6AGwAJAA1AEMAfAB2AGYASwBrAHEAeQBOAEwAOwBZAGIAewB4AGwAYwBUAE0AMwA=19University First Federal Credit UnionusSuiMHP60FrDKfyaJs47hqqrR/JU=0Credit + 4.1.0SpreedlyTestTRX101508208625APPROVED11117100ZQBpAFAAZgBuAHEATgBUAHcASAAwADUAcwBHAHQAVQBLAHAAbgB6AGwAJAA1AEMAfAB2AGYASwBrAHEAeQBOAEwAOwBZAGIAewB4AGwAYwBUAE0AMwA=19University First Federal Credit UnionusSuiMHP60FrDKfyaJs47hqqrR/JU=0Credit ) end def failed_void_response %( - 4.0.4SpreedlyTestTRX101508208633ERRORInvalid Amount-11001201-12jmj7l5rSw0yVb/vlWAYkK/YBwk=0 + 4.1.0SpreedlyTestTRX101508208633ERRORInvalid Amount-11001201-12jmj7l5rSw0yVb/vlWAYkK/YBwk=0 ) end end From 45a145a568d3a556cc5b850f8e9dd865756b32ec Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 18 Jul 2017 10:51:40 -0400 Subject: [PATCH 171/677] Qvalent: Support general credit Also defaults IP address as it is seemingly required for all transactions. Closes #2558 Remote: 19 tests, 63 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 17 tests, 81 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/qvalent.rb | 14 +++++++++- test/remote/gateways/remote_qvalent_test.rb | 12 ++++++++ test/unit/gateways/qvalent_test.rb | 28 +++++++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 3b7a20ee453..9a577b03fab 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * SafeCharge: Update to Version 4.1.0 [nfarve] #2556 +* Qvalent: Support general credit [curiousepic] #2558 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/qvalent.rb b/lib/active_merchant/billing/gateways/qvalent.rb index 20c48d8b183..43e3ec9c09f 100644 --- a/lib/active_merchant/billing/gateways/qvalent.rb +++ b/lib/active_merchant/billing/gateways/qvalent.rb @@ -61,6 +61,18 @@ def refund(amount, authorization, options={}) commit("refund", post) end + # Credit requires the merchant account to be enabled for "Adhoc Refunds" + def credit(amount, payment_method, options={}) + post = {} + add_invoice(post, amount, options) + add_order_number(post, options) + add_payment_method(post, payment_method) + add_customer_data(post, options) + add_soft_descriptors(post, options) + + commit("refund", post) + end + def void(authorization, options={}) post = {} add_reference(post, authorization, options) @@ -136,7 +148,7 @@ def add_order_number(post, options) end def add_customer_data(post, options) - post["order.ipAddress"] = options[:ip] + post["order.ipAddress"] = options[:ip] || "127.0.0.1" post["order.xid"] = options[:xid] if options[:xid] post["order.cavv"] = options[:cavv] if options[:cavv] end diff --git a/test/remote/gateways/remote_qvalent_test.rb b/test/remote/gateways/remote_qvalent_test.rb index 614d60fb2ea..875bc081ee8 100644 --- a/test/remote/gateways/remote_qvalent_test.rb +++ b/test/remote/gateways/remote_qvalent_test.rb @@ -154,6 +154,18 @@ def test_failed_refund assert_equal Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code end + def test_successful_credit + response = @gateway.credit(@amount, @credit_card, @options) + assert_success response + assert_equal "Succeeded", response.message + end + + def test_failed_credit + response = @gateway.credit(@amount, @declined_card, @options) + assert_failure response + assert_equal "Invalid card number (no such number)", response.message + end + def test_successful_store response = @gateway.store(@credit_card, @options) assert_success response diff --git a/test/unit/gateways/qvalent_test.rb b/test/unit/gateways/qvalent_test.rb index bbb46a9178f..d16d01c7bff 100644 --- a/test/unit/gateways/qvalent_test.rb +++ b/test/unit/gateways/qvalent_test.rb @@ -105,6 +105,22 @@ def test_failed_refund assert_failure response end + def test_successful_credit + response = stub_comms do + @gateway.credit(@amount, @credit_card) + end.respond_with(successful_credit_response) + + assert_success response + end + + def test_failed_credit + response = stub_comms do + @gateway.credit(@amount, @credit_card) + end.respond_with(failed_credit_response) + + assert_failure response + end + def test_successful_void response = stub_comms do @gateway.void("auth") @@ -236,6 +252,18 @@ def failed_refund_response ) end + def successful_credit_response + %( + response.summaryCode=0\r\nresponse.responseCode=08\r\nresponse.text=Honour with identification\r\nresponse.referenceNo=732344591\r\nresponse.orderNumber=f365d21f7f5a1a5fe0eb994f144858e2\r\nresponse.RRN=732344591 \r\nresponse.settlementDate=20170817\r\nresponse.transactionDate=17-AUG-2017 01:19:34\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.previousTxn=0\r\nresponse.traceCode=799500\r\nresponse.end\r\n + ) + end + + def failed_credit_response + %( + response.summaryCode=1\r\nresponse.responseCode=14\r\nresponse.text=Invalid card number (no such number)\r\nresponse.referenceNo=732344705\r\nresponse.orderNumber=3baab91d5642a34292375a8932cde85f\r\nresponse.settlementDate=20170817\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.previousTxn=0\r\nresponse.end\r\n + ) + end + def successful_store_response %( response.summaryCode=0\r\nresponse.responseCode=00\r\nresponse.text=Approved or completed successfully\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.accountAlias=400010...224\r\nresponse.preregistrationCode=RSL-20887450\r\nresponse.customerReferenceNumber=RSL-20887450\r\nresponse.previousTxn=0\r\nresponse.end\r\n From 011fe593375fda036d92422a76e4c82b967bb429 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Thu, 24 Aug 2017 10:52:28 -0400 Subject: [PATCH 172/677] DataCash: Enable refunding recurring transactions In order to refund a recurring/continuous authority transaction, the `capturemethod` field must but submitted with the value of "ecomm" or "cnp". See DataCash docs for more details. https://datacash.custhelp.com/app/answers/detail/a_id/792/~/refunding-recurring-transactions Note that this commit also fixes stale card details for transactions using a Solo card. Sending any value for the CV2 results in a rejected response with an invalid CV2 message so we're not longer going to send it. Closes #2560 --- CHANGELOG | 1 + .../billing/gateways/data_cash.rb | 2 ++ test/remote/gateways/remote_data_cash_test.rb | 20 +++++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9a577b03fab..3accef98ba3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * SafeCharge: Update to Version 4.1.0 [nfarve] #2556 * Qvalent: Support general credit [curiousepic] #2558 +* DataCash: Enable refunding recurring transactions [davidsantoso] #2560 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb index bfc05f71959..64404b10912 100644 --- a/lib/active_merchant/billing/gateways/data_cash.rb +++ b/lib/active_merchant/billing/gateways/data_cash.rb @@ -168,6 +168,7 @@ def build_transaction_refund_request(money, authorization) unless money.nil? xml.tag! :TxnDetails do xml.tag! :amount, amount(money) + xml.tag! :capturemethod, 'ecomm' end end end @@ -188,6 +189,7 @@ def build_credit_request(money, credit_card, options) xml.tag! :TxnDetails do xml.tag! :merchantreference, format_reference_number(options[:order_id]) xml.tag! :amount, amount(money) + xml.tag! :capturemethod, 'ecomm' end end end diff --git a/test/remote/gateways/remote_data_cash_test.rb b/test/remote/gateways/remote_data_cash_test.rb index f6fffda0131..e14abdcebf4 100644 --- a/test/remote/gateways/remote_data_cash_test.rb +++ b/test/remote/gateways/remote_data_cash_test.rb @@ -44,8 +44,7 @@ def setup :brand => :solo, :issue_number => 5, :start_month => 12, - :start_year => 2006, - :verification_value => 444 + :start_year => 2006 ) @address = { @@ -303,6 +302,23 @@ def test_fail_to_refund_purchase_which_is_already_refunded assert_equal '1.98 > remaining funds 0.00', second_refund.message end + def test_successful_refund_of_a_repeat_payment + @params[:set_up_continuous_authority] = true + response = @gateway.purchase(@amount, @mastercard, @params) + assert_success response + assert !response.authorization.to_s.split(';')[2].blank? + assert response.test? + + # Make second payment on the continuous authorization that was set up in the first purchase + second_order_params = { :order_id => generate_unique_id } + purchase = @gateway.purchase(201, response.authorization, second_order_params) + assert_success purchase + + # Refund payment that was made via the continuous authorization payment above + refund = @gateway.refund(201, purchase.authorization) + assert_success refund + end + def test_order_id_that_is_too_short @params[:order_id] = @params[:order_id].first(5) response = @gateway.purchase(@amount, @mastercard, @params) From b792d6fcfc09702ae56c0c9b22f7174eb9199876 Mon Sep 17 00:00:00 2001 From: Niaja Date: Wed, 23 Aug 2017 17:13:09 -0400 Subject: [PATCH 173/677] Ebank: Adds Brazil Specific Parameters Birth_date and payment.responsible parameters are required for customers in Brazil. Adding these fields to the gateway. Closes #2559 Loaded suite test/remote/gateways/remote_ebanx_test 16 tests, 44 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/ebanx_test 14 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/ebanx.rb | 12 +++++++++++- test/remote/gateways/remote_ebanx_test.rb | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3accef98ba3..98b9668cf10 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * SafeCharge: Update to Version 4.1.0 [nfarve] #2556 * Qvalent: Support general credit [curiousepic] #2558 * DataCash: Enable refunding recurring transactions [davidsantoso] #2560 +* Ebanx: Adds Brazil Specific Parameters [nfarve] #2559 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb index 8d00800b335..6b958bb5580 100644 --- a/lib/active_merchant/billing/gateways/ebanx.rb +++ b/lib/active_merchant/billing/gateways/ebanx.rb @@ -48,7 +48,7 @@ def purchase(money, payment, options={}) add_customer_data(post, payment, options) add_payment(post, payment) add_address(post, options) - + add_customer_responsible_person(post, payment, options) if post[:payment][:country] == 'BR' commit(:purchase, post) end @@ -60,6 +60,7 @@ def authorize(money, payment, options={}) add_customer_data(post, payment, options) add_payment(post, payment) add_address(post, options) + add_customer_responsible_person(post, payment, options) if post[:payment][:country] == 'BR' post[:payment][:creditcard][:auto_capture] = false commit(:authorize, post) @@ -129,6 +130,14 @@ def add_customer_data(post, payment, options) post[:payment][:name] = payment.name post[:payment][:email] = options[:email] || "unspecified@example.com" post[:payment][:document] = options[:document] + post[:payment][:birth_date] = options[:birth_date] if options[:birth_date] + end + + def add_customer_responsible_person(post, payment, options) + post[:payment][:responsible] = {} + post[:payment][:responsible][:name] = payment.name + post[:payment][:responsible][:document] = options[:document] + post[:payment][:responsible][:birth_date] = options[:birth_date] if options[:birth_date] end def add_address(post, options) @@ -147,6 +156,7 @@ def add_invoice(post, money, options) post[:payment][:amount_total] = amount(money) post[:payment][:currency_code] = (options[:currency] || currency(money)) post[:payment][:merchant_payment_code] = options[:order_id] + post[:payment][:instalments] = options[:instalments] || 1 end def add_payment(post, payment) diff --git a/test/remote/gateways/remote_ebanx_test.rb b/test/remote/gateways/remote_ebanx_test.rb index fdf599bfd75..976e512dbb4 100644 --- a/test/remote/gateways/remote_ebanx_test.rb +++ b/test/remote/gateways/remote_ebanx_test.rb @@ -31,7 +31,8 @@ def test_successful_purchase_with_more_options options = @options.merge({ order_id: generate_unique_id, ip: "127.0.0.1", - email: "joe@example.com" + email: "joe@example.com", + birth_date: "10/11/1980" }) response = @gateway.purchase(@amount, @credit_card, options) From b04eb6e87d2e446c1146f4c20172a82ff70731f7 Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Fri, 25 Aug 2017 18:06:28 -0400 Subject: [PATCH 174/677] Authorize.net: Restore default state value for non-US addresses (#2563) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed in https://github.com/activemerchant/active_merchant/pull/2496 Turns out (surprise!) Authorize.net docs have some contradictory advice. http://developer.authorize.net/api/reference/#payment-transactions-charge-a-credit-card For `billTo.state` says: > State of customer’s billing address. Required only when using a European Payment Processor. --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/authorize_net.rb | 2 +- test/unit/gateways/authorize_net_test.rb | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 98b9668cf10..ad23a6dc7a6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Qvalent: Support general credit [curiousepic] #2558 * DataCash: Enable refunding recurring transactions [davidsantoso] #2560 * Ebanx: Adds Brazil Specific Parameters [nfarve] #2559 +* Authorize.net: Restore default state value for non-US addresses [jasonwebster] #2563 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index d4b9868ad14..1f30f4bc7cc 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -719,7 +719,7 @@ def state_from(address, options) if ["US", "CA"].include?(address[:country]) address[:state] || 'NC' else - address[:state] + address[:state] || 'n/a' end end diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 64b3f82dcb3..b628881e8d1 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -653,7 +653,7 @@ def test_address_with_empty_billing_address parse(data) do |doc| assert_equal "", doc.at_xpath("//billTo/address").content, data assert_equal "", doc.at_xpath("//billTo/city").content, data - assert_equal "", doc.at_xpath("//billTo/state").content, data + assert_equal "n/a", doc.at_xpath("//billTo/state").content, data assert_equal "", doc.at_xpath("//billTo/zip").content, data assert_equal "", doc.at_xpath("//billTo/country").content, data end @@ -691,7 +691,7 @@ def test_address_outsite_north_america @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', country: 'DE'}) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "", doc.at_xpath("//billTo/state").content, data + assert_equal "n/a", doc.at_xpath("//billTo/state").content, data assert_equal "164 Waverley Street", doc.at_xpath("//billTo/address").content, data assert_equal "DE", doc.at_xpath("//billTo/country").content, data end @@ -703,7 +703,7 @@ def test_address_outsite_north_america_with_address2_present @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', address2: 'Apt 1234', country: 'DE'}) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "", doc.at_xpath("//billTo/state").content, data + assert_equal "n/a", doc.at_xpath("//billTo/state").content, data assert_equal "164 Waverley Street Apt 1234", doc.at_xpath("//billTo/address").content, data assert_equal "DE", doc.at_xpath("//billTo/country").content, data end From 60d0c14f5b18bd0b63139589373d1958afbc8d52 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Mon, 28 Aug 2017 13:45:09 -0400 Subject: [PATCH 175/677] MercadoPago: Additional tweaks for transaction requests After speaking quite a bit with MercadoPago support, there were still a number of things that are how requests should be formatted but aren't explicitly called out in their docs. For example, certain field that are required. This particular commit contains the following tweaks: - Adds fields for the payment identification type and number - Combines address1 and address2 to the street_name field - Maps the order_id field to the external_reference field --- CHANGELOG | 1 + .../billing/gateways/mercado_pago.rb | 20 +++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ad23a6dc7a6..ed6a43210a1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * DataCash: Enable refunding recurring transactions [davidsantoso] #2560 * Ebanx: Adds Brazil Specific Parameters [nfarve] #2559 * Authorize.net: Restore default state value for non-US addresses [jasonwebster] #2563 +* MercadoPago: Additional tweaks for transaction requests [davidsantoso] == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index 5b8b178cd6f..65006b65a4f 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -80,7 +80,13 @@ def card_token_request(money, payment, options = {}) post[:security_code] = payment.verification_value post[:expiration_month] = payment.month post[:expiration_year] = payment.year - post[:cardholder] = { name: payment.name } + post[:cardholder] = { + name: payment.name, + identification: { + type: options[:cardholder_identification_type], + number: options[:cardholder_identification_number] + } + } post end @@ -126,8 +132,7 @@ def add_address(post, options) payer: { address: { zip_code: address[:zip], - street_number: split_street_address(address[:address1]).first, - street_name: split_street_address(address[:address1]).last + street_name: "#{address[:address1]} #{address[:address2]}" } } }) @@ -141,9 +146,7 @@ def add_shipping_address(post, options) shipments: { receiver_address: { zip_code: address[:zip], - street_number: split_street_address(address[:address1]).first, - street_name: split_street_address(address[:address1]).last, - apartment: address[:address2] + street_name: "#{address[:address1]} #{address[:address2]}" } } }) @@ -167,10 +170,7 @@ def add_invoice(post, money, options) post[:description] = options[:description] post[:installments] = options[:installments] ? options[:installments].to_i : 1 post[:statement_descriptor] = options[:statement_descriptor] if options[:statement_descriptor] - post[:order] = { - type: options[:order_type] || "mercadopago", - id: options[:order_id] || generate_integer_only_order_id - } + post[:external_reference] = options[:order_id] || generate_integer_only_order_id end def add_payment(post, options) From e0b35e9f0bde807944d78041c9f232b87da1694d Mon Sep 17 00:00:00 2001 From: David Santoso Date: Thu, 31 Aug 2017 10:24:57 -0400 Subject: [PATCH 176/677] Braintree Blue: Add eci_indicator field for Apple Pay The eci_indicator field was previously only supported for Android Pay, however it has recently been added to Apple Pay as well. https://github.com/braintree/braintree_ruby/commit/fb4032d004ea8ad51e521796b01adf1895af6bf5 Closes #2565 --- CHANGELOG | 1 + Gemfile | 2 +- lib/active_merchant/billing/gateways/braintree_blue.rb | 3 ++- test/unit/gateways/braintree_blue_test.rb | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ed6a43210a1..baa83ce6b7e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * Ebanx: Adds Brazil Specific Parameters [nfarve] #2559 * Authorize.net: Restore default state value for non-US addresses [jasonwebster] #2563 * MercadoPago: Additional tweaks for transaction requests [davidsantoso] +* Braintree Blue: Add eci_indicator field for Apple Pay [davidsantoso] #2565 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/Gemfile b/Gemfile index 7c62a122f4e..81f68d6a75e 100644 --- a/Gemfile +++ b/Gemfile @@ -5,5 +5,5 @@ gem 'jruby-openssl', :platforms => :jruby group :test, :remote_test do # gateway-specific dependencies, keeping these gems out of the gemspec - gem 'braintree', '>= 2.50.0' + gem 'braintree', '>= 2.78.0' end diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 10752e71e1b..5bdff081d6a 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -582,7 +582,8 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, "0"), :expiration_year => credit_card_or_vault_id.year.to_s, :cardholder_name => credit_card_or_vault_id.name, - :cryptogram => credit_card_or_vault_id.payment_cryptogram + :cryptogram => credit_card_or_vault_id.payment_cryptogram, + :eci_indicator => credit_card_or_vault_id.eci } elsif credit_card_or_vault_id.source == :android_pay parameters[:android_pay_card] = { diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index cfc9c64ca90..f65e3c847e6 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -606,7 +606,8 @@ def test_apple_pay_card :expiration_month => '09', :expiration_year => (Time.now.year + 1).to_s, :cardholder_name => 'Longbob Longsen', - :cryptogram => '111111111100cryptogram' + :cryptogram => '111111111100cryptogram', + :eci_indicator => '05' } ). returns(braintree_result(:id => "transaction_id")) From f4620fe2dc46e77f882ca1aeefcf3cda745f510e Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Mon, 28 Aug 2017 17:51:02 -0400 Subject: [PATCH 177/677] Braintree: Send phone in options hash Adds phone parameter to customer details, adds one specific test, and updates other relevant unit and remote tests. Also updates failing remote test `test_successful_authorize_with_merchant_account_id`. Instead of comparing sent versus received `merchant_account_id`, it now asserts the correct braintree status. Closes #2564 Unit Tests: 48 tests, 121 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote Tests: 60 tests, 349 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/braintree_blue.rb | 14 +++++++-- .../gateways/remote_braintree_blue_test.rb | 29 +++++++++++++++---- test/unit/gateways/braintree_blue_test.rb | 15 ++++++++-- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index baa83ce6b7e..64a4b6c1f29 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,7 @@ * TransFirst Express: Fix Optional Fields Being Passed Blank [nfarve] #2550 * TransFirst: Fix partial refund [nfarve] #2541 * Vantiv (Litle): Pass 3DS fields [curiousepic] #2536 +* Braintree Blue: Add phone to options [deedeelavinder] #2564 == Version 1.70.0 (August 4, 2017) * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 5bdff081d6a..7985ad6b9a9 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -158,6 +158,8 @@ def update(vault_id, creditcard, options = {}) :first_name => creditcard.first_name, :last_name => creditcard.last_name, :email => scrub_email(options[:email]), + :phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] && + options[:billing_address][:phone]), :credit_card => credit_card_params ) Response.new(result.success?, message_from_result(result), @@ -228,6 +230,8 @@ def add_customer_with_credit_card(creditcard, options) :first_name => creditcard.first_name, :last_name => creditcard.last_name, :email => scrub_email(options[:email]), + :phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] && + options[:billing_address][:phone]), :id => options[:customer], }.merge credit_card_params result = @braintree_gateway.customer.create(merge_credit_card_options(parameters, options)) @@ -312,7 +316,7 @@ def map_address(address) :region => address[:state], :postal_code => scrub_zip(address[:zip]), } - if(address[:country] || address[:country_code_alpha2]) + if (address[:country] || address[:country_code_alpha2]) mapped[:country_code_alpha2] = (address[:country] || address[:country_code_alpha2]) elsif address[:country_name] mapped[:country_name] = address[:country_name] @@ -451,6 +455,7 @@ def extract_refund_args(args) def customer_hash(customer, include_credit_cards=false) hash = { "email" => customer.email, + "phone" => customer.phone, "first_name" => customer.first_name, "last_name" => customer.last_name, "id" => customer.id @@ -492,7 +497,8 @@ def transaction_hash(result) customer_details = { "id" => transaction.customer_details.id, - "email" => transaction.customer_details.email + "email" => transaction.customer_details.email, + "phone" => transaction.customer_details.phone, } billing_details = { @@ -541,7 +547,9 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) :order_id => options[:order_id], :customer => { :id => options[:store] == true ? "" : options[:store], - :email => scrub_email(options[:email]) + :email => scrub_email(options[:email]), + :phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] && + options[:billing_address][:phone]) }, :options => { :store_in_vault => options[:store] ? true : false, diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index 17b70fda99b..fc97f9ee6bc 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -265,6 +265,20 @@ def test_successful_purchase_with_email assert_equal 'customer@example.com', transaction["customer_details"]["email"] end + def test_successful_purchase_with_phone + assert response = @gateway.purchase(@amount, @credit_card, :phone => "123-345-5678") + assert_success response + transaction = response.params["braintree_transaction"] + assert_equal '123-345-5678', transaction["customer_details"]["phone"] + end + + def test_successful_purchase_with_phone_from_address + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + transaction = response.params["braintree_transaction"] + assert_equal '(555)555-5555', transaction["customer_details"]["phone"] + end + def test_purchase_with_store_using_random_customer_id assert response = @gateway.purchase( @amount, credit_card('5105105105105100'), @options.merge(:store => true) @@ -294,7 +308,8 @@ def test_purchase_using_specified_payment_method_token :first_name => 'Old First', :last_name => 'Old Last', :month => 9, :year => 2012 ), - :email => "old@example.com" + :email => "old@example.com", + :phone => "321-654-0987" ) payment_method_token = response.params["braintree_customer"]["credit_cards"][0]["token"] assert response = @gateway.purchase( @@ -507,13 +522,15 @@ def test_successful_update :first_name => 'Old First', :last_name => 'Old Last', :month => 9, :year => 2012 ), - :email => "old@example.com" + :email => "old@example.com", + :phone => "321-654-0987" ) assert_success response assert_equal 'OK', response.message customer_vault_id = response.params["customer_vault_id"] assert_match(/\A\d+\z/, customer_vault_id) assert_equal "old@example.com", response.params["braintree_customer"]["email"] + assert_equal "321-654-0987", response.params["braintree_customer"]["phone"] assert_equal "Old First", response.params["braintree_customer"]["first_name"] assert_equal "Old Last", response.params["braintree_customer"]["last_name"] assert_equal "411111", response.params["braintree_customer"]["credit_cards"][0]["bin"] @@ -527,10 +544,12 @@ def test_successful_update :first_name => 'New First', :last_name => 'New Last', :month => 10, :year => 2014 ), - :email => "new@example.com" + :email => "new@example.com", + :phone => "987-765-5432" ) assert_success response assert_equal "new@example.com", response.params["braintree_customer"]["email"] + assert_equal "987-765-5432", response.params["braintree_customer"]["phone"] assert_equal "New First", response.params["braintree_customer"]["first_name"] assert_equal "New Last", response.params["braintree_customer"]["last_name"] assert_equal "510510", response.params["braintree_customer"]["credit_cards"][0]["bin"] @@ -540,7 +559,7 @@ def test_successful_update end def test_failed_customer_update - assert response = @gateway.store(credit_card('4111111111111111'), :email => "email@example.com") + assert response = @gateway.store(credit_card('4111111111111111'), :email => "email@example.com", :phone => "321-654-0987") assert_success response assert_equal 'OK', response.message assert customer_vault_id = response.params["customer_vault_id"] @@ -621,7 +640,7 @@ def test_successful_authorize_with_merchant_account_id assert response = @gateway.authorize(@amount, @credit_card, :merchant_account_id => fixtures(:braintree_blue)[:merchant_account_id]) assert_success response, "You must specify a valid :merchant_account_id key in your fixtures.yml for this to pass." assert_equal '1000 Approved', response.message - assert_equal fixtures(:braintree_blue)[:merchant_account_id], response.params["braintree_transaction"]["merchant_account_id"] + assert_equal 'authorized', response.params["braintree_transaction"]["status"] end def test_authorize_with_descriptor diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index f65e3c847e6..bd9ad5d99f3 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -162,6 +162,7 @@ def test_verification_merchant_account_id_exists_when_verify_card_and_merchant_a customer = stub( :credit_cards => [stub_everything], :email => 'email', + :phone => '321-654-0987', :first_name => 'John', :last_name => 'Smith' ) @@ -185,6 +186,7 @@ def test_merchant_account_id_can_be_set_by_options customer = stub( :credit_cards => [stub_everything], :email => 'email', + :phone => '321-654-0987', :first_name => 'John', :last_name => 'Smith' ) @@ -201,6 +203,7 @@ 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' ) @@ -222,6 +225,7 @@ def test_passes_email customer = stub( :credit_cards => [stub_everything], :email => "bob@example.com", + :phone => '321-654-0987', :first_name => 'John', :last_name => 'Smith', id: "123" @@ -240,6 +244,7 @@ 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" @@ -258,6 +263,7 @@ 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' ) @@ -278,6 +284,7 @@ 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' } @@ -306,6 +313,7 @@ def test_store_with_billing_address_options def test_store_with_credit_card_token customer = stub( :email => 'email', + :phone => '321-654-0987', :first_name => 'John', :last_name => 'Smith' ) @@ -329,6 +337,7 @@ 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] @@ -598,7 +607,8 @@ def test_apple_pay_card with( :amount => '1.00', :order_id => '1', - :customer => {:id => nil, :email => nil, :first_name => 'Longbob', :last_name => 'Longsen'}, + :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 => { @@ -628,7 +638,8 @@ def test_android_pay_card with( :amount => '1.00', :order_id => '1', - :customer => {:id => nil, :email => nil, :first_name => 'Longbob', :last_name => 'Longsen'}, + :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 => { From faf5cbf406062fc3a2d5e5065fb8687bc09e1d9d Mon Sep 17 00:00:00 2001 From: Niaja Date: Fri, 1 Sep 2017 14:33:48 -0400 Subject: [PATCH 178/677] Conekta: Pull required details from billing address Some transactions were failing due to missing phone field in the details element. This change reduces these failures by pulling phone and customer name from the billing address if they are not present as top-level options. Closes #2568 Loaded suite test/unit/gateways/conekta_test 11 tests, 61 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_conekta_test 13 tests, 51 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/conekta.rb | 5 ++--- test/fixtures.yml | 2 +- test/remote/gateways/remote_conekta_test.rb | 15 ++++++++++++--- test/unit/gateways/conekta_test.rb | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 64a4b6c1f29..245eafd7caa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * Authorize.net: Restore default state value for non-US addresses [jasonwebster] #2563 * MercadoPago: Additional tweaks for transaction requests [davidsantoso] * Braintree Blue: Add eci_indicator field for Apple Pay [davidsantoso] #2565 +* Conekta: Pull required details from billing address [nfarve] #2568 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/conekta.rb b/lib/active_merchant/billing/gateways/conekta.rb index ce073519eda..7ca02a4930f 100644 --- a/lib/active_merchant/billing/gateways/conekta.rb +++ b/lib/active_merchant/billing/gateways/conekta.rb @@ -82,15 +82,14 @@ def add_order(post, money, options) def add_details_data(post, options) details = {} - details[:name] = options[:customer] if options[:customer] + details[:name] = options[:customer] || options[:billing_address][:name] details[:email] = options[:email] if options[:email] - details[:phone] = options[:phone] if options[:phone] + details[:phone] = options[:phone] || options[:billing_address][:phone] post[:device_fingerprint] = options[:device_fingerprint] if options[:device_fingerprint] details[:ip] = options[:ip] if options[:ip] add_billing_address(details, options) add_line_items(details, options) add_shipment(details, options) - post[:details] = details end diff --git a/test/fixtures.yml b/test/fixtures.yml index 8f64da8a5cd..190524486ba 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -196,7 +196,7 @@ commercegate: card_number: "XXXXXXXXXXXXXXXX" conekta: - key: key_eYvWV7gSDkNYXsmr + key: key_6FTbuwqhYs6zvyyeL3PySg # Working credentials, no need to replace creditcall: diff --git a/test/remote/gateways/remote_conekta_test.rb b/test/remote/gateways/remote_conekta_test.rb index 10206246124..30bd7d50167 100644 --- a/test/remote/gateways/remote_conekta_test.rb +++ b/test/remote/gateways/remote_conekta_test.rb @@ -36,10 +36,19 @@ def setup name: "Mario Reyes", phone: "12345678", }, - carrier: "Estafeta" + carrier: "Estafeta", + email: "bob@something.com", + line_items: [{ + name: "Box of Cohiba S1s", + description: "Imported From Mex.", + unit_price: 20000, + quantity: 1, + sku: "7500244909", + type: "food" + }] } end - + def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response @@ -132,7 +141,7 @@ def test_successful_purchase_passing_more_details }, line_items: [ { - rname: "Box of Cohiba S1s", + name: "Box of Cohiba S1s", description: "Imported From Mex.", unit_price: 20000, quantity: 1, diff --git a/test/unit/gateways/conekta_test.rb b/test/unit/gateways/conekta_test.rb index e8e04eedd59..c959c214722 100644 --- a/test/unit/gateways/conekta_test.rb +++ b/test/unit/gateways/conekta_test.rb @@ -34,7 +34,7 @@ def setup :city => "Guerrero", :country => "Mexico", :zip => "5555", - :name => "Mario Reyes", + :customer => "Mario Reyes", :phone => "12345678", :carrier => "Estafeta" } From 15607f6ac9b2da99a0214062d2e753be1359c981 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Mon, 4 Sep 2017 14:52:56 -0400 Subject: [PATCH 179/677] MercadoPago: Default to alphanumeric order_id The previously mapped field for order_id only accepted numeric values. However MercadoPago has since communicated that it would be better to use the `external_reference` field for a merchant's unique transaction identifier and that field will accept letters and numbers as a value. This updates the default to use letters and numbers so the chance of using the same order_id twice (which will cause a transaction to fail) is much lower. --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/mercado_pago.rb | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 245eafd7caa..937b88a3b5a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * MercadoPago: Additional tweaks for transaction requests [davidsantoso] * Braintree Blue: Add eci_indicator field for Apple Pay [davidsantoso] #2565 * Conekta: Pull required details from billing address [nfarve] #2568 +* MercadoPago: Default to alphanumeric order_id [davidsantoso] == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index 65006b65a4f..519c8ffeaf2 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -170,7 +170,7 @@ def add_invoice(post, money, options) post[:description] = options[:description] post[:installments] = options[:installments] ? options[:installments].to_i : 1 post[:statement_descriptor] = options[:statement_descriptor] if options[:statement_descriptor] - post[:external_reference] = options[:order_id] || generate_integer_only_order_id + post[:external_reference] = options[:order_id] || SecureRandom.hex(16) end def add_payment(post, options) @@ -248,10 +248,6 @@ def handle_response(response) raise ResponseError.new(response) end end - - def generate_integer_only_order_id - Time.now.to_i + rand(0..1000) - end end end end From 71466eee7144d906c8df41459aa814ad8fa896b8 Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 5 Sep 2017 10:07:44 -0400 Subject: [PATCH 180/677] Conekta: Add guard clause for details fallbacks Fix the changes in commit f4620fe Closes #2573 Remote: 14 tests, 54 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit 11 tests, 61 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/conekta.rb | 6 +++--- test/remote/gateways/remote_conekta_test.rb | 10 ++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 937b88a3b5a..d6d787cf111 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * Braintree Blue: Add eci_indicator field for Apple Pay [davidsantoso] #2565 * Conekta: Pull required details from billing address [nfarve] #2568 * MercadoPago: Default to alphanumeric order_id [davidsantoso] +* Conekta: Add guard clause for details fallbacks [curiousepic] #2573 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/conekta.rb b/lib/active_merchant/billing/gateways/conekta.rb index 7ca02a4930f..669edc313c2 100644 --- a/lib/active_merchant/billing/gateways/conekta.rb +++ b/lib/active_merchant/billing/gateways/conekta.rb @@ -82,15 +82,15 @@ def add_order(post, money, options) def add_details_data(post, options) details = {} - details[:name] = options[:customer] || options[:billing_address][:name] + details[:name] = options[:customer] || (options[:billing_address][:name] if options[:billing_address]) + details[:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address]) details[:email] = options[:email] if options[:email] - details[:phone] = options[:phone] || options[:billing_address][:phone] - post[:device_fingerprint] = options[:device_fingerprint] if options[:device_fingerprint] details[:ip] = options[:ip] if options[:ip] add_billing_address(details, options) add_line_items(details, options) add_shipment(details, options) post[:details] = details + post[:device_fingerprint] = options[:device_fingerprint] if options[:device_fingerprint] end def add_shipment(post, options) diff --git a/test/remote/gateways/remote_conekta_test.rb b/test/remote/gateways/remote_conekta_test.rb index 30bd7d50167..5e30e2582f6 100644 --- a/test/remote/gateways/remote_conekta_test.rb +++ b/test/remote/gateways/remote_conekta_test.rb @@ -36,7 +36,7 @@ def setup name: "Mario Reyes", phone: "12345678", }, - carrier: "Estafeta", + carrier: "Estafeta", email: "bob@something.com", line_items: [{ name: "Box of Cohiba S1s", @@ -48,7 +48,7 @@ def setup }] } end - + def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response @@ -166,6 +166,12 @@ def test_successful_purchase_passing_more_details assert_equal "Guerrero", response.params['details']['billing_address']['city'] end + def test_failed_purchase_with_no_details + assert response = @gateway.purchase(@amount, @credit_card, {}) + assert_failure response + assert_equal "Falta el correo del comprador.", response.message + end + def test_invalid_key gateway = ConektaGateway.new(key: 'invalid_token') assert response = gateway.purchase(@amount, @credit_card, @options) From 7aed7147e7ea14ce06af06d4ac2b0ef27c738fd5 Mon Sep 17 00:00:00 2001 From: David Perry Date: Thu, 31 Aug 2017 16:34:56 -0400 Subject: [PATCH 181/677] WePay: Don't default API version header WePay has restricted compatibility for the version specified in the request header, to equal to or one ahead of the version set in WePay's Dashboard for that merchant account. This means that letting the adapter default the version header to a certain version (likely one or more version behind current) has greater potential to break integration than allowing WePay's API to assume the version set in the dashboard for that account, which occurs if the header is absent. api_version can still be sent in options and will override the dashboard setting, but be advised that this will only work for one version ahead of what is set in the dashboard. I have updated the version in the dashboard for the test account in Fixtures to the current version, so these tests are run against that version. Closes #2567 Remote: 23 tests, 39 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 20 tests, 74 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/wepay.rb | 11 ++--------- test/remote/gateways/remote_wepay_test.rb | 7 +++++++ test/unit/gateways/wepay_test.rb | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d6d787cf111..4d7568dda6a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Conekta: Pull required details from billing address [nfarve] #2568 * MercadoPago: Default to alphanumeric order_id [davidsantoso] * Conekta: Add guard clause for details fallbacks [curiousepic] #2573 +* WePay: Don't default API version header [curiousepic] #2567 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/wepay.rb b/lib/active_merchant/billing/gateways/wepay.rb index 6b86c5efd7f..a408fd04fa1 100644 --- a/lib/active_merchant/billing/gateways/wepay.rb +++ b/lib/active_merchant/billing/gateways/wepay.rb @@ -10,8 +10,6 @@ class WepayGateway < Gateway self.default_currency = 'USD' self.display_name = 'WePay' - API_VERSION = "2017-02-01" - def initialize(options = {}) requires!(options, :client_id, :account_id, :access_token) super(options) @@ -229,19 +227,14 @@ def headers(options) headers = { "Content-Type" => "application/json", "User-Agent" => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}", - "Authorization" => "Bearer #{@options[:access_token]}", - "Api-Version" => api_version(options) + "Authorization" => "Bearer #{@options[:access_token]}" } - + headers["Api-Version"] = options[:version] if options[:version] headers["Client-IP"] = options[:ip] if options[:ip] headers["WePay-Risk-Token"] = options[:risk_token] if options[:risk_token] headers end - - def api_version(options) - options[:version] || API_VERSION - end end end end diff --git a/test/remote/gateways/remote_wepay_test.rb b/test/remote/gateways/remote_wepay_test.rb index 26b87584c66..f14c3288181 100644 --- a/test/remote/gateways/remote_wepay_test.rb +++ b/test/remote/gateways/remote_wepay_test.rb @@ -143,6 +143,13 @@ def test_authorize_and_void assert_success void end + # Version sent here will need to match or be one ahead of the version set in the test account's dashboard + def test_successful_purchase_with_version + response = @gateway.purchase(@amount, @credit_card, @options.merge(version: '2017-05-31')) + assert_success response + assert_equal 'Success', response.message + end + def test_invalid_login gateway = WepayGateway.new( client_id: 12515, diff --git a/test/unit/gateways/wepay_test.rb b/test/unit/gateways/wepay_test.rb index 734e8ac7906..b63ce1b70d0 100644 --- a/test/unit/gateways/wepay_test.rb +++ b/test/unit/gateways/wepay_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class WepayTest < Test::Unit::TestCase + include CommStub + def setup @gateway = WepayGateway.new( client_id: 'client_id', @@ -147,6 +149,22 @@ def test_invalid_json_response assert_match(/Invalid JSON response received from WePay/, response.message) end + def test_no_version_by_default + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_no_match(/Api-Version/, headers.to_s) + end.respond_with(successful_authorize_response) + end + + def test_version_override + stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(version: '2017-05-31')) + end.check_request do |endpoint, data, headers| + assert_match(/"Api-Version\"=>\"2017-05-31\"/, headers.to_s) + end.respond_with(successful_authorize_response) + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed From 5b16964e5cd6a21882e44cc2a329103bd9064728 Mon Sep 17 00:00:00 2001 From: David Perry Date: Fri, 25 Aug 2017 14:55:22 -0400 Subject: [PATCH 182/677] PayU Latam: Pass unique buyer fields and country requirements Buyer data can be separate from the Payer's (tied to the payment method). This change allows options to be passed for a unique buyer, and adding the buyer element no longer conditions only on the presence of a shipping address. Also adds fields that were missing but are required for Brazil, Colombia, and Mexico, and allows passing paymentCountry as an option. Closes #2570 Unrelated Capture and Void remote tests still failing Remote: 18 tests, 47 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 88.8889% passed Unit: 22 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/payu_latam.rb | 98 ++++++------ .../remote/gateways/remote_payu_latam_test.rb | 118 ++++++++++++++- test/unit/gateways/payu_latam_test.rb | 143 ++++++++++++++++++ 4 files changed, 308 insertions(+), 52 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4d7568dda6a..3b6c94a0931 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * MercadoPago: Default to alphanumeric order_id [davidsantoso] * Conekta: Add guard clause for details fallbacks [curiousepic] #2573 * WePay: Don't default API version header [curiousepic] #2567 +* PayU Latam: Pass unique buyer fields and country requirements [curiousepic] #2570 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index 0f029fbfa1f..e7a386786f8 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -122,7 +122,7 @@ def auth_or_sale(post, transaction_type, amount, payment_method, options) add_invoice(post, amount, options) add_signature(post) add_payment_method(post, payment_method, options) - add_payer(post, options) + add_payer(post, payment_method, options) add_extra_parameters(post, options) end @@ -138,6 +138,7 @@ def add_credentials(post, command) def add_transaction_elements(post, type, options) transaction = {} + transaction[:paymentCountry] = options[:payment_country] || (options[:billing_address][:country] if options[:billing_address]) transaction[:type] = type transaction[:ipAddress] = options[:ip] if options[:ip] transaction[:userAgent] = options[:user_agent] if options[:user_agent] @@ -152,28 +153,59 @@ def add_order(post, options) order[:referenceCode] = options[:order_id] || generate_unique_id order[:description] = options[:description] || 'unspecified' order[:language] = 'en' + order[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address] post[:transaction][:order] = order end + def add_payer(post, payment_method, options) + address = options[:billing_address] + payer = {} + payer[:fullName] = payment_method.name.strip + payer[:contactPhone] = address[:phone] if (address && address[:phone]) + payer[:dniNumber] = options[:dni_number] if options[:dni_number] + payer[:dniType] = options[:dni_type] if options[:dni_type] + payer[:emailAddress] = options[:email] if options[:email] + payer[:birthdate] = options[:birth_date] if options[:birth_date] && options[:payment_country] == 'MX' + payer[:billingAddress] = billing_address_fields(options) + post[:transaction][:payer] = payer + end + + def billing_address_fields(options) + return unless address = options[:billing_address] + billing_address = {} + billing_address[:street1] = address[:address1] + billing_address[:street2] = address[:address2] + billing_address[:city] = address[:city] + billing_address[:state] = address[:state] + billing_address[:country] = address[:country] + billing_address[:postalCode] = address[:zip] if options[:payment_country] == 'MX' + billing_address[:phone] = address[:phone] + billing_address + end + def add_buyer(post, options) - if address = options[:shipping_address] - buyer = {} - buyer[:fullName] = address[:name] - buyer[:dniNumber] = options[:dni_number] if options[:dni_number] - buyer[:dniType] = options[:dni_type] if options[:dni_type] - buyer[:emailAddress] = options[:email] if options[:email] - buyer[:contactPhone] = address[:phone] - shipping_address = {} - shipping_address[:street1] = address[:address1] - shipping_address[:street2] = address[:address2] - shipping_address[:city] = address[:city] - shipping_address[:state] = address[:state] - shipping_address[:country] = address[:country] - shipping_address[:postalCode] = address[:zip] - shipping_address[:phone] = address[:phone] - buyer[:shippingAddress] = shipping_address - post[:transaction][:order][:buyer] = buyer - end + buyer = {} + buyer[:fullName] = options[:buyer_name] if options[:buyer_name] + buyer[:dniNumber] = options[:buyer_dni_number] if options[:buyer_dni_number] + buyer[:dniType] = options[:buyer_dni_type] if options[:buyer_dni_type] + buyer[:cnpj] = options[:buyer_cnpj] if options[:buyer_cnpj] && options[:payment_country] == 'BR' + buyer[:emailAddress] = options[:buyer_email] if options[:buyer_email] + buyer[:contactPhone] = options[:shipping_address][:phone] if options[:shipping_address] + buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address] + post[:transaction][:order][:buyer] = buyer + end + + def shipping_address_fields(options) + return unless address = options[:shipping_address] + shipping_address = {} + shipping_address[:street1] = address[:address1] + shipping_address[:street2] = address[:address2] + shipping_address[:city] = address[:city] + shipping_address[:state] = address[:state] + shipping_address[:country] = address[:country] + shipping_address[:postalCode] = address[:zip] + shipping_address[:phone] = address[:phone] + shipping_address end def add_invoice(post, money, options) @@ -191,8 +223,8 @@ def add_invoice(post, money, options) additional_values = {} additional_values[:TX_VALUE] = tx_value - additional_values[:TX_TAX] = tx_tax - additional_values[:TX_TAX_RETURN_BASE] = tx_tax_return_base + additional_values[:TX_TAX] = tx_tax if options[:payment_country] == 'CO' + additional_values[:TX_TAX_RETURN_BASE] = tx_tax_return_base if options[:payment_country] == 'CO' post[:transaction][:order][:additionalValues] = additional_values end @@ -246,29 +278,6 @@ def add_process_without_cvv2(payment_method, options) false end - def add_payer(post, options) - if address = options[:billing_address] - payer = {} - post[:transaction][:paymentCountry] = address[:country] - payer[:fullName] = address[:name] - payer[:contactPhone] = address[:phone] - payer[:dniNumber] = options[:dni_number] if options[:dni_number] - payer[:dniType] = options[:dni_type] if options[:dni_type] - payer[:emailAddress] = options[:email] if options[:email] - payer[:contactPhone] = address[:phone] - billing_address = {} - billing_address[:street1] = address[:address1] - billing_address[:street2] = address[:address2] - billing_address[:city] = address[:city] - billing_address[:state] = address[:state] - billing_address[:country] = address[:country] - billing_address[:postalCode] = address[:zip] - billing_address[:phone] = address[:phone] - payer[:billingAddress] = billing_address - post[:transaction][:payer] = payer - end - end - def add_extra_parameters(post, options) extra_parameters = {} extra_parameters[:INSTALLMENTS_NUMBER] = options[:installments_number] || 1 @@ -326,6 +335,7 @@ def headers end def post_data(params) + params.merge(test: test?) params.to_json end diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index 5561cbf1486..6de69a26e8c 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -11,13 +11,11 @@ def setup @options = { dni_number: '5415668464654', - dni_type: 'TI', currency: "ARS", order_id: generate_unique_id, description: "Active Merchant Transaction", installments_number: 1, tax: 0, - tax_return_base: 0, email: "username@domain.com", ip: "127.0.0.1", device_session_id: 'vghs6tvkcle931686k1900o6e1', @@ -51,10 +49,47 @@ def test_successful_purchase assert response.test? end + def test_successul_purchase_with_buyer + gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512327")) + + options_buyer = { + currency: "BRL", + billing_address: address( + address1: "Calle 100", + address2: "BL4", + city: "Sao Paulo", + state: "SP", + country: "BR", + zip: "09210710", + phone: "(11)756312633" + ), + shipping_address: address( + address1: "Calle 200", + address2: "N107", + city: "Sao Paulo", + state: "SP", + country: "BR", + zip: "01019-030", + phone: "(11)756312633" + ), + buyer_name: 'Jorge Borges', + buyer_dni_number: '5415668464123', + buyer_dni_type: 'TI', + buyer_cnpj: '32593371000110', + buyer_email: 'axaxaxas@mlo.org' + } + + response = gateway.purchase(@amount, @credit_card, @options.update(options_buyer)) + assert_success response + assert_equal "APPROVED", response.message + assert response.test? + end + def test_successful_purchase_brazil gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512327")) options_brazil = { + payment_country: "BR", currency: "BRL", billing_address: address( address1: "Calle 100", @@ -73,7 +108,8 @@ def test_successful_purchase_brazil country: "BR", zip: "01019-030", phone: "(11)756312633" - ) + ), + buyer_cnpj: "32593371000110" } response = gateway.purchase(@amount, @credit_card, @options.update(options_brazil)) @@ -82,8 +118,68 @@ def test_successful_purchase_brazil assert response.test? end - def test_successful_purchase_sans_options - response = @gateway.purchase(@amount, @credit_card) + def test_successful_purchase_colombia + gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512321")) + + options_colombia = { + payment_country: "CO", + currency: "COP", + billing_address: address( + address1: "Calle 100", + address2: "BL4", + city: "Bogota", + state: "Bogota DC", + country: "CO", + zip: "09210710", + phone: "(11)756312633" + ), + shipping_address: address( + address1: "Calle 200", + address2: "N107", + city: "Bogota", + state: "Bogota DC", + country: "CO", + zip: "01019-030", + phone: "(11)756312633" + ), + tx_tax: '3193', + tx_tax_return_base: '16806' + } + + response = gateway.purchase(@amount, @credit_card, @options.update(options_colombia)) + assert_success response + assert_equal "APPROVED", response.message + assert response.test? + end + + def test_successful_purchase_mexico + gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512324")) + + options_mexico = { + payment_country: "MX", + currency: "MXN", + billing_address: address( + address1: "Calle 100", + address2: "BL4", + city: "Guadalajara", + state: "Jalisco", + country: "MX", + zip: "09210710", + phone: "(11)756312633" + ), + shipping_address: address( + address1: "Calle 200", + address2: "N107", + city: "Guadalajara", + state: "Jalisco", + country: "MX", + zip: "01019-030", + phone: "(11)756312633" + ), + birth_date: '1985-05-25' + } + + response = gateway.purchase(@amount, @credit_card, @options.update(options_mexico)) assert_success response assert_equal "APPROVED", response.message assert response.test? @@ -96,6 +192,12 @@ def test_failed_purchase assert_equal "DECLINED", response.params["transactionResponse"]["state"] end + def test_failed_purchase_with_no_options + response = @gateway.purchase(@amount, @declined_card, {}) + assert_failure response + assert_equal "ANTIFRAUD_REJECTED", response.message + end + def test_successful_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_success response @@ -121,7 +223,7 @@ def test_well_formed_refund_fails_as_expected def test_failed_refund response = @gateway.refund(@amount, '') assert_failure response - assert_match /property: parentTransactionId, message: must not be null/, response.message + assert_match (/property: parentTransactionId, message: must not be null/), response.message end def test_successful_void @@ -136,7 +238,7 @@ def test_successful_void def test_failed_void response = @gateway.void('') assert_failure response - assert_match /property: parentTransactionId, message: must not be null/, response.message + assert_match (/property: parentTransactionId, message: must not be null/), response.message end def test_successful_authorize_and_capture @@ -151,7 +253,7 @@ def test_successful_authorize_and_capture def test_failed_capture response = @gateway.capture(@amount, '') assert_failure response - assert_match /must not be null/, response.message + assert_match (/must not be null/), response.message end def test_verify_credentials diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb index 3d496ad3ddd..efac2488d22 100644 --- a/test/unit/gateways/payu_latam_test.rb +++ b/test/unit/gateways/payu_latam_test.rb @@ -175,6 +175,149 @@ def test_failed_capture assert_equal "property: order.id, message: must not be null property: parentTransactionId, message: must not be null", response.message end + def test_buyer_fields + options_buyer = { + shipping_address: address( + address1: "Calle 200", + address2: "N107", + city: "Sao Paulo", + state: "SP", + country: "BR", + zip: "01019-030", + phone: "(11)756312345" + ), + buyer_name: 'Jorge Borges', + buyer_dni_number: '5415668464456', + buyer_dni_type: 'IT', + buyer_email: 'axaxaxas@mlo.org' + } + + stub_comms do + @gateway.purchase(@amount, @credit_card, @options.update(options_buyer)) + end.check_request do |endpoint, data, headers| + assert_match(/\"buyer\":{\"fullName\":\"Jorge Borges\",\"dniNumber\":\"5415668464456\",\"dniType\":\"IT\",\"emailAddress\":\"axaxaxas@mlo.org\",\"contactPhone\":\"\(11\)756312345/, data) + end.respond_with(successful_purchase_response) + end + + def test_brazil_required_fields + options_brazil = { + payment_country: 'BR', + currency: "BRL", + billing_address: address( + address1: "Calle 100", + address2: "BL4", + city: "Sao Paulo", + state: "SP", + country: "BR", + zip: "09210710", + phone: "(11)756312633" + ), + shipping_address: address( + address1: "Calle 200", + address2: "N107", + city: "Sao Paulo", + state: "SP", + country: "BR", + zip: "01019-030", + phone: "(11)756312633" + ), + buyer_cnpj: "32593371000110" + } + + stub_comms do + @gateway.purchase(@amount, @credit_card, @options.update(options_brazil)) + end.check_request do |endpoint, data, headers| + assert_match(/\"cnpj\":\"32593371000110\"/, data) + end.respond_with(successful_purchase_response) + end + + def test_colombia_required_fields + options_colombia = { + payment_country: "CO", + currency: "COP", + billing_address: address( + address1: "Calle 100", + address2: "BL4", + city: "Bogota", + state: "Bogota DC", + country: "CO", + zip: "09210710", + phone: "(11)756312633" + ), + shipping_address: address( + address1: "Calle 200", + address2: "N107", + city: "Bogota", + state: "Bogota DC", + country: "CO", + zip: "01019-030", + phone: "(11)756312633" + ), + tx_tax: '3193', + tx_tax_return_base: '16806' + } + + stub_comms do + @gateway.purchase(@amount, @credit_card, @options.update(options_colombia)) + end.check_request do |endpoint, data, headers| + assert_match(/\"additionalValues\":{\"TX_VALUE\":{\"value\":\"40.00\",\"currency\":\"COP\"},\"TX_TAX\":{\"value\":0,\"currency\":\"COP\"},\"TX_TAX_RETURN_BASE\":{\"value\":0,\"currency\":\"COP\"}}/, data) + end.respond_with(successful_purchase_response) + end + + def test_mexico_required_fields + options_mexico = { + payment_country: "MX", + currency: "MXN", + billing_address: address( + address1: "Calle 100", + address2: "BL4", + city: "Guadalajara", + state: "Jalisco", + country: "MX", + zip: "09210710", + phone: "(11)756312633" + ), + shipping_address: address( + address1: "Calle 200", + address2: "N107", + city: "Guadalajara", + state: "Jalisco", + country: "MX", + zip: "01019-030", + phone: "(11)756312633" + ), + birth_date: '1985-05-25' + } + + stub_comms do + @gateway.purchase(@amount, @credit_card, @options.update(options_mexico)) + end.check_request do |endpoint, data, headers| + assert_match(/\"birthdate\":\"1985-05-25\"/, data) + end.respond_with(successful_purchase_response) + end + + def test_payment_country_defaults_to_billing_address + options_mexico = { + currency: "MXN", + billing_address: address( + address1: "Calle 100", + address2: "BL4", + city: "Guadalajara", + state: "Jalisco", + country: "MX", + zip: "09210710", + phone: "(11)756312633" + ), + birth_date: '1985-05-25' + } + + stub_comms do + @gateway.purchase(@amount, @credit_card, @options.update(options_mexico)) + end.check_request do |endpoint, data, headers| + assert_match(/\"paymentCountry\":\"MX\"/, data) + end.respond_with(successful_purchase_response) + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed From 0d303ae3d7cbec7de390f98d971eeae467883ee2 Mon Sep 17 00:00:00 2001 From: David Perry Date: Thu, 7 Sep 2017 15:49:29 -0400 Subject: [PATCH 183/677] PayU Latam: Correctly condition buyer element fields According to PayU, the Buyer element is required, and if no buyer info is provided, the Payer's info should be sent in its place, and if only partial Buyer info is provided, the missing fields should instead be sent empty. This change ensures these conditions are fulfilled. It also gathers the buyer fields under one buyer hash option instead of multiple top-level buyer_* fields, and exposes a top-level cnpj field for the payer. Closes #2578 Remote tests continue to fail unrelated capture and void. Remote: 18 tests, 47 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 88.8889% passed 23 tests, 89 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/payu_latam.rb | 28 +++++++++++++------ .../remote/gateways/remote_payu_latam_test.rb | 16 +++++++---- test/unit/gateways/payu_latam_test.rb | 25 ++++++++++++----- 4 files changed, 48 insertions(+), 22 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3b6c94a0931..047ae0a19a4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * Conekta: Add guard clause for details fallbacks [curiousepic] #2573 * WePay: Don't default API version header [curiousepic] #2567 * PayU Latam: Pass unique buyer fields and country requirements [curiousepic] #2570 +* PayU Latam: Correctly condition buyer element fields [curiousepic] #2578 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index e7a386786f8..d4558051a8f 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -118,7 +118,7 @@ def auth_or_sale(post, transaction_type, amount, payment_method, options) add_credentials(post, 'SUBMIT_TRANSACTION') add_transaction_elements(post, transaction_type, options) add_order(post, options) - add_buyer(post, options) + add_buyer(post, payment_method, options) add_invoice(post, amount, options) add_signature(post) add_payment_method(post, payment_method, options) @@ -183,15 +183,25 @@ def billing_address_fields(options) billing_address end - def add_buyer(post, options) + def add_buyer(post, payment_method, options) buyer = {} - buyer[:fullName] = options[:buyer_name] if options[:buyer_name] - buyer[:dniNumber] = options[:buyer_dni_number] if options[:buyer_dni_number] - buyer[:dniType] = options[:buyer_dni_type] if options[:buyer_dni_type] - buyer[:cnpj] = options[:buyer_cnpj] if options[:buyer_cnpj] && options[:payment_country] == 'BR' - buyer[:emailAddress] = options[:buyer_email] if options[:buyer_email] - buyer[:contactPhone] = options[:shipping_address][:phone] if options[:shipping_address] - buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address] + if buyer_hash = options[:buyer] + buyer[:fullName] = buyer_hash[:name] + buyer[:dniNumber] = buyer_hash[:dni_number] + buyer[:dniType] = buyer_hash[:dni_type] + buyer[:cnpj] = buyer_hash[:cnpj] if options[:payment_country] == 'BR' + buyer[:emailAddress] = buyer_hash[:email] + buyer[:contactPhone] = options[:shipping_address][:phone] if options[:shipping_address] + buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address] + else + buyer[:fullName] = payment_method.name.strip + buyer[:dniNumber] = options[:dni_number] + buyer[:dniType] = options[:dni_type] + buyer[:cnpj] = options[:cnpj] if options[:payment_country] == 'BR' + buyer[:emailAddress] = options[:email] + buyer[:contactPhone] = (options[:shipping_address][:phone] if options[:shipping_address]) || (options[:billing_address][:phone] if options[:billing_address]) + buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address] + end post[:transaction][:order][:buyer] = buyer end diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index 6de69a26e8c..4c417de377a 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -72,11 +72,13 @@ def test_successul_purchase_with_buyer zip: "01019-030", phone: "(11)756312633" ), - buyer_name: 'Jorge Borges', - buyer_dni_number: '5415668464123', - buyer_dni_type: 'TI', - buyer_cnpj: '32593371000110', - buyer_email: 'axaxaxas@mlo.org' + buyer: { + name: 'Jorge Borges', + dni_number: '5415668464123', + dni_type: 'TI', + cnpj: '32593371000110', + email: 'axaxaxas@mlo.org' + } } response = gateway.purchase(@amount, @credit_card, @options.update(options_buyer)) @@ -109,7 +111,9 @@ def test_successful_purchase_brazil zip: "01019-030", phone: "(11)756312633" ), - buyer_cnpj: "32593371000110" + buyer:{ + cnpj: "32593371000110" + } } response = gateway.purchase(@amount, @credit_card, @options.update(options_brazil)) diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb index efac2488d22..11b75da35d6 100644 --- a/test/unit/gateways/payu_latam_test.rb +++ b/test/unit/gateways/payu_latam_test.rb @@ -175,7 +175,7 @@ def test_failed_capture assert_equal "property: order.id, message: must not be null property: parentTransactionId, message: must not be null", response.message end - def test_buyer_fields + def test_partial_buyer_hash_info options_buyer = { shipping_address: address( address1: "Calle 200", @@ -186,16 +186,25 @@ def test_buyer_fields zip: "01019-030", phone: "(11)756312345" ), - buyer_name: 'Jorge Borges', - buyer_dni_number: '5415668464456', - buyer_dni_type: 'IT', - buyer_email: 'axaxaxas@mlo.org' + buyer: { + name: 'Jorge Borges', + dni_number: '5415668464456', + email: 'axaxaxas@mlo.org' + } } stub_comms do @gateway.purchase(@amount, @credit_card, @options.update(options_buyer)) end.check_request do |endpoint, data, headers| - assert_match(/\"buyer\":{\"fullName\":\"Jorge Borges\",\"dniNumber\":\"5415668464456\",\"dniType\":\"IT\",\"emailAddress\":\"axaxaxas@mlo.org\",\"contactPhone\":\"\(11\)756312345/, data) + assert_match(/\"buyer\":{\"fullName\":\"Jorge Borges\",\"dniNumber\":\"5415668464456\",\"dniType\":null,\"emailAddress\":\"axaxaxas@mlo.org\",\"contactPhone\":\"\(11\)756312345\",\"shippingAddress\":{\"street1\":\"Calle 200\",\"street2\":\"N107\",\"city\":\"Sao Paulo\",\"state\":\"SP\",\"country\":\"BR\",\"postalCode\":\"01019-030\",\"phone\":\"\(11\)756312345\"}}/, data) + end.respond_with(successful_purchase_response) + end + + def test_buyer_fields_default_to_payer + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match(/\"buyer\":{\"fullName\":\"APPROVED\",\"dniNumber\":\"5415668464654\",\"dniType\":\"TI\",\"emailAddress\":\"username@domain.com\",\"contactPhone\":\"7563126\"/, data) end.respond_with(successful_purchase_response) end @@ -221,7 +230,9 @@ def test_brazil_required_fields zip: "01019-030", phone: "(11)756312633" ), - buyer_cnpj: "32593371000110" + buyer: { + cnpj: "32593371000110" + } } stub_comms do From 242d77e5f4a6c14f181071fa55437d5a38d21d38 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Mon, 11 Sep 2017 13:24:51 -0400 Subject: [PATCH 184/677] Auth.Net: Remove numeric restriction on customer ID Instead of restricting the customer ID to numbers only, allow for any letter, number, or underscore characters. This will allow for a wider range of values while still preventing email addresses and phone numbers. Related https://github.com/activemerchant/active_merchant/pull/704 Closes #2579 --- CHANGELOG | 1 + .../billing/gateways/authorize_net.rb | 2 +- .../gateways/remote_authorize_net_test.rb | 6 +++++ test/unit/gateways/authorize_net_test.rb | 24 ++++++++++++++++++- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 047ae0a19a4..5071ed36946 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * WePay: Don't default API version header [curiousepic] #2567 * PayU Latam: Pass unique buyer fields and country requirements [curiousepic] #2570 * PayU Latam: Correctly condition buyer element fields [curiousepic] #2578 +* Authorize.net: Remove numeric restriction on customer ID [dtykocki] #2579 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index 1f30f4bc7cc..4922080f420 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -535,7 +535,7 @@ def add_check(xml, check) def add_customer_data(xml, payment_source, options) xml.customer do - xml.id(options[:customer]) unless empty?(options[:customer]) || options[:customer] !~ /^\d+$/ + xml.id(options[:customer]) unless empty?(options[:customer]) || options[:customer] !~ /^\w+$/ xml.email(options[:email]) unless empty?(options[:email]) end diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb index 3f3c6a4cb70..806d44a7cf5 100644 --- a/test/remote/gateways/remote_authorize_net_test.rb +++ b/test/remote/gateways/remote_authorize_net_test.rb @@ -103,6 +103,12 @@ def test_successful_purchase_with_level_2_data assert_equal 'This transaction has been approved', response.message end + def test_successful_purchase_with_customer + response = @gateway.purchase(@amount, @credit_card, @options.merge(customer: "abcd_123")) + assert_success response + assert_equal 'This transaction has been approved', response.message + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index b628881e8d1..938ca3e7697 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -908,7 +908,19 @@ def test_include_cust_id_for_numeric_values end.respond_with(successful_authorize_response) end - def test_dont_include_cust_id_for_non_numeric_values + def test_include_cust_id_for_word_character_values + stub_comms do + @gateway.purchase(@amount, @credit_card, customer: "4840_TT") + end.check_request do |endpoint, data, headers| + parse(data) do |doc| + assert_not_nil doc.at_xpath("//customer/id"), data + assert_equal "4840_TT", doc.at_xpath("//customer/id").content, data + assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + end + end.respond_with(successful_authorize_response) + end + + def test_dont_include_cust_id_for_email_addresses stub_comms do @gateway.purchase(@amount, @credit_card, customer: "bob@test.com") end.check_request do |endpoint, data, headers| @@ -918,6 +930,16 @@ def test_dont_include_cust_id_for_non_numeric_values end.respond_with(successful_authorize_response) end + def test_dont_include_cust_id_for_phone_numbers + stub_comms do + @gateway.purchase(@amount, @credit_card, customer: "111-123-1231") + end.check_request do |endpoint, data, headers| + doc = parse(data) + assert !doc.at_xpath("//customer/id"), data + assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + end.respond_with(successful_authorize_response) + end + def test_includes_shipping_name_when_different_from_billing_name card = credit_card('4242424242424242', first_name: "billing", From f19c6cb1bc081818fd90f7c1445c94156a509f5c Mon Sep 17 00:00:00 2001 From: dtykocki Date: Tue, 12 Sep 2017 15:45:21 -0400 Subject: [PATCH 185/677] Beanstream: Do not default state and zip with empty country We've see transaction failures on Beanstream when `ordProvince` and `shipProvince` are provided without a country. According to Beanstream, these values may be optional, but they codependent and if one is included, then both must be present. Closes #2582 --- CHANGELOG | 1 + .../gateways/beanstream/beanstream_core.rb | 12 +++++-- .../remote/gateways/remote_beanstream_test.rb | 18 +++++++++- test/unit/gateways/beanstream_test.rb | 34 +++++++++++++++++-- 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5071ed36946..0932db60e50 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * PayU Latam: Pass unique buyer fields and country requirements [curiousepic] #2570 * PayU Latam: Correctly condition buyer element fields [curiousepic] #2578 * Authorize.net: Remove numeric restriction on customer ID [dtykocki] #2579 +* Beanstream: Do not default state and zip with empty country [dtykocki] #2582 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index a94bc858e8e..7acaa830bb2 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -1,6 +1,8 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: module BeanstreamCore + include Empty + RECURRING_URL = 'https://www.beanstream.com/scripts/recurring_billing.asp' SECURE_PROFILE_URL = 'https://www.beanstream.com/scripts/payment_profile.asp' @@ -177,6 +179,7 @@ def credit(money, source, options = {}) end private + def purchase_action(source) if source.is_a?(Check) :check_purchase @@ -227,7 +230,7 @@ def add_address(post, options) post[:ordAddress1] = billing_address[:address1] post[:ordAddress2] = billing_address[:address2] post[:ordCity] = billing_address[:city] - post[:ordProvince] = STATES[billing_address[:state].upcase] || billing_address[:state] if billing_address[:state] + post[:ordProvince] = state_for(billing_address) post[:ordPostalCode] = billing_address[:zip] post[:ordCountry] = billing_address[:country] end @@ -238,7 +241,7 @@ def add_address(post, options) post[:shipAddress1] = shipping_address[:address1] post[:shipAddress2] = shipping_address[:address2] post[:shipCity] = shipping_address[:city] - post[:shipProvince] = STATES[shipping_address[:state].upcase] || shipping_address[:state] if shipping_address[:state] + post[:shipProvince] = state_for(shipping_address) post[:shipPostalCode] = shipping_address[:zip] post[:shipCountry] = shipping_address[:country] post[:shippingMethod] = shipping_address[:shipping_method] @@ -246,8 +249,13 @@ def add_address(post, options) end end + def state_for(address) + STATES[address[:state].upcase] || address[:state] if address[:state] + end + def prepare_address_for_non_american_countries(options) [ options[:billing_address], options[:shipping_address] ].compact.each do |address| + next if empty?(address[:country]) unless ['US', 'CA'].include?(address[:country]) address[:state] = '--' address[:zip] = '000000' unless address[:zip] diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb index b2dba6dd0d0..175c0a6b1b2 100644 --- a/test/remote/gateways/remote_beanstream_test.rb +++ b/test/remote/gateways/remote_beanstream_test.rb @@ -109,6 +109,15 @@ def test_successful_purchase_with_state_in_iso_format assert_equal "Approved", response.message end + def test_successful_purchase_with_no_addresses + @options[:billing_address] = {} + @options[:shipping_address] = {} + assert response = @gateway.purchase(@amount, @visa, @options) + assert_success response + assert_false response.authorization.blank? + assert_equal "Approved", response.message + end + def test_failed_purchase_due_to_invalid_billing_state @options[:billing_address][:state] = "Invalid" assert response = @gateway.purchase(@amount, @visa, @options) @@ -123,6 +132,13 @@ def test_failed_purchase_due_to_invalid_shipping_state assert_match %r{Invalid shipping province}, response.message end + def test_failed_purchase_due_to_missing_country_with_state + @options[:shipping_address][:country] = nil + assert response = @gateway.purchase(@amount, @visa, @options) + assert_failure response + assert_match %r{Invalid shipping country id}, response.message + end + def test_authorize_and_capture assert auth = @gateway.authorize(@amount, @visa, @options) assert_success auth @@ -222,7 +238,7 @@ def test_invalid_login ) assert response = gateway.purchase(@amount, @visa, @options) assert_failure response - assert_equal 'Invalid merchant id (merchant_id = 0)', response.message + assert_equal 'merchantid=Invalid merchant id (merchant_id = )', response.message end def test_successful_add_to_vault_with_store_method diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb index bd0595ee3e1..130dac23fe0 100644 --- a/test/unit/gateways/beanstream_test.rb +++ b/test/unit/gateways/beanstream_test.rb @@ -232,12 +232,42 @@ def test_includes_network_tokenization_fields assert_success response end + def test_defaults_state_and_zip_with_country + address = { country: "AF" } + @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| + assert_match(/ordProvince=--/, data) + assert_match(/ordPostalCode=000000/, data) + assert_match(/shipProvince=--/, data) + assert_match(/shipPostalCode=000000/, data) + end.respond_with(successful_purchase_response) + + assert_success response + end + + def test_no_state_and_zip_default_with_missing_country + 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| + assert_no_match(/ordProvince=--/, data) + assert_no_match(/ordPostalCode=000000/, data) + assert_no_match(/shipProvince=--/, data) + assert_no_match(/shipPostalCode=000000/, data) + end.respond_with(successful_purchase_response) + + assert_success response + end def test_transcript_scrubbing assert_equal scrubbed_transcript, @gateway.scrub(transcript) end - private def successful_purchase_response @@ -266,7 +296,7 @@ def unsuccessful_authorize_response def successful_void_response "trnApproved=1&trnId=10100563&messageId=1&messageText=Approved&trnOrderNumber=6ca476d1a29da81a5f2d5d2c92ddeb&authCode=TEST&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=9%2F9%2F2015+10%3A13%3A12+AM&avsProcessed=0&avsId=U&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+information+is+unavailable%2E&cvdId=2&cardType=VI&trnType=VP&paymentMethod=CC&ref1=reference+one&ref2=&ref3=&ref4=&ref5=" - end + end def unsuccessful_void_response "trnApproved=0&trnId=0&messageId=0&messageText=%3CLI%3EAdjustment+id+must+be+less+than+8+characters%3Cbr%3E&trnOrderNumber=&authCode=&errorType=U&errorFields=adjId&responseType=T&trnAmount=&trnDate=9%2F9%2F2015+10%3A15%3A20+AM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+for+this+transaction%2E&cardType=&trnType=VP&paymentMethod=CC&ref1=&ref2=&ref3=&ref4=&ref5=" From 7fc0582814ad1e28b6b2e8c33a89b3ae378df5c6 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Fri, 8 Sep 2017 09:05:48 -0400 Subject: [PATCH 186/677] Add refund to Kushki Adds support for performing refund transactions on Kushki. The refund endpoint is a bit quirky in that the response body only returns a message and status code, not a unique transaction identifier like other endpoints. Additionally, the amount param is ignored since the call to perform a refund only accepts a reference identifier. Closes #2575 --- CHANGELOG | 1 + .../billing/gateways/kushki.rb | 20 ++++++-- test/remote/gateways/remote_kushki_test.rb | 20 +++++++- test/unit/gateways/kushki_test.rb | 47 +++++++++++++++++++ 4 files changed, 82 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0932db60e50..60c7a697ade 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * PayU Latam: Correctly condition buyer element fields [curiousepic] #2578 * Authorize.net: Remove numeric restriction on customer ID [dtykocki] #2579 * Beanstream: Do not default state and zip with empty country [dtykocki] #2582 +* Kushki: Add support for refunds [dtykocki] #2575 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/kushki.rb b/lib/active_merchant/billing/gateways/kushki.rb index 98c553951c3..ba0148b353f 100644 --- a/lib/active_merchant/billing/gateways/kushki.rb +++ b/lib/active_merchant/billing/gateways/kushki.rb @@ -24,6 +24,15 @@ def purchase(amount, payment_method, options={}) end end + def refund(amount, authorization, options={}) + action = "refund" + + post = {} + post[:ticketNumber] = authorization + + commit(action, post) + end + def void(authorization, options={}) action = "void" @@ -129,7 +138,8 @@ def add_reference(post, authorization, options) ENDPOINT = { "tokenize" => "tokens", "charge" => "charges", - "void" => "charges" + "void" => "charges", + "refund" => "refund" } def commit(action, params) @@ -152,7 +162,7 @@ def commit(action, params) end def ssl_invoke(action, params) - if action == "void" + if ["void", "refund"].include?(action) ssl_request(:delete, url(action, params), nil, headers(action)) else ssl_post(url(action, params), post_data(params), headers(action)) @@ -174,8 +184,8 @@ def post_data(params) def url(action, params) base_url = test? ? test_url : live_url - if action == "void" - base_url + ENDPOINT[action] + "/" + params[:ticketNumber] + if ["void", "refund"].include?(action) + base_url + ENDPOINT[action] + "/" + params[:ticketNumber].to_s else base_url + ENDPOINT[action] end @@ -194,7 +204,7 @@ def parse(body) end def success_from(response) - return true if response["token"] || response["ticketNumber"] + return true if response["token"] || response["ticketNumber"] || response["code"] == "K000" end def message_from(succeeded, response) diff --git a/test/remote/gateways/remote_kushki_test.rb b/test/remote/gateways/remote_kushki_test.rb index 3f90d661083..1fae5d77b8c 100644 --- a/test/remote/gateways/remote_kushki_test.rb +++ b/test/remote/gateways/remote_kushki_test.rb @@ -51,6 +51,24 @@ def test_failed_purchase assert_equal 'Monto de la transacción es diferente al monto de la venta inicial', response.message end + def test_successful_refund + purchase = @gateway.purchase(@amount, @credit_card) + assert_success purchase + + assert refund = @gateway.refund(@amount, purchase.authorization) + assert_success refund + assert_equal 'Succeeded', refund.message + end + + def test_failed_refund + purchase = @gateway.purchase(@amount, @credit_card) + assert_success purchase + + assert refund = @gateway.refund(@amount, nil) + assert_failure refund + assert_equal 'Missing Authentication Token', refund.message + end + def test_successful_void purchase = @gateway.purchase(@amount, @credit_card) assert_success purchase @@ -63,7 +81,7 @@ def test_successful_void def test_failed_void response = @gateway.void("000") assert_failure response - assert_equal 'Tipo de moneda no válida', response.message + assert_equal 'El monto de la transacción es requerido', response.message end def test_invalid_login diff --git a/test/unit/gateways/kushki_test.rb b/test/unit/gateways/kushki_test.rb index 07198fa87b7..5aeb1a8af9c 100644 --- a/test/unit/gateways/kushki_test.rb +++ b/test/unit/gateways/kushki_test.rb @@ -62,6 +62,35 @@ def test_failed_purchase assert_equal '220', response.error_code end + def test_successful_refund + @gateway.expects(:ssl_post).returns(successful_charge_response) + @gateway.expects(:ssl_post).returns(successful_token_response) + + purchase = @gateway.purchase(@amount, @credit_card) + assert_success purchase + + @gateway.expects(:ssl_request).returns(successful_refund_response) + + assert refund = @gateway.refund(@amount, purchase.authorization) + assert_success refund + assert_equal 'Succeeded', refund.message + end + + def test_failed_refund + @gateway.expects(:ssl_post).returns(successful_charge_response) + @gateway.expects(:ssl_post).returns(successful_token_response) + + purchase = @gateway.purchase(@amount, @credit_card) + assert_success purchase + + @gateway.expects(:ssl_request).returns(failed_refund_response) + + assert refund = @gateway.refund(@amount, purchase.authorization) + assert_failure refund + assert_equal 'Ticket number inválido', refund.message + assert_equal 'K010', refund.error_code + end + def test_successful_void @gateway.expects(:ssl_post).returns(successful_charge_response) @gateway.expects(:ssl_post).returns(successful_token_response) @@ -215,6 +244,24 @@ def failed_charge_response ) end + def successful_refund_response + %( + { + "code": "K000", + "message": "El reembolso solicitado se realizó con éxito." + } + ) + end + + def failed_refund_response + %( + { + "code": "K010", + "message": "Ticket number inválido" + } + ) + end + def successful_void_response %( { From 6eb0c4074019be4ab59f8e478bc5c71316f0d149 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Thu, 14 Sep 2017 10:29:54 -0400 Subject: [PATCH 187/677] Adyen: Fix failing remote tests Closes #2584 --- CHANGELOG | 1 + test/remote/gateways/remote_adyen_test.rb | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 60c7a697ade..e122316f840 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ * Authorize.net: Remove numeric restriction on customer ID [dtykocki] #2579 * Beanstream: Do not default state and zip with empty country [dtykocki] #2582 * Kushki: Add support for refunds [dtykocki] #2575 +* Adyen: Fix failing remote tests [dtykocki] #2584 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb index 5be62e1d320..c4eac422d28 100644 --- a/test/remote/gateways/remote_adyen_test.rb +++ b/test/remote/gateways/remote_adyen_test.rb @@ -22,7 +22,8 @@ def setup shopper_email: "john.smith@test.com", shopper_ip: "77.110.174.153", shopper_reference: "John Smith", - :billing_address => address(), + billing_address: address(), + order_id: "123" } end @@ -165,7 +166,7 @@ def test_invalid_expiry_month_for_purchase card = credit_card('4242424242424242', month: 16) assert response = @gateway.purchase(@amount, card, @options) assert_failure response - assert_equal 'Expiry month should be between 1 and 12 inclusive Card', response.message + assert_equal 'Expiry month should be between 1 and 12 inclusive', response.message end def test_invalid_expiry_year_for_purchase From def19a5d536f8b6adb44249521707d7148ab1563 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Fri, 15 Sep 2017 13:38:39 -0400 Subject: [PATCH 188/677] Merchant Partners: Relax response message assertions for remote tests The response message for a couple failed remote tests have slightly changed. This relaxes the assertion a bit to check for the presence of the words "Invalid account" instead of an exact string. Previous failure message: "Invalid account number" Current failure message: "Invalid account format." --- test/remote/gateways/remote_merchant_partners_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/remote/gateways/remote_merchant_partners_test.rb b/test/remote/gateways/remote_merchant_partners_test.rb index b350166ca54..f398ae39112 100644 --- a/test/remote/gateways/remote_merchant_partners_test.rb +++ b/test/remote/gateways/remote_merchant_partners_test.rb @@ -33,7 +33,7 @@ def test_successful_purchase def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "Invalid account number", response.message + assert_match(/Invalid account/, response.message) assert response.params["result"].start_with?("DECLINED") end @@ -51,7 +51,7 @@ def test_successful_authorize_and_capture def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal "Invalid account number", response.message + assert_match(/Invalid account/, response.message) assert response.params["result"].start_with?("DECLINED") end @@ -103,7 +103,7 @@ def test_successful_credit def test_failed_credit response = @gateway.credit(@amount, @declined_card, @options) assert_failure response - assert_equal "Invalid account number", response.message + assert_match(/Invalid account/, response.message) assert response.params["result"].start_with?("DECLINED") end @@ -116,7 +116,7 @@ def test_successful_verify def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "Invalid account number", response.message + assert_match(/Invalid account/, response.message) assert response.params["result"].start_with?("DECLINED") end From ac0fb11081762db06a1593b5096018f2b9653d31 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Fri, 15 Sep 2017 15:21:11 -0400 Subject: [PATCH 189/677] MercadoPago: Send diners_club cards as diners MercadoPago seems to use the same card type formatting as Active Merchant except in the case of American Express and Diners Club. Amex was updated previously but Diners Club was left out. This formats the diners_club type as just diners. Closes #2585 --- CHANGELOG | 1 + .../billing/gateways/mercado_pago.rb | 11 +++++-- .../gateways/remote_mercado_pago_test.rb | 8 +++++ test/unit/gateways/mercado_pago_test.rb | 30 +++++++++++++++++++ 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e122316f840..cbb35278a23 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * Beanstream: Do not default state and zip with empty country [dtykocki] #2582 * Kushki: Add support for refunds [dtykocki] #2575 * Adyen: Fix failing remote tests [dtykocki] #2584 +* MercadoPago: Send diners_club cards as diners [davidsantoso] #2585 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index 519c8ffeaf2..406ef823a90 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -10,6 +10,11 @@ class MercadoPagoGateway < Gateway self.display_name = 'Mercado Pago' self.money_format = :dollars + CARD_BRAND = { + "american_express" => "amex", + "diners_club" => "diners" + } + def initialize(options={}) requires!(options, :access_token) super @@ -18,7 +23,7 @@ def initialize(options={}) def purchase(money, payment, options={}) MultiResponse.run do |r| r.process { commit("tokenize", "card_tokens", card_token_request(money, payment, options)) } - options.merge!(card_brand: payment.brand) + options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand)) options.merge!(card_token: r.authorization.split("|").first) r.process { commit("purchase", "payments", purchase_request(money, payment, options) ) } end @@ -27,7 +32,7 @@ def purchase(money, payment, options={}) def authorize(money, payment, options={}) MultiResponse.run do |r| r.process { commit("tokenize", "card_tokens", card_token_request(money, payment, options)) } - options.merge!(card_brand: payment.brand) + options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand)) options.merge!(card_token: r.authorization.split("|").first) r.process { commit("authorize", "payments", authorize_request(money, payment, options) ) } end @@ -175,7 +180,7 @@ def add_invoice(post, money, options) def add_payment(post, options) post[:token] = options[:card_token] - post[:payment_method_id] = options[:card_brand] == "american_express" ? "amex" : options[:card_brand] + post[:payment_method_id] = options[:card_brand] end def parse(body) diff --git a/test/remote/gateways/remote_mercado_pago_test.rb b/test/remote/gateways/remote_mercado_pago_test.rb index a8b0171f65c..43e5e659965 100644 --- a/test/remote/gateways/remote_mercado_pago_test.rb +++ b/test/remote/gateways/remote_mercado_pago_test.rb @@ -21,6 +21,14 @@ def test_successful_purchase assert_equal 'accredited', response.message end + def test_successful_purchase_with_american_express + amex_card = credit_card('375365153556885', brand: 'american_express', verification_value: '1234') + + response = @gateway.purchase(@amount, amex_card, @options) + assert_success response + assert_equal 'accredited', response.message + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb index 0febc27339b..1fe1560819d 100644 --- a/test/unit/gateways/mercado_pago_test.rb +++ b/test/unit/gateways/mercado_pago_test.rb @@ -164,6 +164,36 @@ def test_sends_american_express_as_amex assert_equal '4141491|1.0', response.authorization end + def test_sends_diners_club_as_diners + credit_card = credit_card('30569309025904', brand: 'diners_club') + + response = stub_comms do + @gateway.purchase(@amount, credit_card, @options) + end.check_request do |endpoint, data, headers| + if data =~ /"payment_method_id"/ + assert_match(%r(diners), data) + end + end.respond_with(successful_purchase_response) + + assert_success response + assert_equal '4141491|1.0', response.authorization + end + + def test_sends_mastercard_as_master + credit_card = credit_card('5555555555554444', brand: 'master') + + response = stub_comms do + @gateway.purchase(@amount, credit_card, @options) + end.check_request do |endpoint, data, headers| + if data =~ /"payment_method_id"/ + assert_match(%r(master), data) + end + end.respond_with(successful_purchase_response) + + assert_success response + assert_equal '4141491|1.0', response.authorization + end + private def pre_scrubbed From f6060d5555078c9fb39cd65c1a609b553a35846c Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 19 Sep 2017 16:03:37 -0400 Subject: [PATCH 190/677] WePay: Don't require email for Store No longer requires email for Store actions and instead allows the method to default the value if it's absent. Closes #2588 Remote: 24 tests, 40 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 20 tests, 74 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/wepay.rb | 2 -- test/remote/gateways/remote_wepay_test.rb | 6 ++++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cbb35278a23..3457a58fe1b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * Kushki: Add support for refunds [dtykocki] #2575 * Adyen: Fix failing remote tests [dtykocki] #2584 * MercadoPago: Send diners_club cards as diners [davidsantoso] #2585 +* WePay: Don't require email for Store [curiousepic] #2588 == Version 1.71.0 (August 22, 2017) * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 diff --git a/lib/active_merchant/billing/gateways/wepay.rb b/lib/active_merchant/billing/gateways/wepay.rb index a408fd04fa1..d0102d0e664 100644 --- a/lib/active_merchant/billing/gateways/wepay.rb +++ b/lib/active_merchant/billing/gateways/wepay.rb @@ -76,8 +76,6 @@ def refund(money, identifier, options = {}) end def store(creditcard, options = {}) - requires!(options, :email) - post = {} post[:client_id] = @options[:client_id] post[:user_name] = "#{creditcard.first_name} #{creditcard.last_name}" diff --git a/test/remote/gateways/remote_wepay_test.rb b/test/remote/gateways/remote_wepay_test.rb index f14c3288181..0ec5963274c 100644 --- a/test/remote/gateways/remote_wepay_test.rb +++ b/test/remote/gateways/remote_wepay_test.rb @@ -88,11 +88,17 @@ def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response end + def test_successful_store response = @gateway.store(@credit_card, @options) assert_success response end + def test_successful_store_with_defaulted_email + response = @gateway.store(@credit_card, {billing_address: address}) + assert_success response + end + def test_failed_store response = @gateway.store(@declined_card, @options) assert_failure response From 897fa55e4eecc978c45c75fab0062c03d12b5b30 Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Wed, 20 Sep 2017 17:13:49 -0400 Subject: [PATCH 191/677] Release version 1.72.0 --- CHANGELOG | 28 +++++++++++++++------------- lib/active_merchant/version.rb | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3457a58fe1b..91b54e13245 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,24 +1,26 @@ = ActiveMerchant CHANGELOG == HEAD -* SafeCharge: Update to Version 4.1.0 [nfarve] #2556 -* Qvalent: Support general credit [curiousepic] #2558 -* DataCash: Enable refunding recurring transactions [davidsantoso] #2560 -* Ebanx: Adds Brazil Specific Parameters [nfarve] #2559 + +== Version 1.72.0 (September 20, 2017) +* Adyen: Fix failing remote tests [dtykocki] #2584 +* Authorize.net: Remove numeric restriction on customer ID [dtykocki] #2579 * Authorize.net: Restore default state value for non-US addresses [jasonwebster] #2563 -* MercadoPago: Additional tweaks for transaction requests [davidsantoso] +* Beanstream: Do not default state and zip with empty country [dtykocki] #2582 * Braintree Blue: Add eci_indicator field for Apple Pay [davidsantoso] #2565 -* Conekta: Pull required details from billing address [nfarve] #2568 -* MercadoPago: Default to alphanumeric order_id [davidsantoso] * Conekta: Add guard clause for details fallbacks [curiousepic] #2573 -* WePay: Don't default API version header [curiousepic] #2567 -* PayU Latam: Pass unique buyer fields and country requirements [curiousepic] #2570 -* PayU Latam: Correctly condition buyer element fields [curiousepic] #2578 -* Authorize.net: Remove numeric restriction on customer ID [dtykocki] #2579 -* Beanstream: Do not default state and zip with empty country [dtykocki] #2582 +* Conekta: Pull required details from billing address [nfarve] #2568 +* DataCash: Enable refunding recurring transactions [davidsantoso] #2560 +* Ebanx: Adds Brazil Specific Parameters [nfarve] #2559 * Kushki: Add support for refunds [dtykocki] #2575 -* Adyen: Fix failing remote tests [dtykocki] #2584 +* MercadoPago: Additional tweaks for transaction requests [davidsantoso] +* MercadoPago: Default to alphanumeric order_id [davidsantoso] * MercadoPago: Send diners_club cards as diners [davidsantoso] #2585 +* PayU Latam: Correctly condition buyer element fields [curiousepic] #2578 +* PayU Latam: Pass unique buyer fields and country requirements [curiousepic] #2570 +* Qvalent: Support general credit [curiousepic] #2558 +* SafeCharge: Update to Version 4.1.0 [nfarve] #2556 +* WePay: Don't default API version header [curiousepic] #2567 * WePay: Don't require email for Store [curiousepic] #2588 == Version 1.71.0 (August 22, 2017) diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index a357fecf6b1..7acecde7577 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.71.0" + VERSION = "1.72.0" end From 2b89e5295c1fdc7769e44f51b9fbd36b0c84fcf9 Mon Sep 17 00:00:00 2001 From: Bart de Water Date: Tue, 26 Sep 2017 17:32:59 -0400 Subject: [PATCH 192/677] [Wirecard] use localized_amount to fix non-fractional currencies --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/wirecard.rb | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 91b54e13245..f4d8caa8cd1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Wirecard: Format non-fractional currency amounts correctly [bdewater] #2594 == Version 1.72.0 (September 20, 2017) * Adyen: Fix failing remote tests [dtykocki] #2584 diff --git a/lib/active_merchant/billing/gateways/wirecard.rb b/lib/active_merchant/billing/gateways/wirecard.rb index 5649bc2d61f..46a94f942d3 100644 --- a/lib/active_merchant/billing/gateways/wirecard.rb +++ b/lib/active_merchant/billing/gateways/wirecard.rb @@ -235,7 +235,7 @@ def add_transaction_data(xml, money, options) add_address(xml, options[:billing_address]) when :capture, :bookback xml.tag! 'GuWID', options[:preauthorization] - add_amount(xml, money) + add_amount(xml, money, options) when :reversal xml.tag! 'GuWID', options[:preauthorization] end @@ -246,7 +246,7 @@ def add_transaction_data(xml, money, options) # Includes the payment (amount, currency, country) to the transaction-xml def add_invoice(xml, money, options) - add_amount(xml, money) + add_amount(xml, money, options) xml.tag! 'Currency', options[:currency] || currency(money) xml.tag! 'CountryCode', options[:billing_address][:country] xml.tag! 'RECURRING_TRANSACTION' do @@ -255,8 +255,8 @@ def add_invoice(xml, money, options) end # Include the amount in the transaction-xml - def add_amount(xml, money) - xml.tag! 'Amount', amount(money) + def add_amount(xml, money, options) + xml.tag! 'Amount', localized_amount(money, options[:currency] || currency(money)) end # Includes the credit-card data to the transaction-xml From 2ebf6c37c6cb60400c767cb8743c5722423bd204 Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Wed, 27 Sep 2017 16:40:39 -0400 Subject: [PATCH 193/677] Explicitly require braintree-ruby gem version 2.78.0 (#2592) --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/braintree_blue.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f4d8caa8cd1..3ad616a877a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Braintree Blue: Explicitly require braintree-ruby version 2.78 [anotherjosmith] * Wirecard: Format non-fractional currency amounts correctly [bdewater] #2594 == Version 1.72.0 (September 20, 2017) diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 7985ad6b9a9..68a46fa19cd 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -6,8 +6,8 @@ raise "Could not load the braintree gem. Use `gem install braintree` to install it." end -unless Braintree::Version::Major == 2 && Braintree::Version::Minor >= 4 - raise "Need braintree gem >= 2.4.0. Run `gem install braintree --version '~>2.4'` to get the correct version." +unless Braintree::Version::Major == 2 && Braintree::Version::Minor >= 78 + raise "Need braintree gem >= 2.78.0. Run `gem install braintree --version '~>2.78'` to get the correct version." end module ActiveMerchant #:nodoc: From 0710495901fd2ab017fb0995b23d660e9269a8ea Mon Sep 17 00:00:00 2001 From: Andre Lyver Date: Thu, 28 Sep 2017 11:03:30 -0400 Subject: [PATCH 194/677] Add original pspReference to the refund calls, instead of the capture pspReference. (#2589) --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 12 +- test/unit/gateways/adyen_test.rb | 30 +- ~ | 2395 +++++++++++++++++ 4 files changed, 2427 insertions(+), 11 deletions(-) create mode 100644 ~ diff --git a/CHANGELOG b/CHANGELOG index 3ad616a877a..ad0ea0b9418 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ * MercadoPago: Send diners_club cards as diners [davidsantoso] #2585 * PayU Latam: Correctly condition buyer element fields [curiousepic] #2578 * PayU Latam: Pass unique buyer fields and country requirements [curiousepic] #2570 +* Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 * Qvalent: Support general credit [curiousepic] #2558 * SafeCharge: Update to Version 4.1.0 [nfarve] #2556 * WePay: Don't default API version header [curiousepic] #2567 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index 1b387bd5cb4..3e9248283f2 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -144,7 +144,7 @@ def add_payment(post, payment) end def add_references(post, authorization, options = {}) - post[:originalReference] = authorization + post[:originalReference] = psp_reference_from(authorization) post[:reference] = options[:order_id] end @@ -169,7 +169,7 @@ def commit(action, parameters) success, message_from(action, response), response, - authorization: authorization_from(response), + authorization: authorization_from(action, parameters, response), test: test?, error_code: success ? nil : error_code_from(response) ) @@ -207,8 +207,8 @@ def message_from(action, response) end end - def authorization_from(response) - response['pspReference'] + def authorization_from(action, parameters, response) + [parameters[:originalReference], response['pspReference']].compact.join("#").presence end def init_post(options = {}) @@ -223,6 +223,10 @@ def error_code_from(response) STANDARD_ERROR_CODE_MAPPING[response['errorCode']] end + def psp_reference_from(authorization) + authorization.nil? ? nil : authorization.split("#").first + end + end end end diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index 63b042f3a5a..e3012f2e7f9 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -47,8 +47,16 @@ def test_failed_authorize def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - response = @gateway.capture(@amount, 'pspReference') - assert_equal '8814775564188305', response.authorization + response = @gateway.capture(@amount, '7914775043909934') + assert_equal '7914775043909934#8814775564188305', response.authorization + assert_success response + assert response.test? + end + +def test_successful_capture_with_compount_psp_reference + @gateway.expects(:ssl_post).returns(successful_capture_response) + response = @gateway.capture(@amount, '7914775043909934#8514775559000000') + assert_equal '7914775043909934#8814775564188305', response.authorization assert_success response assert response.test? end @@ -66,7 +74,7 @@ def test_successful_purchase @gateway.purchase(@amount, @credit_card, @options) end.respond_with(successful_authorize_response, successful_capture_response) assert_success response - assert_equal '8814775564188305', response.authorization + assert_equal '7914775043909934#8814775564188305', response.authorization assert response.test? end @@ -81,8 +89,16 @@ def test_failed_purchase def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - response = @gateway.refund(@amount, 'pspReference') - assert_equal '8514775559925128', response.authorization + response = @gateway.refund(@amount, '7914775043909934') + assert_equal '7914775043909934#8514775559925128', response.authorization + assert_equal '[refund-received]', response.message + assert response.test? + end + + def test_successful_refund_with_compound_psp_reference + @gateway.expects(:ssl_post).returns(successful_refund_response) + response = @gateway.refund(@amount, '7914775043909934#8514775559000000') + assert_equal '7914775043909934#8514775559925128', response.authorization assert_equal '[refund-received]', response.message assert response.test? end @@ -97,8 +113,8 @@ def test_failed_refund def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) - response = @gateway.void('pspReference') - assert_equal '8614775821628806', response.authorization + response = @gateway.void('7914775043909934') + assert_equal '7914775043909934#8614775821628806', response.authorization assert_equal '[cancel-received]', response.message assert response.test? end diff --git a/~ b/~ new file mode 100644 index 00000000000..f0b3d68f642 --- /dev/null +++ b/~ @@ -0,0 +1,2395 @@ += ActiveMerchant CHANGELOG + +== HEAD +* SafeCharge: Update to Version 4.1.0 [nfarve] #2556 +* Qvalent: Support general credit [curiousepic] #2558 +* DataCash: Enable refunding recurring transactions [davidsantoso] #2560 +* Ebanx: Adds Brazil Specific Parameters [nfarve] #2559 +* Authorize.net: Restore default state value for non-US addresses [jasonwebster] #2563 +* MercadoPago: Additional tweaks for transaction requests [davidsantoso] +* Braintree Blue: Add eci_indicator field for Apple Pay [davidsantoso] #2565 +* Conekta: Pull required details from billing address [nfarve] #2568 +* MercadoPago: Default to alphanumeric order_id [davidsantoso] +* Conekta: Add guard clause for details fallbacks [curiousepic] #2573 +* WePay: Don't default API version header [curiousepic] #2567 +* PayU Latam: Pass unique buyer fields and country requirements [curiousepic] #2570 +* Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 + +== Version 1.71.0 (August 22, 2017) +* Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 +* Checkout V2: Add localized_amount support to add_invoice function [nicolas-maalouf-cko] #2452 +* Checkout V2: Add UAE to country list [shasum] #2548 +* Checkout V2: Fix success response code validation [nicolas-maalouf-cko] #2452 +* CreditCall: Only allow AVS when specified [curiousepic] #2549 +* CreditCall: Parse additional params from responses [nfarve] #2552 +* CreditCall: Parse more response params [nfavre] #2543 +* MercadoPago: Small tweaks to building requests [davidsantoso] #2555 +* Orbital: Support Network Tokenization Credit Cards [curiousepic] #2553 +* Orbital: Updgrade schema version to 7.1 [curiousepic] #2546 +* Remove HUF from default non-fractional currencies [curiousepic] #2538 +* Stripe: Add support for statement_address parameters for EMV transactions [malcolm-mergulhao] #2524 +* TransFirst Express: Don't send address2 without value [nfarve] #2545 +* TransFirst Express: Fix Optional Fields Being Passed Blank [nfarve] #2550 +* TransFirst: Fix partial refund [nfarve] #2541 +* Vantiv (Litle): Pass 3DS fields [curiousepic] #2536 +* Braintree Blue: Add phone to options [deedeelavinder] #2564 + +== Version 1.70.0 (August 4, 2017) +* Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 +* FirstData E4: Fix duplicate XID and CAVV values in tokenized transactions [jasonwebster] #2529 +* FirstData E4: Loose XSD validation for Payeezy (FirstData E4) [jasonwebster] #2529 +* GlobalTransport: Support partial authorizations [dtykocki] #2511 +* Litle: Update schema and certification tests to v9.12 [curiousepic] #2522 +* Litle: Update urls and name to Vantiv [curiousepic] #2531 +* Mercado Pago: Add gateway support [davidsantoso] #2518 +* Orbital: Add support for level 2 data [dtykocki] #2515 +* PayU Latam: Pass DNI Number [curiousepic] #2517 +* Qvalent: Pass 3dSecure fields [curiousepic] #2508 +* SafeCharge: Correct UserID field name [curiousepic] +* SafeCharge: Pass UserID field [curiousepic] #2507 +* AuthorizeNet: Allow Response Code 4 to be returned as successful [nfarve] #2530 +* Forte: Remove order number from captures in Forte Gateway [nfarve] #2532 +* PayU Latam: Add additional mandatory fields [deedeelavinder] #2528 + +== Version 1.69.0 (July 12, 2017) +* WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] +* Adyen: Use Active Merchant standard order_id option for reference [jasonwebster] #2483 +* Correct calculation for three-exponent currencies [curiousepic] #2486 +* SagePay: Use VPSTxId from authorization for refunds [dtykocki] #2489 +* Payflow: Move PAYPAL-NVP header option to a class attribute on the payment gateway [deuxpi] #2492 +* Optimal Payments: Pass CVD indicator accurately [curiousepic] #2491 +* SagePay: Make Repeat purchase if payment is a past authorization [curiousepic] #2495 +* Netbanx: map response errorCodes onto standard error code [iirving] #2456 +* Netbanx: Update supported countries and cardtypes [iirving] #2456 +* Barclaycard Smartpay: Support 0- and 3-exponent currencies [curiousepic] #2498 +* CyberSource: Fix XSD schema validation issues [jasonwebster] #2497 +* WorldPay: Support three-decimal currencies [curiousepic] #2501 +* NMI: Add first and lastname to echeck transactions [dtykocki] #2499 +* PayFlow: Add optional email field [davidsantoso] #2505 +* Worldpay: Support Credit on CFT-enabled merchant IDs [curiousepic] #2503 +* FirstPay: Add processor_id field [davidsantoso] #2506 +* Authorize.Net: Use two character default for billing state [dtykocki] #2496 + +== Version 1.68.0 (June 27, 2017) +* Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 +* Authorize.net: Concatenate address1 and address2 [dtykocki] #2479 +* Braintree Blue: Braintree Blue: Add ECI indicator to Android Pay transactions [davidsantoso] #2474 +* Credorax: Support 0- and 3-exponent currencies [curiousepic] +* Cybersource: update supported card types [bdewater] #2477 +* FirstData: Add a default network tokenization strategy for FirstData E4 [krystosterone] #2473 +* FirstPay: FirstPay: Update hostname and force TLSv1 minimum [davidsantoso] #2478 +* JetPay V2: Support store transactions and token based payments [shasum] #2475 +* Moneris: Add 3DS fields for decrypted Apple and Android Pay data [davidsantoso] #2457 +* Openpay: Send customer name and email in authorize and purchase [dtykocki] #2468 +* Payflow: Moved to name value pair (NVP) with payflow [jusleg] #2462 +* Payflow: Set PAYPAL_NVP header as optional [davidsantoso] #2480 +* QuickPay V10: Return last response for purchase and authorize [curiousepic] #2461 +* SafeCharge: Map billing address fields [davidsantoso] #2464 +* SafeCharge: Track currency from original transaction [davidsantoso] #2470 +* Support three-decimal currencies [curiousepic] #2466 +* Trexle: Add gateway support [hossamhossny] #2351 + +== Version 1.67.0 (June 8, 2017) +* Acapture: Pass 3D Secure fields [davidsantoso] #2451 +* Authorize.net: Pass Level 2 Data Fields [curiousepic] #2444 +* Credorax: Add 3D Secure authentication fields [davidsantoso] #2446 +* Ebanx: Add gateway support [davidsantoso] #2447 +* Ebanx: Reduce supported countries to Brazil and Mexico [davidsantoso] +* FirstData Payeezy: Set default ECI value for auth/purchase transactions [jasonwebster] #2448 +* JetPay V2: Add new gateway [shasum] #2442 +* JetPay V2: Add optional tax data to capture calls [shasum] #2445 +* NMI: Add Network Tokenization support [shasum] #2431 +* Orbital: Pass soft descriptors from options hash [curiousepic] +* Orbital: Update test and production urls [jcowhigjr] #2436 +* Payeezy: Add client_email field for telecheck [davidsantoso] #2455 +* Payeezy: Add customer_id_type and customer_id_number fields [davidsantoso] #2454 +* Quickpay V10: Fix store and token use for recurring payments [wsmoak] #2180 +* Elavon: Support custom fields [curiousepic] #2416 +* WePay: Support risk headers [shasum] #2419 +* WePay: Add Canada as supported country [shasum] #2419 +* Fat Zebra: Fix xid 3D Secure field [curiousepic] +* SafeCharge: Mark support for European countries [curiousepic] +* Checkout V2: Pass customer ip option [curiousepic] +* Realex: Map AVS and CVV response codes [davidsantoso] #2424 +* Opp: Send disable3DSecure custom parameter if present [davidsantoso] #2432 +* SafeCharge: Map standard Active Merchant order_id field [davidsantoso] #2434 +* Payeezy: Default check number to 001 if not present [davidsantoso] #2439 +* Opp: Fix incorrect customParameter key to disable 3DS [davidsantoso] + +== Version 1.66.0 (May 4, 2017) +* Support Rails 5.1 [jhawthorn] #2407 +* ProPay: Add Canada as supported country [davidsantoso] +* ProPay: Add gateway support [davidsantoso] #2405 +* SafeCharge: Support credit transactions [shasum] #2404 +* WePay: Add scrub method [shasum] #2406 +* iVeri: Add gateway support [curiousepic] #2400 +* iVeri: Support 3DSecure data fields [davidsantoso] #2412 +* Opp: Fix transaction success criteria and clean up options [shasum] #2414 + +== Version 1.65.0 (April 26, 2017) +* Adyen: Add Adyen v18 gateway [adyenpayments] #2272 +* Authorize.Net: Force refund of unsettled payments via void [bizla] #2399 +* Barclays ePDQ: removed because it has been replaced by a new API [bdewater] #2331 +* Beanstream: Map ISO province codes for US and CA [shasum] #2396 +* Braintree Blue: Change :full_refund option to :force_full_refund_if_unsettled [bizla] #2403 +* Braintree Blue: Force refund of unsettled payments via void [bizla] #2398 +* Checkout V2: Fix sandbox URL [nicolas-maalouf-cko] #2391 +* Checkout V2: Fix success_from not properly checking two possible success codes [davidsantoso] +* Cybersource: Rescue XML parse exception [shasum] #2380 +* GlobalCollect: Make message and error reporting more robust [curiousepic] #2370 +* GlobalCollect: Set REJECTED refunds as unsuccessful transactions [davidsantoso] #2365 +* GlobalCollect: Truncate firstName field to 15 characters [davidsantoso] +* JetPay: Pass down authorization payment method token to refund a capture [davidsantoso] +* Openpay: Support card points [shasum] #2401 +* Orbital: Don't send CVV indicator if CVV is not present [curiousepic] #2368 +* PayU LATAM: Fix incorrect capture method definition [davidsantoso] +* Payeezy: Support dynamic soft descriptors [shasum] #2384 +* Pin: Add metadata optional field [shasum] #2363 +* Qvalent: Add soft descriptor fields. Add authorize, capture, and void [davidsantoso] +* SafeCharge: Add gateway [davidsantoso] +* SagePay: Support Repeat transactions [curiousepic] #2395 +* Stripe: Support custom application in X-Stripe-Client-User-Agent header [davidsantoso] +* TransFirst Transaction Express: Support ACH [curiousepic] #2389 +* WePay: Support unique_id for idempotent transactions [shasum] #2367 +* Worldpay: Force refund of unsettled payments via void [bizla] #2402 + +== Version 1.64.0 (March 6, 2017) +* Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 +* Authorize.net: Use new `unsupported_feature` standard error code [jasonwebster] #2322 +* Base Gateway: Add new `unsupported_feature` standard error code [jasonwebster] #2322 +* Braintree Blue: Pass cardholder_name with card [curiousepic] #2324 +* Braintree: Add Android Pay meta data fields [jknipp] #2347 +* CardStream: Add additional of currencies [shasum] #2337 +* Credorax: Return failure response reason [shasum] #2341 +* Digitzs: Add gateway [davidsantoso] +* Digitzs: Remove merchant_id from gateway credentials [davidsantoso] +* GlobalCollect: Pass options to Refund [curiousepic] #2330 +* Kushki: Add new gateway [shasum] #2326 +* Kushki: Remove body from void call [shasum] #2348 +* Linkpoint: Raise ArgumentError when trying to instantiate without `:pem` [jasonwebster] #2329 +* Omise: Enable Japan, JPY and JCB support [zdk] #2284 +* PayU LATAM: Count pending refunds as succeeded [curiousepic] #2336 +* PayU LATAM: Let Refund take amount value [curiousepic] #2334 +* Paymill: Send new required fields on tokenization requests [tschelabaumann] #2279 +* Revert "Authorize.net: Allow settings to be passed for CIM purchases" [curiousepic] #2339 +* Sage: Default billing state when outside US [shasum] #2340 +* Stripe: Remove idempotency key from verify [shasum] #2335 +* TransFirst Transaction Express: Don't send order_id with refunds [curiousepic] #2350 +* TransFirst Transaction Express: Fix improper AVS and CVV response code mapping [shasum] #2342 +* WePay: Update API version [shasum] #2349 +* USA ePay Advanced: Add quick_update_customer action [joshreeves] #2229 + +== Version 1.63.0 (February 2, 2017) +* Authorize.net: Add #unstore support [jimryan] #2293 +* AuthorizeNet: Fix line items quirk [shasum] +* CardStream: Add dynamic descriptor option fields [curiousepic] +* CardStream: Support PEN currency [shasum] +* Culqi: Add new gateway [shasum] +* CyberSource: Add Lebanon to supported countries [shasum] +* Element: Add AVS and CVV codes to response [shasum] +* Firstdata E4 (Payeezy): Set correct ECI value for card present swipes [jasonwebster] #2318 +* GlobalCollect: On purchase skip capture if not required [davidsantoso] +* PaymentExpress: Update supported countries [shasum] +* Remove leading or trailing whitespace from credit card name [davidsantoso] +* Remove support for Ruby 2.0 [jasonwebster] +* Secure Pay AU: Add scrubbing support to Secure Pay AU [bruno] #2253 +* Stripe: Fix error in handling of track-only contactless EMV data [jasonwebster] +* Vanco: Update test URL [davidsantoso] +* WePay: Build fee structure correctly [curiousepic] +* WePay: Remove null address fields from request [davidsantoso] +* WePay: Update WePay to API version 2016-12-07 [davidsantoso] +* Wirecard: Send customer data in requests [davidsantoso] +* Worldpay: Add session id attribute [shasum] +* Worldpay: Do not default address when not provided [shasum] + +== Version 1.62.0 (December 5, 2016) +* AuthorizeNet: Map to standard AVSResult codes [shasum] +* CitrusPay: Add 3DSecureId field [davidsantoso] +* CyberSource: Only get alpha2 country code when it's a known country [bruno] #2238 +* Fat Zebra: Add scrubbing to Fat Zebra gateway [bruno] #2037 +* Monei: Add US and CA as new supported countries [davidgf] #2209 +* NAB Transact: Add scrubbing to NAB Transact [bruno] #2038 +* iATS: Add scrubbing support to iATS [bruno] #2228 +* Stripe: Ensure ECI values for tokenized cards are padded [jasonwebster] #2250 +* Forte: Fix incorrect authorization_code response mapping [davidsantoso] +* maxiPago: Send currency with request [curiousepic] +* Credorax: Map order_id to field H9 [curiousepic] +* Authorize.net: Remove duplicate country GB [shasum] +* PayU Latam: Add processWithoutCvv2 field [shasum] +* Fat Zebra: De-nest soft descriptor fields [curiousepic] +* Credorax: Only pass c5 field for billing address1 [davidsantoso] +* Orbital: Add support for CLP currency [curiousepic] +* Authorize.net: Add line item fields and additional transaction settings [shasum] +* Authorize.net: Pass through `header_email_receipt` [shasum] +* Stripe: Scrub additional network tokenization related sensitive data [jasonwebster] #2251 +* Applying: Worldpay: Format non-fractional currency amounts correctly [jasonwebster] #2267 + +== Version 1.61.0 (November 7, 2016) +* Add codes AQ, BQ, SX, and SS to list of countries and update SD numeric code [zxlin] +* AuthorizeNet: Update supported countries list [shasum] +* Barclay SmartPay: Add support for credit [shasum] +* Barclaycard SmartPay: Update supported countries [shasum] +* BluePay: Add Canada to supported countries list [shasum] +* BlueSnap: Update countries list [shasum] +* Braintree Blue: Add Android Pay support [mrezentes] +* Braintree Blue: Add remote test to verify card token [shasum] +* Braintree Blue: Get Android Pay tx id from payment method, not options [mrezentes] +* CardStream: Add MXN currency code [curiousepic] +* CardStream: Set captureDelay to zero on purchase [davidsantoso] +* CitrusPay: Add gateway [duff] +* CitrusPay: Update URL to current API version [davidsantoso] +* Clearhaus: Fix refund of captures [duff] +* Clearhaus: Update list of non fractal currencies [curiousepic] +* Clearhaus: Use localized amount [curiouspic] +* Conekta: Add void action [MauricioMurga] +* Credorax: Add gateway support [davidsantoso] +* CyberSource, Paymill, Payflow: Add verify_credentials [duff] +* CyberSource: Combine auth_reversal with Void [curiousepic] +* CyberSource: Increase merchant defined data fields [davidsantoso] +* CyberSource: Look up alpha2 country code [curiousepic] +* CyberSource: Use localized_amount [curiousepic] +* Element: Pass order_id and shipping address [curiousepic] +* Fat Zebra: Add cavv, xid, and sli fields [curiousepic] +* Fat Zebra: Fix improper descriptor nesting [curiousepic] +* Find countries if they are differently cased [curiousepic] +* GlobalCollect: Update credit card brand list [curiousepic] +* Jetpay: Support endpoint for Canada [shasum] +* Linkpoint: Clean whitespace from PEM [curiousepic] +* Litle: Retain amount to send in auth reversals [curiousepic] +* Litle: add scrubbing support [bruno] +* MONEI: Update supported countries list [davidgf] +* MiGS: Handle IDR currency [curiousepic] +* Migs: Add support for void [mohsenottello] +* Migs: Support some additional fields [duff] +* Moneris: Fix unit test stubs [shasum] +* Moneris: add scrubbing support [bruno] +* NMI, FirstData: Support verify_credentials [curiousepic] +* Openpay: Add support for verify [duff] +* PayJunctionV2: Add gateway support [shasum] +* PayU Latam: Add new gateway [shasum] +* PayU Latam: Update supported countries list [shasum] +* Payflow: Update supported countries list [shasum] +* PaypalExpress: Add SoftDescriptor field [talyssonoc] +* Redsys: Added DOP and CRC currency [davidsantoso] +* Sage: Add support for scrubbing [bruno] +* SagePay: Fix truncation [duff] +* SecurionPay: Update supported countries list [shasum] +* Stripe: Increase authorize amount during verify [davidsantoso] +* Stripe: Set minimum authorize amount depending on currency [davidsantoso] +* Stripe: Support new network tokenization API params [methodmissing] +* Stripe: Update supported countries list [shasum] +* TNS and CitrusPay: Support scrub and verify_credentials [duff] +* TNS and CitrusPay: Update to version 36 of the API [duff] +* TNS: Try TLS v1 [duff] +* Telr: Add gateway support [curiousepic] +* TransFirsTransactionExpress: Remove blank cvv element [davidsantoso] +* TransFirsTransactionExpress: Take into account blank string CVV [davidsantoso] +* Vanco: Improve handling of success determination [duff] +* Worldpay: Add hcgAdditionalData element [davidsantoso] +* Worldpay: Report error code [curiousepic] + +== Version 1.60.0 (July 4, 2016) +* Orbital: Fix CC num leak on profile calls [drewblas] +* VisaNetPeru: Add ability to refund [duff] +* AuthorizeNet: Fix store using new profile [duff] +* Clearhaus: Support private key for signature [curiousepic] +* Clearhaus: Copy private_key when stripping [curiousepic] +* CertoDirect: Remove gateway [shiroginne] +* Braintree: Extra error messaging [jordan-brough] +* AuthorizeNetCim: Set error code for AuthorizeNetCimGateway response [ka8725] +* Quickpay v10: Remove amount requirement for store [curiousepic] +* PSLCards: correct namespace in doc for Response object from ActiveRecord::Billing to ActiveMerchant::Billing [CJ Keeney] +* Pagar.me: Add pagar.me [chrisenytc] +* Stripe: Update Readme to show stripe support [rhlrjv] +* Orbital: Add support for the BRL currency [duff] +* GlobalTransport: Require TLSv1 [duff] +* Openpay: Allow currency to be specified [darkaz] +* DataCash: Use API version 2 [curiousepic] +* Stripe: Support verify_credentials [duff] +* AuthorizeNet: Support verify_credentials [duff] +* BraintreeBlue: Support verify_credentials [duff] +* Redsys: Added SAR currency [agseco] +* QuickPay: Adding customer_ip for authorize action in quickpay [dinesh] +* MaxiPago: add void and refund [shasum] +* MaxiPago: Allow processor_id override [duff] +* Stripe: Interpret string input to store method as token identifier [bizla] +* MaxiPago: Add verify and scrub [shasum] +* Stripe: Remove metadata restriction from EMV transactions [bizla] +* SagePay: Add optional fields to SagePay requests [cristianstanescu] +* CyberSource: Assign default with override for billing address and email [shasum] +* CyberSource: Assign default order_id [duff] +* TNS: Support asia_pacific endpoint [curiousepic] +* TransFirsTransactionExpress: Fix exception [duff] +* CyberSource: Add decision manager optional fields [shasum] +* CyberSource: Add decision manager optional fields [shasum] +* TNS: Add support for TLS v1.2 [curiousepic] +* QuickpayV7: Default description field for store operation [duff] +* Elavon: Support customer_number field [duff] +* Map test_mode_live_card code to new standard error code [berkcaputcu] +* Elavon: Pass customer_number correctly [duff] +* Stripe: add SG to supported_countries attribute [timbeiko] + +== Version 1.59.0 (May 18, 2016) +* Orbital: Allow AVS parts to be sent sans country [duff] +* SecureNet: Return the right error message for declines [duff] +* Moneris: Add verify [anellis] +* Moneris: Add verify [anellis] +* Jetpay: Add support for origin field[anellis] +* Jetpay: Don't default origin field [duff] +* GlobalCollect: New gateway support [curiousepic] +* Openpay: Use strict_encode64 [duff] +* Sage: Always pass along the billing state [duff] +* VisaNet Peru: New gateway support [shasum] +* Worldpay: Allow installationId to be specified at transaction time [duff] +* SecurionPay: Support store [shasum] +* Barclaycard Smartpay: Proper AVS return codes [curiousepic] +* VisaNetPeru: Pass through CVV [duff] +* Barclaycard Smartpay: Use strict_encode64 [duff] +* VisaNetPeru: Fix error when billing address empty [shasum] +* Vanco: Update live_url [duff] +* Cardstream: Reference purchase [curiousepic] +* Paymill: Fix error handling [methodmissing] +* Latitude19: New gateway support [shasum] +* BraintreeBlue: remove invalid test assertions [prburke] +* Merchant e-Solutions: Pass order_id with capture [curiousepic] +* CyberSource: Add rescue for ResponseErrors [curiousepic] +* AuthorizeNet: Always pass recurringBilling flag if present [curiousepic] +* S5: Pass order_id to TransactionID [curiousepic] +* NMI: Set ACH sec_code from options if present [curiousepic] +* VisaNet Peru: Refactor merchant_id and purchase_number handling [shasum] +* Braintree Blue: Pass descriptor_url field [curiousepic] +* VisaNet Peru: Add merchant_define_data option [duff] +* Merchant e-Solutions: pass optional 3Dsecure params [curiousepic] +* NMI: Fix refunds and voids of echecks [duff] +* VisaNet Peru: Pass dummy email when not present [curiousepic] +* PayU India: Add Maestro as supported card [curiousepic] +* Cashnet: Don't retry [duff] +* CardStream: Make Void call Cancel instead of Refund [curiousepic] +* Remove AN and KV country codes as they're not recognized by ISO-3166-1 [apdunston] +* Worldpay: Pass unchanged amount with correct currency exponent [curiousepic] +* Improve our handling of currencies sans fractions [duff] +* Stripe: Added support for the contactless magstripe entry mode option [rbalsdon] +* VisaNet Peru: Change money format to dollars [shasum] +* BlueSnap: Add gateway [duff] +* VisaNet Peru: Select the most meaningful gateway error message [shasum] +* SecurionPay: Update country list [duff] +* Support for BIN 2 MasterCard brand detection [rbalsdon] +* CardStream: Fix signature calculation [duff] +* CyberSource: Update test and live URL [marquisong] +* AuthorizeNet: Truncate nameOnAccount field [duff] +* Tns: Fix ipAddress field [duff] +* WorldNet: New gateway support [varyonic] +* BraintreeBlue: Allow channel override [duff] +* MerchantWarrior: Use Truncated Order Id [ThereExistsX] + + +== Version 1.58.0 (March 1, 2016) +* Move Electron check out of CreditCard into CreditCardMethods [ThereExistsX] +* CardStream: Add AED and NZD currencies [sdball] +* App55: Remove Gateway [ThereExistsX] +* Mercury: Stripping the start and end sentinels on card-present track data for max-length track1 requests [ryanbalsdon] +* SagePay: Update VISA Electron ranges [sdball] +* Clearhaus: Make request signing more transparent & robust [sdball] +* NCRSecurePay: Fix production URL [rwdaigle] +* Add ACH support to Stripe [sdball] +* PayPal Express: Fixing list of currencies without fractions [Krystosterone] +* Cashnet: Default custcode option and proper redirect handling [rwdaigle] +* TransFirst: Fix missing address and remove CC only fields for ACH [davidsantoso] +* More prominent links to contribution docs [rwdaigle] + + +== Version 1.57.0 (February 1, 2016) +* AuthorizeNetCim: Add unmaskExpirationDate option [RamilGilmanov] +* Element: Add gateway support [davidsantoso] +* Cardstream: 3D-secure capture fix [duff] +* Auth.net: Update store to create payment profiles [davidsantoso] +* CyberSource: Add support for mdd_fields [duff] +* Worldpay: Add support for verify [davidsantoso] +* Element: Add guard clause to handle undocumented errors [davidsantoso] +* Clearhaus: Add tests for signed requests [anellis] +* Stripe: Support adding cards to account [anellis] +* Clearhaus: Add text_on_statement option [anellis] +* Payeezy: Void and verify support [davidsantoso] +* Creditcall: Use ecommerce rather than cnp [duff] +* Payeezy: Add support for echecks [davidsantoso] +* Bridgepay: Add ability to store cards and pay with token [anellis] +* Initial support for Android Pay network tokenization cards [mrezentes] +* Transfirst: Fix exception when not all eCheck information is present [davidsantoso] +* Auth.net: Add tests for echeck refunds [davidsantoso] +* Transfirst: use default values for some eCheck data [davidsantoso] +* Element: Update the live URL endpoint [davidsantoso] +* Element: Parse responses from unexpected API errors [davidsantoso] +* Transfirst: Remove unused fields for echeck [davidsantoso] +* Sage: Internal refactoring into a single gateway class w/ common http conn [anellis] +* Cardstream: Adjust authorize and capture transactions [anellis] +* NCRSecurePay: New gateway support (Monetra white-label) [rwdaigle] +* Element: Map ReferenceNumber to order_id [duff] +* Element: Use a better MotoECICode default [duff] +* BraintreeBlue: Return transaction id for failed transactions when available [prburke] +* PayPal: Add InContextPaypalExpressGateway [xuorig] +* TransFirst: CVV is a required tag [duff] +* Checkout V2: Add Descriptor Name and City Options [anellis] +* Forte: Pass order_id [anellis] +* Merchant ESolutioins: Truncate order_id [anellis] +* Transfirst Transaction Express: New gateway support [sdball] +* Stripe: Add `stripe_account` header option [anellis] +* Cardstream: Add AVS code and message [anellis] +* Barclaycard Smartpay: New gateway support [curiousepic] +* Transfirst: Fix missing address and remove CC only fields for ACH [davidsantoso] +* Stripe: Support ACH payments [sdball] +* NCRSecurePay: Fix production URL [rwdaigle] +* Clearhaus: Make request signing more transparent & robust [sdball] +* SagePay: Properly detect Electron brand [sdball] +* Mercury: Fix for max-length track 1 [ryanbalsdon] + + +== Version 1.56.0 (December 1, 2015) +* Add Cardknox gateway [dlehren] +* Mercury: Add support for card present track 2 [ryanbalsdon] +* Cardstream: Improve default currency handling [duff] +* Mercury: Strip start and end sentinels on track 2 [ryanbalsdon] +* Redsys: Support new SHA256 authentication method [davidsantoso] +* Cashnet: Allow custcode override [duff] +* Add Rails 5 support [rafaelfranca] +* Set required Ruby version for install to 2 or greater [rafaelfranca] +* JetPay: Pass ud_fields in capture too [duff] +* Stripe: Correctly detect test mode refunds [aprofeit] +* Fix variables in remote gateways test template [sdball] +* Micropayment: Update fieldnames for new API [duff] +* Fix CreditCard#valid_number? erroring on non-digit characters [PatrickTulskie] +* Stripe: Correctly detect test mode voids [methodmissing] +* Garanti: Add test mode URL and update remote test credentials [cbilgili] +* Cashnet: Allow custcode override on refund [duff] +* Omise: Add a new optional api_version config [zdk] +* Elavon: Include IP address in purchase and authorize requests [aprofeit] +* TransFirst: Add support for ACH and more operations [davidsantoso] +* FirstData_e4: Fix void for even dollar transactions [duff] + +== Version 1.55.0 (November 9, 2015) +* CyberSource: send customer IP address when provided [fastjames] +* Braintree: Simplify Braintree scrubbing when no transcript [duff] +* AuthorizeNet: Allow market_type override [duff] +* FirstData_e4: Support level_2 data [duff] +* FirstData_e4: Fix level_2 and level_3 [duff] +* MerchantWareFour: Use Void not PreAuthorizationVoid [duff] +* JetPay: Allow partial captures [duff] +* Creditcall: Fix production url [duff] +* FirstData_e4: Fix float error in Void [duff] +* Micropayment: Upgrade to new API [mrezentes] +* Netbilling: Add order_id to user_info [mrezentes] +* Stripe: scrub swipe/track, EMV data out of gateway transcripts [girasquid] +* Remove integration_mode [mattfawcett] +* Allow setting CVV requirement at instance level [fabiokr] +* Add SecurionPay gateway [szajbus] +* AuthorizeNet: Don't send currency to void [duff] +* Add Komoju gateway [k2nr] +* Replace Connection magic numbers with constant references [larrylv] +* Add CAMS gateway [trevorgrayson] +* PayPal Express: Fix AllowedPaymentMethod [edclements] +* Litle: Store credit card from PayPage [dontmatta] +* Orbital: Deprecate profile management API [ntalbott] +* FirstData e4: Honor currency when supplied [tchill] +* Authorize.net: Add config_error standard error code [andrewpaliga] +* PayPal Express: Add support for TotalType in SetExpressCheckout [gingerhendrix] +* eWay Rapid: Add :invoice option [DylanFM] +* Braintree: Add nonce payment method [eric1234,cwoodcox] +* Payflow: Allow passing of 3D Secure details via options [marquisong] +* Elavon: Support capture via CCCOMPLETE without credit card [marquisong] +* Securenet: Allow setting test_mode independently [wedstar] +* Replace Base.integration_mode and Base.gateway_mode with just Base.mode [aprofeit] +* Micropayment: Allow specification of a project [duff] +* QuickpayV10: Truncate order_id [duff] +* FirstData_e4: Fix Level 2 data [duff] +* Remove some duplication around name handling [duff] +* FirstData_e4: Support Tax1Number [duff] +* Add Transact Pro gateway [varyonic] +* Add Payeezy gateway [huoxito] +* USAePay: Add test mode setting via options [marquisong] +* Add Clearhaus gateway [dinesh] +* WorldpayOnlinePayments: Fix logic to determine success [ao] +* Paymill: store order_id in description field [nikoloff] +* TWD isn't a zero decimal currency [duff] +* PaypalExpress: Use custom zero decimal currencies [duff] +* Stripe: Migrate from /refund to /refunds [matthelm] +* Bogus: Adding basic EMV support [ryanbalsdon] +* PayBox Direct: Refunds and working test credentials [ivanfer] +* Vanco: Handle case of no billing_address [duff] +* BluePay: Add support for CUSTOM_ID2 field [ajporterfield] +* Creditcall: Handle no verification_value [duff] + +== Version 1.54.0 (October 2, 2015) +* Beanstream: Add Network Tokenization support [girasquid] +* CenPOS: Allow order_id on void [duff] +* Provide better insight to CVV usage in requests [davidsantoso] +* Ogone: Add verify [duff] +* Beanstream: Add verify [mrezentes] +* PayPal: Map standard error codes [JakeCataford] +* Checkout.com: Fix an issue with empty phone numbers. [anotherjosmith] +* Quickpay: Edit store and add ability to purchase with stored card [anellis] +* Stripe: Set `receipt_email` to Stripe request if receipt delivery is requested [miccheng] +* Worldpay US: Add eCheck support [mrezentes] +* FirstData_e4: add level_3 data [mrezentes] +* Vanco: Support passing ip address [duff] +* Paybox Direct: Currency parsing fix [ivanfer] +* QuickpayV10: Remove currency requirement from store. [anellis] +* Raven: Use TLS 1.2 endpoint [bslobodin] + +== Version 1.53.0 (September 1, 2015) + +* Redsys: Add a number of currencies [agseco] +* Raven: update description, test url, and routing; fix tests [bslobodin] +* Raven: do not pass default (incorrect) PaymentType to #void [bslobodin] +* Add scrubbing to a number of gateways [anellis] +* BluePay: Add scrubbing [anellis] +* BraintreeBlue: Allow custom logger [duff] +* MerchantWareFour: Truncate invoiceNumber [duff] +* S5: Pass recurrence_mode in store [duff] +* QuickPay: Support 2-letter country codes in V10 API [girasquid] +* Stripe: Support validate:false field on store [anellis] +* CheckoutV2: Use correct live_url [duff] +* QuickPay: strip # from Order IDs before submission [girasquid] +* Litle: Use schema version 9.4 rather than 8.18 [anellis] +* Litle: Add decrypted apple_pay [anellis] +* QuickPay: fix method signature on #void [girasquid] +* Forte: Add gateway [davidsantoso] +* Stripe: return refund id for refund authorization [anellis] +* Paypal: Update api version [anellis] +* TNS: Translate countries to alpha3 codes [anellis] +* TNS: Handle non existent country [duff] +* TNS: Rescue Errors [anellis] +* CenPOS: Support avs_result and cvv_result [tjstankus] +* Stripe: Add application fee only on non-EMV transactions [bizla] +* Stripe: don't send blank, non-nil values [girasquid] +* Ogone: Send different auth type for mastercard [anellis] +* Cardstream: Add "type" field support [rwdaigle] +* Cardstream: 3dsecure transaction option [rwdaigle] +* Paystation: Map order_id to non-unique merchant reference field [anellis] +* Cardstream: Check for nil street address [anellis] +* Checkout.com and CheckoutV2.com: Update country list [duff] +* Cardstream: Handle nil addresses [rwdaigle] +* MiGS: Allow passing in currency [alovak] +* [POSSIBLE BREAKAGE] NMI: No longer use auth.net emulator [rwdaigle] +* SecureNet: Add DEVELOPERID if supplied [wedy] +* Braintree: Update country list [duff] +* NMI: Don't include dup_seconds if nil [rwdaigle] +* QuickPay: Make all operations to v10 platform synchronous [ta] +* QuickPay: Handle issue where no operations exists on payment [ta] +* NMI: Support merchant_defined_fields [duff] +* QuickpayV10: Add verify [anellis] +* BraintreeBlue: Use wiredump_device for logging only if present [braintreeps] +* QuickpayV10: Add scrubbing [anellis] +* QuickPayV10: Change tests to point to proper gateway [anellis] +* Monei: Add default options argument [davidgf] +* Ogone: Add additional 3d-secure parameters [ntalbott] +* Ogone: Refactor signature calculation [ntalbott] +* Add Creditcall gateway [davidsantoso] +* Redsys: Fix scrubbing for failed transactions [davidsantoso] +* Micropayment: Support Micropayment gateway [rwdaigle] +* USAePay: Use names from the given billing and shipping address [marquisong] +* Stripe: Add application fee on EMV authorize calls [bizla] + +== Version 1.52.0 (July 20, 2015) + +* Authorize.Net: Add device type to authorize.net retail requests [abecevello] +* Vanco: Change transaction type to WEB for echecks [duff] +* PayPal: Allow soft descriptor to be specified [davidsantoso] +* Authorize.net: Add disable_partial_auth field [anellis] +* SagePay: Add apply_avscv2 field [anellis] +* S5: Add Store [anellis] +* Merchant Ware v4: Add support for verify [davidsantoso] +* Mercury: No longer default to allow partial auth [duff] +* PayPal: Fix soft_descriptor and support soft_descriptor_city [duff] +* Merchant Ware: Add scrubbing [davidsantoso] +* Stripe: Make purchase via vaulted card consistent [duff] +* Moneris: Add network tokenization support [andrewpaliga] +* Ogone: Allow specifying a timeout value for requests [tomhipkin] +* PayU India: Increase allowed txnid to 30 characters [ntalbott] +* Authorize.Net: Allow passing device type through options, make wireless POS the default [abecevello] +* Authorize.Net: Update to new Akamai URL [taf2] +* Braintree: Add hold_in_escrow [anellis] +* Stripe: Allow purchases with tokens without customer specification [bizla] + +== Version 1.51.0 (July 2, 2015) + +* Garanti: Illegal character '&' parsing response [masaruhoshi] +* Stripe: Revert force USD for verify [duff] +* Litle: Surface XML validation errors in the response [jasonbosco] +* Litle: Pass the credit card verification value for tokenization (#store) requests, if one is set. [jasonbosco] +* S5: Make scrubbing regex less greedy [duff] +* CardStream: Add support for verify [anellis] +* Authorize.net: UTF-8 encode requests [duff] +* Banwire: Add default email [anellis] +* PayU India: Handle bad JSON [ntalbott] +* Dibs: Pass CVC param only if there's a value [bruno] +* Sage: Credit really is credit not refund [duff] +* Sage: Add ability to refund [duff] +* Cardstream: Add scrubbing [anellis] +* Litle: Add debt_repayment_flag [duff] +* iATS: Support ACH [rwdaigle] +* CheckoutV2: Add Gateway [anellis] +* CenPOS: Fix refund amount issue [duff] +* Add error_code mapping and error_code_from to gateway generator [jnormore] +* Stripe: Parse EMV ARC from error response [bizla] +* Redsys: Add MYR currency [agseco] +* Add "contactless" flag to credit card model [davidseal] +* Stripe: Add "contactless" flag support to gateway [davidseal] +* Add encrypted_pin data to credit card model [ryanbalsdon] +* Stripe: Add encrypted_pin support to gateway [ryanbalsdon] +* Stripe: Support mapping advanced decline codes to standard codes [abecevello] +* Epay: filter out invalid characters in returned URLs [dwradcliffe] +* Redsys: Strip leading zeroes from currency codes [agseco] +* Authorize.net: Add invoice information to refund [marquisong] +* Authorize.net: Add store ability [duff] +* Paystation: Add refund [mrezentes] +* Paystation: No longer require order_id everywhere [duff] +* Checkout: Support descriptor_name and descriptor_city [duff] +* Add supports_network_tokenization? to gateways [jnormore] +* Bpoint: Handle message for invalid login [anellis] +* TransFirst: Add scrubbing [davidsantoso] +* TransFirst: Add back a few request fields [davidsantoso] + + +== Version 1.50.0 (June 1, 2015) + +* Vanco: Add gateway [duff] +* Conekta: Move device fingerprint to root [MauricioMurga] +* Conekta: Change default language to Spanish [MauricioMurga] +* Vanco: Improve authentication handling [duff] +* Vanco: Allow specification of fund_id [duff] +* S5: Add gateway [davidsantoso] +* SecureNet: Truncate order_id [duff] +* [POSSIBLE BREAKAGE] Stripe: Be explicit about API version [duff] +* Dibs: Add gateway [mrezentes] +* Dibs: Rubyize merchant_id and secret_key [mrezentes] +* Stripe: Add support for reverse_transfer [duff] +* USA ePay: Add support for manual entry indicator [AnotherJoSmith] +* Authorize.Net: Add support for manual entry indicator [AnotherJoSmith] +* CenPOS: Change description to invoice_detail [mrezentes] +* BPoint: Add gateway [tjstankus] +* S5: Remove address requirement for purchase and authorize [davidsantoso] +* Vanco: Add support for eChecks [duff] +* Remove Adyen support [ntalbott] +* CenPOS: Use ProcessCreditCard action [duff] +* CASHnet: uri encode the merchant gateway name [mrezentes] +* S5: Include card brand in request body [davidsantoso] +* Vanco: Handle multiple error responses [duff] +* Merchant Partners gateway support [rwdaigle] +* BPoint: Update params to contain all response data [tjstankus] +* BPoint: Support biller_code in options [tjstankus] +* Sagepay: Add Verify [anellis] +* S5: Build XML with UTF-8 encoding [tjstankus] +* Cashnet: Handle unparsable response body [duff] +* CenPOS: Allow specification of customer_code [duff] +* Allied Wallet: Add gateway [anellis] +* S5: set Regex closure on scrubbing method [davidsantoso] +* Dibs: Require TLSv1 [duff] +* Optimal: Handle case of no billing address [duff] +* Omise: Add gateway [zdk] +* CenPOS: Simplify currency handling [duff] +* Beanstream: Don't treat redirect as success [aprofeit] +* Add PayU India gateway [ntalbott] +* NetBilling: Require TLSv1 [duff] +* S5: Handle recurring transactions without CVV [davidsantoso] +* Stripe: Force USD for verify [duff] +* PayU India: Prevent shadowing in response parsing [ntalbott] +* QuickPay: Add support for v10 API [ta] +* Fat Zebra: Fix refund and store signatures [duff] +* Fat Zebra: Allow transactions without a CVV [duff] + +== Version 1.49.0 (May 1, 2015) + +* Braintree: Add support for AVS error codes [ivanvfer] +* MerchantWarrior: Truncate description field [duff] +* Braintree: Add service_fee_amount option [duff] +* SecureNet: Allow shipping_address[:name] [duff] +* MonerisUS: Add verify [mrezentes] +* Ezic: Add gateway [duff] +* Stripe: Add destination field [cwise] +* SecureNet: Fix ordering of shipping field names [duff] +* SecurePayAu: Update API URL [girasquid] +* Stripe: Add EMV "chip & sign", "chip & offline PIN" and Maestro support [bizla] +* Add Errno::EHOSTUNREACH to NetworkConnectionRetries::DEFAULT_CONNECTION_ERRORS [randito78] +* Stripe: Add support for idempotency keys [michaelherold] +* WePay: Handle JSON::ParserError exceptions [duff] +* Borgun: Update country list and homepage url [mrezentes] +* AuthorizeNet: Add cvv to request only if it's valid [tjstankus] +* Stripe: Bug fix: add amounts only on non-EMV transactions, temporarily omit EMV testcases [bizla] +* Ezic: Add support for void [duff] +* iATS: Update supported countries [mrezentes] +* Ezic: Update supported countries [duff] +* AuthorizeNet: Truncate card number [tjstankus] + +== Version 1.48.0 (April 8, 2015) + +* Clean up `rake gateways:hosts` output [ntalbott] +* Add Axcess MS gateway [timtait] +* Add PayHub gateway [grepruby] +* Orbital: Improve data formatting [boone] +* [POSSIBLE BREAKAGE] USAePay Transaction: Make "void release" the default [dppcode] +* Redsys: Add rudimentary vaulting [varyonic] +* Exact: Handle 401 failures better [jefflaporte] +* SagePay: make `VPSProtocol` user-configurable [boxofrad] +* Netbilling: Add store support [cshepherd] +* Add Qvalent gateway [markabe] +* Expose proxy address and port to gateways [arkes] +* Remove Ruby 1.9 [j-mutter] +* Qvalent: Do not sent order.ipAddress when storing [markabe] +* Qvalent: Fix argument name [bruno] +* Qvalent: map card storage reference to authorization [markabe] +* Qvalent: Fix scrub replacement, it was too greedy [markabe] +* PayConex: Add gateway [duff] +* AuthorizeNet: Add credit support [duff] +* CenPOS: Add gateway [markabe] +* Stripe: Update country list [markabe] +* Add Monei.net gateway [leolara] +* MerchantWarrior: Fix refund and capture signatures [duff] +* CenPOS: Add support for capture and refund [markabe] +* Authorize.net: Add support for network tokenization credit cards [jnormore] +* Stripe: Add support for passing in metadata for auths and purchases [kitt] +* Pin: Pass amount param for captures [ab9] +* NAB Transact: Improve store functionality [duff] +* Add Worldpay Online Payments [ao] +* Fat Zebra: Add multi-currency support [nagash] +* Fat Zebra: Add auth/capture capability [nagash] +* Fat Zebra: Add soft descriptor support [nagash] + +== Version 1.47.0 (February 25, 2015) + +* Authorize.Net: Properly send name in shipping address line, when shipping address is provided [girasquid] +* Payflow: Add verify support [ntalbott] +* Capture ConnectionError#triggering_exception [ntalbott] +* Flo2Cash: Map Reference->:order_id (not :invoice) [ntalbott] +* Flo2Cash: Fix card brand handling [ntalbott] +* Flo2Cash: Improve error handling & simplify "Simple" gateway [ntalbott] +* Remove Vindicia gateway [mutemule] +* Firstdata E4: Support other mastercard string [jcbantuelle] +* Checkout: Disallow altering endpoint via options [markabe] + +== Version 1.46.0 (January 20, 2015) + +* CHANGE: drop `offsite_payments` and `active_utils` as dependencies. [wvanbergen] +* CHANGE: remove `OffsitePaymentShim`. You will have to add offsite_payments as a dependency, + and update any mentions of `ActiveSupport::Billing::Integration` to + `OffsitePayments::Integrations`. [wvanbergen] +* QuickBooks Payments: Add adapter [ivanfer, bizla] +* Quickbooks: Remove requirement of oauth gem. +* PayGate: Add support for refunds [StephanAtG2] +* PayPal: Add #scrub for scrubbing PCI information out of HTTP transcripts [girasquid] +* Stripe: Add #scrub for scrubbing PCI information out of HTTP transcripts [girasquid] +* Cybersource: Add ability to verify a card [duff] +* BraintreeBlue: Expose the error code in the response params [duff] +* eWay Rapid: Update supported countries and card types [incarnate] +* PayPal: Allow specifying ButtonSource at init [ntalbott] +* Payflow: Add fraud_review support [ntalbott] +* Add IPP gateway [InfraRuby] +* Redsys: Fix order_id truncation [duff] +* AuthorizeNet: Improve duplicate_window handling [duff] +* PayPal: Fix ButtonSource bug [ntalbott] +* Checkout: Prevent multiple trackids from being passed [markabe] +* Pin: Handle JSON parsing exception in response [duff] +* Improve test suite to test against multiple ActiveSupport versions [wvanbergen] +* Misc. code cleanup [wvanbergen] +* Add Flo2Cash gateway [markabe] +* Litle: Allow order_source override [duff] +* Quickpay: Add ability to finalize a capture [askehansen] +* AuthorizeNet: Prevent test mode using live gateway [duff] +* Add Flo2Cash Simple gateway [markabe] + +== Version 1.45.0 (December 1, 2014) + +* HPS: Always pass CardHolderData element [SecureSubmit, ntalbott] +* PayJunction: Include 'track' parameter if provided [hron] +* WebPay: Fix API calls [tomykaira] +* Moneris US: Add store, unstore, and update [AntoineInsa] +* Moneris US: Add CVV and AVS [AntoineInsa] +* Stripe: Add support for statement_description [markabe] +* CASHNet: Add support for fname and lname [markabe] +* Orbital: Fix customer profile auth/purchase [denis] +* Payex: Fix expiry month to allow 4 digit year [duff] +* Cashnet: Allow overriding custcode [hoenth] +* Cashnet: Fix overridding item_code per transaction [ntalbott] +* Add Checkout.com gateway [ravish-ramrakha-cko] +* HPS: Add verify support [SecureSubmit] +* Add Bank Frick gateway [varyonic] +* Add Global Transport gateway [duff] +* iATS: Add #store and #unstore [duff] +* Authorize.Net: Fix amount formatting [ntalbott] +* Authorize.Net: Truncate order_id to 20 characters [ntalbott] +* Authorize.Net: Truncate more fields [duff] +* Authorize.Net: Truncate invoiceNumber [ntalbott] +* Adyen: Add support for verify operation [duff] +* USAePay: Add track_data support [louiskearns] +* Payex: Use the right url for the purchase call [duff] +* Braintree: Allow dynamic descriptors [duff] +* Openpay: Add support for device session id [guillermo-delucio, ismaelem] +* Redsys: Add support for verify [duff] +* Redsys: Handle unknown currencies [duff] +* Stripe: Make #unstore signature consistent [duff] +* Remove defunct Samurai gateway [ntalbott] +* eWay Rapid: Tweak authorization support [duff] +* Litle: Add support for dynamic descriptors [duff] +* Add TNS gateway [markabe] +* TNS: Update countries and supported card types [markabe] +* Conekta: Add AMEX as a supported card type [MauricioMurga] +* Checkout: pass through currency type [markabe] +* Bogus: return standard error codes [jpcaissy] +* Add PaymentToken and ApplePayPaymentToken objects for token-based transactions [bizla] +* Authorize.Net: Add ApplePay in-app transaction support [bizla] +* Stripe: Add ApplePay in-app transaction support [bizla] +* eWAY Rapid: Add PartnerID param [j-mutter] +* GlobalTransport: Truncate order_id [duff] +* Redsys: Allow a description to be specified [duff] +* NetworkMerchants: Fix currency [j-mutter] +* Redsys: Improve handling of order_id [duff] +* Checkout: Add support for void, refund, and verify [markabe] + +== Version 1.44.1 (Aug 28, 2014) + +* Allow SSLv3 for PsiGate [mutemule] +* Set default :state to n/a for NetworkMerchants [cjoudrey] + +== Version 1.44.0 (Aug 21, 2014) + +* Moneris: Add :avs_enabled option [bslobodin] +* Stripe: Populate authorization in failed responses, when available [bslobodin] +* Moneris: Use the name on the card [duff] +* Balanced: More 1.1 API fixes and mappings [ntalbott] +* Balanced: Handle "pending" refunds [duff] +* Immediately convert credit card date fields to integers [ntalbott] +* Balanced: Handle outside card tokens [ntalbott] +* Balanced: Do not pass address if zip is missing [ntalbott] +* Float active_utils at the patch version instead of the minor version [nwjsmith] +* Wirecard: Fix CVV & AVS response handling [alevett] +* Consolidate deprecation handling [ntalbott] +* Authorize.Net CIM: Do not send x_test_request [danrabinowitz] +* Authorize.Net CIM: Pass delimiter through [jsoma] +* HPS: Add support for track data [SecureSubmit] +* HPS: Fix processing without an address [SecureSubmit] +* Balanced: Do not pass address if zip is blank [duff] +* Do CreditCard attribute cleanup at assignment [ntalbott] +* eWay Rapid: Add auth/capture/void support [ntalbott] +* [POSSIBLE BREAKAGE] Remove dependency on active_utils Validateable [ntalbott] +* Make all active_utils requires explicit [ntalbott] +* Balanced: Handle legacy card tokens [ntalbott] +* Braintree Blue: Default verification merchant id [speric] +* [POSSIBLE BREAKAGE] Extract integrations into an offsite_payments gem [ntalbott] +* [POSSIBLE BREAKAGE] Drop stated/tested compatibility with Rails < 3.2 [ntalbott] +* Stop requiring unused CurrencyCode class from active_utils [ntalbott] +* Move ActiveMerchant::Error into ActiveMerchant [ntalbott] +* Inline RequiresParameters in Gateway & move Country from active_utils [ntalbott] +* Quickpay v7: Fix passing acquirers field [moklett] +* Quickpay v7: Pass an amount when storing cards [ta & moklett] +* Quickpay: Expand list of supported countries [ta] +* Validate CreditCard verification value [mnoack] +* Authorize.Net CIM: Allow updating a payment profile without a full credit card number [speric] +* Wirecard: Add optional CommerceType element [timtait] +* Add Borgun gateway [markabe] +* [POSSIBLE BREAKAGE] NAB Transact: Allow timeout customization [duff] +* Wirecard: Add card store and purchase/authorize by reference [speric] +* Worldpay: Add support for Switch cards [dougal] +* FirstData e4: Send correct card type [npverni] +* Elavon: Add store/update support [npverni] +* Wirecard: Catch an empty ERROR Element [timtait] +* Finansbank (CC5): Add void/refund/credit support [muhammetdilek] +* Wirecard: Use authorization_check for Amex store [npverni] +* Elavon: Make void work for authorizations [duff] +* Add Commercegate gateway [vitaliyvasin] +* Wirecard: Fix "amex" references [mendable] +* HPS: Do not pass empty elements [SecureSubmit] +* Paymill: Add more supported card types [nikoloff] +* Paymill: Add source [nikoloff] +* Paymill: Add description for preauthorizations [nikoloff] +* Paymill: Add remote tests using tokens [nikoloff] +* HPS: Add developer, version number and site trace options [SecureSubmit] +* Update 1stPayGateway.Net gateway [rwdaigle] +* Payflow: Add verbosity option [doppler] +* Allow ignoring the result of any MultiResponse step [ntalbott] +* Stripe: Add ability to verify a card [duff] +* Paypal: Add ability to verify a card [duff] +* Authorize.net: Add ability to verify a card [duff] +* Braintree: Add ability to verify a card [duff] +* Enhance gateway generator to support verify [duff] +* PayPal Express: Add funding source support [baraabourghli] +* Optimal: Add IP address to requests [justinplouffe] +* Pin: Add authorize & capture support [keithpitt] +* Pin: Add update support [keithpitt] +* Vindicia: Stop using the vindicia-api gem [ntalbott] +* Clean up the warnings fog [ntalbott] +* Quickpay: Map options[:ip] for fraud analysis [ta] +* SagePay: Truncate fields [duff] +* First Data E4: Add ability to verify a card [duff] +* Elavon: Add ability to verify a card [duff] +* Worldpay: Pass email and IP address [duff] +* Worldpay: Use updated address format [duff] +* Moneris: Fix address splitting [ntalbott] +* FirstData E4: Allow passing CAVV through [Senjai] +* Braintree Blue: Remember the capture transaction id [duff] +* Eway Rapid: Truncate some fields [duff] +* Optimal Payment: Make account mandatory field [rwdaigle] +* Worldpay: Improve address defaulting [duff] +* Authorize.Net: Add maestro as a supported card type [vparihar01] +* Worldpay: Improve address defaults [duff] +* Braintree Blue: Pass cardholder_name when tokenizing [radar] +* Wirecard: Improve error handling [mendable] +* Litle: Add verify support [markabe] +* USAePay: Add verify support [markabe] +* BridgePay: Add verify support [duff] +* Braintree Blue: Add payment_method_token flag [JDutil] +* SagePay: Add optional FI fields [rob-anderson] +* Iridium: Add AVS and CVV results [X0Refraction] +* NAB Transact: Add credit support [nagash] +* Braintree Blue: Add application_id support [npverni] +* Realex: Add maestro mapping [uriklar] +* Add Worldpay US gateway [markabe] +* Cybersource: Add shipping address [pkoppula] + +== Version 1.43.2 (May 12, 2014) + +* Remove 2Checkout's #line_item due to conflict with Klarna/Shopify [edward] +* Auth.Net CIM: Fix ordering of order/trans_id [pdamer] +* Add PagoFacil gateway [bhserna, abisosa] +* [POSSIBLE BREAKAGE] Stripe: Allow for updating of stored card [speric] +* Authorize.Net: Deprecate ARB [ntalbott] +* Authorize.Net CIM: Add recurring billing flag [gabealmer] +* Spreedly: Add support for :ip [megamoose] +* PayPal Express: Improve received_at handling [jwarchol] +* PayPal Express: Add ReqBillingAddress flag [johnb-razoo] +* Beanstream: Add support for Legato single use tokens [tylerrooney] +* PayPal Digital Goods: Allow mobile [tomprats] +* Maxipago: Add installment support [alexandremcosta] +* Deprecate recurring API support [ntalbott] +* NMI: fix CreditCard check [bslobodin] +* SagePay: Add tokenization support [kernow] +* PayPal Express: Reference transaction details [lrostovsky] +* Balanced: Update to API 1.1 [steveklabnik] +* Add Cashnet gateway [hoenth] +* Conekta: Standardize address options [MauricioMurga] +* Wirecard: Add support for reference purchases [timtait] +* Worldpay: Add support for external references [matsubo] +* Balanced: Voiding a capture is not allowed [duff] +* Add HPS gateway (Heartland Payment Systems) [SecureSubmit] +* Balanced: Fix handling of 500 errors [ntalbott] +* Universal: Remove all billing address fields [bslobodin] +* Balanced: Stop creating a customer on each call [ntalbott] +* Balanced: Refactor and handle legacy authorizations [ntalbott] +* SagePay Form: Update to v3.00 [bslobodin] +* GestPay: Use a more specific error class when parsing [odorcicd] +* PagSeguro: Improve error handling [celsodantas] +* PxPay: Support for newer, query-less redirect URLs [odorcicd, bslobodin] +* eWAY Rapid: Update to 3.1 API [atomgiant] +* Misc refactorings [justinplouffe] +* Remove greedy rescue, and convert some errors to be user-facing [odorcicd] +* PayPal Express: pass logo image for setup request [dimko] +* Improve credit card validation [duff] + +== Version 1.43.1 (May 1, 2014) + +* Merchant Warrior: Scrub names [duff] +* Validate Gateway.supported_countries [rwdaigle] +* Stripe: Add recurring flag support [bslobodin] +* Stripe: Use localized amounts for currencies w/o minor units [bslobodin] +* WebPay: Leverage fixes to Stripe to remove duplicate code [bslobodin] +* Klarna: Miscellanenous fixes [edward] +* Mollie iDEAL: Use order's description [wvanbergen] + +== Version 1.43.0 (April 24, 2014) + +* PagSeguro: New offsite integration [celsodantas] +* Sage Pay: Fix amount parsing in notifications [berkcaputcu] +* Sage Pay: Use API v3.00 [bslobodin] +* BridgePay: Switch method of success detection [markabe] +* BridgePay: Use Return as TransType for refunds [markabe] +* IATS: Complete rewrite using first class API [rwdaigle] +* IATS: Fix invalid country code UK -> GB [rwdaigle] +* DataCash: Fix refund processing using original authorization [bslobodin] +* Transnational gateway renamed to Network Merchants [bslobodin] +* PayMill: Handle non-JSON server responses [bslobodin] + +== Version 1.42.9 (April 15, 2014) + +* Spreedly: Add ip, description and gateway_specific_fields [faizalzakaria] +* Sage (US): Support store/unstore of cards [rwdaigle] +* Pin: Add american express to supported cards [nagash] +* Raven: Update handling of CVV/AVS [bslobodin] +* Raven: Use UUID for RequestID [bslobodin] + +== Version 1.42.8 (April 4, 2014) + +* Cecabank: Handle invalid xml response body [duff] +* Wirecard: Capture error code in the response [duff] +* Litle: Remove gem dependency [duff] +* Litle: Fix case of missing address parts [duff] +* Universal: Add universal offsite API implementation [bslobodin] +* Iridium: Add more currencies [bslobodin] +* iDeal: Add Mollie iDeal offsite implementation [wvanbergen, maartenvg] + +== Version 1.42.7 (March 18, 2014) + +* SagePay: Add support for ReferrerID [markabe] +* Cecabank: Fix expiration date formatting [duff] +* Add WePay gateway [faizalzakaria] +* SmartPs: Add ECI option to SmartPs [odorcicd] +* Rescue and re-raise ActionViewHelperError when offsite helpers raise an error [odorcicd] +* Add FirstGiving gateway [faizalzakaria] +* FirstGiving: Fix refunds [ntalbott] +* Samurai: Handle server errors [ntalbott] +* WePay: Fix refund [duff] + +== Version 1.42.6 (February 24, 2014) + +* Litle: Truncate order_id [duff] +* Conekta: Fix #refund; respect :currency [leofischer] +* SagePay: Truncate description field [duff] +* Add Cecabank gateway [molpe] +* Add Openpay [darkaz] +* Openpay: Simplify test versus production mode [duff] +* Wirecard: Handle a utf-8 description [duff] +* Litle: Partial capture support [ttdonovan] +* Ogone: Allow D3D for alias purchases [pwoestelandt] +* USAePay Advanced: Fix verification_value mapping [dppcode] +* Orbital: Add additional success conditions [boone] +* Orbital: Handle special CVV responses [boone] +* Balanced: Allow working with balanced.js [michaelherold] +* Balanced: Allow passing customer name [michaelherold] +* Balanced: Add support for meta [michaelherold] +* Improve gateway generator [ntalbott] +* Add maxiPago gateway [alexandremcosta] +* Authorize.Net: Remove x_test_request support [ntalbott] +* Conekta: Add default description [bslobodin] +* Add PayDollar integration [bslobodin] + +== Version 1.42.5 (February 7th, 2014) + +* Add Doku Indonesia [bizla] +* Cardstream: Update gateway to use latest API [odorcicd] + +== Version 1.42.4 (January 8th, 2014) + +* DataCash: Set 'ecomm' as capturemethod [DavidGeukers] +* Cybersource: Fix subscriptions with a setup fee [ntalbott] +* Stripe: Do not pass customer details to the /cards endpoint [michellebu] +* Stripe: Allow Stripe API version to be initialized with the gateway [odorcicd] + +== Version 1.42.3 (December 18th, 2013) + +* Balanced: Add support for appears_on_statement_as [duff] +* Authorize.Net: Make already actioned responses failures [odorcicd] +* Add Payex gateway [atomgiant] +* Paymill: Fix authorizations [duff] +* Braintree Blue: Allow specifying the credit card token [ntalbott] +* Braintree Blue: Allow specifying the customer id [ntalbott] +* Braintree Blue: Scrub invalid emails and zips [ntalbott] +* Braintree Blue: Return :credit_card_token as a top level param [ntalbott] +* Braintree Blue: Allow unstoring just a credit card [ntalbott] +* Braintree Blue: #store adds cards to existing customers [ntalbott] +* USA ePay Advanced: Fix check handling [nearapogee] +* USA ePay Advanced: Fix credit card expiration handling [nearapogee] +* USA ePay Advanced: Fix handling of custom transaction responses for single items [nearapogee] +* USA ePay Advanced: Fix capture amount [nearapogee] +* NAB Transact: Fix merchant descriptor with capture/refund requests [nagash] +* Braintree Blue: Add custom_fields & device_data parameters [parallel588] +* Webpay: Add authorize & capture [keikubo] +* MerchantWarrior: Pass description [duff] +* Stripe: Separate email from description [duff] +* Add Payscout gateway [llopez] +* Merchant Warrior: Use billing_address [duff] +* Add SoEasyPay gateway [ir-soeasycorp] +* Bogus: Add check support [npverni] +* Payflow: Add Check support [crazyivan] +* Stripe: Allow expanding objects inline [odorcicd] + +== Version 1.42.2 (November 13th, 2013) + +* Renew public certificate + +== Version 1.42.1 (November 13th, 2013) + +* Signed version of 1.42.0 + +== Version 1.42.0 (November 13th, 2013) + +* Fix NoMethodError "tr" for params with dash [TimothyKlim] +* Authorize.Net: Add cardholder authentication options (CAVV) support [structure] +* CardStreamModern: Added better checks on inputs from the gateway [ExxKA] +* Stripe: Send :ip to the gateway instead of :browser_ip [f3ndot] +* Wirecard Page: new offsite gateway [mbretter] +* Mercury: Add support for requesting a token [kcdragon] +* Add App55 gateway [ianbutler55] +* UsaEpayTransaction: Support for split payments [GBH] +* Add Swipe Checkout gateway [matt-optimizerhq] +* Spreedly Core: Allow overriding the gateway token when running a transaction [hoenth] +* Spreedly Core: Add order_id [hoenth] +* Spreedly Core: Allow store without retain [hoenth] +* Stripe: Support multiple cards on account [pierre] +* Stripe: Add card_id parameter to unstore call [pierre] +* Remove usage of `uname -a` [ntalbott] +* Litle: Allow easier access to the response code [duff] +* Stripe: Add the option to pass a version header [odorcicd] +* Elavon: Update supported countries [duff] +* Add Raven PacNet gateway [llopez] +* BitPay: Fix BitPay issues and implement Notification#acknowledge [odorcicd] + +== Version 1.41.0 (October 24th, 2013) + +* Stripe: Payments won't fail when specifying a customer with a creditcard number [melari] +* Add Conekta gateway [leofischer] +* Wirecard: Add support for void and refund [duff] +* Orbital: Mandatory field fix [juicedM3, jduff] + +== Version 1.40.0 (October 18th, 2013) + +* Paymill: Revert Add support for specifying the :customer [melari] +* Quickpay: Make v7 of the API default [kvs] +* Bitpay: Add return [tahnok] + +== Version 1.39.2 (October 10th, 2013) + +* Eway Rapid: Fix a bug with access codes that have equal signs in them [odorcic] + +== Version 1.39.1 (October 9th, 2013) + +* Bitpay: Invoice Fix [orenmazor] + +== Version 1.39.0 (October 9th, 2013) + +* Moneris: Add optional (off by default) verification_value support [duff] +* Citrus: New Integration [viatechs, melari] +* Payu Paisa: New Integration [melari] +* Spreedly: Pass country with other address fields [hoenth] +* SecureNet: Fix order of xml params [duff] +* Paymill: Add support for void [duff] +* Add MoneyMovers gateway [jeffutter] +* Ogone: Add a :store_amount option [rymai] +* Ogone: Require TLSv1 [ntalbott] +* Moneris: Add support for purchasecorrection [pgib] +* Spreedly: Add ability to retain on success [duff] +* Spreedly: Pass verification value [duff] +* Paymill: Add support for specifying the :customer [Sbastien] +* Realex: Correct AVS input format [ExxKA] +* USAEpay Transaction: Use sandbox when in test mode [radar] +* Braintree Blue: Do not use global config [rdj] +* eWay Rapid: Add response messages [BenZhang] +* Paysbuy: Add 'Pending' notification status [divineforest] +* Cybersource: Use standard :phone field [cade] +* Orbital: Fix/tweak AVS codes [boone] +* Quickpay: Add v7 support [larspind] +* Authorize.Net CIM: Add option to not mark transactions as test [alanandrade] + +== Version 1.38.1 (September 16, 2013) + +* Moneris: Remove verification_value support [melari] + +== Version 1.38.0 (September 6, 2013) + +* FirstData E4: Include missing address information for AVS and CVV [melari] +* Litle: Deprecate credit method in favor of refund [melari] +* Moneris: Add verification_value support [duff] +* Webpay: Fixes issues with partial JPY currency [keikubo, melari] +* SecureNet: Add INVOICENUM and INVOICEDESC optional fields [duff] +* Balanced: Make BalancedGateway::Error inherit from ActiveMerchantError [duff] +* Balanced: Fix #void interface [duff] +* HiTrust: Return correct error message for positive retcodes [melari] +* Moving to pessimistic versioning [davefp] + +== Version 1.37.0 (August 20, 2013) + +* MerchantWarrior: Fix handling of amounts [duff] +* Ipay88: New gateway [kamal, siong1987, jduff] +* IATS: New gateway [unkown, jduff] +* MerchantWarrior: Send the CVV to the gateway [duff] +* PayU: Fix a major bug with status types [melari] +* SecureNet: Allow production transactions [duff] +* Stripe: Allow a card_not_present_fee to be specified [melari] + +== Version 1.36.0 (August 2, 2013) + +* Fat Zebra: More consistent handling of tokens [adrianmacneil] +* Add Platron integration [alexwl] +* Litle: Support wiredump_device [pierre] +* Litle: support paypage registrations [pierre] +* SecureNet: Cleanup and refactoring [duff] +* Mercury: Proper refund and void support [opendining] +* PaymentExpress: Return token in authorization [ntalbott] +* Stripe: Support for partial application fee refunds [melari, odorcicd] +* NMI: Support for recurring flag [duff] +* SecureNet: Use working live url [duff] + +== Version 1.35.1 (July 22, 2013) + +* Stripe: Allow application_fees to be refunded via the refund_application_fee flag [melari] + +== Version 1.35.0 (July 17, 2013) + +* Add Barclays ePDQ Extra Plus gateway [ntalbott] +* PayPal: Add MassPay payment to recipients by UserID [damonmorgan] +* Authorize.Net: Add authorization_code to response params [noahlh] +* Make Rails 4 a supported version [sanemat] +* CyberSource: Add pinless debit card support [JoshMcKin] +* Verkkomaksut: Add item title field [kaapa] +* Add MerchantWare V4 gateway [hron] +* Eway Rapid: Add #store method [adrianmacneil] +* Barclays ePDQ Extra Plus: Use correct PROD url [ntalbott] +* Hitrust: update test & live urls [melari] +* NAB Transact: Add auth & capture support [nagash] +* Mercury: Support card-less capture and refund [ntalbott] +* Mercury: Support void [ntalbott] + +== Version 1.34.1 (June 28, 2013) + +* WorldPay: Add dynamic return URL [jordanwheeler] +* Merchant One: New gateway [coteyr, melari] +* Balanced: Fix exception for invalid email [duff] +* Update supported countries for Paymill & PaymentExpress [duff] +* Worldpay: Add support for diners club [duff] +* Stripe: Include address with card data [melari] + +== Version 1.34.0 (June 20, 2013) + +* PayPal Express gateway: Add unstore support [duff] +* Stripe: Send application_fee with capture requests [melari] +* Make #unstore method signature consistent across gateways [duff] +* Dwolla: Major bug fixes. [capablemonkey, melari] +* Stripe: Add support for including track data [melari] + +== Version 1.33.0 (May 30, 2013) + +* Netaxept: Completely revamped to use the "M" service type [rbjordan3, ntalbott] +* Litle: Void authorizations via an auth reversal [jrust] +* Add RBK Money integration [england] +* Direcpay: Update test url [ashish-d] +* PayPal Express gateway: Add support for creating billing agreements [fabiokr] +* PayPal Express gateway: Add reference authorizations [fabiokr] +* Add Cardstream Modern gateway [ExxKA] +* Pin: Fix special headers [duff] +* PayPal Express gateway: Remember the billing agreement id as Response#authorization [duff] +* PayPal Express gateway: Allow an amount of 0 [duff] +* PayPal Express gateway: Reduce parameter requirements [duff] +* Quickpay integration: Update notification parser to handle API v6 [larspind] +* Sage gateway: Deprecate #credit call [duff] +* Update notification generator to better match current notification class [lulalala] +* Paymill gateway: Change .com -> .de [louiskearns] +* Quickpay integration: Fix v6 response parsing [larspind] +* First Data e4: Add TransArmor store/tokenization support [gabetax] +* MerchantWarrior: Format expiration month/year correctly [klebervirgilio] +* Add iconv for ActiveSupport 2.3 under Ruby 2.0 [sanemat] +* Add Transnational gateway [bvandenbos] +* Authorize.Net: Add Check as payment method [andrunix] +* Merchant e-Solutions: Add ref number and recurring support [carlaares] +* Bogus gateway: Add authorization to purchase response [hron] +* Bluepay gateway: Fix Check support; general cleanup [ntalbott] +* Dwolla: Fix security issues and enable guest checkout [capablemonkey, schonfeld] +* SagePay gateway: Per-transaction 3D-secure selection [ExxKA] +* Barclays ePDQ: Handle incorrectly encoded response [jordanwheeler, aprofeit] +* Orbital: Bug fixes; add CustomerEmail, Retry Logic, Managed Billing, and Destination Address [juicedM3 +* Distinguish invalid vs empty issue_numbers on CreditCards [drasch] +* Float Gemfiles to latest Rails [sanemat] +* USA ePay Advanced: Fix Check support [RyanScottLewis] +* Authorize.Net: Match up Check fields better with eCheck.Net requirements [ntalbott] +* Bluepay: Updated to bp20post api [cagerton, melari] +* Net Registry: Deprecate credit method [jduff] +* Sage: Don't include T_customer_number unless it is numeric [melari] +* Auth.net: Don't include cust_id unless it is numeric [melari] +* Epay: Deprecate credit method [melari] +* New PayU.in Integration [PayU, melari] + +== Version 1.32.1 (April 4, 2013) + +* CC5 and Garanti: Remove $KCODE modifications [melari] +* Paymill: Add support for store [ntalbott] +* USA ePay: Fix misspelling of "Aduth" [joelvh, ntalbott] +* Orbital: Fix nil address values throwing exceptions during truncation [melari] + +== Version 1.32.0 (April 1, 2013) + +* Optimal: Submit shipping address with requests [jduff] +* Iridium: Enable reference transactions for authorize [ntalbott] +* Stripe: Add authorize and capture methods [melari] +* Pin: Add a default description if none is specified to fix failures [melari] +* Litle: Add support for passing optional fields in token based transactions [forest] +* Add Finansbank gateway [scamurcuoglu] +* Paymill: Use .com instead of .de for save card url [besi] +* Worldpay integration: Use more robust endpoint urls [nashbridges] +* Braintree Blue: Return CC token in transaction hash [cyu] +* Robokassa: Fix signature for empty amount [ukolovda] +* Worldpay gateway: Fix error messages for some failures [duff] +* Worldpay gateway: Allow settled payments to be refunded [dougal] +* Spreedly: Update urls and terminology [duff] +* Make card brand error more user friendly [oggy] +* DataCash: Update test Mastercard number [jamesshipton] +* DataCash: Update test response fixtures [jamesshipton] +* Pin: Add Pin.js card token support [nagash] +* PayPal Express gateway: Fix error when no address information is in response [pierre] +* Ogone: Use BYPSP for ALIASOPERATION [ntalbott] +* Paymill: Handle error storing card [duff] +* SagePay integration: Add referrer field [melari] +* Pin: Add extra headers [duff] +* Paymill: Add support for store [ntalbott] +* USA ePay Advanced: Fix typo in message credit card data options [joelvh] + +== Version 1.31.1 (February 25, 2013) + +* Cybersource: Bug fixes [natejgreene, jduff] + +== Version 1.31.0 (February 20, 2013) + +* Worldpay: XML encoding is required to be ISO-8859-1 [dougal] +* Worldpay: Add card code for more supported card types [dougal] +* Ogone: Add action option [pwoestelandt] +* PayPal Express gateway: Add support for BuyerEmailOptInEnable [chrisrbnelson] +* Add Paymill gateway [duff] +* Add EVO Canada gateway [alexdunae] +* Fixed credit card and check interface, used correct method for checking payment type [jduff] + +== Version 1.30.0 (February 13, 2013) + +* Add FirstData Global Gateway e4 [frobcode] +* PaymentExpress: Add support for optional fields: ClientType and TxnData [moklett] +* PaymentExpress: Limit MerchantReference/description to 64 chars [moklett] +* Wirecard: description must be no more than 32 characters [moklett] +* Litle: Add support for passing a token to the authorize and purchase methods [forest] +* PayPal Common: Allow searching for transactions by ProfileID [aq1018] +* Add Spreedly Core gateway [duff] +* eWay Gateway: Return proper value for authorization [duff] +* eWay Gateway: Add support for refunds [duff] +* Quickpay: Add support for protocols 5 & 6 [twarberg] +* Banwire gateway: Handle JSON::ParserError [duff] +* Balanced gateway: Fix unspecified marketplace [duff] +* QBMS gateway: Allow partial addresses [duff] +* Authorize.Net CIM: Allow omitting card expiration date [shanebonham] +* Authorize.Net CIM: Add support for extraOptions to createCustomerProfileTransaction [tpiekos] +* Add NETPAY gateway [samlown] +* Balanced gateway: Add amount to the refund method signature [ntalbott] +* Orbital gateway: Fix void method signature [aprofeit, ntalbott] +* Eway Managed: Add 'query_customer' API as #retrieve [cdaloisio] +* NetPay: Fix the signature for void [duff] +* Cybersource: Add check support [bowmande] +* Moneris: Use a capture of $0 for void [ntalbott] +* PayPal Express integration: Fix received_at time zone [ntalbott] +* NAB Transact: Add refund capability [nagash] +* Stripe: Add support for application_fee [duff] +* SagePay: Add support for GiftAidPayment [duff] +* Wirecard: Add support for partial captures [richardblair] +* Add Pin gateway [madpilot] +* Balanced: Added support for on_behalf_of_uri to capture [cwise] +* Litle: Add support for passing an order_source [forest] +* Add Merchant Warrior gateway [pronix, Fodoj, ntalbott] +* Use v4 of the MerchantWare API for voiding transactions [melari] +* Add support for Authorize.net in CA and GB [melari] +* Send customer's IP to Beanstream for fraud review [melari] + +== Version 1.29.3 (December 7, 2012) + +* Braintree Blue: Better wiredump_device support [ntalbott] +* Braintree: Store sets vault id as authorization [ntalbott] +* WorldPay: Fix currencies without fractions like JPY and HUF by rounding down amount [Soleone] + +== Version 1.29.2 (December 7, 2012) + +* Moneris: fix issue with the default options not being merged [jduff] +* Sage Pay: Make 0000 default post code for everyone if missing [BlakeMesdag] + +== Version 1.29.1 (December 5, 2012) + +* Add eWay Rapid 3.0 gateway [ntalbott] +* Fix AVS responses missing attributes [jduff] + +== Version 1.29.0 (November 30, 2012) + +* Authorize.Net gateway: Support description and order_id for capture [ntalbott] +* Add Mercury gateway [adr1anx, opendining] +* Webmoney integration: Add gross, item_id, and amount accessors to notification [fr33z3] +* Fix running tests under ActiveSupport 2.3.14 [ntalbott] +* SagePay Form integration: Remove dependency on ActiveSupport's String#truncate [ntalbott] +* Elavon gateway: Add support for the sales tax parameter [stevestmartin] +* Add WebPay gateway [keikubo] +* iTransact gateway: make void API consistent [frobcode] +* Stripe gateway: Pass city in add_address [npverni] +* Paypal gateway: Add option to change the outstanding balance of a recurring billing profile [mattwhite] +* Mercury gateway: Fix authorizations API [ntalbott] +* Mercury gateway: Support refund properly [ntalbott] +* Braintree Blue gateway: Add support for the recurring flag [ntalbott] +* Add HDFC gateway [ntalbott] +* HDFC gateway: Add more supported currencies [ntalbott] +* HDFC gateway: Add support for passing ECI value [ntalbott] +* HDFC gateway: Allow setting test mode via options [ntalbott] +* HDFC gateway: Pass phone number in UDF3 [ntalbott] +* HDFC gateway: Fix unescaped '&' entity in XML [ntalbott] +* HDFC gateway: More robust entity fixing [ntalbott] +* Add A1Agregator integration [england] +* Refactored handling of #test? and @options [ntalbott] +* Realex gateway: Realex gateway: Fix billing address format [ntalbott] +* Orbital gateway: handle custom AVS response codes [jonm-okc] +* Orbital gateway: Fix infinite connection retry [jonm-okc, ntalbott] +* PayPal integration: Add support for MassPay IPN notifications [damonmorgan] +* Orbital gateway: Fix status of void result [jonm-okc] +* Add Redsys gateway [samlown] +* Cybersource gateway: Add support for subscription credit [fabiokr] +* Use Thor for generators [ntalbott] +* Psigate gateway: Add void support [samuelreh] +* Add Liqpay integration [beorc] +* Paypal Express gateway: Add shipping accessor to response [v-fedorov] + +== Version 1.28.0 (August 10, 2012) + +* PayPal Express: support non standard locale codes [Soleone] +* Litle: allow setting test mode per transaction [jduff] +* Add Banwire gateway [acolin] +* Authorize.Net CIM gateway: Move cardCode after order to comply with the XSD [davetron5000] +* Add WebMoney integration [Mehonoshin] +* EasyPay: Make symmetric with other integrations [nashby] +* Add Paysbuy integration [divineforest] +* Bogus gateway: Use last digit for pass/fail [mipearson] +* Elavon gateway: Separate from Viaklix, implement refund & void [duff] +* Orbital gateway: Update to API version 5.6 and add support for profile requests [rbarazi] + +== Version 1.27.0 (August 10, 2012) + +* Add First Data integration [courtland] +* Add WebPay integration [nashby] +* Add Suomen Maksuturva integration [akonan] +* Payway gateway: Fix card storage [BenZhang] +* Payflow Pro gateway: Add MaxFailPayments support [gregwinn] +* Add Paxum integration [Mehonoshin] +* Add Balanced gateway [mjallday] +* Plug'n Pay gateway: Add tests for partial capture [csaunders] +* Braintree Blue gateway: Add credit card details to responses [dougbradbury] +* PayPal gateway: Support for 'Full' refund type [kurenn] +* Worldpay: fix refund [jduff/omh] +* Add PxPay offsite integration [boourns] +* Wirecard: always capture 'authorization' transaction [ntalbott] +* Add rake task to verify ssl certs [boourns] + +== Version 1.26.0 (July 6, 2012) + +* Orbital gateway: fix broken requests by ensuring the order of XML elements matches their DTD [Soleone] +* CyberSource gateway: clean up formatting [ntalbott] +* Netbilling gateway: Add refund/credit/void support [ntalbott] +* Add PayGate XML gateway [rubyisbeautiful] +* Add PayWay gateway [BenZhang] +* PayWay gateway: Tweaks to make more ActiveMerchant like [ntalbott] +* Netbilling gateway: Fix error handling [ntalbott] +* Netbilling gateway: Add refund/credit/void support [zenom, ntalbott] + +== Version 1.25.0 (July 3, 2012) + +* eWAY gateway: Add support for Diners Club cards [Soleone] +* Orbital gateway: Never send country code for orders outside of US, CA and GB [Soleone] +* Add EasyPay integration [nashby] +* Updating LitleOnline requirement to 8.13.2 to take advantage of better validation and get bugfix for Username [GregDrake] +* USAepay gateway: Add description support [ntalbott] +* Add Paypal Payments Advanced integration [csaunders] +* Authorize.Net gateway: Improve #refund docs [neerajdotname] +* Wirecard gateway: Fix for missing address hash [ntalbott] +* Clean up requires of RubyGems and JSON gems. Rename remote Litle test to match naming conventions [codyfauser] +* Cybersource gateway: Fix updating address only [fabiokr] +* Cybersource gateway: Move email requirement [fabiokr] +* Add the Metrics Global gateway [DanKnox] +* Braintree Blue gateway: Support wiredump_device [moklett] +* Add Fat Zebra gateway [amasses] +* Braintree Blue gateway: Always pass CVV on update [shayfrendt] +* eWAY gateway: Update docs. Require address [juggler] +* Cybersource gateway: Add support for subscriptions [fabiokr] +* WePay: Use better endpoint for recurring with no CVV [davidsantoso] + + +== Version 1.24.0 (June 8, 2012) + +* PayPal gateway: Support for incomplete captures [mbulat] +* Moneris gateway: Add support for vault [kenzie] +* NAB Transact gateway: Add support for card descriptors [nagash] +* SagePayForm: truncate long description fields [jnormore] +* Paybox Direct: treat all response codes besides '00000' as failures +[Soleone] +* Deprecate CreditCard#type method in favor of CreditCard#brand [jduff] +* Cybersource gateway: Add subscriptions support [fabiokr, jaredmoody] +* eWay gateway: Improved docs, and more accurate required parameters [juggler] +* Braintree Blue gateway: Always pass CVV on card update [shayfrendt] +* Add Fat Zebra gateway [amasses] +* Braintree Blue gateway: Add support for wiredump_device [moklett] +* Add Metrics Global gateway [DanKnox] +* Cybersource gateway: Do not require email address for subscription operations [fabiokr] +* Cybersource gateway: Fix passing only an address when updating a subscription [fabiokr] +* Wirecard gateway: Fix for missing address; general cleanup [ntalbott] +* Authorize.Net gateway: Document ability to just pass the last four to #refund [neerajdotname] +* Add EasyPay integration [nashby] + +== Version 1.23.0 (May 23, 2012) + +* Add Litle gateway [GregDrake] +* PaymentExpress gateway: add support for BillingId and DpsBillingId for token [mikel] +* 2checkout integration: Add ability to auto settle [craigchristenson] +* 2checkout integration: Switch default mode to single page [craigchristenson] +* Cybersource: Revert - Add retrieve method to pull details on a +stored card [jduff] +* Cybersource: Revert - Add recurring payment support [jduff] +* PaymentExpress: add Cvc2Presence flag when submitting verification +value [jduff] +* SecurePayAU: fix CreditCard check [jduff] +* Barclays: fix order capture [csaunders/ntalbott/jduff] + +== Version 1.22.0 (May 17, 2012) + +* Remove version restriction for money gem [ylansegal] +* Add iTransact XML gateway [motske] +* PayPal Express Gateway: add options[:landing_page] [markus] +* USA ePay: Fix handling of AVS [duff] +* Ogone: Add store method to create an alias without making a purchase [joelcogen] +* Spelling fix: purcahse -> purchase [mnoack] +* ePay: Added more useful results for authorization errors [Dennis O'Connor] +* Add Robokassa integration [nashby] +* PayPal Gateway: Add recurring API [dscataglini] +* Braintree: Add support for :verify_card option on store [brentmc79] +* Moneris: cannot void a preauthorization [eddanger] +* Add Moneris US gateway [eddanger] +* Add Dotpay integration [kacperix] +* Payflow: Add description, comment and comment2 tags [ksnyder] +* Dotpay: Fix field mapping [kacperix] +* Authorize.Net CIM: Optionally add 'order' details to transactions [pote] +* Braintree: Allow including billing address when storing a customer [brentmc79] +* PayPal Gateway: Refactored PaymentDetails & PaymentDetailsItem common code [dscataglini] +* Viaklix/Elavon: Separate "demo accounts" from "test transactions" [mltsy] +* PayPal Gateway: Add transaction_details, balance, authorize_transaction, and manage_pending_transaction API calls [dscataglini] +* PayPal Gateway: Add support for TransactionSearch & DoReferenceTransaction [dscataglini] +* Cybersource: Add recurring payment support [jaredmoory] +* Tidy up gateway lists [ashokak] +* Paybox: remove Iconv usage [ntalbott] +* Dotpay: Add amount mapping, pin setter, and support for test? [kacperix] +* Braintree Blue: Make address country map to alpha2 [ntalbott] +* Use GB as the alpha2 country code for the UK [ntalbott] +* Realex: Handle XML response with unescaped ampersand [ntalbott] +* Add Vindicia gateway [steved555] +* Payment Express: use %w[] for country list [parndt] +* Braintree Blue: Match remote test up with change to :country [braintreeps] +* PayPal Integration: Fix received_at method time parsing [subbarao] +* Add MiGS Gateway [mnoack, nagash] +* Quickpay integration: Fix payment_service_for helper [TheMaster] +* Braintree Blue gateway: Improve update method [brentmc79] +* 2checkout integration: Add mode mapping & line items helper [AlexanderZaytsev] +* USA ePay Advanced gateway: Fix expiration date format. [cctalbott] +* Add ePay integration [ePay] +* 2checkout integration: Add support for single page payment routine [AlexanderZaytsev] +* Ogone: Add support for 3D Secure [rymai, ZenCocoon] +* Stripe gateway: Remove authorize and capture methods since they are not supported [jduff] +* Stripe gateway: default test to false if no livemode parameter is specified [jduff] +* Paybox Direct gateway: 'card absent' and 'do not honour' should be considered failures, not fraudulent [jduff] +* Add Verkkomaksut integration [akonan] +* Remove trailing spaces from generator templates [akonan] +* Payflow gateway: Allow modification of RetryNumDays [jrust] +* Payflow gateway: Don't auto-set start_date on modification [jrust] +* Bluepay gateway: Add ACH & recurring support [jslingerland] +* Orbital gateway: Don't send AVS address details for any country besides US, CA, GB and UK [Soleone] +* Payflow Express gateway: Better amount handling [jduff] +* Barclays gateway: Allow American Express [duff] +* Ogone gateway: Remove duplicated method [ntalbott] +* Cybersource gateway: Add retrieve method to pull details on a stored card [fabiokr] + +== Version 1.21.0 (March 7, 2012) + +* Stripe: Add support for passing IP [collision] +* Merchant e-Solutions: pass expiration date when purchasing with a stored credit card [chrisyoung] +* Braintree: Fix passing custom processor ids to old accounts [maxsilver] +* Authorize.net CIM: Add validation mode option to create_customer_profile_request [jwood] +* eWay Managed: Include transaction number in response params [jamsi] +* Fix various hash ordering issues exposed by Ruby 1.8 [ntalbott] +* Authorize.Net CIM: Add WEB echeck type [deathbob] +* Move Braintree from the gemspec to the Gemfile [ntalbott] +* Add CertoDirect gateway [hron] +* Authorize.Net CIM: Add option for setting a custom delimiter [bmorton] +* Authorize.Net CIM: Add 3.1 response fields [bmorton] +* Authorize.Net CIM: Misc fixes and doc improvements [bmorton] +* Authorize.Net CIM: Fix error when order is blank [KeeperPat] +* Beanstream: Add recurring payments support [castiglione] +* Make ePay password optional [ePay] +* Quickpay: skip testmode if transaction provided [brentmc79] +* Payflow: add additional fields [thorstadt] +* Authorize.Net CIM: Add get_customer_profile_ids [howaboutwe] +* PayPal Express: Add support for BrandName and Custom fields [exviva] +* Payflow: Handle dates with leading zeros [jcoleman] +* Authorize.Net CIM: Add CCV code support & improve tests [tgarnett] +* Add Authorize.Net SIM integration [courtland & rdp] +* Secure Pay AU: Handle periodic payments [tommeier] +* Viaklix: Add discover as a supported card type [waelchatila] +* Improvements to testing infrastructure for integrations [jduff] +* Add NAB Transact (AU) Gateway [tommeier] +* PayPal Express: Add Support for Reference Transactions using BAIDs [kenmazaika] +* Authorize.Net CIM: Add support for optional refund fields [nilmethod] +* SecurePayTech: Fix EnableCSC parameter so CVV codes are checked. [tlconnor] +* SecurePayTech: Add remote tests for CSC checking. [tlconnor] +* Samurai: Add option to retain payment methods once stored [brentmc79] +* PayPal Express Gateway: Add support for Digital Goods / Micropayments [kenmazaika] + + +== Version 1.20.4 (February 22, 2012) + +* Fix json dependency + +== Version 1.20.3 (February 7, 2012) + +* Various fixes to support Ruby 1.9 [wisq] +* SkipJack: Fix partial capture [jduff] +* Optimal Payments: submit region when outside North America [jduff] +* USA ePay: Add void and refund support [duff/ntalbott] +* Add first digits to credit card [codyfauser] +* Orbital: fixes to authentication and order id [Soleone] +* Stripe: fixes to purchase method [duff/ntalbott] + +== Version 1.20.2 (January 16, 2012) + +* Remove authorize/capture support for Stripe [gdb] + +== Version 1.20.1 (December 22, 2011) + +* PayflowExpressUk: Fix parsing street2 from response [odorcicd] +* AuthorizeNet: Support tracking id [odorcicd] +* SagePay Form: Map billing address to shipping address [jduff] + +== Version 1.20.0 (November 14, 2011) + +* Add support for USA ePay Advanced SOAP interface [matthewcalebsmith/jduff] +* Beanstram: fix purchase with Secure Profile [pitr/jduff] +* Orbital: various fixes [Soleone] +* Add Samuari gateway by Fee Fighters [jkrall/odorcicd] +* Lock money gem to 3.7.1 or less since newer versions break in 1.9 [jduff] +* Braintree: handle gateway rejected transactions gracefully [braintreeps/jduff] +* Ogone: support different signature encryptors, custom currency and eci [ZenCocoon/rymai/jduff] +* Payflow Link: use secure token [jduff] +* Added refund method to Exact, Pay Junction and Skip Jack gateways [jduff] +* Elavon: added test url [kylekeesling/jduff] +* Fix redundent errors when credit card is expired [castiglione/jduff] +* Two Checkout: update service url [vampirechicken/jduff] + +== Version 1.18.1 (September 23, 2011) + +* Braintree: allow setting merchant_account_id on initialize [jduff] +* Realex: only send letters and numbers in shipping code field [Soleone] + +== Version 1.18.0 (September 23, 2011) + +* NoChex: Update the URL that payment requests are posted to [caseywhalen/jduff] +* QBMS: fixed test mode check [Soleone] +* Realex: encode avs info with shipping address [Soleone] +* Add Dwolla offsite gateway [armsteadj1/jduff] +* Eway: pass email, customer, description and options to store [moklett/tobi] +* New dependency: active_utils gem [odorcicd] +* Optimal Payments: fix test mode check [jduff] + +== Version 1.17.0 (August 23, 2011) + +* Add Payflow Link integration [jduff] +* Add CardSave gateway [MrJaba/jduff]] +* Quickpay: Support protocal version 4 and fraud parameters [anderslemke/jduff] +* Authorize.net: Add status_recurring [mm1/jduff] +* Paypal Express: Support specifying :items with purchase [sivabudh/jduff] +* ePay: Add Sweden and Norway to supported countries [ePay/jduff] +* Brainreee: Support passing merchant_account_id parameter [braintreeps/jduff] +* Paypal Express: Remove deprecated Address field in favor of ShipToAddress[jduff] +* Add Optimal Payments gateway [jamie/jduff] +* Documentation improvements [dasch/nhemsley/jstorimer/jduff] +* Authorize.Net: Pass through first name, last name, and zip for refunds. [ntalbott] + +== Version 1.16.0 (July 18, 2011) + +* Bogus: Support referenced transactions for #authorize, #purchase, #recurring and +#credit [dasch/jduff] +* Payment Express: Update gateway url [bayan/titanous] +* Moneybookers: Send country and account_name if provided [Soleone] +* Moneris: Add Diners Club and Discover [Soleone] +* Cybersource: add auth_reversal support [jeberly/titanous] +* WorldPay: Update endpoint URLs for offsite gateway [Soleone] +* Worldpay: Add JCB and add Maestro [Soleone] +* Authorize.net: Add Diners Club and JCB [Soleone] +* Quickpay: Add testmode for subscribe and authorize [dasch/jduff] +* Orbital: fix handling of phone numbers. [ntalbott] +* Braintree: Add Diners Club [cody] +* Add ePaymentPlans offsite payment [robertomiranda/Soleone] +* Add Stripe gateway [boucher/titanous] +* Add Paystation gateway [nikz/jduff] +* Bump minimum ActiveSupport version to 2.3.11 [titanous] +* Use securerandom from stdlib not active_support [phlipper/jduff] + +== Version 1.15.0 (May 12, 2011) + +* DirecPay: Fix address to not include address2 twice in some cases [Soleone] +* DirecPay: Send company if available [Soleone] +* Realex: Fix hash signature [ntalbott/Soleone] +* SecurePay AU: Update remote tests [ntalbott] +* SecurePay AU: Fix method arity for #capture, #refund, #credit and #void [Soleone] +* Barclays ePDQ: Make response parsing more robust [Soleone] +* Payflow Express: Add line item support [wolframarnold] +* Payflow Express: Add comment field support [wolframarnold] +* Payflow: Add more optional fields [wolframarnold] +* Beanstream/Paypal: Fix CREDIT_DEPRECATION_MESSAGE errors [Jonathan Rudenberg] +* BraintreeBlue: Return a hash instead of a transaction object [braintreeps] +* BraintreeBlue: Return proper AVS/CVV values [braintreeps] +* Bogus: Add #recurring [trwomey] +* Make Validateable compatible with ActiveModel [CodeMonkeySteve] +* Add DirectEBanking offsite gateway [Gerwin Brunner/Soleone] +* ActiveSupport 3.1 beta support [cgriego] + +== Version 1.14.0 (Apr 29, 2011) + +* SagePayForm: Implement #cancelled? for Return. [wisq] +* Add #cancelled? to Integrations::Return [wisq] +* Bogus gateway: Add refund support and better tests [wisq] +* Beanstream: Add support for storing cards [duffomelia] +* eWay: Add support for storing cards [duffomelia] +* Add validation mode to update profile request [Ken Miller] +* Authorize.net CIM: Add oldLiveMode [ntalbott] +* Authorize.net CIM: Add extra transaction types [Ken Miller] +* JetPay: gateway tweaks [ntalbott] +* Deprecate a bunch more #credit methods [ntalbott] +* RealEx: Add authorize/capture/credit/void [ntalbott] +* SecurePay AU: Add authorize/capture/credit/void [ntalbott] +* PayPal Express: Make response parsing more robust [ntalbott] +* Test deprecation warnings; add deprecation line numbers [ntabott] +* Add Orbital direct gateway [ntalbott] +* Add WorldPay direct gateway [ntalbott] + +== Version 1.13.0 (Apr 19, 2011) + +* Add a Gemfile for optional bundler support [ssoroka] +* Stop using has_rdoc= when rubygems version is 1.7.0 or greater, since it's deprecated [ssoroka] +* Add tax field to braintree [wisq] +* Quickpay: Also add Sweden as supported country [Soleone] +* Adding refund method for gateways that are using the credit method for referenced based refunds, added deprecation worning to the credit method [John Duff] +* Return the Braintree transaction id in the response for void and refund transaction calls [John Duff] +* PayPal Express: Extract phone number from address if no contact phone was sent [Soleone] +* Unify all offsite gateways that verify the signature of Returns or Notifications by always using the #acknowledge method and calling the secret :credential2 [Soleone] +* Valitor: Change name of credential for Return and Notification from :password to :credential2 in symmetry with the other Integrations [Soleone] +* Moneybookers: Add support for tracking token [Soleone] +* Moneybookers: Require credential when creating Notifications instead of adding an argument to #acknowledge [Soleone] +* Moneybookers: Fix Notification to return correct status [Soleone] +* Support default Return class for all Integrations that don't use returns [Soleone] +* Add support for passing additional options when creating a Notification to all Integrations [Soleone] +* Update BraintreeBlue#refund to have consistent method signature [Jonathan Rudenberg] +* Add rails/init.rb for gem campatability in Rails [Rūdolfs Ošiņš] +* Fix Paypal Express response parser [Jonathan Rudenberg] +* Braintree/Transax: Add tax field [wisq] + +== Version 1.12.1 (Mar 21, 2011) + +* Ogone: Make sure response.params is a real Hash [Soleone] +* WorldPay: Fix service_url in production mode [Soleone] + +== Version 1.12.0 (Mar 1, 2011) + +* DirecPay: Send phone number as mobile phone by default [Soleone] +* Support sending line items for PayPal Express transactions [Jonathan Rudenberg] +* Update PayPal Express XML format to latest version [Jonathan Rudenberg] +* Fix custom image header for PayPal Express [mwagg] +* Add InvoiceID and OrderDescription to PayPal Express Authorize and Capture [cody] +* Add Moneybookers integration [Alex Diakov] +* Add QBMS (Quickbooks Merchant Services) gateway [ntalbott] +* Add NMI gateway [ntalbott] +* Make fully compatible with Rails 2 & 3, and Ruby 1.8 & 1.9 [ntalbott] +* Authorize.Net: Only return AVS message for AVS-related reason codes. [ntalbott] +* Add Federated Canada gateway [ntalbott] +* Garanti: Fix text normalization for nil values [Selem Delul] +* Valitor: Always send amount without any decimal places [Soleone] +* Add WorldPay integration [Soleone] + +== Version 1.11.0 (Feb 11, 2011) + +* Bump dependency for activesupport from 2.3.2 to 2.3.8 [Soleone] +* Garanti: Normalize text in xml fields for non-standard characters [Selem Delul] +* Garanti: Make sure order number does not contain illegal characters [Soleone] +* Fix ActionView tests for ActiveSupport 3.0.4 [Soleone] +* DirecPay: Make address information editable by default [Soleone] +* Fix ePDQ credit to expect and handle full authorization [Nathaniel Talbott] +* Add Barclays ePDQ Gateway [Nathaniel Talbott] +* Add default fixture for Garanti and don't use fixture for Garanti [cody] +* Add cms param for ePay [ePay] +* Add Valitor Integration [Nathaniel Talbott] + +== Version 1.10.0 (Jan 20, 2011) + +* PayPal Express: Support returning payer phone number [Soleone] +* Fix ePay to correctly send order number [Soleone] +* Add BluePay Gateway [Nathaniel Talbott] +* Add Quantum Gateway [Joshua Lippiner] +* Add iDEAL/Rabobank gateway [Jonathan Rudenberg] +* SagePayForm: Added send_email_confirmation (default false) to enable confirmation emails [wisq] + +== Version 1.9.4 (Jan 5, 2011) + +* Update Garanti gateway to integrate with new API [Selem Delul] + +== Version 1.9.3 (December 17, 2010) + +* Fix BBS Netaxept to change transaction type from C (for MOTO: mail order telephone order) to M (for credit card orders) [Soleone] +* Fix Iridium and ePay to work with any object that responds to credit card methods not only ActiveMerchant::CreditCard objects + +== Version 1.9.2 (December 9, 2010) + +* Add support for PayPal mobile payments [wisq] +* Add ePay gateway [ePay, Jonathan Rudenberg] +* Allow access to the raw HTTP response [Jonathan Rudenberg] + +== Version 1.9.1 (November 24, 2010) + +* PayPal Express and PayPal Pro: Send JPY currency correctly without decimals [Soleone] +* Netaxept: Make sure password (token) is URL escaped and update remote tests for updated server behavior [Soleone] +* DirecPay: Add support for additional options in Return class and add convenience method to get transaction status update [Soleone] +* Add new alias credit_card.brand for credit_card.type and handle the brand correctly in Netaxept [Soleone] +* Iridium: Do not depend on ExpiryDate class for credit_card [Soleone] +* PayFlow: Use same timeout of 60 seconds in HTTP header and XML for all requests [Soleone] +* PayPal Website Payments Pro CA no longer supports American Express cards [Soleone] +* Updated BIN ranges for Discover to match recent documents [kaunartist] + +== Version 1.9.0 (October 14, 2010) + +* Add support for DirecPay gateway [Soleone] +* Add SagePay Form integration gateway [wisq] +* Allow Return class to include a Notification for gateways that treat the direct response as a notification [wisq] +* Add support for PayboxDirect gateway [Donald Piret] +* Add support for SecureNet gateway [Kal] +* Add support for the Inspire gateway [ryan r. smith] + +== Version 1.8.0 (September 24, 2010) + +* PayPal Express: Add support for billing agreements [Nathaniel Talbott] +* Allow comparing countries [Nathaniel Talbott] +* Iridium: Fix country handling [Nathaniel Talbott] +* Iridium: Fix missing billing address [Nathaniel Talbott] +* Iridium: Do not pass CV2 if not present [Nathaniel Talbott] +* Add Iridium support [Phil Smy] +* Add Netaxept support [Nathaniel Talbott] +* PaymentExpress: Use Card Holder Help Text for the response message [Nathaniel Talbott] +* Sort the country name list [Duff OMelia] + +== Version 1.7.3 (September 14, 2010) + +* Fix SagePay special handling for Japanese YEN currency to not send fractional amounts [Soleone] + +== Version 1.7.2 (August 27, 2010) + +* Update Braintree integration to play nicely with the braintree 2.5.0 gem [Soleone] +* Fix SagePay to not send fractional amounts for Japanese YEN currency [Soleone] + +== Version 1.7.1 (July 28, 2010) + +* Pull in only the necessary components of Active Support. Enables use of ActiveMerchant with Rails 3 [railsjedi] + +== Version 1.7.0 (July 9, 2010) + +* Add support for new Braintree Blue Gateway (using the braintree gem) [Braintree] + +== Version 1.6.0 (July 6, 2010) + +* Add a task rake gateways:hosts to get a list of all outbound hosts and ports [cody] +* Fix test failure in chronopay helper in Ruby 1.9.1 [cody] +* Fix timezone issue in credit card test. [cody] +* Fix failing unit test for Garanti gateway [cody] +* Fix failing CyberSource remote test [Patrick Joyce] +* Support for Garanti Sanal Pos: Turkish bank and billing gateway [Selem Delul] +* Add deprecation note for Money objects to Bogus gateway [Soleone] +* Updated test URL for Merchant eSolutions and added valid remote test credentials [Soleone] +* Add new error class for SSL certificate problems in connection class [Soleone] +* Update valid_month and valid_expiry_year to coerce string arguments to integers [cody] +* Add support for displaying credit cards with PayPal Express. Use the :allow_guest_checkout => true option when setting up the transaction [Edward Ocampo-Gooding] +* Use card_brand method for checking for checks in Sage and Beanstream [cody] +* Add JCB and Diners Club to LinkPoint [Soleone] + +== Version 1.5.1 (February 14, 2010) + +* Cleanup Rakefile, add gemspec and prepare for 1.5.1 release [cody] +* Update copyright dates [cody] +* Work around SkipJack bug by reversing the order of the query params [Soleone] +* Fix uppercase character in autoload of 2Checkout's Notification class [Edward Ocampo-Gooding] +* Detect language used in Chronopay integration based on billing address country [Soleone] +* Better handle international addresses in BeanstreamGateway [Soleone] + +== Version 1.5.0 (February 2, 2010) + +* Fix Gestpay notification to avoid Ruby 1.9 warnings [cody] +* Fix Chronopay notification time parsing for Ruby 1.9 [Joe Van Dyk] +* Set default currency of Braintree to USD [cody] +* Fix QuickPay helper for Ruby 1.9 compat [cody] +* Use String#each_line instead of collect in PaySecureGateway for Ruby 1.9 compat [cody] +* Use String#each_line instead of to_a in SagePayGateway for Ruby 1.9 compat [cody] +* Don't return an array when finding the country code. Fixes issue with Ruby 1.9 [cody] +* Fix custom assertions for Ruby 1.9 [cody] +* Deprecate Money objects [cody] +* Update JCB rejex to catch all valid PANs [pjhyett] +* Remove old TransaXGateway constant [cody] +* Remove old ProtxGateway constant [cody] +* Remove old BrainTree constant [cody] +* Remove AuthorizedNet constant [cody] +* SecurePay changed their delimeter from % to ,. Update gateway to handle changes [Soleone] +* Fix documentation typo in base.rb [mig-hub] +* Add capture test to Linkpoint [Dusty Doris] +* Fix bug in Linkpoint with ternary operator and Ruby 1.9.1 [Dusty Doris] +* Add currency and processor options to Braintree gateway [cbillen] +* Unify API to always look for billing_address/address hash inside of options [stopdropandrew] +* Fix bug with Modern Payments Gateway where failure authorizations appeared to be successful [cody] +* Fix Modern Payments Gateway [cody] +* Use basic SkipJack host for all non-authorization transactions. Fix status method [cody] +* Strip non alpha numeric chars out of MerchantWare order number [cody] +* Parse complete response of Authorize.net CIM gateway [Patrick Joyce] +* Update to PayPal Sandbox URL for testing Payflow Pro Express Checkout. See Express Checkout for Payflow Pro guide [cody] +* Provide a C_STATE value of "Outside United States" for SageGateway when processing international customers [cody] +* PayPal Website Payments Pro Canada supports Amex [cody] +* Add line item support for LinkpointGateway. [Tony Primerano] +* Add support for SallieMae gateway [iamjwc] +* Add support for the JetPay gateway [Phil Ripperger, Peter Williams, cody] +* Add support for advanced SkipJack processors. Pass :advanced => true when constructing gateway [cody] +* Support test option in AuthorizeNetCimGateway [Tim] +* Improve Ogone error messages [cody] +* Add support for :test => true option to OgoneGateway [cody] +* Bump PayPal Version to 59.0 [cody] +* Add amex support to eWay gateway [cody] +* Change Payflow header X-VPS-Timeout -> X-VPS-Client-Timeout [cody] +* Fix typo preventing OgoneGateway from working in production [Nicolas Jacobeus] +* Add support for the Elavon MyVirtualMerchant gateway [jstorimer] +* Fix recurring transactions in Ogone gateway [cody] +* Fix money formatting for Ogone gateway [cody] +* Tweak Ogone gateway to use ActiveMerchant conventions for reference transactions [cody, jstorimer] +* Add support for the Ogone DirectLink payment gateway [Nicolas Jacobeus] +* Add support for the Antigua based FirstPay payment gateway [Phil R] +* Add support for PayPal reference transactions [kevin, John, Rahsun McAfee] +* Add support for the MerchantWARE payment gateway [cody] +* Rename Protx to SagePay [jstorimer] +* Allow test mode for eWay gateway [Duff OMelia] +* Don't use Time.parse for the ExpiryDate [cody] +* Add support for CVV code to Authorize.net CIM [Guy Naor] +* Add shipping address to Authorize.net [Eric Tarn] +* Don't setup the logger by default [cody] +* Refactor ActiveMerchant::Connection out of the PostsData module. Add support for logging and wiredumping requests [cody] +* Assume a valid load path when running tests [cody] +* Use SHIPTOSTREET2 element instead of STREET2 element for Payflow Express Uk address [cody] +* Clean up the test helper [cody] +* Fix DataCash unit test that was making a remote call [cody] +* Don't check Request#test? for remote PaymentExpress tests because their test environment has changed [cody] +* Update Instapay gateway to support capture and add address, order, and invoice fields. Add support for CVV and AVS response [cody] +* Add support for Instapay gateway [brahma] +* Cleanup PaymentExpress reference purchases and turn on AVS [cody] +* Add reference purchases and authorizations to PaymentExpress [mocra] +* Add support for Merchant e-Solutions Gateway [Zac Williams, Robby Russell] +* Fix Braintree unit test [cody] +* Add support for checks to SmartPs gateways [jvoohris] +* Extract SmartPs for Braintree and Transax [mmangino] +* Ruby 1.9 compatibility [bschwartz] +* Update Payflow Express to handle Street2 element [James MacAulay] +* Fix typo in Protx DeliveryState field [cody] +* Ignore Wirecard state unless it is 2 characters [Cody] +* Update Wirecard to make country and state processing more robust [Soleone] +* Update ProTX to use the latest v2.23 protocol [Tekin] + +== Version 1.4.2 (April 24, 2009) + +* Fix typo in Authorize.net CIM [infused] +* Add missing ISO countries [Edward Ocampo-Gooding] +* Add support for Guernsey to country.rb [cody] +* Add American Express to the MonerisGateway [cody] +* Use :words_connector instead of connector in RequiresParameters [cody] +* Fixed CreditCard not validating start_month and start_year when set as string [Tekin] +* Update PostsData to support get requests [cody] +* Fix broken Quickpay remote test [cody] +* Update Quickpay gateway to v3. Add support for offsite integration for Danish Dankort cards [Lars Pind] +* Use default partner id when passed in :partner is blank with PayflowGateway [cody] +* Remove PayflowGateway.certification_id [cody] +* Set Response#test? to true in TrustCommerce gateway when using the demo account in production [cody] +* Correctly set Sage.supported_countries [cody] +* Add BogusGateway#void [Donald Ball] +* Fix PSL gateway capturing [cody] +* Fix failed Visa debit purchases with PSL gateway start date info is present [cody] +* Support personal fixtures file on Windows [cody] +* Clearer variable naming for BraintreeGateway#authorize [Jonathan S. Katz] +* Fix brittle Authorize.net tests [cody] +* Add support for Authorize.net duplicate window [Seamus Abshere] +* Return transaction id for PayPal refunds [jxtps435] +* Allow storage of e-checks with BraintreeGateway [jimiray] +* Add test URL to PayJunction gateway [boomtowndesigngroup] +* More robust parsing for Wirecard gateway [Soleone] +* Pass the issue number to CardStream verbatim and update test card numbers [Soleone] + +== Version 1.4.1 (December 9, 2008) + +* Update CardStream URL. Note that you will also need to update your login id. [cody] + +== Version 1.4.0 (November 27, 2008) + +* Return failed authorization when SkipJack purchase fails [Tron, cody] +* Update README [cody] +* Add metadata to Authorize.net CIM gateway [cody] +* Make ActionViewHelper compatible with changes to concat method in ActionPack [cody] +* Remove PayPal and Payflow Name-Value gateways. PayPal is no longer terminating the Payflow XML API. [cody] +* Don't directly use the inflector in the action view helper [cody] +* Work around Rails Inflector change [cody] +* Add configurable timeouts to PostsData [Michael Koziarski] +* Add valid_sender? method to gateway integrations [Soleone] +* Fix PayPal error parsing [cody] +* Fix MIT-LICENSE [cody] +* Add a payment gateway for Website Payments Pro Canada [cody] +* Fix shipping amount option in Sage gateway [Darrick Wiebe] +* Improved message and error message handling [Soleone] +* Get Wirecard working in the Live environment [Soleone] +* Remove dead code in PayPal Common API files [cody] +* Use the PayPal short error message if the long message is empty [cody] +* Fix unit tests when being run by Cruise Control [cody] +* Add support for PayPal Fraud Review Response [cody] +* Add testing support for German Wirecard Gateway [Soleone] +* Specify required version of ActiveSupport [cody] +* Make ssl_strict a superclass_delegating_accessor so the entire application's validation of SSL certs can be disabled in the event of certificate problem. [cody] +* Make Gateway.application_id a superclass_delegating_accessor so it can be set from outside the subclass definition [cody] +* Add Discover to the list of supported card types for Braintree [cody] +* Add support for Modern Payments gateway [Jeremy Nicoll, cody] +* Add support for EFT/ACH and Interac Online to the BeanstreamGateway [cody] +* Document the SageGateway [cody] +* Add support for echecks with SageGateway. [cody] +* Handle all successful SecurePay AU response codes [cody] +* Get SageGateway working with real test account. Improve test suite. [cody] +* Unify TrustCommerce, Payment Express, and Braintree CC storage [benjamin.curtis] +* Update to use new Payflow Pro URLs [cody] +* Fix missing Content-Type header for Ruby 1.8.4 [cody] +* Fix Authorize.Net CIM response.message [patrick.t.joyce] +* Add JCB and Diners Club as supported cards to SageGateway [cody] +* Add CA country code to Sage gateway's supported countries [cody] +* Add support for Sage Payment Solutions gateway [cody] +* Add test mode detection to Beanstream [cody] +* Add support for Beanstream payment gateway [xiaobozz] +* Add support for PayPal NV Pair API. Will be used to replace the usage of the PayPal SOAP API in ActiveMerchant in the future [Greg Furmanek, cody] +* Protx does support UK Maestro [cody] +* Add tests for length of UK Maestro cards [cody] +* Return all the error messages and codes from paypal responses [cody] +* Fail hard when attempting to capture without a credit card with NetRegistry [cody] +* Add support for the order fields to the create_customer_profile_transaction in Authorize.net CIM. [Patrick T. Joyce] +* Strip invalid characters and limit lengths of Protx customer data [Simon Russell] +* Fix empty start or end dates in Protx [Simon Russell] +* Add support for Authorize.net CIM [Patrick T. Joyce, Ian Lotinsky] +* Add option to skip order review to all PayPal Express gateways [garret.alfert, cody] +* Add capturing partial amounts, fix issue number formatting, fix authorization string when nil values returned, fix parsing of multiple '=' characters, simplify message_from [Simon Russell] +* Fix StartDate in ProtxGatewy [cody] +* Add support for refunds and continuous authority references to DataCashGateway [joel.chippindale] +* Fix gross in HiTrust notification. Don't use Money object in Verifi gateway [cody] +* Initial implementation of Payflow Name-Value API [Greg Furmanek] +* Add support for CyberSource credits [mjuneja] + +== Version 1.3.2 (February 24, 2008) + +* Actually fix the bug by adding extdata element to Payflow Requests [cody] +* Fix bug with adding name to Payflow requests [cody] +* Gateways will now look for CreditCard#brand before looking for CreditCard#type [cody] +* Make before_validate in CreditCard more clear [keith_du...@mac.com, cody] +* Don't send full Australian state names to PayPal [cody] +* Return last_digits that are less than 4 characters long [cody] +* Fix Bug with Authorize.Net ARB Remote Test [patrick.t.joyce] +* Add support for forcing test mode on Secure Pay AU gateway [cody] +* Update Secure Pay Au to meet specs for MessageInfo elements [cody] +* Add support for the Australian Secure Pay payment gateway [cody] +* Allow LinkPoint cancellations for recurring billing. [yanagimoto.shin] +* Add support for Åland Islands to the country list [cody] + +== Version 1.3.1 (January 28, 2008) + +* Rename BrainTreeGateway to BraintreeGateway, but keep alias to old naming for backwards compatibility [cody] + +== Version 1.3.0 (January 28, 2008) + +* Remove attr_readers for url and response from Gateway [cody] +* Remove @url from EfsnetGateway [cody] +* Remove @response instance variable in QuickpayGateway. [cody] +* Remove @response instance variable in PsigateGateway. Don't use billing address for shipping [cody] +* Remove @response instance variable in PaypalGateway. Don't use billing address for shipping. [cody] +* Remove @response instance variable in PayflowGateway [cody] +* Remove @response instance variable in MonerisGateway [cody] +* Remove @response instance variable and don't use billing address for shipping address in LinkpointGateway [cody] +* Remove @response instance variable from ExactGateway [cody] +* Remove @response instance variable from EwayGateway [cody] +* Remove @response instance variable from EfsnetGateway [cody] +* Remove @response instance variable from DataCashGateway [cody] +* Don't use billing_address for shipping_address in CyberSourceGateway [cody] +* Remove @response instance variable from CardStreamGateway [cody] +* Remove @response instance variable from BrainTreeGateway [cody] +* Remove unused deal_with_cc method from BogusGateway [cody] +* Remove test_result_from_cc_number completely from ActiveMerchant [cody] +* Don't use billing_address for shipping_address in Realex [cody] +* Update Realex to add support for cvv data. remove test_result_from_cc_number. [cody] +* Update Protx to add support for avs and cvv data. remove test_result_from_cc_number. [cody] +* Include ActiveMerchant::Utils module in test_helper and use generate_unique_id from the module instead of generate_order_id. [cody] +* Update SecurePay tests to check for avs and cvv data. [cody] +* Update SkipJack to add support for avs and cvv data. remove test_result_from_cc_number. [cody] +* Move generate_unique_id to its own module [cody] +* Update Viaklix to add support for avs and cvv data. remove test_result_from_cc_number. Truncate fields to avoid failure [cody] +* Update PSL Card Gateway to add support for avs and cvv data. remove test_result_from_cc_number. [cody] +* Update PlugNPayGateway to support avs and cvv data. Remove test_result_from_cc_number. [cody] +* Update PaymentExpressGateway to remove test_result_from_cc_number. [cody] +* Update PaySecure to remove test_result_from_cc_number. [cody] +* Update NetbillingGateway to support avs and cvv data. Remove test_result_from_cc_number. [cody] +* Replace all usage of :address with :billing_address in test cases [cody] +* Remove sensitive data from NetRegistryGateway responses. Refactor gateway and tests. Remove test_result_from_cc_number. [cody] +* Update VerifiGateway to support avs and cvv data. Remove test_result_from_cc_number. [cody] +* Small refactoring of UsaEpayGateway [cody] +* Update UsaEpayGateway to support avs and cvv data. Remove test_result_from_cc_number. [cody] +* Update TrustCommerce docs now that the gateway falls back to SSL post when tclink isn't available [cody] +* Change ARB to use correct :address1 key for addresses [cody] +* No need for specialized recurring response for Authorize.net recurring billing [cody] +* Update TransFirst to support avs and cvv data. Remove test_result_from_cc_number. [cody] +* Maintain backwards compatibility with :address option for now in the Payflow gateways [cody] +* Remove test_result_from_cc_number from SecurePayTech. Improve unit test coverage [cody] +* Fix email option in PayflowGateway. Remove support for :address option. :billing_address and :shipping_address must now be passed in separately. [cody] +* Make Bogus gateway's credit() method behave like capture [cody] +* Add update and delete methods to update and delete records stored in the vault. [benjamin.curtis] +* Add support for recurring_inquiry() to the PayflowGateway [dave.my...@contentfree.com] +* Add support for Authorize.net Automated Recurring Billing (ARB) [vkurnavenkov, forestcarlisle, ianlotin...@hotmail.com, patrick.t.joyce] +* Fix laser card regex [ladislav.martincik] +* Cleanup whitepace in README [patrick.t.joyce] +* Update ExactGateway to support avs and cvv data. Remove test_result_from_cc_number. [cody] +* Remove test_result_from_cc_number from eWay gateway. [cody] +* Remove duplicate attr_reader definitions from all gateways [cody] +* Remove useless tests raising Error [cody] +* Update gateway templates [cody] +* Fix Authorize.net test where authorize() was being called instead of purchase(). Perform some cleanup of the tests [ianlotin...@hotmail.com, cody] +* Improve Authorize.net documentation based on the DataCashGateway docs [patrick.t.joyce] +* Update EfsnetGateway to support avs and cvv data. Remove test_result_from_cc_number. [cody] +* Remove test_result_from_cc_number from DataCash. Improve unit test coverage [cody] +* Update CyberSourceGateway to support avs and cvv results. Remove test_result_from_cc_number. [cody] +* Remove match information from CVVResult [cody] +* Remove Response#card_data. The application has access to the information anyway [cody] +* Return the last 4 digits of the card number from the Response instead of the masked number [cody] +* Actually use the shipping address in TrustCommerce [cody] +* Update TrustCommerceGateway to support avs and cvv results. Remove test_result_from_cc_number. Automatically fallback to SSL POST if the TCLink library is not available. Add additional customer information to the requests. [cody] +* Fix remote CardStreamGateway tests [cody] +* Map merchant AVS codes to street and postal match codes [cody] +* Update CardStreamGateway to support avs and cvv data [cody] +* Remove merchant_data hash. Add additional CVV codes [cody] +* Update QuickpayGateway to support merchant_data hash. Remove test_result_from_cc_number. [cody] +* Update LinkpointGateway to support merchant_data hash. Remove test_result_from_cc_number. [cody] +* Update PsigateGateway to support merchant_data hash. Remove test_result_from_cc_number. [cody] +* Update MonerisGateway to support merchant_data hash. Remove test_result_from_cc_number. [cody] +* Remove AVS Message and CVV2 Message from params hash in Authorize.net [cody] +* Update BrainTreeGateway to support merchant_data hash [cody] +* Update PaypalGateway to support merchant_data hash [cody] +* Update Payflow to support merchant_data hash [cody] +* Add card data to PayJunction response. PayJunction does not return the CVV or AVS result codes. Remote test_result_from_cc_number from PayJunction. [cody] +* Rename CCVResult to CVVResult to be more aligned with ActiveMerchant's usage of the term verification value [cody] +* Remove test_result_from_cc_number from Authorize.net in favour of mocking [cody] +* Add merchant_data hash, which contains all of the card_data, avs_result, and ccv_result. [cody] +* Add CCVResult for the Card Code Verification Result. Update Authorize.net to use the new class [cody] +* Rename AVSResult#match_type AVSResult#match [cody] +* Rename AVS::Result class to AVSResult [cody] +* Convert Authorize.net gateway to use the new AVS module [cody] +* Add AVS data to the Response object [cody] +* Fix credentials for remote Authorize.net TEST MODE test [cody] +* Add AVS module and AVS::Result class [cody] +* Update base gateway class RDOC [cody] +* Update the README with the latest list of supported gateways. Update the example in the README to include the verification value, which is now required by the credit card object by default. [cody] +* Handle the return from 2Checkout [cody] +* Automatically determine the credit card type when a type is not provided [cody] +* Revert to initial implementation of LUHN algorithm because it all fits in one simple method [cody] +* Remove unused api_cert_chain.crt file [cody] +* Update PaypalGateway, and PaypalExpressGateway to send requests to the correct endpoints when using API signatures [cody] +* Successful return code for HiTRUST is actually 00 [cody] +* Make ActiveMerchant::Billing::Error a subclass of ActiveMerchant::ActiveMerchantError [cody] +* Handle the return from the offsite payment gateways [cody] +* Default HiTRUST order description to "Store purchase" [cody] +* Fix HiTRUST field names [cody] +* Add support for passing in the locale code [georg.fr...@meandevel.com] +* Add support for the Offsite payment gateway HiTRUST [cody] +* Accept SuccessWithWarning as success [cody] +* Add a link to the LinkPoint staging server docs in remote_linkpoint_test.rb [cody] +* Update Discover regex [cody] +* Match full pan range of Maestro cards from 12 - 19 digits in length [cody] +* Fix errors on base of CreditCard [josh.bassett] +* Update product to use Rubigen instead of stolen Rails generator [cody] +* Mimic directory structure of unit tests in remote tests [cody] +* Restructure the location of the remote tests [cody] +* Ensure DataCash order_id is limited to 30 characters [cody] +* Return the pretty messages from PayJunction based on the return code [cody] +* make CreditCard.require_verification_value = true the default [cody] +* Use existing credit_card helper in credit card tests [cody] +* Return the authrorization number of the original transaction in the SkipJack gateway [cody] +* Update format of line items given to the gateway. Cleanup and uncomment unit tests [cody] +* Add support for the SkipJack gateway [Bill Bereza, cody] +* Make the bogus gateway easier to test by moving messages into constants [cody] +* Add retry logic when connection has been refused for all gateways. Enable safe retries of all connection failures with the PayflowGateway, as it has a unique request header. [cody] +* Catch Timeout::Error when posting data [cody] +* Change order of loading ActionPack for tests since assert_success defined in ActionController::Assertions::DeprecatedAssertions inteferes with ActiveMerchant's definition [cody] +* Catch Errno::ETIMEDOUT and extend open and read timeouts to 60 seconds [cody] +* Add address2 to the billing address of Viaklix transactions [cody] +* Improve Psigate generic error message [cody] +* Fix small errors in Psigate documentation [cody] +* Add Response#fraud_review? query method to the response. Allows gateways to indicate that a payment is pending review by the fraud service [cody] +* Handle Errno::ECONNRESET when posting data [cody] +* Fix broken USA ePay URL [cody] +* Update RequiresParameters to support HashWithIndifferentAccess [cody] +* Add support for SecurePayTech payment gateway [Jasper Bryant-Greene] +* Detect when test credentials are being used with PayJunction [cody] +* Update documentation about TrustCommerce void [cody] +* Add void to TrustCommerce [jesse.c.scott] +* Add support for echecks to the BrainTree gateway [Jeremy Voorhis] +* Fix before_validate and validate methods in CreditCard [rick.denatale] +* Add support for Netbilling payment gateway [cody] +* Pass in N/A for unknown states when a country is present in PaypalGateway [cody] +* Strip non alpha chars from order_id in Payflow gateway, as Paymentech Tampa can't handle them [cody] +* Add support for the PaySecure payment gateway [cody] +* Add support for descriptions in Authorize.net credits [shiva.kaul] +* Great cleanup and improvement of CreditCard code, tests, and docs [James Herdman] + +== Version 1.2.1 + +* Fix remote PayPal tests [cody] + +== Version 1.2.0 + +* Update Linkpoint tests to remove useless pem file [cody] +* Use symbols for CreditCard error messages, since errors have indifferent access [cody] +* Improve CreditCard error messages [George Ogata] +* Change deny to assert_false, and deny_success to assert_failure. Remove Gateway.gateway, as it is available from Base [cody] +* Improve documentation, and test coverage [James Herdman] +* Refactor MonerisGateway, improve test coverage and documentation [James Herdman] +* Add support for crediting to Moneris [James Herdman] +* Send state N/A in Payflow when the state is blank. Fixes UK PayPal Express payments when not providing a state [cody] +* Load remote test credentials from a fixtures file. ActiveMerchant will look for a custom file ~/.active_merchant/fixtures.yml. If the file exists it will be loaded instead of the default fixtures provided by ActiveMerchant. This makes development easier, and removes the risk of committing non-public test account credentials to subversion. [cody] +* Add support for password protected pem files [cody] +* Add support for Concord Efsnet payment gateway [snacktime] +* Fix dependency loading for gateways that are subclasses [cody] +* Add Braintree payment gateway [Michael J. Mangino] +* Add support for PayPal API signatures [Benjamin Curtis, cody] +* Add payment gateway Viaklix [Sal Scotto, cody] +* Add Australian payment gateway NetRegistry [George Ogata] +* Take order email from the options hash instead of the address for CyberSource [cody] +* Use an array for LineItems when calculating tax in CyberSource gateway [cody] +* Add CyberSource gateway [Matt Margolis] +* Sanitize Protx order id [cody] +* Fix support for electron in Protx [cody] +* Add support for Protx [shiftx, cody] +* Use undef_method with a single argument in SecurePay to prevent JRuby from choking on it. [jonathan.l.bartlett] +* Default address_override to 0 for PayPal Website Payments Standard payments. [cody] +* Enhance credit card error messages [manfred] +* Use HashWithIndifferentAccess for CreditCard for compatibility with Rails applications [michael.j.mangino] +* Fix nil exception when no response reason text is found in Authorize.net [cody] +* Add support for PayJunction [Matt Sanders] +* Change billing_address to shipping_address in PayPal Integration helper, as billing_address was incorrect. Addresses passed to billing_address for the PayPal helper will no longer be added to the form. This will break existing code, as the address will not be passed. +* Remove switch patterns from card detection that were eliminated on July 1, 2007 [cody] +* Format the issue number in Payflow requests to always be 2 digits [cody] +* Move application_id to Gateway and Helper class respectively [cody] +* Improve TrustCommerce documentation [cody] +* Add credit to Payflow [cody] +* Add support for the Plug 'N Pay gateway [ryan.norbauer, cody] +* Add support for ItemTotal, Shipping, Handling, and Tax amounts in the PayPal Express and PayPal gateways [baldwindavid, cody] +* Add page customization options to the PaypalExpress, and PayflowExpress gateways [ cpjolicoeur, cody] +* Add Verifi gateway [Paul Hepworth] +* Add a PayflowResponse object with a profile_id accessor method. Return the correct authorization number on recurring actions [cody] +* Add support for an initial transaction with recurring payments [findchris, cody] +* Add support for email receipts to recurring Payflow Payments [Rick Olson] +* Ensure the ButtonSource isn't too long [cody] +* Add ButtonSource to Paypal and PaypalExpress gateways [cody] +* Rename application to application_id and place it on Base, so it can be set once and forgotten about [cody] +* Add ButtonSource field to PayflowExpress gateway [cody] +* Add a field for the bn to the PayPal helper [cody] +* Add remote secure pay test and correctly define test? [cody] +* Undefine unsupported methods from SecurePay [cody] +* Enhance the TransFirst error message for declined transactions [cody] +* Add initial support for TransFirst gateway [cody] +* Deprecate certification_id in Payflow gateways [cody] +* Work around required PayPal state fields for countries that don't require states [cody] +* Add metadata to SecurePay gateway [cody] +* Add initial support for the SecurePay gateway using the Authorize.net translator [cody] +* Add the homepage_url and display_name accessors to each gateway [cody] +* Remove Money dependency from main gateways. Cleanup tests. Add supported_countries class accessor which returns an array of 2 digit iso country codes for which countries the gateway supports accounts in [cody] +* Add American Express card to Psigate [cody] +* Send N/A to PayPal in the PayPal Helper when we don't know the UK county [cody] +* Actually pass the amount of the capture through to Payflow [cody] +* Update ExactGateway test and test mode [cody] +* Remove unused method in PslCardGateway [cody] +* Add updated credit card tests [cody] +* Update and test PslCardGateway [cody] +* Add Laser card type [cody] +* Update Nochex documentation [cody] +* Sanitize the Realex order_id [cody] +* Add support for Irish Realex payment gateway [John Ward, cody] +* Move credit_card helper method to the test_helper [cody] +* Update PayflowExpressResponse to match the interface of the PayflowExpressResponse. Add :no_shipping and :address_override options to PayflowExpress [cody] +* Add a currency option to the Payflow and Paypal gateways [cody] +* PaypalExpress should use the shipping address, not the billing address [cody] +* Allow overriding the user with Payflow so that a vendor and user can be provided when making requests [cody] +* PayPal DirectPayment API requires a UK County to be sent as the state or province. Return N/A as the state when one isn't provided to ensure that PayPal doesn't reject the payment [cody] +* Add ability to perform reference transactions with Payflow [Al Evans, cody] +* Enhance recurring Payflow tests and recurring_inquiry [Al Evans] +* Add recurring payments to Payflow [Rick Olson] +* Improve the error message generated by requires! [cody] +* Update credit card regular expressions and update Quickpay gateway with tests for new cards [cody] +* Add support for token based payments to PaymentExpress [Nik Wakelin] +* Refactor default_currency to the base gateway class [cody] +* Clean unsupported characters from the Quickpay ordernum [cody] +* Call the :sale and :authorization in QuickpayGateway [cody] +* Add Danish gateway Quickpay [cody] +* Remove redundant hash brackets from generator template [cody] +* Add additional options to the PayPal Website Payments Standard Helper [Rick Olson] +* Move generate_unique_id method to Gateway class so other gateways can also use it [cody] +* Allow notification name / value pairs to have a . in the name like checkout.x = 400 [cody] +* Fix PaypalExpressGateway#purchase to have the same method signature as other gateways [cody] +* Cargo cult off the rails unique id generator instead of UUID library [cody] +* Add uuid-1.0.3 for generating random request UUIDs [cody] +* Remove mock_methods and http mock from the library [cody] +* PaypalExpress cannot setup a payment for 0 dollars. If the amount is zero then setup a payment for $1. [cody] +* Small changes to PslCard gateway [cody] +* Fix Money dependency with PslCard gateway [cody] +* Add PslCard payment gateway [MoneySpyder http://moneyspyder.co.uk] +* Scrub the card number, expiry, and CVV code from the response [cody] +* Use test? query for checking test mode [cody] +* Add support for the E-xact Payment Gateway [James Edward Gray II, cody] +* Fix partially broken method of dealing with phone numbers in the PayPal Helper [cody] +* Update remote tests for PaymentExpress [cody] +* Add Content-Type header to PaymentExpress post [cody] +* Use DECLINED as the message for declined transactions in the PaymentExpress remote tests [cody] +* Add JCB as a supported card type for the PaymentExpressGateway [cody] +* Rename DpsGateway to PaymentExpressGateway [cody] +* Add DPS Payment Express gateway (NZ) [dgjones, cody] +* Remove duplicate and incorrect expdate method from Authorize.net [cody] +* Allow authorization and purchase using a billing_id retrieved from TrustCommerce citadel [jesse.c.scott] +* Don't return a frozen string from CreditCard.type? [cody] +* Update remote Psigate test to ensure using a verification value doesn't break anything [cody] +* Update remote Moneris test to ensure using a verification value doesn't break anything [cody] +* Fix Solo issue number with CardStream gateway and improve test coverage [cody] +* Add CardStream gateway [Jonah Fox, Thomas Nichols, cody] +* Verify Peer in PayPal notifications and add account method [cody] + +== Version 1.1.0 + +* Add unique_id option to PayPal mass payments [Haig] +* Fix expiry date in USA ePay [cody] +* Fix PayPal Payments Pro UK with Switch & Solo cards [cody] +* Add reauthorization to PaypalGateway and PaypalExpressGateway [dorrenchen] +* Update DataCash tests and format merchant reference number to meet DataCash's requirements [MoneySpyder, cody] +* Add Datacash gateway [MoneySpyder, cody] +* VERIFY_PEER on all SSL requests [cody] +* Add support for 2Checkout [cody] + +== Version 1.0.3 + +* Add support for PayPal mass payments to the PaypalGateway and the PaypalExpressGateway [Brandon Keepers] +* Add a credit method to Authorize.net [cody] + +== Version 1.0.2 + +* Add support for OrderDescription, Payer, and InvoiceID fields in PaypalGateway [cody] + +== Version 1.0.1 + +* Add support for crediting to PayPal [cody, Haig] + +== Version 1.0.0 + +* Add discover to list of supported card types for Authorize.net +* Fix Psigate crediting [sean.alien8@gmail.com] +* Fix dependency loading of tests +* Add methods for storing credit cards to the Bogus gateway [Jim Kane] +* Fix bugs in expiration dates. [Jim Kane] +* Fixed bugs related to authorized.net [Rick Olson] +* Linkpoint is now a full featured backend for active merchant [Ryan Heneise] +* Added linkpoint support [Ryan Heneise] +* Added trust commerce gateway [Hans Friedrich] +* Removed shipping stuff until there is time to implement it properly +* The library now rejects money amounts which are not either cents as integer or a Money object +* Moneris now uses the same layout as the authorized.net plugin +* Added authorized.net +* Changed default to :test mode. Set to production with ActiveMerchant::Billing::Base.gateway_mode = :production +* More refactoring +* Refactored a bit so that there is space for billing and shipping area. None of the shipping aids are fleshed out yet. Needs more work. +* Added Moneris support +* Credit card in memory object resembling a AR object +* Credit card validation methods as static methods of the credit card object + +== PlanetArgon fork for integrating Merchant eSolutions gateway From ba311b5ccafbbc75043d6b028d1521bf0f99cc97 Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Thu, 28 Sep 2017 12:33:13 -0400 Subject: [PATCH 195/677] FirstData E4: Scrub 3DS cryptogram (#2596) --- CHANGELOG | 3 ++- lib/active_merchant/billing/gateways/firstdata_e4.rb | 7 ++++--- test/unit/gateways/firstdata_e4_test.rb | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ad0ea0b9418..2b428a19316 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,8 @@ == HEAD * Braintree Blue: Explicitly require braintree-ruby version 2.78 [anotherjosmith] * Wirecard: Format non-fractional currency amounts correctly [bdewater] #2594 +* Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 +* FirstData E4: Scrub 3DS cryptogram [jasonwebster] #2596 == Version 1.72.0 (September 20, 2017) * Adyen: Fix failing remote tests [dtykocki] #2584 @@ -20,7 +22,6 @@ * MercadoPago: Send diners_club cards as diners [davidsantoso] #2585 * PayU Latam: Correctly condition buyer element fields [curiousepic] #2578 * PayU Latam: Pass unique buyer fields and country requirements [curiousepic] #2570 -* Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 * Qvalent: Support general credit [curiousepic] #2558 * SafeCharge: Update to Version 4.1.0 [nfarve] #2556 * WePay: Don't default API version header [curiousepic] #2567 diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index f8f48ccc774..985bc6449f2 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -141,9 +141,10 @@ def supports_scrubbing? end def scrub(transcript) - transcript. - gsub(%r(().+()), '\1[FILTERED]\2'). - gsub(%r(().+()), '\1[FILTERED]\2') + transcript + .gsub(%r(().+()), '\1[FILTERED]\2') + .gsub(%r(().+()), '\1[FILTERED]\2') + .gsub(%r(().+()), '\1[FILTERED]\2') end def supports_network_tokenization? diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb index 548d8795353..2e84b379689 100755 --- a/test/unit/gateways/firstdata_e4_test.rb +++ b/test/unit/gateways/firstdata_e4_test.rb @@ -304,7 +304,7 @@ def pre_scrubbed starting SSL for api.demo.globalgatewaye4.firstdata.com:443... SSL established <- "POST /transaction/v11 HTTP/1.1\r\nContent-Type: application/xml\r\nAccepts: application/xml\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.demo.globalgatewaye4.firstdata.com\r\nContent-Length: 593\r\n\r\n" - <- "REDACTEDREDACTED001.0042424242424242420916Longbob LongsenVisa1234 My Street|K1C2N6|Ottawa|ON|CA11231Store Purchase" + <- "REDACTEDREDACTED001.0042424242424242420916Longbob LongsenVisa1234 My Street|K1C2N6|Ottawa|ON|CA11231Store Purchaselol" -> "HTTP/1.1 201 Created\r\n" -> "Cache-Control: max-age=0, private, must-revalidate\r\n" -> "Content-Type: application/xml; charset=utf-8\r\n" @@ -320,7 +320,7 @@ def pre_scrubbed -> "Connection: Close\r\n" -> "\r\n" reading 2872 bytes... - -> "\n\n AD2327-05\n \n 00\n 1.0\n \n ############4242\n 42930941\n \n \n \n ET151682\n 0916\n Longbob Longsen\n 1234 My Street|K1C2N6|Ottawa|ON|CA\n 123\n 0\n \n \n \n \n \n \n \n \n \n \n \n 1\n \n Store Purchase\n \n 216.191.105.146\n \n false\n true\n 00\n Transaction Normal\n 100\n Approved\n \n 106826\n 1\n M\n 0025564\n \n USD\n \n false\n Shopify DEMO0678\n 126 York Street\n Ottawa\n Alabama\n Canada\n K1N 5T5\n www.shopify.com\n \n Visa\n \n \n \n \n false\n =========== TRANSACTION RECORD ==========\nShopify DEMO0678\n126 York Street\nOttawa, AL K1N 5T5\nCanada\nwww.shopify.com\n\nTY" + -> "\n\n AD2327-05\n \n 00\n 1.0\n \n ############4242\n 42930941\n \n \n \n ET151682\n 0916\n Longbob Longsen\n 1234 My Street|K1C2N6|Ottawa|ON|CA\n 123\n 0\n \n \n \n \n \n \n \n \n \n lol\n \n 1\n \n Store Purchase\n \n 216.191.105.146\n \n false\n true\n 00\n Transaction Normal\n 100\n Approved\n \n 106826\n 1\n M\n 0025564\n \n USD\n \n false\n Shopify DEMO0678\n 126 York Street\n Ottawa\n Alabama\n Canada\n K1N 5T5\n www.shopify.com\n \n Visa\n \n \n \n \n false\n =========== TRANSACTION RECORD ==========\nShopify DEMO0678\n126 York Street\nOttawa, AL K1N 5T5\nCanada\nwww.shopify.com\n\nTY" -> "PE: Purchase\n\nACCT: Visa $ 1.00 USD\n\nCARDHOLDER NAME : Longbob Longsen\nCARD NUMBER : ############4242\nDATE/TIME : 26 Jan 15 12:11:44\nREFERENCE # : 106826 M\nAUTHOR. # : ET151682\nTRANS. REF. : 1\n\n Approved - Thank You 100\n\n\nPlease retain this copy for your records.\n\nCardholder will pay above amount to card\nissuer pursuant to cardholder agreement.\n=========================================\n\n" read 2872 bytes Conn close @@ -334,7 +334,7 @@ def post_scrubbed starting SSL for api.demo.globalgatewaye4.firstdata.com:443... SSL established <- "POST /transaction/v11 HTTP/1.1\r\nContent-Type: application/xml\r\nAccepts: application/xml\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.demo.globalgatewaye4.firstdata.com\r\nContent-Length: 593\r\n\r\n" - <- "REDACTEDREDACTED001.00[FILTERED]0916Longbob LongsenVisa1234 My Street|K1C2N6|Ottawa|ON|CA1[FILTERED]1Store Purchase" + <- "REDACTEDREDACTED001.00[FILTERED]0916Longbob LongsenVisa1234 My Street|K1C2N6|Ottawa|ON|CA1[FILTERED]1Store Purchase[FILTERED]" -> "HTTP/1.1 201 Created\r\n" -> "Cache-Control: max-age=0, private, must-revalidate\r\n" -> "Content-Type: application/xml; charset=utf-8\r\n" @@ -350,7 +350,7 @@ def post_scrubbed -> "Connection: Close\r\n" -> "\r\n" reading 2872 bytes... - -> "\n\n AD2327-05\n \n 00\n 1.0\n \n [FILTERED]\n 42930941\n \n \n \n ET151682\n 0916\n Longbob Longsen\n 1234 My Street|K1C2N6|Ottawa|ON|CA\n [FILTERED]\n 0\n \n \n \n \n \n \n \n \n \n \n \n 1\n \n Store Purchase\n \n 216.191.105.146\n \n false\n true\n 00\n Transaction Normal\n 100\n Approved\n \n 106826\n 1\n M\n 0025564\n \n USD\n \n false\n Shopify DEMO0678\n 126 York Street\n Ottawa\n Alabama\n Canada\n K1N 5T5\n www.shopify.com\n \n Visa\n \n \n \n \n false\n =========== TRANSACTION RECORD ==========\nShopify DEMO0678\n126 York Street\nOttawa, AL K1N 5T5\nCanada\nwww.shopify.com\n\nTY" + -> "\n\n AD2327-05\n \n 00\n 1.0\n \n [FILTERED]\n 42930941\n \n \n \n ET151682\n 0916\n Longbob Longsen\n 1234 My Street|K1C2N6|Ottawa|ON|CA\n [FILTERED]\n 0\n \n \n \n \n \n \n \n \n \n [FILTERED]\n \n 1\n \n Store Purchase\n \n 216.191.105.146\n \n false\n true\n 00\n Transaction Normal\n 100\n Approved\n \n 106826\n 1\n M\n 0025564\n \n USD\n \n false\n Shopify DEMO0678\n 126 York Street\n Ottawa\n Alabama\n Canada\n K1N 5T5\n www.shopify.com\n \n Visa\n \n \n \n \n false\n =========== TRANSACTION RECORD ==========\nShopify DEMO0678\n126 York Street\nOttawa, AL K1N 5T5\nCanada\nwww.shopify.com\n\nTY" -> "PE: Purchase\n\nACCT: Visa $ 1.00 USD\n\nCARDHOLDER NAME : Longbob Longsen\nCARD NUMBER : ############4242\nDATE/TIME : 26 Jan 15 12:11:44\nREFERENCE # : 106826 M\nAUTHOR. # : ET151682\nTRANS. REF. : 1\n\n Approved - Thank You 100\n\n\nPlease retain this copy for your records.\n\nCardholder will pay above amount to card\nissuer pursuant to cardholder agreement.\n=========================================\n\n" read 2872 bytes Conn close From 22966a348f2ee627a059b2419cb7517949cce98f Mon Sep 17 00:00:00 2001 From: Matthew Heath Date: Mon, 4 Sep 2017 22:43:57 +0100 Subject: [PATCH 196/677] PayHub: Replace single quotes with double quotes in error message This fixes interpolating the raw response from Payhub's API in the error message. Closes #2572 and #2516 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/pay_hub.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2b428a19316..d6b4990386f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Wirecard: Format non-fractional currency amounts correctly [bdewater] #2594 * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 * FirstData E4: Scrub 3DS cryptogram [jasonwebster] #2596 +* PayHub: Replace single quotes with double quotes in error message [matthewheath] #2572 == Version 1.72.0 (September 20, 2017) * Adyen: Fix failing remote tests [dtykocki] #2584 diff --git a/lib/active_merchant/billing/gateways/pay_hub.rb b/lib/active_merchant/billing/gateways/pay_hub.rb index fede5ca5c92..afd6be918c2 100644 --- a/lib/active_merchant/billing/gateways/pay_hub.rb +++ b/lib/active_merchant/billing/gateways/pay_hub.rb @@ -200,8 +200,8 @@ def response_error(raw_response) def json_error(raw_response) { - error_message: 'Invalid response received from the Payhub API. Please contact wecare@payhub.com if you continue to receive this message.' + - ' (The raw response returned by the API was #{raw_response.inspect})' + error_message: "Invalid response received from the Payhub API. Please contact wecare@payhub.com if you continue to receive this message." + + " (The raw response returned by the API was #{raw_response.inspect})" } end From 3b3c82d1a2395a3001553fadef65538e51329ce3 Mon Sep 17 00:00:00 2001 From: Andre Lyver Date: Thu, 28 Sep 2017 13:46:52 -0400 Subject: [PATCH 197/677] Release version 1.73.0 --- CHANGELOG | 6 ++++-- lib/active_merchant/version.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d6b4990386f..422b32f0059 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,11 +1,13 @@ = ActiveMerchant CHANGELOG == HEAD -* Braintree Blue: Explicitly require braintree-ruby version 2.78 [anotherjosmith] -* Wirecard: Format non-fractional currency amounts correctly [bdewater] #2594 + +== Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 +* Braintree Blue: Explicitly require braintree-ruby version 2.78 [anotherjosmith] * FirstData E4: Scrub 3DS cryptogram [jasonwebster] #2596 * PayHub: Replace single quotes with double quotes in error message [matthewheath] #2572 +* Wirecard: Format non-fractional currency amounts correctly [bdewater] #2594 == Version 1.72.0 (September 20, 2017) * Adyen: Fix failing remote tests [dtykocki] #2584 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 7acecde7577..8cb7562fef6 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.72.0" + VERSION = "1.73.0" end From a32278fc515396ac9275b3730a8ac39cca3ca9c7 Mon Sep 17 00:00:00 2001 From: Andre Lyver Date: Fri, 29 Sep 2017 10:48:47 -0400 Subject: [PATCH 198/677] Deleting extra erroneous ~ file. This file was added somehow and should be there. --- ~ | 2395 ------------------------------------------------------------- 1 file changed, 2395 deletions(-) delete mode 100644 ~ diff --git a/~ b/~ deleted file mode 100644 index f0b3d68f642..00000000000 --- a/~ +++ /dev/null @@ -1,2395 +0,0 @@ -= ActiveMerchant CHANGELOG - -== HEAD -* SafeCharge: Update to Version 4.1.0 [nfarve] #2556 -* Qvalent: Support general credit [curiousepic] #2558 -* DataCash: Enable refunding recurring transactions [davidsantoso] #2560 -* Ebanx: Adds Brazil Specific Parameters [nfarve] #2559 -* Authorize.net: Restore default state value for non-US addresses [jasonwebster] #2563 -* MercadoPago: Additional tweaks for transaction requests [davidsantoso] -* Braintree Blue: Add eci_indicator field for Apple Pay [davidsantoso] #2565 -* Conekta: Pull required details from billing address [nfarve] #2568 -* MercadoPago: Default to alphanumeric order_id [davidsantoso] -* Conekta: Add guard clause for details fallbacks [curiousepic] #2573 -* WePay: Don't default API version header [curiousepic] #2567 -* PayU Latam: Pass unique buyer fields and country requirements [curiousepic] #2570 -* Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 - -== Version 1.71.0 (August 22, 2017) -* Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551 -* Checkout V2: Add localized_amount support to add_invoice function [nicolas-maalouf-cko] #2452 -* Checkout V2: Add UAE to country list [shasum] #2548 -* Checkout V2: Fix success response code validation [nicolas-maalouf-cko] #2452 -* CreditCall: Only allow AVS when specified [curiousepic] #2549 -* CreditCall: Parse additional params from responses [nfarve] #2552 -* CreditCall: Parse more response params [nfavre] #2543 -* MercadoPago: Small tweaks to building requests [davidsantoso] #2555 -* Orbital: Support Network Tokenization Credit Cards [curiousepic] #2553 -* Orbital: Updgrade schema version to 7.1 [curiousepic] #2546 -* Remove HUF from default non-fractional currencies [curiousepic] #2538 -* Stripe: Add support for statement_address parameters for EMV transactions [malcolm-mergulhao] #2524 -* TransFirst Express: Don't send address2 without value [nfarve] #2545 -* TransFirst Express: Fix Optional Fields Being Passed Blank [nfarve] #2550 -* TransFirst: Fix partial refund [nfarve] #2541 -* Vantiv (Litle): Pass 3DS fields [curiousepic] #2536 -* Braintree Blue: Add phone to options [deedeelavinder] #2564 - -== Version 1.70.0 (August 4, 2017) -* Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520 -* FirstData E4: Fix duplicate XID and CAVV values in tokenized transactions [jasonwebster] #2529 -* FirstData E4: Loose XSD validation for Payeezy (FirstData E4) [jasonwebster] #2529 -* GlobalTransport: Support partial authorizations [dtykocki] #2511 -* Litle: Update schema and certification tests to v9.12 [curiousepic] #2522 -* Litle: Update urls and name to Vantiv [curiousepic] #2531 -* Mercado Pago: Add gateway support [davidsantoso] #2518 -* Orbital: Add support for level 2 data [dtykocki] #2515 -* PayU Latam: Pass DNI Number [curiousepic] #2517 -* Qvalent: Pass 3dSecure fields [curiousepic] #2508 -* SafeCharge: Correct UserID field name [curiousepic] -* SafeCharge: Pass UserID field [curiousepic] #2507 -* AuthorizeNet: Allow Response Code 4 to be returned as successful [nfarve] #2530 -* Forte: Remove order number from captures in Forte Gateway [nfarve] #2532 -* PayU Latam: Add additional mandatory fields [deedeelavinder] #2528 - -== Version 1.69.0 (July 12, 2017) -* WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso] -* Adyen: Use Active Merchant standard order_id option for reference [jasonwebster] #2483 -* Correct calculation for three-exponent currencies [curiousepic] #2486 -* SagePay: Use VPSTxId from authorization for refunds [dtykocki] #2489 -* Payflow: Move PAYPAL-NVP header option to a class attribute on the payment gateway [deuxpi] #2492 -* Optimal Payments: Pass CVD indicator accurately [curiousepic] #2491 -* SagePay: Make Repeat purchase if payment is a past authorization [curiousepic] #2495 -* Netbanx: map response errorCodes onto standard error code [iirving] #2456 -* Netbanx: Update supported countries and cardtypes [iirving] #2456 -* Barclaycard Smartpay: Support 0- and 3-exponent currencies [curiousepic] #2498 -* CyberSource: Fix XSD schema validation issues [jasonwebster] #2497 -* WorldPay: Support three-decimal currencies [curiousepic] #2501 -* NMI: Add first and lastname to echeck transactions [dtykocki] #2499 -* PayFlow: Add optional email field [davidsantoso] #2505 -* Worldpay: Support Credit on CFT-enabled merchant IDs [curiousepic] #2503 -* FirstPay: Add processor_id field [davidsantoso] #2506 -* Authorize.Net: Use two character default for billing state [dtykocki] #2496 - -== Version 1.68.0 (June 27, 2017) -* Authorize.Net: Return failed response if forced refund settlement fails [bizla] #2476 -* Authorize.net: Concatenate address1 and address2 [dtykocki] #2479 -* Braintree Blue: Braintree Blue: Add ECI indicator to Android Pay transactions [davidsantoso] #2474 -* Credorax: Support 0- and 3-exponent currencies [curiousepic] -* Cybersource: update supported card types [bdewater] #2477 -* FirstData: Add a default network tokenization strategy for FirstData E4 [krystosterone] #2473 -* FirstPay: FirstPay: Update hostname and force TLSv1 minimum [davidsantoso] #2478 -* JetPay V2: Support store transactions and token based payments [shasum] #2475 -* Moneris: Add 3DS fields for decrypted Apple and Android Pay data [davidsantoso] #2457 -* Openpay: Send customer name and email in authorize and purchase [dtykocki] #2468 -* Payflow: Moved to name value pair (NVP) with payflow [jusleg] #2462 -* Payflow: Set PAYPAL_NVP header as optional [davidsantoso] #2480 -* QuickPay V10: Return last response for purchase and authorize [curiousepic] #2461 -* SafeCharge: Map billing address fields [davidsantoso] #2464 -* SafeCharge: Track currency from original transaction [davidsantoso] #2470 -* Support three-decimal currencies [curiousepic] #2466 -* Trexle: Add gateway support [hossamhossny] #2351 - -== Version 1.67.0 (June 8, 2017) -* Acapture: Pass 3D Secure fields [davidsantoso] #2451 -* Authorize.net: Pass Level 2 Data Fields [curiousepic] #2444 -* Credorax: Add 3D Secure authentication fields [davidsantoso] #2446 -* Ebanx: Add gateway support [davidsantoso] #2447 -* Ebanx: Reduce supported countries to Brazil and Mexico [davidsantoso] -* FirstData Payeezy: Set default ECI value for auth/purchase transactions [jasonwebster] #2448 -* JetPay V2: Add new gateway [shasum] #2442 -* JetPay V2: Add optional tax data to capture calls [shasum] #2445 -* NMI: Add Network Tokenization support [shasum] #2431 -* Orbital: Pass soft descriptors from options hash [curiousepic] -* Orbital: Update test and production urls [jcowhigjr] #2436 -* Payeezy: Add client_email field for telecheck [davidsantoso] #2455 -* Payeezy: Add customer_id_type and customer_id_number fields [davidsantoso] #2454 -* Quickpay V10: Fix store and token use for recurring payments [wsmoak] #2180 -* Elavon: Support custom fields [curiousepic] #2416 -* WePay: Support risk headers [shasum] #2419 -* WePay: Add Canada as supported country [shasum] #2419 -* Fat Zebra: Fix xid 3D Secure field [curiousepic] -* SafeCharge: Mark support for European countries [curiousepic] -* Checkout V2: Pass customer ip option [curiousepic] -* Realex: Map AVS and CVV response codes [davidsantoso] #2424 -* Opp: Send disable3DSecure custom parameter if present [davidsantoso] #2432 -* SafeCharge: Map standard Active Merchant order_id field [davidsantoso] #2434 -* Payeezy: Default check number to 001 if not present [davidsantoso] #2439 -* Opp: Fix incorrect customParameter key to disable 3DS [davidsantoso] - -== Version 1.66.0 (May 4, 2017) -* Support Rails 5.1 [jhawthorn] #2407 -* ProPay: Add Canada as supported country [davidsantoso] -* ProPay: Add gateway support [davidsantoso] #2405 -* SafeCharge: Support credit transactions [shasum] #2404 -* WePay: Add scrub method [shasum] #2406 -* iVeri: Add gateway support [curiousepic] #2400 -* iVeri: Support 3DSecure data fields [davidsantoso] #2412 -* Opp: Fix transaction success criteria and clean up options [shasum] #2414 - -== Version 1.65.0 (April 26, 2017) -* Adyen: Add Adyen v18 gateway [adyenpayments] #2272 -* Authorize.Net: Force refund of unsettled payments via void [bizla] #2399 -* Barclays ePDQ: removed because it has been replaced by a new API [bdewater] #2331 -* Beanstream: Map ISO province codes for US and CA [shasum] #2396 -* Braintree Blue: Change :full_refund option to :force_full_refund_if_unsettled [bizla] #2403 -* Braintree Blue: Force refund of unsettled payments via void [bizla] #2398 -* Checkout V2: Fix sandbox URL [nicolas-maalouf-cko] #2391 -* Checkout V2: Fix success_from not properly checking two possible success codes [davidsantoso] -* Cybersource: Rescue XML parse exception [shasum] #2380 -* GlobalCollect: Make message and error reporting more robust [curiousepic] #2370 -* GlobalCollect: Set REJECTED refunds as unsuccessful transactions [davidsantoso] #2365 -* GlobalCollect: Truncate firstName field to 15 characters [davidsantoso] -* JetPay: Pass down authorization payment method token to refund a capture [davidsantoso] -* Openpay: Support card points [shasum] #2401 -* Orbital: Don't send CVV indicator if CVV is not present [curiousepic] #2368 -* PayU LATAM: Fix incorrect capture method definition [davidsantoso] -* Payeezy: Support dynamic soft descriptors [shasum] #2384 -* Pin: Add metadata optional field [shasum] #2363 -* Qvalent: Add soft descriptor fields. Add authorize, capture, and void [davidsantoso] -* SafeCharge: Add gateway [davidsantoso] -* SagePay: Support Repeat transactions [curiousepic] #2395 -* Stripe: Support custom application in X-Stripe-Client-User-Agent header [davidsantoso] -* TransFirst Transaction Express: Support ACH [curiousepic] #2389 -* WePay: Support unique_id for idempotent transactions [shasum] #2367 -* Worldpay: Force refund of unsettled payments via void [bizla] #2402 - -== Version 1.64.0 (March 6, 2017) -* Authorize.net: Allow settings to be passed for CIM purchases [fwilkins] #2300 -* Authorize.net: Use new `unsupported_feature` standard error code [jasonwebster] #2322 -* Base Gateway: Add new `unsupported_feature` standard error code [jasonwebster] #2322 -* Braintree Blue: Pass cardholder_name with card [curiousepic] #2324 -* Braintree: Add Android Pay meta data fields [jknipp] #2347 -* CardStream: Add additional of currencies [shasum] #2337 -* Credorax: Return failure response reason [shasum] #2341 -* Digitzs: Add gateway [davidsantoso] -* Digitzs: Remove merchant_id from gateway credentials [davidsantoso] -* GlobalCollect: Pass options to Refund [curiousepic] #2330 -* Kushki: Add new gateway [shasum] #2326 -* Kushki: Remove body from void call [shasum] #2348 -* Linkpoint: Raise ArgumentError when trying to instantiate without `:pem` [jasonwebster] #2329 -* Omise: Enable Japan, JPY and JCB support [zdk] #2284 -* PayU LATAM: Count pending refunds as succeeded [curiousepic] #2336 -* PayU LATAM: Let Refund take amount value [curiousepic] #2334 -* Paymill: Send new required fields on tokenization requests [tschelabaumann] #2279 -* Revert "Authorize.net: Allow settings to be passed for CIM purchases" [curiousepic] #2339 -* Sage: Default billing state when outside US [shasum] #2340 -* Stripe: Remove idempotency key from verify [shasum] #2335 -* TransFirst Transaction Express: Don't send order_id with refunds [curiousepic] #2350 -* TransFirst Transaction Express: Fix improper AVS and CVV response code mapping [shasum] #2342 -* WePay: Update API version [shasum] #2349 -* USA ePay Advanced: Add quick_update_customer action [joshreeves] #2229 - -== Version 1.63.0 (February 2, 2017) -* Authorize.net: Add #unstore support [jimryan] #2293 -* AuthorizeNet: Fix line items quirk [shasum] -* CardStream: Add dynamic descriptor option fields [curiousepic] -* CardStream: Support PEN currency [shasum] -* Culqi: Add new gateway [shasum] -* CyberSource: Add Lebanon to supported countries [shasum] -* Element: Add AVS and CVV codes to response [shasum] -* Firstdata E4 (Payeezy): Set correct ECI value for card present swipes [jasonwebster] #2318 -* GlobalCollect: On purchase skip capture if not required [davidsantoso] -* PaymentExpress: Update supported countries [shasum] -* Remove leading or trailing whitespace from credit card name [davidsantoso] -* Remove support for Ruby 2.0 [jasonwebster] -* Secure Pay AU: Add scrubbing support to Secure Pay AU [bruno] #2253 -* Stripe: Fix error in handling of track-only contactless EMV data [jasonwebster] -* Vanco: Update test URL [davidsantoso] -* WePay: Build fee structure correctly [curiousepic] -* WePay: Remove null address fields from request [davidsantoso] -* WePay: Update WePay to API version 2016-12-07 [davidsantoso] -* Wirecard: Send customer data in requests [davidsantoso] -* Worldpay: Add session id attribute [shasum] -* Worldpay: Do not default address when not provided [shasum] - -== Version 1.62.0 (December 5, 2016) -* AuthorizeNet: Map to standard AVSResult codes [shasum] -* CitrusPay: Add 3DSecureId field [davidsantoso] -* CyberSource: Only get alpha2 country code when it's a known country [bruno] #2238 -* Fat Zebra: Add scrubbing to Fat Zebra gateway [bruno] #2037 -* Monei: Add US and CA as new supported countries [davidgf] #2209 -* NAB Transact: Add scrubbing to NAB Transact [bruno] #2038 -* iATS: Add scrubbing support to iATS [bruno] #2228 -* Stripe: Ensure ECI values for tokenized cards are padded [jasonwebster] #2250 -* Forte: Fix incorrect authorization_code response mapping [davidsantoso] -* maxiPago: Send currency with request [curiousepic] -* Credorax: Map order_id to field H9 [curiousepic] -* Authorize.net: Remove duplicate country GB [shasum] -* PayU Latam: Add processWithoutCvv2 field [shasum] -* Fat Zebra: De-nest soft descriptor fields [curiousepic] -* Credorax: Only pass c5 field for billing address1 [davidsantoso] -* Orbital: Add support for CLP currency [curiousepic] -* Authorize.net: Add line item fields and additional transaction settings [shasum] -* Authorize.net: Pass through `header_email_receipt` [shasum] -* Stripe: Scrub additional network tokenization related sensitive data [jasonwebster] #2251 -* Applying: Worldpay: Format non-fractional currency amounts correctly [jasonwebster] #2267 - -== Version 1.61.0 (November 7, 2016) -* Add codes AQ, BQ, SX, and SS to list of countries and update SD numeric code [zxlin] -* AuthorizeNet: Update supported countries list [shasum] -* Barclay SmartPay: Add support for credit [shasum] -* Barclaycard SmartPay: Update supported countries [shasum] -* BluePay: Add Canada to supported countries list [shasum] -* BlueSnap: Update countries list [shasum] -* Braintree Blue: Add Android Pay support [mrezentes] -* Braintree Blue: Add remote test to verify card token [shasum] -* Braintree Blue: Get Android Pay tx id from payment method, not options [mrezentes] -* CardStream: Add MXN currency code [curiousepic] -* CardStream: Set captureDelay to zero on purchase [davidsantoso] -* CitrusPay: Add gateway [duff] -* CitrusPay: Update URL to current API version [davidsantoso] -* Clearhaus: Fix refund of captures [duff] -* Clearhaus: Update list of non fractal currencies [curiousepic] -* Clearhaus: Use localized amount [curiouspic] -* Conekta: Add void action [MauricioMurga] -* Credorax: Add gateway support [davidsantoso] -* CyberSource, Paymill, Payflow: Add verify_credentials [duff] -* CyberSource: Combine auth_reversal with Void [curiousepic] -* CyberSource: Increase merchant defined data fields [davidsantoso] -* CyberSource: Look up alpha2 country code [curiousepic] -* CyberSource: Use localized_amount [curiousepic] -* Element: Pass order_id and shipping address [curiousepic] -* Fat Zebra: Add cavv, xid, and sli fields [curiousepic] -* Fat Zebra: Fix improper descriptor nesting [curiousepic] -* Find countries if they are differently cased [curiousepic] -* GlobalCollect: Update credit card brand list [curiousepic] -* Jetpay: Support endpoint for Canada [shasum] -* Linkpoint: Clean whitespace from PEM [curiousepic] -* Litle: Retain amount to send in auth reversals [curiousepic] -* Litle: add scrubbing support [bruno] -* MONEI: Update supported countries list [davidgf] -* MiGS: Handle IDR currency [curiousepic] -* Migs: Add support for void [mohsenottello] -* Migs: Support some additional fields [duff] -* Moneris: Fix unit test stubs [shasum] -* Moneris: add scrubbing support [bruno] -* NMI, FirstData: Support verify_credentials [curiousepic] -* Openpay: Add support for verify [duff] -* PayJunctionV2: Add gateway support [shasum] -* PayU Latam: Add new gateway [shasum] -* PayU Latam: Update supported countries list [shasum] -* Payflow: Update supported countries list [shasum] -* PaypalExpress: Add SoftDescriptor field [talyssonoc] -* Redsys: Added DOP and CRC currency [davidsantoso] -* Sage: Add support for scrubbing [bruno] -* SagePay: Fix truncation [duff] -* SecurionPay: Update supported countries list [shasum] -* Stripe: Increase authorize amount during verify [davidsantoso] -* Stripe: Set minimum authorize amount depending on currency [davidsantoso] -* Stripe: Support new network tokenization API params [methodmissing] -* Stripe: Update supported countries list [shasum] -* TNS and CitrusPay: Support scrub and verify_credentials [duff] -* TNS and CitrusPay: Update to version 36 of the API [duff] -* TNS: Try TLS v1 [duff] -* Telr: Add gateway support [curiousepic] -* TransFirsTransactionExpress: Remove blank cvv element [davidsantoso] -* TransFirsTransactionExpress: Take into account blank string CVV [davidsantoso] -* Vanco: Improve handling of success determination [duff] -* Worldpay: Add hcgAdditionalData element [davidsantoso] -* Worldpay: Report error code [curiousepic] - -== Version 1.60.0 (July 4, 2016) -* Orbital: Fix CC num leak on profile calls [drewblas] -* VisaNetPeru: Add ability to refund [duff] -* AuthorizeNet: Fix store using new profile [duff] -* Clearhaus: Support private key for signature [curiousepic] -* Clearhaus: Copy private_key when stripping [curiousepic] -* CertoDirect: Remove gateway [shiroginne] -* Braintree: Extra error messaging [jordan-brough] -* AuthorizeNetCim: Set error code for AuthorizeNetCimGateway response [ka8725] -* Quickpay v10: Remove amount requirement for store [curiousepic] -* PSLCards: correct namespace in doc for Response object from ActiveRecord::Billing to ActiveMerchant::Billing [CJ Keeney] -* Pagar.me: Add pagar.me [chrisenytc] -* Stripe: Update Readme to show stripe support [rhlrjv] -* Orbital: Add support for the BRL currency [duff] -* GlobalTransport: Require TLSv1 [duff] -* Openpay: Allow currency to be specified [darkaz] -* DataCash: Use API version 2 [curiousepic] -* Stripe: Support verify_credentials [duff] -* AuthorizeNet: Support verify_credentials [duff] -* BraintreeBlue: Support verify_credentials [duff] -* Redsys: Added SAR currency [agseco] -* QuickPay: Adding customer_ip for authorize action in quickpay [dinesh] -* MaxiPago: add void and refund [shasum] -* MaxiPago: Allow processor_id override [duff] -* Stripe: Interpret string input to store method as token identifier [bizla] -* MaxiPago: Add verify and scrub [shasum] -* Stripe: Remove metadata restriction from EMV transactions [bizla] -* SagePay: Add optional fields to SagePay requests [cristianstanescu] -* CyberSource: Assign default with override for billing address and email [shasum] -* CyberSource: Assign default order_id [duff] -* TNS: Support asia_pacific endpoint [curiousepic] -* TransFirsTransactionExpress: Fix exception [duff] -* CyberSource: Add decision manager optional fields [shasum] -* CyberSource: Add decision manager optional fields [shasum] -* TNS: Add support for TLS v1.2 [curiousepic] -* QuickpayV7: Default description field for store operation [duff] -* Elavon: Support customer_number field [duff] -* Map test_mode_live_card code to new standard error code [berkcaputcu] -* Elavon: Pass customer_number correctly [duff] -* Stripe: add SG to supported_countries attribute [timbeiko] - -== Version 1.59.0 (May 18, 2016) -* Orbital: Allow AVS parts to be sent sans country [duff] -* SecureNet: Return the right error message for declines [duff] -* Moneris: Add verify [anellis] -* Moneris: Add verify [anellis] -* Jetpay: Add support for origin field[anellis] -* Jetpay: Don't default origin field [duff] -* GlobalCollect: New gateway support [curiousepic] -* Openpay: Use strict_encode64 [duff] -* Sage: Always pass along the billing state [duff] -* VisaNet Peru: New gateway support [shasum] -* Worldpay: Allow installationId to be specified at transaction time [duff] -* SecurionPay: Support store [shasum] -* Barclaycard Smartpay: Proper AVS return codes [curiousepic] -* VisaNetPeru: Pass through CVV [duff] -* Barclaycard Smartpay: Use strict_encode64 [duff] -* VisaNetPeru: Fix error when billing address empty [shasum] -* Vanco: Update live_url [duff] -* Cardstream: Reference purchase [curiousepic] -* Paymill: Fix error handling [methodmissing] -* Latitude19: New gateway support [shasum] -* BraintreeBlue: remove invalid test assertions [prburke] -* Merchant e-Solutions: Pass order_id with capture [curiousepic] -* CyberSource: Add rescue for ResponseErrors [curiousepic] -* AuthorizeNet: Always pass recurringBilling flag if present [curiousepic] -* S5: Pass order_id to TransactionID [curiousepic] -* NMI: Set ACH sec_code from options if present [curiousepic] -* VisaNet Peru: Refactor merchant_id and purchase_number handling [shasum] -* Braintree Blue: Pass descriptor_url field [curiousepic] -* VisaNet Peru: Add merchant_define_data option [duff] -* Merchant e-Solutions: pass optional 3Dsecure params [curiousepic] -* NMI: Fix refunds and voids of echecks [duff] -* VisaNet Peru: Pass dummy email when not present [curiousepic] -* PayU India: Add Maestro as supported card [curiousepic] -* Cashnet: Don't retry [duff] -* CardStream: Make Void call Cancel instead of Refund [curiousepic] -* Remove AN and KV country codes as they're not recognized by ISO-3166-1 [apdunston] -* Worldpay: Pass unchanged amount with correct currency exponent [curiousepic] -* Improve our handling of currencies sans fractions [duff] -* Stripe: Added support for the contactless magstripe entry mode option [rbalsdon] -* VisaNet Peru: Change money format to dollars [shasum] -* BlueSnap: Add gateway [duff] -* VisaNet Peru: Select the most meaningful gateway error message [shasum] -* SecurionPay: Update country list [duff] -* Support for BIN 2 MasterCard brand detection [rbalsdon] -* CardStream: Fix signature calculation [duff] -* CyberSource: Update test and live URL [marquisong] -* AuthorizeNet: Truncate nameOnAccount field [duff] -* Tns: Fix ipAddress field [duff] -* WorldNet: New gateway support [varyonic] -* BraintreeBlue: Allow channel override [duff] -* MerchantWarrior: Use Truncated Order Id [ThereExistsX] - - -== Version 1.58.0 (March 1, 2016) -* Move Electron check out of CreditCard into CreditCardMethods [ThereExistsX] -* CardStream: Add AED and NZD currencies [sdball] -* App55: Remove Gateway [ThereExistsX] -* Mercury: Stripping the start and end sentinels on card-present track data for max-length track1 requests [ryanbalsdon] -* SagePay: Update VISA Electron ranges [sdball] -* Clearhaus: Make request signing more transparent & robust [sdball] -* NCRSecurePay: Fix production URL [rwdaigle] -* Add ACH support to Stripe [sdball] -* PayPal Express: Fixing list of currencies without fractions [Krystosterone] -* Cashnet: Default custcode option and proper redirect handling [rwdaigle] -* TransFirst: Fix missing address and remove CC only fields for ACH [davidsantoso] -* More prominent links to contribution docs [rwdaigle] - - -== Version 1.57.0 (February 1, 2016) -* AuthorizeNetCim: Add unmaskExpirationDate option [RamilGilmanov] -* Element: Add gateway support [davidsantoso] -* Cardstream: 3D-secure capture fix [duff] -* Auth.net: Update store to create payment profiles [davidsantoso] -* CyberSource: Add support for mdd_fields [duff] -* Worldpay: Add support for verify [davidsantoso] -* Element: Add guard clause to handle undocumented errors [davidsantoso] -* Clearhaus: Add tests for signed requests [anellis] -* Stripe: Support adding cards to account [anellis] -* Clearhaus: Add text_on_statement option [anellis] -* Payeezy: Void and verify support [davidsantoso] -* Creditcall: Use ecommerce rather than cnp [duff] -* Payeezy: Add support for echecks [davidsantoso] -* Bridgepay: Add ability to store cards and pay with token [anellis] -* Initial support for Android Pay network tokenization cards [mrezentes] -* Transfirst: Fix exception when not all eCheck information is present [davidsantoso] -* Auth.net: Add tests for echeck refunds [davidsantoso] -* Transfirst: use default values for some eCheck data [davidsantoso] -* Element: Update the live URL endpoint [davidsantoso] -* Element: Parse responses from unexpected API errors [davidsantoso] -* Transfirst: Remove unused fields for echeck [davidsantoso] -* Sage: Internal refactoring into a single gateway class w/ common http conn [anellis] -* Cardstream: Adjust authorize and capture transactions [anellis] -* NCRSecurePay: New gateway support (Monetra white-label) [rwdaigle] -* Element: Map ReferenceNumber to order_id [duff] -* Element: Use a better MotoECICode default [duff] -* BraintreeBlue: Return transaction id for failed transactions when available [prburke] -* PayPal: Add InContextPaypalExpressGateway [xuorig] -* TransFirst: CVV is a required tag [duff] -* Checkout V2: Add Descriptor Name and City Options [anellis] -* Forte: Pass order_id [anellis] -* Merchant ESolutioins: Truncate order_id [anellis] -* Transfirst Transaction Express: New gateway support [sdball] -* Stripe: Add `stripe_account` header option [anellis] -* Cardstream: Add AVS code and message [anellis] -* Barclaycard Smartpay: New gateway support [curiousepic] -* Transfirst: Fix missing address and remove CC only fields for ACH [davidsantoso] -* Stripe: Support ACH payments [sdball] -* NCRSecurePay: Fix production URL [rwdaigle] -* Clearhaus: Make request signing more transparent & robust [sdball] -* SagePay: Properly detect Electron brand [sdball] -* Mercury: Fix for max-length track 1 [ryanbalsdon] - - -== Version 1.56.0 (December 1, 2015) -* Add Cardknox gateway [dlehren] -* Mercury: Add support for card present track 2 [ryanbalsdon] -* Cardstream: Improve default currency handling [duff] -* Mercury: Strip start and end sentinels on track 2 [ryanbalsdon] -* Redsys: Support new SHA256 authentication method [davidsantoso] -* Cashnet: Allow custcode override [duff] -* Add Rails 5 support [rafaelfranca] -* Set required Ruby version for install to 2 or greater [rafaelfranca] -* JetPay: Pass ud_fields in capture too [duff] -* Stripe: Correctly detect test mode refunds [aprofeit] -* Fix variables in remote gateways test template [sdball] -* Micropayment: Update fieldnames for new API [duff] -* Fix CreditCard#valid_number? erroring on non-digit characters [PatrickTulskie] -* Stripe: Correctly detect test mode voids [methodmissing] -* Garanti: Add test mode URL and update remote test credentials [cbilgili] -* Cashnet: Allow custcode override on refund [duff] -* Omise: Add a new optional api_version config [zdk] -* Elavon: Include IP address in purchase and authorize requests [aprofeit] -* TransFirst: Add support for ACH and more operations [davidsantoso] -* FirstData_e4: Fix void for even dollar transactions [duff] - -== Version 1.55.0 (November 9, 2015) -* CyberSource: send customer IP address when provided [fastjames] -* Braintree: Simplify Braintree scrubbing when no transcript [duff] -* AuthorizeNet: Allow market_type override [duff] -* FirstData_e4: Support level_2 data [duff] -* FirstData_e4: Fix level_2 and level_3 [duff] -* MerchantWareFour: Use Void not PreAuthorizationVoid [duff] -* JetPay: Allow partial captures [duff] -* Creditcall: Fix production url [duff] -* FirstData_e4: Fix float error in Void [duff] -* Micropayment: Upgrade to new API [mrezentes] -* Netbilling: Add order_id to user_info [mrezentes] -* Stripe: scrub swipe/track, EMV data out of gateway transcripts [girasquid] -* Remove integration_mode [mattfawcett] -* Allow setting CVV requirement at instance level [fabiokr] -* Add SecurionPay gateway [szajbus] -* AuthorizeNet: Don't send currency to void [duff] -* Add Komoju gateway [k2nr] -* Replace Connection magic numbers with constant references [larrylv] -* Add CAMS gateway [trevorgrayson] -* PayPal Express: Fix AllowedPaymentMethod [edclements] -* Litle: Store credit card from PayPage [dontmatta] -* Orbital: Deprecate profile management API [ntalbott] -* FirstData e4: Honor currency when supplied [tchill] -* Authorize.net: Add config_error standard error code [andrewpaliga] -* PayPal Express: Add support for TotalType in SetExpressCheckout [gingerhendrix] -* eWay Rapid: Add :invoice option [DylanFM] -* Braintree: Add nonce payment method [eric1234,cwoodcox] -* Payflow: Allow passing of 3D Secure details via options [marquisong] -* Elavon: Support capture via CCCOMPLETE without credit card [marquisong] -* Securenet: Allow setting test_mode independently [wedstar] -* Replace Base.integration_mode and Base.gateway_mode with just Base.mode [aprofeit] -* Micropayment: Allow specification of a project [duff] -* QuickpayV10: Truncate order_id [duff] -* FirstData_e4: Fix Level 2 data [duff] -* Remove some duplication around name handling [duff] -* FirstData_e4: Support Tax1Number [duff] -* Add Transact Pro gateway [varyonic] -* Add Payeezy gateway [huoxito] -* USAePay: Add test mode setting via options [marquisong] -* Add Clearhaus gateway [dinesh] -* WorldpayOnlinePayments: Fix logic to determine success [ao] -* Paymill: store order_id in description field [nikoloff] -* TWD isn't a zero decimal currency [duff] -* PaypalExpress: Use custom zero decimal currencies [duff] -* Stripe: Migrate from /refund to /refunds [matthelm] -* Bogus: Adding basic EMV support [ryanbalsdon] -* PayBox Direct: Refunds and working test credentials [ivanfer] -* Vanco: Handle case of no billing_address [duff] -* BluePay: Add support for CUSTOM_ID2 field [ajporterfield] -* Creditcall: Handle no verification_value [duff] - -== Version 1.54.0 (October 2, 2015) -* Beanstream: Add Network Tokenization support [girasquid] -* CenPOS: Allow order_id on void [duff] -* Provide better insight to CVV usage in requests [davidsantoso] -* Ogone: Add verify [duff] -* Beanstream: Add verify [mrezentes] -* PayPal: Map standard error codes [JakeCataford] -* Checkout.com: Fix an issue with empty phone numbers. [anotherjosmith] -* Quickpay: Edit store and add ability to purchase with stored card [anellis] -* Stripe: Set `receipt_email` to Stripe request if receipt delivery is requested [miccheng] -* Worldpay US: Add eCheck support [mrezentes] -* FirstData_e4: add level_3 data [mrezentes] -* Vanco: Support passing ip address [duff] -* Paybox Direct: Currency parsing fix [ivanfer] -* QuickpayV10: Remove currency requirement from store. [anellis] -* Raven: Use TLS 1.2 endpoint [bslobodin] - -== Version 1.53.0 (September 1, 2015) - -* Redsys: Add a number of currencies [agseco] -* Raven: update description, test url, and routing; fix tests [bslobodin] -* Raven: do not pass default (incorrect) PaymentType to #void [bslobodin] -* Add scrubbing to a number of gateways [anellis] -* BluePay: Add scrubbing [anellis] -* BraintreeBlue: Allow custom logger [duff] -* MerchantWareFour: Truncate invoiceNumber [duff] -* S5: Pass recurrence_mode in store [duff] -* QuickPay: Support 2-letter country codes in V10 API [girasquid] -* Stripe: Support validate:false field on store [anellis] -* CheckoutV2: Use correct live_url [duff] -* QuickPay: strip # from Order IDs before submission [girasquid] -* Litle: Use schema version 9.4 rather than 8.18 [anellis] -* Litle: Add decrypted apple_pay [anellis] -* QuickPay: fix method signature on #void [girasquid] -* Forte: Add gateway [davidsantoso] -* Stripe: return refund id for refund authorization [anellis] -* Paypal: Update api version [anellis] -* TNS: Translate countries to alpha3 codes [anellis] -* TNS: Handle non existent country [duff] -* TNS: Rescue Errors [anellis] -* CenPOS: Support avs_result and cvv_result [tjstankus] -* Stripe: Add application fee only on non-EMV transactions [bizla] -* Stripe: don't send blank, non-nil values [girasquid] -* Ogone: Send different auth type for mastercard [anellis] -* Cardstream: Add "type" field support [rwdaigle] -* Cardstream: 3dsecure transaction option [rwdaigle] -* Paystation: Map order_id to non-unique merchant reference field [anellis] -* Cardstream: Check for nil street address [anellis] -* Checkout.com and CheckoutV2.com: Update country list [duff] -* Cardstream: Handle nil addresses [rwdaigle] -* MiGS: Allow passing in currency [alovak] -* [POSSIBLE BREAKAGE] NMI: No longer use auth.net emulator [rwdaigle] -* SecureNet: Add DEVELOPERID if supplied [wedy] -* Braintree: Update country list [duff] -* NMI: Don't include dup_seconds if nil [rwdaigle] -* QuickPay: Make all operations to v10 platform synchronous [ta] -* QuickPay: Handle issue where no operations exists on payment [ta] -* NMI: Support merchant_defined_fields [duff] -* QuickpayV10: Add verify [anellis] -* BraintreeBlue: Use wiredump_device for logging only if present [braintreeps] -* QuickpayV10: Add scrubbing [anellis] -* QuickPayV10: Change tests to point to proper gateway [anellis] -* Monei: Add default options argument [davidgf] -* Ogone: Add additional 3d-secure parameters [ntalbott] -* Ogone: Refactor signature calculation [ntalbott] -* Add Creditcall gateway [davidsantoso] -* Redsys: Fix scrubbing for failed transactions [davidsantoso] -* Micropayment: Support Micropayment gateway [rwdaigle] -* USAePay: Use names from the given billing and shipping address [marquisong] -* Stripe: Add application fee on EMV authorize calls [bizla] - -== Version 1.52.0 (July 20, 2015) - -* Authorize.Net: Add device type to authorize.net retail requests [abecevello] -* Vanco: Change transaction type to WEB for echecks [duff] -* PayPal: Allow soft descriptor to be specified [davidsantoso] -* Authorize.net: Add disable_partial_auth field [anellis] -* SagePay: Add apply_avscv2 field [anellis] -* S5: Add Store [anellis] -* Merchant Ware v4: Add support for verify [davidsantoso] -* Mercury: No longer default to allow partial auth [duff] -* PayPal: Fix soft_descriptor and support soft_descriptor_city [duff] -* Merchant Ware: Add scrubbing [davidsantoso] -* Stripe: Make purchase via vaulted card consistent [duff] -* Moneris: Add network tokenization support [andrewpaliga] -* Ogone: Allow specifying a timeout value for requests [tomhipkin] -* PayU India: Increase allowed txnid to 30 characters [ntalbott] -* Authorize.Net: Allow passing device type through options, make wireless POS the default [abecevello] -* Authorize.Net: Update to new Akamai URL [taf2] -* Braintree: Add hold_in_escrow [anellis] -* Stripe: Allow purchases with tokens without customer specification [bizla] - -== Version 1.51.0 (July 2, 2015) - -* Garanti: Illegal character '&' parsing response [masaruhoshi] -* Stripe: Revert force USD for verify [duff] -* Litle: Surface XML validation errors in the response [jasonbosco] -* Litle: Pass the credit card verification value for tokenization (#store) requests, if one is set. [jasonbosco] -* S5: Make scrubbing regex less greedy [duff] -* CardStream: Add support for verify [anellis] -* Authorize.net: UTF-8 encode requests [duff] -* Banwire: Add default email [anellis] -* PayU India: Handle bad JSON [ntalbott] -* Dibs: Pass CVC param only if there's a value [bruno] -* Sage: Credit really is credit not refund [duff] -* Sage: Add ability to refund [duff] -* Cardstream: Add scrubbing [anellis] -* Litle: Add debt_repayment_flag [duff] -* iATS: Support ACH [rwdaigle] -* CheckoutV2: Add Gateway [anellis] -* CenPOS: Fix refund amount issue [duff] -* Add error_code mapping and error_code_from to gateway generator [jnormore] -* Stripe: Parse EMV ARC from error response [bizla] -* Redsys: Add MYR currency [agseco] -* Add "contactless" flag to credit card model [davidseal] -* Stripe: Add "contactless" flag support to gateway [davidseal] -* Add encrypted_pin data to credit card model [ryanbalsdon] -* Stripe: Add encrypted_pin support to gateway [ryanbalsdon] -* Stripe: Support mapping advanced decline codes to standard codes [abecevello] -* Epay: filter out invalid characters in returned URLs [dwradcliffe] -* Redsys: Strip leading zeroes from currency codes [agseco] -* Authorize.net: Add invoice information to refund [marquisong] -* Authorize.net: Add store ability [duff] -* Paystation: Add refund [mrezentes] -* Paystation: No longer require order_id everywhere [duff] -* Checkout: Support descriptor_name and descriptor_city [duff] -* Add supports_network_tokenization? to gateways [jnormore] -* Bpoint: Handle message for invalid login [anellis] -* TransFirst: Add scrubbing [davidsantoso] -* TransFirst: Add back a few request fields [davidsantoso] - - -== Version 1.50.0 (June 1, 2015) - -* Vanco: Add gateway [duff] -* Conekta: Move device fingerprint to root [MauricioMurga] -* Conekta: Change default language to Spanish [MauricioMurga] -* Vanco: Improve authentication handling [duff] -* Vanco: Allow specification of fund_id [duff] -* S5: Add gateway [davidsantoso] -* SecureNet: Truncate order_id [duff] -* [POSSIBLE BREAKAGE] Stripe: Be explicit about API version [duff] -* Dibs: Add gateway [mrezentes] -* Dibs: Rubyize merchant_id and secret_key [mrezentes] -* Stripe: Add support for reverse_transfer [duff] -* USA ePay: Add support for manual entry indicator [AnotherJoSmith] -* Authorize.Net: Add support for manual entry indicator [AnotherJoSmith] -* CenPOS: Change description to invoice_detail [mrezentes] -* BPoint: Add gateway [tjstankus] -* S5: Remove address requirement for purchase and authorize [davidsantoso] -* Vanco: Add support for eChecks [duff] -* Remove Adyen support [ntalbott] -* CenPOS: Use ProcessCreditCard action [duff] -* CASHnet: uri encode the merchant gateway name [mrezentes] -* S5: Include card brand in request body [davidsantoso] -* Vanco: Handle multiple error responses [duff] -* Merchant Partners gateway support [rwdaigle] -* BPoint: Update params to contain all response data [tjstankus] -* BPoint: Support biller_code in options [tjstankus] -* Sagepay: Add Verify [anellis] -* S5: Build XML with UTF-8 encoding [tjstankus] -* Cashnet: Handle unparsable response body [duff] -* CenPOS: Allow specification of customer_code [duff] -* Allied Wallet: Add gateway [anellis] -* S5: set Regex closure on scrubbing method [davidsantoso] -* Dibs: Require TLSv1 [duff] -* Optimal: Handle case of no billing address [duff] -* Omise: Add gateway [zdk] -* CenPOS: Simplify currency handling [duff] -* Beanstream: Don't treat redirect as success [aprofeit] -* Add PayU India gateway [ntalbott] -* NetBilling: Require TLSv1 [duff] -* S5: Handle recurring transactions without CVV [davidsantoso] -* Stripe: Force USD for verify [duff] -* PayU India: Prevent shadowing in response parsing [ntalbott] -* QuickPay: Add support for v10 API [ta] -* Fat Zebra: Fix refund and store signatures [duff] -* Fat Zebra: Allow transactions without a CVV [duff] - -== Version 1.49.0 (May 1, 2015) - -* Braintree: Add support for AVS error codes [ivanvfer] -* MerchantWarrior: Truncate description field [duff] -* Braintree: Add service_fee_amount option [duff] -* SecureNet: Allow shipping_address[:name] [duff] -* MonerisUS: Add verify [mrezentes] -* Ezic: Add gateway [duff] -* Stripe: Add destination field [cwise] -* SecureNet: Fix ordering of shipping field names [duff] -* SecurePayAu: Update API URL [girasquid] -* Stripe: Add EMV "chip & sign", "chip & offline PIN" and Maestro support [bizla] -* Add Errno::EHOSTUNREACH to NetworkConnectionRetries::DEFAULT_CONNECTION_ERRORS [randito78] -* Stripe: Add support for idempotency keys [michaelherold] -* WePay: Handle JSON::ParserError exceptions [duff] -* Borgun: Update country list and homepage url [mrezentes] -* AuthorizeNet: Add cvv to request only if it's valid [tjstankus] -* Stripe: Bug fix: add amounts only on non-EMV transactions, temporarily omit EMV testcases [bizla] -* Ezic: Add support for void [duff] -* iATS: Update supported countries [mrezentes] -* Ezic: Update supported countries [duff] -* AuthorizeNet: Truncate card number [tjstankus] - -== Version 1.48.0 (April 8, 2015) - -* Clean up `rake gateways:hosts` output [ntalbott] -* Add Axcess MS gateway [timtait] -* Add PayHub gateway [grepruby] -* Orbital: Improve data formatting [boone] -* [POSSIBLE BREAKAGE] USAePay Transaction: Make "void release" the default [dppcode] -* Redsys: Add rudimentary vaulting [varyonic] -* Exact: Handle 401 failures better [jefflaporte] -* SagePay: make `VPSProtocol` user-configurable [boxofrad] -* Netbilling: Add store support [cshepherd] -* Add Qvalent gateway [markabe] -* Expose proxy address and port to gateways [arkes] -* Remove Ruby 1.9 [j-mutter] -* Qvalent: Do not sent order.ipAddress when storing [markabe] -* Qvalent: Fix argument name [bruno] -* Qvalent: map card storage reference to authorization [markabe] -* Qvalent: Fix scrub replacement, it was too greedy [markabe] -* PayConex: Add gateway [duff] -* AuthorizeNet: Add credit support [duff] -* CenPOS: Add gateway [markabe] -* Stripe: Update country list [markabe] -* Add Monei.net gateway [leolara] -* MerchantWarrior: Fix refund and capture signatures [duff] -* CenPOS: Add support for capture and refund [markabe] -* Authorize.net: Add support for network tokenization credit cards [jnormore] -* Stripe: Add support for passing in metadata for auths and purchases [kitt] -* Pin: Pass amount param for captures [ab9] -* NAB Transact: Improve store functionality [duff] -* Add Worldpay Online Payments [ao] -* Fat Zebra: Add multi-currency support [nagash] -* Fat Zebra: Add auth/capture capability [nagash] -* Fat Zebra: Add soft descriptor support [nagash] - -== Version 1.47.0 (February 25, 2015) - -* Authorize.Net: Properly send name in shipping address line, when shipping address is provided [girasquid] -* Payflow: Add verify support [ntalbott] -* Capture ConnectionError#triggering_exception [ntalbott] -* Flo2Cash: Map Reference->:order_id (not :invoice) [ntalbott] -* Flo2Cash: Fix card brand handling [ntalbott] -* Flo2Cash: Improve error handling & simplify "Simple" gateway [ntalbott] -* Remove Vindicia gateway [mutemule] -* Firstdata E4: Support other mastercard string [jcbantuelle] -* Checkout: Disallow altering endpoint via options [markabe] - -== Version 1.46.0 (January 20, 2015) - -* CHANGE: drop `offsite_payments` and `active_utils` as dependencies. [wvanbergen] -* CHANGE: remove `OffsitePaymentShim`. You will have to add offsite_payments as a dependency, - and update any mentions of `ActiveSupport::Billing::Integration` to - `OffsitePayments::Integrations`. [wvanbergen] -* QuickBooks Payments: Add adapter [ivanfer, bizla] -* Quickbooks: Remove requirement of oauth gem. -* PayGate: Add support for refunds [StephanAtG2] -* PayPal: Add #scrub for scrubbing PCI information out of HTTP transcripts [girasquid] -* Stripe: Add #scrub for scrubbing PCI information out of HTTP transcripts [girasquid] -* Cybersource: Add ability to verify a card [duff] -* BraintreeBlue: Expose the error code in the response params [duff] -* eWay Rapid: Update supported countries and card types [incarnate] -* PayPal: Allow specifying ButtonSource at init [ntalbott] -* Payflow: Add fraud_review support [ntalbott] -* Add IPP gateway [InfraRuby] -* Redsys: Fix order_id truncation [duff] -* AuthorizeNet: Improve duplicate_window handling [duff] -* PayPal: Fix ButtonSource bug [ntalbott] -* Checkout: Prevent multiple trackids from being passed [markabe] -* Pin: Handle JSON parsing exception in response [duff] -* Improve test suite to test against multiple ActiveSupport versions [wvanbergen] -* Misc. code cleanup [wvanbergen] -* Add Flo2Cash gateway [markabe] -* Litle: Allow order_source override [duff] -* Quickpay: Add ability to finalize a capture [askehansen] -* AuthorizeNet: Prevent test mode using live gateway [duff] -* Add Flo2Cash Simple gateway [markabe] - -== Version 1.45.0 (December 1, 2014) - -* HPS: Always pass CardHolderData element [SecureSubmit, ntalbott] -* PayJunction: Include 'track' parameter if provided [hron] -* WebPay: Fix API calls [tomykaira] -* Moneris US: Add store, unstore, and update [AntoineInsa] -* Moneris US: Add CVV and AVS [AntoineInsa] -* Stripe: Add support for statement_description [markabe] -* CASHNet: Add support for fname and lname [markabe] -* Orbital: Fix customer profile auth/purchase [denis] -* Payex: Fix expiry month to allow 4 digit year [duff] -* Cashnet: Allow overriding custcode [hoenth] -* Cashnet: Fix overridding item_code per transaction [ntalbott] -* Add Checkout.com gateway [ravish-ramrakha-cko] -* HPS: Add verify support [SecureSubmit] -* Add Bank Frick gateway [varyonic] -* Add Global Transport gateway [duff] -* iATS: Add #store and #unstore [duff] -* Authorize.Net: Fix amount formatting [ntalbott] -* Authorize.Net: Truncate order_id to 20 characters [ntalbott] -* Authorize.Net: Truncate more fields [duff] -* Authorize.Net: Truncate invoiceNumber [ntalbott] -* Adyen: Add support for verify operation [duff] -* USAePay: Add track_data support [louiskearns] -* Payex: Use the right url for the purchase call [duff] -* Braintree: Allow dynamic descriptors [duff] -* Openpay: Add support for device session id [guillermo-delucio, ismaelem] -* Redsys: Add support for verify [duff] -* Redsys: Handle unknown currencies [duff] -* Stripe: Make #unstore signature consistent [duff] -* Remove defunct Samurai gateway [ntalbott] -* eWay Rapid: Tweak authorization support [duff] -* Litle: Add support for dynamic descriptors [duff] -* Add TNS gateway [markabe] -* TNS: Update countries and supported card types [markabe] -* Conekta: Add AMEX as a supported card type [MauricioMurga] -* Checkout: pass through currency type [markabe] -* Bogus: return standard error codes [jpcaissy] -* Add PaymentToken and ApplePayPaymentToken objects for token-based transactions [bizla] -* Authorize.Net: Add ApplePay in-app transaction support [bizla] -* Stripe: Add ApplePay in-app transaction support [bizla] -* eWAY Rapid: Add PartnerID param [j-mutter] -* GlobalTransport: Truncate order_id [duff] -* Redsys: Allow a description to be specified [duff] -* NetworkMerchants: Fix currency [j-mutter] -* Redsys: Improve handling of order_id [duff] -* Checkout: Add support for void, refund, and verify [markabe] - -== Version 1.44.1 (Aug 28, 2014) - -* Allow SSLv3 for PsiGate [mutemule] -* Set default :state to n/a for NetworkMerchants [cjoudrey] - -== Version 1.44.0 (Aug 21, 2014) - -* Moneris: Add :avs_enabled option [bslobodin] -* Stripe: Populate authorization in failed responses, when available [bslobodin] -* Moneris: Use the name on the card [duff] -* Balanced: More 1.1 API fixes and mappings [ntalbott] -* Balanced: Handle "pending" refunds [duff] -* Immediately convert credit card date fields to integers [ntalbott] -* Balanced: Handle outside card tokens [ntalbott] -* Balanced: Do not pass address if zip is missing [ntalbott] -* Float active_utils at the patch version instead of the minor version [nwjsmith] -* Wirecard: Fix CVV & AVS response handling [alevett] -* Consolidate deprecation handling [ntalbott] -* Authorize.Net CIM: Do not send x_test_request [danrabinowitz] -* Authorize.Net CIM: Pass delimiter through [jsoma] -* HPS: Add support for track data [SecureSubmit] -* HPS: Fix processing without an address [SecureSubmit] -* Balanced: Do not pass address if zip is blank [duff] -* Do CreditCard attribute cleanup at assignment [ntalbott] -* eWay Rapid: Add auth/capture/void support [ntalbott] -* [POSSIBLE BREAKAGE] Remove dependency on active_utils Validateable [ntalbott] -* Make all active_utils requires explicit [ntalbott] -* Balanced: Handle legacy card tokens [ntalbott] -* Braintree Blue: Default verification merchant id [speric] -* [POSSIBLE BREAKAGE] Extract integrations into an offsite_payments gem [ntalbott] -* [POSSIBLE BREAKAGE] Drop stated/tested compatibility with Rails < 3.2 [ntalbott] -* Stop requiring unused CurrencyCode class from active_utils [ntalbott] -* Move ActiveMerchant::Error into ActiveMerchant [ntalbott] -* Inline RequiresParameters in Gateway & move Country from active_utils [ntalbott] -* Quickpay v7: Fix passing acquirers field [moklett] -* Quickpay v7: Pass an amount when storing cards [ta & moklett] -* Quickpay: Expand list of supported countries [ta] -* Validate CreditCard verification value [mnoack] -* Authorize.Net CIM: Allow updating a payment profile without a full credit card number [speric] -* Wirecard: Add optional CommerceType element [timtait] -* Add Borgun gateway [markabe] -* [POSSIBLE BREAKAGE] NAB Transact: Allow timeout customization [duff] -* Wirecard: Add card store and purchase/authorize by reference [speric] -* Worldpay: Add support for Switch cards [dougal] -* FirstData e4: Send correct card type [npverni] -* Elavon: Add store/update support [npverni] -* Wirecard: Catch an empty ERROR Element [timtait] -* Finansbank (CC5): Add void/refund/credit support [muhammetdilek] -* Wirecard: Use authorization_check for Amex store [npverni] -* Elavon: Make void work for authorizations [duff] -* Add Commercegate gateway [vitaliyvasin] -* Wirecard: Fix "amex" references [mendable] -* HPS: Do not pass empty elements [SecureSubmit] -* Paymill: Add more supported card types [nikoloff] -* Paymill: Add source [nikoloff] -* Paymill: Add description for preauthorizations [nikoloff] -* Paymill: Add remote tests using tokens [nikoloff] -* HPS: Add developer, version number and site trace options [SecureSubmit] -* Update 1stPayGateway.Net gateway [rwdaigle] -* Payflow: Add verbosity option [doppler] -* Allow ignoring the result of any MultiResponse step [ntalbott] -* Stripe: Add ability to verify a card [duff] -* Paypal: Add ability to verify a card [duff] -* Authorize.net: Add ability to verify a card [duff] -* Braintree: Add ability to verify a card [duff] -* Enhance gateway generator to support verify [duff] -* PayPal Express: Add funding source support [baraabourghli] -* Optimal: Add IP address to requests [justinplouffe] -* Pin: Add authorize & capture support [keithpitt] -* Pin: Add update support [keithpitt] -* Vindicia: Stop using the vindicia-api gem [ntalbott] -* Clean up the warnings fog [ntalbott] -* Quickpay: Map options[:ip] for fraud analysis [ta] -* SagePay: Truncate fields [duff] -* First Data E4: Add ability to verify a card [duff] -* Elavon: Add ability to verify a card [duff] -* Worldpay: Pass email and IP address [duff] -* Worldpay: Use updated address format [duff] -* Moneris: Fix address splitting [ntalbott] -* FirstData E4: Allow passing CAVV through [Senjai] -* Braintree Blue: Remember the capture transaction id [duff] -* Eway Rapid: Truncate some fields [duff] -* Optimal Payment: Make account mandatory field [rwdaigle] -* Worldpay: Improve address defaulting [duff] -* Authorize.Net: Add maestro as a supported card type [vparihar01] -* Worldpay: Improve address defaults [duff] -* Braintree Blue: Pass cardholder_name when tokenizing [radar] -* Wirecard: Improve error handling [mendable] -* Litle: Add verify support [markabe] -* USAePay: Add verify support [markabe] -* BridgePay: Add verify support [duff] -* Braintree Blue: Add payment_method_token flag [JDutil] -* SagePay: Add optional FI fields [rob-anderson] -* Iridium: Add AVS and CVV results [X0Refraction] -* NAB Transact: Add credit support [nagash] -* Braintree Blue: Add application_id support [npverni] -* Realex: Add maestro mapping [uriklar] -* Add Worldpay US gateway [markabe] -* Cybersource: Add shipping address [pkoppula] - -== Version 1.43.2 (May 12, 2014) - -* Remove 2Checkout's #line_item due to conflict with Klarna/Shopify [edward] -* Auth.Net CIM: Fix ordering of order/trans_id [pdamer] -* Add PagoFacil gateway [bhserna, abisosa] -* [POSSIBLE BREAKAGE] Stripe: Allow for updating of stored card [speric] -* Authorize.Net: Deprecate ARB [ntalbott] -* Authorize.Net CIM: Add recurring billing flag [gabealmer] -* Spreedly: Add support for :ip [megamoose] -* PayPal Express: Improve received_at handling [jwarchol] -* PayPal Express: Add ReqBillingAddress flag [johnb-razoo] -* Beanstream: Add support for Legato single use tokens [tylerrooney] -* PayPal Digital Goods: Allow mobile [tomprats] -* Maxipago: Add installment support [alexandremcosta] -* Deprecate recurring API support [ntalbott] -* NMI: fix CreditCard check [bslobodin] -* SagePay: Add tokenization support [kernow] -* PayPal Express: Reference transaction details [lrostovsky] -* Balanced: Update to API 1.1 [steveklabnik] -* Add Cashnet gateway [hoenth] -* Conekta: Standardize address options [MauricioMurga] -* Wirecard: Add support for reference purchases [timtait] -* Worldpay: Add support for external references [matsubo] -* Balanced: Voiding a capture is not allowed [duff] -* Add HPS gateway (Heartland Payment Systems) [SecureSubmit] -* Balanced: Fix handling of 500 errors [ntalbott] -* Universal: Remove all billing address fields [bslobodin] -* Balanced: Stop creating a customer on each call [ntalbott] -* Balanced: Refactor and handle legacy authorizations [ntalbott] -* SagePay Form: Update to v3.00 [bslobodin] -* GestPay: Use a more specific error class when parsing [odorcicd] -* PagSeguro: Improve error handling [celsodantas] -* PxPay: Support for newer, query-less redirect URLs [odorcicd, bslobodin] -* eWAY Rapid: Update to 3.1 API [atomgiant] -* Misc refactorings [justinplouffe] -* Remove greedy rescue, and convert some errors to be user-facing [odorcicd] -* PayPal Express: pass logo image for setup request [dimko] -* Improve credit card validation [duff] - -== Version 1.43.1 (May 1, 2014) - -* Merchant Warrior: Scrub names [duff] -* Validate Gateway.supported_countries [rwdaigle] -* Stripe: Add recurring flag support [bslobodin] -* Stripe: Use localized amounts for currencies w/o minor units [bslobodin] -* WebPay: Leverage fixes to Stripe to remove duplicate code [bslobodin] -* Klarna: Miscellanenous fixes [edward] -* Mollie iDEAL: Use order's description [wvanbergen] - -== Version 1.43.0 (April 24, 2014) - -* PagSeguro: New offsite integration [celsodantas] -* Sage Pay: Fix amount parsing in notifications [berkcaputcu] -* Sage Pay: Use API v3.00 [bslobodin] -* BridgePay: Switch method of success detection [markabe] -* BridgePay: Use Return as TransType for refunds [markabe] -* IATS: Complete rewrite using first class API [rwdaigle] -* IATS: Fix invalid country code UK -> GB [rwdaigle] -* DataCash: Fix refund processing using original authorization [bslobodin] -* Transnational gateway renamed to Network Merchants [bslobodin] -* PayMill: Handle non-JSON server responses [bslobodin] - -== Version 1.42.9 (April 15, 2014) - -* Spreedly: Add ip, description and gateway_specific_fields [faizalzakaria] -* Sage (US): Support store/unstore of cards [rwdaigle] -* Pin: Add american express to supported cards [nagash] -* Raven: Update handling of CVV/AVS [bslobodin] -* Raven: Use UUID for RequestID [bslobodin] - -== Version 1.42.8 (April 4, 2014) - -* Cecabank: Handle invalid xml response body [duff] -* Wirecard: Capture error code in the response [duff] -* Litle: Remove gem dependency [duff] -* Litle: Fix case of missing address parts [duff] -* Universal: Add universal offsite API implementation [bslobodin] -* Iridium: Add more currencies [bslobodin] -* iDeal: Add Mollie iDeal offsite implementation [wvanbergen, maartenvg] - -== Version 1.42.7 (March 18, 2014) - -* SagePay: Add support for ReferrerID [markabe] -* Cecabank: Fix expiration date formatting [duff] -* Add WePay gateway [faizalzakaria] -* SmartPs: Add ECI option to SmartPs [odorcicd] -* Rescue and re-raise ActionViewHelperError when offsite helpers raise an error [odorcicd] -* Add FirstGiving gateway [faizalzakaria] -* FirstGiving: Fix refunds [ntalbott] -* Samurai: Handle server errors [ntalbott] -* WePay: Fix refund [duff] - -== Version 1.42.6 (February 24, 2014) - -* Litle: Truncate order_id [duff] -* Conekta: Fix #refund; respect :currency [leofischer] -* SagePay: Truncate description field [duff] -* Add Cecabank gateway [molpe] -* Add Openpay [darkaz] -* Openpay: Simplify test versus production mode [duff] -* Wirecard: Handle a utf-8 description [duff] -* Litle: Partial capture support [ttdonovan] -* Ogone: Allow D3D for alias purchases [pwoestelandt] -* USAePay Advanced: Fix verification_value mapping [dppcode] -* Orbital: Add additional success conditions [boone] -* Orbital: Handle special CVV responses [boone] -* Balanced: Allow working with balanced.js [michaelherold] -* Balanced: Allow passing customer name [michaelherold] -* Balanced: Add support for meta [michaelherold] -* Improve gateway generator [ntalbott] -* Add maxiPago gateway [alexandremcosta] -* Authorize.Net: Remove x_test_request support [ntalbott] -* Conekta: Add default description [bslobodin] -* Add PayDollar integration [bslobodin] - -== Version 1.42.5 (February 7th, 2014) - -* Add Doku Indonesia [bizla] -* Cardstream: Update gateway to use latest API [odorcicd] - -== Version 1.42.4 (January 8th, 2014) - -* DataCash: Set 'ecomm' as capturemethod [DavidGeukers] -* Cybersource: Fix subscriptions with a setup fee [ntalbott] -* Stripe: Do not pass customer details to the /cards endpoint [michellebu] -* Stripe: Allow Stripe API version to be initialized with the gateway [odorcicd] - -== Version 1.42.3 (December 18th, 2013) - -* Balanced: Add support for appears_on_statement_as [duff] -* Authorize.Net: Make already actioned responses failures [odorcicd] -* Add Payex gateway [atomgiant] -* Paymill: Fix authorizations [duff] -* Braintree Blue: Allow specifying the credit card token [ntalbott] -* Braintree Blue: Allow specifying the customer id [ntalbott] -* Braintree Blue: Scrub invalid emails and zips [ntalbott] -* Braintree Blue: Return :credit_card_token as a top level param [ntalbott] -* Braintree Blue: Allow unstoring just a credit card [ntalbott] -* Braintree Blue: #store adds cards to existing customers [ntalbott] -* USA ePay Advanced: Fix check handling [nearapogee] -* USA ePay Advanced: Fix credit card expiration handling [nearapogee] -* USA ePay Advanced: Fix handling of custom transaction responses for single items [nearapogee] -* USA ePay Advanced: Fix capture amount [nearapogee] -* NAB Transact: Fix merchant descriptor with capture/refund requests [nagash] -* Braintree Blue: Add custom_fields & device_data parameters [parallel588] -* Webpay: Add authorize & capture [keikubo] -* MerchantWarrior: Pass description [duff] -* Stripe: Separate email from description [duff] -* Add Payscout gateway [llopez] -* Merchant Warrior: Use billing_address [duff] -* Add SoEasyPay gateway [ir-soeasycorp] -* Bogus: Add check support [npverni] -* Payflow: Add Check support [crazyivan] -* Stripe: Allow expanding objects inline [odorcicd] - -== Version 1.42.2 (November 13th, 2013) - -* Renew public certificate - -== Version 1.42.1 (November 13th, 2013) - -* Signed version of 1.42.0 - -== Version 1.42.0 (November 13th, 2013) - -* Fix NoMethodError "tr" for params with dash [TimothyKlim] -* Authorize.Net: Add cardholder authentication options (CAVV) support [structure] -* CardStreamModern: Added better checks on inputs from the gateway [ExxKA] -* Stripe: Send :ip to the gateway instead of :browser_ip [f3ndot] -* Wirecard Page: new offsite gateway [mbretter] -* Mercury: Add support for requesting a token [kcdragon] -* Add App55 gateway [ianbutler55] -* UsaEpayTransaction: Support for split payments [GBH] -* Add Swipe Checkout gateway [matt-optimizerhq] -* Spreedly Core: Allow overriding the gateway token when running a transaction [hoenth] -* Spreedly Core: Add order_id [hoenth] -* Spreedly Core: Allow store without retain [hoenth] -* Stripe: Support multiple cards on account [pierre] -* Stripe: Add card_id parameter to unstore call [pierre] -* Remove usage of `uname -a` [ntalbott] -* Litle: Allow easier access to the response code [duff] -* Stripe: Add the option to pass a version header [odorcicd] -* Elavon: Update supported countries [duff] -* Add Raven PacNet gateway [llopez] -* BitPay: Fix BitPay issues and implement Notification#acknowledge [odorcicd] - -== Version 1.41.0 (October 24th, 2013) - -* Stripe: Payments won't fail when specifying a customer with a creditcard number [melari] -* Add Conekta gateway [leofischer] -* Wirecard: Add support for void and refund [duff] -* Orbital: Mandatory field fix [juicedM3, jduff] - -== Version 1.40.0 (October 18th, 2013) - -* Paymill: Revert Add support for specifying the :customer [melari] -* Quickpay: Make v7 of the API default [kvs] -* Bitpay: Add return [tahnok] - -== Version 1.39.2 (October 10th, 2013) - -* Eway Rapid: Fix a bug with access codes that have equal signs in them [odorcic] - -== Version 1.39.1 (October 9th, 2013) - -* Bitpay: Invoice Fix [orenmazor] - -== Version 1.39.0 (October 9th, 2013) - -* Moneris: Add optional (off by default) verification_value support [duff] -* Citrus: New Integration [viatechs, melari] -* Payu Paisa: New Integration [melari] -* Spreedly: Pass country with other address fields [hoenth] -* SecureNet: Fix order of xml params [duff] -* Paymill: Add support for void [duff] -* Add MoneyMovers gateway [jeffutter] -* Ogone: Add a :store_amount option [rymai] -* Ogone: Require TLSv1 [ntalbott] -* Moneris: Add support for purchasecorrection [pgib] -* Spreedly: Add ability to retain on success [duff] -* Spreedly: Pass verification value [duff] -* Paymill: Add support for specifying the :customer [Sbastien] -* Realex: Correct AVS input format [ExxKA] -* USAEpay Transaction: Use sandbox when in test mode [radar] -* Braintree Blue: Do not use global config [rdj] -* eWay Rapid: Add response messages [BenZhang] -* Paysbuy: Add 'Pending' notification status [divineforest] -* Cybersource: Use standard :phone field [cade] -* Orbital: Fix/tweak AVS codes [boone] -* Quickpay: Add v7 support [larspind] -* Authorize.Net CIM: Add option to not mark transactions as test [alanandrade] - -== Version 1.38.1 (September 16, 2013) - -* Moneris: Remove verification_value support [melari] - -== Version 1.38.0 (September 6, 2013) - -* FirstData E4: Include missing address information for AVS and CVV [melari] -* Litle: Deprecate credit method in favor of refund [melari] -* Moneris: Add verification_value support [duff] -* Webpay: Fixes issues with partial JPY currency [keikubo, melari] -* SecureNet: Add INVOICENUM and INVOICEDESC optional fields [duff] -* Balanced: Make BalancedGateway::Error inherit from ActiveMerchantError [duff] -* Balanced: Fix #void interface [duff] -* HiTrust: Return correct error message for positive retcodes [melari] -* Moving to pessimistic versioning [davefp] - -== Version 1.37.0 (August 20, 2013) - -* MerchantWarrior: Fix handling of amounts [duff] -* Ipay88: New gateway [kamal, siong1987, jduff] -* IATS: New gateway [unkown, jduff] -* MerchantWarrior: Send the CVV to the gateway [duff] -* PayU: Fix a major bug with status types [melari] -* SecureNet: Allow production transactions [duff] -* Stripe: Allow a card_not_present_fee to be specified [melari] - -== Version 1.36.0 (August 2, 2013) - -* Fat Zebra: More consistent handling of tokens [adrianmacneil] -* Add Platron integration [alexwl] -* Litle: Support wiredump_device [pierre] -* Litle: support paypage registrations [pierre] -* SecureNet: Cleanup and refactoring [duff] -* Mercury: Proper refund and void support [opendining] -* PaymentExpress: Return token in authorization [ntalbott] -* Stripe: Support for partial application fee refunds [melari, odorcicd] -* NMI: Support for recurring flag [duff] -* SecureNet: Use working live url [duff] - -== Version 1.35.1 (July 22, 2013) - -* Stripe: Allow application_fees to be refunded via the refund_application_fee flag [melari] - -== Version 1.35.0 (July 17, 2013) - -* Add Barclays ePDQ Extra Plus gateway [ntalbott] -* PayPal: Add MassPay payment to recipients by UserID [damonmorgan] -* Authorize.Net: Add authorization_code to response params [noahlh] -* Make Rails 4 a supported version [sanemat] -* CyberSource: Add pinless debit card support [JoshMcKin] -* Verkkomaksut: Add item title field [kaapa] -* Add MerchantWare V4 gateway [hron] -* Eway Rapid: Add #store method [adrianmacneil] -* Barclays ePDQ Extra Plus: Use correct PROD url [ntalbott] -* Hitrust: update test & live urls [melari] -* NAB Transact: Add auth & capture support [nagash] -* Mercury: Support card-less capture and refund [ntalbott] -* Mercury: Support void [ntalbott] - -== Version 1.34.1 (June 28, 2013) - -* WorldPay: Add dynamic return URL [jordanwheeler] -* Merchant One: New gateway [coteyr, melari] -* Balanced: Fix exception for invalid email [duff] -* Update supported countries for Paymill & PaymentExpress [duff] -* Worldpay: Add support for diners club [duff] -* Stripe: Include address with card data [melari] - -== Version 1.34.0 (June 20, 2013) - -* PayPal Express gateway: Add unstore support [duff] -* Stripe: Send application_fee with capture requests [melari] -* Make #unstore method signature consistent across gateways [duff] -* Dwolla: Major bug fixes. [capablemonkey, melari] -* Stripe: Add support for including track data [melari] - -== Version 1.33.0 (May 30, 2013) - -* Netaxept: Completely revamped to use the "M" service type [rbjordan3, ntalbott] -* Litle: Void authorizations via an auth reversal [jrust] -* Add RBK Money integration [england] -* Direcpay: Update test url [ashish-d] -* PayPal Express gateway: Add support for creating billing agreements [fabiokr] -* PayPal Express gateway: Add reference authorizations [fabiokr] -* Add Cardstream Modern gateway [ExxKA] -* Pin: Fix special headers [duff] -* PayPal Express gateway: Remember the billing agreement id as Response#authorization [duff] -* PayPal Express gateway: Allow an amount of 0 [duff] -* PayPal Express gateway: Reduce parameter requirements [duff] -* Quickpay integration: Update notification parser to handle API v6 [larspind] -* Sage gateway: Deprecate #credit call [duff] -* Update notification generator to better match current notification class [lulalala] -* Paymill gateway: Change .com -> .de [louiskearns] -* Quickpay integration: Fix v6 response parsing [larspind] -* First Data e4: Add TransArmor store/tokenization support [gabetax] -* MerchantWarrior: Format expiration month/year correctly [klebervirgilio] -* Add iconv for ActiveSupport 2.3 under Ruby 2.0 [sanemat] -* Add Transnational gateway [bvandenbos] -* Authorize.Net: Add Check as payment method [andrunix] -* Merchant e-Solutions: Add ref number and recurring support [carlaares] -* Bogus gateway: Add authorization to purchase response [hron] -* Bluepay gateway: Fix Check support; general cleanup [ntalbott] -* Dwolla: Fix security issues and enable guest checkout [capablemonkey, schonfeld] -* SagePay gateway: Per-transaction 3D-secure selection [ExxKA] -* Barclays ePDQ: Handle incorrectly encoded response [jordanwheeler, aprofeit] -* Orbital: Bug fixes; add CustomerEmail, Retry Logic, Managed Billing, and Destination Address [juicedM3 -* Distinguish invalid vs empty issue_numbers on CreditCards [drasch] -* Float Gemfiles to latest Rails [sanemat] -* USA ePay Advanced: Fix Check support [RyanScottLewis] -* Authorize.Net: Match up Check fields better with eCheck.Net requirements [ntalbott] -* Bluepay: Updated to bp20post api [cagerton, melari] -* Net Registry: Deprecate credit method [jduff] -* Sage: Don't include T_customer_number unless it is numeric [melari] -* Auth.net: Don't include cust_id unless it is numeric [melari] -* Epay: Deprecate credit method [melari] -* New PayU.in Integration [PayU, melari] - -== Version 1.32.1 (April 4, 2013) - -* CC5 and Garanti: Remove $KCODE modifications [melari] -* Paymill: Add support for store [ntalbott] -* USA ePay: Fix misspelling of "Aduth" [joelvh, ntalbott] -* Orbital: Fix nil address values throwing exceptions during truncation [melari] - -== Version 1.32.0 (April 1, 2013) - -* Optimal: Submit shipping address with requests [jduff] -* Iridium: Enable reference transactions for authorize [ntalbott] -* Stripe: Add authorize and capture methods [melari] -* Pin: Add a default description if none is specified to fix failures [melari] -* Litle: Add support for passing optional fields in token based transactions [forest] -* Add Finansbank gateway [scamurcuoglu] -* Paymill: Use .com instead of .de for save card url [besi] -* Worldpay integration: Use more robust endpoint urls [nashbridges] -* Braintree Blue: Return CC token in transaction hash [cyu] -* Robokassa: Fix signature for empty amount [ukolovda] -* Worldpay gateway: Fix error messages for some failures [duff] -* Worldpay gateway: Allow settled payments to be refunded [dougal] -* Spreedly: Update urls and terminology [duff] -* Make card brand error more user friendly [oggy] -* DataCash: Update test Mastercard number [jamesshipton] -* DataCash: Update test response fixtures [jamesshipton] -* Pin: Add Pin.js card token support [nagash] -* PayPal Express gateway: Fix error when no address information is in response [pierre] -* Ogone: Use BYPSP for ALIASOPERATION [ntalbott] -* Paymill: Handle error storing card [duff] -* SagePay integration: Add referrer field [melari] -* Pin: Add extra headers [duff] -* Paymill: Add support for store [ntalbott] -* USA ePay Advanced: Fix typo in message credit card data options [joelvh] - -== Version 1.31.1 (February 25, 2013) - -* Cybersource: Bug fixes [natejgreene, jduff] - -== Version 1.31.0 (February 20, 2013) - -* Worldpay: XML encoding is required to be ISO-8859-1 [dougal] -* Worldpay: Add card code for more supported card types [dougal] -* Ogone: Add action option [pwoestelandt] -* PayPal Express gateway: Add support for BuyerEmailOptInEnable [chrisrbnelson] -* Add Paymill gateway [duff] -* Add EVO Canada gateway [alexdunae] -* Fixed credit card and check interface, used correct method for checking payment type [jduff] - -== Version 1.30.0 (February 13, 2013) - -* Add FirstData Global Gateway e4 [frobcode] -* PaymentExpress: Add support for optional fields: ClientType and TxnData [moklett] -* PaymentExpress: Limit MerchantReference/description to 64 chars [moklett] -* Wirecard: description must be no more than 32 characters [moklett] -* Litle: Add support for passing a token to the authorize and purchase methods [forest] -* PayPal Common: Allow searching for transactions by ProfileID [aq1018] -* Add Spreedly Core gateway [duff] -* eWay Gateway: Return proper value for authorization [duff] -* eWay Gateway: Add support for refunds [duff] -* Quickpay: Add support for protocols 5 & 6 [twarberg] -* Banwire gateway: Handle JSON::ParserError [duff] -* Balanced gateway: Fix unspecified marketplace [duff] -* QBMS gateway: Allow partial addresses [duff] -* Authorize.Net CIM: Allow omitting card expiration date [shanebonham] -* Authorize.Net CIM: Add support for extraOptions to createCustomerProfileTransaction [tpiekos] -* Add NETPAY gateway [samlown] -* Balanced gateway: Add amount to the refund method signature [ntalbott] -* Orbital gateway: Fix void method signature [aprofeit, ntalbott] -* Eway Managed: Add 'query_customer' API as #retrieve [cdaloisio] -* NetPay: Fix the signature for void [duff] -* Cybersource: Add check support [bowmande] -* Moneris: Use a capture of $0 for void [ntalbott] -* PayPal Express integration: Fix received_at time zone [ntalbott] -* NAB Transact: Add refund capability [nagash] -* Stripe: Add support for application_fee [duff] -* SagePay: Add support for GiftAidPayment [duff] -* Wirecard: Add support for partial captures [richardblair] -* Add Pin gateway [madpilot] -* Balanced: Added support for on_behalf_of_uri to capture [cwise] -* Litle: Add support for passing an order_source [forest] -* Add Merchant Warrior gateway [pronix, Fodoj, ntalbott] -* Use v4 of the MerchantWare API for voiding transactions [melari] -* Add support for Authorize.net in CA and GB [melari] -* Send customer's IP to Beanstream for fraud review [melari] - -== Version 1.29.3 (December 7, 2012) - -* Braintree Blue: Better wiredump_device support [ntalbott] -* Braintree: Store sets vault id as authorization [ntalbott] -* WorldPay: Fix currencies without fractions like JPY and HUF by rounding down amount [Soleone] - -== Version 1.29.2 (December 7, 2012) - -* Moneris: fix issue with the default options not being merged [jduff] -* Sage Pay: Make 0000 default post code for everyone if missing [BlakeMesdag] - -== Version 1.29.1 (December 5, 2012) - -* Add eWay Rapid 3.0 gateway [ntalbott] -* Fix AVS responses missing attributes [jduff] - -== Version 1.29.0 (November 30, 2012) - -* Authorize.Net gateway: Support description and order_id for capture [ntalbott] -* Add Mercury gateway [adr1anx, opendining] -* Webmoney integration: Add gross, item_id, and amount accessors to notification [fr33z3] -* Fix running tests under ActiveSupport 2.3.14 [ntalbott] -* SagePay Form integration: Remove dependency on ActiveSupport's String#truncate [ntalbott] -* Elavon gateway: Add support for the sales tax parameter [stevestmartin] -* Add WebPay gateway [keikubo] -* iTransact gateway: make void API consistent [frobcode] -* Stripe gateway: Pass city in add_address [npverni] -* Paypal gateway: Add option to change the outstanding balance of a recurring billing profile [mattwhite] -* Mercury gateway: Fix authorizations API [ntalbott] -* Mercury gateway: Support refund properly [ntalbott] -* Braintree Blue gateway: Add support for the recurring flag [ntalbott] -* Add HDFC gateway [ntalbott] -* HDFC gateway: Add more supported currencies [ntalbott] -* HDFC gateway: Add support for passing ECI value [ntalbott] -* HDFC gateway: Allow setting test mode via options [ntalbott] -* HDFC gateway: Pass phone number in UDF3 [ntalbott] -* HDFC gateway: Fix unescaped '&' entity in XML [ntalbott] -* HDFC gateway: More robust entity fixing [ntalbott] -* Add A1Agregator integration [england] -* Refactored handling of #test? and @options [ntalbott] -* Realex gateway: Realex gateway: Fix billing address format [ntalbott] -* Orbital gateway: handle custom AVS response codes [jonm-okc] -* Orbital gateway: Fix infinite connection retry [jonm-okc, ntalbott] -* PayPal integration: Add support for MassPay IPN notifications [damonmorgan] -* Orbital gateway: Fix status of void result [jonm-okc] -* Add Redsys gateway [samlown] -* Cybersource gateway: Add support for subscription credit [fabiokr] -* Use Thor for generators [ntalbott] -* Psigate gateway: Add void support [samuelreh] -* Add Liqpay integration [beorc] -* Paypal Express gateway: Add shipping accessor to response [v-fedorov] - -== Version 1.28.0 (August 10, 2012) - -* PayPal Express: support non standard locale codes [Soleone] -* Litle: allow setting test mode per transaction [jduff] -* Add Banwire gateway [acolin] -* Authorize.Net CIM gateway: Move cardCode after order to comply with the XSD [davetron5000] -* Add WebMoney integration [Mehonoshin] -* EasyPay: Make symmetric with other integrations [nashby] -* Add Paysbuy integration [divineforest] -* Bogus gateway: Use last digit for pass/fail [mipearson] -* Elavon gateway: Separate from Viaklix, implement refund & void [duff] -* Orbital gateway: Update to API version 5.6 and add support for profile requests [rbarazi] - -== Version 1.27.0 (August 10, 2012) - -* Add First Data integration [courtland] -* Add WebPay integration [nashby] -* Add Suomen Maksuturva integration [akonan] -* Payway gateway: Fix card storage [BenZhang] -* Payflow Pro gateway: Add MaxFailPayments support [gregwinn] -* Add Paxum integration [Mehonoshin] -* Add Balanced gateway [mjallday] -* Plug'n Pay gateway: Add tests for partial capture [csaunders] -* Braintree Blue gateway: Add credit card details to responses [dougbradbury] -* PayPal gateway: Support for 'Full' refund type [kurenn] -* Worldpay: fix refund [jduff/omh] -* Add PxPay offsite integration [boourns] -* Wirecard: always capture 'authorization' transaction [ntalbott] -* Add rake task to verify ssl certs [boourns] - -== Version 1.26.0 (July 6, 2012) - -* Orbital gateway: fix broken requests by ensuring the order of XML elements matches their DTD [Soleone] -* CyberSource gateway: clean up formatting [ntalbott] -* Netbilling gateway: Add refund/credit/void support [ntalbott] -* Add PayGate XML gateway [rubyisbeautiful] -* Add PayWay gateway [BenZhang] -* PayWay gateway: Tweaks to make more ActiveMerchant like [ntalbott] -* Netbilling gateway: Fix error handling [ntalbott] -* Netbilling gateway: Add refund/credit/void support [zenom, ntalbott] - -== Version 1.25.0 (July 3, 2012) - -* eWAY gateway: Add support for Diners Club cards [Soleone] -* Orbital gateway: Never send country code for orders outside of US, CA and GB [Soleone] -* Add EasyPay integration [nashby] -* Updating LitleOnline requirement to 8.13.2 to take advantage of better validation and get bugfix for Username [GregDrake] -* USAepay gateway: Add description support [ntalbott] -* Add Paypal Payments Advanced integration [csaunders] -* Authorize.Net gateway: Improve #refund docs [neerajdotname] -* Wirecard gateway: Fix for missing address hash [ntalbott] -* Clean up requires of RubyGems and JSON gems. Rename remote Litle test to match naming conventions [codyfauser] -* Cybersource gateway: Fix updating address only [fabiokr] -* Cybersource gateway: Move email requirement [fabiokr] -* Add the Metrics Global gateway [DanKnox] -* Braintree Blue gateway: Support wiredump_device [moklett] -* Add Fat Zebra gateway [amasses] -* Braintree Blue gateway: Always pass CVV on update [shayfrendt] -* eWAY gateway: Update docs. Require address [juggler] -* Cybersource gateway: Add support for subscriptions [fabiokr] -* WePay: Use better endpoint for recurring with no CVV [davidsantoso] - - -== Version 1.24.0 (June 8, 2012) - -* PayPal gateway: Support for incomplete captures [mbulat] -* Moneris gateway: Add support for vault [kenzie] -* NAB Transact gateway: Add support for card descriptors [nagash] -* SagePayForm: truncate long description fields [jnormore] -* Paybox Direct: treat all response codes besides '00000' as failures -[Soleone] -* Deprecate CreditCard#type method in favor of CreditCard#brand [jduff] -* Cybersource gateway: Add subscriptions support [fabiokr, jaredmoody] -* eWay gateway: Improved docs, and more accurate required parameters [juggler] -* Braintree Blue gateway: Always pass CVV on card update [shayfrendt] -* Add Fat Zebra gateway [amasses] -* Braintree Blue gateway: Add support for wiredump_device [moklett] -* Add Metrics Global gateway [DanKnox] -* Cybersource gateway: Do not require email address for subscription operations [fabiokr] -* Cybersource gateway: Fix passing only an address when updating a subscription [fabiokr] -* Wirecard gateway: Fix for missing address; general cleanup [ntalbott] -* Authorize.Net gateway: Document ability to just pass the last four to #refund [neerajdotname] -* Add EasyPay integration [nashby] - -== Version 1.23.0 (May 23, 2012) - -* Add Litle gateway [GregDrake] -* PaymentExpress gateway: add support for BillingId and DpsBillingId for token [mikel] -* 2checkout integration: Add ability to auto settle [craigchristenson] -* 2checkout integration: Switch default mode to single page [craigchristenson] -* Cybersource: Revert - Add retrieve method to pull details on a -stored card [jduff] -* Cybersource: Revert - Add recurring payment support [jduff] -* PaymentExpress: add Cvc2Presence flag when submitting verification -value [jduff] -* SecurePayAU: fix CreditCard check [jduff] -* Barclays: fix order capture [csaunders/ntalbott/jduff] - -== Version 1.22.0 (May 17, 2012) - -* Remove version restriction for money gem [ylansegal] -* Add iTransact XML gateway [motske] -* PayPal Express Gateway: add options[:landing_page] [markus] -* USA ePay: Fix handling of AVS [duff] -* Ogone: Add store method to create an alias without making a purchase [joelcogen] -* Spelling fix: purcahse -> purchase [mnoack] -* ePay: Added more useful results for authorization errors [Dennis O'Connor] -* Add Robokassa integration [nashby] -* PayPal Gateway: Add recurring API [dscataglini] -* Braintree: Add support for :verify_card option on store [brentmc79] -* Moneris: cannot void a preauthorization [eddanger] -* Add Moneris US gateway [eddanger] -* Add Dotpay integration [kacperix] -* Payflow: Add description, comment and comment2 tags [ksnyder] -* Dotpay: Fix field mapping [kacperix] -* Authorize.Net CIM: Optionally add 'order' details to transactions [pote] -* Braintree: Allow including billing address when storing a customer [brentmc79] -* PayPal Gateway: Refactored PaymentDetails & PaymentDetailsItem common code [dscataglini] -* Viaklix/Elavon: Separate "demo accounts" from "test transactions" [mltsy] -* PayPal Gateway: Add transaction_details, balance, authorize_transaction, and manage_pending_transaction API calls [dscataglini] -* PayPal Gateway: Add support for TransactionSearch & DoReferenceTransaction [dscataglini] -* Cybersource: Add recurring payment support [jaredmoory] -* Tidy up gateway lists [ashokak] -* Paybox: remove Iconv usage [ntalbott] -* Dotpay: Add amount mapping, pin setter, and support for test? [kacperix] -* Braintree Blue: Make address country map to alpha2 [ntalbott] -* Use GB as the alpha2 country code for the UK [ntalbott] -* Realex: Handle XML response with unescaped ampersand [ntalbott] -* Add Vindicia gateway [steved555] -* Payment Express: use %w[] for country list [parndt] -* Braintree Blue: Match remote test up with change to :country [braintreeps] -* PayPal Integration: Fix received_at method time parsing [subbarao] -* Add MiGS Gateway [mnoack, nagash] -* Quickpay integration: Fix payment_service_for helper [TheMaster] -* Braintree Blue gateway: Improve update method [brentmc79] -* 2checkout integration: Add mode mapping & line items helper [AlexanderZaytsev] -* USA ePay Advanced gateway: Fix expiration date format. [cctalbott] -* Add ePay integration [ePay] -* 2checkout integration: Add support for single page payment routine [AlexanderZaytsev] -* Ogone: Add support for 3D Secure [rymai, ZenCocoon] -* Stripe gateway: Remove authorize and capture methods since they are not supported [jduff] -* Stripe gateway: default test to false if no livemode parameter is specified [jduff] -* Paybox Direct gateway: 'card absent' and 'do not honour' should be considered failures, not fraudulent [jduff] -* Add Verkkomaksut integration [akonan] -* Remove trailing spaces from generator templates [akonan] -* Payflow gateway: Allow modification of RetryNumDays [jrust] -* Payflow gateway: Don't auto-set start_date on modification [jrust] -* Bluepay gateway: Add ACH & recurring support [jslingerland] -* Orbital gateway: Don't send AVS address details for any country besides US, CA, GB and UK [Soleone] -* Payflow Express gateway: Better amount handling [jduff] -* Barclays gateway: Allow American Express [duff] -* Ogone gateway: Remove duplicated method [ntalbott] -* Cybersource gateway: Add retrieve method to pull details on a stored card [fabiokr] - -== Version 1.21.0 (March 7, 2012) - -* Stripe: Add support for passing IP [collision] -* Merchant e-Solutions: pass expiration date when purchasing with a stored credit card [chrisyoung] -* Braintree: Fix passing custom processor ids to old accounts [maxsilver] -* Authorize.net CIM: Add validation mode option to create_customer_profile_request [jwood] -* eWay Managed: Include transaction number in response params [jamsi] -* Fix various hash ordering issues exposed by Ruby 1.8 [ntalbott] -* Authorize.Net CIM: Add WEB echeck type [deathbob] -* Move Braintree from the gemspec to the Gemfile [ntalbott] -* Add CertoDirect gateway [hron] -* Authorize.Net CIM: Add option for setting a custom delimiter [bmorton] -* Authorize.Net CIM: Add 3.1 response fields [bmorton] -* Authorize.Net CIM: Misc fixes and doc improvements [bmorton] -* Authorize.Net CIM: Fix error when order is blank [KeeperPat] -* Beanstream: Add recurring payments support [castiglione] -* Make ePay password optional [ePay] -* Quickpay: skip testmode if transaction provided [brentmc79] -* Payflow: add additional fields [thorstadt] -* Authorize.Net CIM: Add get_customer_profile_ids [howaboutwe] -* PayPal Express: Add support for BrandName and Custom fields [exviva] -* Payflow: Handle dates with leading zeros [jcoleman] -* Authorize.Net CIM: Add CCV code support & improve tests [tgarnett] -* Add Authorize.Net SIM integration [courtland & rdp] -* Secure Pay AU: Handle periodic payments [tommeier] -* Viaklix: Add discover as a supported card type [waelchatila] -* Improvements to testing infrastructure for integrations [jduff] -* Add NAB Transact (AU) Gateway [tommeier] -* PayPal Express: Add Support for Reference Transactions using BAIDs [kenmazaika] -* Authorize.Net CIM: Add support for optional refund fields [nilmethod] -* SecurePayTech: Fix EnableCSC parameter so CVV codes are checked. [tlconnor] -* SecurePayTech: Add remote tests for CSC checking. [tlconnor] -* Samurai: Add option to retain payment methods once stored [brentmc79] -* PayPal Express Gateway: Add support for Digital Goods / Micropayments [kenmazaika] - - -== Version 1.20.4 (February 22, 2012) - -* Fix json dependency - -== Version 1.20.3 (February 7, 2012) - -* Various fixes to support Ruby 1.9 [wisq] -* SkipJack: Fix partial capture [jduff] -* Optimal Payments: submit region when outside North America [jduff] -* USA ePay: Add void and refund support [duff/ntalbott] -* Add first digits to credit card [codyfauser] -* Orbital: fixes to authentication and order id [Soleone] -* Stripe: fixes to purchase method [duff/ntalbott] - -== Version 1.20.2 (January 16, 2012) - -* Remove authorize/capture support for Stripe [gdb] - -== Version 1.20.1 (December 22, 2011) - -* PayflowExpressUk: Fix parsing street2 from response [odorcicd] -* AuthorizeNet: Support tracking id [odorcicd] -* SagePay Form: Map billing address to shipping address [jduff] - -== Version 1.20.0 (November 14, 2011) - -* Add support for USA ePay Advanced SOAP interface [matthewcalebsmith/jduff] -* Beanstram: fix purchase with Secure Profile [pitr/jduff] -* Orbital: various fixes [Soleone] -* Add Samuari gateway by Fee Fighters [jkrall/odorcicd] -* Lock money gem to 3.7.1 or less since newer versions break in 1.9 [jduff] -* Braintree: handle gateway rejected transactions gracefully [braintreeps/jduff] -* Ogone: support different signature encryptors, custom currency and eci [ZenCocoon/rymai/jduff] -* Payflow Link: use secure token [jduff] -* Added refund method to Exact, Pay Junction and Skip Jack gateways [jduff] -* Elavon: added test url [kylekeesling/jduff] -* Fix redundent errors when credit card is expired [castiglione/jduff] -* Two Checkout: update service url [vampirechicken/jduff] - -== Version 1.18.1 (September 23, 2011) - -* Braintree: allow setting merchant_account_id on initialize [jduff] -* Realex: only send letters and numbers in shipping code field [Soleone] - -== Version 1.18.0 (September 23, 2011) - -* NoChex: Update the URL that payment requests are posted to [caseywhalen/jduff] -* QBMS: fixed test mode check [Soleone] -* Realex: encode avs info with shipping address [Soleone] -* Add Dwolla offsite gateway [armsteadj1/jduff] -* Eway: pass email, customer, description and options to store [moklett/tobi] -* New dependency: active_utils gem [odorcicd] -* Optimal Payments: fix test mode check [jduff] - -== Version 1.17.0 (August 23, 2011) - -* Add Payflow Link integration [jduff] -* Add CardSave gateway [MrJaba/jduff]] -* Quickpay: Support protocal version 4 and fraud parameters [anderslemke/jduff] -* Authorize.net: Add status_recurring [mm1/jduff] -* Paypal Express: Support specifying :items with purchase [sivabudh/jduff] -* ePay: Add Sweden and Norway to supported countries [ePay/jduff] -* Brainreee: Support passing merchant_account_id parameter [braintreeps/jduff] -* Paypal Express: Remove deprecated Address field in favor of ShipToAddress[jduff] -* Add Optimal Payments gateway [jamie/jduff] -* Documentation improvements [dasch/nhemsley/jstorimer/jduff] -* Authorize.Net: Pass through first name, last name, and zip for refunds. [ntalbott] - -== Version 1.16.0 (July 18, 2011) - -* Bogus: Support referenced transactions for #authorize, #purchase, #recurring and -#credit [dasch/jduff] -* Payment Express: Update gateway url [bayan/titanous] -* Moneybookers: Send country and account_name if provided [Soleone] -* Moneris: Add Diners Club and Discover [Soleone] -* Cybersource: add auth_reversal support [jeberly/titanous] -* WorldPay: Update endpoint URLs for offsite gateway [Soleone] -* Worldpay: Add JCB and add Maestro [Soleone] -* Authorize.net: Add Diners Club and JCB [Soleone] -* Quickpay: Add testmode for subscribe and authorize [dasch/jduff] -* Orbital: fix handling of phone numbers. [ntalbott] -* Braintree: Add Diners Club [cody] -* Add ePaymentPlans offsite payment [robertomiranda/Soleone] -* Add Stripe gateway [boucher/titanous] -* Add Paystation gateway [nikz/jduff] -* Bump minimum ActiveSupport version to 2.3.11 [titanous] -* Use securerandom from stdlib not active_support [phlipper/jduff] - -== Version 1.15.0 (May 12, 2011) - -* DirecPay: Fix address to not include address2 twice in some cases [Soleone] -* DirecPay: Send company if available [Soleone] -* Realex: Fix hash signature [ntalbott/Soleone] -* SecurePay AU: Update remote tests [ntalbott] -* SecurePay AU: Fix method arity for #capture, #refund, #credit and #void [Soleone] -* Barclays ePDQ: Make response parsing more robust [Soleone] -* Payflow Express: Add line item support [wolframarnold] -* Payflow Express: Add comment field support [wolframarnold] -* Payflow: Add more optional fields [wolframarnold] -* Beanstream/Paypal: Fix CREDIT_DEPRECATION_MESSAGE errors [Jonathan Rudenberg] -* BraintreeBlue: Return a hash instead of a transaction object [braintreeps] -* BraintreeBlue: Return proper AVS/CVV values [braintreeps] -* Bogus: Add #recurring [trwomey] -* Make Validateable compatible with ActiveModel [CodeMonkeySteve] -* Add DirectEBanking offsite gateway [Gerwin Brunner/Soleone] -* ActiveSupport 3.1 beta support [cgriego] - -== Version 1.14.0 (Apr 29, 2011) - -* SagePayForm: Implement #cancelled? for Return. [wisq] -* Add #cancelled? to Integrations::Return [wisq] -* Bogus gateway: Add refund support and better tests [wisq] -* Beanstream: Add support for storing cards [duffomelia] -* eWay: Add support for storing cards [duffomelia] -* Add validation mode to update profile request [Ken Miller] -* Authorize.net CIM: Add oldLiveMode [ntalbott] -* Authorize.net CIM: Add extra transaction types [Ken Miller] -* JetPay: gateway tweaks [ntalbott] -* Deprecate a bunch more #credit methods [ntalbott] -* RealEx: Add authorize/capture/credit/void [ntalbott] -* SecurePay AU: Add authorize/capture/credit/void [ntalbott] -* PayPal Express: Make response parsing more robust [ntalbott] -* Test deprecation warnings; add deprecation line numbers [ntabott] -* Add Orbital direct gateway [ntalbott] -* Add WorldPay direct gateway [ntalbott] - -== Version 1.13.0 (Apr 19, 2011) - -* Add a Gemfile for optional bundler support [ssoroka] -* Stop using has_rdoc= when rubygems version is 1.7.0 or greater, since it's deprecated [ssoroka] -* Add tax field to braintree [wisq] -* Quickpay: Also add Sweden as supported country [Soleone] -* Adding refund method for gateways that are using the credit method for referenced based refunds, added deprecation worning to the credit method [John Duff] -* Return the Braintree transaction id in the response for void and refund transaction calls [John Duff] -* PayPal Express: Extract phone number from address if no contact phone was sent [Soleone] -* Unify all offsite gateways that verify the signature of Returns or Notifications by always using the #acknowledge method and calling the secret :credential2 [Soleone] -* Valitor: Change name of credential for Return and Notification from :password to :credential2 in symmetry with the other Integrations [Soleone] -* Moneybookers: Add support for tracking token [Soleone] -* Moneybookers: Require credential when creating Notifications instead of adding an argument to #acknowledge [Soleone] -* Moneybookers: Fix Notification to return correct status [Soleone] -* Support default Return class for all Integrations that don't use returns [Soleone] -* Add support for passing additional options when creating a Notification to all Integrations [Soleone] -* Update BraintreeBlue#refund to have consistent method signature [Jonathan Rudenberg] -* Add rails/init.rb for gem campatability in Rails [Rūdolfs Ošiņš] -* Fix Paypal Express response parser [Jonathan Rudenberg] -* Braintree/Transax: Add tax field [wisq] - -== Version 1.12.1 (Mar 21, 2011) - -* Ogone: Make sure response.params is a real Hash [Soleone] -* WorldPay: Fix service_url in production mode [Soleone] - -== Version 1.12.0 (Mar 1, 2011) - -* DirecPay: Send phone number as mobile phone by default [Soleone] -* Support sending line items for PayPal Express transactions [Jonathan Rudenberg] -* Update PayPal Express XML format to latest version [Jonathan Rudenberg] -* Fix custom image header for PayPal Express [mwagg] -* Add InvoiceID and OrderDescription to PayPal Express Authorize and Capture [cody] -* Add Moneybookers integration [Alex Diakov] -* Add QBMS (Quickbooks Merchant Services) gateway [ntalbott] -* Add NMI gateway [ntalbott] -* Make fully compatible with Rails 2 & 3, and Ruby 1.8 & 1.9 [ntalbott] -* Authorize.Net: Only return AVS message for AVS-related reason codes. [ntalbott] -* Add Federated Canada gateway [ntalbott] -* Garanti: Fix text normalization for nil values [Selem Delul] -* Valitor: Always send amount without any decimal places [Soleone] -* Add WorldPay integration [Soleone] - -== Version 1.11.0 (Feb 11, 2011) - -* Bump dependency for activesupport from 2.3.2 to 2.3.8 [Soleone] -* Garanti: Normalize text in xml fields for non-standard characters [Selem Delul] -* Garanti: Make sure order number does not contain illegal characters [Soleone] -* Fix ActionView tests for ActiveSupport 3.0.4 [Soleone] -* DirecPay: Make address information editable by default [Soleone] -* Fix ePDQ credit to expect and handle full authorization [Nathaniel Talbott] -* Add Barclays ePDQ Gateway [Nathaniel Talbott] -* Add default fixture for Garanti and don't use fixture for Garanti [cody] -* Add cms param for ePay [ePay] -* Add Valitor Integration [Nathaniel Talbott] - -== Version 1.10.0 (Jan 20, 2011) - -* PayPal Express: Support returning payer phone number [Soleone] -* Fix ePay to correctly send order number [Soleone] -* Add BluePay Gateway [Nathaniel Talbott] -* Add Quantum Gateway [Joshua Lippiner] -* Add iDEAL/Rabobank gateway [Jonathan Rudenberg] -* SagePayForm: Added send_email_confirmation (default false) to enable confirmation emails [wisq] - -== Version 1.9.4 (Jan 5, 2011) - -* Update Garanti gateway to integrate with new API [Selem Delul] - -== Version 1.9.3 (December 17, 2010) - -* Fix BBS Netaxept to change transaction type from C (for MOTO: mail order telephone order) to M (for credit card orders) [Soleone] -* Fix Iridium and ePay to work with any object that responds to credit card methods not only ActiveMerchant::CreditCard objects - -== Version 1.9.2 (December 9, 2010) - -* Add support for PayPal mobile payments [wisq] -* Add ePay gateway [ePay, Jonathan Rudenberg] -* Allow access to the raw HTTP response [Jonathan Rudenberg] - -== Version 1.9.1 (November 24, 2010) - -* PayPal Express and PayPal Pro: Send JPY currency correctly without decimals [Soleone] -* Netaxept: Make sure password (token) is URL escaped and update remote tests for updated server behavior [Soleone] -* DirecPay: Add support for additional options in Return class and add convenience method to get transaction status update [Soleone] -* Add new alias credit_card.brand for credit_card.type and handle the brand correctly in Netaxept [Soleone] -* Iridium: Do not depend on ExpiryDate class for credit_card [Soleone] -* PayFlow: Use same timeout of 60 seconds in HTTP header and XML for all requests [Soleone] -* PayPal Website Payments Pro CA no longer supports American Express cards [Soleone] -* Updated BIN ranges for Discover to match recent documents [kaunartist] - -== Version 1.9.0 (October 14, 2010) - -* Add support for DirecPay gateway [Soleone] -* Add SagePay Form integration gateway [wisq] -* Allow Return class to include a Notification for gateways that treat the direct response as a notification [wisq] -* Add support for PayboxDirect gateway [Donald Piret] -* Add support for SecureNet gateway [Kal] -* Add support for the Inspire gateway [ryan r. smith] - -== Version 1.8.0 (September 24, 2010) - -* PayPal Express: Add support for billing agreements [Nathaniel Talbott] -* Allow comparing countries [Nathaniel Talbott] -* Iridium: Fix country handling [Nathaniel Talbott] -* Iridium: Fix missing billing address [Nathaniel Talbott] -* Iridium: Do not pass CV2 if not present [Nathaniel Talbott] -* Add Iridium support [Phil Smy] -* Add Netaxept support [Nathaniel Talbott] -* PaymentExpress: Use Card Holder Help Text for the response message [Nathaniel Talbott] -* Sort the country name list [Duff OMelia] - -== Version 1.7.3 (September 14, 2010) - -* Fix SagePay special handling for Japanese YEN currency to not send fractional amounts [Soleone] - -== Version 1.7.2 (August 27, 2010) - -* Update Braintree integration to play nicely with the braintree 2.5.0 gem [Soleone] -* Fix SagePay to not send fractional amounts for Japanese YEN currency [Soleone] - -== Version 1.7.1 (July 28, 2010) - -* Pull in only the necessary components of Active Support. Enables use of ActiveMerchant with Rails 3 [railsjedi] - -== Version 1.7.0 (July 9, 2010) - -* Add support for new Braintree Blue Gateway (using the braintree gem) [Braintree] - -== Version 1.6.0 (July 6, 2010) - -* Add a task rake gateways:hosts to get a list of all outbound hosts and ports [cody] -* Fix test failure in chronopay helper in Ruby 1.9.1 [cody] -* Fix timezone issue in credit card test. [cody] -* Fix failing unit test for Garanti gateway [cody] -* Fix failing CyberSource remote test [Patrick Joyce] -* Support for Garanti Sanal Pos: Turkish bank and billing gateway [Selem Delul] -* Add deprecation note for Money objects to Bogus gateway [Soleone] -* Updated test URL for Merchant eSolutions and added valid remote test credentials [Soleone] -* Add new error class for SSL certificate problems in connection class [Soleone] -* Update valid_month and valid_expiry_year to coerce string arguments to integers [cody] -* Add support for displaying credit cards with PayPal Express. Use the :allow_guest_checkout => true option when setting up the transaction [Edward Ocampo-Gooding] -* Use card_brand method for checking for checks in Sage and Beanstream [cody] -* Add JCB and Diners Club to LinkPoint [Soleone] - -== Version 1.5.1 (February 14, 2010) - -* Cleanup Rakefile, add gemspec and prepare for 1.5.1 release [cody] -* Update copyright dates [cody] -* Work around SkipJack bug by reversing the order of the query params [Soleone] -* Fix uppercase character in autoload of 2Checkout's Notification class [Edward Ocampo-Gooding] -* Detect language used in Chronopay integration based on billing address country [Soleone] -* Better handle international addresses in BeanstreamGateway [Soleone] - -== Version 1.5.0 (February 2, 2010) - -* Fix Gestpay notification to avoid Ruby 1.9 warnings [cody] -* Fix Chronopay notification time parsing for Ruby 1.9 [Joe Van Dyk] -* Set default currency of Braintree to USD [cody] -* Fix QuickPay helper for Ruby 1.9 compat [cody] -* Use String#each_line instead of collect in PaySecureGateway for Ruby 1.9 compat [cody] -* Use String#each_line instead of to_a in SagePayGateway for Ruby 1.9 compat [cody] -* Don't return an array when finding the country code. Fixes issue with Ruby 1.9 [cody] -* Fix custom assertions for Ruby 1.9 [cody] -* Deprecate Money objects [cody] -* Update JCB rejex to catch all valid PANs [pjhyett] -* Remove old TransaXGateway constant [cody] -* Remove old ProtxGateway constant [cody] -* Remove old BrainTree constant [cody] -* Remove AuthorizedNet constant [cody] -* SecurePay changed their delimeter from % to ,. Update gateway to handle changes [Soleone] -* Fix documentation typo in base.rb [mig-hub] -* Add capture test to Linkpoint [Dusty Doris] -* Fix bug in Linkpoint with ternary operator and Ruby 1.9.1 [Dusty Doris] -* Add currency and processor options to Braintree gateway [cbillen] -* Unify API to always look for billing_address/address hash inside of options [stopdropandrew] -* Fix bug with Modern Payments Gateway where failure authorizations appeared to be successful [cody] -* Fix Modern Payments Gateway [cody] -* Use basic SkipJack host for all non-authorization transactions. Fix status method [cody] -* Strip non alpha numeric chars out of MerchantWare order number [cody] -* Parse complete response of Authorize.net CIM gateway [Patrick Joyce] -* Update to PayPal Sandbox URL for testing Payflow Pro Express Checkout. See Express Checkout for Payflow Pro guide [cody] -* Provide a C_STATE value of "Outside United States" for SageGateway when processing international customers [cody] -* PayPal Website Payments Pro Canada supports Amex [cody] -* Add line item support for LinkpointGateway. [Tony Primerano] -* Add support for SallieMae gateway [iamjwc] -* Add support for the JetPay gateway [Phil Ripperger, Peter Williams, cody] -* Add support for advanced SkipJack processors. Pass :advanced => true when constructing gateway [cody] -* Support test option in AuthorizeNetCimGateway [Tim] -* Improve Ogone error messages [cody] -* Add support for :test => true option to OgoneGateway [cody] -* Bump PayPal Version to 59.0 [cody] -* Add amex support to eWay gateway [cody] -* Change Payflow header X-VPS-Timeout -> X-VPS-Client-Timeout [cody] -* Fix typo preventing OgoneGateway from working in production [Nicolas Jacobeus] -* Add support for the Elavon MyVirtualMerchant gateway [jstorimer] -* Fix recurring transactions in Ogone gateway [cody] -* Fix money formatting for Ogone gateway [cody] -* Tweak Ogone gateway to use ActiveMerchant conventions for reference transactions [cody, jstorimer] -* Add support for the Ogone DirectLink payment gateway [Nicolas Jacobeus] -* Add support for the Antigua based FirstPay payment gateway [Phil R] -* Add support for PayPal reference transactions [kevin, John, Rahsun McAfee] -* Add support for the MerchantWARE payment gateway [cody] -* Rename Protx to SagePay [jstorimer] -* Allow test mode for eWay gateway [Duff OMelia] -* Don't use Time.parse for the ExpiryDate [cody] -* Add support for CVV code to Authorize.net CIM [Guy Naor] -* Add shipping address to Authorize.net [Eric Tarn] -* Don't setup the logger by default [cody] -* Refactor ActiveMerchant::Connection out of the PostsData module. Add support for logging and wiredumping requests [cody] -* Assume a valid load path when running tests [cody] -* Use SHIPTOSTREET2 element instead of STREET2 element for Payflow Express Uk address [cody] -* Clean up the test helper [cody] -* Fix DataCash unit test that was making a remote call [cody] -* Don't check Request#test? for remote PaymentExpress tests because their test environment has changed [cody] -* Update Instapay gateway to support capture and add address, order, and invoice fields. Add support for CVV and AVS response [cody] -* Add support for Instapay gateway [brahma] -* Cleanup PaymentExpress reference purchases and turn on AVS [cody] -* Add reference purchases and authorizations to PaymentExpress [mocra] -* Add support for Merchant e-Solutions Gateway [Zac Williams, Robby Russell] -* Fix Braintree unit test [cody] -* Add support for checks to SmartPs gateways [jvoohris] -* Extract SmartPs for Braintree and Transax [mmangino] -* Ruby 1.9 compatibility [bschwartz] -* Update Payflow Express to handle Street2 element [James MacAulay] -* Fix typo in Protx DeliveryState field [cody] -* Ignore Wirecard state unless it is 2 characters [Cody] -* Update Wirecard to make country and state processing more robust [Soleone] -* Update ProTX to use the latest v2.23 protocol [Tekin] - -== Version 1.4.2 (April 24, 2009) - -* Fix typo in Authorize.net CIM [infused] -* Add missing ISO countries [Edward Ocampo-Gooding] -* Add support for Guernsey to country.rb [cody] -* Add American Express to the MonerisGateway [cody] -* Use :words_connector instead of connector in RequiresParameters [cody] -* Fixed CreditCard not validating start_month and start_year when set as string [Tekin] -* Update PostsData to support get requests [cody] -* Fix broken Quickpay remote test [cody] -* Update Quickpay gateway to v3. Add support for offsite integration for Danish Dankort cards [Lars Pind] -* Use default partner id when passed in :partner is blank with PayflowGateway [cody] -* Remove PayflowGateway.certification_id [cody] -* Set Response#test? to true in TrustCommerce gateway when using the demo account in production [cody] -* Correctly set Sage.supported_countries [cody] -* Add BogusGateway#void [Donald Ball] -* Fix PSL gateway capturing [cody] -* Fix failed Visa debit purchases with PSL gateway start date info is present [cody] -* Support personal fixtures file on Windows [cody] -* Clearer variable naming for BraintreeGateway#authorize [Jonathan S. Katz] -* Fix brittle Authorize.net tests [cody] -* Add support for Authorize.net duplicate window [Seamus Abshere] -* Return transaction id for PayPal refunds [jxtps435] -* Allow storage of e-checks with BraintreeGateway [jimiray] -* Add test URL to PayJunction gateway [boomtowndesigngroup] -* More robust parsing for Wirecard gateway [Soleone] -* Pass the issue number to CardStream verbatim and update test card numbers [Soleone] - -== Version 1.4.1 (December 9, 2008) - -* Update CardStream URL. Note that you will also need to update your login id. [cody] - -== Version 1.4.0 (November 27, 2008) - -* Return failed authorization when SkipJack purchase fails [Tron, cody] -* Update README [cody] -* Add metadata to Authorize.net CIM gateway [cody] -* Make ActionViewHelper compatible with changes to concat method in ActionPack [cody] -* Remove PayPal and Payflow Name-Value gateways. PayPal is no longer terminating the Payflow XML API. [cody] -* Don't directly use the inflector in the action view helper [cody] -* Work around Rails Inflector change [cody] -* Add configurable timeouts to PostsData [Michael Koziarski] -* Add valid_sender? method to gateway integrations [Soleone] -* Fix PayPal error parsing [cody] -* Fix MIT-LICENSE [cody] -* Add a payment gateway for Website Payments Pro Canada [cody] -* Fix shipping amount option in Sage gateway [Darrick Wiebe] -* Improved message and error message handling [Soleone] -* Get Wirecard working in the Live environment [Soleone] -* Remove dead code in PayPal Common API files [cody] -* Use the PayPal short error message if the long message is empty [cody] -* Fix unit tests when being run by Cruise Control [cody] -* Add support for PayPal Fraud Review Response [cody] -* Add testing support for German Wirecard Gateway [Soleone] -* Specify required version of ActiveSupport [cody] -* Make ssl_strict a superclass_delegating_accessor so the entire application's validation of SSL certs can be disabled in the event of certificate problem. [cody] -* Make Gateway.application_id a superclass_delegating_accessor so it can be set from outside the subclass definition [cody] -* Add Discover to the list of supported card types for Braintree [cody] -* Add support for Modern Payments gateway [Jeremy Nicoll, cody] -* Add support for EFT/ACH and Interac Online to the BeanstreamGateway [cody] -* Document the SageGateway [cody] -* Add support for echecks with SageGateway. [cody] -* Handle all successful SecurePay AU response codes [cody] -* Get SageGateway working with real test account. Improve test suite. [cody] -* Unify TrustCommerce, Payment Express, and Braintree CC storage [benjamin.curtis] -* Update to use new Payflow Pro URLs [cody] -* Fix missing Content-Type header for Ruby 1.8.4 [cody] -* Fix Authorize.Net CIM response.message [patrick.t.joyce] -* Add JCB and Diners Club as supported cards to SageGateway [cody] -* Add CA country code to Sage gateway's supported countries [cody] -* Add support for Sage Payment Solutions gateway [cody] -* Add test mode detection to Beanstream [cody] -* Add support for Beanstream payment gateway [xiaobozz] -* Add support for PayPal NV Pair API. Will be used to replace the usage of the PayPal SOAP API in ActiveMerchant in the future [Greg Furmanek, cody] -* Protx does support UK Maestro [cody] -* Add tests for length of UK Maestro cards [cody] -* Return all the error messages and codes from paypal responses [cody] -* Fail hard when attempting to capture without a credit card with NetRegistry [cody] -* Add support for the order fields to the create_customer_profile_transaction in Authorize.net CIM. [Patrick T. Joyce] -* Strip invalid characters and limit lengths of Protx customer data [Simon Russell] -* Fix empty start or end dates in Protx [Simon Russell] -* Add support for Authorize.net CIM [Patrick T. Joyce, Ian Lotinsky] -* Add option to skip order review to all PayPal Express gateways [garret.alfert, cody] -* Add capturing partial amounts, fix issue number formatting, fix authorization string when nil values returned, fix parsing of multiple '=' characters, simplify message_from [Simon Russell] -* Fix StartDate in ProtxGatewy [cody] -* Add support for refunds and continuous authority references to DataCashGateway [joel.chippindale] -* Fix gross in HiTrust notification. Don't use Money object in Verifi gateway [cody] -* Initial implementation of Payflow Name-Value API [Greg Furmanek] -* Add support for CyberSource credits [mjuneja] - -== Version 1.3.2 (February 24, 2008) - -* Actually fix the bug by adding extdata element to Payflow Requests [cody] -* Fix bug with adding name to Payflow requests [cody] -* Gateways will now look for CreditCard#brand before looking for CreditCard#type [cody] -* Make before_validate in CreditCard more clear [keith_du...@mac.com, cody] -* Don't send full Australian state names to PayPal [cody] -* Return last_digits that are less than 4 characters long [cody] -* Fix Bug with Authorize.Net ARB Remote Test [patrick.t.joyce] -* Add support for forcing test mode on Secure Pay AU gateway [cody] -* Update Secure Pay Au to meet specs for MessageInfo elements [cody] -* Add support for the Australian Secure Pay payment gateway [cody] -* Allow LinkPoint cancellations for recurring billing. [yanagimoto.shin] -* Add support for Åland Islands to the country list [cody] - -== Version 1.3.1 (January 28, 2008) - -* Rename BrainTreeGateway to BraintreeGateway, but keep alias to old naming for backwards compatibility [cody] - -== Version 1.3.0 (January 28, 2008) - -* Remove attr_readers for url and response from Gateway [cody] -* Remove @url from EfsnetGateway [cody] -* Remove @response instance variable in QuickpayGateway. [cody] -* Remove @response instance variable in PsigateGateway. Don't use billing address for shipping [cody] -* Remove @response instance variable in PaypalGateway. Don't use billing address for shipping. [cody] -* Remove @response instance variable in PayflowGateway [cody] -* Remove @response instance variable in MonerisGateway [cody] -* Remove @response instance variable and don't use billing address for shipping address in LinkpointGateway [cody] -* Remove @response instance variable from ExactGateway [cody] -* Remove @response instance variable from EwayGateway [cody] -* Remove @response instance variable from EfsnetGateway [cody] -* Remove @response instance variable from DataCashGateway [cody] -* Don't use billing_address for shipping_address in CyberSourceGateway [cody] -* Remove @response instance variable from CardStreamGateway [cody] -* Remove @response instance variable from BrainTreeGateway [cody] -* Remove unused deal_with_cc method from BogusGateway [cody] -* Remove test_result_from_cc_number completely from ActiveMerchant [cody] -* Don't use billing_address for shipping_address in Realex [cody] -* Update Realex to add support for cvv data. remove test_result_from_cc_number. [cody] -* Update Protx to add support for avs and cvv data. remove test_result_from_cc_number. [cody] -* Include ActiveMerchant::Utils module in test_helper and use generate_unique_id from the module instead of generate_order_id. [cody] -* Update SecurePay tests to check for avs and cvv data. [cody] -* Update SkipJack to add support for avs and cvv data. remove test_result_from_cc_number. [cody] -* Move generate_unique_id to its own module [cody] -* Update Viaklix to add support for avs and cvv data. remove test_result_from_cc_number. Truncate fields to avoid failure [cody] -* Update PSL Card Gateway to add support for avs and cvv data. remove test_result_from_cc_number. [cody] -* Update PlugNPayGateway to support avs and cvv data. Remove test_result_from_cc_number. [cody] -* Update PaymentExpressGateway to remove test_result_from_cc_number. [cody] -* Update PaySecure to remove test_result_from_cc_number. [cody] -* Update NetbillingGateway to support avs and cvv data. Remove test_result_from_cc_number. [cody] -* Replace all usage of :address with :billing_address in test cases [cody] -* Remove sensitive data from NetRegistryGateway responses. Refactor gateway and tests. Remove test_result_from_cc_number. [cody] -* Update VerifiGateway to support avs and cvv data. Remove test_result_from_cc_number. [cody] -* Small refactoring of UsaEpayGateway [cody] -* Update UsaEpayGateway to support avs and cvv data. Remove test_result_from_cc_number. [cody] -* Update TrustCommerce docs now that the gateway falls back to SSL post when tclink isn't available [cody] -* Change ARB to use correct :address1 key for addresses [cody] -* No need for specialized recurring response for Authorize.net recurring billing [cody] -* Update TransFirst to support avs and cvv data. Remove test_result_from_cc_number. [cody] -* Maintain backwards compatibility with :address option for now in the Payflow gateways [cody] -* Remove test_result_from_cc_number from SecurePayTech. Improve unit test coverage [cody] -* Fix email option in PayflowGateway. Remove support for :address option. :billing_address and :shipping_address must now be passed in separately. [cody] -* Make Bogus gateway's credit() method behave like capture [cody] -* Add update and delete methods to update and delete records stored in the vault. [benjamin.curtis] -* Add support for recurring_inquiry() to the PayflowGateway [dave.my...@contentfree.com] -* Add support for Authorize.net Automated Recurring Billing (ARB) [vkurnavenkov, forestcarlisle, ianlotin...@hotmail.com, patrick.t.joyce] -* Fix laser card regex [ladislav.martincik] -* Cleanup whitepace in README [patrick.t.joyce] -* Update ExactGateway to support avs and cvv data. Remove test_result_from_cc_number. [cody] -* Remove test_result_from_cc_number from eWay gateway. [cody] -* Remove duplicate attr_reader definitions from all gateways [cody] -* Remove useless tests raising Error [cody] -* Update gateway templates [cody] -* Fix Authorize.net test where authorize() was being called instead of purchase(). Perform some cleanup of the tests [ianlotin...@hotmail.com, cody] -* Improve Authorize.net documentation based on the DataCashGateway docs [patrick.t.joyce] -* Update EfsnetGateway to support avs and cvv data. Remove test_result_from_cc_number. [cody] -* Remove test_result_from_cc_number from DataCash. Improve unit test coverage [cody] -* Update CyberSourceGateway to support avs and cvv results. Remove test_result_from_cc_number. [cody] -* Remove match information from CVVResult [cody] -* Remove Response#card_data. The application has access to the information anyway [cody] -* Return the last 4 digits of the card number from the Response instead of the masked number [cody] -* Actually use the shipping address in TrustCommerce [cody] -* Update TrustCommerceGateway to support avs and cvv results. Remove test_result_from_cc_number. Automatically fallback to SSL POST if the TCLink library is not available. Add additional customer information to the requests. [cody] -* Fix remote CardStreamGateway tests [cody] -* Map merchant AVS codes to street and postal match codes [cody] -* Update CardStreamGateway to support avs and cvv data [cody] -* Remove merchant_data hash. Add additional CVV codes [cody] -* Update QuickpayGateway to support merchant_data hash. Remove test_result_from_cc_number. [cody] -* Update LinkpointGateway to support merchant_data hash. Remove test_result_from_cc_number. [cody] -* Update PsigateGateway to support merchant_data hash. Remove test_result_from_cc_number. [cody] -* Update MonerisGateway to support merchant_data hash. Remove test_result_from_cc_number. [cody] -* Remove AVS Message and CVV2 Message from params hash in Authorize.net [cody] -* Update BrainTreeGateway to support merchant_data hash [cody] -* Update PaypalGateway to support merchant_data hash [cody] -* Update Payflow to support merchant_data hash [cody] -* Add card data to PayJunction response. PayJunction does not return the CVV or AVS result codes. Remote test_result_from_cc_number from PayJunction. [cody] -* Rename CCVResult to CVVResult to be more aligned with ActiveMerchant's usage of the term verification value [cody] -* Remove test_result_from_cc_number from Authorize.net in favour of mocking [cody] -* Add merchant_data hash, which contains all of the card_data, avs_result, and ccv_result. [cody] -* Add CCVResult for the Card Code Verification Result. Update Authorize.net to use the new class [cody] -* Rename AVSResult#match_type AVSResult#match [cody] -* Rename AVS::Result class to AVSResult [cody] -* Convert Authorize.net gateway to use the new AVS module [cody] -* Add AVS data to the Response object [cody] -* Fix credentials for remote Authorize.net TEST MODE test [cody] -* Add AVS module and AVS::Result class [cody] -* Update base gateway class RDOC [cody] -* Update the README with the latest list of supported gateways. Update the example in the README to include the verification value, which is now required by the credit card object by default. [cody] -* Handle the return from 2Checkout [cody] -* Automatically determine the credit card type when a type is not provided [cody] -* Revert to initial implementation of LUHN algorithm because it all fits in one simple method [cody] -* Remove unused api_cert_chain.crt file [cody] -* Update PaypalGateway, and PaypalExpressGateway to send requests to the correct endpoints when using API signatures [cody] -* Successful return code for HiTRUST is actually 00 [cody] -* Make ActiveMerchant::Billing::Error a subclass of ActiveMerchant::ActiveMerchantError [cody] -* Handle the return from the offsite payment gateways [cody] -* Default HiTRUST order description to "Store purchase" [cody] -* Fix HiTRUST field names [cody] -* Add support for passing in the locale code [georg.fr...@meandevel.com] -* Add support for the Offsite payment gateway HiTRUST [cody] -* Accept SuccessWithWarning as success [cody] -* Add a link to the LinkPoint staging server docs in remote_linkpoint_test.rb [cody] -* Update Discover regex [cody] -* Match full pan range of Maestro cards from 12 - 19 digits in length [cody] -* Fix errors on base of CreditCard [josh.bassett] -* Update product to use Rubigen instead of stolen Rails generator [cody] -* Mimic directory structure of unit tests in remote tests [cody] -* Restructure the location of the remote tests [cody] -* Ensure DataCash order_id is limited to 30 characters [cody] -* Return the pretty messages from PayJunction based on the return code [cody] -* make CreditCard.require_verification_value = true the default [cody] -* Use existing credit_card helper in credit card tests [cody] -* Return the authrorization number of the original transaction in the SkipJack gateway [cody] -* Update format of line items given to the gateway. Cleanup and uncomment unit tests [cody] -* Add support for the SkipJack gateway [Bill Bereza, cody] -* Make the bogus gateway easier to test by moving messages into constants [cody] -* Add retry logic when connection has been refused for all gateways. Enable safe retries of all connection failures with the PayflowGateway, as it has a unique request header. [cody] -* Catch Timeout::Error when posting data [cody] -* Change order of loading ActionPack for tests since assert_success defined in ActionController::Assertions::DeprecatedAssertions inteferes with ActiveMerchant's definition [cody] -* Catch Errno::ETIMEDOUT and extend open and read timeouts to 60 seconds [cody] -* Add address2 to the billing address of Viaklix transactions [cody] -* Improve Psigate generic error message [cody] -* Fix small errors in Psigate documentation [cody] -* Add Response#fraud_review? query method to the response. Allows gateways to indicate that a payment is pending review by the fraud service [cody] -* Handle Errno::ECONNRESET when posting data [cody] -* Fix broken USA ePay URL [cody] -* Update RequiresParameters to support HashWithIndifferentAccess [cody] -* Add support for SecurePayTech payment gateway [Jasper Bryant-Greene] -* Detect when test credentials are being used with PayJunction [cody] -* Update documentation about TrustCommerce void [cody] -* Add void to TrustCommerce [jesse.c.scott] -* Add support for echecks to the BrainTree gateway [Jeremy Voorhis] -* Fix before_validate and validate methods in CreditCard [rick.denatale] -* Add support for Netbilling payment gateway [cody] -* Pass in N/A for unknown states when a country is present in PaypalGateway [cody] -* Strip non alpha chars from order_id in Payflow gateway, as Paymentech Tampa can't handle them [cody] -* Add support for the PaySecure payment gateway [cody] -* Add support for descriptions in Authorize.net credits [shiva.kaul] -* Great cleanup and improvement of CreditCard code, tests, and docs [James Herdman] - -== Version 1.2.1 - -* Fix remote PayPal tests [cody] - -== Version 1.2.0 - -* Update Linkpoint tests to remove useless pem file [cody] -* Use symbols for CreditCard error messages, since errors have indifferent access [cody] -* Improve CreditCard error messages [George Ogata] -* Change deny to assert_false, and deny_success to assert_failure. Remove Gateway.gateway, as it is available from Base [cody] -* Improve documentation, and test coverage [James Herdman] -* Refactor MonerisGateway, improve test coverage and documentation [James Herdman] -* Add support for crediting to Moneris [James Herdman] -* Send state N/A in Payflow when the state is blank. Fixes UK PayPal Express payments when not providing a state [cody] -* Load remote test credentials from a fixtures file. ActiveMerchant will look for a custom file ~/.active_merchant/fixtures.yml. If the file exists it will be loaded instead of the default fixtures provided by ActiveMerchant. This makes development easier, and removes the risk of committing non-public test account credentials to subversion. [cody] -* Add support for password protected pem files [cody] -* Add support for Concord Efsnet payment gateway [snacktime] -* Fix dependency loading for gateways that are subclasses [cody] -* Add Braintree payment gateway [Michael J. Mangino] -* Add support for PayPal API signatures [Benjamin Curtis, cody] -* Add payment gateway Viaklix [Sal Scotto, cody] -* Add Australian payment gateway NetRegistry [George Ogata] -* Take order email from the options hash instead of the address for CyberSource [cody] -* Use an array for LineItems when calculating tax in CyberSource gateway [cody] -* Add CyberSource gateway [Matt Margolis] -* Sanitize Protx order id [cody] -* Fix support for electron in Protx [cody] -* Add support for Protx [shiftx, cody] -* Use undef_method with a single argument in SecurePay to prevent JRuby from choking on it. [jonathan.l.bartlett] -* Default address_override to 0 for PayPal Website Payments Standard payments. [cody] -* Enhance credit card error messages [manfred] -* Use HashWithIndifferentAccess for CreditCard for compatibility with Rails applications [michael.j.mangino] -* Fix nil exception when no response reason text is found in Authorize.net [cody] -* Add support for PayJunction [Matt Sanders] -* Change billing_address to shipping_address in PayPal Integration helper, as billing_address was incorrect. Addresses passed to billing_address for the PayPal helper will no longer be added to the form. This will break existing code, as the address will not be passed. -* Remove switch patterns from card detection that were eliminated on July 1, 2007 [cody] -* Format the issue number in Payflow requests to always be 2 digits [cody] -* Move application_id to Gateway and Helper class respectively [cody] -* Improve TrustCommerce documentation [cody] -* Add credit to Payflow [cody] -* Add support for the Plug 'N Pay gateway [ryan.norbauer, cody] -* Add support for ItemTotal, Shipping, Handling, and Tax amounts in the PayPal Express and PayPal gateways [baldwindavid, cody] -* Add page customization options to the PaypalExpress, and PayflowExpress gateways [ cpjolicoeur, cody] -* Add Verifi gateway [Paul Hepworth] -* Add a PayflowResponse object with a profile_id accessor method. Return the correct authorization number on recurring actions [cody] -* Add support for an initial transaction with recurring payments [findchris, cody] -* Add support for email receipts to recurring Payflow Payments [Rick Olson] -* Ensure the ButtonSource isn't too long [cody] -* Add ButtonSource to Paypal and PaypalExpress gateways [cody] -* Rename application to application_id and place it on Base, so it can be set once and forgotten about [cody] -* Add ButtonSource field to PayflowExpress gateway [cody] -* Add a field for the bn to the PayPal helper [cody] -* Add remote secure pay test and correctly define test? [cody] -* Undefine unsupported methods from SecurePay [cody] -* Enhance the TransFirst error message for declined transactions [cody] -* Add initial support for TransFirst gateway [cody] -* Deprecate certification_id in Payflow gateways [cody] -* Work around required PayPal state fields for countries that don't require states [cody] -* Add metadata to SecurePay gateway [cody] -* Add initial support for the SecurePay gateway using the Authorize.net translator [cody] -* Add the homepage_url and display_name accessors to each gateway [cody] -* Remove Money dependency from main gateways. Cleanup tests. Add supported_countries class accessor which returns an array of 2 digit iso country codes for which countries the gateway supports accounts in [cody] -* Add American Express card to Psigate [cody] -* Send N/A to PayPal in the PayPal Helper when we don't know the UK county [cody] -* Actually pass the amount of the capture through to Payflow [cody] -* Update ExactGateway test and test mode [cody] -* Remove unused method in PslCardGateway [cody] -* Add updated credit card tests [cody] -* Update and test PslCardGateway [cody] -* Add Laser card type [cody] -* Update Nochex documentation [cody] -* Sanitize the Realex order_id [cody] -* Add support for Irish Realex payment gateway [John Ward, cody] -* Move credit_card helper method to the test_helper [cody] -* Update PayflowExpressResponse to match the interface of the PayflowExpressResponse. Add :no_shipping and :address_override options to PayflowExpress [cody] -* Add a currency option to the Payflow and Paypal gateways [cody] -* PaypalExpress should use the shipping address, not the billing address [cody] -* Allow overriding the user with Payflow so that a vendor and user can be provided when making requests [cody] -* PayPal DirectPayment API requires a UK County to be sent as the state or province. Return N/A as the state when one isn't provided to ensure that PayPal doesn't reject the payment [cody] -* Add ability to perform reference transactions with Payflow [Al Evans, cody] -* Enhance recurring Payflow tests and recurring_inquiry [Al Evans] -* Add recurring payments to Payflow [Rick Olson] -* Improve the error message generated by requires! [cody] -* Update credit card regular expressions and update Quickpay gateway with tests for new cards [cody] -* Add support for token based payments to PaymentExpress [Nik Wakelin] -* Refactor default_currency to the base gateway class [cody] -* Clean unsupported characters from the Quickpay ordernum [cody] -* Call the :sale and :authorization in QuickpayGateway [cody] -* Add Danish gateway Quickpay [cody] -* Remove redundant hash brackets from generator template [cody] -* Add additional options to the PayPal Website Payments Standard Helper [Rick Olson] -* Move generate_unique_id method to Gateway class so other gateways can also use it [cody] -* Allow notification name / value pairs to have a . in the name like checkout.x = 400 [cody] -* Fix PaypalExpressGateway#purchase to have the same method signature as other gateways [cody] -* Cargo cult off the rails unique id generator instead of UUID library [cody] -* Add uuid-1.0.3 for generating random request UUIDs [cody] -* Remove mock_methods and http mock from the library [cody] -* PaypalExpress cannot setup a payment for 0 dollars. If the amount is zero then setup a payment for $1. [cody] -* Small changes to PslCard gateway [cody] -* Fix Money dependency with PslCard gateway [cody] -* Add PslCard payment gateway [MoneySpyder http://moneyspyder.co.uk] -* Scrub the card number, expiry, and CVV code from the response [cody] -* Use test? query for checking test mode [cody] -* Add support for the E-xact Payment Gateway [James Edward Gray II, cody] -* Fix partially broken method of dealing with phone numbers in the PayPal Helper [cody] -* Update remote tests for PaymentExpress [cody] -* Add Content-Type header to PaymentExpress post [cody] -* Use DECLINED as the message for declined transactions in the PaymentExpress remote tests [cody] -* Add JCB as a supported card type for the PaymentExpressGateway [cody] -* Rename DpsGateway to PaymentExpressGateway [cody] -* Add DPS Payment Express gateway (NZ) [dgjones, cody] -* Remove duplicate and incorrect expdate method from Authorize.net [cody] -* Allow authorization and purchase using a billing_id retrieved from TrustCommerce citadel [jesse.c.scott] -* Don't return a frozen string from CreditCard.type? [cody] -* Update remote Psigate test to ensure using a verification value doesn't break anything [cody] -* Update remote Moneris test to ensure using a verification value doesn't break anything [cody] -* Fix Solo issue number with CardStream gateway and improve test coverage [cody] -* Add CardStream gateway [Jonah Fox, Thomas Nichols, cody] -* Verify Peer in PayPal notifications and add account method [cody] - -== Version 1.1.0 - -* Add unique_id option to PayPal mass payments [Haig] -* Fix expiry date in USA ePay [cody] -* Fix PayPal Payments Pro UK with Switch & Solo cards [cody] -* Add reauthorization to PaypalGateway and PaypalExpressGateway [dorrenchen] -* Update DataCash tests and format merchant reference number to meet DataCash's requirements [MoneySpyder, cody] -* Add Datacash gateway [MoneySpyder, cody] -* VERIFY_PEER on all SSL requests [cody] -* Add support for 2Checkout [cody] - -== Version 1.0.3 - -* Add support for PayPal mass payments to the PaypalGateway and the PaypalExpressGateway [Brandon Keepers] -* Add a credit method to Authorize.net [cody] - -== Version 1.0.2 - -* Add support for OrderDescription, Payer, and InvoiceID fields in PaypalGateway [cody] - -== Version 1.0.1 - -* Add support for crediting to PayPal [cody, Haig] - -== Version 1.0.0 - -* Add discover to list of supported card types for Authorize.net -* Fix Psigate crediting [sean.alien8@gmail.com] -* Fix dependency loading of tests -* Add methods for storing credit cards to the Bogus gateway [Jim Kane] -* Fix bugs in expiration dates. [Jim Kane] -* Fixed bugs related to authorized.net [Rick Olson] -* Linkpoint is now a full featured backend for active merchant [Ryan Heneise] -* Added linkpoint support [Ryan Heneise] -* Added trust commerce gateway [Hans Friedrich] -* Removed shipping stuff until there is time to implement it properly -* The library now rejects money amounts which are not either cents as integer or a Money object -* Moneris now uses the same layout as the authorized.net plugin -* Added authorized.net -* Changed default to :test mode. Set to production with ActiveMerchant::Billing::Base.gateway_mode = :production -* More refactoring -* Refactored a bit so that there is space for billing and shipping area. None of the shipping aids are fleshed out yet. Needs more work. -* Added Moneris support -* Credit card in memory object resembling a AR object -* Credit card validation methods as static methods of the credit card object - -== PlanetArgon fork for integrating Merchant eSolutions gateway From 7a425467624984b018aa88dd3e8df7418053d14a Mon Sep 17 00:00:00 2001 From: dtykocki Date: Fri, 29 Sep 2017 06:29:03 -0400 Subject: [PATCH 199/677] WePay - Only send ip and device params for non-recurring transactions Per WePay's documentation, both `original_ip` and `original_device` are not valid arguments when calling `/credit_card/transfer`. These two params will now only be sent to `/credit_card/create` when storing a credit card. Also, the `verification_value` has been changed in remote tests to prevent a false positive failure in `test_transcript_scrubbing`. Closes #2597 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/wepay.rb | 4 ++-- test/remote/gateways/remote_wepay_test.rb | 10 +++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 422b32f0059..cd75c597eb3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * FirstData E4: Scrub 3DS cryptogram [jasonwebster] #2596 * PayHub: Replace single quotes with double quotes in error message [matthewheath] #2572 * Wirecard: Format non-fractional currency amounts correctly [bdewater] #2594 +* WePay: Only send ip and device for non-recurring transactions [dtykocki] #2597 == Version 1.72.0 (September 20, 2017) * Adyen: Fix failing remote tests [dtykocki] #2584 diff --git a/lib/active_merchant/billing/gateways/wepay.rb b/lib/active_merchant/billing/gateways/wepay.rb index d0102d0e664..b9cd338213a 100644 --- a/lib/active_merchant/billing/gateways/wepay.rb +++ b/lib/active_merchant/billing/gateways/wepay.rb @@ -84,8 +84,6 @@ def store(creditcard, options = {}) post[:cvv] = creditcard.verification_value unless options[:recurring] post[:expiration_month] = creditcard.month post[:expiration_year] = creditcard.year - post[:original_ip] = options[:ip] if options[:ip] - post[:original_device] = options[:device_fingerprint] if options[:device_fingerprint] if(billing_address = (options[:billing_address] || options[:address])) post[:address] = {} @@ -100,6 +98,8 @@ def store(creditcard, options = {}) post[:client_secret] = @options[:client_secret] commit('/credit_card/transfer', post, options) else + post[:original_device] = options[:device_fingerprint] if options[:device_fingerprint] + post[:original_ip] = options[:ip] if options[:ip] commit('/credit_card/create', post, options) end end diff --git a/test/remote/gateways/remote_wepay_test.rb b/test/remote/gateways/remote_wepay_test.rb index 0ec5963274c..c0a395b5d78 100644 --- a/test/remote/gateways/remote_wepay_test.rb +++ b/test/remote/gateways/remote_wepay_test.rb @@ -5,7 +5,7 @@ def setup @gateway = WepayGateway.new(fixtures(:wepay)) @amount = 2000 - @credit_card = credit_card('5496198584584769') + @credit_card = credit_card('5496198584584769', verification_value: '321') @declined_card = credit_card('') @options = { @@ -33,6 +33,14 @@ def test_successful_purchase_with_token assert_success response end + def test_successful_purchase_with_recurring_and_ip + store = @gateway.store(@credit_card, @options.merge(recurring: true, ip: '127.0.0.1')) + assert_success store + + response = @gateway.purchase(@amount, store.authorization, @options) + assert_success response + end + def test_successful_purchase_sans_cvv @options[:recurring] = true store = @gateway.store(@credit_card, @options) From 424fa8d613da6e720bfed005aa33f2b5dced5ca4 Mon Sep 17 00:00:00 2001 From: David Santoso Date: Fri, 29 Sep 2017 13:33:07 -0400 Subject: [PATCH 200/677] Barclaycard Smartpay: Use authorization pspReference for refunds Barclaycard Smartpay requires a `pspReference` from a previous authorization to be sent, not the `pspReference` from a subsequent capture. This updates the authorization field to be a concat of the authorization and capture `pspReference` values which will then be later split, and the first (authorization) `pspReference` will be used in the refund request. I should note that this fix is backwards compatible with the previous setup- non concated authorizations will still send the capture `pspReference`- however those transactions will still ultimately fail when refund settlements are attempted. Closes #2599 --- CHANGELOG | 3 +- .../billing/gateways/barclaycard_smartpay.rb | 15 +++++++-- .../remote_barclaycard_smartpay_test.rb | 5 +++ .../gateways/barclaycard_smartpay_test.rb | 31 +++++++++++++++++-- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cd75c597eb3..2b273cf7a45 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ = ActiveMerchant CHANGELOG == HEAD +* WePay: Only send ip and device for non-recurring transactions [dtykocki] #2597 +* Barclaycard Smartpay: Use authorization pspReference for refunds [davidsantoso] #2599 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 @@ -8,7 +10,6 @@ * FirstData E4: Scrub 3DS cryptogram [jasonwebster] #2596 * PayHub: Replace single quotes with double quotes in error message [matthewheath] #2572 * Wirecard: Format non-fractional currency amounts correctly [bdewater] #2594 -* WePay: Only send ip and device for non-recurring transactions [dtykocki] #2597 == Version 1.72.0 (September 20, 2017) * Adyen: Fix failing remote tests [dtykocki] #2584 diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index a95ef270e65..3d7cd3e2488 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -139,7 +139,7 @@ def commit(action, post) response, test: test?, avs_result: AVSResult.new(:code => parse_avs_code(response)), - authorization: response['recurringDetailReference'] || response['pspReference'] + authorization: response['recurringDetailReference'] || authorization_from(post, response) ) rescue ResponseError => e @@ -158,6 +158,13 @@ def commit(action, post) raise end + def authorization_from(parameters, response) + authorization = [parameters[:originalReference], response['pspReference']].compact + + return nil if authorization.empty? + return authorization.join("#") + end + def parse_avs_code(response) AVS_MAPPING[response["avsResult"][0..1].strip] if response["avsResult"] end @@ -259,10 +266,14 @@ def credit_card_hash(creditcard) def modification_request(reference, options) hash = {} hash[:merchantAccount] = @options[:merchant] - hash[:originalReference] = reference if reference + hash[:originalReference] = psp_reference_from(reference) hash.keep_if { |_, v| v } end + def psp_reference_from(authorization) + authorization.nil? ? nil : authorization.split("#").first + end + def payment_request(money, options) hash = {} hash[:merchantAccount] = @options[:merchant] diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index ec7c805f4bc..539c55abd30 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -3,6 +3,7 @@ class RemoteBarclaycardSmartpayTest < Test::Unit::TestCase def setup @gateway = BarclaycardSmartpayGateway.new(fixtures(:barclaycard_smartpay)) + BarclaycardSmartpayGateway.ssl_strict = false @amount = 100 @credit_card = credit_card('4111111111111111', :month => 8, :year => 2018, :verification_value => 737) @@ -42,6 +43,10 @@ def setup }) end + def teardown + BarclaycardSmartpayGateway.ssl_strict = true + end + def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb index e7f93a0950c..ad074938ed9 100644 --- a/test/unit/gateways/barclaycard_smartpay_test.rb +++ b/test/unit/gateways/barclaycard_smartpay_test.rb @@ -31,6 +31,16 @@ def setup }) end + def test_successful_purchase + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.respond_with(successful_authorize_response, successful_capture_response) + + assert_success response + assert_equal '7914002629995504#8814002632606717', response.authorization + assert response.test? + end + def test_successful_authorize @gateway.stubs(:ssl_post).returns(successful_authorize_response) @@ -53,6 +63,7 @@ def test_successful_capture response = @gateway.capture(@amount, '7914002629995504', @options) assert_success response + assert_equal '7914002629995504#8814002632606717', response.authorization assert response.test? end @@ -64,13 +75,27 @@ def test_failed_capture assert response.test? end - def test_successful_refund - @gateway.expects(:ssl_post).returns(successful_refund_response) + 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| + assert_match(/originalReference=8814002632606717/, data) + end.respond_with(successful_refund_response) - response = @gateway.refund(@amount, '7914002629995504', @options) assert_success response assert response.test? + end + + def test_successful_refund + response = stub_comms do + @gateway.refund(@amount, '7914002629995504#8814002632606717', @options) + end.check_request do |endpoint, data, headers| + assert_match(/originalReference=7914002629995504&/, data) + assert_no_match(/8814002632606717/, data) + end.respond_with(successful_refund_response) + assert_success response + assert response.test? end def test_failed_refund From e1209b7c119a4ce81a96c0cc53f16572ec343744 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Tue, 3 Oct 2017 04:05:44 -0400 Subject: [PATCH 201/677] Adyen: Update list of support countries Closes #2600 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 2b273cf7a45..68767bb6176 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * WePay: Only send ip and device for non-recurring transactions [dtykocki] #2597 * Barclaycard Smartpay: Use authorization pspReference for refunds [davidsantoso] #2599 +* Adyen: Update list of supported countries [dtykocki] #2600 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index 3e9248283f2..8671328664d 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -7,7 +7,7 @@ class AdyenGateway < Gateway self.test_url = 'https://pal-test.adyen.com/pal/servlet/Payment/v18' self.live_url = 'https://pal-live.adyen.com/pal/servlet/Payment/v18' - self.supported_countries = ['AD','AE','AF','AG','AI','AL','AM','AO','AQ','AR','AS','AT','AU','AW','AX','AZ','BA','BB','BD','BE','BF','BG','BH','BI','BJ','BL','BM','BN','BO','BQ','BR','BS','BT','BV','BW','BY','BZ','CA','CC','CD','CF','CG','CH','CI','CK','CL','CM','CN','CO','CR','CU','CV','CW','CX','CY','CZ','DE','DJ','DK','DM','DO','DZ','EC','EE','EG','EH','ER','ES','ET','FI','FJ','FK','FM','FO','FR','GA','GB','GD','GE','GF','GG','GH','GI','GL','GM','GN','GP','GQ','GR','GS','GT','GU','GW','GY','HK','HM','HN','HR','HT','HU','ID','IE','IL','IM','IN','IO','IQ','IR','IS','IT','JE','JM','JO','JP','KE','KG','KH','KI','KM','KN','KP','KR','KW','KY','KZ','LA','LB','LC','LI','LK','LR','LS','LT','LU','LV','LY','MA','MC','MD','ME','MF','MG','MH','MK','ML','MM','MN','MO','MP','MQ','MR','MS','MT','MU','MV','MW','MX','MY','MZ','NA','NC','NE','NF','NG','NI','NL','NO','NP','NR','NU','NZ','OM','PA','PE','PF','PG','PH','PK','PL','PM','PN','PR','PS','PT','PW','PY','QA','RE','RO','RS','RU','RW','SA','SB','SC','SD','SE','SG','SH','SI','SJ','SK','SL','SM','SN','SO','SR','SS','ST','SV','SX','SY','SZ','TC','TD','TF','TG','TH','TJ','TK','TL','TM','TN','TO','TR','TT','TV','TW','TZ','UA','UG','UM','US','UY','UZ','VA','VC','VE','VG','VI','VN','VU','WF','WS','YE','YT','ZA','ZM','ZW'] + self.supported_countries = ['AT','AU','BE','BG','BR','CH','CY','CZ','DE','DK','EE','ES','FI','FR','GB','GI','GR','HK','HU','IE','IS','IT','LI','LT','LU','LV','MC','MT','MX','NL','NO','PL','PT','RO','SE','SG','SK','SI','US'] self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb, :dankort, :maestro, :discover] From 81e4648766f9397b86b86beb8fe8c0cff1d9c419 Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 26 Sep 2017 16:52:40 -0400 Subject: [PATCH 202/677] Credorax: Update response codes Credorax has changed their response code messages. This also updates test card values and remote tests. Closes #2595 Remote: 18 tests, 51 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 17 tests, 83 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/credorax.rb | 94 +++++++++++-------- test/remote/gateways/remote_credorax_test.rb | 34 ++++--- 3 files changed, 72 insertions(+), 57 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 68767bb6176..6a69296e224 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * WePay: Only send ip and device for non-recurring transactions [dtykocki] #2597 * Barclaycard Smartpay: Use authorization pspReference for refunds [davidsantoso] #2599 * Adyen: Update list of supported countries [dtykocki] #2600 +* Credorax: Update response codes [curiousepic] #2595 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb index 61e4b95196d..a97ea6195fd 100644 --- a/lib/active_merchant/billing/gateways/credorax.rb +++ b/lib/active_merchant/billing/gateways/credorax.rb @@ -30,71 +30,87 @@ class CredoraxGateway < Gateway "03" => "Invalid merchant", "04" => "Pick up card", "05" => "Do not Honour", - "06" => "Invalid Transaction for Terminal", + "06" => "Error", "07" => "Pick up card special condition", - "08" => "Time-Out", - "09" => "No Original", + "08" => "Honour with identification", + "09" => "Request in progress", "10" => "Approved for partial amount", - "11" => "Partial Approval", - "12" => "Invalid transaction card / issuer / acquirer", + "11" => "Approved (VIP)", + "12" => "Invalid transaction", "13" => "Invalid amount", "14" => "Invalid card number", - "17" => "Invalid Capture date (terminal business date)", - "19" => "System Error; Re-enter transaction", - "20" => "No From Account", - "21" => "No To Account", - "22" => "No Checking Account", - "23" => "No Saving Account", - "24" => "No Credit Account", + "15" => "No such issuer", + "16" => "Approved, update track 3", + "17" => "Customer cancellation", + "18" => "Customer dispute", + "19" => "Re-enter transaction", + "20" => "Invalid response", + "21" => "No action taken", + "22" => "Suspected malfunction", + "23" => "Unacceptable transaction fee", + "24" => "File update not supported by receiver", + "25" => "No such record", + "26" => "Duplicate record update, old record replaced", + "27" => "File update field edit error", + "28" => "File locked out while update", + "29" => "File update error, contact acquirer", "30" => "Format error", - "34" => "Implausible card data", + "31" => "Issuer signed-off", + "32" => "Completed partially", + "33" => "Pick-up, expired card", + "34" => "Suspect Fraud", + "35" => "Pick-up, card acceptor contact acquirer", + "36" => "Pick up, card restricted", + "37" => "Pick up, call acquirer security", + "38" => "Pick up, Allowable PIN tries exceeded", "39" => "Transaction Not Allowed", + "40" => "Requested function not supported", "41" => "Lost Card, Pickup", - "42" => "Special Pickup", - "43" => "Hot Card, Pickup (if possible)", - "44" => "Pickup Card", + "42" => "No universal account", + "43" => "Pick up, stolen card", + "44" => "No investment account", + "50" => "Do not renew", "51" => "Not sufficient funds", "52" => "No checking Account", "53" => "No savings account", "54" => "Expired card", "55" => "Pin incorrect", + "56" => "No card record", "57" => "Transaction not allowed for cardholder", "58" => "Transaction not allowed for merchant", "59" => "Suspected Fraud", + "60" => "Card acceptor contact acquirer", "61" => "Exceeds withdrawal amount limit", "62" => "Restricted card", - "63" => "MAC Key Error", + "63" => "Security violation", + "64" => "Wrong original amount", "65" => "Activity count limit exceeded", - "66" => "Exceeds Acquirer Limit", - "67" => "Retain Card; no reason specified", - "68" => "Response received too late", + "66" => "Call acquirers security department", + "67" => "Card to be picked up at ATM", + "68" => "Response received too late.", + "70" => "Invalid transaction; contact card issuer", + "71" => "Decline PIN not changed", "75" => "Pin tries exceeded", - "76" => "Invalid Account", - "77" => "Issuer Does Not Participate In The Service", - "78" => "Function Not Available", - "79" => "Key Validation Error", - "80" => "Approval for Purchase Amount Only", - "81" => "Unable to Verify PIN", + "76" => "Wrong PIN, number of PIN tries exceeded", + "77" => "Wrong Reference No.", + "78" => "Record Not Found", + "79" => "Already reversed", + "80" => "Network error", + "81" => "Foreign network error / PIN cryptographic error", "82" => "Time out at issuer system", - "83" => "Not declined (Valid for all zero amount transactions)", - "84" => "Invalid Life Cycle of transaction", - "85" => "Not declined", + "83" => "Transaction failed", + "84" => "Pre-authorization timed out", + "85" => "No reason to decline", "86" => "Cannot verify pin", "87" => "Purchase amount only, no cashback allowed", "88" => "MAC sync Error", - "89" => "Security Violation", + "89" => "Authentication failure", "91" => "Issuer not available", "92" => "Unable to route at acquirer Module", - "93" => "Transaction cannot be completed", - "94" => "Duplicate transaction", - "95" => "Contact Acquirer", + "93" => "Cannot be completed, violation of law", + "94" => "Duplicate Transmission", + "95" => "Reconcile error / Auth Not found", "96" => "System malfunction", - "97" => "No Funds Transfer", - "98" => "Duplicate Reversal", - "99" => "Duplicate Transaction", - "N3" => "Cash Service Not Available", - "N4" => "Cash Back Request Exceeds Issuer Limit", - "N7" => "N7 (visa), Decline CVV2 failure", "R0" => "Stop Payment Order", "R1" => "Revocation of Authorisation Order", "R3" => "Revocation of all Authorisations Order" diff --git a/test/remote/gateways/remote_credorax_test.rb b/test/remote/gateways/remote_credorax_test.rb index 6f4927cc6f4..89432952a6b 100644 --- a/test/remote/gateways/remote_credorax_test.rb +++ b/test/remote/gateways/remote_credorax_test.rb @@ -5,8 +5,8 @@ def setup @gateway = CredoraxGateway.new(fixtures(:credorax)) @amount = 100 - @credit_card = credit_card('5223450000000007', verification_value: "090", month: "12", year: "2025") - @declined_card = credit_card('4000300011112220') + @credit_card = credit_card('4176661000001015', verification_value: "281", month: "12", year: "2017") + @declined_card = credit_card('4176661000001015', verification_value: "000", month: "12", year: "2017") @options = { order_id: "1", currency: "EUR", @@ -31,7 +31,7 @@ def test_successful_purchase def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message + assert_equal "Do not Honour", response.message end def test_successful_authorize_and_capture @@ -48,15 +48,16 @@ def test_successful_authorize_and_capture def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message - assert_equal "05", response.params["Z2"] + assert_equal "Do not Honour", response.message end def test_failed_capture - response = @gateway.capture(@amount, "") - assert_failure response - assert_equal "2. At least one of input parameters is malformed.: Parameter [g4] cannot be empty.", response.message - assert_equal "-9", response.params["Z2"] + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + capture = @gateway.capture(0, auth.authorization) + assert_failure capture + assert_equal "Invalid amount", capture.message end def test_successful_purchase_and_void @@ -95,8 +96,7 @@ def test_successful_capture_and_void def test_failed_void response = @gateway.void("") assert_failure response - assert_equal "2. At least one of input parameters is malformed.: Parameter [g4] cannot be empty.", response.message - assert_equal "-9", response.params["Z2"] + assert_equal "Internal server error. Please contact Credorax support.", response.message end def test_successful_refund @@ -122,10 +122,9 @@ def test_successful_refund_and_void end def test_failed_refund - response = @gateway.refund(nil, "") + response = @gateway.refund(nil, "123;123;123") assert_failure response - assert_equal "2. At least one of input parameters is malformed.: Parameter [g4] cannot be empty.", response.message - assert_equal "-9", response.params["Z2"] + assert_equal "Internal server error. Please contact Credorax support.", response.message end def test_successful_credit @@ -135,9 +134,9 @@ def test_successful_credit end def test_failed_credit - response = @gateway.credit(@amount, @declined_card, @options) + response = @gateway.credit(0, @declined_card, @options) assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message + assert_equal "Invalid amount", response.message end def test_successful_verify @@ -149,8 +148,7 @@ def test_successful_verify def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message - assert_equal "05", response.params["Z2"] + assert_equal "Do not Honour", response.message end def test_transcript_scrubbing From 53f5f25e3a4a041fb83802c19462e7be4b3b7573 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Tue, 3 Oct 2017 09:18:30 -0400 Subject: [PATCH 203/677] Borgun: Add support for USD and localized currency Closes #2602 --- CHANGELOG | 1 + .../billing/gateways/borgun.rb | 3 +- test/remote/gateways/remote_borgun_test.rb | 37 ++++++++++++++++++- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6a69296e224..683b328de18 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Barclaycard Smartpay: Use authorization pspReference for refunds [davidsantoso] #2599 * Adyen: Update list of supported countries [dtykocki] #2600 * Credorax: Update response codes [curiousepic] #2595 +* Borgun: Add support for USD transactions [dtykocki] #2602 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb index ff329fb4b2c..ec61fa40b18 100644 --- a/lib/active_merchant/billing/gateways/borgun.rb +++ b/lib/active_merchant/billing/gateways/borgun.rb @@ -26,7 +26,6 @@ def purchase(money, payment, options={}) post[:TransType] = '1' add_invoice(post, money, options) add_payment_method(post, payment) - commit('sale', post) end @@ -35,7 +34,6 @@ def authorize(money, payment, options={}) post[:TransType] = '5' add_invoice(post, money, options) add_payment_method(post, payment) - commit('authonly', post) end @@ -80,6 +78,7 @@ def scrub(transcript) CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")} CURRENCY_CODES["ISK"] = "352" CURRENCY_CODES["EUR"] = "978" + CURRENCY_CODES["USD"] = "840" def add_invoice(post, money, options) post[:TrAmount] = amount(money) diff --git a/test/remote/gateways/remote_borgun_test.rb b/test/remote/gateways/remote_borgun_test.rb index 1d41f1f8b99..3e58a5b7b90 100644 --- a/test/remote/gateways/remote_borgun_test.rb +++ b/test/remote/gateways/remote_borgun_test.rb @@ -8,7 +8,7 @@ def setup @gateway = BorgunGateway.new(fixtures(:borgun)) @amount = 100 - @credit_card = credit_card('5587402000012011', year: 2014, month: 9, verification_value: 415) + @credit_card = credit_card('5587402000012011', year: 2018, month: 9, verification_value: 415) @declined_card = credit_card('4155520000000002') @options = { @@ -28,6 +28,12 @@ def test_successful_purchase assert_equal 'Succeeded', response.message end + def test_successful_purchase_usd + response = @gateway.purchase(@amount, @credit_card, @options.merge(currency: "USD")) + assert_success response + assert_equal 'Succeeded', response.message + end + def test_successful_purchase_without_options response = @gateway.purchase(@amount, @credit_card) assert_success response @@ -48,6 +54,14 @@ def test_successful_authorize_and_capture assert_success capture end + def test_successful_authorize_and_capture_usd + auth = @gateway.authorize(@amount, @credit_card, @options.merge(currency: 'USD')) + assert_success auth + + assert capture = @gateway.capture(@amount, auth.authorization, currency: 'USD') + assert_success capture + end + def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response @@ -74,6 +88,14 @@ def test_successful_refund assert_success refund end + def test_successful_refund_usd + purchase = @gateway.purchase(@amount, @credit_card, @options.merge(currency: 'USD')) + assert_success purchase + + assert refund = @gateway.refund(@amount, purchase.authorization, currency: 'USD') + assert_success refund + end + def test_partial_refund purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase @@ -95,11 +117,22 @@ def test_successful_void assert_success void end + def test_successful_void_usd + auth = @gateway.authorize(@amount, @credit_card, @options.merge(currency: 'USD')) + assert_success auth + + assert void = @gateway.void(auth.authorization, currency: 'USD') + assert_success void + end + def test_failed_void response = @gateway.void('') assert_failure response end + # This test does not consistently pass. When run multiple times within 1 minute, + # an ActiveMerchant::ConnectionError() + # exception is raised. def test_invalid_login gateway = BorgunGateway.new( processor: '0', @@ -107,7 +140,7 @@ def test_invalid_login username: 'not', password: 'right' ) - authentication_exception = assert_raise ActiveMerchant::ResponseError, 'Failed with 500 Internal Server Error' do + authentication_exception = assert_raise ActiveMerchant::ResponseError, 'Failed with 401 [ISS.0084.9001] Invalid credentials' do gateway.purchase(@amount, @credit_card, @options) end assert response = authentication_exception.response From 65d886787c1c1935220f54acd6ef81ff76016b25 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Wed, 4 Oct 2017 08:55:08 -0400 Subject: [PATCH 204/677] Borgun: Include currency code from split authorization When performing a void transaction on Borgun, the currency code must match the original currency code used on the authorization. Because of this, the adapter will now store the original currency code in the authorization and include it when void is called. Closes #2605 --- CHANGELOG | 1 + .../billing/gateways/borgun.rb | 14 ++++++++------ test/remote/gateways/remote_borgun_test.rb | 19 ++++++++++++++++++- test/unit/gateways/borgun_test.rb | 8 ++++---- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 683b328de18..058ea154459 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * Adyen: Update list of supported countries [dtykocki] #2600 * Credorax: Update response codes [curiousepic] #2595 * Borgun: Add support for USD transactions [dtykocki] #2602 +* Borgun: Include currency code from split authorization for voids [dtykocki] #2605 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb index ec61fa40b18..6544c786f50 100644 --- a/lib/active_merchant/billing/gateways/borgun.rb +++ b/lib/active_merchant/billing/gateways/borgun.rb @@ -55,9 +55,10 @@ def refund(money, authorization, options={}) def void(authorization, options={}) post = {} - # TransType and TrAmount must match original values from auth or purchase. - _, _, _, _, _, transtype, tramount = split_authorization(authorization) + # TransType, TrAmount, and currency must match original values from auth or purchase. + _, _, _, _, _, transtype, tramount, currency = split_authorization(authorization) post[:TransType] = transtype + options[:currency] = options[:currency] || CURRENCY_CODES.key(currency) add_invoice(post, tramount.to_i, options) add_reference(post, authorization) commit('void', post) @@ -94,7 +95,7 @@ def add_payment_method(post, payment_method) end def add_reference(post, authorization) - dateandtime, batch, transaction, rrn, authcode, _, _ = split_authorization(authorization) + dateandtime, batch, transaction, rrn, authcode, _, _, _ = split_authorization(authorization) post[:DateAndTime] = dateandtime post[:Batch] = batch post[:Transaction] = transaction @@ -165,13 +166,14 @@ def authorization_from(response) response[:rrn], response[:authcode], response[:transtype], - response[:tramount] + response[:tramount], + response[:trcurrency] ].join("|") end def split_authorization(authorization) - dateandtime, batch, transaction, rrn, authcode, transtype, tramount = authorization.split("|") - [dateandtime, batch, transaction, rrn, authcode, transtype, tramount] + dateandtime, batch, transaction, rrn, authcode, transtype, tramount, currency = authorization.split("|") + [dateandtime, batch, transaction, rrn, authcode, transtype, tramount, currency] end def headers diff --git a/test/remote/gateways/remote_borgun_test.rb b/test/remote/gateways/remote_borgun_test.rb index 3e58a5b7b90..02310810865 100644 --- a/test/remote/gateways/remote_borgun_test.rb +++ b/test/remote/gateways/remote_borgun_test.rb @@ -117,11 +117,28 @@ def test_successful_void assert_success void end + def test_successful_void_with_no_currency_in_authorization + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + *new_auth, _ = auth.authorization.split("|") + assert void = @gateway.void(new_auth.join("|")) + assert_success void + end + def test_successful_void_usd auth = @gateway.authorize(@amount, @credit_card, @options.merge(currency: 'USD')) assert_success auth - assert void = @gateway.void(auth.authorization, currency: 'USD') + assert void = @gateway.void(auth.authorization) + assert_success void + end + + def test_successful_void_usd_with_options + auth = @gateway.authorize(@amount, @credit_card, @options.merge(currency: 'USD')) + assert_success auth + + assert void = @gateway.void(auth.authorization, @options.merge(currency: 'USD')) assert_success void end diff --git a/test/unit/gateways/borgun_test.rb b/test/unit/gateways/borgun_test.rb index 79d7c635a4d..b7694e7adf1 100644 --- a/test/unit/gateways/borgun_test.rb +++ b/test/unit/gateways/borgun_test.rb @@ -27,7 +27,7 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "140216103700|11|15|WC0000000001|123456|1|000000012300", response.authorization + assert_equal "140216103700|11|15|WC0000000001|123456|1|000000012300|978", response.authorization assert response.test? end @@ -44,7 +44,7 @@ def test_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "140601083732|11|18|WC0000000001|123456|5|000000012300", response.authorization + assert_equal "140601083732|11|18|WC0000000001|123456|5|000000012300|978", response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -61,7 +61,7 @@ def test_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "140216103700|11|15|WC0000000001|123456|1|000000012300", response.authorization + assert_equal "140216103700|11|15|WC0000000001|123456|1|000000012300|978", response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -78,7 +78,7 @@ def test_void end.respond_with(successful_purchase_response) assert_success response - assert_equal "140216103700|11|15|WC0000000001|123456|1|000000012300", response.authorization + assert_equal "140216103700|11|15|WC0000000001|123456|1|000000012300|978", response.authorization refund = stub_comms do @gateway.void(response.authorization) From 99dce318b109266eaf72356f8db32dda71423d3a Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 19 Sep 2017 15:23:50 -0400 Subject: [PATCH 205/677] Ebanx: Support Store and person_type option Adds Store support. The "responsible" element is now only added when it is required, for transactions in Brazil with a person_type of "business". Store also passes "country" from options, as it is required. Four negative test cases are failing due to changes to test card numbers we have yet to receive an update for. Closes #2604 Remote: 18 tests, 46 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 77.7778% passed Unit: 15 tests, 51 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/ebanx.rb | 81 ++++++++++++++----- test/remote/gateways/remote_ebanx_test.rb | 35 +++++--- test/unit/gateways/ebanx_test.rb | 25 ++++++ 4 files changed, 113 insertions(+), 29 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 058ea154459..3c544d40a36 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * Credorax: Update response codes [curiousepic] #2595 * Borgun: Add support for USD transactions [dtykocki] #2602 * Borgun: Include currency code from split authorization for voids [dtykocki] #2605 +* Ebanx: Support Store and person_type option [curiousepic] #2604 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb index 6b958bb5580..7c8af708397 100644 --- a/lib/active_merchant/billing/gateways/ebanx.rb +++ b/lib/active_merchant/billing/gateways/ebanx.rb @@ -24,7 +24,8 @@ class EbanxGateway < Gateway authorize: "direct", capture: "capture", refund: "refund", - void: "cancel" + void: "cancel", + store: "token" } HTTP_METHOD = { @@ -32,7 +33,8 @@ class EbanxGateway < Gateway authorize: :post, capture: :get, refund: :post, - void: :get + void: :get, + store: :post } def initialize(options={}) @@ -46,9 +48,10 @@ def purchase(money, payment, options={}) add_operation(post) add_invoice(post, money, options) add_customer_data(post, payment, options) - add_payment(post, payment) + add_card_or_token(post, payment) add_address(post, options) - add_customer_responsible_person(post, payment, options) if post[:payment][:country] == 'BR' + add_customer_responsible_person(post, payment, options) + commit(:purchase, post) end @@ -58,9 +61,9 @@ def authorize(money, payment, options={}) add_operation(post) add_invoice(post, money, options) add_customer_data(post, payment, options) - add_payment(post, payment) + add_card_or_token(post, payment) add_address(post, options) - add_customer_responsible_person(post, payment, options) if post[:payment][:country] == 'BR' + add_customer_responsible_person(post, payment, options) post[:payment][:creditcard][:auto_capture] = false commit(:authorize, post) @@ -94,6 +97,15 @@ def void(authorization, options={}) commit(:void, post) end + def store(credit_card, options={}) + post = {} + add_integration_key(post) + add_payment_details(post, credit_card) + post[:country] = customer_country(options) + + commit(:store, post) + end + def verify(credit_card, options={}) MultiResponse.run(:use_first_response) do |r| r.process { authorize(100, credit_card, options) } @@ -127,13 +139,14 @@ def add_authorization(post, authorization) end def add_customer_data(post, payment, options) - post[:payment][:name] = payment.name + post[:payment][:name] = payment.is_a?(String) ? "Not Provided" : payment.name post[:payment][:email] = options[:email] || "unspecified@example.com" post[:payment][:document] = options[:document] post[:payment][:birth_date] = options[:birth_date] if options[:birth_date] end - def add_customer_responsible_person(post, payment, options) + def add_customer_responsible_person(post, payment, options) + return unless (options[:person_type] && options[:person_type].downcase == 'business') && customer_country(options) == 'br' post[:payment][:responsible] = {} post[:payment][:responsible][:name] = payment.name post[:payment][:responsible][:document] = options[:document] @@ -147,7 +160,7 @@ def add_address(post, options) post[:payment][:city] = address[:city] post[:payment][:state] = address[:state] post[:payment][:zipcode] = address[:zip] - post[:payment][:country] = address[:country] + post[:payment][:country] = address[:country].downcase post[:payment][:phone_number] = address[:phone] end end @@ -159,14 +172,30 @@ def add_invoice(post, money, options) post[:payment][:instalments] = options[:instalments] || 1 end - def add_payment(post, payment) - post[:payment][:payment_type_code] = CARD_BRAND[payment.brand.to_sym] - post[:payment][:creditcard] = { - card_number: payment.number, - card_name: payment.name, - card_due_date: "#{payment.month}/#{payment.year}", - card_cvv: payment.verification_value - } + def add_card_or_token(post, payment) + if payment.is_a?(String) + payment, brand = payment.split("|") + end + post[:payment][:payment_type_code] = payment.is_a?(String) ? brand : CARD_BRAND[payment.brand.to_sym] + post[:payment][:creditcard] = payment_details(payment) + end + + def add_payment_details(post, payment) + post[:payment_type_code] = CARD_BRAND[payment.brand.to_sym] + post[:creditcard] = payment_details(payment) + end + + def payment_details(payment) + if payment.is_a?(String) + { token: payment } + else + { + card_number: payment.number, + card_name: payment.name, + card_due_date: "#{payment.month}/#{payment.year}", + card_cvv: payment.verification_value + } + end end def parse(body) @@ -183,7 +212,7 @@ def commit(action, parameters) success, message_from(response), response, - authorization: authorization_from(response), + authorization: authorization_from(action, parameters, response), test: test?, error_code: error_code_from(response, success) ) @@ -196,6 +225,8 @@ def success_from(action, response) response.try(:[], "payment").try(:[], "status") == "PE" elsif action == :void response.try(:[], "payment").try(:[], "status") == "CA" + elsif action == :store + response.try(:[], "status") == "SUCCESS" else false end @@ -206,8 +237,12 @@ def message_from(response) response.try(:[], "payment").try(:[], "transaction_status").try(:[], "description") end - def authorization_from(response) - response.try(:[], "payment").try(:[], "hash") + def authorization_from(action, parameters, response) + if action == :store + response.try(:[], "token") + "|" + CARD_BRAND[parameters[:payment_type_code].to_sym] + else + response.try(:[], "payment").try(:[], "hash") + end end def post_data(action, parameters = {}) @@ -239,6 +274,12 @@ def error_code_from(response, success) response.try(:[], "payment").try(:[], "transaction_status").try(:[], "code") end end + + def customer_country(options) + if country = options[:country] || (options[:billing_address][:country] if options[:billing_address]) + country.downcase + end + end end end end diff --git a/test/remote/gateways/remote_ebanx_test.rb b/test/remote/gateways/remote_ebanx_test.rb index 976e512dbb4..87e9ecd19cd 100644 --- a/test/remote/gateways/remote_ebanx_test.rb +++ b/test/remote/gateways/remote_ebanx_test.rb @@ -6,7 +6,7 @@ def setup @amount = 100 @credit_card = credit_card('4111111111111111') - @declined_card = credit_card('4716909774636285') + @declined_card = credit_card('5102026827345142') @options = { billing_address: address({ address1: '1040 Rua E', @@ -24,7 +24,7 @@ def setup def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal 'Sandbox - Test credit card, transaction captured', response.message + assert_equal 'Accepted', response.message end def test_successful_purchase_with_more_options @@ -37,7 +37,7 @@ def test_successful_purchase_with_more_options response = @gateway.purchase(@amount, @credit_card, options) assert_success response - assert_equal 'Sandbox - Test credit card, transaction captured', response.message + assert_equal 'Accepted', response.message end def test_failed_purchase @@ -50,11 +50,11 @@ def test_failed_purchase def test_successful_authorize_and_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert_equal 'Sandbox - Test credit card, transaction will be approved', auth.message + assert_equal 'Accepted', auth.message assert capture = @gateway.capture(@amount, auth.authorization) assert_success capture - assert_equal 'Sandbox - Test credit card, transaction captured', capture.message + assert_equal 'Accepted', capture.message end def test_failed_authorize @@ -85,7 +85,7 @@ def test_successful_refund refund_options = @options.merge({description: "full refund"}) assert refund = @gateway.refund(@amount, purchase.authorization, refund_options) assert_success refund - assert_equal 'Sandbox - Test credit card, transaction captured', refund.message + assert_equal 'Accepted', refund.message end def test_partial_refund @@ -109,7 +109,7 @@ def test_successful_void assert void = @gateway.void(auth.authorization) assert_success void - assert_equal 'Sandbox - Test credit card, transaction cancelled', void.message + assert_equal 'Accepted', void.message end def test_failed_void @@ -118,16 +118,33 @@ def test_failed_void assert_equal 'Parameter hash not informed', response.message end + def test_successful_store_and_purchase + store = @gateway.store(@credit_card, @options) + assert_success store + + assert purchase = @gateway.purchase(@amount, store.authorization, @options) + assert_success purchase + assert_equal 'Accepted', purchase.message + end + + def test_failed_purchase_with_stored_card + store = @gateway.store(@declined_card, @options) + assert_success store + + assert purchase = @gateway.purchase(@amount, store.authorization, @options) + assert_failure purchase + end + def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_match %r{Sandbox - Test credit card, transaction will be approved}, response.message + assert_match %r{Accepted}, response.message end def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_match %r{Sandbox - Test credit card, transaction declined reason insufficientFunds}, response.message + assert_match %r{Accepted}, response.message end def test_invalid_login diff --git a/test/unit/gateways/ebanx_test.rb b/test/unit/gateways/ebanx_test.rb index 35cf38cec91..76e565fe46f 100644 --- a/test/unit/gateways/ebanx_test.rb +++ b/test/unit/gateways/ebanx_test.rb @@ -127,6 +127,19 @@ def test_failed_verify assert_equal "NOK", response.error_code end + def test_successful_store_and_purchase + @gateway.expects(:ssl_request).returns(successful_store_response) + + store = @gateway.store(@credit_card, @options) + assert_success store + assert_equal 'a61a7c98535718801395991b5112f888d359c2d632e2c3bb8afe75aa23f3334d7fd8dc57d7721f8162503773063de59ee85901b5714a92338c6d9c0352aee78c|visa', store.authorization + + @gateway.expects(:ssl_request).returns(successful_purchase_with_stored_card_response) + + response = @gateway.purchase(@amount, store.authorization, @options) + assert_success response + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed @@ -205,4 +218,16 @@ def failed_void_response {"status":"ERROR","status_code":"BP-CAN-1","status_message":"Parameter hash not informed"} ) end + + def successful_store_response + %( + {"status":"SUCCESS","payment_type_code":"visa","token":"a61a7c98535718801395991b5112f888d359c2d632e2c3bb8afe75aa23f3334d7fd8dc57d7721f8162503773063de59ee85901b5714a92338c6d9c0352aee78c","masked_card_number":"411111xxxxxx1111"} + ) + end + + def successful_purchase_with_stored_card_response + %( + {"payment":{"hash":"59d3e2955021c5e2b180e1ea9670e2d9675c15453a2ab346","pin":"252076123","merchant_payment_code":"a942f8a68836e888fa8e8af1e8ca4bf2","order_number":null,"status":"CO","status_date":"2017-10-03 19:18:45","open_date":"2017-10-03 19:18:44","confirm_date":"2017-10-03 19:18:45","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-10-06","instalments":"1","payment_type_code":"visa","details":{"billing_descriptor":""},"transaction_status":{"acquirer":"EBANX","code":"OK","description":"Accepted"},"pre_approved":true,"capture_available":false,"customer":{"document":"85351346893","email":"unspecified@example.com","name":"NOT PROVIDED","birth_date":null}},"status":"SUCCESS"} + ) + end end From a7eba217795ef76e064de5cff71a14de9299e9f4 Mon Sep 17 00:00:00 2001 From: David Perry Date: Fri, 6 Oct 2017 11:35:13 -0400 Subject: [PATCH 206/677] Elavon: Update endpoint URLs Elavon/Converge is updating their endpoint URLS as per https://www.besha2ready.com/converge Closes #2608 Remote: 23 tests, 102 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 28 tests, 138 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/elavon.rb | 4 ++-- test/fixtures.yml | 7 ++++--- test/remote/gateways/remote_elavon_test.rb | 3 +-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3c544d40a36..931269fcf51 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * Borgun: Add support for USD transactions [dtykocki] #2602 * Borgun: Include currency code from split authorization for voids [dtykocki] #2605 * Ebanx: Support Store and person_type option [curiousepic] #2604 +* Elavon: Update endpoint URLs [curiousepic] #2608 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb index d1ae68d609a..248da8df7d5 100644 --- a/lib/active_merchant/billing/gateways/elavon.rb +++ b/lib/active_merchant/billing/gateways/elavon.rb @@ -7,8 +7,8 @@ class ElavonGateway < Gateway class_attribute :test_url, :live_url, :delimiter, :actions - self.test_url = 'https://demo.myvirtualmerchant.com/VirtualMerchantDemo/process.do' - self.live_url = 'https://www.myvirtualmerchant.com/VirtualMerchant/process.do' + self.test_url = 'https://api.demo.convergepay.com/VirtualMerchantDemo/process.do' + self.live_url = 'https://api.convergepay.com/VirtualMerchant/process.do' self.display_name = 'Elavon MyVirtualMerchant' self.supported_countries = %w(US CA PR DE IE NO PL LU BE NL) diff --git a/test/fixtures.yml b/test/fixtures.yml index 190524486ba..86ce18c25fd 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -246,10 +246,11 @@ efsnet: login: X password: Y +# Provided for url update test elavon: - login: LOGIN - password: PASSWORD - user: USER (often the same as LOGIN) + login: "000127" + user: ssltest + password: "IERAOBEE5V0D6Q3Q6R51TG89XAIVGEQ3LGLKMKCKCVQBGGGAU7FN627GPA54P5HR" element: account_id: "1013963" diff --git a/test/remote/gateways/remote_elavon_test.rb b/test/remote/gateways/remote_elavon_test.rb index 00e8f5bd55c..765459f7c14 100644 --- a/test/remote/gateways/remote_elavon_test.rb +++ b/test/remote/gateways/remote_elavon_test.rb @@ -60,8 +60,7 @@ def test_unsuccessful_capture end def test_unsuccessful_authorization - @credit_card.number = "1234567890123" - assert response = @gateway.authorize(@amount, @credit_card, @options) + assert response = @gateway.authorize(@amount, @bad_credit_card, @options) assert_failure response assert_equal 'The Credit Card Number supplied in the authorization request appears to be invalid.', response.message end From f12f1c82a3823ac7ff09f0e7ef7b956ed2ccd676 Mon Sep 17 00:00:00 2001 From: David Perry Date: Fri, 6 Oct 2017 10:49:48 -0400 Subject: [PATCH 207/677] PayU Latam: Set payment_country gateway attribute Checks both gateway parameters and options for payment_country and sets it as an attribute of the gateway on initialize. 2 remote tests continue to fail unrelated capture and void. Closes #2611 Remote: 18 tests, 47 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 88.8889% passed Unit: 24 tests, 94 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/payu_latam.rb | 3 ++- .../remote/gateways/remote_payu_latam_test.rb | 2 +- test/unit/gateways/payu_latam_test.rb | 20 +++++++++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 931269fcf51..5bf425a45e3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * Borgun: Include currency code from split authorization for voids [dtykocki] #2605 * Ebanx: Support Store and person_type option [curiousepic] #2604 * Elavon: Update endpoint URLs [curiousepic] #2608 +* PayU Latam: Set payment_country gateway attribute [curiousepic] #2611 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index d4558051a8f..6dcfa83384c 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -31,6 +31,7 @@ class PayuLatamGateway < Gateway def initialize(options={}) requires!(options, :merchant_id, :account_id, :api_login, :api_key) super + @options[:payment_country] ||= options[:payment_country] if options[:payment_country] end def purchase(amount, payment_method, options={}) @@ -138,7 +139,7 @@ def add_credentials(post, command) def add_transaction_elements(post, type, options) transaction = {} - transaction[:paymentCountry] = options[:payment_country] || (options[:billing_address][:country] if options[:billing_address]) + transaction[:paymentCountry] = @options[:payment_country] || (options[:billing_address][:country] if options[:billing_address]) transaction[:type] = type transaction[:ipAddress] = options[:ip] if options[:ip] transaction[:userAgent] = options[:user_agent] if options[:user_agent] diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index 4c417de377a..1ea9a9be146 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -2,7 +2,7 @@ class RemotePayuLatamTest < Test::Unit::TestCase def setup - @gateway = PayuLatamGateway.new(fixtures(:payu_latam)) + @gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(payment_country: 'AR')) @amount = 4000 @credit_card = credit_card("4097440000000004", verification_value: "444", first_name: "APPROVED", last_name: "") diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb index 11b75da35d6..52628e33621 100644 --- a/test/unit/gateways/payu_latam_test.rb +++ b/test/unit/gateways/payu_latam_test.rb @@ -307,6 +307,26 @@ def test_mexico_required_fields end.respond_with(successful_purchase_response) end + def test_payment_country_set_from_credential_or_options + gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key', payment_country: 'payment_country') + assert_match gateway.options[:payment_country], "payment_country" + + stub_comms do + gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match(/\"paymentCountry\":\"payment_country\"/, data) + end.respond_with(successful_purchase_response) + + gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key') + assert_nil gateway.options[:payment_country] + + stub_comms do + gateway.purchase(@amount, @credit_card, @options.merge(payment_country: 'payment_country')) + end.check_request do |endpoint, data, headers| + assert_match(/\"paymentCountry\":\"payment_country\"/, data) + end.respond_with(successful_purchase_response) + end + def test_payment_country_defaults_to_billing_address options_mexico = { currency: "MXN", From b19d23446b0ed22972635e4152d84a8126eae4bb Mon Sep 17 00:00:00 2001 From: Amanda Puff Date: Fri, 4 Aug 2017 15:10:03 -0400 Subject: [PATCH 208/677] Authorize.net CIM - Handle multiple error messages Authorize.net can send back one or multiple errors in their responses. We need to correctly assess whether response["messages"]["message"] is an Array or Hash, and if it is an Array, then we need to set the top level error_code and message fields to the first error returned. Closes #2537 --- CHANGELOG | 1 + .../billing/gateways/authorize_net_cim.rb | 6 ++- test/unit/gateways/authorize_net_cim_test.rb | 42 ++++++++++++++++++- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5bf425a45e3..332a6ad9531 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * Ebanx: Support Store and person_type option [curiousepic] #2604 * Elavon: Update endpoint URLs [curiousepic] #2608 * PayU Latam: Set payment_country gateway attribute [curiousepic] #2611 +* Authorize.net CIM: Handle multiple error messages [amandapuff] #2537 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb index d4c59ad12a7..c89f482a089 100644 --- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb +++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb @@ -858,7 +858,9 @@ def commit(action, request) response_params = parse(action, xml) - message = response_params['messages']['message']['text'] + message_element= response_params["messages"]["message"] + first_error = message_element.is_a?(Array) ? message_element.first : message_element + message = first_error['text'] test_mode = @options[:test_requests] || message =~ /Test Mode/ success = response_params['messages']['result_code'] == 'Ok' response_params['direct_response'] = parse_direct_response(response_params['direct_response']) if response_params['direct_response'] @@ -867,7 +869,7 @@ def commit(action, request) response_options = {} response_options[:test] = test_mode response_options[:authorization] = transaction_id || response_params['customer_profile_id'] || (response_params['profile'] ? response_params['profile']['customer_profile_id'] : nil) - response_options[:error_code] = response_params['messages']['message']['code'] unless success + response_options[:error_code] = first_error['code'] unless success Response.new(success, message, response_params, response_options) end diff --git a/test/unit/gateways/authorize_net_cim_test.rb b/test/unit/gateways/authorize_net_cim_test.rb index 75e41ea4a05..472a5878d2a 100644 --- a/test/unit/gateways/authorize_net_cim_test.rb +++ b/test/unit/gateways/authorize_net_cim_test.rb @@ -509,6 +509,8 @@ def test_should_create_customer_profile_transaction_auth_capture_and_then_refund # http://www.modernbill.com/support/manual/old/v4/adminhelp/english/Configuration/Payment_Settings/Gateway_API/AuthorizeNet/Module_Authorize.net.htm assert_failure response assert_equal 'The referenced transaction does not meet the criteria for issuing a credit.', response.params['direct_response']['message'] + assert_equal 'The transaction was unsuccessful.', response.message + assert_equal "E00027", response.error_code return response end @@ -583,7 +585,7 @@ def test_should_create_customer_profile_transaction_for_refund_request assert_equal 'This transaction has been approved.', response.params['direct_response']['message'] end - def test_should_create_customer_profile_trasnaction_passing_recurring_flag + def test_should_create_customer_profile_transaction_passing_recurring_flag response = stub_comms do @gateway.create_customer_profile_transaction( :transaction => { @@ -618,6 +620,22 @@ def test_full_or_masked_card_number assert_equal 'XXXX1234', @gateway.send(:full_or_masked_card_number, '1234') end + def test_multiple_errors_when_creating_customer_profile + @gateway.expects(:ssl_post).returns(unsuccessful_create_customer_profile_transaction_response_with_multiple_errors(:refund)) + assert response = @gateway.create_customer_profile_transaction( + :transaction => { + :type => :refund, + :amount => 1, + + :customer_profile_id => @customer_profile_id, + :customer_payment_profile_id => @customer_payment_profile_id, + :trans_id => 1 + } + ) + assert_equal 'The transaction was unsuccessful.', response.message + assert_equal 'E00027', response.error_code + end + private def get_auth_only_response @@ -1056,4 +1074,26 @@ def unsuccessful_create_customer_profile_transaction_response(transaction_type) XML end + def unsuccessful_create_customer_profile_transaction_response_with_multiple_errors(transaction_type) + <<-XML + + + + Error + + E00027 + The transaction was unsuccessful. + + + E00001 + An error occurred during processing. Please try again. + + + #{UNSUCCESSUL_DIRECT_RESPONSE[transaction_type]} + + XML + end end From 6f1eb55d8f2b83d0faafc7f53a35b99a12be31a6 Mon Sep 17 00:00:00 2001 From: David Perry Date: Wed, 11 Oct 2017 16:37:00 -0400 Subject: [PATCH 209/677] Beanstream: Pass email fields without address Passes email fields even if a billing or shipping address is not present. Also supports a shipping_email option. 2 remote test failures are occuring for echeck transactions, for which we are not currently concerned. Closes #2615 Remote: 35 tests, 158 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 94.2857% passed Unit: 21 tests, 100 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../gateways/beanstream/beanstream_core.rb | 7 ++++--- test/remote/gateways/remote_beanstream_test.rb | 15 ++++++++++++++- test/unit/gateways/beanstream_test.rb | 14 ++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 332a6ad9531..6157088867f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Elavon: Update endpoint URLs [curiousepic] #2608 * PayU Latam: Set payment_country gateway attribute [curiousepic] #2611 * Authorize.net CIM: Handle multiple error messages [amandapuff] #2537 +* Beanstream: Pass email fields without address [curiousepic] #2615 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index 7acaa830bb2..9b01c72c8e2 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -221,11 +221,13 @@ def add_reference(post, reference) end def add_address(post, options) + post[:ordEmailAddress] = options[:email] if options[:email] + post[:shipEmailAddress] = options[:shipping_email] || options[:email] if options[:email] + prepare_address_for_non_american_countries(options) if billing_address = options[:billing_address] || options[:address] post[:ordName] = billing_address[:name] - post[:ordEmailAddress] = options[:email] post[:ordPhoneNumber] = billing_address[:phone] post[:ordAddress1] = billing_address[:address1] post[:ordAddress2] = billing_address[:address2] @@ -234,9 +236,9 @@ def add_address(post, options) post[:ordPostalCode] = billing_address[:zip] post[:ordCountry] = billing_address[:country] end + if shipping_address = options[:shipping_address] post[:shipName] = shipping_address[:name] - post[:shipEmailAddress] = options[:email] post[:shipPhoneNumber] = shipping_address[:phone] post[:shipAddress1] = shipping_address[:address1] post[:shipAddress2] = shipping_address[:address2] @@ -465,4 +467,3 @@ def post_data(params, use_profile_api) end end end - diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb index 175c0a6b1b2..15ac8c69d38 100644 --- a/test/remote/gateways/remote_beanstream_test.rb +++ b/test/remote/gateways/remote_beanstream_test.rb @@ -18,7 +18,7 @@ def setup @declined_mastercard = credit_card('5100000020002000') @amex = credit_card('371100001000131', {:verification_value => 1234}) - @declined_amex = credit_card('342400001000180') + @declined_amex = credit_card('342400001000180', {:verification_value => 1234}) # Canadian EFT @check = check( @@ -109,6 +109,19 @@ def test_successful_purchase_with_state_in_iso_format assert_equal "Approved", response.message end + def test_successful_purchase_with_only_email + options = { + :order_id => generate_unique_id, + :email => 'xiaobozzz@example.com', + :shipping_email => 'ship@mail.com' + } + + assert response = @gateway.purchase(@amount, @visa, options) + assert_success response + assert_false response.authorization.blank? + assert_equal "Approved", response.message + end + def test_successful_purchase_with_no_addresses @options[:billing_address] = {} @options[:shipping_address] = {} diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb index 130dac23fe0..b238d2e865e 100644 --- a/test/unit/gateways/beanstream_test.rb +++ b/test/unit/gateways/beanstream_test.rb @@ -264,6 +264,20 @@ def test_no_state_and_zip_default_with_missing_country assert_success response end + def test_sends_email_without_addresses + @options[:billing_address] = nil + @options[:shipping_address] = nil + @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| + assert_match(/ordEmailAddress=xiaobozzz%40example.com/, data) + assert_match(/shipEmailAddress=ship%40mail.com/, data) + end.respond_with(successful_purchase_response) + + assert_success response + end + def test_transcript_scrubbing assert_equal scrubbed_transcript, @gateway.scrub(transcript) end From c2a2ea483c48310b1d0b2d7225f19844d83ef189 Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Thu, 12 Oct 2017 15:41:54 -0400 Subject: [PATCH 210/677] Fixes basic auth for netbanx by sending the account_number and api_key (#2616) The previous implementation for basic auth was only using the api_key. According to https://developer.paysafe.com/en/cards/api/#/introduction/authentication, we should be sending the account_number followed by the api_key. --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/netbanx.rb | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 6157088867f..9af205d0dda 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Netbanx: Fix basic auth by sending the account_number and api_key [anotherjosmith] #2616 * WePay: Only send ip and device for non-recurring transactions [dtykocki] #2597 * Barclaycard Smartpay: Use authorization pspReference for refunds [davidsantoso] #2599 * Adyen: Update list of supported countries [dtykocki] #2600 diff --git a/lib/active_merchant/billing/gateways/netbanx.rb b/lib/active_merchant/billing/gateways/netbanx.rb index 2f88291c6f5..a19dd42e8cf 100644 --- a/lib/active_merchant/billing/gateways/netbanx.rb +++ b/lib/active_merchant/billing/gateways/netbanx.rb @@ -241,11 +241,15 @@ def headers { 'Accept' => 'application/json', 'Content-type' => 'application/json', - 'Authorization' => "Basic #{Base64.strict_encode64(@options[:api_key].to_s).strip}", + 'Authorization' => "Basic #{basic_auth}", 'User-Agent' => "Netbanx-Paysafe v1.0/ActiveMerchant #{ActiveMerchant::VERSION}" } end + def basic_auth + Base64.strict_encode64("#{@options[:account_number]}:#{@options[:api_key]}") + end + def error_code_from(response) unless success_from(response) case response['errorCode'] From c531c1f8f497511eff39e4fcb4d3bd8b56bcb83a Mon Sep 17 00:00:00 2001 From: dtykocki Date: Thu, 12 Oct 2017 09:02:53 -0400 Subject: [PATCH 211/677] Beanstream: Add recurring flag in order to bypass CVV requirement Per Beanstream, as of Oct 14th, 2017 new merchants will be required to pass in the CVV on transactions. By supplying the `recurringPayment` flag on `authorize`, `capture`, or `purchase` the CVV requirement will be bypassed. Closes #2617 --- CHANGELOG | 1 + .../billing/gateways/beanstream.rb | 2 + .../gateways/beanstream/beanstream_core.rb | 7 ++- .../remote/gateways/remote_beanstream_test.rb | 48 +++++++++++++++++++ test/unit/gateways/beanstream_test.rb | 27 ++++++++++- 5 files changed, 82 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9af205d0dda..85d27675f6b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * PayU Latam: Set payment_country gateway attribute [curiousepic] #2611 * Authorize.net CIM: Handle multiple error messages [amandapuff] #2537 * Beanstream: Pass email fields without address [curiousepic] #2615 +* Beanstream: Support recurringPayment for auth, capture, and purchase transactions [dtykocki] #2617 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/beanstream.rb b/lib/active_merchant/billing/gateways/beanstream.rb index f396a7d7d0f..d60d8a5d7ed 100644 --- a/lib/active_merchant/billing/gateways/beanstream.rb +++ b/lib/active_merchant/billing/gateways/beanstream.rb @@ -75,6 +75,7 @@ def authorize(money, source, options = {}) add_address(post, options) add_transaction_type(post, :authorization) add_customer_ip(post, options) + add_recurring_payment(post, options) commit(post) end @@ -86,6 +87,7 @@ def purchase(money, source, options = {}) add_address(post, options) add_transaction_type(post, purchase_action(source)) add_customer_ip(post, options) + add_recurring_payment(post, options) commit(post) end diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index 9b01c72c8e2..e60e9bd2646 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -138,7 +138,7 @@ def self.included(base) # The homepage URL of the gateway base.homepage_url = 'http://www.beanstream.com/' - base.live_url = 'https://www.beanstream.com/scripts/process_transaction.asp' + base.live_url = 'https://api.na.bambora.com/scripts/process_transaction.asp' # The name of the gateway base.display_name = 'Beanstream.com' @@ -161,6 +161,7 @@ def capture(money, authorization, options = {}) add_amount(post, money) add_reference(post, reference) add_transaction_type(post, :capture) + add_recurring_payment(post, options) commit(post) end @@ -265,6 +266,10 @@ def prepare_address_for_non_american_countries(options) end end + def add_recurring_payment(post, options) + post[:recurringPayment] = true if options[:recurring].to_s == 'true' + end + def add_invoice(post, options) post[:trnOrderNumber] = options[:order_id] post[:trnComments] = options[:description] diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb index 15ac8c69d38..9f382ef4d8b 100644 --- a/test/remote/gateways/remote_beanstream_test.rb +++ b/test/remote/gateways/remote_beanstream_test.rb @@ -13,6 +13,7 @@ def setup # Beanstream test cards. Cards require a CVV of 123, which is the default of the credit card helper @visa = credit_card('4030000010001234') @declined_visa = credit_card('4003050500040005') + @visa_no_cvv = credit_card('4030000010001234', verification_value: nil) @mastercard = credit_card('5100000010001004') @declined_mastercard = credit_card('5100000020002000') @@ -70,6 +71,20 @@ def test_successful_visa_purchase assert_equal "Approved", response.message end + def test_successful_visa_purchase_with_recurring + assert response = @gateway.purchase(@amount, @visa, @options.merge(recurring: true)) + assert_success response + assert_false response.authorization.blank? + assert_equal "Approved", response.message + end + + def test_successful_visa_purchase_no_cvv + assert response = @gateway.purchase(@amount, @visa_no_cvv, @options) + assert_success response + assert_false response.authorization.blank? + assert_equal "Approved", response.message + end + def test_unsuccessful_visa_purchase assert response = @gateway.purchase(@amount, @declined_visa, @options) assert_failure response @@ -83,6 +98,13 @@ def test_successful_mastercard_purchase assert_equal "Approved", response.message end + def test_successful_mastercard_purchase_with_recurring + assert response = @gateway.purchase(@amount, @mastercard, @options.merge(recurring: true)) + assert_success response + assert_false response.authorization.blank? + assert_equal "Approved", response.message + end + def test_unsuccessful_mastercard_purchase assert response = @gateway.purchase(@amount, @declined_mastercard, @options) assert_failure response @@ -96,6 +118,13 @@ def test_successful_amex_purchase assert_equal "Approved", response.message end + def test_successful_amex_purchase_with_recurring + assert response = @gateway.purchase(@amount, @amex, @options.merge(recurring: true)) + assert_success response + assert_false response.authorization.blank? + assert_equal "Approved", response.message + end + def test_unsuccessful_amex_purchase assert response = @gateway.purchase(@amount, @declined_amex, @options) assert_failure response @@ -163,6 +192,17 @@ def test_authorize_and_capture assert_false capture.authorization.blank? end + def test_authorize_and_capture_with_recurring + assert auth = @gateway.authorize(@amount, @visa, @options.merge(recurring: true)) + assert_success auth + assert_equal "Approved", auth.message + assert_false auth.authorization.blank? + + assert capture = @gateway.capture(@amount, auth.authorization, recurring: true) + assert_success capture + assert_false capture.authorization.blank? + end + def test_successful_verify response = @gateway.verify(@visa, @options) assert_success response @@ -190,6 +230,14 @@ def test_successful_purchase_and_void assert_success void end + def test_successful_purchase_and_void_with_recurring + assert purchase = @gateway.purchase(@amount, @visa, @options.merge(recurring: true)) + assert_success purchase + + assert void = @gateway.void(purchase.authorization) + assert_success void + end + def test_successful_purchase_and_refund_and_void_refund assert purchase = @gateway.purchase(@amount, @visa, @options) assert_success purchase diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb index b238d2e865e..a97990ba636 100644 --- a/test/unit/gateways/beanstream_test.rb +++ b/test/unit/gateways/beanstream_test.rb @@ -57,13 +57,36 @@ def setup end def test_successful_purchase - @gateway.expects(:ssl_post).returns(successful_purchase_response) + response = stub_comms(@gateway, :ssl_request) do + @gateway.purchase(@amount, @decrypted_credit_card, @options) + end.check_request do |method, endpoint, data, headers| + refute_match(/recurringPayment=true/, data) + end.respond_with(successful_purchase_response) - assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal '10000028;15.00;P', response.authorization end + def test_successful_purchase_with_recurring + response = stub_comms(@gateway, :ssl_request) do + @gateway.purchase(@amount, @decrypted_credit_card, @options.merge(recurring: true)) + end.check_request do |method, endpoint, data, headers| + assert_match(/recurringPayment=true/, data) + end.respond_with(successful_purchase_response) + + assert_success response + end + + def test_successful_authorize_with_recurring + response = stub_comms(@gateway, :ssl_request) do + @gateway.authorize(@amount, @decrypted_credit_card, @options.merge(recurring: true)) + end.check_request do |method, endpoint, data, headers| + assert_match(/recurringPayment=true/, data) + end.respond_with(successful_purchase_response) + + assert_success response + end + def test_successful_test_request_in_production_environment Base.mode = :production @gateway.expects(:ssl_post).returns(successful_test_purchase_response) From 6987b7e1d1d4855f5d8a9d473ad3aaea742ac6bb Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Fri, 6 Oct 2017 10:43:40 -0400 Subject: [PATCH 212/677] WePay: Adds tests to verify store options. The `store` action uses one of two possible endpoints depending on other parameters. Only `/create` was being tested. This adds tests to verify success and failure for both endpoints. Closes #2607 Remote Tests: 27 tests, 45 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit Tests: 21 tests, 78 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- test/remote/gateways/remote_wepay_test.rb | 27 ++++++++++++++++++++++- test/unit/gateways/wepay_test.rb | 10 ++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/test/remote/gateways/remote_wepay_test.rb b/test/remote/gateways/remote_wepay_test.rb index c0a395b5d78..ee7fe151b30 100644 --- a/test/remote/gateways/remote_wepay_test.rb +++ b/test/remote/gateways/remote_wepay_test.rb @@ -6,6 +6,8 @@ def setup @amount = 2000 @credit_card = credit_card('5496198584584769', verification_value: '321') + @credit_card_without_cvv = credit_card('5496198584584769', verification_value: nil) + @declined_card = credit_card('') @options = { @@ -97,11 +99,34 @@ def test_failed_authorize assert_failure response end - def test_successful_store + def test_successful_store_via_create_with_cvv + # POST /credit_card/create response = @gateway.store(@credit_card, @options) assert_success response end + def test_successful_store_via_transfer_without_cvv + # special permission required + # POST /credit_card/transfer + response = @gateway.store(@credit_card_without_cvv, @options.merge(recurring: true)) + assert_success response + end + + def test_unsuccessful_store_via_create_with_cvv + response = @gateway.store(@credit_card_without_cvv, @options) + + assert_failure response + assert_equal('This app does not have permissions to create credit cards without a cvv', response.message) + end + + # # Requires commenting out `unless options[:recurring]` when building post hash in `store` method. + # def test_unsuccessful_store_via_transfer_with_cvv + # response = @gateway.store(@credit_card, @options.merge(recurring: true)) + # + # assert_failure response + # assert_equal('cvv parameter is unexpected', response.message) + # end + def test_successful_store_with_defaulted_email response = @gateway.store(@credit_card, {billing_address: address}) assert_success response diff --git a/test/unit/gateways/wepay_test.rb b/test/unit/gateways/wepay_test.rb index b63ce1b70d0..8f64d00b984 100644 --- a/test/unit/gateways/wepay_test.rb +++ b/test/unit/gateways/wepay_test.rb @@ -125,7 +125,7 @@ def test_failed_void assert_equal "this checkout has already been cancelled", response.message end - def test_successful_store + def test_successful_store_via_create @gateway.expects(:ssl_post).returns(successful_store_response) response = @gateway.store(@credit_card, @options) @@ -133,6 +133,14 @@ def test_successful_store assert_equal "3322208138", response.authorization end + def test_successful_store_via_transfer + @gateway.expects(:ssl_post).returns(successful_store_response) + + response = @gateway.store(@credit_card, @options.merge(recurring: true)) + assert_success response + assert_equal "3322208138", response.authorization + end + def test_failed_store @gateway.expects(:ssl_post).returns(failed_store_response) From d5385846e3d7e53a1d6702d4d5556159fe623adc Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Tue, 5 Sep 2017 20:42:54 -0400 Subject: [PATCH 213/677] Barclaycard Smartpay: Refactors address parsing. Although using a regex has worked for *most* of the needed address parsing, there are still a few exceptions. Due to the unusual address structure, this allows some require fields to come through in the options hash: `:street`, `:shipping_street`, `:house_number`, and `:shipping_house_number`. Closes #2603 Unit Tests: 22 tests, 95 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote Tests: 25 tests, 50 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 5 +- .../billing/gateways/barclaycard_smartpay.rb | 49 ++++++---- .../remote_barclaycard_smartpay_test.rb | 53 +++++++++++ .../gateways/barclaycard_smartpay_test.rb | 90 +++++++++++++++++++ 4 files changed, 179 insertions(+), 18 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 85d27675f6b..2c0a7ea5964 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * Authorize.net CIM: Handle multiple error messages [amandapuff] #2537 * Beanstream: Pass email fields without address [curiousepic] #2615 * Beanstream: Support recurringPayment for auth, capture, and purchase transactions [dtykocki] #2617 +* Barclaycard Smartpay: Pass street and house_number fields, in addition to standard address [deedeelavinder] #2603 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 @@ -1790,7 +1791,7 @@ value [jduff] * Support default Return class for all Integrations that don't use returns [Soleone] * Add support for passing additional options when creating a Notification to all Integrations [Soleone] * Update BraintreeBlue#refund to have consistent method signature [Jonathan Rudenberg] -* Add rails/init.rb for gem campatability in Rails [Rūdolfs Ošiņš] +* Add rails/init.rb for gem campatability in Rails [R?dolfs O?i??] * Fix Paypal Express response parser [Jonathan Rudenberg] * Braintree/Transax: Add tax field [wisq] @@ -2106,7 +2107,7 @@ value [jduff] * Update Secure Pay Au to meet specs for MessageInfo elements [cody] * Add support for the Australian Secure Pay payment gateway [cody] * Allow LinkPoint cancellations for recurring billing. [yanagimoto.shin] -* Add support for Åland Islands to the country list [cody] +* Add support for ?land Islands to the country list [cody] == Version 1.3.1 (January 28, 2008) diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index 3d7cd3e2488..95ac68c65a1 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -33,15 +33,8 @@ def authorize(money, creditcard, options = {}) post = payment_request(money, options) post[:amount] = amount_hash(money, options[:currency]) post[:card] = credit_card_hash(creditcard) - - if address = (options[:billing_address] || options[:address]) - post[:billingAddress] = address_hash(address) - end - - if options[:shipping_address] - post[:deliveryAddress] = address_hash(options[:shipping_address]) - end - + post[:billingAddress] = billing_address_hash(options) + post[:deliveryAddress] = shipping_address_hash(options) if options[:shipping_address] commit('authorise', post) end @@ -230,17 +223,41 @@ def build_url(action) end end - def address_hash(address) - full_address = "#{address[:address1]} #{address[:address2]}" if address - street = address[:street] if address[:street] - house = address[:houseNumberOrName] ? address[:houseNumberOrName] : full_address.split(/\s+/).keep_if { |x| x =~ /\d/ }.join(' ') + def billing_address_hash(options) + address = options[:address] || options[:billing_address] if options[:address] || options[:billing_address] + street = options[:street] || parse_street(address) + house = options[:house_number] || parse_house_number(address) + + create_address_hash(address, house, street) + end + + def shipping_address_hash(options) + address = options[:shipping_address] + street = options[:shipping_street] || parse_street(address) + house = options[:shipping_house_number] || parse_house_number(address) + create_address_hash(address, house, street) + end + + def parse_street(address) + address_to_parse = "#{address[:address1]} #{address[:address2]}" + street = address[:street] || address_to_parse.split(/\s+/).keep_if { |x| x !~ /\d/ }.join(' ') + street.empty? ? "Not Provided" : street + end + + def parse_house_number(address) + address_to_parse = "#{address[:address1]} #{address[:address2]}" + house = address[:houseNumberOrName] || address_to_parse.split(/\s+/).keep_if { |x| x =~ /\d/ }.join(' ') + house.empty? ? "Not Provided" : house + end + + def create_address_hash(address, house, street) hash = {} + hash[:houseNumberOrName] = house + hash[:street] = street hash[:city] = address[:city] if address[:city] - hash[:street] = street || full_address.split(/\s+/).keep_if { |x| x !~ /\d/ }.join(' ') - hash[:houseNumberOrName] = house.empty? ? "Not Provided" : house - hash[:postalCode] = address[:zip] if address[:zip] hash[:stateOrProvince] = address[:state] if address[:state] + hash[:postalCode] = address[:zip] if address[:zip] hash[:country] = address[:country] if address[:country] hash end diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index 539c55abd30..e866452fbcd 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -26,6 +26,43 @@ def setup description: 'Store Purchase' } + @options_with_alternate_address = { + order_id: '1', + billing_address: { + name: 'PU JOI SO', + address1: '新北市店溪路3579號139樓', + company: 'Widgets Inc', + city: '新北市', + zip: '231509', + country: 'TW', + phone: '(555)555-5555', + fax: '(555)555-6666' + }, + email: 'pujoi@so.com', + customer: 'PU JOI SO', + description: 'Store Purchase' + } + + @options_with_house_number_and_street = { + order_id: '1', + house_number: '100', + street: 'Top Level Drive', + billing_address: { + name: 'Jim Smith', + address1: '100 Top Level Dr', + company: 'Widgets Inc', + city: 'Ottawa', + state: 'ON', + zip: 'K1C2N6', + country: 'CA', + phone: '(555)555-5555', + fax: '(555)555-6666' + }, + email: 'long@deb.com', + customer: 'Longdeb Longsen', + description: 'Store Purchase' + } + @avs_credit_card = credit_card('4400000000000008', :month => 8, :year => 2018, @@ -59,6 +96,22 @@ def test_failed_purchase assert_equal 'Refused', response.message end + def test_successful_purchase_with_unusual_address + response = @gateway.purchase(@amount, + @credit_card, + @options_with_alternate_address) + assert_success response + assert_equal '[capture-received]', response.message + end + + def test_successful_purchase_with_house_number_and_street + response = @gateway.purchase(@amount, + @credit_card, + @options.merge(street: 'Top Level Drive', house_number: '100')) + assert_success response + assert_equal '[capture-received]', response.message + end + def test_successful_authorize_and_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb index ad074938ed9..486c6df657b 100644 --- a/test/unit/gateways/barclaycard_smartpay_test.rb +++ b/test/unit/gateways/barclaycard_smartpay_test.rb @@ -19,6 +19,51 @@ def setup description: 'Store Purchase' } + @options_with_alternate_address = { + order_id: '1', + billing_address: { + name: 'PU JOI SO', + address1: '新北市店溪路3579號139樓', + company: 'Widgets Inc', + city: '新北市', + zip: '231509', + country: 'TW', + phone: '(555)555-5555', + fax: '(555)555-6666' + }, + email: 'pujoi@so.com', + customer: 'PU JOI SO', + description: 'Store Purchase' + } + + @options_with_house_number_and_street = { + order_id: '1', + street: 'Top Level Drive', + house_number: '1000', + billing_address: address, + description: 'Store Purchase' + } + + @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' + } + @avs_address = @options @avs_address.update(billing_address: { name: 'Jim Smith', @@ -41,6 +86,51 @@ def test_successful_purchase assert response.test? end + 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| + 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) + + assert_success response + assert_equal '7914002629995504', response.authorization + assert response.test? + end + + def test_successful_authorize_with_house_number_and_street + response = stub_comms do + @gateway.authorize(@amount, + @credit_card, + @options_with_house_number_and_street) + end.check_request do |endpoint, data, headers| + assert_match(/billingAddress.street=Top\+Level\+Drive/, data) + assert_match(/billingAddress.houseNumberOrName=1000/, data) + end.respond_with(successful_authorize_response) + + assert response + assert_success response + assert_equal '7914002629995504', response.authorization + end + + def test_successful_authorize_with_shipping_house_number_and_street + response = stub_comms do + @gateway.authorize(@amount, + @credit_card, + @options_with_shipping_house_number_and_shipping_street) + 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) + assert_match(/deliveryAddress.houseNumberOrName=999/, data) + end.respond_with(successful_authorize_response) + + assert response + assert_success response + assert_equal '7914002629995504', response.authorization + end + def test_successful_authorize @gateway.stubs(:ssl_post).returns(successful_authorize_response) From 27a5fdfb6fd7887b43e71c42da956ad4415e6c38 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Mon, 25 Sep 2017 14:28:33 -0400 Subject: [PATCH 214/677] Payeezy: Adds :store functionality. Adds :store to Payeezy gateway using Transarmor token according to documentation here: https://developer.payeezy.com/payeezy-api/apis/get/securitytokens Refactors gateway to include endpoint for tokenization and to handle returned JSONP object. Concatenates token data for storage. Closes #2591 Unit Tests: 30 tests, 146 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote Tests: 25 tests, 90 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/payeezy.rb | 175 ++++++++++++++---- test/fixtures.yml | 4 +- test/remote/gateways/remote_payeezy_test.rb | 27 ++- test/unit/gateways/payeezy_test.rb | 62 ++++++- 5 files changed, 219 insertions(+), 50 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2c0a7ea5964..2d825304f19 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * Beanstream: Pass email fields without address [curiousepic] #2615 * Beanstream: Support recurringPayment for auth, capture, and purchase transactions [dtykocki] #2617 * Barclaycard Smartpay: Pass street and house_number fields, in addition to standard address [deedeelavinder] #2603 +* Payeezy: Adds support for store [deedeelavinder] #2591 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index 206b122442f..e7c1e5f39a9 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -3,9 +3,9 @@ module Billing class PayeezyGateway < Gateway class_attribute :integration_url - self.test_url = 'https://api-cert.payeezy.com/v1/transactions' - self.integration_url = 'https://api-cat.payeezy.com/v1/transactions' - self.live_url = 'https://api.payeezy.com/v1/transactions' + self.test_url = 'https://api-cert.payeezy.com/v1' + self.integration_url = 'https://api-cat.payeezy.com/v1' + self.live_url = 'https://api.payeezy.com/v1' self.default_currency = 'USD' self.money_format = :cents @@ -31,7 +31,7 @@ def initialize(options = {}) end def purchase(amount, payment_method, options = {}) - params = {transaction_type: 'purchase'} + params = payment_method.is_a?(String) ? { transaction_type: 'recurring' } : { transaction_type: 'purchase' } add_invoice(params, options) add_payment_method(params, payment_method, options) @@ -73,6 +73,14 @@ def refund(amount, authorization, options = {}) commit(params, options) end + def store(payment_method, options = {}) + params = {} + + add_creditcard_for_tokenization(params, payment_method, options) + + commit(params, options) + end + def void(authorization, options = {}) params = {transaction_type: 'void'} @@ -119,27 +127,34 @@ def add_authorization_info(params, authorization) params[:method] = method end + def add_creditcard_for_tokenization(params, payment_method, options) + params[:apikey] = @options[:apikey] + params[:js_security_key] = options[:js_security_key] + params[:ta_token] = options[:ta_token] + params[:callback] = 'Payeezy.callback' + params[:type] = 'FDToken' + card = add_card_data(payment_method) + params['credit_card.type'] = card[:type] + params['credit_card.cardholder_name'] = card[:cardholder_name] + params['credit_card.card_number'] = card[:card_number] + params['credit_card.exp_date'] = card[:exp_date] + params['credit_card.cvv'] = card[:cvv] + end + + def is_store_action?(params) + params[:ta_token].present? + end + def add_payment_method(params, payment_method, options) if payment_method.is_a? Check add_echeck(params, payment_method, options) + elsif payment_method.is_a? String + add_token(params, payment_method, options) else add_creditcard(params, payment_method) end end - def add_creditcard(params, creditcard) - credit_card = {} - - credit_card[:type] = CREDIT_CARD_BRAND[creditcard.brand] - credit_card[:cardholder_name] = creditcard.name - credit_card[:card_number] = creditcard.number - credit_card[:exp_date] = "#{format(creditcard.month, :two_digits)}#{format(creditcard.year, :two_digits)}" - credit_card[:cvv] = creditcard.verification_value if creditcard.verification_value? - - params[:method] = 'credit_card' - params[:credit_card] = credit_card - end - def add_echeck(params, echeck, options) tele_check = {} @@ -156,6 +171,44 @@ def add_echeck(params, echeck, options) params[:tele_check] = tele_check end + def add_token(params, payment_method, options) + token = {} + token[:token_type] = 'FDToken' + + type, cardholder_name, exp_date, card_number = payment_method.split('|') + + token[:token_data] = {} + token[:token_data][:type] = type + token[:token_data][:cardholder_name] = cardholder_name + token[:token_data][:value] = card_number + token[:token_data][:exp_date] = exp_date + token[:token_data][:cvv] = options[:cvv] if options[:cvv] + + params[:method] = 'token' + params[:token] = token + end + + def add_creditcard(params, creditcard) + credit_card = add_card_data(creditcard) + + params[:method] = 'credit_card' + params[:credit_card] = credit_card + end + + def add_card_data(payment_method) + card = {} + card[:type] = CREDIT_CARD_BRAND[payment_method.brand] + card[:cardholder_name] = payment_method.name + card[:card_number] = payment_method.number + card[:exp_date] = format_exp_date(payment_method.month, payment_method.year) + card[:cvv] = payment_method.verification_value if payment_method.verification_value? + card + end + + def format_exp_date(month, year) + "#{format(month, :two_digits)}#{format(year, :two_digits)}" + end + def add_address(params, options) address = options[:billing_address] return unless address @@ -180,25 +233,18 @@ def add_soft_descriptors(params, options) end def commit(params, options) - url = if options[:integration] - integration_url - elsif test? - test_url - else - live_url - end + url = base_url(options) + endpoint(params) if transaction_id = params.delete(:transaction_id) url = "#{url}/#{transaction_id}" end begin - body = params.to_json - response = parse(ssl_post(url, body, headers(body))) + response = api_request(url, params) rescue ResponseError => e response = response_error(e.response.body) rescue JSON::ParserError - response = json_error(raw_response) + response = json_error(e.response.body) end Response.new( @@ -213,17 +259,34 @@ def commit(params, options) ) end - def success_from(response) - response['transaction_status'] == 'approved' + def base_url(options) + if options[:integration] + integration_url + elsif test? + test_url + else + live_url + end end - def authorization_from(params, response) - [ - response['transaction_id'], - response['transaction_tag'], - params[:method], - (response['amount'] && response['amount'].to_i) - ].join('|') + def endpoint(params) + is_store_action?(params) ? '/securitytokens' : '/transactions' + end + + def api_request(url, params) + if is_store_action?(params) + callback = ssl_request(:get, "#{url}?#{post_data(params)}", nil, {}) + payload = callback[/{(?:\n|.)*}/] + parse(payload) + else + body = params.to_json + parse(ssl_post(url, body, headers(body))) + end + end + + def post_data(params) + return nil unless params + params.reject { |k, v| v.blank? }.collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join("&") end def generate_hmac(nonce, current_timestamp, payload) @@ -256,19 +319,55 @@ def error_code(response, success) response['Error'].to_h['messages'].to_a.map { |e| e['code'] }.join(', ') end + def success_from(response) + if response['transaction_status'] + response['transaction_status'] == 'approved' + elsif response['results'] + response['results']['status'] == 'success' + else + false + end + end + def handle_message(response, success) - if success + if success && response['status'].present? + 'Token successfully created.' + elsif success "#{response['gateway_message']} - #{response['bank_message']}" elsif %w(401 403).include?(response['code']) response['message'] elsif response.key?('Error') response['Error']['messages'].first['description'] + elsif response.key?('results') + response['results']['Error']['messages'].first['description'] elsif response.key?('error') response['error'] elsif response.key?('fault') response['fault'].to_h['faultstring'] else - response['bank_message'] + response['bank_message'] || 'Failure to successfully create token.' + end + end + + def authorization_from(params, response) + if is_store_action?(params) + if success_from(response) + [ + response['results']['token']['type'], + response['results']['token']['cardholder_name'], + response['results']['token']['exp_date'], + response['results']['token']['value'] + ].join('|') + else + nil + end + else + [ + response['transaction_id'], + response['transaction_tag'], + params[:method], + (response['amount'] && response['amount'].to_i) + ].join('|') end end diff --git a/test/fixtures.yml b/test/fixtures.yml index 86ce18c25fd..8e63ba2e948 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -645,8 +645,8 @@ paybox_direct: # Working credentials, no need to replace payeezy: - apikey: oKB61AAxbN3xwC6gVAH3dp58FmioHSAT - apisecret: 36ef1fc3b908b7a79ad2c29de931d2ccff26fcec35602c709a9e34318e936683 + apikey: UyDMTXx6TD9WErF6ynw7xeEfCAn8fcGs + apisecret: 2a4974e242c91cab7f38910938f2a5db79e89756b084bbf7cab7849b50a9930f token: fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6 payex: diff --git a/test/remote/gateways/remote_payeezy_test.rb b/test/remote/gateways/remote_payeezy_test.rb index ebfa6cb36a6..9e36909a592 100644 --- a/test/remote/gateways/remote_payeezy_test.rb +++ b/test/remote/gateways/remote_payeezy_test.rb @@ -9,7 +9,8 @@ def setup @amount = 100 @options = { :billing_address => address, - :merchant_ref => 'Store Purchase' + :merchant_ref => 'Store Purchase', + :ta_token => '123' } @options_mdd = { soft_descriptors: { @@ -26,6 +27,30 @@ def setup } end + def test_successful_store + assert response = @gateway.store(@credit_card, + @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) + assert_success response + assert_equal 'Token successfully created.', response.message + assert response.authorization + end + + def test_successful_store_and_purchase + assert response = @gateway.store(@credit_card, + @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) + assert_success response + assert !response.authorization.blank? + assert purchase = @gateway.purchase(@amount, response.authorization, @options) + assert_success purchase + end + + def test_unsuccessful_store + assert response = @gateway.store(@bad_credit_card, + @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) + assert_failure response + assert_equal 'The credit card number check failed', response.message + end + def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_match(/Transaction Normal/, response.message) diff --git a/test/unit/gateways/payeezy_test.rb b/test/unit/gateways/payeezy_test.rb index acf27ab22e2..5507f09fe8f 100644 --- a/test/unit/gateways/payeezy_test.rb +++ b/test/unit/gateways/payeezy_test.rb @@ -5,17 +5,15 @@ class PayeezyGateway < Test::Unit::TestCase include CommStub def setup - @gateway = PayeezyGateway.new( - apikey: "45234543524353", - apisecret: "4235423325", - token: "rewrt-23543543542353542" - ) + @gateway = PayeezyGateway.new(fixtures(:payeezy)) @credit_card = credit_card + @bad_credit_card = credit_card('4111111111111113') @check = check @amount = 100 @options = { - :billing_address => address + :billing_address => address, + :ta_token => '123' } @authorization = "ET1700|106625152|credit_card|4738" end @@ -26,7 +24,7 @@ def test_invalid_credentials assert response = @gateway.authorize(100, @credit_card, {}) assert_failure response assert response.test? - assert_equal '||credit_card|', response.authorization + assert response.authorization assert_equal 'HMAC validation Failure', response.message end @@ -36,7 +34,7 @@ def test_invalid_token assert response = @gateway.authorize(100, @credit_card, {}) assert_failure response assert response.test? - assert_equal '||credit_card|', response.authorization + assert response.authorization assert_equal 'Access denied', response.message end @@ -46,7 +44,7 @@ def test_invalid_token_on_integration assert response = @gateway.authorize(100, @credit_card, {}) assert_failure response assert response.test? - assert_equal '||credit_card|', response.authorization + assert response.authorization assert_equal 'Invalid ApiKey for given resource', response.message end @@ -59,6 +57,40 @@ def test_successful_purchase assert_equal 'Transaction Normal - Approved', response.message end + def test_successful_store + response = stub_comms do + @gateway.store(@credit_card, @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) + end.respond_with(successful_store_response) + + assert_success response + assert_equal 'Token successfully created.', response.message + assert response.test? + end + + def test_successful_store_and_purchase + response = stub_comms do + @gateway.store(@credit_card, @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) + end.respond_with(successful_store_response) + + assert_success response + assert_match %r{Token successfully created}, response.message + + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + purchase = @gateway.purchase(@amount, response.authorization, @options) + assert_success purchase + end + + def test_failed_store + response = stub_comms do + @gateway.store(@bad_credit_card, @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) + end.respond_with(failed_store_response) + + assert_failure response + assert_equal 'The credit card number check failed', response.message + assert response.test? + end + def test_successful_purchase_with_echeck @gateway.expects(:ssl_post).returns(successful_purchase_echeck_response) assert response = @gateway.purchase(@amount, @check, @options) @@ -362,6 +394,18 @@ def successful_purchase_echeck_response RESPONSE end + def successful_store_response + <<-RESPONSE + "\n Payeezy.callback({\n \t\"status\":201,\n \t\"results\":{\"correlation_id\":\"228.0715530338021\",\"status\":\"success\",\"type\":\"FDToken\",\"token\":{\"type\":\"Visa\",\"cardholder_name\":\"Longbob Longsen\",\"exp_date\":\"0918\",\"value\":\"9715442510284242\"}}\n })\n " + RESPONSE + end + + def failed_store_response + <<-RESPONSE + "\n Payeezy.callback({\n \t\"status\":400,\n \t\"results\":{\"correlation_id\":\"228.0715669121910\",\"status\":\"failed\",\"Error\":{\"messages\":[{\"code\":\"invalid_card_number\",\"description\":\"The credit card number check failed\"}]},\"type\":\"FDToken\"}\n })\n " + RESPONSE + end + def failed_purchase_response yamlexcep = <<-RESPONSE --- !ruby/exception:ActiveMerchant::ResponseError From 028b5326ef59191c51f95dac594661c796ef651a Mon Sep 17 00:00:00 2001 From: dtykocki Date: Thu, 12 Oct 2017 09:34:02 -0400 Subject: [PATCH 215/677] Checkout V2: Expose AVS and CVV results for purchases This adds AVS and CVV result details to `purchase`. Since the gateway only returns AVS and CVV information when performing the initial authorization, the responses from both `authorize` and `capture` are now merged in `purchase`. Also, this fixes a failing test by correcting how the adapter sends address1 and address2. Closes #2619 --- CHANGELOG | 1 + .../billing/gateways/checkout_v2.rb | 40 ++++++++++++++----- .../gateways/remote_checkout_v2_test.rb | 15 +++++++ test/unit/gateways/checkout_v2_test.rb | 20 +++++++++- 4 files changed, 66 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2d825304f19..856b91fa376 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * Beanstream: Support recurringPayment for auth, capture, and purchase transactions [dtykocki] #2617 * Barclaycard Smartpay: Pass street and house_number fields, in addition to standard address [deedeelavinder] #2603 * Payeezy: Adds support for store [deedeelavinder] #2591 +* Checkout V2: Expose AVS and CVV results for purchases [dtykocki] #2619 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb index cf56dbdded1..3188f225a96 100644 --- a/lib/active_merchant/billing/gateways/checkout_v2.rb +++ b/lib/active_merchant/billing/gateways/checkout_v2.rb @@ -17,10 +17,24 @@ def initialize(options={}) end def purchase(amount, payment_method, options={}) - MultiResponse.run do |r| + multi = MultiResponse.run do |r| r.process { authorize(amount, payment_method, options) } r.process { capture(amount, r.authorization, options) } end + + merged_params = multi.responses.map { |r| r.params }.reduce({}, :merge) + succeeded = success_from(merged_params) + + Response.new( + succeeded, + message_from(succeeded, merged_params), + merged_params, + authorization: authorization_from(merged_params), + avs_result: avs_result(:purchase, succeeded, merged_params), + cvv_result: cvv_result(:purchase, succeeded, merged_params), + error_code: error_code_from(succeeded, merged_params), + test: test? + ) end def authorize(amount, payment_method, options={}) @@ -98,8 +112,8 @@ def add_customer_data(post, options) address = options[:billing_address] if(address && post[:card]) post[:card][:billingDetails] = {} - post[:card][:billingDetails][:address1] = address[:address1] - post[:card][:billingDetails][:address2] = address[:address2] + post[:card][:billingDetails][:addressLine1] = address[:address1] + post[:card][:billingDetails][:addressLine2] = address[:address2] post[:card][:billingDetails][:city] = address[:city] post[:card][:billingDetails][:state] = address[:state] post[:card][:billingDetails][:country] = address[:country] @@ -125,8 +139,8 @@ def commit(action, post, authorization = nil) authorization: authorization_from(response), error_code: error_code_from(succeeded, response), test: test?, - avs_result: avs_result(action, response), - cvv_result: cvv_result(action, response)) + avs_result: avs_result(action, succeeded, response), + cvv_result: cvv_result(action, succeeded, response)) end def headers @@ -148,12 +162,20 @@ def base_url test? ? test_url : live_url end - def avs_result(action, response) - action == :purchase ? AVSResult.new(code: response["card"]["avsCheck"]) : nil + def avs_result(action, succeeded, response) + if succeeded + action == :purchase ? AVSResult.new(code: response["card"]["avsCheck"]) : nil + else + nil + end end - def cvv_result(action, response) - action == :purchase ? CVVResult.new(response["card"]["cvvCheck"]) : nil + def cvv_result(action, succeeded, response) + if succeeded + action == :purchase ? CVVResult.new(response["card"]["cvvCheck"]) : nil + else + nil + end end def parse(body) diff --git a/test/remote/gateways/remote_checkout_v2_test.rb b/test/remote/gateways/remote_checkout_v2_test.rb index 965f249453f..a9880e7d6b5 100644 --- a/test/remote/gateways/remote_checkout_v2_test.rb +++ b/test/remote/gateways/remote_checkout_v2_test.rb @@ -33,6 +33,21 @@ def test_successful_purchase assert_equal 'Succeeded', response.message end + def test_successful_purchase_includes_avs_result + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Succeeded', response.message + assert_equal 'S', response.avs_result["code"] + assert_equal 'U.S.-issuing bank does not support AVS.', response.avs_result["message"] + end + + def test_successful_purchase_includes_cvv_result + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Succeeded', response.message + assert_equal 'Y', response.cvv_result["code"] + end + def test_successful_purchase_with_descriptors options = @options.merge(descriptor_name: "shop", descriptor_city: "london") response = @gateway.purchase(@amount, @credit_card, options) diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb index b51d265c5b4..739cb40e300 100644 --- a/test/unit/gateways/checkout_v2_test.rb +++ b/test/unit/gateways/checkout_v2_test.rb @@ -18,11 +18,29 @@ def test_successful_purchase end.respond_with(successful_purchase_response) assert_success response - assert_equal 'charge_test_941CA9CE174U76BD29C8', response.authorization assert response.test? end + def test_successful_purchase_includes_avs_result + response = stub_comms do + @gateway.purchase(@amount, @credit_card) + end.respond_with(successful_purchase_response) + + assert_equal 'S', response.avs_result["code"] + assert_equal 'U.S.-issuing bank does not support AVS.', response.avs_result["message"] + assert_equal 'X', response.avs_result["postal_match"] + assert_equal 'X', response.avs_result["street_match"] + end + + def test_successful_purchase_includes_cvv_result + response = stub_comms do + @gateway.purchase(@amount, @credit_card) + end.respond_with(successful_purchase_response) + + assert_equal 'Y', response.cvv_result["code"] + end + def test_purchase_with_additional_fields response = stub_comms do @gateway.purchase(@amount, @credit_card, {descriptor_city: "london", descriptor_name: "sherlock"}) From 5181014f14fd69f8b6b55ecac092c8a4cf149361 Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 16 Oct 2017 16:43:25 -0400 Subject: [PATCH 216/677] EBANX: Pass person_type and name for stored cards Also conditions person_responsible element more correctly, and allows the customer name passed to use the name associated with the billing address when it is not available from the payment method, such as when the payment method is a string for a stored card. Four negative test cases are failing due to changes to test card numbers we have yet to receive an update for. Closes #2621 Unit: 15 tests, 51 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 20 tests, 52 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 80% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/ebanx.rb | 23 ++++++++++++++----- test/remote/gateways/remote_ebanx_test.rb | 18 ++++++++++++++- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 856b91fa376..41727af0c49 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ * Barclaycard Smartpay: Pass street and house_number fields, in addition to standard address [deedeelavinder] #2603 * Payeezy: Adds support for store [deedeelavinder] #2591 * Checkout V2: Expose AVS and CVV results for purchases [dtykocki] #2619 +* EBANX: Pass person_type and name for stored cards [curiousepic] #2621 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb index 7c8af708397..a9700b6ce97 100644 --- a/lib/active_merchant/billing/gateways/ebanx.rb +++ b/lib/active_merchant/billing/gateways/ebanx.rb @@ -139,18 +139,20 @@ def add_authorization(post, authorization) end def add_customer_data(post, payment, options) - post[:payment][:name] = payment.is_a?(String) ? "Not Provided" : payment.name + post[:payment][:name] = customer_name(payment, options) post[:payment][:email] = options[:email] || "unspecified@example.com" post[:payment][:document] = options[:document] post[:payment][:birth_date] = options[:birth_date] if options[:birth_date] end def add_customer_responsible_person(post, payment, options) - return unless (options[:person_type] && options[:person_type].downcase == 'business') && customer_country(options) == 'br' - post[:payment][:responsible] = {} - post[:payment][:responsible][:name] = payment.name - post[:payment][:responsible][:document] = options[:document] - post[:payment][:responsible][:birth_date] = options[:birth_date] if options[:birth_date] + post[:payment][:person_type] = options[:person_type] if options[:person_type] + if options[:person_type] && options[:person_type].downcase == 'business' + post[:payment][:responsible] = {} + post[:payment][:responsible][:name] = customer_name(payment, options) + post[:payment][:responsible][:document] = options[:document] if options[:document] + post[:payment][:responsible][:birth_date] = options[:birth_date] if options[:birth_date] + end end def add_address(post, options) @@ -280,6 +282,15 @@ def customer_country(options) country.downcase end end + + def customer_name(payment, options) + address_name = options[:billing_address][:name] if options[:billing_address] && options[:billing_address][:name] + if payment.is_a?(String) + address_name || "Not Provided" + else + payment.name + end + end end end end diff --git a/test/remote/gateways/remote_ebanx_test.rb b/test/remote/gateways/remote_ebanx_test.rb index 87e9ecd19cd..632108666dd 100644 --- a/test/remote/gateways/remote_ebanx_test.rb +++ b/test/remote/gateways/remote_ebanx_test.rb @@ -32,7 +32,8 @@ def test_successful_purchase_with_more_options order_id: generate_unique_id, ip: "127.0.0.1", email: "joe@example.com", - birth_date: "10/11/1980" + birth_date: "10/11/1980", + person_type: 'personal' }) response = @gateway.purchase(@amount, @credit_card, options) @@ -40,6 +41,12 @@ def test_successful_purchase_with_more_options assert_equal 'Accepted', response.message end + def test_successful_purchase_as_brazil_business_with_cnpj + response = @gateway.purchase(@amount, @credit_card, @options.update(person_type: 'business', document: '32593371000110')) + assert_success response + assert_equal 'Accepted', response.message + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response @@ -127,6 +134,15 @@ def test_successful_store_and_purchase assert_equal 'Accepted', purchase.message end + def test_successful_store_and_purchase_as_brazil_business + store = @gateway.store(@credit_card, @options.update(person_type: 'business', document: '32593371000110')) + assert_success store + + assert purchase = @gateway.purchase(@amount, store.authorization, @options.update(person_type: 'business', document: '32593371000110')) + assert_success purchase + assert_equal 'Accepted', purchase.message + end + def test_failed_purchase_with_stored_card store = @gateway.store(@declined_card, @options) assert_success store From c6c69675827a70138f339bca91e222d0c5e3d850 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Tue, 17 Oct 2017 15:53:39 -0400 Subject: [PATCH 217/677] Barclaycard Smartpay: Allows purchase with no address Closes #2623 Unit tests: 22 tests, 95 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote tests: 26 tests, 52 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- .../billing/gateways/barclaycard_smartpay.rb | 2 +- .../gateways/remote_barclaycard_smartpay_test.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index 95ac68c65a1..8fd42a4cbda 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -33,7 +33,7 @@ def authorize(money, creditcard, options = {}) post = payment_request(money, options) post[:amount] = amount_hash(money, options[:currency]) post[:card] = credit_card_hash(creditcard) - post[:billingAddress] = billing_address_hash(options) + post[:billingAddress] = billing_address_hash(options) if options[:billing_address] post[:deliveryAddress] = shipping_address_hash(options) if options[:shipping_address] commit('authorise', post) end diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index e866452fbcd..3799752011c 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -63,6 +63,13 @@ def setup description: 'Store Purchase' } + @options_with_no_address = { + order_id: '1', + email: 'long@bob.com', + customer: 'Longbob Longsen', + description: 'Store Purchase' + } + @avs_credit_card = credit_card('4400000000000008', :month => 8, :year => 2018, @@ -112,6 +119,14 @@ def test_successful_purchase_with_house_number_and_street assert_equal '[capture-received]', response.message end + def test_successful_purchase_with_no_address + response = @gateway.purchase(@amount, + @credit_card, + @options_with_no_address) + assert_success response + assert_equal '[capture-received]', response.message + end + def test_successful_authorize_and_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth From 1bd9b1e387e7f52d8675c70ce2fb776dcde351ab Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 16 Oct 2017 15:15:23 -0400 Subject: [PATCH 218/677] CyberSource: Support 3DSecure requests 3 remote failures include pinless debit card tests which this commit is not concerned with and a false alarm from overeager scrubbing assertion. Closes #2624 Remote: 39 tests, 180 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 92.3077% passed Unit: 44 tests, 212 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/cyber_source.rb | 2 ++ .../gateways/remote_cyber_source_test.rb | 32 +++++++++++++++++++ test/unit/gateways/cyber_source_test.rb | 21 ++++++++++++ 4 files changed, 56 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 41727af0c49..38715085074 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * Payeezy: Adds support for store [deedeelavinder] #2591 * Checkout V2: Expose AVS and CVV results for purchases [dtykocki] #2619 * EBANX: Pass person_type and name for stored cards [curiousepic] #2621 +* CyberSource: Support 3DSecure requests [curiousepic] #2624 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 8ac9201df0b..72289e5e293 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -258,6 +258,7 @@ def build_auth_request(money, creditcard_or_reference, options) add_decision_manager_fields(xml, options) add_mdd_fields(xml, options) add_auth_service(xml, creditcard_or_reference, options) + xml.tag! 'payerAuthEnrollService', {'run' => 'true'} if options[:payer_auth_enroll_service] add_payment_network_token(xml) if network_tokenization?(creditcard_or_reference) add_business_rules_data(xml, creditcard_or_reference, options) xml.target! @@ -294,6 +295,7 @@ def build_purchase_request(money, payment_method_or_reference, options) add_check_service(xml) else add_purchase_service(xml, payment_method_or_reference, options) + xml.tag! 'payerAuthEnrollService', {'run' => 'true'} if options[:payer_auth_enroll_service] add_payment_network_token(xml) if network_tokenization?(payment_method_or_reference) add_business_rules_data(xml, payment_method_or_reference, options) unless options[:pinless_debit_card] end diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb index 8067a888cb6..cf7f74077a3 100644 --- a/test/remote/gateways/remote_cyber_source_test.rb +++ b/test/remote/gateways/remote_cyber_source_test.rb @@ -9,6 +9,12 @@ def setup @credit_card = credit_card('4111111111111111', verification_value: '321') @declined_card = credit_card('801111111111111') @pinless_debit_card = credit_card('4002269999999999') + @three_ds_enrolled_card = credit_card('4000000000000002', + verification_value: '321', + month: "12", + year: "#{Time.now.year + 2}", + brand: :visa + ) @amount = 100 @@ -363,6 +369,32 @@ def test_successful_retrieve_subscription assert response.test? end + def test_3ds_purchase_request + assert response = @gateway.purchase(1202, @three_ds_enrolled_card, @options.merge(payer_auth_enroll_service: true)) + assert_equal "475", response.params["reasonCode"] + assert !response.params["acsURL"].blank? + assert !response.params["paReq"].blank? + assert !response.params["xid"].blank? + assert !response.success? + end + + def test_3ds_authorize_request + assert response = @gateway.authorize(1202, @three_ds_enrolled_card, @options.merge(payer_auth_enroll_service: true)) + assert_equal "475", response.params["reasonCode"] + assert !response.params["acsURL"].blank? + assert !response.params["paReq"].blank? + assert !response.params["xid"].blank? + assert !response.success? + end + + def test_3ds_transactions_with_unenrolled_card + assert response = @gateway.purchase(1202, @credit_card, @options.merge(payer_auth_enroll_service: true)) + assert response.success? + + assert response = @gateway.authorize(1202, @credit_card, @options.merge(payer_auth_enroll_service: true)) + assert response.success? + end + def test_verify_credentials assert @gateway.verify_credentials diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index 0df3df0a91e..bd59d5ac843 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -446,6 +446,19 @@ def test_malformed_xml_handling assert response.test? end + def test_3ds_response + purchase = stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(payer_auth_enroll_service: true)) + end.check_request do |endpoint, data, headers| + assert_match(/\/, data) + end.respond_with(threedeesecure_purchase_response) + + assert_failure purchase + assert_equal "YTJycDdLR3RIVnpmMXNFejJyazA=", purchase.params["xid"] + assert_equal "eNpVUe9PwjAQ/d6/ghA/r2tBYMvRBEUFFEKQEP1Yu1Om7gfdJoy/3nZsgk2a3Lveu757B+utRhw/oyo0CphjlskPbIXBsC25TvuPD/lkc3xn2d2R6y+3LWA5WuFOwA/qLExiwRzX4UAbSEwLrbYyzgVItbuZLkS353HWA1pDAhHq6Vgw3ule9/pAT5BALCMUqnwznZJCKwRaZQiopIhzXYpB1wXaAAKF/hbbPE8zn9L9fu9cUB2VREBtAQF6FrQsbJSZOQ9hIF7Xs1KNg6dVZzXdxGk0f1nc4+eslMfREKitIBDIHAV3WZ+Z2+Ku3/F8bjRXeQIysmrEFeOOa0yoIYHUfjQ6Icbt02XGTFRojbFqRmoQATykSYymxlD+YjPDWfntxBqrcusg8wbmWGcrXNFD4w3z2IkfVkZRy6H13mi9YhP9W/0vhyyqPw==", purchase.params["paReq"] + assert_equal "https://0eafstag.cardinalcommerce.com/EAFService/jsp/v1/redirect", purchase.params["acsURL"] + end + def test_scrub assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed end @@ -692,6 +705,14 @@ def malformed_xml_response XML end + def threedeesecure_purchase_response + <<-XML + + +2017-10-17T20:39:27.392Z1a5ba4804da54b384c6e8a2d8057ea995082727663166909004012REJECT475AhjzbwSTE4kEGDR65zjsGwFLjtwzsJ0gXLJx6Xb0ky3SA7ek8AYA/A17475https://0eafstag.cardinalcommerce.com/EAFService/jsp/v1/redirecteNpVUe9PwjAQ/d6/ghA/r2tBYMvRBEUFFEKQEP1Yu1Om7gfdJoy/3nZsgk2a3Lveu757B+utRhw/oyo0CphjlskPbIXBsC25TvuPD/lkc3xn2d2R6y+3LWA5WuFOwA/qLExiwRzX4UAbSEwLrbYyzgVItbuZLkS353HWA1pDAhHq6Vgw3ule9/pAT5BALCMUqnwznZJCKwRaZQiopIhzXYpB1wXaAAKF/hbbPE8zn9L9fu9cUB2VREBtAQF6FrQsbJSZOQ9hIF7Xs1KNg6dVZzXdxGk0f1nc4+eslMfREKitIBDIHAV3WZ+Z2+Ku3/F8bjRXeQIysmrEFeOOa0yoIYHUfjQ6Icbt02XGTFRojbFqRmoQATykSYymxlD+YjPDWfntxBqrcusg8wbmWGcrXNFD4w3z2IkfVkZRy6H13mi9YhP9W/0vhyyqPw==1198888YTJycDdLR3RIVnpmMXNFejJyazA=<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&amp;gold=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</url><protocol>ThreeDSecure</protocol></VERes></Message></VEResProof></AuthProof>YENROLLED + XML + end + def assert_xml_valid_to_xsd(data, root_element = '//s:Body/*') schema_file = File.open("#{File.dirname(__FILE__)}/../../schema/cyber_source/CyberSourceTransaction_#{CyberSourceGateway::XSD_VERSION}.xsd") doc = Nokogiri::XML(data) From d0e1b4c93303bb04704f669480c25d364cdc0e7b Mon Sep 17 00:00:00 2001 From: JoseLuis Vilar Date: Fri, 13 Oct 2017 12:58:49 +0200 Subject: [PATCH 219/677] Include DKK as supported currency According to Redsys, DKK maps to code 208, so that's what's set here. Closes #2618 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/redsys.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 38715085074..436493e352f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Redsys: Support the DKK currency type [bpollack] #2618 * Netbanx: Fix basic auth by sending the account_number and api_key [anotherjosmith] #2616 * WePay: Only send ip and device for non-recurring transactions [dtykocki] #2597 * Barclaycard Smartpay: Use authorization pspReference for refunds [davidsantoso] #2599 diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb index 4f936dbd34c..59fe84a73ce 100644 --- a/lib/active_merchant/billing/gateways/redsys.rb +++ b/lib/active_merchant/billing/gateways/redsys.rb @@ -59,6 +59,7 @@ class RedsysGateway < Gateway "COP" => '170', "CRC" => '188', "CZK" => '203', + "DKK" => '208', "DOP" => '214', "EUR" => '978', "GBP" => '826', From 36792b5ea4d2fc58e89ac191151a8b7d4c2a3aeb Mon Sep 17 00:00:00 2001 From: Bart Date: Tue, 24 Oct 2017 16:48:34 -0400 Subject: [PATCH 220/677] Use monotonic clock to measure elapsed time (#2566) The monotonic clock can only move forward and is not subject to changes of the system clock, e.g. corrections due to NTP --- lib/active_merchant/connection.rb | 4 ++-- lib/active_merchant/network_connection_retries.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index 7bd0328bee8..8ef1fcd57cb 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -49,7 +49,7 @@ def initialize(endpoint) end def request(method, body, headers = {}) - request_start = Time.now.to_f + request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC) retry_exceptions(:max_retries => max_retries, :logger => logger, :tag => tag) do begin @@ -89,7 +89,7 @@ def request(method, body, headers = {}) end ensure - info "connection_request_total_time=%.4fs" % [Time.now.to_f - request_start], tag + info "connection_request_total_time=%.4fs" % [Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start], tag end private diff --git a/lib/active_merchant/network_connection_retries.rb b/lib/active_merchant/network_connection_retries.rb index 4793dcf83b6..4248df7ce4b 100644 --- a/lib/active_merchant/network_connection_retries.rb +++ b/lib/active_merchant/network_connection_retries.rb @@ -42,19 +42,19 @@ def retry_network_exceptions(options = {}) request_start = nil begin - request_start = Time.now.to_f + request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = yield - log_with_retry_details(options[:logger], initial_retries-retries + 1, Time.now.to_f - request_start, "success", options[:tag]) + log_with_retry_details(options[:logger], initial_retries-retries + 1, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, "success", options[:tag]) result rescue ActiveMerchant::RetriableConnectionError => e retries -= 1 - log_with_retry_details(options[:logger], initial_retries-retries, Time.now.to_f - request_start, e.message, options[:tag]) + log_with_retry_details(options[:logger], initial_retries-retries, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, e.message, options[:tag]) retry unless retries.zero? raise ActiveMerchant::ConnectionError.new(e.message, e) rescue ActiveMerchant::ConnectionError, ActiveMerchant::InvalidResponseError => e retries -= 1 - log_with_retry_details(options[:logger], initial_retries-retries, Time.now.to_f - request_start, e.message, options[:tag]) + log_with_retry_details(options[:logger], initial_retries-retries, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, e.message, options[:tag]) retry if (options[:retry_safe] || retry_safe) && !retries.zero? raise end From cb07d5ccc45ee7b81b2f5defc0f95bb77d99c5c1 Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Tue, 24 Oct 2017 16:52:53 -0400 Subject: [PATCH 221/677] Release version 1.74.0 --- CHANGELOG | 28 +++++++++++++++------------- lib/active_merchant/version.rb | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 436493e352f..4b55e947449 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,25 +1,27 @@ = ActiveMerchant CHANGELOG == HEAD -* Redsys: Support the DKK currency type [bpollack] #2618 -* Netbanx: Fix basic auth by sending the account_number and api_key [anotherjosmith] #2616 -* WePay: Only send ip and device for non-recurring transactions [dtykocki] #2597 -* Barclaycard Smartpay: Use authorization pspReference for refunds [davidsantoso] #2599 + +== Version 1.74.0 (October 24, 2017) * Adyen: Update list of supported countries [dtykocki] #2600 -* Credorax: Update response codes [curiousepic] #2595 -* Borgun: Add support for USD transactions [dtykocki] #2602 -* Borgun: Include currency code from split authorization for voids [dtykocki] #2605 -* Ebanx: Support Store and person_type option [curiousepic] #2604 -* Elavon: Update endpoint URLs [curiousepic] #2608 -* PayU Latam: Set payment_country gateway attribute [curiousepic] #2611 * Authorize.net CIM: Handle multiple error messages [amandapuff] #2537 +* Barclaycard Smartpay: Pass street and house_number fields, in addition to standard address [deedeelavinder] #2603 +* Barclaycard Smartpay: Use authorization pspReference for refunds [davidsantoso] #2599 * Beanstream: Pass email fields without address [curiousepic] #2615 * Beanstream: Support recurringPayment for auth, capture, and purchase transactions [dtykocki] #2617 -* Barclaycard Smartpay: Pass street and house_number fields, in addition to standard address [deedeelavinder] #2603 -* Payeezy: Adds support for store [deedeelavinder] #2591 +* Borgun: Add support for USD transactions [dtykocki] #2602 +* Borgun: Include currency code from split authorization for voids [dtykocki] #2605 * Checkout V2: Expose AVS and CVV results for purchases [dtykocki] #2619 -* EBANX: Pass person_type and name for stored cards [curiousepic] #2621 +* Credorax: Update response codes [curiousepic] #2595 * CyberSource: Support 3DSecure requests [curiousepic] #2624 +* Ebanx: Pass person_type and name for stored cards [curiousepic] #2621 +* Ebanx: Support Store and person_type option [curiousepic] #2604 +* Elavon: Update endpoint URLs [curiousepic] #2608 +* Netbanx: Fix basic auth by sending the account_number and api_key [anotherjosmith] #2616 +* Payeezy: Adds support for store [deedeelavinder] #2591 +* PayU Latam: Set payment_country gateway attribute [curiousepic] #2611 +* Redsys: Support the DKK currency type [bpollack] #2618 +* WePay: Only send ip and device for non-recurring transactions [dtykocki] #2597 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 8cb7562fef6..ca079789036 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.73.0" + VERSION = "1.74.0" end From d0bf09a45c236e1606549598187289a6cd729dd1 Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Thu, 26 Oct 2017 10:05:10 -0400 Subject: [PATCH 222/677] FirstData E4 (Payeezy): Ensure numeric ECI values are zero padded (#2630) --- CHANGELOG | 1 + .../billing/gateways/firstdata_e4.rb | 2 +- test/unit/gateways/firstdata_e4_test.rb | 20 +++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 4b55e947449..51642b546f0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* FirstData E4 (Payeezy): Ensure numeric ECI values are zero padded [jasonwebster] #2630 == Version 1.74.0 (October 24, 2017) * Adyen: Update list of supported countries [dtykocki] #2600 diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index 985bc6449f2..9623681100f 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -238,7 +238,7 @@ def add_credit_card(xml, credit_card, options) xml.tag! "CardType", card_type(credit_card.brand) eci = (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI - xml.tag! "Ecommerce_Flag", eci + xml.tag! "Ecommerce_Flag", eci.to_s =~ /^[0-9]+$/ ? eci.to_s.rjust(2, '0') : eci add_credit_card_verification_strings(xml, credit_card, options) end diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb index 2e84b379689..64c6d9222e3 100755 --- a/test/unit/gateways/firstdata_e4_test.rb +++ b/test/unit/gateways/firstdata_e4_test.rb @@ -190,6 +190,26 @@ def test_eci_default_value end.respond_with(successful_purchase_response) end + def test_eci_numeric_padding + @credit_card = network_tokenization_credit_card + @credit_card.eci = "5" + + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match "05", data + end.respond_with(successful_purchase_response) + + @credit_card = network_tokenization_credit_card + @credit_card.eci = 5 + + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match "05", data + end.respond_with(successful_purchase_response) + end + def test_eci_option_value stub_comms do @gateway.purchase(@amount, @credit_card, @options.merge(eci: "05")) From dcbde8cbaf1b0bde3e5630e761d548b48ecf3a5e Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Wed, 25 Oct 2017 18:06:52 -0400 Subject: [PATCH 223/677] Support extra data for Barclay Smartcard credits Barclays Smartcard will be requiring credits that lack a PSP to include four additional pieces of information: the date-of-birth, entity type, nationality, and full name of the person requesting the credit. This change enables including them for credit requests. --- .../billing/gateways/barclaycard_smartpay.rb | 4 ++ .../remote_barclaycard_smartpay_test.rb | 33 +++++++++++++++- .../gateways/barclaycard_smartpay_test.rb | 39 +++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index 8fd42a4cbda..731501f64d1 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -60,6 +60,10 @@ def credit(money, creditcard, options = {}) post = payment_request(money, options) post[:amount] = amount_hash(money, options[:currency]) post[:card] = credit_card_hash(creditcard) + post[:dateOfBirth] = options[:date_of_birth] if options[:date_of_birth] + post[:entityType] = options[:entity_type] if options[:entity_type] + post[:nationality] = options[:nationality] if options[:nationality] + post[:shopperName] = options[:shopper_name] if options[:shopper_name] commit('refundWithData', post) end diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index 3799752011c..dcb330808a0 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -70,6 +70,31 @@ def setup 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'}, + email: 'long@bob.com', + customer: 'Longbob Longsen', + description: 'Store Purchase', + date_of_birth: '1990-10-11', + entity_type: 'NaturalPerson', + nationality: 'US', + shopper_name: { + firstName: 'Longbob', + lastName: 'Longsen', + gender: 'MALE' + } + } + @avs_credit_card = credit_card('4400000000000008', :month => 8, :year => 2018, @@ -175,7 +200,7 @@ def test_failed_refund end def test_successful_credit - response = @gateway.credit(@amount, @credit_card, @options) + response = @gateway.credit(@amount, @credit_card, @options_with_credit_fields) assert_success response end @@ -184,6 +209,12 @@ def test_failed_credit assert_failure response end + def test_failed_credit_insufficient_validation + # This test will fail currently (the credit will succeed), but it should succeed after October 29th + # response = @gateway.credit(@amount, @credit_card, @options) + # assert_failure response + end + def test_successful_void auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb index 486c6df657b..c314f8b2244 100644 --- a/test/unit/gateways/barclaycard_smartpay_test.rb +++ b/test/unit/gateways/barclaycard_smartpay_test.rb @@ -64,6 +64,31 @@ def setup 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'}, + email: 'long@bob.com', + customer: 'Longbob Longsen', + description: 'Store Purchase', + date_of_birth: '1990-10-11', + entity_type: 'NaturalPerson', + nationality: 'US', + shopper_name: { + firstName: 'Longbob', + lastName: 'Longsen', + gender: 'MALE' + } + } + @avs_address = @options @avs_address.update(billing_address: { name: 'Jim Smith', @@ -210,6 +235,20 @@ def test_failed_credit assert_failure response end + def test_credit_contains_all_fields + response = stub_comms do + @gateway.credit(@amount, @credit_card, @options_with_credit_fields) + end.check_request do |endpoint, data, headers| + assert_match(/dateOfBirth=1990-10-11&/, data) + assert_match(/entityType=NaturalPerson&/, data) + assert_match(/nationality=US&/, data) + assert_match(/shopperName.firstName=Longbob&/, data) + end.respond_with(successful_credit_response) + + assert_success response + assert response.test? + end + def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) From 2568a21054fc397b1d63b380d623ef1160b13ae8 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Fri, 27 Oct 2017 19:00:27 -0400 Subject: [PATCH 224/677] PayU Latam: Four small updates 1) Adds `partnerId`. 2) Ensures phone_number is passed to 'buyer.contactPhone' and prefers billing phone over shipping phone. 3) Sends empty field for 'ip_address' when none supplied. 4) Ensures 'creditCard.secutiryCode' node is not included when there is no 'cvv'. Closes #2634 Remote Tests: (Includes 5 failing tests on master: 2 'INTERNAL_PAYMENT_PROVIDER_ERROR' and 3 'DECLINED_TEST_MODE_NOT_ALLOWED'.) 18 tests, 45 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 72.2222% passed Unit Tests: 24 tests, 94 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 2 ++ .../billing/gateways/payu_latam.rb | 16 +++++----------- test/unit/gateways/payu_latam_test.rb | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 51642b546f0..1870000218f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,8 @@ * PayU Latam: Set payment_country gateway attribute [curiousepic] #2611 * Redsys: Support the DKK currency type [bpollack] #2618 * WePay: Only send ip and device for non-recurring transactions [dtykocki] #2597 +* PayU Latam: Adds `partnerID`, adjusts phone preferences, allows empty `ip_address`, and adjusts for no `cvv` +* [deedeelavinder] #2634 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index 6dcfa83384c..634bc452de9 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -141,7 +141,7 @@ def add_transaction_elements(post, type, options) transaction = {} transaction[:paymentCountry] = @options[:payment_country] || (options[:billing_address][:country] if options[:billing_address]) transaction[:type] = type - transaction[:ipAddress] = options[:ip] if options[:ip] + transaction[:ipAddress] = options[:ip] || '' transaction[:userAgent] = options[:user_agent] if options[:user_agent] transaction[:cookie] = options[:cookie] if options[:cookie] transaction[:deviceSessionId] = options[:device_session_id] if options[:device_session_id] @@ -151,6 +151,7 @@ def add_transaction_elements(post, type, options) def add_order(post, options) order = {} order[:accountId] = @options[:account_id] + order[:partnerId] = options[:partnerId] if options[:partnerId] order[:referenceCode] = options[:order_id] || generate_unique_id order[:description] = options[:description] || 'unspecified' order[:language] = 'en' @@ -192,7 +193,7 @@ def add_buyer(post, payment_method, options) buyer[:dniType] = buyer_hash[:dni_type] buyer[:cnpj] = buyer_hash[:cnpj] if options[:payment_country] == 'BR' buyer[:emailAddress] = buyer_hash[:email] - buyer[:contactPhone] = options[:shipping_address][:phone] if options[:shipping_address] + buyer[:contactPhone] = (options[:billing_address][:phone] if options[:billing_address]) || (options[:shipping_address][:phone] if options[:shipping_address]) || '' buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address] else buyer[:fullName] = payment_method.name.strip @@ -200,7 +201,7 @@ def add_buyer(post, payment_method, options) buyer[:dniType] = options[:dni_type] buyer[:cnpj] = options[:cnpj] if options[:payment_country] == 'BR' buyer[:emailAddress] = options[:email] - buyer[:contactPhone] = (options[:shipping_address][:phone] if options[:shipping_address]) || (options[:billing_address][:phone] if options[:billing_address]) + buyer[:contactPhone] = (options[:billing_address][:phone] if options[:billing_address]) || (options[:shipping_address][:phone] if options[:shipping_address]) || '' buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address] end post[:transaction][:order][:buyer] = buyer @@ -268,7 +269,7 @@ def add_payment_method(post, payment_method, options) else credit_card = {} credit_card[:number] = payment_method.number - credit_card[:securityCode] = add_security_code(payment_method, options) + credit_card[:securityCode] = payment_method.verification_value || options[:cvv] credit_card[:expirationDate] = format(payment_method.year, :four_digits).to_s + '/' + format(payment_method.month, :two_digits).to_s credit_card[:name] = payment_method.name.strip credit_card[:processWithoutCvv2] = true if add_process_without_cvv2(payment_method, options) @@ -277,13 +278,6 @@ def add_payment_method(post, payment_method, options) end end - def add_security_code(payment_method, options) - return payment_method.verification_value unless payment_method.verification_value.blank? - return options[:cvv] unless options[:cvv].blank? - return "0000" if BRAND_MAP[payment_method.brand.to_s] == "AMEX" - "000" - end - def add_process_without_cvv2(payment_method, options) return true if payment_method.verification_value.blank? && options[:cvv].blank? false diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb index 52628e33621..160a7642f11 100644 --- a/test/unit/gateways/payu_latam_test.rb +++ b/test/unit/gateways/payu_latam_test.rb @@ -196,7 +196,7 @@ def test_partial_buyer_hash_info stub_comms do @gateway.purchase(@amount, @credit_card, @options.update(options_buyer)) end.check_request do |endpoint, data, headers| - assert_match(/\"buyer\":{\"fullName\":\"Jorge Borges\",\"dniNumber\":\"5415668464456\",\"dniType\":null,\"emailAddress\":\"axaxaxas@mlo.org\",\"contactPhone\":\"\(11\)756312345\",\"shippingAddress\":{\"street1\":\"Calle 200\",\"street2\":\"N107\",\"city\":\"Sao Paulo\",\"state\":\"SP\",\"country\":\"BR\",\"postalCode\":\"01019-030\",\"phone\":\"\(11\)756312345\"}}/, data) + assert_match(/\"buyer\":{\"fullName\":\"Jorge Borges\",\"dniNumber\":\"5415668464456\",\"dniType\":null,\"emailAddress\":\"axaxaxas@mlo.org\",\"contactPhone\":\"7563126\",\"shippingAddress\":{\"street1\":\"Calle 200\",\"street2\":\"N107\",\"city\":\"Sao Paulo\",\"state\":\"SP\",\"country\":\"BR\",\"postalCode\":\"01019-030\",\"phone\":\"\(11\)756312345\"}}/, data) end.respond_with(successful_purchase_response) end From 0492749097ac00db3f0f58e0cbc3294eb7548cc7 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Thu, 26 Oct 2017 09:16:28 -0400 Subject: [PATCH 225/677] Shallow copy the options hash for Barclays tests The intent in the tests was clearly to create a *distinct* options array, but what actually happened is that the original options array was modified. This patch causes the code to do the intended behavior. (Interestingly, this doesn't alter any test passes or failures, because having extra data doesn't upset either the unit tests or remote tests.) --- test/remote/gateways/remote_barclaycard_smartpay_test.rb | 2 +- test/unit/gateways/barclaycard_smartpay_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index dcb330808a0..9d39afcb86a 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -100,7 +100,7 @@ def setup :year => 2018, :verification_value => 737) - @avs_address = @options + @avs_address = @options.clone @avs_address.update(billing_address: { name: 'Jim Smith', street: 'Test AVS result', diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb index c314f8b2244..1d399883d7c 100644 --- a/test/unit/gateways/barclaycard_smartpay_test.rb +++ b/test/unit/gateways/barclaycard_smartpay_test.rb @@ -89,7 +89,7 @@ def setup } } - @avs_address = @options + @avs_address = @options.clone @avs_address.update(billing_address: { name: 'Jim Smith', street: 'Test AVS result', From 43be090d365ad0611d779562b8c588f2283fcef8 Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 30 Oct 2017 16:50:50 -0400 Subject: [PATCH 226/677] Ebanx: Pass fields for business person responsible Also cleans up changelog. Closes #2635 Four negative test cases are failing due to changes to test card numbers we have yet to receive an update for. Remote: 20 tests, 52 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 80% passed Unit: 15 tests, 51 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 6 ++++-- lib/active_merchant/billing/gateways/ebanx.rb | 6 +++--- test/remote/gateways/remote_ebanx_test.rb | 20 +++++++++++++++---- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1870000218f..6ce08dc3f05 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,10 @@ == HEAD * FirstData E4 (Payeezy): Ensure numeric ECI values are zero padded [jasonwebster] #2630 +* Barclaycard Smartpay: Extra data fields for credits [bpollack] #2631 +* PayU Latam: Adds `partnerID`, adjusts phone preferences, allows empty `ip_address`, and adjusts for no `cvv` [deedeelavinder] #2634 +* Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 +* Ebanx: Pass fields for business person responsible [curiousepic] #2635 == Version 1.74.0 (October 24, 2017) * Adyen: Update list of supported countries [dtykocki] #2600 @@ -23,8 +27,6 @@ * PayU Latam: Set payment_country gateway attribute [curiousepic] #2611 * Redsys: Support the DKK currency type [bpollack] #2618 * WePay: Only send ip and device for non-recurring transactions [dtykocki] #2597 -* PayU Latam: Adds `partnerID`, adjusts phone preferences, allows empty `ip_address`, and adjusts for no `cvv` -* [deedeelavinder] #2634 == Version 1.73.0 (September 28, 2017) * Adyen: Use original authorization pspReference on Refunds [lyverovski] #2589 diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb index a9700b6ce97..1aa4f101126 100644 --- a/lib/active_merchant/billing/gateways/ebanx.rb +++ b/lib/active_merchant/billing/gateways/ebanx.rb @@ -149,9 +149,9 @@ def add_customer_responsible_person(post, payment, options) post[:payment][:person_type] = options[:person_type] if options[:person_type] if options[:person_type] && options[:person_type].downcase == 'business' post[:payment][:responsible] = {} - post[:payment][:responsible][:name] = customer_name(payment, options) - post[:payment][:responsible][:document] = options[:document] if options[:document] - post[:payment][:responsible][:birth_date] = options[:birth_date] if options[:birth_date] + post[:payment][:responsible][:name] = options[:responsible_name] if options[:responsible_name] + post[:payment][:responsible][:document] = options[:responsible_document] if options[:responsible_document] + post[:payment][:responsible][:birth_date] = options[:responsible_birth_date] if options[:responsible_birth_date] end end diff --git a/test/remote/gateways/remote_ebanx_test.rb b/test/remote/gateways/remote_ebanx_test.rb index 632108666dd..8408ed194b8 100644 --- a/test/remote/gateways/remote_ebanx_test.rb +++ b/test/remote/gateways/remote_ebanx_test.rb @@ -41,8 +41,14 @@ def test_successful_purchase_with_more_options assert_equal 'Accepted', response.message end - def test_successful_purchase_as_brazil_business_with_cnpj - response = @gateway.purchase(@amount, @credit_card, @options.update(person_type: 'business', document: '32593371000110')) + def test_successful_purchase_as_brazil_business_with_responsible_fields + options = @options.update(document: "32593371000110", + person_type: 'business', + responsible_name: 'Business Person', + responsible_document: '32593371000111', + responsible_birth_date: "1/11/1975") + + response = @gateway.purchase(@amount, @credit_card, options) assert_success response assert_equal 'Accepted', response.message end @@ -135,10 +141,16 @@ def test_successful_store_and_purchase end def test_successful_store_and_purchase_as_brazil_business - store = @gateway.store(@credit_card, @options.update(person_type: 'business', document: '32593371000110')) + options = @options.update(document: "32593371000110", + person_type: 'business', + responsible_name: 'Business Person', + responsible_document: '32593371000111', + responsible_birth_date: "1/11/1975") + + store = @gateway.store(@credit_card, options) assert_success store - assert purchase = @gateway.purchase(@amount, store.authorization, @options.update(person_type: 'business', document: '32593371000110')) + assert purchase = @gateway.purchase(@amount, store.authorization, options) assert_success purchase assert_equal 'Accepted', purchase.message end From 4c07a88589e716ae17cbe07439db695c41b66c64 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Tue, 31 Oct 2017 09:00:34 -0400 Subject: [PATCH 227/677] Support Colombia with Ebanx This required no implementation changes to support, but, since Ebanx allows only one country per email address, and since each country is slightly different, I did go ahead and add an explicit test just for Colombia--which does now pass. Note that the four tests identified as failing in #2635 still fail, for the same reason, but the new test succeeds. ENRG-7030 Closes #2636 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/ebanx.rb | 2 +- test/remote/gateways/remote_ebanx_test.rb | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 6ce08dc3f05..131db14450a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * PayU Latam: Adds `partnerID`, adjusts phone preferences, allows empty `ip_address`, and adjusts for no `cvv` [deedeelavinder] #2634 * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 * Ebanx: Pass fields for business person responsible [curiousepic] #2635 +* Ebanx: Support Colombian transactions [bpollack] #2636 == Version 1.74.0 (October 24, 2017) * Adyen: Update list of supported countries [dtykocki] #2600 diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb index 1aa4f101126..2a334766823 100644 --- a/lib/active_merchant/billing/gateways/ebanx.rb +++ b/lib/active_merchant/billing/gateways/ebanx.rb @@ -4,7 +4,7 @@ class EbanxGateway < Gateway self.test_url = 'https://sandbox.ebanx.com/ws/' self.live_url = 'https://api.ebanx.com/ws/' - self.supported_countries = ['BR', 'MX'] + self.supported_countries = ['BR', 'MX', 'CO'] self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club] diff --git a/test/remote/gateways/remote_ebanx_test.rb b/test/remote/gateways/remote_ebanx_test.rb index 8408ed194b8..2e50ced72b0 100644 --- a/test/remote/gateways/remote_ebanx_test.rb +++ b/test/remote/gateways/remote_ebanx_test.rb @@ -53,6 +53,27 @@ def test_successful_purchase_as_brazil_business_with_responsible_fields assert_equal 'Accepted', response.message end + def test_successful_purchase_as_colombian + options = @options.merge({ + order_id: generate_unique_id, + ip: "127.0.0.1", + email: "jose@example.com.co", + birth_date: "10/11/1980", + billing_address: address({ + address1: '1040 Rua E', + city: 'Medellín', + state: 'AN', + zip: '29269', + country: 'CO', + phone_number: '8522847035' + }) + }) + + response = @gateway.purchase(500, @credit_card, options) + assert_success response + assert_equal 'Accepted', response.message + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response From 3aba38f980a1733619e6384e1c57ff57ffdbf168 Mon Sep 17 00:00:00 2001 From: David Perry Date: Thu, 2 Nov 2017 10:34:21 -0400 Subject: [PATCH 228/677] Sage Payment Solutions: Scrub check info Bank account and routing numbers, and SSN were not being scrubbed. Closes #2639 Unit: 21 tests, 189 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 27 tests, 94 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/sage.rb | 3 ++ test/remote/gateways/remote_sage_test.rb | 11 +++++ test/unit/gateways/sage_test.rb | 48 ++++++++++++++++++++ 4 files changed, 63 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 131db14450a..7a64921772c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 * Ebanx: Pass fields for business person responsible [curiousepic] #2635 * Ebanx: Support Colombian transactions [bpollack] #2636 +* Sage Payment Solutions: Scrub check info [curiousepic] #2639 == Version 1.74.0 (October 24, 2017) * Adyen: Update list of supported countries [dtykocki] #2600 diff --git a/lib/active_merchant/billing/gateways/sage.rb b/lib/active_merchant/billing/gateways/sage.rb index b1a10a02c8e..3841615c7a2 100644 --- a/lib/active_merchant/billing/gateways/sage.rb +++ b/lib/active_merchant/billing/gateways/sage.rb @@ -102,6 +102,9 @@ def scrub(transcript) gsub(%r((M_key=)[^&]*), '\1[FILTERED]'). gsub(%r((C_cardnumber=)[^&]*), '\1[FILTERED]'). gsub(%r((C_cvv=)[^&]*), '\1[FILTERED]'). + gsub(%r((C_rte=)[^&]*), '\1[FILTERED]'). + gsub(%r((C_acct=)[^&]*), '\1[FILTERED]'). + gsub(%r((C_ssn=)[^&]*), '\1[FILTERED]'). gsub(%r(().+()), '\1[FILTERED]\2'). gsub(%r(().+()), '\1[FILTERED]\2'). gsub(%r(().+()), '\1[FILTERED]\2') diff --git a/test/remote/gateways/remote_sage_test.rb b/test/remote/gateways/remote_sage_test.rb index 4f688dc2e9d..f68f0767829 100644 --- a/test/remote/gateways/remote_sage_test.rb +++ b/test/remote/gateways/remote_sage_test.rb @@ -221,4 +221,15 @@ def test_transcript_scrubbing_store assert_scrubbed(@gateway.options[:password], transcript) end + def test_echeck_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @check, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@check.account_number, transcript) + assert_scrubbed(@check.routing_number, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end + end diff --git a/test/unit/gateways/sage_test.rb b/test/unit/gateways/sage_test.rb index 527fbc68d4c..314490ed87a 100644 --- a/test/unit/gateways/sage_test.rb +++ b/test/unit/gateways/sage_test.rb @@ -316,6 +316,7 @@ def test_failed_unstore def test_scrub assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + assert_equal @gateway.scrub(pre_scrubbed_echeck), post_scrubbed_echeck end def test_supports_scrubbing? @@ -488,4 +489,51 @@ def post_scrubbed Conn close POST_SCRUBBED end + + def pre_scrubbed_echeck + <<-PRE_SCRUBBED +opening connection to www.sagepayments.net:443... +opened +starting SSL for www.sagepayments.net:443... +SSL established +<- "POST /cgi-bin/eftVirtualCheck.dll?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: www.sagepayments.net\r\nContent-Length: 562\r\n\r\n" +<- "C_first_name=Jim&C_last_name=Smith&C_rte=244183602&C_acct=15378535&C_check_number=1&C_acct_type=DDA&C_customer_type=WEB&C_originator_id=&T_addenda=&C_ssn=&C_dl_state_code=&C_dl_number=&C_dob=&T_amt=1.00&T_ordernum=0ac6fd1f74a98de94bf9&C_address=456+My+Street&C_city=Ottawa&C_state=ON&C_zip=K1C2N6&C_country=CA&C_telephone=%28555%29555-5555&C_fax=%28555%29555-6666&C_email=longbob%40example.com&C_ship_name=Jim+Smith&C_ship_address=456+My+Street&C_ship_city=Ottawa&C_ship_state=ON&C_ship_zip=K1C2N6&C_ship_country=CA&M_id=562313162894&M_key=J6U9B3G2F6L3&T_code=01" +-> "HTTP/1.1 200 OK\r\n" +-> "Cache-Control: no-cache\r\n" +-> "Pragma: no-cache\r\n" +-> "Transfer-Encoding: chunked\r\n" +-> "Content-Type: text/html; charset=us-ascii\r\n" +-> "Content-Encoding: gzip\r\n" +-> "Expires: -1\r\n" +-> "Vary: Accept-Encoding\r\n" +-> "Server: Microsoft-IIS/7.5\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "Date: Thu, 02 Nov 2017 13:26:30 GMT\r\n" +-> "Connection: close\r\n" +-> "\r\n" +-> "ac\r\n" +reading 172 bytes... +-> "\x1F\x8B\b\x00\x00\x00\x00\x00\x04\x00\xED\xBD\a`\x1CI\x96%&/m\xCA{\x7FJ\xF5J\xD7\xE0t\xA1\b\x80`\x13$\xD8\x90@\x10\xEC\xC1\x88\xCD\xE6\x92\xEC\x1DiG#)\xAB*\x81\xCAeVe]f\x16@\xCC\xED\x9D\xBC\xF7\xDE{\xEF\xBD\xF7\xDE{\xEF\xBD\xF7\xBA;\x9DN'\xF7\xDF\xFF?\\fd\x01l\xF6\xCEJ\xDA\xC9\x9E!\x80\xAA\xC8\x1F?~|\x1F?\"~\xAD\xE3\x94\x9F\xE3\x93\x93\xD3\x97oN\x9F\xD2\xAF\xD1gg\xE7\xD9\x93\xBDo?\xFC\x89\xAF\x16\xF7v~\xA7\x9Dl\xFA\xE9\xF9l\xF7\xFC\xC1~\xF6\xF0`\x96?\xDC\x9F\x9C?\xFC\x9Dv~\xA7\x17_\xBE8\xA5\x1F\xBF" +read 172 bytes +reading 2 bytes... +-> "\r\n" +read 2 bytes +-> "b\r\n" +reading 11 bytes... +-> "\xF6\xFF\x03\x90\xEB\x1E T\x00\x00\x00" +read 11 bytes +reading 2 bytes... +-> "\r\n" +read 2 bytes +-> "0\r\n" +-> "\r\n" +Conn close + PRE_SCRUBBED + end + + def post_scrubbed_echeck + <<-POST_SCRUBBED +opening connection to www.sagepayments.net:443...\nopened\nstarting SSL for www.sagepayments.net:443...\nSSL established\n<- \"POST /cgi-bin/eftVirtualCheck.dll?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: www.sagepayments.net\r\nContent-Length: 562\r\n\r\n\"\n<- \"C_first_name=Jim&C_last_name=Smith&C_rte=[FILTERED]&C_acct=[FILTERED]&C_check_number=1&C_acct_type=DDA&C_customer_type=WEB&C_originator_id=&T_addenda=&C_ssn=[FILTERED]&C_dl_state_code=&C_dl_number=&C_dob=&T_amt=1.00&T_ordernum=0ac6fd1f74a98de94bf9&C_address=456+My+Street&C_city=Ottawa&C_state=ON&C_zip=K1C2N6&C_country=CA&C_telephone=%28555%29555-5555&C_fax=%28555%29555-6666&C_email=longbob%40example.com&C_ship_name=Jim+Smith&C_ship_address=456+My+Street&C_ship_city=Ottawa&C_ship_state=ON&C_ship_zip=K1C2N6&C_ship_country=CA&M_id=[FILTERED]&M_key=[FILTERED]&T_code=01\"\n-> \"HTTP/1.1 200 OK\r\n\"\n-> \"Cache-Control: no-cache\r\n\"\n-> \"Pragma: no-cache\r\n\"\n-> \"Transfer-Encoding: chunked\r\n\"\n-> \"Content-Type: text/html; charset=us-ascii\r\n\"\n-> \"Content-Encoding: gzip\r\n\"\n-> \"Expires: -1\r\n\"\n-> \"Vary: Accept-Encoding\r\n\"\n-> \"Server: Microsoft-IIS/7.5\r\n\"\n-> \"X-Powered-By: ASP.NET\r\n\"\n-> \"Date: Thu, 02 Nov 2017 13:26:30 GMT\r\n\"\n-> \"Connection: close\r\n\"\n-> \"\r\n\"\n-> \"ac\r\n\"\nreading 172 bytes...\n-> \"\u001F?\b\u0000\u0000\u0000\u0000\u0000\u0004\u0000??\a`\u001CI?%&/m?{\u007FJ?J??t?\b?`\u0013$?@\u0010??????\u001DiG#)?*??eVe]f\u0016@????{???{???;?N'????\\fd\u0001l??J??!???\u001F?~|\u001F?\"~????oN???gg???o????\u0016?v~??l???l???~??`???????v~?\u0017_?8?\u001F?\"\nread 172 bytes\nreading 2 bytes...\n-> \"\r\n\"\nread 2 bytes\n-> \"b\r\n\"\nreading 11 bytes...\n-> \"??\u0003??\u001E T\u0000\u0000\u0000\"\nread 11 bytes\nreading 2 bytes...\n-> \"\r\n\"\nread 2 bytes\n-> \"0\r\n\"\n-> \"\r\n\"\nConn close + POST_SCRUBBED + end end From 42e69f44390d7e7532574d6bcbbb6f597ddc0b0d Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Thu, 2 Nov 2017 18:12:50 -0400 Subject: [PATCH 229/677] Worldpay US: Allow requesting use of backup URL In the case a Worldpay US transaction fails, clients should reattempt on the backup URL. This change allows them to do so by instantiating a copy of the gateway with `use_backup_url` set to a truthy value. Furthers ENRG-6747 Closes #2641 --- CHANGELOG | 1 + .../billing/gateways/worldpay_us.rb | 11 +++++++++-- test/remote/gateways/remote_worldpay_us_test.rb | 7 +++++++ test/unit/gateways/worldpay_us_test.rb | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7a64921772c..733da04cc42 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * Ebanx: Pass fields for business person responsible [curiousepic] #2635 * Ebanx: Support Colombian transactions [bpollack] #2636 * Sage Payment Solutions: Scrub check info [curiousepic] #2639 +* Worldbank US: Allow using the backup URL [bpollack] #2641 == Version 1.74.0 (October 24, 2017) * Adyen: Update list of supported countries [dtykocki] #2600 diff --git a/lib/active_merchant/billing/gateways/worldpay_us.rb b/lib/active_merchant/billing/gateways/worldpay_us.rb index e66901e376e..5771cb97944 100644 --- a/lib/active_merchant/billing/gateways/worldpay_us.rb +++ b/lib/active_merchant/billing/gateways/worldpay_us.rb @@ -3,11 +3,14 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class WorldpayUsGateway < Gateway + class_attribute :backup_url + self.display_name = "Worldpay US" self.homepage_url = "http://www.worldpay.com/us" # No sandbox, just use test cards. - self.live_url = 'https://trans.worldpay.us/cgi-bin/process.cgi' + self.live_url = 'https://trans.worldpay.us/cgi-bin/process.cgi' + self.backup_url = 'https://trans.gwtx01.com/cgi-bin/process.cgi' self.supported_countries = ['US'] self.default_currency = 'USD' @@ -71,6 +74,10 @@ def verify(credit_card, options={}) private + def url + @options[:use_backup_url] ? self.backup_url : self.live_url + end + def add_customer_data(post, options) if(billing_address = (options[:billing_address] || options[:address])) post[:ci_companyname] = billing_address[:company] @@ -170,7 +177,7 @@ def commit(action, post) post[:authonly] = '1' if action == 'authorize' - raw = parse(ssl_post(live_url, post.to_query)) + raw = parse(ssl_post(url, post.to_query)) succeeded = success_from(raw['result']) Response.new( diff --git a/test/remote/gateways/remote_worldpay_us_test.rb b/test/remote/gateways/remote_worldpay_us_test.rb index d9e786ff3d4..933127f769e 100644 --- a/test/remote/gateways/remote_worldpay_us_test.rb +++ b/test/remote/gateways/remote_worldpay_us_test.rb @@ -22,6 +22,13 @@ def test_successful_purchase assert_equal 'Succeeded', response.message end + def test_successful_purchase_on_backup_url + gateway = WorldpayUsGateway.new(fixtures(:worldpay_us).merge({ use_backup_url: true})) + response = gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Succeeded', response.message + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response diff --git a/test/unit/gateways/worldpay_us_test.rb b/test/unit/gateways/worldpay_us_test.rb index 63b0ea6ab8c..ec50c2b0054 100644 --- a/test/unit/gateways/worldpay_us_test.rb +++ b/test/unit/gateways/worldpay_us_test.rb @@ -175,6 +175,21 @@ def test_empty_response_fails assert_equal "Unable to read error message", response.message end + def test_backup_url + gateway = WorldpayUsGateway.new( + acctid: 'acctid', + subid: 'subid', + merchantpin: 'merchantpin', + use_backup_url: true + ) + response = stub_comms(gateway) do + gateway.purchase(@amount, @credit_card, use_backup_url: true) + end.check_request do |endpoint, data, headers| + assert_equal WorldpayUsGateway.backup_url, endpoint + end.respond_with(successful_purchase_response) + assert_success response + end + private def successful_purchase_response From 16a736d83202fdab755071f962efe8f6765b6f66 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Mon, 6 Nov 2017 17:10:11 -0500 Subject: [PATCH 230/677] Payu Latam: Changes partnerID to partner_id in options Remote Tests: (Includes 5 failing tests on master: 2 'INTERNAL_PAYMENT_PROVIDER_ERROR' and 3 'DECLINED_TEST_MODE_NOT_ALLOWED'.) 18 tests, 45 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 72.2222% passed Unit Tests: 24 tests, 94 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/payu_latam.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index 634bc452de9..aa35628d232 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -151,7 +151,7 @@ def add_transaction_elements(post, type, options) def add_order(post, options) order = {} order[:accountId] = @options[:account_id] - order[:partnerId] = options[:partnerId] if options[:partnerId] + order[:partnerId] = options[:partner_id] if options[:partner_id] order[:referenceCode] = options[:order_id] || generate_unique_id order[:description] = options[:description] || 'unspecified' order[:language] = 'en' From c74eddeb9eeaa71ae984bc0d2b92e513d26f3771 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Fri, 27 Oct 2017 17:33:18 -0400 Subject: [PATCH 231/677] Cyber Source: Correctly identifies 'subscriptionID' for store 'subscriptionID' is required to authorize store. Previously 'requestID' was used to populate the 'subscriptionID'. In the sandbox, they yield identical values. In production, however, they are two different values. This correctly captures the 'subscriptionID' separately from the 'requestID'. Closes #2633 Remote Tests: (Includes 2 failing tests on master regarding pinless_debit_cards. The code for pinless_debit_cards does not currently run.) 39 tests, 181 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 94.8718% passed Unit Tests: 44 tests, 212 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/cyber_source.rb | 9 +++++++-- test/remote/gateways/remote_cyber_source_test.rb | 2 +- test/unit/gateways/cyber_source_test.rb | 6 +++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 733da04cc42..0e5d380738e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * Ebanx: Support Colombian transactions [bpollack] #2636 * Sage Payment Solutions: Scrub check info [curiousepic] #2639 * Worldbank US: Allow using the backup URL [bpollack] #2641 +* Cyber Source: Correctly passes subscriptionID for store [deedeelavinder] #2633 == Version 1.74.0 (October 24, 2017) * Adyen: Update list of supported countries [dtykocki] #2600 diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 72289e5e293..c44e96fa677 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -618,7 +618,7 @@ def add_subscription(xml, options, reference = nil) xml.tag! 'recurringSubscriptionInfo' do if reference - _, subscription_id, _ = reference.split(";") + subscription_id = reference.split(";")[6] xml.tag! 'subscriptionID', subscription_id end @@ -709,7 +709,7 @@ def commit(request, action, amount, options) success = response[:decision] == "ACCEPT" message = response[:message] - authorization = success ? [ options[:order_id], response[:requestID], response[:requestToken], action, amount, options[:currency]].compact.join(";") : nil + authorization = success ? authorization_from(response, action, amount, options) : nil Response.new(success, message, response, :test => test?, @@ -759,6 +759,11 @@ def reason_message(reason_code) return if reason_code.blank? @@response_codes[:"r#{reason_code}"] end + + def authorization_from(response, action, amount, options) + [options[:order_id], response[:requestID], response[:requestToken], action, amount, + options[:currency], response[:subscriptionID]].join(";") + end end end end diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb index cf7f74077a3..598b87f785c 100644 --- a/test/remote/gateways/remote_cyber_source_test.rb +++ b/test/remote/gateways/remote_cyber_source_test.rb @@ -319,7 +319,7 @@ def test_successful_create_subscription_with_setup_fee def test_successful_create_subscription_with_monthly_options response = @gateway.store(@credit_card, @subscription_options.merge(:setup_fee => 99.0, :subscription => {:amount => 49.0, :automatic_renew => false, frequency: 'monthly'})) assert_equal 'Successful transaction', response.message - response = @gateway.retrieve(";#{response.params['subscriptionID']};", :order_id => @subscription_options[:order_id]) + response = @gateway.retrieve(response.authorization, order_id: @subscription_options[:order_id]) assert_equal "0.49", response.params['recurringAmount'] assert_equal 'monthly', response.params['frequency'] end diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index bd59d5ac843..955764361e1 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -59,7 +59,7 @@ def test_successful_credit_card_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_equal 'Successful transaction', response.message assert_success response - assert_equal "#{@options[:order_id]};#{response.params['requestID']};#{response.params['requestToken']};purchase;100;USD", response.authorization + assert_equal "#{@options[:order_id]};#{response.params['requestID']};#{response.params['requestToken']};purchase;100;USD;", response.authorization assert response.test? end @@ -95,7 +95,7 @@ def test_successful_check_purchase assert response = @gateway.purchase(@amount, @check, @options) assert_equal 'Successful transaction', response.message assert_success response - assert_equal "#{@options[:order_id]};#{response.params['requestID']};#{response.params['requestToken']};purchase;100;USD", response.authorization + assert_equal "#{@options[:order_id]};#{response.params['requestID']};#{response.params['requestToken']};purchase;100;USD;", response.authorization assert response.test? end @@ -105,7 +105,7 @@ def test_successful_pinless_debit_card_purchase 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 + assert_equal "#{@options[:order_id]};#{response.params['requestID']};#{response.params['requestToken']};purchase;100;USD;", response.authorization assert response.test? end From 23c38dd7f5758360fca02b6099254b31211d7573 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Tue, 7 Nov 2017 09:51:40 -0500 Subject: [PATCH 232/677] Worldpay US: Allowing switching to backup gateway per-transaction Previously, in 42e69f44390d, we allowed creating a Worldpay US gateway that targeted the backup URL. This commit changes that to instead allow specifying the URL per-transaction. Furthers ENRG-6747 Closes #2645 --- CHANGELOG | 1 + .../billing/gateways/worldpay_us.rb | 18 +++++++++--------- test/unit/gateways/worldpay_us_test.rb | 10 ++-------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0e5d380738e..b9aa88d9a16 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * Sage Payment Solutions: Scrub check info [curiousepic] #2639 * Worldbank US: Allow using the backup URL [bpollack] #2641 * Cyber Source: Correctly passes subscriptionID for store [deedeelavinder] #2633 +* Worldbank US: Allow using the backup URL per-request [bpollack] #2645 == Version 1.74.0 (October 24, 2017) * Adyen: Update list of supported countries [dtykocki] #2600 diff --git a/lib/active_merchant/billing/gateways/worldpay_us.rb b/lib/active_merchant/billing/gateways/worldpay_us.rb index 5771cb97944..21922940277 100644 --- a/lib/active_merchant/billing/gateways/worldpay_us.rb +++ b/lib/active_merchant/billing/gateways/worldpay_us.rb @@ -28,7 +28,7 @@ def purchase(money, payment_method, options={}) add_payment_method(post, payment_method) add_customer_data(post, options) - commit('purchase', post) + commit('purchase', options, post) end def authorize(money, payment, options={}) @@ -37,7 +37,7 @@ def authorize(money, payment, options={}) add_credit_card(post, payment) add_customer_data(post, options) - commit('authorize', post) + commit('authorize', options, post) end def capture(amount, authorization, options={}) @@ -46,7 +46,7 @@ def capture(amount, authorization, options={}) add_reference(post, authorization) add_customer_data(post, options) - commit('capture', post) + commit('capture', options, post) end def refund(amount, authorization, options={}) @@ -55,14 +55,14 @@ def refund(amount, authorization, options={}) add_reference(post, authorization) add_customer_data(post, options) - commit("refund", post) + commit("refund", options, post) end def void(authorization, options={}) post = {} add_reference(post, authorization) - commit('void', post) + commit('void', options, post) end def verify(credit_card, options={}) @@ -74,8 +74,8 @@ def verify(credit_card, options={}) private - def url - @options[:use_backup_url] ? self.backup_url : self.live_url + def url(options) + options[:use_backup_url].to_s == "true" ? self.backup_url : self.live_url end def add_customer_data(post, options) @@ -169,7 +169,7 @@ def parse(xml) "void" => "ns_void", } - def commit(action, post) + def commit(action, options, post) post[:action] = ACTIONS[action] unless post[:action] post[:acctid] = @options[:acctid] post[:subid] = @options[:subid] @@ -177,7 +177,7 @@ def commit(action, post) post[:authonly] = '1' if action == 'authorize' - raw = parse(ssl_post(url, post.to_query)) + raw = parse(ssl_post(url(options), post.to_query)) succeeded = success_from(raw['result']) Response.new( diff --git a/test/unit/gateways/worldpay_us_test.rb b/test/unit/gateways/worldpay_us_test.rb index ec50c2b0054..51082dc3743 100644 --- a/test/unit/gateways/worldpay_us_test.rb +++ b/test/unit/gateways/worldpay_us_test.rb @@ -176,14 +176,8 @@ def test_empty_response_fails end def test_backup_url - gateway = WorldpayUsGateway.new( - acctid: 'acctid', - subid: 'subid', - merchantpin: 'merchantpin', - use_backup_url: true - ) - response = stub_comms(gateway) do - gateway.purchase(@amount, @credit_card, use_backup_url: true) + response = stub_comms(@gateway) do + @gateway.purchase(@amount, @credit_card, use_backup_url: true) end.check_request do |endpoint, data, headers| assert_equal WorldpayUsGateway.backup_url, endpoint end.respond_with(successful_purchase_response) From 6076f8cd3f1b73884dcfef7726fab78a4eaa0a78 Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Tue, 7 Nov 2017 17:24:15 -0500 Subject: [PATCH 233/677] Stop making remote requests for payeezy store unit tests (#2646) --- test/unit/gateways/payeezy_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit/gateways/payeezy_test.rb b/test/unit/gateways/payeezy_test.rb index 5507f09fe8f..d3161920959 100644 --- a/test/unit/gateways/payeezy_test.rb +++ b/test/unit/gateways/payeezy_test.rb @@ -58,7 +58,7 @@ def test_successful_purchase end def test_successful_store - response = stub_comms do + response = stub_comms(@gateway, :ssl_request) do @gateway.store(@credit_card, @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) end.respond_with(successful_store_response) @@ -68,7 +68,7 @@ def test_successful_store end def test_successful_store_and_purchase - response = stub_comms do + response = stub_comms(@gateway, :ssl_request) do @gateway.store(@credit_card, @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) end.respond_with(successful_store_response) @@ -82,7 +82,7 @@ def test_successful_store_and_purchase end def test_failed_store - response = stub_comms do + response = stub_comms(@gateway, :ssl_request) do @gateway.store(@bad_credit_card, @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) end.respond_with(failed_store_response) From 373a5c8480efca8568bc9cc00f0c273873f4c64f Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Tue, 7 Nov 2017 18:02:52 -0500 Subject: [PATCH 234/677] Only send currency and billing_details for auths and sales for Netbanx (#2643) Paysafe does not allow you to send this information for captures and purchases. Therefore we shouldn't include them even if they're passed in the options. --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/netbanx.rb | 13 +++++-------- test/remote/gateways/remote_netbanx_test.rb | 12 ++++++------ test/unit/gateways/netbanx_test.rb | 3 ++- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b9aa88d9a16..fb85a34e9e8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Worldbank US: Allow using the backup URL [bpollack] #2641 * Cyber Source: Correctly passes subscriptionID for store [deedeelavinder] #2633 * Worldbank US: Allow using the backup URL per-request [bpollack] #2645 +* Netbanx: Only send currency and billing_details for auths and sales [anotherjosmith] #2643 == Version 1.74.0 (October 24, 2017) * Adyen: Update list of supported countries [dtykocki] #2600 diff --git a/lib/active_merchant/billing/gateways/netbanx.rb b/lib/active_merchant/billing/gateways/netbanx.rb index a19dd42e8cf..654dce2c0b5 100644 --- a/lib/active_merchant/billing/gateways/netbanx.rb +++ b/lib/active_merchant/billing/gateways/netbanx.rb @@ -31,7 +31,7 @@ def purchase(money, payment, options={}) post = {} add_invoice(post, money, options) add_settle_with_auth(post) - add_payment(post, payment) + add_payment(post, payment, options) commit(:post, 'auths', post) end @@ -39,7 +39,7 @@ def purchase(money, payment, options={}) def authorize(money, payment, options={}) post = {} add_invoice(post, money, options) - add_payment(post, payment) + add_payment(post, payment, options) commit(:post, 'auths', post) end @@ -132,13 +132,7 @@ def add_credit_card(post, credit_card, options = {}) def add_invoice(post, money, options) post[:amount] = amount(money) - post[:currencyCode] = options[:currency] if options[:currency] add_order_id(post, options) - - if options[:billing_address] - post[:billingDetails] = map_address(options[:billing_address]) - end - end def add_payment(post, credit_card_or_reference, options = {}) @@ -150,6 +144,9 @@ def add_payment(post, credit_card_or_reference, options = {}) post[:card][:cvv] = credit_card_or_reference.verification_value post[:card][:cardExpiry] = expdate(credit_card_or_reference) end + + post[:currencyCode] = options[:currency] if options[:currency] + post[:billingDetails] = map_address(options[:billing_address]) if options[:billing_address] end def expdate(credit_card) diff --git a/test/remote/gateways/remote_netbanx_test.rb b/test/remote/gateways/remote_netbanx_test.rb index 5d2731659c1..5d28ce15ce5 100644 --- a/test/remote/gateways/remote_netbanx_test.rb +++ b/test/remote/gateways/remote_netbanx_test.rb @@ -3,13 +3,13 @@ class RemoteNetbanxTest < Test::Unit::TestCase def setup @gateway = NetbanxGateway.new(fixtures(:netbanx)) - @amount = 100 @credit_card = credit_card('4530910000012345') @declined_amount = 11 @options = { billing_address: address, - description: 'Store Purchase' + description: 'Store Purchase', + currency: 'CAD' } end @@ -54,7 +54,7 @@ def test_successful_authorize_and_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert capture = @gateway.capture(@amount, auth.authorization) + assert capture = @gateway.capture(@amount, auth.authorization, @options) assert_success capture assert_equal 'OK', capture.message end @@ -63,7 +63,7 @@ def test_partial_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert capture = @gateway.capture(@amount-1, auth.authorization) + assert capture = @gateway.capture(@amount-1, auth.authorization, @options) assert_success capture end @@ -127,7 +127,7 @@ def test_failed_refund auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert capture = @gateway.capture(@amount, auth.authorization) + assert capture = @gateway.capture(@amount, auth.authorization, @options) assert_success capture # the following shall fail if you run it immediately after the capture @@ -141,7 +141,7 @@ def test_successful_void auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert void = @gateway.void(auth.authorization) + assert void = @gateway.void(auth.authorization, @options) assert_success void assert_equal 'OK', void.message end diff --git a/test/unit/gateways/netbanx_test.rb b/test/unit/gateways/netbanx_test.rb index 509effac9e9..56a74c156aa 100644 --- a/test/unit/gateways/netbanx_test.rb +++ b/test/unit/gateways/netbanx_test.rb @@ -9,7 +9,8 @@ def setup @options = { order_id: '1', billing_address: address, - description: 'Store Purchase' + description: 'Store Purchase', + currency: 'CAD' } end From ffd7d23f61c3a8e950523ebc1ca73fcb8ed5ae5f Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Wed, 8 Nov 2017 10:26:35 -0500 Subject: [PATCH 235/677] Revert "Fixes basic auth for netbanx by sending the account_number and api_key" (#2644) This reverts commit a838219a497144abc2bd72f16729e9d9b07a495c. The previous change needed to be reverted because I had misunderstood that the account number and username are different values. By reverting the last PR, the api_key needs to be in the basic auth format already (: 'application/json', 'Content-type' => 'application/json', - 'Authorization' => "Basic #{basic_auth}", + 'Authorization' => "Basic #{Base64.strict_encode64(@options[:api_key].to_s)}", 'User-Agent' => "Netbanx-Paysafe v1.0/ActiveMerchant #{ActiveMerchant::VERSION}" } end - def basic_auth - Base64.strict_encode64("#{@options[:account_number]}:#{@options[:api_key]}") - end - def error_code_from(response) unless success_from(response) case response['errorCode'] From ece79cf91354365a3e123ce035e0289e6673785d Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Thu, 9 Nov 2017 13:03:52 -0500 Subject: [PATCH 236/677] Release version 1.75.0 --- CHANGELOG | 14 ++++++++------ lib/active_merchant/version.rb | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 63d1c56758c..336c0f9f2ea 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,18 +1,20 @@ = ActiveMerchant CHANGELOG == HEAD -* FirstData E4 (Payeezy): Ensure numeric ECI values are zero padded [jasonwebster] #2630 -* Barclaycard Smartpay: Extra data fields for credits [bpollack] #2631 -* PayU Latam: Adds `partnerID`, adjusts phone preferences, allows empty `ip_address`, and adjusts for no `cvv` [deedeelavinder] #2634 + +== Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 +* Barclaycard Smartpay: Extra data fields for credits [bpollack] #2631 +* Cyber Source: Correctly passes subscriptionID for store [deedeelavinder] #2633 * Ebanx: Pass fields for business person responsible [curiousepic] #2635 * Ebanx: Support Colombian transactions [bpollack] #2636 +* FirstData E4 (Payeezy): Ensure numeric ECI values are zero padded [jasonwebster] #2630 +* Netbanx: Only send currency and billing_details for auths and sales [anotherjosmith] #2643 +* Netbanx: Revert "Fixes basic auth for netbanx by sending the account_number and api_key" [anotherjosmith] #2644 +* PayU Latam: Adds `partnerID`, adjusts phone preferences, allows empty `ip_address`, and adjusts for no `cvv` [deedeelavinder] #2634 * Sage Payment Solutions: Scrub check info [curiousepic] #2639 * Worldbank US: Allow using the backup URL [bpollack] #2641 -* Cyber Source: Correctly passes subscriptionID for store [deedeelavinder] #2633 * Worldbank US: Allow using the backup URL per-request [bpollack] #2645 -* Netbanx: Only send currency and billing_details for auths and sales [anotherjosmith] #2643 -* Netbanx: Revert "Fixes basic auth for netbanx by sending the account_number and api_key" [anotherjosmith] #2644 == Version 1.74.0 (October 24, 2017) * Adyen: Update list of supported countries [dtykocki] #2600 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index ca079789036..1dee09dc9d3 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.74.0" + VERSION = "1.75.0" end From e30473abe8f7f25057508dfe48ad9a648f7408ec Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Mon, 13 Nov 2017 08:58:23 -0500 Subject: [PATCH 237/677] Checkout V2: Allow AVS and CVV for Authorizations AVS and CVV result details will also now come through on authorizations. Closes #2650 Remote Tests: 24 tests, 57 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit Tests: 19 tests, 80 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/checkout_v2.rb | 41 +++---- .../gateways/remote_checkout_v2_test.rb | 21 ++++ test/unit/gateways/checkout_v2_test.rb | 102 ++++++++++++++---- 4 files changed, 122 insertions(+), 43 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 336c0f9f2ea..8bc5db4387f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Checkout V2: Allows AVS and CVV result details to come through on authorizations [deedeelavinder] #2650 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb index 3188f225a96..eb08f36a1fc 100644 --- a/lib/active_merchant/billing/gateways/checkout_v2.rb +++ b/lib/active_merchant/billing/gateways/checkout_v2.rb @@ -25,16 +25,7 @@ def purchase(amount, payment_method, options={}) merged_params = multi.responses.map { |r| r.params }.reduce({}, :merge) succeeded = success_from(merged_params) - Response.new( - succeeded, - message_from(succeeded, merged_params), - merged_params, - authorization: authorization_from(merged_params), - avs_result: avs_result(:purchase, succeeded, merged_params), - cvv_result: cvv_result(:purchase, succeeded, merged_params), - error_code: error_code_from(succeeded, merged_params), - test: test? - ) + response(:purchase, succeeded, merged_params) end def authorize(amount, payment_method, options={}) @@ -132,6 +123,15 @@ def commit(action, post, authorization = nil) end succeeded = success_from(response) + + response(action, succeeded, response) + end + + def response(action, succeeded, response) + successful_response = succeeded && action == :purchase || action == :authorize + avs_result = successful_response ? avs_result(response) : nil + cvv_result = successful_response ? cvv_result(response) : nil + Response.new( succeeded, message_from(succeeded, response), @@ -139,8 +139,9 @@ def commit(action, post, authorization = nil) authorization: authorization_from(response), error_code: error_code_from(succeeded, response), test: test?, - avs_result: avs_result(action, succeeded, response), - cvv_result: cvv_result(action, succeeded, response)) + avs_result: avs_result, + cvv_result: cvv_result + ) end def headers @@ -162,20 +163,12 @@ def base_url test? ? test_url : live_url end - def avs_result(action, succeeded, response) - if succeeded - action == :purchase ? AVSResult.new(code: response["card"]["avsCheck"]) : nil - else - nil - end + def avs_result(response) + response['card'] && response['card']['avsCheck'] ? AVSResult.new(code: response['card']['avsCheck']) : nil end - def cvv_result(action, succeeded, response) - if succeeded - action == :purchase ? CVVResult.new(response["card"]["cvvCheck"]) : nil - else - nil - end + def cvv_result(response) + response['card'] && response['card']['cvvCheck'] ? CVVResult.new(response['card']['cvvCheck']) : nil end def parse(body) diff --git a/test/remote/gateways/remote_checkout_v2_test.rb b/test/remote/gateways/remote_checkout_v2_test.rb index a9880e7d6b5..80288c2f405 100644 --- a/test/remote/gateways/remote_checkout_v2_test.rb +++ b/test/remote/gateways/remote_checkout_v2_test.rb @@ -41,6 +41,14 @@ def test_successful_purchase_includes_avs_result assert_equal 'U.S.-issuing bank does not support AVS.', response.avs_result["message"] end + def test_successful_authorize_includes_avs_result + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + assert_equal 'Succeeded', response.message + assert_equal 'S', response.avs_result["code"] + assert_equal 'U.S.-issuing bank does not support AVS.', response.avs_result["message"] + end + def test_successful_purchase_includes_cvv_result response = @gateway.purchase(@amount, @credit_card, @options) assert_success response @@ -48,6 +56,13 @@ def test_successful_purchase_includes_cvv_result assert_equal 'Y', response.cvv_result["code"] end + def test_successful_authorize_includes_cvv_result + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + assert_equal 'Succeeded', response.message + assert_equal 'Y', response.cvv_result["code"] + end + def test_successful_purchase_with_descriptors options = @options.merge(descriptor_name: "shop", descriptor_city: "london") response = @gateway.purchase(@amount, @credit_card, options) @@ -85,6 +100,12 @@ def test_avs_failed_purchase assert_equal '40111 - Street Match Only', response.message end + def test_avs_failed_authorize + response = @gateway.authorize(@amount, @credit_card, billing_address: address.update(address1: 'Test_A')) + assert_failure response + assert_equal '40111 - Street Match Only', response.message + end + def test_successful_authorize_and_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb index 739cb40e300..50c79e73bea 100644 --- a/test/unit/gateways/checkout_v2_test.rb +++ b/test/unit/gateways/checkout_v2_test.rb @@ -41,6 +41,25 @@ def test_successful_purchase_includes_cvv_result assert_equal 'Y', response.cvv_result["code"] end + def test_successful_authorize_includes_avs_result + response = stub_comms do + @gateway.authorize(@amount, @credit_card) + end.respond_with(successful_authorize_response) + + assert_equal 'S', response.avs_result["code"] + assert_equal 'U.S.-issuing bank does not support AVS.', response.avs_result["message"] + assert_equal 'X', response.avs_result["postal_match"] + assert_equal 'X', response.avs_result["street_match"] + end + + def test_successful_authorize_includes_cvv_result + response = stub_comms do + @gateway.authorize(@amount, @credit_card) + end.respond_with(successful_authorize_response) + + assert_equal 'Y', response.cvv_result["code"] + end + def test_purchase_with_additional_fields response = stub_comms do @gateway.purchase(@amount, @credit_card, {descriptor_city: "london", descriptor_name: "sherlock"}) @@ -65,7 +84,7 @@ def test_successful_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "charge_test_941CA9CE174U76BD29C8", response.authorization + assert_equal "charge_test_AF1A29AD350Q748C7EA8", response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -98,7 +117,7 @@ def test_successful_void end.respond_with(successful_authorize_response) assert_success response - assert_equal "charge_test_941CA9CE174U76BD29C8", response.authorization + assert_equal "charge_test_AF1A29AD350Q748C7EA8", response.authorization void = stub_comms do @gateway.void(response.authorization) @@ -239,23 +258,68 @@ def failed_purchase_response def successful_authorize_response %( - { - "id":"charge_test_941CA9CE174U76BD29C8", - "liveMode":false, - "created":"2015-05-27T20:45:58Z", - "value":200.0, - "currency":"USD", - "trackId":"1", - "description":null, - "email":"longbob.longsen@gmail.com", - "chargeMode":1, - "transactionIndicator":1, - "customerIp":null, - "responseMessage":"Authorised", - "responseAdvancedInfo":"Authorised", - "responseCode":"10000" - } - ) + { + "id":"charge_test_AF1A29AD350Q748C7EA8", + "liveMode":false, + "created":"2017-11-13T14:05:27Z", + "value":200, + "currency":"USD", + "trackId":"1", + "description":null, + "email":"longbob.longsen@example.com", + "chargeMode":1, + "transactionIndicator":1, + "customerIp":null, + "responseMessage":"Approved", + "responseAdvancedInfo":"Approved", + "responseCode":"10000", + "status":"Authorised", + "authCode":"923189", + "isCascaded":false, + "autoCapture":"N", + "autoCapTime":0.0, + "card":{"customerId": + "cust_12DCEB24-ACEA-48AB-BEF2-35A3C09BE581", + "expiryMonth":"06", + "expiryYear":"2018", + "billingDetails":{ + "addressLine1":"456 My Street", + "addressLine2":"Apt 1", + "postcode":"K1C2N6", + "country":"CA", + "city":"Ottawa", + "state":"ON", + "phone":{"number":"(555)555-5555"} + }, + "id":"card_CFA314F4-388D-4CF4-BE6F-940D894C9E64", + "last4":"4242", + "bin":"424242", + "paymentMethod":"Visa", + "fingerprint":"F639CAB2745BEE4140BF86DF6B6D6E255C5945AAC3788D923FA047EA4C208622", + "name":"Longbob Longsen", + "cvvCheck":"Y", + "avsCheck":"S" + }, + "riskCheck":true, + "customerPaymentPlans":null, + "metadata":{}, + "shippingDetails":{ + "addressLine1":null, + "addressLine2":null, + "postcode":null, + "country":null, + "city":null, + "state":null, + "phone":{} + }, + "products":[], + "udf1":null, + "udf2":null, + "udf3":null, + "udf4":null, + "udf5":null + } + ) end def failed_authorize_response From fb611826168a2ea1453654bf6f1d60e2683ffe07 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Fri, 10 Nov 2017 17:50:58 -0500 Subject: [PATCH 238/677] Global Collect: Adds pre-authorization Adds boolean flag for pre-authorization. Closes #2651 Remote Tests: 15 tests, 35 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit Tests: 16 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/global_collect.rb | 8 +++++--- test/unit/gateways/global_collect_test.rb | 20 +++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8bc5db4387f..2c94dc2248e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * Checkout V2: Allows AVS and CVV result details to come through on authorizations [deedeelavinder] #2650 +* Global Collect: Adds boolean option for pre_authorization [deeedeelavinder] #2651 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 2e21d62ca9f..b8fc6be69c9 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -30,7 +30,7 @@ def purchase(money, payment, options={}) def authorize(money, payment, options={}) post = nestable_hash add_order(post, money, options) - add_payment(post, payment) + add_payment(post, payment, options) add_customer_data(post, options, payment) add_address(post, payment, options) @@ -106,15 +106,17 @@ def add_amount(post, money, options={}) } end - def add_payment(post, payment) + def add_payment(post, payment, options) year = format(payment.year, :two_digits) month = format(payment.month, :two_digits) expirydate = "#{month}#{year}" + pre_authorization = options[:pre_authorization] ? 'PRE_AUTHORIZATION' : 'FINAL_AUTHORIZATION' post["cardPaymentMethodSpecificInput"] = { "paymentProductId" => BRAND_MAP[payment.brand], "skipAuthentication" => "true", # refers to 3DSecure - "skipFraudService" => "true" + "skipFraudService" => "true", + "authorizationMode" => pre_authorization } post["cardPaymentMethodSpecificInput"]["card"] = { "cvv" => payment.verification_value, diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb index e256de0c432..c257f90d765 100644 --- a/test/unit/gateways/global_collect_test.rb +++ b/test/unit/gateways/global_collect_test.rb @@ -45,6 +45,26 @@ def test_purchase_does_not_run_capture_if_authorize_auto_captured assert_equal 1, response.responses.size end + def test_authorize_with_pre_authorization_flag + response = stub_comms do + @gateway.authorize(@accepted_amount, @credit_card, @options.merge(pre_authorization: true)) + end.check_request do |endpoint, data, headers| + assert_match(/PRE_AUTHORIZATION/, data) + end.respond_with(successful_authorize_response) + + assert_success response + end + + def test_authorize_without_pre_authorization_flag + response = stub_comms do + @gateway.authorize(@accepted_amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match(/FINAL_AUTHORIZATION/, data) + end.respond_with(successful_authorize_response) + + assert_success response + end + def test_trucates_first_name_to_15_chars credit_card = credit_card('4567350000427977', { first_name: "thisisaverylongfirstname" }) From e5734ef2749b69ab1b770c7e2312694ba9ee164d Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 6 Nov 2017 10:41:21 -0500 Subject: [PATCH 239/677] Credorax: Pass Transaction Type field The a9 ("Transaction Type") field is required to be sent with a value of 8 for visa and mastercard if the card data is stored (anywhere) as tokenized data. This commit allows passing the a9 value as an option. Closes #2653 Remote: 19 tests, 54 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 18 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/credorax.rb | 9 ++++++++- test/remote/gateways/remote_credorax_test.rb | 7 +++++++ test/unit/gateways/credorax_test.rb | 10 ++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 2c94dc2248e..a764d622813 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * Checkout V2: Allows AVS and CVV result details to come through on authorizations [deedeelavinder] #2650 * Global Collect: Adds boolean option for pre_authorization [deeedeelavinder] #2651 +* Credorax: Pass Transaction Type field [curiousepic] #2653 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb index a97ea6195fd..0a57a4b0e21 100644 --- a/lib/active_merchant/billing/gateways/credorax.rb +++ b/lib/active_merchant/billing/gateways/credorax.rb @@ -129,6 +129,7 @@ def purchase(amount, payment_method, options={}) add_email(post, options) add_3d_secure(post, options) add_echo(post, options) + add_transaction_type(post, options) commit(:purchase, post) end @@ -141,6 +142,7 @@ def authorize(amount, payment_method, options={}) add_email(post, options) add_3d_secure(post, options) add_echo(post, options) + add_transaction_type(post, options) commit(:authorize, post) end @@ -182,7 +184,8 @@ def credit(amount, payment_method, options={}) add_customer_data(post, options) add_email(post, options) add_echo(post, options) - + add_transaction_type(post, options) + commit(:credit, post) end @@ -264,6 +267,10 @@ def add_echo(post, options) post[:d2] = options[:echo] unless options[:echo].blank? end + def add_transaction_type(post, options) + post[:a9] = options[:transaction_type] if options[:transaction_type] + end + ACTIONS = { purchase: '1', authorize: '2', diff --git a/test/remote/gateways/remote_credorax_test.rb b/test/remote/gateways/remote_credorax_test.rb index 89432952a6b..d33de554502 100644 --- a/test/remote/gateways/remote_credorax_test.rb +++ b/test/remote/gateways/remote_credorax_test.rb @@ -28,6 +28,13 @@ def test_successful_purchase assert_equal "Succeeded", response.message end + def test_successful_purchase_with_extra_options + response = @gateway.purchase(@amount, @credit_card, @options.merge(transaction_type: '8')) + assert_success response + assert_equal "1", response.params["H9"] + assert_equal "Succeeded", response.message + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response diff --git a/test/unit/gateways/credorax_test.rb b/test/unit/gateways/credorax_test.rb index fca8590f741..6a404ded066 100644 --- a/test/unit/gateways/credorax_test.rb +++ b/test/unit/gateways/credorax_test.rb @@ -204,6 +204,16 @@ def test_defaults_3d_secure_cavv_field_to_none_if_not_present assert response.test? end + def test_adds_a9_field + 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| + assert_match(/a9=8/, data) + end.respond_with(successful_purchase_response) + end + private def successful_purchase_response From f0a099014ada6213bdb33f6043d2a30dfbec7a01 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Wed, 22 Nov 2017 15:51:00 -0500 Subject: [PATCH 240/677] Implement Cardprocess Gateway Furthers ENRG-6967 --- CHANGELOG | 1 + .../billing/gateways/cardprocess.rb | 254 ++++++++++++++++ test/fixtures.yml | 6 + .../gateways/remote_cardprocess_test.rb | 148 +++++++++ test/unit/gateways/cardprocess_test.rb | 280 ++++++++++++++++++ 5 files changed, 689 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/cardprocess.rb create mode 100644 test/remote/gateways/remote_cardprocess_test.rb create mode 100644 test/unit/gateways/cardprocess_test.rb diff --git a/CHANGELOG b/CHANGELOG index a764d622813..f2f231b9809 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * Checkout V2: Allows AVS and CVV result details to come through on authorizations [deedeelavinder] #2650 * Global Collect: Adds boolean option for pre_authorization [deeedeelavinder] #2651 * Credorax: Pass Transaction Type field [curiousepic] #2653 +* Add CardProcess Gateway [bpollack] #2659 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/cardprocess.rb b/lib/active_merchant/billing/gateways/cardprocess.rb new file mode 100644 index 00000000000..d16979824a4 --- /dev/null +++ b/lib/active_merchant/billing/gateways/cardprocess.rb @@ -0,0 +1,254 @@ +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class CardprocessGateway < Gateway + self.test_url = 'https://test.vr-pay-ecommerce.de/v1/payments' + self.live_url = 'https://vr-pay-ecommerce.de/v1/payments' + + self.supported_countries = %w[ BE BG CZ DK DE EE IE ES FR HR IT CY LV LT LU + MT HU NL AT PL PT RO SI SK FI SE GB IS LI NO + CH ME MK AL RS TR BA ] + self.default_currency = 'EUR' + self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb] + + self.homepage_url = 'https://vr-pay-ecommerce.docs.oppwa.com/' + self.display_name = 'CardProcess VR-Pay' + self.money_format = :dollars + + STANDARD_ERROR_CODE_MAPPING = {} + + # Creates a new CardProcess Gateway + # + # The gateway requires a valid login, password, and entity ID + # to be passed in the +options+ hash. + # + # === Options + # + # * :user_id -- The CardProcess user ID + # * :password -- The CardProcess password + # * :entity_id -- The CardProcess channel or entity ID for any transactions + def initialize(options={}) + requires!(options, :user_id, :password, :entity_id) + super + # This variable exists purely to allow remote tests to force error codes; + # the lack of a setter despite its usage is intentional. + @test_options = {} + end + + def purchase(money, payment, options = {}) + post = {} + add_invoice(post, money, options) + add_payment(post, payment) + add_address(post, payment, options) + add_customer_data(post, options) + + commit('DB', post) + end + + def authorize(money, payment, options = {}) + post = {} + add_invoice(post, money, options) + add_payment(post, payment) + add_address(post, payment, options) + add_customer_data(post, options) + + commit('PA', post) + end + + def capture(money, authorization, options = {}) + post = { + id: authorization + } + add_invoice(post, money, options) + commit('CP', post) + end + + def refund(money, authorization, options = {}) + post = { + id: authorization + } + add_invoice(post, money, options) + commit('RF', post) + end + + def credit(money, payment, options = {}) + post = {} + add_invoice(post, money, options) + add_payment(post, payment) + add_address(post, payment, options) + add_customer_data(post, options) + + commit('CD', post) + end + + def void(authorization, _options = {}) + post = { + id: authorization + } + commit('RV', post) + end + + def verify(credit_card, options = {}) + MultiResponse.run do |r| + r.process { authorize(100, credit_card, options) } + r.process { void(r.authorization, options) } + end + end + + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript + .gsub(%r{(authentication\.[^=]+=)[^&]+}, '\1[FILTERED]') + .gsub(%r{(card\.number=)\d+}, '\1[FILTERED]') + .gsub(%r{(cvv=)\d{3,4}}, '\1[FILTERED]\2') + end + + private + + def add_customer_data(post, options) + post['customer.ip'] = options[:ip] if options[:ip] + end + + def add_address(post, _card, options) + if (address = options[:billing_address] || options[:address]) + post[:billing] = hashify_address(address) + end + + if (shipping = options[:shipping_address]) + post[:shipping] = hashify_address(shipping) + end + end + + def add_invoice(post, money, options) + return if money.nil? + post[:amount] = amount(money) + post[:currency] = (options[:currency] || currency(money)) + post[:merchantInvoiceId] = options[:merchant_invoice_id] if options[:merchant_invoice_id] + post[:merchantTransactionId] = options[:merchant_transaction_id] if options[:merchant_transaction_id] + post[:transactionCategory] = options[:transaction_category] if options[:transaction_category] + end + + def add_payment(post, payment) + return if payment.is_a?(String) + post[:paymentBrand] = payment.brand.upcase if payment.brand + post[:card] ||= {} + post[:card][:number] = payment.number + post[:card][:holder] = payment.name + post[:card][:expiryMonth] = sprintf('%02d', payment.month) + post[:card][:expiryYear] = sprintf('%02d', payment.year) + post[:card][:cvv] = payment.verification_value + end + + def parse(body) + JSON.parse(body) + end + + def commit(action, parameters) + url = (test? ? test_url : live_url) + if (id = parameters.delete(:id)) + url += "/#{id}" + end + + begin + raw_response = ssl_post(url, post_data(action, parameters.merge(@test_options))) + rescue ResponseError => e + raw_response = e.response.body + end + response = parse(raw_response) + + Response.new( + success_from(response), + message_from(response), + response, + authorization: authorization_from(response), + avs_result: AVSResult.new(code: response['result']['avsResponse']), + cvv_result: CVVResult.new(response['result']['cvvResponse']), + test: test?, + error_code: error_code_from(response) + ) + end + + def success_from(response) + response['result']['code'] =~ /^(000\.000\.|000\.100\.1|000\.[36])/ + end + + def message_from(response) + response['result']['description'] + end + + def authorization_from(response) + response['id'] + end + + def post_data(action, parameters = {}) + post = parameters.clone + post[:authentication] ||= {} + post[:authentication][:userId] = @options[:user_id] + post[:authentication][:password] = @options[:password] + post[:authentication][:entityId] = @options[:entity_id] + post[:paymentType] = action + dot_flatten_hash(post).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&") + end + + def error_code_from(response) + unless success_from(response) + case response['result']['code'] + when '100.100.101' + STANDARD_ERROR_CODE[:incorrect_number] + when '100.100.303' + STANDARD_ERROR_CODE[:expired_card] + when /100\.100\.(201|301|305)/ + STANDARD_ERROR_CODE[:invalid_expiry_date] + when /100.100.60[01]/ + STANDARD_ERROR_CODE[:invalid_cvc] + when '800.100.151' + STANDARD_ERROR_CODE[:invalid_number] + when '800.100.153' + STANDARD_ERROR_CODE[:incorrect_cvc] + when /800.800.(102|302)/ + STANDARD_ERROR_CODE[:incorrect_address] + when '800.800.202' + STANDARD_ERROR_CODE[:invalid_zip] + when '800.100.166' + STANDARD_ERROR_CODE[:incorrect_pin] + when '800.100.171' + STANDARD_ERROR_CODE[:pickup_card] + when /^(200|700)\./ + STANDARD_ERROR_CODE[:config_error] + when /^(800\.[17]00|800\.800\.[123])/ + STANDARD_ERROR_CODE[:card_declined] + when /^(900\.[1234]00)/ + STANDARD_ERROR_CODE[:processing_error] + else + STANDARD_ERROR_CODE[:processing_error] + end + end + end + + def hashify_address(address) + hash = {} + hash[:street1] = address[:address1] if address[:address1] + hash[:street2] = address[:address2] if address[:address2] + hash[:city] = address[:city] if address[:city] + hash[:state] = address[:state] if address[:state] + hash[:postcode] = address[:zip] if address[:zip] + hash[:country] = address[:country] if address[:country] + hash + end + + def dot_flatten_hash(hash, prefix = '') + h = {} + hash.each_pair do |k, v| + if v.is_a?(Hash) + h.merge!(dot_flatten_hash(v, prefix + k.to_s + '.')) + else + h[prefix + k.to_s] = v + end + end + h + end + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index 8e63ba2e948..afe7076207c 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -135,6 +135,12 @@ card_stream: cardknox: api_key: ActiveMerchant_Test +# Working credentials, no need to replace +cardprocess: + user_id: 8a8294174e735d0c014e78beb6c5154f + password: cTZjAm9c87 + entity_id: 8a8294174e735d0c014e78beb6b9154b + # Cashnet doesn't provide public testing data cashnet: merchant: 'X' diff --git a/test/remote/gateways/remote_cardprocess_test.rb b/test/remote/gateways/remote_cardprocess_test.rb new file mode 100644 index 00000000000..e589c19cda2 --- /dev/null +++ b/test/remote/gateways/remote_cardprocess_test.rb @@ -0,0 +1,148 @@ +require 'test_helper' + +class RemoteCardprocessTest < Test::Unit::TestCase + def setup + @gateway = CardprocessGateway.new(fixtures(:cardprocess)) + + @amount = 100 + @credit_card = credit_card('4200000000000000') + @credit_card_3ds = credit_card('4711100000000000') + + @options = { + billing_address: address, + description: 'Store Purchase' + } + end + + def test_successful_purchase + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_match %r{^Request successfully processed}, response.message + end + + def test_successful_purchase_with_more_options + options = { + order_id: '1', + ip: '127.0.0.1', + email: 'joe@example.com' + } + + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_match %r{^Request successfully processed}, response.message + end + + def test_failed_purchase + bad_credit_card = credit_card('4200000000000001') + response = @gateway.purchase(@amount, bad_credit_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + assert_equal 'invalid creditcard, bank account number or bank name', response.message + end + + def test_successful_authorize_and_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + assert_match %r{^Request successfully processed}, capture.message + end + + def test_failed_authorize + @gateway.instance_variable_set(:@test_options, {'customParameters[forceResultCode]' => '800.100.151'}) + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_equal 'transaction declined (invalid card)', response.message + end + + def test_partial_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount-1, auth.authorization) + assert_success capture + end + + def test_failed_capture + response = @gateway.capture(@amount, '12345678123456781234567812345678') + assert_failure response + assert_equal 'capture needs at least one successful transaction of type (PA)', response.message + end + + def test_successful_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount, purchase.authorization) + assert_success refund + assert_match %r{^Request successfully processed}, refund.message + end + + def test_successful_credit + response = @gateway.credit(@amount, @credit_card, @options) + assert_success response + assert_match %r{^Request successfully processed}, response.message + end + + def test_partial_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount-1, purchase.authorization) + assert_success refund + end + + def test_failed_refund + response = @gateway.refund(@amount, '') + assert_failure response + assert_equal 'invalid or missing parameter', response.message + end + + def test_successful_void + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert void = @gateway.void(auth.authorization) + assert_success void + assert_match %r{^Request successfully processed}, void.message + end + + def test_failed_void + response = @gateway.void('') + assert_failure response + assert_equal 'invalid or missing parameter', response.message + end + + def test_successful_verify + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_match %r{^Request successfully processed}, response.message + end + + def test_failed_verify + @gateway.instance_variable_set(:@test_options, {'customParameters[forceResultCode]' => '600.200.100'}) + response = @gateway.verify(@credit_card, @options) + assert_failure response + assert_match %r{invalid Payment Method}, response.message + end + + def test_invalid_login + gateway = CardprocessGateway.new(user_id: '00000000000000000000000000000000', password: 'qwerty', entity_id: '00000000000000000000000000000000') + + response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal 'invalid authentication information', response.message + end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end +end diff --git a/test/unit/gateways/cardprocess_test.rb b/test/unit/gateways/cardprocess_test.rb new file mode 100644 index 00000000000..29abcdef429 --- /dev/null +++ b/test/unit/gateways/cardprocess_test.rb @@ -0,0 +1,280 @@ +require 'test_helper' + +class CardprocessTest < Test::Unit::TestCase + def setup + @gateway = CardprocessGateway.new(user_id: 'login', password: 'password', entity_id: '123') + @credit_card = credit_card + @amount = 100 + + @options = { + order_id: '1', + billing_address: address, + description: 'Store Purchase' + } + end + + def test_successful_purchase + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + + assert_equal '8a8294495fe8084a016002dd17c163fd', response.authorization + assert_equal 'DB', response.params['paymentType'] + assert response.test? + end + + def test_failed_purchase + @gateway.expects(:ssl_post).returns(failed_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + end + + def test_successful_authorize + @gateway.expects(:ssl_post).returns(successful_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + + assert_equal '8a82944a5fe82704016002caa42c14f8', response.authorization + assert_equal 'PA', response.params['paymentType'] + assert response.test? + end + + def test_failed_authorize + @gateway.expects(:ssl_post).returns(failed_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_equal 'PA', response.params['paymentType'] + assert response.test? + end + + def test_successful_capture + @gateway.expects(:ssl_post).returns(successful_capture_response) + + response = @gateway.capture(@amount, '123', @options) + assert_success response + + assert_equal '8a82944a5fe82704016002caa7cd1513', response.authorization + assert_equal 'CP', response.params['paymentType'] + assert response.test? + end + + def test_failed_capture + @gateway.expects(:ssl_post).returns(failed_capture_response) + + response = @gateway.capture(@amount, '123', @options) + assert_failure response + assert response.test? + end + + def test_successful_refund + @gateway.expects(:ssl_post).returns(successful_refund_response) + + response = @gateway.refund(@amount, '123', @options) + assert_success response + + assert_equal '8a82944a5fe82704016002cc88f61731', response.authorization + assert_equal 'RF', response.params['paymentType'] + assert response.test? + end + + def test_failed_refund + @gateway.expects(:ssl_post).returns(failed_refund_response) + + response = @gateway.refund(@amount, '123', @options) + assert_failure response + end + + def test_successful_void + @gateway.expects(:ssl_post).returns(successful_void_response) + + response = @gateway.void('123') + assert_success response + + assert_equal '8a8294495fe8084a016002cc489446d6', response.authorization + assert_equal 'RV', response.params['paymentType'] + assert response.test? + end + + def test_failed_void + @gateway.expects(:ssl_post).returns(failed_void_response) + + response = @gateway.void('123') + assert_failure response + end + + def test_successful_verify + @gateway.stubs(:ssl_post).returns(successful_authorize_response, successful_capture_response) + + response = @gateway.verify(@credit_card, @options) + assert_success response + assert response.test? + end + + def test_successful_verify_with_failed_void + @gateway.stubs(:ssl_post).returns(successful_authorize_response, failed_void_response) + + response = @gateway.verify(@credit_card, @options) + assert_failure response + assert response.test? + end + + def test_failed_verify + @gateway.expects(:ssl_post).returns(failed_authorize_response) + + response = @gateway.verify(@credit_card, @options) + assert_failure response + assert response.test? + end + + def test_general_credit + @gateway.expects(:ssl_post).returns(successful_credit_response) + + response = @gateway.credit(@amount, @credit_card, @options) + assert_success response + + assert_equal '8a8294495fe8084a01600332a83d4899', response.authorization + assert_equal 'CD', response.params['paymentType'] + assert response.test? + end + + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + + def test_error_code_parsing + codes = { + '000.000.000' => nil, + '100.100.101' => :incorrect_number, + '100.100.303' => :expired_card, + '100.100.305' => :invalid_expiry_date, + '100.100.600' => :invalid_cvc, + '200.222.222' => :config_error, + '700.777.777' => :config_error, + '800.800.101' => :card_declined, + '800.800.102' => :incorrect_address, + '800.800.302' => :incorrect_address, + '800.800.150' => :card_declined, + '800.100.151' => :invalid_number, + '800.100.152' => :card_declined, + '800.100.153' => :incorrect_cvc, + '800.100.154' => :card_declined, + '800.800.202' => :invalid_zip + } + codes.each_pair do |code, key| + response = {'result' => {'code' => code}} + assert_equal Gateway::STANDARD_ERROR_CODE[key], @gateway.send(:error_code_from, response), "expecting #{code} => #{key}" + end + end + + private + + def pre_scrubbed + %q( +opening connection to test.vr-pay-ecommerce.de:443... +opened +starting SSL for test.vr-pay-ecommerce.de:443... +SSL established +<- "POST /v1/payments 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: test.vr-pay-ecommerce.de\r\nContent-Length: 447\r\n\r\n" +<- "amount=1.00¤cy=EUR&paymentBrand=VISA&card.number=4200000000000000&card.holder=Longbob+Longsen&card.expiryMonth=09&card.expiryYear=2018&card.cvv=123&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.userId=8a8294174e735d0c014e78beb6c5154f&authentication.password=cTZjAm9c87&authentication.entityId=8a8294174e735d0c014e78beb6b9154b&paymentType=DB" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Mon, 27 Nov 2017 21:40:52 GMT\r\n" +-> "Server: Apache-Coyote/1.1\r\n" +-> "Strict-Transport-Security: max-age=63072000; includeSubdomains; preload\r\n" +-> "X-Content-Type-Options: nosniff\r\n" +-> "X-XSS-Protection: 1; mode=block\r\n" +-> "Access-Control-Allow-Origin: *\r\n" +-> "Access-Control-Allow-Credentials: true\r\n" +-> "X-Application-WAF-Action: allow\r\n" +-> "Content-Type: application/json;charset=UTF-8\r\n" +-> "Content-Length: 725\r\n" +-> "X-Content-Type-Options: nosniff\r\n" +-> "Connection: close\r\n" +-> "\r\n" +reading 725 bytes... +-> "" +-> "{\"id\":\"8a82944a5fe82704015fff6cf5e572b4\",\"paymentType\":\"DB\",\"paymentBrand\":\"VISA\",\"amount\":\"1.00\",\"currency\":\"EUR\",\"descriptor\":\"5901.3583.3250 OPP_Channel \",\"result\":{\"code\":\"000.100.110\",\"description\":\"Request successfully processed in 'Merchant in Integrator Test Mode'\"},\"card\":{\"bin\":\"420000\",\"last4Digits\":\"0000\",\"holder\":\"Longbob Longsen\",\"expiryMonth\":\"09\",\"expiryYear\":\"2018\"},\"billing\":{\"street1\":\"456 My Street\",\"street2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"postcode\":\"K1C2N6\",\"country\":\"CA\"},\"risk\":{\"score\":\"100\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-27 21:40:51+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_24979bbf8c3a424cbd25e59860bb5417\"}" +read 725 bytes +Conn close + ) + end + + def post_scrubbed + %q( +opening connection to test.vr-pay-ecommerce.de:443... +opened +starting SSL for test.vr-pay-ecommerce.de:443... +SSL established +<- "POST /v1/payments 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: test.vr-pay-ecommerce.de\r\nContent-Length: 447\r\n\r\n" +<- "amount=1.00¤cy=EUR&paymentBrand=VISA&card.number=[FILTERED]&card.holder=Longbob+Longsen&card.expiryMonth=09&card.expiryYear=2018&card.cvv=[FILTERED]&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.userId=[FILTERED]&authentication.password=[FILTERED]&authentication.entityId=[FILTERED]&paymentType=DB" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Mon, 27 Nov 2017 21:40:52 GMT\r\n" +-> "Server: Apache-Coyote/1.1\r\n" +-> "Strict-Transport-Security: max-age=63072000; includeSubdomains; preload\r\n" +-> "X-Content-Type-Options: nosniff\r\n" +-> "X-XSS-Protection: 1; mode=block\r\n" +-> "Access-Control-Allow-Origin: *\r\n" +-> "Access-Control-Allow-Credentials: true\r\n" +-> "X-Application-WAF-Action: allow\r\n" +-> "Content-Type: application/json;charset=UTF-8\r\n" +-> "Content-Length: 725\r\n" +-> "X-Content-Type-Options: nosniff\r\n" +-> "Connection: close\r\n" +-> "\r\n" +reading 725 bytes... +-> "" +-> "{\"id\":\"8a82944a5fe82704015fff6cf5e572b4\",\"paymentType\":\"DB\",\"paymentBrand\":\"VISA\",\"amount\":\"1.00\",\"currency\":\"EUR\",\"descriptor\":\"5901.3583.3250 OPP_Channel \",\"result\":{\"code\":\"000.100.110\",\"description\":\"Request successfully processed in 'Merchant in Integrator Test Mode'\"},\"card\":{\"bin\":\"420000\",\"last4Digits\":\"0000\",\"holder\":\"Longbob Longsen\",\"expiryMonth\":\"09\",\"expiryYear\":\"2018\"},\"billing\":{\"street1\":\"456 My Street\",\"street2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"postcode\":\"K1C2N6\",\"country\":\"CA\"},\"risk\":{\"score\":\"100\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-27 21:40:51+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_24979bbf8c3a424cbd25e59860bb5417\"}" +read 725 bytes +Conn close + ) + end + + def successful_purchase_response + "{\"id\":\"8a8294495fe8084a016002dd17c163fd\",\"paymentType\":\"DB\",\"paymentBrand\":\"VISA\",\"amount\":\"1.00\",\"currency\":\"EUR\",\"descriptor\":\"0177.7272.0802 OPP_Channel \",\"result\":{\"code\":\"000.100.110\",\"description\":\"Request successfully processed in 'Merchant in Integrator Test Mode'\"},\"card\":{\"bin\":\"420000\",\"last4Digits\":\"0000\",\"holder\":\"Longbob Longsen\",\"expiryMonth\":\"09\",\"expiryYear\":\"2018\"},\"billing\":{\"street1\":\"456 My Street\",\"street2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"postcode\":\"K1C2N6\",\"country\":\"CA\"},\"risk\":{\"score\":\"100\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 13:42:12+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_ed9f9af4170942719cf6e3446f823f45\"}" + end + + def failed_purchase_response + "{\"id\":\"8a82944a5fe827040160030a3308412d\",\"paymentType\":\"DB\",\"paymentBrand\":\"VISA\",\"result\":{\"code\":\"100.100.101\",\"description\":\"invalid creditcard, bank account number or bank name\"},\"card\":{\"bin\":\"420000\",\"last4Digits\":\"0001\",\"holder\":\"Longbob Longsen\",\"expiryMonth\":\"09\",\"expiryYear\":\"2018\"},\"billing\":{\"street1\":\"456 My Street\",\"street2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"postcode\":\"K1C2N6\",\"country\":\"CA\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 14:31:28+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_43d463600f8d429ea6ac09cf25fd9f24\"}" + end + + def successful_authorize_response + "{\"id\":\"8a82944a5fe82704016002caa42c14f8\",\"paymentType\":\"PA\",\"paymentBrand\":\"VISA\",\"amount\":\"1.00\",\"currency\":\"EUR\",\"descriptor\":\"8374.4038.5698 OPP_Channel \",\"result\":{\"code\":\"000.100.110\",\"description\":\"Request successfully processed in 'Merchant in Integrator Test Mode'\"},\"card\":{\"bin\":\"420000\",\"last4Digits\":\"0000\",\"holder\":\"Longbob Longsen\",\"expiryMonth\":\"09\",\"expiryYear\":\"2018\"},\"billing\":{\"street1\":\"456 My Street\",\"street2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"postcode\":\"K1C2N6\",\"country\":\"CA\"},\"risk\":{\"score\":\"100\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 13:22:03+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_fc59650eafc84da29ce10e7171e71a34\"}" + end + + def failed_authorize_response + "{\"paymentType\":\"PA\",\"paymentBrand\":\"VISA\",\"result\":{\"code\":\"800.100.151\",\"description\":\"transaction declined (invalid card)\"},\"card\":{\"bin\":\"420000\",\"last4Digits\":\"0000\",\"holder\":\"Longbob Longsen\",\"expiryMonth\":\"09\",\"expiryYear\":\"2018\"},\"billing\":{\"street1\":\"456 My Street\",\"street2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"postcode\":\"K1C2N6\",\"country\":\"CA\"},\"customParameters\":{\"forceResultCode\":\"800.100.151\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 13:50:31+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_1077c67bc41048ff887da9ab9ee8b89d\"}" + end + + def successful_capture_response + "{\"id\":\"8a82944a5fe82704016002caa7cd1513\",\"paymentType\":\"CP\",\"amount\":\"1.00\",\"currency\":\"EUR\",\"descriptor\":\"4938.4300.2018 OPP_Channel\",\"result\":{\"code\":\"000.100.110\",\"description\":\"Request successfully processed in 'Merchant in Integrator Test Mode'\"},\"risk\":{\"score\":\"0\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 13:22:03+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_fb956c7668a04e18af61519693a1d114\"}" + end + + def failed_capture_response + "{\"id\":\"8a82944a5fe8270401600313d3965bca\",\"paymentType\":\"CP\",\"result\":{\"code\":\"700.400.510\",\"description\":\"capture needs at least one successful transaction of type (PA)\"},\"risk\":{\"score\":\"0\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 14:41:59+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_8abfd898a6cd406f94181d9096607aea\"}" + end + + def successful_refund_response + "{\"id\":\"8a82944a5fe82704016002cc88f61731\",\"paymentType\":\"RF\",\"amount\":\"1.00\",\"currency\":\"EUR\",\"descriptor\":\"3478.1411.3954 OPP_Channel\",\"result\":{\"code\":\"000.100.110\",\"description\":\"Request successfully processed in 'Merchant in Integrator Test Mode'\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 13:24:07+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_99293f4fffe64105870e77b8e18c0c02\"}" + end + + def failed_refund_response + "{\"result\":{\"code\":\"200.300.404\",\"description\":\"invalid or missing parameter\",\"parameterErrors\":[{\"name\":\"paymentType\",\"value\":\"RF\",\"message\":\"must be one of [PA, DB, CD, PA.CP]\"},{\"name\":\"paymentBrand\",\"value\":null,\"message\":\"card properties must be set\"}]},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 14:33:31+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_febee8f6863b4392b064b23602f3f382\"}" + end + + def successful_void_response + "{\"id\":\"8a8294495fe8084a016002cc489446d6\",\"paymentType\":\"RV\",\"amount\":\"1.00\",\"currency\":\"EUR\",\"descriptor\":\"9673.6314.6402 OPP_Channel\",\"result\":{\"code\":\"000.100.110\",\"description\":\"Request successfully processed in 'Merchant in Integrator Test Mode'\"},\"risk\":{\"score\":\"0\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 13:23:50+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_744a5416960a420da01edc3b3daf6c6f\"}" + end + + def failed_void_response + "{\"result\":{\"code\":\"200.300.404\",\"description\":\"invalid or missing parameter\",\"parameterErrors\":[{\"name\":\"paymentBrand\",\"value\":null,\"message\":\"card properties must be set\"},{\"name\":\"paymentType\",\"value\":\"RV\",\"message\":\"must be one of [PA, DB, CD, PA.CP]\"},{\"name\":\"amount\",\"value\":null,\"message\":\"may not be empty\"},{\"name\":\"currency\",\"value\":null,\"message\":\"may not be empty\"}]},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 14:34:50+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_4a909e0b99214eb9b155b46a2c67df30\"}" + end + + def successful_credit_response + "{\"id\":\"8a8294495fe8084a01600332a83d4899\",\"paymentType\":\"CD\",\"paymentBrand\":\"VISA\",\"amount\":\"1.00\",\"currency\":\"EUR\",\"descriptor\":\"2299.3739.4338 OPP_Channel \",\"result\":{\"code\":\"000.100.110\",\"description\":\"Request successfully processed in 'Merchant in Integrator Test Mode'\"},\"card\":{\"bin\":\"420000\",\"last4Digits\":\"0000\",\"holder\":\"Longbob Longsen\",\"expiryMonth\":\"09\",\"expiryYear\":\"2018\"},\"billing\":{\"street1\":\"456 My Street\",\"street2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"postcode\":\"K1C2N6\",\"country\":\"CA\"},\"risk\":{\"score\":\"100\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 15:15:39+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_691783d2e7834e6eb8ca011f4fee1b74\"}" + end +end From 2855e9a2d7dd7ad693d37efcd0638d8cde08e957 Mon Sep 17 00:00:00 2001 From: Bart Date: Wed, 29 Nov 2017 15:44:36 -0500 Subject: [PATCH 241/677] Prevent frozen objects being assigned as wiredump device (#2660) The wiredump device takes an object that quacks like an IO stream (e.g. File or String) and passes it along to Net:HTTP#set_debug_output where it is used by the private `D` method for appending log messages, as seen here: https://github.com/ruby/ruby/blob/c91cb76f8d84b2963f6ede2ef445ad46a6104216/lib/net/http.rb#L1567 If the device is set to an empty string literal (i.e. "") and the frozen string literal magic comment is added to the file, this causes `RuntimeError: can't modify frozen String` exceptions. The stacktrace can be confusing since setting up the gateway object and using it usually happens in different places in the application code. This PR aims to fail early if such a situation occurs and provide a stacktrace that clearly points to the cause of the error. --- lib/active_merchant/connection.rb | 7 ++++++- test/unit/connection_test.rb | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index 8ef1fcd57cb..b859cc1f76c 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -25,7 +25,7 @@ class Connection attr_accessor :ca_path attr_accessor :pem attr_accessor :pem_password - attr_accessor :wiredump_device + attr_reader :wiredump_device attr_accessor :logger attr_accessor :tag attr_accessor :ignore_http_status @@ -48,6 +48,11 @@ def initialize(endpoint) @proxy_port = nil end + def wiredump_device=(device) + raise ArgumentError, "can't wiredump to frozen #{device.class}" if device && device.frozen? + @wiredump_device = device + end + def request(method, body, headers = {}) request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC) diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index 8486ef987d9..6417270fe83 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -178,4 +178,11 @@ def test_failure_with_ssl_certificate end end + def test_wiredump_service_raises_on_frozen_object + transcript = ''.freeze + assert_raise ArgumentError, "can't wiredump to frozen object" do + @connection.wiredump_device = transcript + end + end + end From c8eee7619301d13f10f6f72eb678c9da99c03468 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Tue, 28 Nov 2017 18:27:19 -0500 Subject: [PATCH 242/677] Safe Charge: Provisions adapter for 3DS purchases Safe Charge has implemented a system by which they determine whether purchases should be routed through the 3DS flow or not. If the merchant is not approved for 3DS, transactions will occur as before, outside of the 3DS flow. If a merchant is approved for 3DS, Sage Charge will evaluate the card for enrollment status. If the card is not enrolled, it will be processed as a 'regular' transaction. If the card is enrolled, the Safe Charge response will include the 'xid', 'ascurl', and the 'pareq'. Closes #2661 Remote Tests: 21 tests, 62 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit Tests: 17 tests, 76 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/safe_charge.rb | 28 ++++++++++----- test/fixtures.yml | 4 +++ .../gateways/remote_safe_charge_test.rb | 34 +++++++++++++++++++ test/unit/gateways/safe_charge_test.rb | 23 +++++++++++++ 5 files changed, 82 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f2f231b9809..f5650cf042c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Global Collect: Adds boolean option for pre_authorization [deeedeelavinder] #2651 * Credorax: Pass Transaction Type field [curiousepic] #2653 * Add CardProcess Gateway [bpollack] #2659 +* Safe Charge: Provision 3DS option for approved merchants [deedeelavinder] #2661 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index e7e8bd74088..e62a9a9c1ab 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -22,7 +22,8 @@ def initialize(options={}) def purchase(money, payment, options={}) post = {} - add_transaction_data("Sale", post, money, options) + post[:sg_APIType] = 1 + add_transaction_data("Sale3D", post, money, options) add_payment(post, payment) add_customer_details(post, payment, options) @@ -150,21 +151,32 @@ def parse(xml) doc = Nokogiri::XML(xml) doc.root.xpath('*').each do |node| - response[node.name.underscore.downcase.to_sym] = node.text + if node.elements.size == 0 + response[node.name.underscore.downcase.to_sym] = node.text + else + node.traverse do |childnode| + childnode_to_response(response, childnode) + end + end end - response end - def childnode_to_response(response, node, childnode) - name = "#{node.name.downcase}_#{childnode.name.downcase}" - if name == 'payment_method_data' && !childnode.elements.empty? - response[name.to_sym] = Hash.from_xml(childnode.to_s).values.first + def childnode_to_response(response, childnode) + if childnode.elements.size == 0 + element_name_to_symbol(response, childnode) else - response[name.to_sym] = childnode.text + childnode.traverse do |childnode| + element_name_to_symbol(response, childnode) + end end end + def element_name_to_symbol(response, childnode) + name = "#{childnode.name.downcase}" + response[name.to_sym] = childnode.text + end + def commit(parameters) url = (test? ? test_url : live_url) response = parse(ssl_post(url, post_data(parameters))) diff --git a/test/fixtures.yml b/test/fixtures.yml index afe7076207c..91fdfe5799f 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -1053,6 +1053,10 @@ safe_charge: client_login_id: 'SpreedlyTestTRX' client_password: '5Jp5xKmgqY' +safe_charge_three_ds: + client_login_id: 'SpreedlyManTestTRX' + client_password: 'iGx9DQQHQG' + sage: login: 214282982451 password: 'Z5W2S8J7X8T5' diff --git a/test/remote/gateways/remote_safe_charge_test.rb b/test/remote/gateways/remote_safe_charge_test.rb index d51b0ba550f..f137d721f1b 100644 --- a/test/remote/gateways/remote_safe_charge_test.rb +++ b/test/remote/gateways/remote_safe_charge_test.rb @@ -13,6 +13,40 @@ def setup description: 'Store Purchase', currency: "EUR" } + + @three_ds_gateway = SafeChargeGateway.new(fixtures(:safe_charge_three_ds)) + @three_ds_enrolled_card = credit_card('4012 0010 3749 0014') + @three_ds_non_enrolled_card = credit_card('5333 3062 3122 6927') + @three_ds_invalid_pa_res_card = credit_card('4012 0010 3749 0006') + end + + def test_successful_3ds_purchase + response = @three_ds_gateway.purchase(@amount, @three_ds_enrolled_card, @options) + assert_success response + assert !response.params["acsurl"].blank? + assert !response.params["pareq"].blank? + assert !response.params["xid"].blank? + assert_equal 'Success', response.message + end + + def test_successful_regular_purchase_through_3ds_flow_with_non_enrolled_card + response = @three_ds_gateway.purchase(@amount, @three_ds_non_enrolled_card, @options) + assert_success response + assert response.params["acsurl"].blank? + assert response.params["pareq"].blank? + assert response.params["xid"].blank? + assert response.params["threedflow"] = 1 + assert_equal 'Success', response.message + end + + def test_successful_regular_purchase_through_3ds_flow_with_invalid_pa_res + response = @three_ds_gateway.purchase(@amount, @three_ds_invalid_pa_res_card, @options) + assert_success response + assert !response.params["acsurl"].blank? + assert !response.params["pareq"].blank? + assert !response.params["xid"].blank? + assert response.params["threedflow"] = 1 + assert_equal 'Success', response.message end def test_successful_purchase diff --git a/test/unit/gateways/safe_charge_test.rb b/test/unit/gateways/safe_charge_test.rb index ce86ab35e72..1133f77a76f 100644 --- a/test/unit/gateways/safe_charge_test.rb +++ b/test/unit/gateways/safe_charge_test.rb @@ -1,9 +1,12 @@ require 'test_helper' class SafeChargeTest < Test::Unit::TestCase + include CommStub + def setup @gateway = SafeChargeGateway.new(client_login_id: 'login', client_password: 'password') @credit_card = credit_card + @three_ds_enrolled_card = credit_card('4012 0010 3749 0014') @amount = 100 @options = { @@ -158,6 +161,20 @@ def test_scrub assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed end + def test_3ds_response + purchase = stub_comms do + @gateway.purchase(@amount, @three_ds_enrolled_card, @options) + end.check_request do |endpoint, data, headers| + assert_match(/Sale3D/, data) + assert_match(/sg_APIType/, data) + end.respond_with(successful_3ds_purchase_response) + + assert_success purchase + assert_equal "MDAwMDAwMDAwMDE1MTAxMDgzMTA=", purchase.params["xid"] + assert_equal "eJxVUdtuwjAM/ZWK95GYgijIjVTWaUNTGdqQ4DUKFq2gF9J0A75+SVcuixTF59g+sY5xlWqi+ItUo0lgQnUtd+Rl27BXyScYAQce+MB7ApfRJx0FfpOus7IQ0Of9AbIrtK1apbIwAqU6zuYLMQSY8ABZBzEnPY8FfzhjGCH7o7GQOYlIq9J4K6qNd5VD1mZQlU1h9FkEQ47sCrDRB5EaU00ZO5RKHtKyth2ORXYfaNm4qLYqp2wrkjj6ud8XSFbRKYl3F/uGyFwFbqUhMeAwBvC5B6Opz6c+IGt5lLn73hlgR+kAVu6PqMu4xCOB1l1NhTqLydg6ckNIp6osyFZYJ28xsvvAz2/OT2WsRa+bdf2+X6cXtd9oHxZNPks+ojB0DrcFTi2zrkDAJ62cA8icBOuWx7oF2+jf4n8B", purchase.params["pareq"] + assert_equal "https://pit.3dsecure.net/VbVTestSuiteService/pit1/acsService/paReq?summary=MjRlZGYwY2EtZTk5Zi00NDJjLTljOTAtNWUxZmRhMjEwODg3", purchase.params["acsurl"] + end + private def pre_scrubbed @@ -287,4 +304,10 @@ def failed_void_response 4.1.0SpreedlyTestTRX101508208633ERRORInvalid Amount-11001201-12jmj7l5rSw0yVb/vlWAYkK/YBwk=0 ) end + + def successful_3ds_purchase_response + %( + 4.1.0SpreedlyManTestTRX98bd80c8c9534088311153ad6a67d108101510108310APPROVED00ZQBpAFAAMwBTAEcAMQBZAHcASQA4ADoAPQBlACQAZAB3ACMAWwAyAFoAWQBLAFUAPwBTAHYAKQAnAHQAUAA2AHYAYwAoAG0ARgBNAEEAcAAlAGEAMwA=YeJxVUdtuwjAM/ZWK95GYgijIjVTWaUNTGdqQ4DUKFq2gF9J0A75+SVcuixTF59g+sY5xlWqi+ItUo0lgQnUtd+Rl27BXyScYAQce+MB7ApfRJx0FfpOus7IQ0Of9AbIrtK1apbIwAqU6zuYLMQSY8ABZBzEnPY8FfzhjGCH7o7GQOYlIq9J4K6qNd5VD1mZQlU1h9FkEQ47sCrDRB5EaU00ZO5RKHtKyth2ORXYfaNm4qLYqp2wrkjj6ud8XSFbRKYl3F/uGyFwFbqUhMeAwBvC5B6Opz6c+IGt5lLn73hlgR+kAVu6PqMu4xCOB1l1NhTqLydg6ckNIp6osyFZYJ28xsvvAz2/OT2WsRa+bdf2+X6cXtd9oHxZNPks+ojB0DrcFTi2zrkDAJ62cA8icBOuWx7oF2+jf4n8B000000000000715https://pit.3dsecure.net/VbVTestSuiteService/pit1/acsService/paReq?summary=MjRlZGYwY2EtZTk5Zi00NDJjLTljOTAtNWUxZmRhMjEwODg3MDAwMDAwMDAwMDE1MTAxMDgzMTA=19Visa Production Support Client Bid 1usrDNDlh6XR8R6CVdGQyqDkZzdqE0=10Debit01EUR1EUR + ) + end end From 93ec51ad6532aa5464b13233b564b1d06449b59d Mon Sep 17 00:00:00 2001 From: David Perry Date: Thu, 30 Nov 2017 11:21:31 -0500 Subject: [PATCH 243/677] PayU Latam: Require payment_country on initialize Since merchant accounts must be tied to a payment country, this finally makes payment_country required for initalizing the gateway, and removes support for overriding it with an option field. Also, tests for refund and void are renamed and expect failure as they are not currently supported in the sandbox. When they become supported, these should fail, flagging them to be updated as passing tests. Declined and pending test cards are now throwing a new unexpected error, unrelated to these changes. Closes #2663 Remote: 18 tests, 47 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 83.3333% passed Unit: 22 tests, 83 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/payu_latam.rb | 17 +++-- .../remote/gateways/remote_payu_latam_test.rb | 26 ++++---- test/unit/gateways/payu_latam_test.rb | 65 ++++--------------- 4 files changed, 36 insertions(+), 73 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f5650cf042c..f9d94017922 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * Credorax: Pass Transaction Type field [curiousepic] #2653 * Add CardProcess Gateway [bpollack] #2659 * Safe Charge: Provision 3DS option for approved merchants [deedeelavinder] #2661 +* PayU Latam: Require payment_country on initialize [curiousepic] #2663 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index aa35628d232..d2812c01dd3 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -29,9 +29,8 @@ class PayuLatamGateway < Gateway } def initialize(options={}) - requires!(options, :merchant_id, :account_id, :api_login, :api_key) + requires!(options, :merchant_id, :account_id, :api_login, :api_key, :payment_country) super - @options[:payment_country] ||= options[:payment_country] if options[:payment_country] end def purchase(amount, payment_method, options={}) @@ -139,7 +138,7 @@ def add_credentials(post, command) def add_transaction_elements(post, type, options) transaction = {} - transaction[:paymentCountry] = @options[:payment_country] || (options[:billing_address][:country] if options[:billing_address]) + transaction[:paymentCountry] = @options[:payment_country] transaction[:type] = type transaction[:ipAddress] = options[:ip] || '' transaction[:userAgent] = options[:user_agent] if options[:user_agent] @@ -167,7 +166,7 @@ def add_payer(post, payment_method, options) payer[:dniNumber] = options[:dni_number] if options[:dni_number] payer[:dniType] = options[:dni_type] if options[:dni_type] payer[:emailAddress] = options[:email] if options[:email] - payer[:birthdate] = options[:birth_date] if options[:birth_date] && options[:payment_country] == 'MX' + payer[:birthdate] = options[:birth_date] if options[:birth_date] && @options[:payment_country] == 'MX' payer[:billingAddress] = billing_address_fields(options) post[:transaction][:payer] = payer end @@ -180,7 +179,7 @@ def billing_address_fields(options) billing_address[:city] = address[:city] billing_address[:state] = address[:state] billing_address[:country] = address[:country] - billing_address[:postalCode] = address[:zip] if options[:payment_country] == 'MX' + billing_address[:postalCode] = address[:zip] if @options[:payment_country] == 'MX' billing_address[:phone] = address[:phone] billing_address end @@ -191,7 +190,7 @@ def add_buyer(post, payment_method, options) buyer[:fullName] = buyer_hash[:name] buyer[:dniNumber] = buyer_hash[:dni_number] buyer[:dniType] = buyer_hash[:dni_type] - buyer[:cnpj] = buyer_hash[:cnpj] if options[:payment_country] == 'BR' + buyer[:cnpj] = buyer_hash[:cnpj] if @options[:payment_country] == 'BR' buyer[:emailAddress] = buyer_hash[:email] buyer[:contactPhone] = (options[:billing_address][:phone] if options[:billing_address]) || (options[:shipping_address][:phone] if options[:shipping_address]) || '' buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address] @@ -199,7 +198,7 @@ def add_buyer(post, payment_method, options) buyer[:fullName] = payment_method.name.strip buyer[:dniNumber] = options[:dni_number] buyer[:dniType] = options[:dni_type] - buyer[:cnpj] = options[:cnpj] if options[:payment_country] == 'BR' + buyer[:cnpj] = options[:cnpj] if @options[:payment_country] == 'BR' buyer[:emailAddress] = options[:email] buyer[:contactPhone] = (options[:billing_address][:phone] if options[:billing_address]) || (options[:shipping_address][:phone] if options[:shipping_address]) || '' buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address] @@ -235,8 +234,8 @@ def add_invoice(post, money, options) additional_values = {} additional_values[:TX_VALUE] = tx_value - additional_values[:TX_TAX] = tx_tax if options[:payment_country] == 'CO' - additional_values[:TX_TAX_RETURN_BASE] = tx_tax_return_base if options[:payment_country] == 'CO' + additional_values[:TX_TAX] = tx_tax if @options[:payment_country] == 'CO' + additional_values[:TX_TAX_RETURN_BASE] = tx_tax_return_base if @options[:payment_country] == 'CO' post[:transaction][:order][:additionalValues] = additional_values end diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index 1ea9a9be146..c6660e14e73 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -37,7 +37,7 @@ def setup # supports auth and purchase transactions only def test_invalid_login - gateway = PayuLatamGateway.new(merchant_id: "", account_id: "", api_login: "U", api_key: "U") + gateway = PayuLatamGateway.new(merchant_id: "", account_id: "", api_login: "U", api_key: "U", payment_country: "AR") response = gateway.purchase(@amount, @credit_card, @options) assert_failure response end @@ -50,7 +50,7 @@ def test_successful_purchase end def test_successul_purchase_with_buyer - gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512327")) + gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512327", payment_country: "BR")) options_buyer = { currency: "BRL", @@ -88,7 +88,7 @@ def test_successul_purchase_with_buyer end def test_successful_purchase_brazil - gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512327")) + gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512327", payment_country: "BR")) options_brazil = { payment_country: "BR", @@ -123,7 +123,7 @@ def test_successful_purchase_brazil end def test_successful_purchase_colombia - gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512321")) + gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512321", payment_country: "CO")) options_colombia = { payment_country: "CO", @@ -157,7 +157,7 @@ def test_successful_purchase_colombia end def test_successful_purchase_mexico - gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512324")) + gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512324", payment_country: "MX")) options_mexico = { payment_country: "MX", @@ -230,13 +230,14 @@ def test_failed_refund assert_match (/property: parentTransactionId, message: must not be null/), response.message end - def test_successful_void + # If this test fails, support for void may have been added to the sandbox + def test_unsupported_test_void_fails_as_expected auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth assert void = @gateway.void(auth.authorization) - assert_success void - assert_equal "APPROVED", void.message + assert_failure void + assert_equal "Internal payment provider error. ", void.message end def test_failed_void @@ -245,13 +246,14 @@ def test_failed_void assert_match (/property: parentTransactionId, message: must not be null/), response.message end - def test_successful_authorize_and_capture + # If this test fails, support for captures may have been added to the sandbox + def test_unsupported_test_capture_fails_as_expected auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth assert capture = @gateway.capture(@amount, auth.authorization) - assert_success capture - assert_equal 'APPROVED', response.message + assert_failure capture + assert_equal 'Internal payment provider error. ', capture.message end def test_failed_capture @@ -263,7 +265,7 @@ def test_failed_capture def test_verify_credentials assert @gateway.verify_credentials - gateway = PayuLatamGateway.new(merchant_id: "X", account_id: "512322", api_login: "X", api_key: "X") + gateway = PayuLatamGateway.new(merchant_id: "X", account_id: "512322", api_login: "X", api_key: "X", payment_country: "AR") assert !gateway.verify_credentials end diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb index 160a7642f11..e0305156a4e 100644 --- a/test/unit/gateways/payu_latam_test.rb +++ b/test/unit/gateways/payu_latam_test.rb @@ -4,7 +4,7 @@ class PayuLatamTest < Test::Unit::TestCase include CommStub def setup - @gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key') + @gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key', payment_country: 'AR') @amount = 4000 @credit_card = credit_card("4097440000000004", verification_value: "444", first_name: "APPROVED", last_name: "") @@ -209,8 +209,9 @@ def test_buyer_fields_default_to_payer end def test_brazil_required_fields + gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key', payment_country: 'BR') + options_brazil = { - payment_country: 'BR', currency: "BRL", billing_address: address( address1: "Calle 100", @@ -235,16 +236,17 @@ def test_brazil_required_fields } } - stub_comms do - @gateway.purchase(@amount, @credit_card, @options.update(options_brazil)) + stub_comms(gateway) do + gateway.purchase(@amount, @credit_card, @options.update(options_brazil)) end.check_request do |endpoint, data, headers| assert_match(/\"cnpj\":\"32593371000110\"/, data) end.respond_with(successful_purchase_response) end def test_colombia_required_fields + gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key', payment_country: 'CO') + options_colombia = { - payment_country: "CO", currency: "COP", billing_address: address( address1: "Calle 100", @@ -268,16 +270,17 @@ def test_colombia_required_fields tx_tax_return_base: '16806' } - stub_comms do - @gateway.purchase(@amount, @credit_card, @options.update(options_colombia)) + stub_comms(gateway) do + gateway.purchase(@amount, @credit_card, @options.update(options_colombia)) end.check_request do |endpoint, data, headers| assert_match(/\"additionalValues\":{\"TX_VALUE\":{\"value\":\"40.00\",\"currency\":\"COP\"},\"TX_TAX\":{\"value\":0,\"currency\":\"COP\"},\"TX_TAX_RETURN_BASE\":{\"value\":0,\"currency\":\"COP\"}}/, data) end.respond_with(successful_purchase_response) end def test_mexico_required_fields + gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key', payment_country: 'MX') + options_mexico = { - payment_country: "MX", currency: "MXN", billing_address: address( address1: "Calle 100", @@ -300,55 +303,13 @@ def test_mexico_required_fields birth_date: '1985-05-25' } - stub_comms do - @gateway.purchase(@amount, @credit_card, @options.update(options_mexico)) + stub_comms(gateway) do + gateway.purchase(@amount, @credit_card, @options.update(options_mexico)) end.check_request do |endpoint, data, headers| assert_match(/\"birthdate\":\"1985-05-25\"/, data) end.respond_with(successful_purchase_response) end - def test_payment_country_set_from_credential_or_options - gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key', payment_country: 'payment_country') - assert_match gateway.options[:payment_country], "payment_country" - - stub_comms do - gateway.purchase(@amount, @credit_card, @options) - end.check_request do |endpoint, data, headers| - assert_match(/\"paymentCountry\":\"payment_country\"/, data) - end.respond_with(successful_purchase_response) - - gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key') - assert_nil gateway.options[:payment_country] - - stub_comms do - gateway.purchase(@amount, @credit_card, @options.merge(payment_country: 'payment_country')) - end.check_request do |endpoint, data, headers| - assert_match(/\"paymentCountry\":\"payment_country\"/, data) - end.respond_with(successful_purchase_response) - end - - def test_payment_country_defaults_to_billing_address - options_mexico = { - currency: "MXN", - billing_address: address( - address1: "Calle 100", - address2: "BL4", - city: "Guadalajara", - state: "Jalisco", - country: "MX", - zip: "09210710", - phone: "(11)756312633" - ), - birth_date: '1985-05-25' - } - - stub_comms do - @gateway.purchase(@amount, @credit_card, @options.update(options_mexico)) - end.check_request do |endpoint, data, headers| - assert_match(/\"paymentCountry\":\"MX\"/, data) - end.respond_with(successful_purchase_response) - end - def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed From eab54dac38ebd4a9f35d69715be049567f9acf7c Mon Sep 17 00:00:00 2001 From: Niaja Date: Wed, 6 Dec 2017 15:23:05 -0500 Subject: [PATCH 244/677] Adyen: Remove CVV as Required Field and Determines shopperInteraction Adyen gateway does not require that cvv is passed, it shouldn't be used in recurring transactions. Updates shopperInteraction to be determined using based on if the cvv is passed. This can be overridden by passing the value directly. Loaded suite test/remote/gateways/remote_adyen_test 28 tests, 68 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/adyen_test 17 tests, 84 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2665 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 10 ++++++++-- test/remote/gateways/remote_adyen_test.rb | 8 ++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f9d94017922..6fb135a5948 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * Add CardProcess Gateway [bpollack] #2659 * Safe Charge: Provision 3DS option for approved merchants [deedeelavinder] #2661 * PayU Latam: Require payment_country on initialize [curiousepic] #2663 +* Adyen: Remove CVV as Required Field and Determines shopperInteraction [nfarve] #2665 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index 8671328664d..d4ebdc8bc64 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -45,6 +45,7 @@ def authorize(money, payment, options={}) add_invoice(post, money, options) add_payment(post, payment) add_extra_data(post, options) + add_shopper_interaction(post,payment,options) add_address(post, options) commit('authorise', post) end @@ -97,7 +98,11 @@ def add_extra_data(post, options) post[:selectedBrand] = options[:selected_brand] if options[:selected_brand] post[:deliveryDate] = options[:delivery_date] if options[:delivery_date] post[:merchantOrderReference] = options[:merchant_order_reference] if options[:merchant_order_reference] - post[:shopperInteraction] = options[:shopper_interaction] if options[:shopper_interaction] + end + + def add_shopper_interaction(post, payment, options={}) + shopper_interaction = payment.verification_value ? "Ecommerce" : "ContAuth" + post[:shopperInteraction] = options[:shopper_interaction] || shopper_interaction end def add_address(post, options) @@ -138,8 +143,9 @@ def add_payment(post, payment) number: payment.number, cvc: payment.verification_value } + card.delete_if{|k,v| v.blank? } - requires!(card, :expiryMonth, :expiryYear, :holderName, :number, :cvc) + requires!(card, :expiryMonth, :expiryYear, :holderName, :number) post[:card] = card end diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb index c4eac422d28..ec55953c309 100644 --- a/test/remote/gateways/remote_adyen_test.rb +++ b/test/remote/gateways/remote_adyen_test.rb @@ -45,6 +45,14 @@ def test_successful_purchase assert_equal '[capture-received]', response.message end + def test_successful_purchase_no_cvv + credit_card = @credit_card + credit_card.verification_value = nil + response = @gateway.purchase(@amount, credit_card, @options) + assert_success response + assert_equal '[capture-received]', response.message + end + def test_successful_purchase_with_more_options options = @options.merge!(fraudOffset: '1') response = @gateway.purchase(@amount, @credit_card, options) From 43ca00e12047fd8c60d0cf5eb129f71e9de674e8 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Thu, 7 Dec 2017 09:05:17 -0500 Subject: [PATCH 245/677] SafeCharge: add support for VendorID, WebsiteID, and IP logging Furthers ENRG-7184 Closes #2667 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/safe_charge.rb | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 6fb135a5948..01e627a0e22 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * Safe Charge: Provision 3DS option for approved merchants [deedeelavinder] #2661 * PayU Latam: Require payment_country on initialize [curiousepic] #2663 * Adyen: Remove CVV as Required Field and Determines shopperInteraction [nfarve] #2665 +* SafeCharge: add support for VendorID, WebsiteID, and IP logging [bpollack] #2667 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index e62a9a9c1ab..8ba42f09671 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -121,6 +121,9 @@ def add_transaction_data(trans_type, post, money, options) post[:sg_UserID] = options[:user_id] if options[:user_id] post[:sg_AuthType] = options[:auth_type] if options[:auth_type] post[:sg_ExpectedFulfillmentCount] = options[:expected_fulfillment_count] if options[:expected_fulfillment_count] + post[:sg_WebsiteID] = options[:website_id] if options[:website_id] + post[:sg_IPAddress] = options[:ip] if options[:ip] + post[:sg_VendorID] = options[:vendor_id] if options[:vendor_id] end def add_payment(post, payment) From b93dff1dc45876a1ac125d70bfa74beb90a9179b Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Thu, 7 Dec 2017 10:20:57 -0500 Subject: [PATCH 246/677] Safe Charge: Adds 3DS flag The documentation and sandbox indicated that Safe Charge had an internal method for determining 3DS status/flow. This adds an explicit 3DS flag when/if there are issues with that internal mechanism. Closes #2668 Unit Tests: 17 tests, 76 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote Tests: 21 tests, 62 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/safe_charge.rb | 5 +++-- test/remote/gateways/remote_safe_charge_test.rb | 7 ++++--- test/unit/gateways/safe_charge_test.rb | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 01e627a0e22..01df0e1a1e4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * PayU Latam: Require payment_country on initialize [curiousepic] #2663 * Adyen: Remove CVV as Required Field and Determines shopperInteraction [nfarve] #2665 * SafeCharge: add support for VendorID, WebsiteID, and IP logging [bpollack] #2667 +* Safe Charge: Adds 3DS flag [deedeelavinder] #2668 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index 8ba42f09671..373ae08d024 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -22,8 +22,9 @@ def initialize(options={}) def purchase(money, payment, options={}) post = {} - post[:sg_APIType] = 1 - add_transaction_data("Sale3D", post, money, options) + post[:sg_APIType] = 1 if options[:three_d_secure] + trans_type = options[:three_d_secure] ? "Sale3D" : "Sale" + add_transaction_data(trans_type, post, money, options) add_payment(post, payment) add_customer_details(post, payment, options) diff --git a/test/remote/gateways/remote_safe_charge_test.rb b/test/remote/gateways/remote_safe_charge_test.rb index f137d721f1b..ca9e1778871 100644 --- a/test/remote/gateways/remote_safe_charge_test.rb +++ b/test/remote/gateways/remote_safe_charge_test.rb @@ -14,6 +14,7 @@ def setup currency: "EUR" } + @three_ds_options = @options.merge(three_d_secure: true) @three_ds_gateway = SafeChargeGateway.new(fixtures(:safe_charge_three_ds)) @three_ds_enrolled_card = credit_card('4012 0010 3749 0014') @three_ds_non_enrolled_card = credit_card('5333 3062 3122 6927') @@ -21,7 +22,7 @@ def setup end def test_successful_3ds_purchase - response = @three_ds_gateway.purchase(@amount, @three_ds_enrolled_card, @options) + response = @three_ds_gateway.purchase(@amount, @three_ds_enrolled_card, @three_ds_options) assert_success response assert !response.params["acsurl"].blank? assert !response.params["pareq"].blank? @@ -30,7 +31,7 @@ def test_successful_3ds_purchase end def test_successful_regular_purchase_through_3ds_flow_with_non_enrolled_card - response = @three_ds_gateway.purchase(@amount, @three_ds_non_enrolled_card, @options) + response = @three_ds_gateway.purchase(@amount, @three_ds_non_enrolled_card, @three_ds_options) assert_success response assert response.params["acsurl"].blank? assert response.params["pareq"].blank? @@ -40,7 +41,7 @@ def test_successful_regular_purchase_through_3ds_flow_with_non_enrolled_card end def test_successful_regular_purchase_through_3ds_flow_with_invalid_pa_res - response = @three_ds_gateway.purchase(@amount, @three_ds_invalid_pa_res_card, @options) + response = @three_ds_gateway.purchase(@amount, @three_ds_invalid_pa_res_card, @three_ds_options) assert_success response assert !response.params["acsurl"].blank? assert !response.params["pareq"].blank? diff --git a/test/unit/gateways/safe_charge_test.rb b/test/unit/gateways/safe_charge_test.rb index 1133f77a76f..3685b8879e3 100644 --- a/test/unit/gateways/safe_charge_test.rb +++ b/test/unit/gateways/safe_charge_test.rb @@ -14,6 +14,7 @@ def setup billing_address: address, description: 'Store Purchase' } + @three_ds_options = @options.merge(three_d_secure: true) end def test_successful_purchase @@ -163,7 +164,7 @@ def test_scrub def test_3ds_response purchase = stub_comms do - @gateway.purchase(@amount, @three_ds_enrolled_card, @options) + @gateway.purchase(@amount, @three_ds_enrolled_card, @three_ds_options) end.check_request do |endpoint, data, headers| assert_match(/Sale3D/, data) assert_match(/sg_APIType/, data) From b4e4943a8fc12d158013a82e2540021c723002d7 Mon Sep 17 00:00:00 2001 From: Niaja Date: Thu, 7 Dec 2017 15:36:01 -0500 Subject: [PATCH 247/677] PayU Latam: Change default text for description Updates description to include merchant_id if there is no description. Updates the tests for purchases in Colombia to properly use tax information and to match the test example provided in docs. 3 remote tests are failing that are not related to these changes Closes #2669 Remote Tests: Finished in 49.482971 seconds. 19 tests, 50 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 84.2105% passed Unit Tests: Finished in 0.015186 seconds. 22 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/payu_latam.rb | 2 +- test/remote/gateways/remote_payu_latam_test.rb | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 01df0e1a1e4..f72d41df60c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* PayU Latam: Change default text for description [nfarve] #2669 * Checkout V2: Allows AVS and CVV result details to come through on authorizations [deedeelavinder] #2650 * Global Collect: Adds boolean option for pre_authorization [deeedeelavinder] #2651 * Credorax: Pass Transaction Type field [curiousepic] #2653 diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index d2812c01dd3..67f74ad3044 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -152,7 +152,7 @@ def add_order(post, options) order[:accountId] = @options[:account_id] order[:partnerId] = options[:partner_id] if options[:partner_id] order[:referenceCode] = options[:order_id] || generate_unique_id - order[:description] = options[:description] || 'unspecified' + order[:description] = options[:description] || 'Compra en ' + @options[:merchant_id] order[:language] = 'en' order[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address] post[:transaction][:order] = order diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index c6660e14e73..7d97c9d846a 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -146,11 +146,11 @@ def test_successful_purchase_colombia zip: "01019-030", phone: "(11)756312633" ), - tx_tax: '3193', - tx_tax_return_base: '16806' + tax: "3193", + tax_return_base: "16806" } - response = gateway.purchase(@amount, @credit_card, @options.update(options_colombia)) + response = gateway.purchase(2000000, @credit_card, @options.update(options_colombia)) assert_success response assert_equal "APPROVED", response.message assert response.test? @@ -189,6 +189,15 @@ def test_successful_purchase_mexico assert response.test? end + def test_successful_purchase_no_description + options = @options + options.delete(:description) + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_equal "APPROVED", response.message + assert response.test? + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response From e4df97aa2dd0adde69d2fe2189ae8a35b185a9ec Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Tue, 12 Dec 2017 11:19:54 -0500 Subject: [PATCH 248/677] CardProcess: return a strict boolean for success While nil is falsy and 0 is truthy, some consumers expect the AM success flag to be strictly true or false. We change here to honor that behavior. --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/cardprocess.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index f72d41df60c..7453c3da35f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Adyen: Remove CVV as Required Field and Determines shopperInteraction [nfarve] #2665 * SafeCharge: add support for VendorID, WebsiteID, and IP logging [bpollack] #2667 * Safe Charge: Adds 3DS flag [deedeelavinder] #2668 +* CardProcess: Fix success? to always return true or false [bpollack] #2674 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/cardprocess.rb b/lib/active_merchant/billing/gateways/cardprocess.rb index d16979824a4..059ad175298 100644 --- a/lib/active_merchant/billing/gateways/cardprocess.rb +++ b/lib/active_merchant/billing/gateways/cardprocess.rb @@ -171,7 +171,7 @@ def commit(action, parameters) end def success_from(response) - response['result']['code'] =~ /^(000\.000\.|000\.100\.1|000\.[36])/ + !(response['result']['code'] =~ /^(000\.000\.|000\.100\.1|000\.[36])/).nil? end def message_from(response) From 1d4c73d94ab229b1226eea73ccd661194b6cf93f Mon Sep 17 00:00:00 2001 From: Mridul Singhai Date: Thu, 7 Dec 2017 16:10:14 -0500 Subject: [PATCH 249/677] Correct CVV, AVS codes for Sagepay Closes #2670 --- CHANGELOG | 1 + .../billing/gateways/sage_pay.rb | 15 ++++++--- test/unit/gateways/sage_pay_test.rb | 31 +++++++++++++++---- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7453c3da35f..247a818b31d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * SafeCharge: add support for VendorID, WebsiteID, and IP logging [bpollack] #2667 * Safe Charge: Adds 3DS flag [deedeelavinder] #2668 * CardProcess: Fix success? to always return true or false [bpollack] #2674 +* SagePay: Correct CVV, AVS codes for Sagepay [singhai0] #2670 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index dabac8358aa..bcff3473ac2 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -37,13 +37,20 @@ class SagePayGateway < Gateway :jcb => "JCB" } - AVS_CVV_CODE = { + AVS_CODE = { "NOTPROVIDED" => nil, "NOTCHECKED" => 'X', "MATCHED" => 'Y', "NOTMATCHED" => 'N' } + CVV_CODE = { + "NOTPROVIDED" => 'S', + "NOTCHECKED" => 'X', + "MATCHED" => 'M', + "NOTMATCHED" => 'N' + } + OPTIONAL_REQUEST_FIELDS = { paypal_callback_url: :PayPalCallbackURL, basket: :Basket, @@ -348,10 +355,10 @@ def commit(action, parameters) :test => test?, :authorization => authorization_from(response, parameters, action), :avs_result => { - :street_match => AVS_CVV_CODE[ response["AddressResult"] ], - :postal_match => AVS_CVV_CODE[ response["PostCodeResult"] ], + :street_match => AVS_CODE[ response["AddressResult"] ], + :postal_match => AVS_CODE[ response["PostCodeResult"] ], }, - :cvv_result => AVS_CVV_CODE[ response["CV2Result"] ] + :cvv_result => CVV_CODE[ response["CV2Result"] ] ) end diff --git a/test/unit/gateways/sage_pay_test.rb b/test/unit/gateways/sage_pay_test.rb index 7932dae938e..fda0187a170 100644 --- a/test/unit/gateways/sage_pay_test.rb +++ b/test/unit/gateways/sage_pay_test.rb @@ -57,20 +57,39 @@ def test_capture_url assert_equal 'https://test.sagepay.com/gateway/service/release.vsp', @gateway.send(:url_for, :capture) end - def test_avs_result + def test_matched_avs_result + @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + + assert_equal 'Y', response.avs_result['postal_match'] + assert_equal 'Y', response.avs_result['street_match'] + end + + def test_partially_matched_avs_result @gateway.expects(:ssl_post).returns(successful_purchase_response) response = @gateway.purchase(@amount, @credit_card, @options) + assert_equal 'Y', response.avs_result['postal_match'] assert_equal 'N', response.avs_result['street_match'] end - def test_cvv_result - @gateway.expects(:ssl_post).returns(successful_purchase_response) + def test_matched_cvv_result + @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + + assert_equal 'M', response.cvv_result['code'] + end + + def test_not_matched_cvv_result + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) - response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal 'N', response.cvv_result['code'] - end + assert_equal 'N', response.cvv_result['code'] + end def test_dont_send_fractional_amount_for_chinese_yen @amount = 100_00 # 100 YEN From 69beb802c47363cd01502fc6ae4a6ae3f832ff16 Mon Sep 17 00:00:00 2001 From: David Perry Date: Wed, 13 Dec 2017 12:25:47 -0500 Subject: [PATCH 250/677] PayU Latam: Count pending Voids as successful Previously, voids with a state of pending were not counted as succeeded. This accounts for that, passes a meaningful value for the message, and updates a test response to be more accurate. Closes #2677 Three unrelated failing remote tests. Remote: 19 tests, 50 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 84.2105% passed Unit: 22 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/payu_latam.rb | 8 +++++--- test/unit/gateways/payu_latam_test.rb | 10 +++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 247a818b31d..800a19fd122 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * Safe Charge: Adds 3DS flag [deedeelavinder] #2668 * CardProcess: Fix success? to always return true or false [bpollack] #2674 * SagePay: Correct CVV, AVS codes for Sagepay [singhai0] #2670 +* PayU Latam: Count pending Voids as successful [curiousepic] #2677 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index 67f74ad3044..cb5eeadc054 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -357,7 +357,7 @@ def success_from(action, response) response["code"] == "SUCCESS" && response["creditCardToken"] && response["creditCardToken"]["creditCardTokenId"].present? when 'verify_credentials' response["code"] == "SUCCESS" - when 'refund' + when 'refund', 'void' response["code"] == "SUCCESS" && response["transactionResponse"] && (response["transactionResponse"]["state"] == "PENDING" || response["transactionResponse"]["state"] == "APPROVED") else response["code"] == "SUCCESS" && response["transactionResponse"] && (response["transactionResponse"]["state"] == "APPROVED") @@ -374,8 +374,10 @@ def message_from(action, success, response) return "VERIFIED" if success "FAILED" else - response_message = response["transactionResponse"]["responseMessage"] if response["transactionResponse"] - response_code = response["transactionResponse"]["responseCode"] if response["transactionResponse"] + if response["transactionResponse"] + response_message = response["transactionResponse"]["responseMessage"] + response_code = response["transactionResponse"]["responseCode"] || response["transactionResponse"]["pendingReason"] + end return response_code if success response["error"] || response_message || response_code || "FAILED" end diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb index e0305156a4e..f3d3480f2d2 100644 --- a/test/unit/gateways/payu_latam_test.rb +++ b/test/unit/gateways/payu_latam_test.rb @@ -96,7 +96,7 @@ def test_successful_void response = @gateway.void("7edbaf68-8f3a-4ae7-b9c7-d1e27e314999", @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal "PENDING_REVIEW", response.message end def test_failed_void @@ -530,15 +530,15 @@ def successful_void_response "transactionResponse": { "orderId": 840434914, "transactionId": "e66fd9aa-f485-4f10-b1d6-be8e9e354b63", - "state": "APPROVED", + "state": "PENDING", "paymentNetworkResponseCode": "0", "paymentNetworkResponseErrorMessage": null, "trazabilityCode": "49263990", "authorizationCode": "NPS-011111", - "pendingReason": null, - "responseCode": "APPROVED", + "pendingReason": "PENDING_REVIEW", + "responseCode": null, "errorCode": null, - "responseMessage": "APROBADA - Autorizada", + "responseMessage": null, "transactionDate": null, "transactionTime": null, "operationDate": 1486655230074, From bcf35b332689e4fb3159f9adb88ce28e0c593b24 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Tue, 12 Dec 2017 17:09:43 -0500 Subject: [PATCH 251/677] Mercado Pago: protect against invalid access tokens An access token provided that was not validly URL-encoded (e.g., had spaces) could cause ActiveRecord to crash, since it could result in a malformed URL. This ensures that even a malformed access token can be passed through, avoiding a crash and allowing normal error handling to take place. Closes #2675 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/mercado_pago.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 800a19fd122..90495428951 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * CardProcess: Fix success? to always return true or false [bpollack] #2674 * SagePay: Correct CVV, AVS codes for Sagepay [singhai0] #2670 * PayU Latam: Count pending Voids as successful [curiousepic] #2677 +* Mercado Pago: Ensure acess tokens are URL escaped [bpollack] #2675 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index 406ef823a90..748374cb7fc 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -236,7 +236,7 @@ def error_code_from(action, response) def url(action) full_url = (test? ? test_url : live_url) - full_url + "/#{action}?access_token=#{@options[:access_token]}" + full_url + "/#{action}?access_token=#{CGI.escape(@options[:access_token])}" end def headers From 2161e7331b5cead6dcb54c25c8633c6624fdef2e Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Tue, 12 Dec 2017 14:15:09 -0500 Subject: [PATCH 252/677] MiGS: improve test suite and fix SecureHash Our test cards were out-of-date, and MiGS now requires SHA256 hashes. Address both of these issues, and the entire remote tests now run again. Closes #2257 Closes #2256 Closes #2676 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/migs.rb | 15 +++++++++----- test/remote/gateways/remote_migs_test.rb | 21 ++++++++++---------- test/unit/gateways/migs_test.rb | 14 ++++++------- 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 90495428951..76f650aabcb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * SagePay: Correct CVV, AVS codes for Sagepay [singhai0] #2670 * PayU Latam: Count pending Voids as successful [curiousepic] #2677 * Mercado Pago: Ensure acess tokens are URL escaped [bpollack] #2675 +* MiGS: Update hash format to SHA256 and restore remote tests [bpollack] #2676 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb index 55974e27407..5ce4eac411f 100644 --- a/lib/active_merchant/billing/gateways/migs.rb +++ b/lib/active_merchant/billing/gateways/migs.rb @@ -1,6 +1,6 @@ require 'active_merchant/billing/gateways/migs/migs_codes' -require 'digest/md5' # Used in add_secure_hash +require 'openssl' # Used in add_secure_hash module ActiveMerchant #:nodoc: module Billing #:nodoc: @@ -187,7 +187,7 @@ def purchase_offsite_response(data) response_hash = parse(data) - expected_secure_hash = calculate_secure_hash(response_hash.reject{|k, v| k == :SecureHash}, @options[:secure_hash]) + expected_secure_hash = calculate_secure_hash(response_hash, @options[:secure_hash]) unless response_hash[:SecureHash] == expected_secure_hash raise SecurityError, "Secure Hash mismatch, response may be tampered with" end @@ -245,6 +245,7 @@ def parse(body) end def commit(post) + add_secure_hash(post) if @options[:secure_hash] data = ssl_post self.merchant_hosted_url, post_data(post) response_hash = parse(data) response_object(response_hash) @@ -290,12 +291,16 @@ def post_data(post) def add_secure_hash(post) post[:SecureHash] = calculate_secure_hash(post, @options[:secure_hash]) + post[:SecureHashType] = 'SHA256' end def calculate_secure_hash(post, secure_hash) - sorted_values = post.sort_by(&:to_s).map(&:last) - input = secure_hash + sorted_values.join - Digest::MD5.hexdigest(input).upcase + input = post + .reject { |k| %i[SecureHash SecureHashType].include?(k) } + .sort + .map { |(k, v)| "vpc_#{k}=#{v}" } + .join('&') + OpenSSL::HMAC.hexdigest('SHA256', [secure_hash].pack('H*'), input).upcase end end end diff --git a/test/remote/gateways/remote_migs_test.rb b/test/remote/gateways/remote_migs_test.rb index 2214f8626c7..b1264771ce9 100644 --- a/test/remote/gateways/remote_migs_test.rb +++ b/test/remote/gateways/remote_migs_test.rb @@ -10,10 +10,10 @@ def setup @amount = 100 @declined_amount = 105 - @visa = credit_card('4005550000000001', :month => 5, :year => 2017, :brand => 'visa') - @master = credit_card('5123456789012346', :month => 5, :year => 2017, :brand => 'master') - @amex = credit_card('371449635311004', :month => 5, :year => 2017, :brand => 'american_express') - @diners = credit_card('30123456789019', :month => 5, :year => 2017, :brand => 'diners_club') + @visa = credit_card('4987654321098769', :month => 5, :year => 2021, :brand => 'visa') + @master = credit_card('5123456789012346', :month => 5, :year => 2021, :brand => 'master') + @amex = credit_card('371449635311004', :month => 5, :year => 2021, :brand => 'american_express') + @diners = credit_card('30123456789019', :month => 5, :year => 2021, :brand => 'diners_club') @credit_card = @visa @options = { @@ -37,8 +37,6 @@ def test_server_purchase_url responses = { 'visa' => /You have chosen .*VISA.*/, 'master' => /You have chosen .*MasterCard.*/, - 'diners_club' => /You have chosen .*Diners Club.*/, - 'american_express' => /You have chosen .*American Express.*/ } responses.each_pair do |card_type, response_text| @@ -83,11 +81,12 @@ def test_failed_authorize end def test_refund - assert payment_response = @gateway.purchase(@amount, @credit_card, @options) - assert_success payment_response - assert response = @gateway.refund(@amount, payment_response.authorization, @options) - assert_success response - assert_equal 'Approved', response.message + # skip "Refunds are not working in the testing envirnment" + # assert payment_response = @gateway.purchase(@amount, @credit_card, @options) + # assert_success payment_response + # assert response = @gateway.refund(@amount, payment_response.authorization, @options) + # refute_success response + # assert_equal 'Approved', response.message end def test_status diff --git a/test/unit/gateways/migs_test.rb b/test/unit/gateways/migs_test.rb index 644e1bd214a..9dfcbce5ff0 100644 --- a/test/unit/gateways/migs_test.rb +++ b/test/unit/gateways/migs_test.rb @@ -1,4 +1,5 @@ require 'test_helper' +require 'openssl' class MigsTest < Test::Unit::TestCase def setup @@ -45,25 +46,24 @@ def test_secure_hash :OrderInfo => 'A48cvE28', :Amount => 2995 } - ordered_values = "#{@gateway.options[:secure_hash]}2995MER123A48cvE28" - + ordered_values = "vpc_Amount=2995&vpc_MerchantId=MER123&vpc_OrderInfo=A48cvE28" @gateway.send(:add_secure_hash, params) - assert_equal Digest::MD5.hexdigest(ordered_values).upcase, params[:SecureHash] + assert_equal OpenSSL::HMAC.hexdigest('SHA256', [@gateway.options[:secure_hash]].pack('H*'), ordered_values).upcase, params[:SecureHash] end def test_purchase_offsite_response # Below response from instance running remote test - response_params = "vpc_3DSXID=a1B8UcW%2BKYqkSinLQohGmqQd9uY%3D&vpc_3DSenrolled=U&vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=100&vpc_AuthorizeId=367739&vpc_BatchNo=20120421&vpc_CSCResultCode=Unsupported&vpc_Card=MC&vpc_Command=pay&vpc_Locale=en&vpc_MerchTxnRef=9&vpc_Merchant=TESTANZTEST3&vpc_Message=Approved&vpc_OrderInfo=1&vpc_ReceiptNo=120421367739&vpc_SecureHash=8794D9478D030B65F3092282E76283F8&vpc_TransactionNo=2000025183&vpc_TxnResponseCode=0&vpc_VerSecurityLevel=06&vpc_VerStatus=U&vpc_VerType=3DS&vpc_Version=1" + response_params = "vpc_3DSXID=a1B8UcW%2BKYqkSinLQohGmqQd9uY%3D&vpc_3DSenrolled=U&vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=100&vpc_AuthorizeId=367739&vpc_BatchNo=20120421&vpc_CSCResultCode=Unsupported&vpc_Card=MC&vpc_Command=pay&vpc_Locale=en&vpc_MerchTxnRef=9&vpc_Merchant=TESTANZTEST3&vpc_Message=Approved&vpc_OrderInfo=1&vpc_ReceiptNo=120421367739&vpc_SecureHash=20DE2CDEBE40D6F24E3ABC5D74081CB5B341CD447530121AD51A9504A923BBD0&vpc_TransactionNo=2000025183&vpc_TxnResponseCode=0&vpc_VerSecurityLevel=06&vpc_VerStatus=U&vpc_VerType=3DS&vpc_Version=1" response_hash = @gateway.send(:parse, response_params) - response_hash.delete(:SecureHash) calculated_hash = @gateway.send(:calculate_secure_hash, response_hash, @gateway.options[:secure_hash]) - assert_equal '8794D9478D030B65F3092282E76283F8', calculated_hash + expected_hash_input = "vpc_3DSXID=a1B8UcW+KYqkSinLQohGmqQd9uY=&vpc_3DSenrolled=U&vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=100&vpc_AuthorizeId=367739&vpc_BatchNo=20120421&vpc_CSCResultCode=Unsupported&vpc_Card=MC&vpc_Command=pay&vpc_Locale=en&vpc_MerchTxnRef=9&vpc_Merchant=TESTANZTEST3&vpc_Message=Approved&vpc_OrderInfo=1&vpc_ReceiptNo=120421367739&vpc_TransactionNo=2000025183&vpc_TxnResponseCode=0&vpc_VerSecurityLevel=06&vpc_VerStatus=U&vpc_VerType=3DS&vpc_Version=1" + assert_equal OpenSSL::HMAC.hexdigest('SHA256', [@gateway.options[:secure_hash]].pack('H*'), expected_hash_input).upcase, calculated_hash response = @gateway.purchase_offsite_response(response_params) assert_success response - tampered_response1 = response_params.gsub('83F8', '93F8') + tampered_response1 = response_params.gsub('20DE', '20DF') assert_raise(SecurityError){@gateway.purchase_offsite_response(tampered_response1)} tampered_response2 = response_params.gsub('Locale=en', 'Locale=es') From 9b1b6be752fd6ee1360f7740577f441618e32bcc Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Fri, 27 Oct 2017 14:12:36 -0400 Subject: [PATCH 253/677] Add a verify call to the MiGS gateway MiGS doesn't support an actual verify call, so this is just an auth + void. Closes #2664 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/migs.rb | 7 +++++++ test/remote/gateways/remote_migs_test.rb | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 76f650aabcb..f2f9acd68e9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * PayU Latam: Count pending Voids as successful [curiousepic] #2677 * Mercado Pago: Ensure acess tokens are URL escaped [bpollack] #2675 * MiGS: Update hash format to SHA256 and restore remote tests [bpollack] #2676 +* MiGS: Support verify calls [bpollack] #2664 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb index 5ce4eac411f..867c080e973 100644 --- a/lib/active_merchant/billing/gateways/migs.rb +++ b/lib/active_merchant/billing/gateways/migs.rb @@ -121,6 +121,13 @@ def credit(money, authorization, options = {}) refund(money, authorization, options) end + def verify(credit_card, options={}) + MultiResponse.run do |r| + r.process { authorize(100, credit_card, options) } + r.process(:ignore_result) { void(r.authorization, options) } + end + end + # Checks the status of a previous transaction # This can be useful when a response is not received due to network issues # diff --git a/test/remote/gateways/remote_migs_test.rb b/test/remote/gateways/remote_migs_test.rb index b1264771ce9..a1ba53a0551 100644 --- a/test/remote/gateways/remote_migs_test.rb +++ b/test/remote/gateways/remote_migs_test.rb @@ -74,6 +74,12 @@ def test_authorize_and_void assert_equal 'Approved', void.message end + def test_verify + assert verify = @gateway.verify(@credit_card, @options) + assert_success verify + assert_equal 'Approved', verify.message + end + def test_failed_authorize assert response = @gateway.authorize(@declined_amount, @credit_card, @options) assert_failure response From 427a23b1ce391bfe5595541181cfc4e5f678f608 Mon Sep 17 00:00:00 2001 From: Niaja Date: Fri, 15 Dec 2017 15:27:29 -0500 Subject: [PATCH 254/677] iATS: Fix Messages with Failure on iATS Server Authorization Result is not returned if there is a status failure. Can't depending on having this result passed Loaded suite test/unit/gateways/iats_payments_test 17 tests, 166 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_iats_payments_test 12 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications --- .../billing/gateways/iats_payments.rb | 4 +-- test/unit/gateways/iats_payments_test.rb | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/active_merchant/billing/gateways/iats_payments.rb b/lib/active_merchant/billing/gateways/iats_payments.rb index 56acbcb530f..e96f94d3f4f 100644 --- a/lib/active_merchant/billing/gateways/iats_payments.rb +++ b/lib/active_merchant/billing/gateways/iats_payments.rb @@ -225,7 +225,7 @@ def recursively_parse_element(node, response) end def successful_result_message?(response) - response[:authorization_result].start_with?('OK') + response[:authorization_result] ? response[:authorization_result].start_with?('OK') : false end def success_from(response) @@ -233,7 +233,7 @@ def success_from(response) end def message_from(response) - if(!successful_result_message?(response)) + if !successful_result_message?(response) && response[:authorization_result] return response[:authorization_result].strip elsif(response[:status] == 'Failure') return response[:errors] diff --git a/test/unit/gateways/iats_payments_test.rb b/test/unit/gateways/iats_payments_test.rb index d13475b1b75..e3aa2aab5a1 100644 --- a/test/unit/gateways/iats_payments_test.rb +++ b/test/unit/gateways/iats_payments_test.rb @@ -243,6 +243,16 @@ def test_supported_countries end end + def test_failed_connection + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.respond_with(failed_connection_response) + + assert response + assert_failure response + assert_match(/Server Error/, response.message) + end + def test_scrub assert_equal @gateway.scrub(pre_scrub), post_scrub end @@ -513,6 +523,26 @@ def successful_unstore_response XML end + def failed_connection_response + <<-XML + + + + + + + Failure + Server Error + + + + + + + + XML + end + def pre_scrub <<-XML opening connection to www.iatspayments.com:443... From 307529e258d2b09c44d0a6fa2e351c8a31259adb Mon Sep 17 00:00:00 2001 From: Niaja Date: Mon, 18 Dec 2017 11:29:43 -0500 Subject: [PATCH 255/677] iATS: Fix Messages with Failure on iATS Server Update to changelog Closes 2680 --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index f2f9acd68e9..7b5c9fc6dd0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ * Mercado Pago: Ensure acess tokens are URL escaped [bpollack] #2675 * MiGS: Update hash format to SHA256 and restore remote tests [bpollack] #2676 * MiGS: Support verify calls [bpollack] #2664 +* iATS: Fix Messages with Failure on iATS Server [nfarve] #2680 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 From 5ae0473a838bc188d1258832ff291dc18db79f27 Mon Sep 17 00:00:00 2001 From: Niaja Date: Wed, 20 Dec 2017 14:10:57 -0500 Subject: [PATCH 256/677] Barclaycard Smartpay: Correct response for fraud rejects The docs say that an authCode is only returned for successful transactions, but it is also passed for fraud rejects. Loaded suite test/unit/gateways/barclaycard_smartpay_test 23 tests, 104 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_barclaycard_smartpay_test 27 tests, 52 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2683 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/barclaycard_smartpay.rb | 2 +- test/unit/gateways/barclaycard_smartpay_test.rb | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7b5c9fc6dd0..1eed549893c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * MiGS: Update hash format to SHA256 and restore remote tests [bpollack] #2676 * MiGS: Support verify calls [bpollack] #2664 * iATS: Fix Messages with Failure on iATS Server [nfarve] #2680 +* Barclaycard Smartpay: Correct repsonse for fraud rejects #2683 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index 731501f64d1..c79c7298816 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -211,8 +211,8 @@ def message_from(response) end def success_from(response) - return true if response.has_key?('authCode') return true if response['result'] == 'Success' + return true if response['resultCode'] == 'Authorised' return true if response['resultCode'] == 'Received' successful_responses = %w([capture-received] [cancel-received] [refund-received]) successful_responses.include?(response['response']) diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb index 1d399883d7c..d7784ef6f69 100644 --- a/test/unit/gateways/barclaycard_smartpay_test.rb +++ b/test/unit/gateways/barclaycard_smartpay_test.rb @@ -313,6 +313,7 @@ def test_avs_result @gateway.expects(:ssl_post).returns(failed_avs_response) response = @gateway.authorize(@amount, @credit_card, @avs_address) + assert_failure response assert_equal "N", response.avs_result['code'] assert response.test? end From de3439e3626e86095616fe98099f64dbdb13109e Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Mon, 18 Dec 2017 17:01:39 -0500 Subject: [PATCH 257/677] Adyen: Make parts of addresses optional As long as the country code is provided, then Adyen may, in certain situations, allow the submission of "N/A" for address fields, but nevertheless requires those fields to be present. Loaded suite Loaded suite test/unit/gateways/adyen_test 16 tests, 79 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_adyen_test 28 tests, 65 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2684 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 8 ++++---- test/remote/gateways/remote_adyen_test.rb | 9 +++------ test/unit/gateways/adyen_test.rb | 7 ++++--- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1eed549893c..b3508b14e79 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * MiGS: Support verify calls [bpollack] #2664 * iATS: Fix Messages with Failure on iATS Server [nfarve] #2680 * Barclaycard Smartpay: Correct repsonse for fraud rejects #2683 +* Adyen: Allow incomplete addresses in some situations [bpollack] #2684 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index d4ebdc8bc64..68bfeae774e 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -107,12 +107,12 @@ def add_shopper_interaction(post, payment, options={}) def add_address(post, options) return unless post[:card] && post[:card].kind_of?(Hash) - if address = options[:billing_address] || options[:address] + if (address = options[:billing_address] || options[:address]) && address[:country] post[:card][:billingAddress] = {} - post[:card][:billingAddress][:street] = address[:address1] if address[:address1] - post[:card][:billingAddress][:houseNumberOrName] = address[:address2] if address[:address2] + post[:card][:billingAddress][:street] = address[:address1] || 'N/A' + post[:card][:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A' post[:card][:billingAddress][:postalCode] = address[:zip] if address[:zip] - post[:card][:billingAddress][:city] = address[:city] if address[:city] + post[:card][:billingAddress][:city] = address[:city] || 'N/A' post[:card][:billingAddress][:stateOrProvince] = address[:state] if address[:state] post[:card][:billingAddress][:country] = address[:country] if address[:country] end diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb index ec55953c309..db3202542e3 100644 --- a/test/remote/gateways/remote_adyen_test.rb +++ b/test/remote/gateways/remote_adyen_test.rb @@ -195,22 +195,19 @@ def test_missing_address_for_purchase @options[:billing_address].delete(:address1) @options[:billing_address].delete(:address2) response = @gateway.authorize(@amount, @credit_card, @options) - assert_failure response - assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code + assert_success response end def test_missing_city_for_purchase @options[:billing_address].delete(:city) response = @gateway.authorize(@amount, @credit_card, @options) - assert_failure response - assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code + assert_success response end def test_missing_house_number_or_name_for_purchase @options[:billing_address].delete(:address2) response = @gateway.authorize(@amount, @credit_card, @options) - assert_failure response - assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code + assert_success response end def test_invalid_country_for_purchase diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index e3012f2e7f9..11ee8eae8a2 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -153,16 +153,17 @@ def test_scrub def test_add_address post = {:card => {:billingAddress => {}}} + @options[:billing_address].delete(:address1) + @options[:billing_address].delete(:address2) @gateway.send(:add_address, post, @options) - assert_equal @options[:billing_address][:address1], post[:card][:billingAddress][:street] - assert_equal @options[:billing_address][:address2], post[:card][:billingAddress][:houseNumberOrName] + assert_equal 'N/A', post[:card][:billingAddress][:street] + assert_equal 'N/A', post[:card][:billingAddress][:houseNumberOrName] assert_equal @options[:billing_address][:zip], post[:card][:billingAddress][:postalCode] assert_equal @options[:billing_address][:city], post[:card][:billingAddress][:city] assert_equal @options[:billing_address][:state], post[:card][:billingAddress][:stateOrProvince] assert_equal @options[:billing_address][:country], post[:card][:billingAddress][:country] end - private def pre_scrubbed From 8f6851576fbf8425efe401324634508ad271e146 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Tue, 26 Dec 2017 13:01:11 -0500 Subject: [PATCH 258/677] Payment Express: Fix remote tests Unit tests: 33 tests, 238 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote tests: 1 tests, 3 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- test/remote/gateways/remote_payment_express_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/remote/gateways/remote_payment_express_test.rb b/test/remote/gateways/remote_payment_express_test.rb index ce2dda8a764..01acdb8fc54 100644 --- a/test/remote/gateways/remote_payment_express_test.rb +++ b/test/remote/gateways/remote_payment_express_test.rb @@ -75,7 +75,7 @@ def test_invalid_login :password => '' ) assert response = gateway.purchase(@amount, @credit_card, @options) - assert_match %r{error}i, response.message + assert_match %r{Invalid Credentials}i, response.message assert_failure response end From 084b9505b33e3de27301e641753380187da7f232 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Mon, 4 Dec 2017 15:47:35 -0500 Subject: [PATCH 259/677] Implement Paymentez Gateway Unit tests: 13 tests, 37 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote tests: 13 tests, 29 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2685 --- CHANGELOG | 1 + .../billing/gateways/paymentez.rb | 273 ++++++++++++++ test/fixtures.yml | 4 + test/remote/gateways/remote_paymentez_test.rb | 114 ++++++ test/unit/gateways/paymentez_test.rb | 345 ++++++++++++++++++ 5 files changed, 737 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/paymentez.rb create mode 100644 test/remote/gateways/remote_paymentez_test.rb create mode 100644 test/unit/gateways/paymentez_test.rb diff --git a/CHANGELOG b/CHANGELOG index b3508b14e79..755019bbb1e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ * iATS: Fix Messages with Failure on iATS Server [nfarve] #2680 * Barclaycard Smartpay: Correct repsonse for fraud rejects #2683 * Adyen: Allow incomplete addresses in some situations [bpollack] #2684 +* Paymentez: Add new gateway [bpollack] #2685 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb new file mode 100644 index 00000000000..6ca8fef27ea --- /dev/null +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -0,0 +1,273 @@ +require 'base64' +require 'digest' + +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class PaymentezGateway < Gateway #:nodoc: + self.test_url = 'https://ccapi-stg.paymentez.com/v2/' + self.live_url = 'https://ccapi.paymentez.com/v2/' + + self.supported_countries = %w[MX EC VE CO BR CL] + self.default_currency = 'USD' + self.supported_cardtypes = %i[visa master american_express diners_club] + + self.homepage_url = 'https://secure.paymentez.com/' + self.display_name = 'Paymentez' + + STANDARD_ERROR_CODE_MAPPING = { + 1 => :processing_error, + 6 => :card_declined, + 9 => :card_declined, + 10 => :processing_error, + 11 => :card_declined, + 12 => :config_error, + 13 => :config_error, + 19 => :invalid_cvc, + 20 => :config_error, + 21 => :card_declined, + 22 => :card_declined, + 23 => :card_declined, + 24 => :card_declined, + 25 => :card_declined, + 26 => :card_declined, + 27 => :card_declined, + 28 => :card_declined + }.freeze + + CARD_MAPPING = { + 'visa' => 'vi', + 'master' => 'mc', + 'american_express' => 'ax', + 'diners_club' => 'di' + }.freeze + + def initialize(options = {}) + requires!(options, :application_code, :app_key) + super + end + + def purchase(money, payment, options = {}) + post = {} + + add_invoice(post, money, options) + add_payment(post, payment) + add_customer_data(post, options) + + commit_transaction('debit_cc', post) + end + + def authorize(money, payment, options = {}) + post = {} + + add_invoice(post, money, options) + add_customer_data(post, options) + + MultiResponse.run do |r| + r.process { store(payment, options) } + post[:card] = { token: r.authorization } + r.process { commit_transaction('authorize', post) } + end + end + + def capture(_money, authorization, _options = {}) + post = { transaction: { id: authorization } } + + commit_transaction('capture', post) + end + + def refund(_money, authorization, options = {}) + void(authorization, options) + end + + def void(authorization, _options = {}) + post = { transaction: { id: authorization } } + commit_transaction('refund', post) + end + + def verify(credit_card, options = {}) + MultiResponse.run do |r| + r.process { authorize(100, credit_card, options) } + r.process { void(r.authorization, options) } + end + end + + def store(credit_card, options = {}) + post = {} + + add_customer_data(post, options) + add_payment(post, credit_card) + + response = commit_card('add', post) + if !response.success? && !(token = extract_previous_card_token(response)).nil? + unstore(token, options) + response = commit_card('add', post) + end + response + end + + def unstore(identification, options = {}) + post = { card: { token: identification }, user: { id: options[:user_id] }} + commit_card('delete', post) + end + + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript + .gsub(%r{(\\?"number\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]') + .gsub(%r{(\\?"cvc\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]') + .gsub(%r{(Auth-Token: )([A-Za-z0-9=]+)}, '\1[FILTERED]') + end + + private + + def add_customer_data(post, options) + requires!(options, :user_id, :email) + post[:user] ||= {} + post[:user][:id] = options[:user_id] + post[:user][:email] = options[:email] + post[:user][:ip_address] = options[:ip] if options[:ip] + post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number] + end + + def add_invoice(post, money, options) + post[:session_id] = options[:session_id] if options[:session_id] + + post[:order] ||= {} + post[:order][:amount] = amount(money).to_f + post[:order][:vat] = options[:vat] if options[:vat] + post[:order][:dev_reference] = options[:dev_reference] if options[:dev_reference] + post[:order][:description] = options[:description] if options[:description] + post[:order][:discount] = options[:discount] if options[:discount] + post[:order][:installments] = options[:installments] if options[:installments] + post[:order][:installments_type] = options[:installments_type] if options[:installments_type] + post[:order][:taxable_amount] = options[:taxable_amount] if options[:taxable_amount] + end + + def add_payment(post, payment) + post[:card] ||= {} + post[:card][:number] = payment.number + post[:card][:holder_name] = payment.name + post[:card][:expiry_month] = payment.month + post[:card][:expiry_year] = payment.year + post[:card][:cvc] = payment.verification_value + post[:card][:type] = CARD_MAPPING[payment.brand] + end + + def parse(body) + JSON.parse(body) + end + + def commit_raw(object, action, parameters) + url = "#{(test? ? test_url : live_url)}#{object}/#{action}" + + begin + raw_response = ssl_post(url, post_data(parameters), headers) + rescue ResponseError => e + raw_response = e.response.body + end + parse(raw_response) + end + + def commit_transaction(action, parameters) + response = commit_raw('transaction', action, parameters) + Response.new( + success_from(response), + message_from(response), + response, + authorization: authorization_from(response), + test: test?, + error_code: error_code_from(response) + ) + end + + def commit_card(action, parameters) + response = commit_raw('card', action, parameters) + Response.new( + card_success_from(response), + card_message_from(response), + response, + authorization: card_authorization_from(response), + test: test?, + error_code: card_error_code_from(response) + ) + end + + def headers + { + 'Auth-Token' => authentication_code, + 'Content-Type' => 'application/json' + } + end + + def success_from(response) + !response.include?('error') && (response['status'] || response['transaction']['status']) == 'success' + end + + def card_success_from(response) + return false if response.include?('error') + return true if response['message'] == 'card deleted' + response['card']['status'] == 'valid' + end + + def message_from(response) + if success_from(response) + response['transaction'] && response['transaction']['message'] + else + response['error'] && response['error']['type'] + end + end + + def card_message_from(response) + if !response.include?('error') + response['message'] || response['card']['message'] + else + response['error']['type'] + end + end + + def authorization_from(response) + response['transaction'] && response['transaction']['id'] + end + + def card_authorization_from(response) + response['card'] && response['card']['token'] + end + + def extract_previous_card_token(response) + match = /Card already added: (\d+)/.match(response.message) + match && match[1] + end + + def post_data(parameters = {}) + JSON.dump(parameters) + end + + def error_code_from(response) + return if success_from(response) + if response['transaction'] + detail = response['transaction']['status_detail'] + if STANDARD_ERROR_CODE_MAPPING.include?(detail) + return STANDARD_ERROR_CODE[STANDARD_ERROR_CODE_MAPPING[detail]] + end + elsif response['error'] + return STANDARD_ERROR_CODE[:config_error] + end + STANDARD_ERROR_CODE[:processing_error] + end + + def card_error_code_from(response) + STANDARD_ERROR_CODE[:processing_error] unless card_success_from(response) + end + + def authentication_code + timestamp = Time.new.to_i + unique_token = Digest::SHA256.hexdigest("#{@options[:app_key]}#{timestamp}") + authentication_string = "#{@options[:application_code]};#{timestamp};#{unique_token}" + Base64.encode64(authentication_string).delete("\n") + end + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index 91fdfe5799f..40da19ea241 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -675,6 +675,10 @@ payment_express: login: LOGIN password: PASSWORD +paymentez: + application_code: APPCODE + app_key: APPKEY + paymill: private_key: a9580be4a7b9d0151a3da88c6c935ce0 public_key: 57313835619696ac361dc591bc973626 diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb new file mode 100644 index 00000000000..695d00da0d2 --- /dev/null +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -0,0 +1,114 @@ +require 'test_helper' + +class RemotePaymentezTest < Test::Unit::TestCase + def setup + @gateway = PaymentezGateway.new(fixtures(:paymentez)) + + @amount = 100 + @credit_card = credit_card('4111111111111111', verification_value: '555') + @declined_card = credit_card('4242424242424242', verification_value: '555') + @options = { + billing_address: address, + description: 'Store Purchase', + user_id: '998', + email: 'joe@example.com', + vat: 0, + dev_reference: 'Testing' + } + end + + def test_successful_purchase + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + end + + def test_successful_purchase_with_more_options + options = { + order_id: '1', + ip: '127.0.0.1' + } + + response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) + assert_success response + end + + def test_failed_purchase + response = @gateway.purchase(@amount, @declined_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code + end + + def test_successful_void + auth = @gateway.purchase(@amount, @credit_card, @options) + assert_success auth + + assert void = @gateway.void(auth.authorization) + assert_success void + end + + def test_failed_void + response = @gateway.void('') + assert_failure response + assert_equal 'Carrier not supported', response.message + assert_equal Gateway::STANDARD_ERROR_CODE[:config_error], response.error_code + end + + def test_successful_authorize_and_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + assert_equal 'Operation Successful', capture.message + end + + def test_failed_authorize + response = @gateway.authorize(@amount, @declined_card, @options) + assert_failure response + assert_equal 'Not Authorized', response.message + end + + def test_partial_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + assert capture = @gateway.capture(@amount - 1, auth.authorization) + assert_success capture + end + + def test_failed_capture + response = @gateway.capture(@amount, '') + assert_failure response + assert_equal 'Carrier not supported', response.message + end + + def test_store + response = @gateway.store(@credit_card, @options) + assert_success response + end + + def test_unstore + response = @gateway.store(@credit_card, @options) + assert_success response + auth = response.authorization + response = @gateway.unstore(auth, @options) + assert_success response + end + + def test_invalid_login + gateway = PaymentezGateway.new(application_code: '9z8y7w6x', app_key: '1a2b3c4d') + + response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal 'BackendResponseException', response.message + assert_equal Gateway::STANDARD_ERROR_CODE[:config_error], response.error_code + end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + end +end diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb new file mode 100644 index 00000000000..97c1c03a77a --- /dev/null +++ b/test/unit/gateways/paymentez_test.rb @@ -0,0 +1,345 @@ +require 'test_helper' + +class PaymentezTest < Test::Unit::TestCase + def setup + @gateway = PaymentezGateway.new(application_code: 'foo', app_key: 'bar') + @credit_card = credit_card + @amount = 100 + + @options = { + order_id: '1', + user_id: '123', + billing_address: address, + description: 'Store Purchase', + email: 'a@b.com' + } + end + + def test_successful_purchase + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + + assert_equal 'PR-926', response.authorization + assert response.test? + end + + def test_failed_purchase + @gateway.expects(:ssl_post).returns(failed_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code + end + + def test_successful_authorize + @gateway.stubs(:ssl_post).returns(successful_store_response, successful_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + assert_equal 'CI-635', response.authorization + assert response.test? + end + + def test_failed_authorize + @gateway.expects(:ssl_post).returns(failed_store_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert response.test? + end + + def test_successful_capture + @gateway.expects(:ssl_post).returns(successful_capture_response) + + response = @gateway.capture(@amount, '1234', @options) + assert_success response + assert_equal 'CI-635', response.authorization + assert response.test? + end + + def test_failed_capture + @gateway.expects(:ssl_post).returns(failed_capture_response) + + response = @gateway.capture(@amount, '1234', @options) + assert_failure response + assert response.test? + end + + def test_successful_refund + @gateway.expects(:ssl_post).returns(successful_refund_response) + + response = @gateway.refund(@amount, '1234', @options) + assert_success response + assert response.test? + end + + def test_failed_refund + @gateway.expects(:ssl_post).returns(failed_refund_response) + + response = @gateway.refund(@amount, '1234', @options) + assert_failure response + assert response.test? + end + + def test_successful_void + @gateway.expects(:ssl_post).returns(successful_void_response) + + response = @gateway.void('1234', @options) + assert_success response + assert response.test? + end + + def test_failed_void + @gateway.expects(:ssl_post).returns(failed_void_response) + + response = @gateway.void('1234', @options) + assert_failure response + end + + def test_simple_store + @gateway.expects(:ssl_post).returns(successful_store_response) + + response = @gateway.store(@credit_card, @options) + assert_success response + assert_equal '14436664108567261211', response.authorization + end + + def test_complex_store + @gateway.stubs(:ssl_post).returns(already_stored_response, successful_unstore_response, successful_store_response) + + response = @gateway.store(@credit_card, @options) + assert_success response + end + + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + + private + + def pre_scrubbed + %q( +opening connection to ccapi-stg.paymentez.com:443... +opened +starting SSL for ccapi-stg.paymentez.com:443... +SSL established +<- "POST /v2/transaction/debit_cc HTTP/1.1\r\nContent-Type: application/json\r\nAuth-Token: U1BETFktTVgtU0VSVkVSOzE1MTM3MDU5OTc7M8I1MjQ1NT5yMWNlZWU0ZjFlYTdiZDBlOGE1MWIxZjBkYzBjZTMyYjZmN2RmNjE4ZGQ5MmNiODhjMTM5MWIyNg==\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: ccapi-stg.paymentez.com\r\nContent-Length: 264\r\n\r\n" +<- "{\"order\":{\"amount\":1.0,\"vat\":0,\"dev_reference\":\"Testing\",\"description\":\"Store Purchase\"},\"card\":{\"number\":\"4111111111111111\",\"holder_name\":\"Longbob Longsen\",\"expiry_month\":9,\"expiry_year\":2018,\"cvc\":\"123\",\"type\":\"vi\"},\"user\":{\"id\":\"123\",\"email\":\"joe@example.com\"}}" +-> "HTTP/1.1 200 OK\r\n" +-> "Server: nginx/1.12.1\r\n" +-> "Date: Tue, 19 Dec 2017 17:51:42 GMT\r\n" +-> "Content-Type: application/json\r\n" +-> "Content-Length: 402\r\n" +-> "Connection: close\r\n" +-> "Vary: Accept-Language, Cookie\r\n" +-> "Content-Language: es\r\n" +-> "\r\n" +reading 402 bytes... +-> "{\"transaction\": {\"status\": \"success\", \"payment_date\": \"2017-12-19T17:51:39.985\", \"amount\": 1.0, \"authorization_code\": \"123456\", \"installments\": 1, \"dev_reference\": \"Testing\", \"message\": \"Response by mock\", \"carrier_code\": \"00\", \"id\": \"PR-871\", \"status_detail\": 3}, \"card\": {\"bin\": \"411111\", \"expiry_year\": \"2018\", \"expiry_month\": \"9\", \"transaction_reference\": \"PR-871\", \"type\": \"vi\", \"number\": \"1111\"}}" +read 402 bytes +Conn close + ) + end + + def post_scrubbed + %q( +opening connection to ccapi-stg.paymentez.com:443... +opened +starting SSL for ccapi-stg.paymentez.com:443... +SSL established +<- "POST /v2/transaction/debit_cc HTTP/1.1\r\nContent-Type: application/json\r\nAuth-Token: [FILTERED]\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: ccapi-stg.paymentez.com\r\nContent-Length: 264\r\n\r\n" +<- "{\"order\":{\"amount\":1.0,\"vat\":0,\"dev_reference\":\"Testing\",\"description\":\"Store Purchase\"},\"card\":{\"number\":[FILTERED],\"holder_name\":\"Longbob Longsen\",\"expiry_month\":9,\"expiry_year\":2018,\"cvc\":[FILTERED],\"type\":\"vi\"},\"user\":{\"id\":\"123\",\"email\":\"joe@example.com\"}}" +-> "HTTP/1.1 200 OK\r\n" +-> "Server: nginx/1.12.1\r\n" +-> "Date: Tue, 19 Dec 2017 17:51:42 GMT\r\n" +-> "Content-Type: application/json\r\n" +-> "Content-Length: 402\r\n" +-> "Connection: close\r\n" +-> "Vary: Accept-Language, Cookie\r\n" +-> "Content-Language: es\r\n" +-> "\r\n" +reading 402 bytes... +-> "{\"transaction\": {\"status\": \"success\", \"payment_date\": \"2017-12-19T17:51:39.985\", \"amount\": 1.0, \"authorization_code\": \"123456\", \"installments\": 1, \"dev_reference\": \"Testing\", \"message\": \"Response by mock\", \"carrier_code\": \"00\", \"id\": \"PR-871\", \"status_detail\": 3}, \"card\": {\"bin\": \"411111\", \"expiry_year\": \"2018\", \"expiry_month\": \"9\", \"transaction_reference\": \"PR-871\", \"type\": \"vi\", \"number\": \"1111\"}}" +read 402 bytes +Conn close + ) + end + + def successful_purchase_response + %q( + { + "transaction": { + "status": "success", + "payment_date": "2017-12-19T20:29:12.715", + "amount": 1, + "authorization_code": "123456", + "installments": 1, + "dev_reference": "Testing", + "message": "Response by mock", + "carrier_code": "00", + "id": "PR-926", + "status_detail": 3 + }, + "card": { + "bin": "411111", + "expiry_year": "2018", + "expiry_month": "9", + "transaction_reference": "PR-926", + "type": "vi", + "number": "1111" + } + } + ) + end + + def failed_purchase_response + %q( + { + "transaction": { + "status": "failure", + "payment_date": null, + "amount": 1, + "authorization_code": null, + "installments": 1, + "dev_reference": "Testing", + "message": "Response by mock", + "carrier_code": "3", + "id": "PR-945", + "status_detail": 9 + }, + "card": { + "bin": "424242", + "expiry_year": "2018", + "expiry_month": "9", + "transaction_reference": "PR-945", + "type": "vi", + "number": "4242" + } + } + ) + end + + def successful_authorize_response + %q( + { + "transaction": { + "status": "success", + "payment_date": "2017-12-21T18:04:42", + "amount": 1, + "authorization_code": "487897", + "installments": 1, + "dev_reference": "Testing", + "message": "Operation Successful", + "carrier_code": "4", + "id": "CI-635", + "status_detail": 0 + }, + "card": { + "bin": "411111", + "status": "valid", + "token": "12032069702317830187", + "expiry_year": "2018", + "expiry_month": "9", + "transaction_reference": "CI-635", + "type": "vi", + "number": "1111" + } + } + ) + end + + def failed_authorize_response + %q( + { + "card": { + "bin": "424242", + "status": "rejected", + "token": "2026849624512750545", + "message": "Not Authorized", + "expiry_year": "2018", + "expiry_month": "9", + "transaction_reference": "CI-606", + "type": "vi", + "number": "4242" + } + } + ) + end + + def successful_capture_response + %q( + { + "transaction": { + "status": "success", + "payment_date": "2017-12-21T18:04:42", + "amount": 1, + "authorization_code": "487897", + "installments": 1, + "dev_reference": "Testing", + "message": "Operation Successful", + "carrier_code": "6", + "id": "CI-635", + "status_detail": 3 + }, + "card": { + "bin": "411111", + "status": "valid", + "token": "12032069702317830187", + "expiry_year": "2018", + "expiry_month": "9", + "transaction_reference": "CI-635", + "type": "vi", + "number": "1111" + } + } + ) + end + + def failed_capture_response + "{\"error\": {\"type\": \"Carrier not supported\", \"help\": \"\", \"description\": \"{}\"}}" + end + + def successful_void_response + '{"status": "success", "detail": "Completed"}' + end + + def failed_void_response + '{"error": {"type": "Carrier not supported", "help": "", "description": "{}"}}' + end + + alias_method :successful_refund_response, :successful_void_response + alias_method :failed_refund_response, :failed_void_response + + def already_stored_response + '{"error": {"type": "Card already added: 14436664108567261211", "help": "If you want to update the card, first delete it", "description": "{}"}}' + end + + def successful_unstore_response + '{"message": "card deleted"}' + end + + def successful_store_response + '{"card": {"bin": "411111", "status": "valid", "token": "14436664108567261211", "message": "", "expiry_year": "2018", "expiry_month": "9", "transaction_reference": "PR-959", "type": "vi", "number": "1111"}}' + end + + def failed_store_response + %q( + { + "card": { + "bin": "424242", + "status": "rejected", + "token": "2026849624512750545", + "message": "Not Authorized", + "expiry_year": "2018", + "expiry_month": "9", + "transaction_reference": "CI-606", + "type": "vi", + "number": "4242" + } + } + ) + end +end From b33e394133f1a28d332ed8b005a3b8bf01b21f4c Mon Sep 17 00:00:00 2001 From: dtykocki Date: Fri, 29 Dec 2017 08:58:46 -0500 Subject: [PATCH 260/677] PayU Latam: Provide a mechanism to override the amount in verify On PayU Latam, transaction minimums are variable per customer, country, and payment method. Because of this, the default set of minimums may result in failed transactions. This provides the ability to override the amount used in the verify call via the `verify_amount` option. Closes #2688 --- CHANGELOG | 1 + .../billing/gateways/payu_latam.rb | 2 +- .../remote/gateways/remote_payu_latam_test.rb | 27 ++++++++++++++++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 755019bbb1e..c65bceafe05 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,7 @@ * Barclaycard Smartpay: Correct repsonse for fraud rejects #2683 * Adyen: Allow incomplete addresses in some situations [bpollack] #2684 * Paymentez: Add new gateway [bpollack] #2685 +* PayU Latam: Provide a mechanism to override the amount in verify [dtykocki] #2688 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index cb5eeadc054..4d24aaf1934 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -77,7 +77,7 @@ def refund(amount, authorization, options={}) def verify(credit_card, options={}) minimum = MINIMUMS[options[:currency].upcase] if options[:currency] - amount = minimum || 100 + amount = options[:verify_amount] || minimum || 100 MultiResponse.run(:use_first_response) do |r| r.process { authorize(amount, credit_card, options) } diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index 7d97c9d846a..95c25daa69e 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -201,14 +201,13 @@ def test_successful_purchase_no_description def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "ANTIFRAUD_REJECTED", response.message assert_equal "DECLINED", response.params["transactionResponse"]["state"] end def test_failed_purchase_with_no_options response = @gateway.purchase(@amount, @declined_card, {}) assert_failure response - assert_equal "ANTIFRAUD_REJECTED", response.message + assert_equal "DECLINED", response.params["transactionResponse"]["state"] end def test_successful_authorize @@ -221,8 +220,7 @@ def test_successful_authorize def test_failed_authorize response = @gateway.authorize(@amount, @pending_card, @options) assert_failure response - assert_equal "PENDING_TRANSACTION_REVIEW", response.message - assert_equal "PENDING", response.params["transactionResponse"]["state"] + assert_equal "DECLINED", response.params["transactionResponse"]["state"] end def test_well_formed_refund_fails_as_expected @@ -278,6 +276,27 @@ def test_verify_credentials assert !gateway.verify_credentials end + def test_successful_verify + verify = @gateway.verify(@credit_card, @options) + + assert_success verify + assert_equal "APPROVED", verify.message + end + + def test_successful_verify_with_specified_amount + verify = @gateway.verify(@credit_card, @options.merge(verify_amount: 5100)) + + assert_success verify + assert_equal "APPROVED", verify.message + end + + def test_failed_verify_with_specified_amount + verify = @gateway.verify(@credit_card, @options.merge(verify_amount: 1699)) + + assert_failure verify + assert_equal "The order value is less than minimum allowed. Minimum value allowed 17 ARS", verify.message + end + def test_transcript_scrubbing transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) From 2c8187ee4551ed22ac6e7e599871072de2eb5407 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Fri, 29 Dec 2017 09:11:19 -0500 Subject: [PATCH 261/677] Mercado Pago: Support X-Device-Session-ID This is one of two components to decrease erroneously rejected Mercado Pago transactions. Remote: 16 tests, 44 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 18 tests, 90 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2689 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/mercado_pago.rb | 11 +++++++---- test/unit/gateways/mercado_pago_test.rb | 9 +++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c65bceafe05..a945a91a52b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,6 +22,7 @@ * Adyen: Allow incomplete addresses in some situations [bpollack] #2684 * Paymentez: Add new gateway [bpollack] #2685 * PayU Latam: Provide a mechanism to override the amount in verify [dtykocki] #2688 +* Mercado Pago: Support X-Device-Session-ID Header [bpollack] #2689 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index 748374cb7fc..9e668874c98 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -114,6 +114,7 @@ def authorize_request(money, payment, options = {}) def add_additional_data(post, options) post[:sponsor_id] = options[:sponsor_id] + post[:device_id] = options[:device_id] if options[:device_id] post[:additional_info] = { ip_address: options[:ip_address] } @@ -191,7 +192,7 @@ def commit(action, path, parameters) if ["capture", "void"].include?(action) response = parse(ssl_request(:put, url(path), post_data(parameters), headers)) else - response = parse(ssl_post(url(path), post_data(parameters), headers)) + response = parse(ssl_post(url(path), post_data(parameters), headers(parameters))) end Response.new( @@ -221,7 +222,7 @@ def authorization_from(response, params) end def post_data(parameters = {}) - parameters.to_json + parameters.clone.tap { |p| p.delete(:device_id) }.to_json end def error_code_from(action, response) @@ -239,10 +240,12 @@ def url(action) full_url + "/#{action}?access_token=#{CGI.escape(@options[:access_token])}" end - def headers - { + def headers(options = {}) + headers = { "Content-Type" => "application/json" } + headers['X-Device-Session-ID'] = options[:device_id] if options[:device_id] + headers end def handle_response(response) diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb index 1fe1560819d..a3a7389d9be 100644 --- a/test/unit/gateways/mercado_pago_test.rb +++ b/test/unit/gateways/mercado_pago_test.rb @@ -194,6 +194,15 @@ def test_sends_mastercard_as_master assert_equal '4141491|1.0', response.authorization end + def test_includes_deviceid_header + @options[:device_id] = '1a2b3c' + @gateway.expects(:ssl_post).with(anything, anything, headers = {'Content-Type' => 'application/json'}).returns(successful_purchase_response) + @gateway.expects(:ssl_post).with(anything, anything, headers = {'Content-Type' => 'application/json', 'X-Device-Session-ID' => '1a2b3c'}).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + end + private def pre_scrubbed From e560823be200b2e4f573bcc3da417876b443f488 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Fri, 29 Dec 2017 09:11:19 -0500 Subject: [PATCH 262/677] Mercado Pago: add arbitrary additional_info parameters Remote: 16 tests, 44 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 19 tests, 95 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2691 --- CHANGELOG | 1 + .../billing/gateways/mercado_pago.rb | 3 ++- test/unit/gateways/mercado_pago_test.rb | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a945a91a52b..b7f63a52a5f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,7 @@ * Paymentez: Add new gateway [bpollack] #2685 * PayU Latam: Provide a mechanism to override the amount in verify [dtykocki] #2688 * Mercado Pago: Support X-Device-Session-ID Header [bpollack] #2689 +* Mercado Pago: Support arbitrary additional_info JSON [bpollack] #2691 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index 9e668874c98..65e4b40aef2 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -117,7 +117,8 @@ def add_additional_data(post, options) post[:device_id] = options[:device_id] if options[:device_id] post[:additional_info] = { ip_address: options[:ip_address] - } + }.merge(options[:additional_info] || {}) + add_address(post, options) add_shipping_address(post, options) diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb index a3a7389d9be..aaf93e99361 100644 --- a/test/unit/gateways/mercado_pago_test.rb +++ b/test/unit/gateways/mercado_pago_test.rb @@ -203,6 +203,20 @@ def test_includes_deviceid_header assert_success response end + def test_includes_additional_data + @options[:additional_info] = {'foo' => 'bar', 'baz' => 'quux'} + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + if data =~ /payment_method_id/ + assert_match(/"foo":"bar"/, data) + assert_match(/"baz":"quux"/, data) + end + end.respond_with(successful_purchase_response) + + assert_success response + end + private def pre_scrubbed From e602e8cb913b8d687f4b8cbdbb22d0c187dee949 Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Fri, 8 Dec 2017 11:05:06 -0500 Subject: [PATCH 263/677] FirstData E4: Override ECI value for Apple Pay transactions with Discover Discover has a hard requirement that the ECI value for all Apple Pay transactions be set to exactly 4, regardless of what is or is not provided in the Apple PKPaymentToken. This is under subject of merchant fees and penalties if not, according to people I've talked to at Discover. The Discover specification reads: https://www.dropbox.com/s/fnmofdfnsc37wuj/Screenshot%202017-11-21%2017.43.16.png?dl=0 Yes, that's mostly meaningless, but "field 61 position 9" is what gateways map the incoming ECI value to. I've confirmed this information with contacts at FirstData, which said basically "yeah, this is a Discover requirement, and you must send it in differently, we won't do it for you." --- CHANGELOG | 1 + .../billing/gateways/firstdata_e4.rb | 17 ++++++++++++++--- test/unit/gateways/firstdata_e4_test.rb | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b7f63a52a5f..859825d547a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,7 @@ * PayU Latam: Provide a mechanism to override the amount in verify [dtykocki] #2688 * Mercado Pago: Support X-Device-Session-ID Header [bpollack] #2689 * Mercado Pago: Support arbitrary additional_info JSON [bpollack] #2691 +* FirstData E4: Override ECI value for Apple Pay transactions with Discover [jasonwebster] #2671 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index 9623681100f..44b01586377 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -237,13 +237,24 @@ def add_credit_card(xml, credit_card, options) xml.tag! "CardHoldersName", credit_card.name xml.tag! "CardType", card_type(credit_card.brand) - eci = (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI - xml.tag! "Ecommerce_Flag", eci.to_s =~ /^[0-9]+$/ ? eci.to_s.rjust(2, '0') : eci - + add_credit_card_eci(xml, credit_card, options) add_credit_card_verification_strings(xml, credit_card, options) end end + def add_credit_card_eci(xml, credit_card, options) + eci = if credit_card.is_a?(NetworkTokenizationCreditCard) && credit_card.source == :apple_pay && card_brand(credit_card) == "discover" + # Discover requires any Apple Pay transaction, regardless of in-app + # or web, and regardless of the ECI contained in the PKPaymentToken, + # to have an ECI value explicitly of 04. + "04" + else + (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI + end + + xml.tag! "Ecommerce_Flag", eci.to_s =~ /^[0-9]+$/ ? eci.to_s.rjust(2, '0') : eci + end + def add_credit_card_verification_strings(xml, credit_card, options) address = options[:billing_address] || options[:address] if address diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb index 64c6d9222e3..45dfd718e49 100755 --- a/test/unit/gateways/firstdata_e4_test.rb +++ b/test/unit/gateways/firstdata_e4_test.rb @@ -237,6 +237,25 @@ def test_network_tokenization_requests_with_amex end.respond_with(successful_purchase_response) end + def test_network_tokenization_requests_with_discover + stub_comms do + credit_card = network_tokenization_credit_card( + "6011111111111117", + brand: "discover", + transaction_id: "123", + eci: "05", + payment_cryptogram: "whatever_the_cryptogram_is", + ) + + @gateway.purchase(@amount, credit_card, @options) + end.check_request do |_, data, _| + assert_match "04", data + assert_match "123", data + assert_match "whatever_the_cryptogram_is", data + assert_xml_valid_to_wsdl(data) + end.respond_with(successful_purchase_response) + end + def test_network_tokenization_requests_with_other_brands %w(visa mastercard other).each do |brand| stub_comms do From fc5a94c271f5a86968f981485319c787d8b83c2f Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Tue, 2 Jan 2018 11:16:50 -0500 Subject: [PATCH 264/677] Fix tests failing due to new year (#2692) These assertions had hard coded years in the credit card expiry, which isn't how the test helpers work. Let's assert against what the card object actually contains. --- test/unit/gateways/safe_charge_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit/gateways/safe_charge_test.rb b/test/unit/gateways/safe_charge_test.rb index 3685b8879e3..a5ce762e70b 100644 --- a/test/unit/gateways/safe_charge_test.rb +++ b/test/unit/gateways/safe_charge_test.rb @@ -25,7 +25,7 @@ def test_successful_purchase assert_equal '111951|101508189567|ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAd' \ 'AAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAF' \ - 'UAbQBYAFIAMwA=|09|18|1.00|USD', response.authorization + "UAbQBYAFIAMwA=|%02d|%d|1.00|USD" % [@credit_card.month, @credit_card.year.to_s[-2..-1]], response.authorization assert response.test? end @@ -45,7 +45,7 @@ def test_successful_authorize assert_equal '111534|101508189855|MQBVAG4ASABkAEgAagB3AEsAbgAtACoAWgAzAFwAW' \ 'wBNAF8ATQBUAD0AegBQAGwAQAAtAD0AXAB5AFkALwBtAFAALABaAHoAOgBFAE' \ - 'wAUAA1AFUAMwA=|09|18|1.00|USD', response.authorization + "wAUAA1AFUAMwA=|%02d|%d|1.00|USD" % [@credit_card.month, @credit_card.year.to_s[-2..-1]], response.authorization assert response.test? end @@ -138,7 +138,7 @@ def test_successful_verify assert_equal '111534|101508189855|MQBVAG4ASABkAEgAagB3AEsAbgAtACoAWgAzAFwAW' \ 'wBNAF8ATQBUAD0AegBQAGwAQAAtAD0AXAB5AFkALwBtAFAALABaAHoAOgBFAE' \ - 'wAUAA1AFUAMwA=|09|18|1.00|USD', response.authorization + "wAUAA1AFUAMwA=|%02d|%d|1.00|USD" % [@credit_card.month, @credit_card.year.to_s[-2..-1]], response.authorization assert response.test? end From 63e6a25c5a547bcddad34233c459874750896f4e Mon Sep 17 00:00:00 2001 From: Bart de Water Date: Wed, 3 Jan 2018 09:20:55 -0500 Subject: [PATCH 265/677] Quickbooks: Add payment context to Quickbooks charges and refunds The mobile and isEcommerce flags are mandatory on the sandbox env now and will be in production starting February 1st. Without the context errors like "PMT-4000: context is invalid." are returned. References: - https://developer.intuit.com/hub/blog/2017/08/01/updates-payment-apis-quickbooks-online - https://developer.intuit.com/docs/api/payments/charges Closes #2694 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/quickbooks.rb | 10 ++++++++++ test/unit/gateways/quickbooks_test.rb | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 859825d547a..7dd6629340e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -25,6 +25,7 @@ * Mercado Pago: Support X-Device-Session-ID Header [bpollack] #2689 * Mercado Pago: Support arbitrary additional_info JSON [bpollack] #2691 * FirstData E4: Override ECI value for Apple Pay transactions with Discover [jasonwebster] #2671 +* Quickbooks: Add payment context to Quickbooks charges and refunds [bdewater] #2694 == Version 1.75.0 (November 9, 2017) * Barclaycard Smartpay: Clean up test options hashes [bpollack] #2632 diff --git a/lib/active_merchant/billing/gateways/quickbooks.rb b/lib/active_merchant/billing/gateways/quickbooks.rb index 15ae55d54ce..a4f52206ec9 100644 --- a/lib/active_merchant/billing/gateways/quickbooks.rb +++ b/lib/active_merchant/billing/gateways/quickbooks.rb @@ -78,6 +78,7 @@ def capture(money, authorization, options = {}) post = {} capture_uri = "#{ENDPOINT}/#{CGI.escape(authorization)}/capture" post[:amount] = localized_amount(money, currency(money)) + add_context(post, options) commit(capture_uri, post) end @@ -85,6 +86,7 @@ def capture(money, authorization, options = {}) def refund(money, authorization, options = {}) post = {} post[:amount] = localized_amount(money, currency(money)) + add_context(post, options) commit(refund_uri(authorization), post) end @@ -137,6 +139,7 @@ def add_amount(post, money, options = {}) def add_payment(post, payment, options = {}) add_creditcard(post, payment, options) + add_context(post, options) end def add_creditcard(post, creditcard, options = {}) @@ -151,6 +154,13 @@ def add_creditcard(post, creditcard, options = {}) post[:card] = card end + def add_context(post, options = {}) + post[:context] = { + mobile: options.fetch(:mobile, false), + isEcommerce: options.fetch(:ecommerce, true) + } + end + def parse(body) JSON.parse(body) end diff --git a/test/unit/gateways/quickbooks_test.rb b/test/unit/gateways/quickbooks_test.rb index c264c0354b1..c8f5641d1ce 100644 --- a/test/unit/gateways/quickbooks_test.rb +++ b/test/unit/gateways/quickbooks_test.rb @@ -112,6 +112,16 @@ def test_scrub_with_small_json assert_equal @gateway.scrub(pre_scrubbed_small_json), post_scrubbed_small_json end + def test_default_context + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |_endpoint, data, _headers| + json = JSON.parse(data) + refute json.fetch('context').fetch('mobile') + assert json.fetch('context').fetch('isEcommerce') + end.respond_with(successful_purchase_response) + end + private def pre_scrubbed_small_json From c73f5b698436aad02a7b7ba94298f53da8ce109d Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Wed, 3 Jan 2018 09:53:40 -0500 Subject: [PATCH 266/677] Release v1.76.0 --- lib/active_merchant/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 1dee09dc9d3..be277160218 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.75.0" + VERSION = "1.76.0" end From 6f1fd1465eaa188474aae726ea39e6666f666f0c Mon Sep 17 00:00:00 2001 From: Jason Webster Date: Wed, 3 Jan 2018 09:56:39 -0500 Subject: [PATCH 267/677] Update changelog for 1.76.0 Ahhh whoops. Forgot to do it in the release commit. --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 7dd6629340e..29070df4888 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ = ActiveMerchant CHANGELOG == HEAD + +== Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 * Checkout V2: Allows AVS and CVV result details to come through on authorizations [deedeelavinder] #2650 * Global Collect: Adds boolean option for pre_authorization [deeedeelavinder] #2651 From 905c2f64e85343c788185ebce2d26d5310b011b1 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Fri, 29 Dec 2017 09:11:19 -0500 Subject: [PATCH 268/677] Forte and Moneris US: ensure unit tests are local-only Improper use (or lack of it, rather) of stub_comms was causing Forte and Moneris US unit tests to fail intermittently on Travis. Fix them to truly be local-only. Forte unit tests: 17 tests, 58 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Moneris US unit tests: Unit: 32 tests, 161 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2696 --- CHANGELOG | 2 + test/unit/gateways/forte_test.rb | 105 ++++++++++++++------------ test/unit/gateways/moneris_us_test.rb | 4 +- 3 files changed, 62 insertions(+), 49 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 29070df4888..d7677bbe83f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ = ActiveMerchant CHANGELOG == HEAD +* Forte: ensure unit tests are local-only [bpollack] #2696 +* Moneris US: ensure unit tests are local-only [bpollack] #2696 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/test/unit/gateways/forte_test.rb b/test/unit/gateways/forte_test.rb index d3990377e13..de88de9ab31 100644 --- a/test/unit/gateways/forte_test.rb +++ b/test/unit/gateways/forte_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class ForteTest < Test::Unit::TestCase + include CommStub + def setup @gateway = ForteGateway.new(location_id: 'location_id', account_id: 'account_id', api_key: 'api_key', secret: 'secret') @credit_card = credit_card @@ -15,9 +17,9 @@ def setup end def test_successful_purchase - @gateway.expects(:handle_resp).returns(successful_purchase_response) - - response = @gateway.purchase(@amount, @credit_card, @options) + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.purchase(@amount, @credit_card, @options) + end.respond_with(MockedResponse.new(successful_purchase_response)) assert_success response assert_equal 'trn_bb7687a7-3d3a-40c2-8fa9-90727a814249#123456', response.authorization @@ -26,24 +28,25 @@ def test_successful_purchase def test_purchase_passes_options options = { order_id: '1' } - @gateway.expects(:commit).with(anything, has_entries(:order_number => '1')) - @gateway.purchase(@amount, @credit_card, options) + stub_comms(@gateway, :raw_ssl_request) do + @gateway.purchase(@amount, @credit_card, options) + end.respond_with(MockedResponse.new(successful_purchase_response)) end def test_failed_purchase - @gateway.expects(:handle_resp).returns(failed_purchase_response) - - response = @gateway.purchase(@amount, @credit_card, @options) + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.purchase(@amount, @credit_card, @options) + end.respond_with(MockedResponse.new(failed_purchase_response)) assert_failure response assert_equal "INVALID TRN", response.message end def test_successful_purchase_with_echeck - @gateway.expects(:handle_resp).returns(successful_echeck_purchase_response) - - response = @gateway.purchase(@amount, @check, @options) + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.purchase(@amount, @check, @options) + end.respond_with(MockedResponse.new(successful_echeck_purchase_response)) assert_success response assert_equal 'trn_bb7687a7-3d3a-40c2-8fa9-90727a814249#123456', response.authorization @@ -51,88 +54,88 @@ def test_successful_purchase_with_echeck end def test_failed_purchase_with_echeck - @gateway.expects(:handle_resp).returns(failed_echeck_purchase_response) - - response = @gateway.purchase(@amount, @credit_card, @options) + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.purchase(@amount, @credit_card, @options) + end.respond_with(MockedResponse.new(failed_echeck_purchase_response)) assert_failure response assert_equal "INVALID CREDIT CARD NUMBER", response.message end def test_successful_authorize - @gateway.expects(:handle_resp).returns(successful_authorize_response) - - response = @gateway.authorize(@amount, @credit_card, @options) + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.authorize(@amount, @credit_card, @options) + end.respond_with(MockedResponse.new(successful_authorize_response)) assert_success response end def test_failed_authorize - @gateway.expects(:handle_resp).returns(failed_authorize_response) - - response = @gateway.authorize(@amount, @credit_card, @options) + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.authorize(@amount, @credit_card, @options) + end.respond_with(MockedResponse.new(failed_authorize_response)) assert_failure response assert_equal "INVALID CREDIT CARD NUMBER", response.message end def test_successful_capture - @gateway.expects(:handle_resp).returns(successful_capture_response) - - response = @gateway.capture(@amount, "authcode") + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.capture(@amount, "authcode") + end.respond_with(MockedResponse.new(successful_capture_response)) assert_success response end def test_failed_capture - @gateway.expects(:handle_resp).returns(failed_capture_response) - - response = @gateway.capture(@amount, "authcode") + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.capture(@amount, "authcode") + end.respond_with(MockedResponse.new(failed_capture_response)) assert_failure response end def test_successful_credit - @gateway.expects(:handle_resp).returns(successful_credit_response) - - response = @gateway.credit(@amount, @credit_card, @options) + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.credit(@amount, @credit_card, @options) + end.respond_with(MockedResponse.new(successful_credit_response)) assert_success response end def test_failed_credit - @gateway.expects(:handle_resp).returns(failed_credit_response) - - response = @gateway.credit(@amount, @credit_card, @options) + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.credit(@amount, @credit_card, @options) + end.respond_with(MockedResponse.new(failed_credit_response)) assert_failure response end def test_successful_void - @gateway.expects(:handle_resp).returns(successful_credit_response) - - response = @gateway.void("authcode") + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.void("authcode") + end.respond_with(MockedResponse.new(successful_credit_response)) assert_success response end def test_failed_void - @gateway.expects(:handle_resp).returns(failed_credit_response) - - response = @gateway.void("authcode") + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.void("authcode") + end.respond_with(MockedResponse.new(failed_credit_response)) assert_failure response end def test_successful_verify - @gateway.expects(:handle_resp).times(2).returns(successful_authorize_response, successful_void_response) - - response = @gateway.verify(@credit_card, @options) + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.verify(@credit_card, @options) + end.respond_with(MockedResponse.new(successful_authorize_response), MockedResponse.new(successful_void_response)) assert_success response end def test_successful_verify_with_failed_void - @gateway.expects(:handle_resp).times(2).returns(successful_authorize_response, failed_void_response) - - response = @gateway.verify(@credit_card, @options) + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.verify(@credit_card, @options) + end.respond_with(MockedResponse.new(successful_authorize_response), MockedResponse.new(failed_void_response)) assert_success response end def test_failed_verify - @gateway.expects(:handle_resp).returns(failed_authorize_response) - - response = @gateway.verify(@credit_card, @options) + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.verify(@credit_card, @options) + end.respond_with(MockedResponse.new(failed_authorize_response)) assert_failure response end @@ -143,6 +146,14 @@ def test_scrub private + class MockedResponse + attr :code, :body + def initialize(body, code = 200) + @code = code + @body = body + end + end + def pre_scrubbed %q( <- "POST /api/v2/accounts/act_300111/locations/loc_176008/transactions/ HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Basic ZjA4N2E5MGYwMGYwYWU1NzA1MGM5MzdlZDM4MTVjOWY6ZDc5M2Q2NDA2NGUzMTEzYTc0ZmE3MjAzNWNmYzNhMWQ=\r\nX-Forte-Auth-Account-Id: act_300111\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: sandbox.forte.net\r\nContent-Length: 471\r\n\r\n" diff --git a/test/unit/gateways/moneris_us_test.rb b/test/unit/gateways/moneris_us_test.rb index 8bc63a9c289..f9f997b5d0a 100644 --- a/test/unit/gateways/moneris_us_test.rb +++ b/test/unit/gateways/moneris_us_test.rb @@ -243,7 +243,7 @@ def test_avs_enabled_and_provided gateway = MonerisGateway.new(login: 'store1', password: 'yesguy', avs_enabled: true) billing_address = address(address1: "1234 Anystreet", address2: "") - stub_comms do + stub_comms(gateway) do gateway.purchase(@amount, @credit_card, billing_address: billing_address, order_id: "1") end.check_request do |endpoint, data, headers| assert_match(%r{avs_street_number>1234<}, data) @@ -255,7 +255,7 @@ def test_avs_enabled_and_provided def test_avs_enabled_but_not_provided gateway = MonerisGateway.new(login: 'store1', password: 'yesguy', avs_enabled: true) - stub_comms do + stub_comms(gateway) do gateway.purchase(@amount, @credit_card, @options.tap { |x| x.delete(:billing_address) }) end.check_request do |endpoint, data, headers| assert_no_match(%r{avs_street_number>}, data) From 974b3c8888587e4ae47816a348cba3238a73d52f Mon Sep 17 00:00:00 2001 From: Niaja Date: Tue, 2 Jan 2018 11:04:17 -0500 Subject: [PATCH 269/677] Payflow: Change Verify Method for Amex Cards Currently $0 authorization is only supported for AVS. This changes the verify method for amex cards to be a $1 auth and void. Tests failures are unrelated to these changes. Loaded suite test/remote/gateways/remote_payflow_test 27 tests, 99 assertions, 10 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 62.963% passed ---------------------------------------------------------------------------------------- 0.60 tests/s, 2.18 assertions/s Loaded suite test/unit/gateways/payflow_test 44 tests, 192 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/payflow.rb | 9 ++++++++- test/fixtures.yml | 2 +- test/remote/gateways/remote_payflow_test.rb | 10 ++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb index 6e7d0e6f1b6..5d9315dc29a 100644 --- a/lib/active_merchant/billing/gateways/payflow.rb +++ b/lib/active_merchant/billing/gateways/payflow.rb @@ -45,7 +45,14 @@ def refund(money, reference, options = {}) end def verify(payment, options={}) - authorize(0, payment, options) + if credit_card_type(payment) == 'Amex' + MultiResponse.run(:use_first_response) do |r| + r.process { authorize(100, payment, options) } + r.process(:ignore_result) { void(r.authorization, options) } + end + else + authorize(0, payment, options) + end end def verify_credentials diff --git a/test/fixtures.yml b/test/fixtures.yml index 40da19ea241..0b5092a20cf 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -663,7 +663,7 @@ payex: # Working credentials, no need to replace payflow: login: 'spreedlyIntegrations' - password: 'y9q)(j7H' + password: 'L9DjqEKjXCkU' partner: 'PayPal' payflow_uk: diff --git a/test/remote/gateways/remote_payflow_test.rb b/test/remote/gateways/remote_payflow_test.rb index b0068e50c96..fbc5f2f2589 100644 --- a/test/remote/gateways/remote_payflow_test.rb +++ b/test/remote/gateways/remote_payflow_test.rb @@ -129,6 +129,16 @@ def test_successful_verify assert_equal "Verified", response.message end + def test_successful_verify_amex + @amex_credit_card = credit_card( + '378282246310005', + :brand => 'american_express' + ) + assert response = @gateway.verify(@amex_credit_card, @options) + assert_success response + assert_equal "Approved", response.message + end + def test_failed_verify assert response = @gateway.verify(credit_card("4000056655665556"), @options) assert_failure response From 8ca6ac96ee7c83ff796e3530fbc08224b66f0baa Mon Sep 17 00:00:00 2001 From: Niaja Date: Wed, 3 Jan 2018 15:57:16 -0500 Subject: [PATCH 270/677] Authorize.net: Allow Transaction Id to be passed for refunds Authorize.net requires transaction id and payment info to refund a transaction. This allows for the transaction_id to be passed directly Loaded suite test/remote/gateways/remote_authorize_net_test 63 tests, 215 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/authorize_net_test Finished in 0.306942 seconds. 90 tests, 511 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 2 ++ lib/active_merchant/billing/gateways/authorize_net.rb | 7 +++++++ test/remote/gateways/remote_authorize_net_test.rb | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index d7677bbe83f..aa1e669addc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,8 +1,10 @@ = ActiveMerchant CHANGELOG == HEAD +* Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 * Forte: ensure unit tests are local-only [bpollack] #2696 * Moneris US: ensure unit tests are local-only [bpollack] #2696 +* Payflow: Change Verify Method for Amex Cards [nfarve] #2693 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index 4922080f420..cd5e8b69453 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -168,6 +168,7 @@ def credit(amount, payment, options={}) xml.amount(amount(amount)) add_payment_source(xml, payment) + xml.refTransId(transaction_id_from(options[:transaction_id])) if options[:transaction_id] add_invoice(xml, 'refundTransaction', options) add_customer_data(xml, payment, options) add_settings(xml, payment, options) @@ -423,6 +424,12 @@ def add_settings(xml, source, options) xml.settingValue(options[:header_email_receipt]) end end + if options[:test_request] + xml.setting do + xml.settingName("testRequest") + xml.settingValue("1") + end + end end end diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb index 806d44a7cf5..ed443256b70 100644 --- a/test/remote/gateways/remote_authorize_net_test.rb +++ b/test/remote/gateways/remote_authorize_net_test.rb @@ -569,6 +569,16 @@ def test_successful_echeck_credit assert response.authorization end + def test_successful_echeck_refund + purchase = @gateway.purchase(@amount, @check, @options) + assert_success purchase + + @options.update(transaction_id: purchase.params['transaction_id'], test_request: true) + refund = @gateway.credit(@amount, @check, @options) + assert_failure refund + assert_match %r{The transaction cannot be found}, refund.message, "Only allowed to refund transactions that have settled. This is the best we can do for now testing wise." + end + def test_failed_credit response = @gateway.credit(@amount, @declined_card, @options) assert_failure response From b6958c8528241e38f6f641fb45711cc1e487d6ca Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Wed, 3 Jan 2018 15:18:46 -0500 Subject: [PATCH 271/677] Safe Charge: fix variable shadowing issue Unit: 17 tests, 76 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 21 tests, 62 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2697 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/safe_charge.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index aa1e669addc..8dc49e6461b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Forte: ensure unit tests are local-only [bpollack] #2696 * Moneris US: ensure unit tests are local-only [bpollack] #2696 * Payflow: Change Verify Method for Amex Cards [nfarve] #2693 +* Safe Charge: fix an issue with variable shadowing in the adapter [bpollack] #2697 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index 373ae08d024..3c7119ae16f 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -170,8 +170,8 @@ def childnode_to_response(response, childnode) if childnode.elements.size == 0 element_name_to_symbol(response, childnode) else - childnode.traverse do |childnode| - element_name_to_symbol(response, childnode) + childnode.traverse do |node| + element_name_to_symbol(response, node) end end end From 747047956feb69e526d5674b60ee93798cb5f36b Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Fri, 29 Dec 2017 09:11:19 -0500 Subject: [PATCH 272/677] Borgun: add remote scrubbing test One remote test (test_invalid_login) fails; I believe this is an upstream change, but at any rate, it's not affected by this patch. I'll do a separate commit if this failure is expected. Remote: 19 tests, 43 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 94.7368% passed Unit: 7 tests, 34 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- test/remote/gateways/remote_borgun_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/remote/gateways/remote_borgun_test.rb b/test/remote/gateways/remote_borgun_test.rb index 02310810865..4b4ac758865 100644 --- a/test/remote/gateways/remote_borgun_test.rb +++ b/test/remote/gateways/remote_borgun_test.rb @@ -163,4 +163,14 @@ def test_invalid_login assert response = authentication_exception.response assert_match(/Access Denied/, response.body) end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + end end From fd044d7f7330c7bb8db253c3aa0d80778f1778fd Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Fri, 29 Dec 2017 09:11:19 -0500 Subject: [PATCH 273/677] Clearhaus: add remote scrubbing test Also repaired one remote test, whose behavior changed due to an upstream change on how URL paths were handled. Unit: 22 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 23 tests, 70 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- test/remote/gateways/remote_clearhaus_test.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/remote/gateways/remote_clearhaus_test.rb b/test/remote/gateways/remote_clearhaus_test.rb index 48da7c9b1a8..006249c9263 100644 --- a/test/remote/gateways/remote_clearhaus_test.rb +++ b/test/remote/gateways/remote_clearhaus_test.rb @@ -118,7 +118,7 @@ def test_partial_capture end def test_failed_capture - response = @gateway.capture(@amount, '') + response = @gateway.capture(@amount, 'z') assert_failure response assert_equal 'invalid transaction id', response.message end @@ -196,4 +196,14 @@ def test_invalid_login gateway.purchase(@amount, @credit_card, @options) end end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + end end From ac0d721e19b6be6611c9f9011a28c457f11e85d5 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Fri, 29 Dec 2017 09:11:19 -0500 Subject: [PATCH 274/677] Fat Zebra: add remote scrubbing test One remote test (test_failed_purchase_with_incomplete_3DS_information) fails, but not due to this commit, and fixing it is outside the scope of this commit. Unit: 17 tests, 89 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 19 tests, 68 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 94.7368% passed --- test/remote/gateways/remote_fat_zebra_test.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/remote/gateways/remote_fat_zebra_test.rb b/test/remote/gateways/remote_fat_zebra_test.rb index d63efaf3a4c..8dbe064d0ec 100644 --- a/test/remote/gateways/remote_fat_zebra_test.rb +++ b/test/remote/gateways/remote_fat_zebra_test.rb @@ -10,7 +10,7 @@ def setup @options = { :order_id => rand(100000).to_s, - :ip => "123.1.2.3" + :ip => "1.2.3.4" } end @@ -148,4 +148,14 @@ def test_invalid_login assert_failure response assert_equal 'Invalid Login', response.message end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + end end From 8bec04fa45ab406e00a01838b627ce906127b0c9 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Fri, 29 Dec 2017 09:11:19 -0500 Subject: [PATCH 275/677] Barclays EPDQ: add remote scrubbing tests Three remote tests fail: two appear to be changes in how Barclays EPDQ responds to inavlid data, and one appears to be our test account lacking permissions to do refunds. None are affected by this patch. Remote: 18 tests, 67 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 83.3333% passed Unit: 44 tests, 185 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- .../gateways/remote_barclays_epdq_extra_plus_test.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb b/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb index b8fb97c8265..01c575ce95d 100644 --- a/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb +++ b/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb @@ -5,7 +5,7 @@ class RemoteBarclaysEpdqExtraPlusTest < Test::Unit::TestCase def setup @gateway = BarclaysEpdqExtraPlusGateway.new(fixtures(:barclays_epdq_extra_plus)) @amount = 100 - @credit_card = credit_card('4000100011112224') + @credit_card = credit_card('4000100011112224', :verification_value => '987') @mastercard = credit_card('5399999999999999', :brand => "mastercard") @declined_card = credit_card('1111111111111111') @credit_card_d3d = credit_card('4000000000000002', :verification_value => '111') @@ -224,4 +224,14 @@ def test_invalid_login assert_failure response assert_equal 'Some of the data entered is incorrect. please retry.', response.message end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + end end From 1517c9bbbce375adffe5261b813e1ba3b6bd65e7 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Fri, 29 Dec 2017 09:11:19 -0500 Subject: [PATCH 276/677] Cashnet: add scrubbing support and support test server Remote: 5 tests, 26 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 16 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2695 --- CHANGELOG | 5 + .../billing/gateways/cashnet.rb | 16 ++- test/remote/gateways/remote_cashnet_test.rb | 11 ++ test/unit/gateways/cashnet_test.rb | 131 ++++++++++++++++++ 4 files changed, 161 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8dc49e6461b..a5f155ac6c9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,11 @@ * Moneris US: ensure unit tests are local-only [bpollack] #2696 * Payflow: Change Verify Method for Amex Cards [nfarve] #2693 * Safe Charge: fix an issue with variable shadowing in the adapter [bpollack] #2697 +* Crashnet: add scrubbing support [bpollack] #2695 +* Barclays EPDQ: add scrubbing support [bpollack] #2695 +* Fat Zebra: add remote scrubbing test [bpollack] #2695 +* Clearhaus: add remote scrubbing test [bpollack] #2695 +* Borgun: add remote scrubbing test [bpollack] #2695 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/gateways/cashnet.rb b/lib/active_merchant/billing/gateways/cashnet.rb index df790f198ba..463d83e66cc 100644 --- a/lib/active_merchant/billing/gateways/cashnet.rb +++ b/lib/active_merchant/billing/gateways/cashnet.rb @@ -3,7 +3,8 @@ module Billing #:nodoc: class CashnetGateway < Gateway include Empty - self.live_url = "https://commerce.cashnet.com/" + self.live_url = "https://commerce.cashnet.com/" + self.test_url = "https://train.cashnet.com/" self.supported_countries = ["US"] self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb] @@ -54,11 +55,22 @@ def refund(money, identification, options = {}) commit('REFUND', money, post) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript + .gsub(%r{(password=)[^&]+}, '\1[FILTERED]') + .gsub(%r{(cardno=)[^&]+}, '\1[FILTERED]') + .gsub(%r{(cid=)[^&]+}, '\1[FILTERED]') + end + private def commit(action, money, fields) fields[:amount] = amount(money) - url = live_url + CGI.escape(@options[:merchant_gateway_name]) + url = (test? ? test_url : live_url) + CGI.escape(@options[:merchant_gateway_name]) raw_response = ssl_post(url, post_data(action, fields)) parsed_response = parse(raw_response) diff --git a/test/remote/gateways/remote_cashnet_test.rb b/test/remote/gateways/remote_cashnet_test.rb index b30925b2bbe..babeb00ae47 100644 --- a/test/remote/gateways/remote_cashnet_test.rb +++ b/test/remote/gateways/remote_cashnet_test.rb @@ -52,4 +52,15 @@ def test_failed_refund assert_match %r{Amount to refund exceeds}, refund.message assert_equal "302", refund.params["result"] end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end end diff --git a/test/unit/gateways/cashnet_test.rb b/test/unit/gateways/cashnet_test.rb index 52ba6f8255c..a5f1cbc7efb 100644 --- a/test/unit/gateways/cashnet_test.rb +++ b/test/unit/gateways/cashnet_test.rb @@ -141,6 +141,11 @@ def test_allows_custcode_override end.respond_with(successful_purchase_response) end + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + private def expected_expiration_date '%02d%02d' % [@credit_card.month, @credit_card.year.to_s[2..4]] @@ -169,4 +174,130 @@ def failed_purchase_response def invalid_response "A String without a cngateway tag" 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\n

Object 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\n

Object 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 From e99f157fd9c285cb178282b4e1cb7ca736ba64cb Mon Sep 17 00:00:00 2001 From: Ryan Balsdon Date: Mon, 16 Oct 2017 15:31:14 -0400 Subject: [PATCH 277/677] Stripe: quickchip support, consolidate emv states and read_method metadata --- CHANGELOG | 1 + lib/active_merchant/billing/credit_card.rb | 25 +++---- .../billing/gateways/stripe.rb | 25 +++++-- test/fixtures.yml | 10 --- .../remote/gateways/remote_stripe_emv_test.rb | 73 +++++++++---------- test/unit/gateways/stripe_test.rb | 60 +++++++++++++-- 6 files changed, 120 insertions(+), 74 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a5f155ac6c9..d55cee54705 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Fat Zebra: add remote scrubbing test [bpollack] #2695 * Clearhaus: add remote scrubbing test [bpollack] #2695 * Borgun: add remote scrubbing test [bpollack] #2695 +* Stripe: Added support for the quickchip entry mode option [rbalsdon] == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb index 3e7a344ee11..91b211bc6fd 100644 --- a/lib/active_merchant/billing/credit_card.rb +++ b/lib/active_merchant/billing/credit_card.rb @@ -176,21 +176,20 @@ def requires_verification_value? # @return [String] attr_accessor :icc_data - # Returns or sets a fallback reason for a EMV transaction whereby the customer's card entered a fallback scenario. - # This can be an arbitrary string. + # Returns or sets information about the source of the card data. # # @return [String] - attr_accessor :fallback_reason - - # Returns or sets whether card-present EMV data has been read contactlessly. - # - # @return [true, false] - attr_accessor :contactless_emv - - # Returns or sets whether card-present magstripe data has been read contactlessly. - # - # @return [true, false] - attr_accessor :contactless_magstripe + attr_accessor :read_method + + READ_METHOD_DESCRIPTIONS = { + nil => 'A card reader was not used.', + 'fallback_no_chip' => 'Magstripe was read because the card has no chip.', + 'fallback_chip_error' => "Magstripe was read because the card's chip failed.", + 'contactless' => 'Data was read by a Contactless EMV kernel. Issuer script results are not available.', + 'contactless_magstripe' => 'Contactless data was read with a non-EMV protocol.', + 'contact' => 'Data was read using the EMV protocol. Issuer script results may follow.', + 'contact_quickchip' => 'Data was read by the Quickchip EMV kernel. Issuer script results are not available.', + } # Returns the ciphertext of the card's encrypted PIN. # diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 10a23be6f0b..65a95003838 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -112,6 +112,7 @@ def purchase(money, payment, options = {}) end r.process do post = create_post_for_auth_or_purchase(money, payment, options) + post[:card][:processing_method] = 'quick_chip' if quickchip_payment?(payment) commit(:post, 'charges', post, options) end end.responses.last @@ -305,6 +306,7 @@ def create_post_for_auth_or_purchase(money, payment, options) if emv_payment?(payment) add_statement_address(post, options) + add_emv_metadata(post, payment) else add_amount(post, money, options, true) add_customer_data(post, options) @@ -383,8 +385,7 @@ def add_creditcard(post, creditcard, options) card = {} if emv_payment?(creditcard) add_emv_creditcard(post, creditcard.icc_data) - post[:card][:read_method] = "contactless" if creditcard.contactless_emv - post[:card][:read_method] = "contactless_magstripe_mode" if creditcard.contactless_magstripe + post[:card][:read_method] = "contactless" if creditcard.read_method == 'contactless' if creditcard.encrypted_pin_cryptogram.present? && creditcard.encrypted_pin_ksn.present? post[:card][:encrypted_pin] = creditcard.encrypted_pin_cryptogram post[:card][:encrypted_pin_key_id] = creditcard.encrypted_pin_ksn @@ -392,9 +393,11 @@ def add_creditcard(post, creditcard, options) elsif creditcard.respond_to?(:number) if creditcard.respond_to?(:track_data) && creditcard.track_data.present? card[:swipe_data] = creditcard.track_data - card[:fallback_reason] = creditcard.fallback_reason if creditcard.fallback_reason - card[:read_method] = "contactless" if creditcard.contactless_emv - card[:read_method] = "contactless_magstripe_mode" if creditcard.contactless_magstripe + if creditcard.respond_to?(:read_method) + card[:fallback_reason] = 'no_chip' if creditcard.read_method == 'fallback_no_chip' + card[:fallback_reason] = 'chip_error' if creditcard.read_method == 'fallback_chip_error' + card[:read_method] = "contactless_magstripe_mode" if creditcard.read_method == 'contactless_magstripe' + end else card[:number] = creditcard.number card[:exp_month] = creditcard.month @@ -446,12 +449,18 @@ def add_flags(post, options) end def add_metadata(post, options = {}) - post[:metadata] = options[:metadata] || {} + post[:metadata] ||= {} + post[:metadata].merge!(options[:metadata]) if options[:metadata] post[:metadata][:email] = options[:email] if options[:email] post[:metadata][:order_id] = options[:order_id] if options[:order_id] post.delete(:metadata) if post[:metadata].empty? end + def add_emv_metadata(post, creditcard) + post[:metadata] ||= {} + post[:metadata][:card_read_method] = creditcard.read_method if creditcard.respond_to?(:read_method) + end + def fetch_application_fees(identification, options = {}) options.merge!(:key => @fee_refund_api_key) @@ -586,6 +595,10 @@ def emv_payment?(payment) payment.respond_to?(:emv?) && payment.emv? end + def quickchip_payment?(payment) + payment.respond_to?(:read_method) && payment.read_method == 'contact_quickchip' + end + def card_from_response(response) response["card"] || response["active_card"] || response["source"] || {} end diff --git a/test/fixtures.yml b/test/fixtures.yml index 0b5092a20cf..1e9105c3023 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -1113,16 +1113,6 @@ stripe: stripe_destination: stripe_user_id: "acct_17FRNfIPBJTitsen" -# Used only for remote tests that use EMV credit card mocks -stripe_emv_uk: - login: - fee_refund_login: - -# Used only for remote tests that use EMV credit card mocks -stripe_emv_us: - login: - fee_refund_login: - # Externally verified bank account for testing stripe_verified_bank_account: customer_id: "cus_7s22nNueP2Hjj6" diff --git a/test/remote/gateways/remote_stripe_emv_test.rb b/test/remote/gateways/remote_stripe_emv_test.rb index 076d504ff1c..1db4b4f53af 100644 --- a/test/remote/gateways/remote_stripe_emv_test.rb +++ b/test/remote/gateways/remote_stripe_emv_test.rb @@ -1,14 +1,16 @@ require 'test_helper' class RemoteStripeEmvTest < Test::Unit::TestCase + CHARGE_ID_REGEX = /ch_[a-zA-Z\d]{24}/ + def setup @gateway = StripeGateway.new(fixtures(:stripe)) @amount = 100 @emv_credit_cards = { - uk: ActiveMerchant::Billing::CreditCard.new(icc_data: '500B56495341204352454449545F201A56495341204143515549524552205445535420434152442030315F24031512315F280208405F2A0208265F300202015F34010182025C008407A0000000031010950502000080009A031408259B02E8009C01009F02060000000734499F03060000000000009F0607A00000000310109F0902008C9F100706010A03A080009F120F4352454449544F20444520564953419F1A0208269F1C0831373030303437309F1E0831373030303437309F2608EB2EC0F472BEA0A49F2701809F3303E0B8C89F34031E03009F3501229F360200C39F37040A27296F9F4104000001319F4502DAC5DFAE5711476173FFFFFF0119D15122011758989389DFAE5A08476173FFFFFF011957114761739001010119D151220117589893895A084761739001010119'), - us: ActiveMerchant::Billing::CreditCard.new(icc_data: '50074D41455354524F571167999989000018123D25122200835506065A0967999989000018123F5F20134D54495032362D204D41455354524F203132415F24032512315F280200565F2A0208405F300202205F340101820278008407A0000000043060950500000080009A031504219B02E8009C01009F02060000000010009F03060000000000009F0607A00000000430609F090200029F10120210A7800F040000000000000000000000FF9F12074D61657374726F9F1A0208409F1C0831303030333331369F1E0831303030333331369F2608460245B808BCA1369F2701809F3303E0B8C89F34034403029F3501229F360200279F3704EA2C3A7A9F410400000094DF280104DFAE5711679999FFFFFFF8123D2512220083550606DFAE5A09679999FFFFFFF8123F'), - contactless: ActiveMerchant::Billing::CreditCard.new(icc_data: '500D5649534120454C454354524F4E5F20175649534120434445542032312F434152443035202020205F2A0208405F340111820200008407A00000000320109A031505119C01009F02060000000006959F0607A00000000320109F090200019F100706011103A000009F1A0200569F1C0831323334353637389F1E0831303030333236389F260852A5A96394EDA96D9F2701809F3303E0B8C89F3501229F360200069F3704A4428D7A9F410400000289DF280100DF30020301DFAE021885D6E511F8844CEA0DC72883180AC081AF4593A8A3C5FDD8DFAE030AFFFF0102628D1100005EDFAE5712476173FFFFFFFFF2234D151220114524040FDFAE021892FC2C940487F43AC64AB3DFD54C7B72F445FE409D80FDF5DFAE030AFFFF0102628D1100005F') + uk: ActiveMerchant::Billing::CreditCard.new(icc_data: '5A08476173900101011957114761739001010119D221220117589288899F131F3137353839383930303238383030303030304F07A0000000031010500B564953412043524544495482025C008407A00000000310108A025A318E0E00000000000000001E0302031F00950542000080009A031707259B02E8009C01005F24032212315F25030907015F2A0208265F3401019F01060000000000019F02060000000001009F03060000000000009F0607A00000000310109F0702FF009F0902008C9F0D05F0400088009F0E0500100000009F0F05F0400098009F100706010A03A000009F120F4352454449544F20444520564953419F160F3132333435363738393031323334359F1A0208269F1C0831313232333334349F1E0831323334353637389F21031137269F26084A3000C111F061539F2701809F33036028C89F34031E03009F3501219F360200029F370467D5DD109F3901059F40057E0000A0019F4104000001979F4E0D54657374204D65726368616E749F110101DF834F0F434842313136373235303030343439DF83620100'), + us: ActiveMerchant::Billing::CreditCard.new(icc_data: '5A08476173900101011957114761739001010119D221220117589288899F131F3137353839383930303238383030303030304F07A0000000031010500B564953412043524544495482025C008407A00000000310108A025A318E0E00000000000000001E0302031F00950542000080009A031707259B02E8009C01005F24032212315F25030907015F2A0208405F3401019F01060000000000019F02060000000001009F03060000000000009F0607A00000000310109F0702FF009F0902008C9F0D05F0400088009F0E0500100000009F0F05F0400098009F100706010A03A000009F120F4352454449544F20444520564953419F160F3132333435363738393031323334359F1A0208409F1C0831313232333334349F1E0831323334353637389F21031137269F26084A3000C111F061539F2701809F33036028C89F34031E03009F3501219F360200029F370467D5DD109F3901059F40057E0000A0019F4104000001979F4E0D54657374204D65726368616E749F110101DF834F0F434842313136373235303030343439DF83620100'), + contactless: ActiveMerchant::Billing::CreditCard.new(icc_data: '5A08476173900101011957114761739001010119D22122011758928889500D5649534120454C454354524F4E5F20175649534120434445542032312F434152443035202020205F2A0208405F340111820200008407A00000000320109A031505119C01009F02060000000006009F0607A00000000320109F090200019F100706011103A000009F1A0200569F1C0831323334353637389F1E0831303030333236389F260852A5A96394EDA96D9F2701809F3303E0B8C89F3501229F360200069F3704A4428D7A9F410400000289') } @options = { @@ -16,13 +18,17 @@ def setup :description => 'ActiveMerchant Test Purchase', :email => 'wow@example.com' } + + # This capture hex says that the payload is a transaction cryptogram (TC) but does not + # provide the actual cryptogram. This will only work in test mode and would cause real + # cards to be declined. + @capture_options = { icc_data: "9F270140" } end # for EMV contact transactions, it's advised to do a separate auth + capture # to satisfy the EMV chip's transaction flow, but this works as a legal # API call. You shouldn't use it in a real EMV implementation, though. def test_successful_purchase_with_emv_credit_card_in_uk - @gateway = StripeGateway.new(fixtures(:stripe_emv_uk)) assert response = @gateway.purchase(@amount, @emv_credit_cards[:uk], @options) assert_success response assert_equal "charge", response.params["object"] @@ -33,7 +39,6 @@ def test_successful_purchase_with_emv_credit_card_in_uk # perform separate auth & capture rather than a purchase in practice for the # reasons mentioned above. def test_successful_purchase_with_emv_credit_card_in_us - @gateway = StripeGateway.new(fixtures(:stripe_emv_us)) assert response = @gateway.purchase(@amount, @emv_credit_cards[:us], @options) assert_success response assert_equal "charge", response.params["object"] @@ -41,12 +46,22 @@ def test_successful_purchase_with_emv_credit_card_in_us assert_match CHARGE_ID_REGEX, response.authorization end + def test_successful_purchase_with_quickchip_credit_card_in_us + credit_card = @emv_credit_cards[:us] + credit_card.read_method = 'contact_quickchip' + assert response = @gateway.purchase(@amount, credit_card, @options) + assert_success response + assert_equal "charge", response.params["object"] + assert response.params["captured"] + assert response.params["paid"] + assert_match CHARGE_ID_REGEX, response.authorization + end + # For EMV contactless transactions, generally a purchase is preferred since # a TC is typically generated at the point of sale. def test_successful_purchase_with_emv_contactless_credit_card - @gateway = StripeGateway.new(fixtures(:stripe_emv_us)) emv_credit_card = @emv_credit_cards[:contactless] - emv_credit_card.contactless = true + emv_credit_card.read_method = 'contactless' assert response = @gateway.purchase(@amount, emv_credit_card, @options) assert_success response assert_equal "charge", response.params["object"] @@ -55,31 +70,28 @@ def test_successful_purchase_with_emv_contactless_credit_card end def test_authorization_and_capture_with_emv_credit_card_in_uk - @gateway = StripeGateway.new(fixtures(:stripe_emv_uk)) assert authorization = @gateway.authorize(@amount, @emv_credit_cards[:uk], @options) assert_success authorization assert authorization.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" refute authorization.params["captured"] - assert capture = @gateway.capture(@amount, authorization.authorization) + assert capture = @gateway.capture(@amount, authorization.authorization, @capture_options) assert_success capture assert capture.emv_authorization, "Capture should contain emv_authorization containing the EMV TC" end def test_authorization_and_capture_with_emv_credit_card_in_us - @gateway = StripeGateway.new(fixtures(:stripe_emv_us)) assert authorization = @gateway.authorize(@amount, @emv_credit_cards[:us], @options) assert_success authorization assert authorization.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" refute authorization.params["captured"] - assert capture = @gateway.capture(@amount, authorization.authorization) + assert capture = @gateway.capture(@amount, authorization.authorization, @capture_options) assert_success capture assert capture.emv_authorization, "Capture should contain emv_authorization containing the EMV TC" end def test_authorization_and_capture_of_online_pin_with_emv_credit_card_in_us - @gateway = StripeGateway.new(fixtures(:stripe_emv_us)) emv_credit_card = @emv_credit_cards[:us] emv_credit_card.encrypted_pin_cryptogram = "8b68af72199529b8" emv_credit_card.encrypted_pin_ksn = "ffff0102628d12000001" @@ -89,27 +101,12 @@ def test_authorization_and_capture_of_online_pin_with_emv_credit_card_in_us assert authorization.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" refute authorization.params["captured"] - assert capture = @gateway.capture(@amount, authorization.authorization) - assert_success capture - assert capture.emv_authorization, "Capture should contain emv_authorization containing the EMV TC" - end - - def test_authorization_and_capture_with_emv_contactless_credit_card - @gateway = StripeGateway.new(fixtures(:stripe_emv_us)) - emv_credit_card = @emv_credit_cards[:contactless] - emv_credit_card.contactless = true - assert authorization = @gateway.authorize(@amount, emv_credit_card, @options) - assert_success authorization - assert authorization.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" - refute authorization.params["captured"] - - assert capture = @gateway.capture(@amount, authorization.authorization) + assert capture = @gateway.capture(@amount, authorization.authorization, @capture_options) assert_success capture assert capture.emv_authorization, "Capture should contain emv_authorization containing the EMV TC" end def test_authorization_and_void_with_emv_credit_card_in_us - @gateway = StripeGateway.new(fixtures(:stripe_emv_us)) assert authorization = @gateway.authorize(@amount, @emv_credit_cards[:us], @options) assert_success authorization assert authorization.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" @@ -120,7 +117,6 @@ def test_authorization_and_void_with_emv_credit_card_in_us end def test_authorization_and_void_with_emv_credit_card_in_uk - @gateway = StripeGateway.new(fixtures(:stripe_emv_uk)) assert authorization = @gateway.authorize(@amount, @emv_credit_cards[:uk], @options) assert_success authorization assert authorization.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" @@ -130,21 +126,20 @@ def test_authorization_and_void_with_emv_credit_card_in_uk assert_success void end - def test_authorization_and_void_with_emv_contactless_credit_card - @gateway = StripeGateway.new(fixtures(:stripe_emv_us)) + def test_purchase_and_void_with_emv_contactless_credit_card emv_credit_card = @emv_credit_cards[:contactless] - emv_credit_card.contactless = true - assert authorization = @gateway.authorize(@amount, emv_credit_card, @options) - assert_success authorization - assert authorization.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" - refute authorization.params["captured"] - - assert void = @gateway.void(authorization.authorization) + emv_credit_card.read_method = 'contactless' + assert purchase = @gateway.purchase(@amount, emv_credit_card, @options) + assert_success purchase + assert purchase.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" + assert purchase.params["captured"] + assert purchase.params["paid"] + + assert void = @gateway.void(purchase.authorization) assert_success void end def test_authorization_emv_credit_card_in_us_with_metadata - @gateway = StripeGateway.new(fixtures(:stripe_emv_us)) assert authorization = @gateway.authorize(@amount, @emv_credit_cards[:us], @options.merge({:metadata => {:this_is_a_random_key_name => 'with a random value', :i_made_up_this_key_too => 'canyoutell'}, :order_id => "42", :email => "foo@wonderfullyfakedomain.com"})) assert_success authorization end diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index 599d644595e..a7619782f10 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -743,8 +743,8 @@ def test_add_creditcard_with_credit_card def test_add_creditcard_with_track_data post = {} - @credit_card.stubs(:track_data).returns("Tracking data") - @credit_card.stubs(:contactless_magstripe).returns(true) + @credit_card.stubs(:track_data).returns("Swipe data") + @credit_card.stubs(:read_method).returns('contactless_magstripe') @gateway.send(:add_creditcard, post, @credit_card, {}) assert_equal @credit_card.track_data, post[:card][:swipe_data] assert_equal "contactless_magstripe_mode", post[:card][:read_method] @@ -755,6 +755,34 @@ def test_add_creditcard_with_track_data assert_nil post[:card][:name] end + def test_add_creditcard_with_fallback_no_chip + post = {} + @credit_card.stubs(:track_data).returns("Swipe data") + @credit_card.stubs(:read_method).returns('fallback_no_chip') + @gateway.send(:add_creditcard, post, @credit_card, {}) + assert_equal @credit_card.track_data, post[:card][:swipe_data] + assert_equal "no_chip", post[:card][:fallback_reason] + assert_nil post[:card][:number] + assert_nil post[:card][:exp_year] + assert_nil post[:card][:exp_month] + assert_nil post[:card][:cvc] + assert_nil post[:card][:name] + end + + def test_add_creditcard_with_fallback_chip_error + post = {} + @credit_card.stubs(:track_data).returns("Swipe data") + @credit_card.stubs(:read_method).returns('fallback_chip_error') + @gateway.send(:add_creditcard, post, @credit_card, {}) + assert_equal @credit_card.track_data, post[:card][:swipe_data] + assert_equal "chip_error", post[:card][:fallback_reason] + assert_nil post[:card][:number] + assert_nil post[:card][:exp_year] + assert_nil post[:card][:exp_month] + assert_nil post[:card][:cvc] + assert_nil post[:card][:name] + end + def test_add_creditcard_with_card_token post = {} credit_card_token = "card_2iD4AezYnNNzkW" @@ -873,6 +901,7 @@ def test_client_data_submitted_with_metadata_in_options_with_emv_credit_card_pur assert_match(/metadata\[i_made_up_this_key_too\]=canyoutell/, data) assert_match(/metadata\[email\]=foo\%40wonderfullyfakedomain\.com/, data) assert_match(/metadata\[order_id\]=42/, data) + assert_match(/metadata\[card_read_method\]=contact/, data) end.respond_with(successful_purchase_response) end @@ -885,6 +914,25 @@ def test_client_data_submitted_with_metadata_in_options_with_emv_credit_card_aut assert_match(/metadata\[i_made_up_this_key_too\]=canyoutell/, data) assert_match(/metadata\[email\]=foo\%40wonderfullyfakedomain\.com/, data) assert_match(/metadata\[order_id\]=42/, data) + assert_match(/metadata\[card_read_method\]=contact/, data) + end.respond_with(successful_purchase_response) + end + + def test_quickchip_is_set_on_purchase + stub_comms(@gateway, :ssl_request) do + @emv_credit_card.read_method = 'contact_quickchip' + @gateway.purchase(@amount, @emv_credit_card, @options) + end.check_request do |method, endpoint, data, headers| + assert_match(/card\[processing_method\]=quick_chip/, data) + end.respond_with(successful_purchase_response) + end + + def test_quickchip_is_not_set_on_authorize + stub_comms(@gateway, :ssl_request) do + @emv_credit_card.read_method = 'contact_quickchip' + @gateway.authorize(@amount, @emv_credit_card, @options) + end.check_request do |method, endpoint, data, headers| + refute_match(/card\[processing_method\]=quick_chip/, data) end.respond_with(successful_purchase_response) end @@ -1016,9 +1064,9 @@ def test_address_is_included_with_card_data end.respond_with(successful_purchase_response) end - def test_contactless_emv_flag_is_included_with_emv_card_data + def test_contactless_flag_is_included_with_emv_card_data stub_comms(@gateway, :ssl_request) do - @emv_credit_card.contactless_emv = true + @emv_credit_card.read_method = 'contactless' @gateway.purchase(@amount, @emv_credit_card, @options) end.check_request do |method, endpoint, data, headers| data =~ /card\[read_method\]=contactless/ @@ -1027,7 +1075,7 @@ def test_contactless_emv_flag_is_included_with_emv_card_data def test_contactless_magstripe_flag_is_included_with_emv_card_data stub_comms(@gateway, :ssl_request) do - @emv_credit_card.contactless_magstripe = true + @emv_credit_card.read_method = 'contactless_magstripe' @gateway.purchase(@amount, @emv_credit_card, @options) end.check_request do |method, endpoint, data, headers| data =~ /card\[read_method\]=contactless_magstripe_mode/ @@ -1286,7 +1334,7 @@ def test_verify_bad_credentials # this mock is only useful with unit tests, as cryptograms generated by an EMV terminal # are specific to the target acquirer, so remote tests using this mock will fail elsewhere. def credit_card_with_icc_data - ActiveMerchant::Billing::CreditCard.new(icc_data: '500B56495341204352454449545F201A56495341204143515549524552205445535420434152442030315F24031512315F280208405F2A0208265F300202015F34010182025C008407A0000000031010950502000080009A031408259B02E8009C01009F02060000000734499F03060000000000009F0607A00000000310109F0902008C9F100706010A03A080009F120F4352454449544F20444520564953419F1A0208269F1C0831373030303437309F1E0831373030303437309F2608EB2EC0F472BEA0A49F2701809F3303E0B8C89F34031E03009F3501229F360200C39F37040A27296F9F4104000001319F4502DAC5DFAE5711476173FFFFFF0119D15122011758989389DFAE5A08476173FFFFFF011957114761739001010119D151220117589893895A084761739001010119') + ActiveMerchant::Billing::CreditCard.new(read_method: 'contact', icc_data: '500B56495341204352454449545F201A56495341204143515549524552205445535420434152442030315F24031512315F280208405F2A0208265F300202015F34010182025C008407A0000000031010950502000080009A031408259B02E8009C01009F02060000000734499F03060000000000009F0607A00000000310109F0902008C9F100706010A03A080009F120F4352454449544F20444520564953419F1A0208269F1C0831373030303437309F1E0831373030303437309F2608EB2EC0F472BEA0A49F2701809F3303E0B8C89F34031E03009F3501229F360200C39F37040A27296F9F4104000001319F4502DAC5DFAE5711476173FFFFFF0119D15122011758989389DFAE5A08476173FFFFFF011957114761739001010119D151220117589893895A084761739001010119') end def pre_scrubbed From 51dc1bab330ac70e23fb44571b787de4ae796f60 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Wed, 3 Jan 2018 16:35:13 -0500 Subject: [PATCH 278/677] Data Cash: add Transcript scrubbing support Unit: 14 tests, 34 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 29 tests, 90 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- .../billing/gateways/data_cash.rb | 10 +++ test/remote/gateways/remote_data_cash_test.rb | 10 +++ test/unit/gateways/data_cash_test.rb | 65 +++++++++++++++++++ 3 files changed, 85 insertions(+) diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb index 64404b10912..6a23e86d009 100644 --- a/lib/active_merchant/billing/gateways/data_cash.rb +++ b/lib/active_merchant/billing/gateways/data_cash.rb @@ -77,6 +77,16 @@ def refund(money, reference, options = {}) commit(build_transaction_refund_request(money, reference)) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(/()\d+(<\/pan>)/i, '\1[FILTERED]\2'). + gsub(/()\d+(<\/cv2>)/i, '\1[FILTERED]\2'). + gsub(/().+(<\/password>)/i, '\1[FILTERED]\2') + end private diff --git a/test/remote/gateways/remote_data_cash_test.rb b/test/remote/gateways/remote_data_cash_test.rb index e14abdcebf4..9ff6635e5f9 100644 --- a/test/remote/gateways/remote_data_cash_test.rb +++ b/test/remote/gateways/remote_data_cash_test.rb @@ -332,4 +332,14 @@ def test_order_id_that_is_too_long assert response.test? end + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @visa_delta, @params) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@visa_delta.number, transcript) + assert_scrubbed(@visa_delta.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end end diff --git a/test/unit/gateways/data_cash_test.rb b/test/unit/gateways/data_cash_test.rb index 066b567ed0c..ad933feb72a 100644 --- a/test/unit/gateways/data_cash_test.rb +++ b/test/unit/gateways/data_cash_test.rb @@ -188,4 +188,69 @@ def successful_purchase_using_continuous_authority_response XML end + + def test_transcript_scrubbing + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrub), post_scrub + 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 \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 \n\n\n" +read 1369 bytes +reading 2 bytes... +-> "" +-> "\r\n" +read 2 bytes +-> "0\r\n" +-> "\r\n" +Conn close +SCRUBBED + end end From 25dfcdfec2dae8064995de21c37d5ec1e0597637 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Wed, 3 Jan 2018 17:30:06 -0500 Subject: [PATCH 279/677] Elavon: add transcript scrubbing Unit: 29 tests, 141 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 24 tests, 105 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- .../billing/gateways/elavon.rb | 11 +++ test/remote/gateways/remote_elavon_test.rb | 12 +++ test/unit/gateways/elavon_test.rb | 80 +++++++++++++++++++ 3 files changed, 103 insertions(+) diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb index 248da8df7d5..2e160ed9343 100644 --- a/lib/active_merchant/billing/gateways/elavon.rb +++ b/lib/active_merchant/billing/gateways/elavon.rb @@ -136,6 +136,17 @@ def update(token, creditcard, options = {}) commit(:update, nil, form, options) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((&?ssl_pin=)[^&]*)i, '\1[FILTERED]'). + gsub(%r((&?ssl_card_number=)[^&\\n\r\n]*)i, '\1[FILTERED]'). + gsub(%r((&?ssl_cvv2cvc2=)[^&]*)i, '\1[FILTERED]') + end + private def add_invoice(form,options) diff --git a/test/remote/gateways/remote_elavon_test.rb b/test/remote/gateways/remote_elavon_test.rb index 765459f7c14..866fcd21eb6 100644 --- a/test/remote/gateways/remote_elavon_test.rb +++ b/test/remote/gateways/remote_elavon_test.rb @@ -204,4 +204,16 @@ def test_successful_purchase_with_custom_fields assert_equal 'APPROVAL', response.message assert response.authorization end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end + end diff --git a/test/unit/gateways/elavon_test.rb b/test/unit/gateways/elavon_test.rb index 8d0164aeded..48667573b57 100644 --- a/test/unit/gateways/elavon_test.rb +++ b/test/unit/gateways/elavon_test.rb @@ -275,7 +275,13 @@ def test_custom_fields_in_request end.respond_with(successful_purchase_response) end + def test_transcript_scrubbing + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrub), post_scrub + end + private + def successful_purchase_response "ssl_card_number=42********4242 ssl_exp_date=0910 @@ -461,4 +467,78 @@ def failed_update_response errorName=Credit Card Number Invalid errorMessage=The Credit Card Number supplied in the authorization request appears to be invalid." end + + def pre_scrub + %q{ +opening connection to api.demo.convergepay.com:443... +opened +starting SSL for api.demo.convergepay.com:443... +SSL established +<- "POST /VirtualMerchantDemo/process.do 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: api.demo.convergepay.com\r\nContent-Length: 616\r\n\r\n" +<- "ssl_merchant_id=000127&ssl_pin=IERAOBEE5V0D6Q3Q6R51TG89XAIVGEQ3LGLKMKCKCVQBGGGAU7FN627GPA54P5HR&ssl_show_form=false&ssl_result_format=ASCII&ssl_user_id=ssltest&ssl_invoice_number=&ssl_description=Test+Transaction&ssl_card_number=4124939999999990&ssl_exp_date=0919&ssl_cvv2cvc2=123&ssl_cvv2cvc2_indicator=1&ssl_first_name=Longbob&ssl_last_name=Longsen&ssl_avs_address=456+My+Street&ssl_address2=Apt+1&ssl_avs_zip=K1C2N6&ssl_city=Ottawa&ssl_state=ON&ssl_company=Widgets+Inc&ssl_phone=%28555%29555-5555&ssl_country=CA&ssl_email=paul%40domain.com&ssl_cardholder_ip=203.0.113.0&ssl_amount=1.00&ssl_transaction_type=CCSALE" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Wed, 03 Jan 2018 21:40:26 GMT\r\n" +-> "Pragma: no-cache\r\n" +-> "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n" +-> "Expires: 0\r\n" +-> "Content-Disposition: inline; filename=response.txt\r\n" +-> "AuthApproved: true\r\n" +-> "AuthResponse: AA\r\n" +-> "Set-Cookie: JSESSIONID=00007wKfJV3-JFME8QiC_RCDjuI:14j4qkv92; HTTPOnly; Path=/; Secure\r\n" +-> "Set-Cookie: JSESSIONID=0000uW6woWZ84eAJunhFLfJz8hS:14j4qkv92; HTTPOnly; Path=/; Secure\r\n" +-> "Connection: close\r\n" +-> "Content-Type: text/plain\r\n" +-> "Content-Language: en-US\r\n" +-> "Content-Encoding: gzip\r\n" +-> "Transfer-Encoding: chunked\r\n" +-> "\r\n" +-> "1A5 \r\n" +reading 421 bytes... +-> "\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x03MR\xEFk\xDB0\x10\xFD\xDE\xBF\xC2\x1F\xB7\x81[\xC9\xB1\x1D\xBB \x98\x7FtP\xD66!+\xDBGs\xB1o\x99\xC0\x96\x84%{q\xFF\xFA\xC9R\x12f\x10\xDC\xBDw\xBEw\xEF8\xAD\xFB\xA6\x85\xB1k\xC44\x1Cqd1\xFDr\xFB\xF2<'w\xDA\x16\xE0Y5\x1D\x18d$\xA7\xB9C`\x90\x930\x8C\xDE\x13_\xA1\xA1Gm\xE0\xCC\\\xC6\xC5,y\x8B\xD7\x9E\x0E\x130\xA0\x8FV9\x1Fu\xA8`4\xD3\x88\xBE\xFB\xDD;WM\xE1;\xFBJ9\xA8\x1E\r\x97\xE2Rp\x05A,\xEC\x17\xEFNht\xF0,Z\x87\xFF\xE6\xA36^\xE6E\x8A\xD3Q\x1E\x1D\xDC\xC3\xFF\xA8F\xE1P\x98u\x03]7\xA2\xD6,N\xD2\xE0u\t~\x98\x11\xD1x\xD63\x11+\x94\t\xA8W\xE5fa;c\xE0/\xB8\xDC\x9A\xB5\x03\xED\xDEn\xDD>\xB8b\xDFi\x15\xBD\xA5\xBE~u1.\xAC*\\\xAA\xFEH\x81\xECS\x92$\x9F\xED\v\xEDK\x1C\x8E\x03\xF0\x9E)\x98\xFA\xAF\x9D\xB4\xB1\xB8\xB7\xF6\x1Cc\a\x98z\xC3\xFCz}\xD2\fv(8!+\xF6\xFB\xC3\xEEg\xF1\xE28s\x16\r\xEF\x18\xD9\x10J\xB3\x82&!\xA9\xD3:O\xF3*|\x8A\xEA2\x8C\xB34\t\xB3o\xDB$,\xD3\xA2,\xB3tC\xB7E\xE9\xFE\x04\xA5F9\xC3:l\x87,\xDEnI\x1C9\xA2\x9D\xE7h\xD5TR\xE8\xCB\xD6W\x8B7\xE4\xE2\xBAu&\x9B#\xF4 Z{\x1C\xD7cX'2\xDCn\x9C\xD0\a\xB2y\x88\b\xCD\x02\x12?\xC6\xE41\xDA\x06\xFBW/\xB1\xDE\x9CY\x14\xB2\xEA\xF0T?\xBFW\xC5\xA1\xFE\aC\x85\x1DS\x8C\x02\x00\x00" +read 421 bytes +reading 2 bytes... +-> "\r\n" +read 2 bytes +-> "0\r\n" +-> "\r\n" +Conn close +}} + end + + def post_scrub + %q{ +opening connection to api.demo.convergepay.com:443... +opened +starting SSL for api.demo.convergepay.com:443... +SSL established +<- "POST /VirtualMerchantDemo/process.do 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: api.demo.convergepay.com\r\nContent-Length: 616\r\n\r\n" +<- "ssl_merchant_id=000127&ssl_pin=[FILTERED]&ssl_show_form=false&ssl_result_format=ASCII&ssl_user_id=ssltest&ssl_invoice_number=&ssl_description=Test+Transaction&ssl_card_number=[FILTERED]&ssl_exp_date=0919&ssl_cvv2cvc2=[FILTERED]&ssl_cvv2cvc2_indicator=1&ssl_first_name=Longbob&ssl_last_name=Longsen&ssl_avs_address=456+My+Street&ssl_address2=Apt+1&ssl_avs_zip=K1C2N6&ssl_city=Ottawa&ssl_state=ON&ssl_company=Widgets+Inc&ssl_phone=%28555%29555-5555&ssl_country=CA&ssl_email=paul%40domain.com&ssl_cardholder_ip=203.0.113.0&ssl_amount=1.00&ssl_transaction_type=CCSALE" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Wed, 03 Jan 2018 21:40:26 GMT\r\n" +-> "Pragma: no-cache\r\n" +-> "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n" +-> "Expires: 0\r\n" +-> "Content-Disposition: inline; filename=response.txt\r\n" +-> "AuthApproved: true\r\n" +-> "AuthResponse: AA\r\n" +-> "Set-Cookie: JSESSIONID=00007wKfJV3-JFME8QiC_RCDjuI:14j4qkv92; HTTPOnly; Path=/; Secure\r\n" +-> "Set-Cookie: JSESSIONID=0000uW6woWZ84eAJunhFLfJz8hS:14j4qkv92; HTTPOnly; Path=/; Secure\r\n" +-> "Connection: close\r\n" +-> "Content-Type: text/plain\r\n" +-> "Content-Language: en-US\r\n" +-> "Content-Encoding: gzip\r\n" +-> "Transfer-Encoding: chunked\r\n" +-> "\r\n" +-> "1A5 \r\n" +reading 421 bytes... +-> "\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x03MR\xEFk\xDB0\x10\xFD\xDE\xBF\xC2\x1F\xB7\x81[\xC9\xB1\x1D\xBB \x98\x7FtP\xD66!+\xDBGs\xB1o\x99\xC0\x96\x84%{q\xFF\xFA\xC9R\x12f\x10\xDC\xBDw\xBEw\xEF8\xAD\xFB\xA6\x85\xB1k\xC44\x1Cqd1\xFDr\xFB\xF2<'w\xDA\x16\xE0Y5\x1D\x18d$\xA7\xB9C`\x90\x930\x8C\xDE\x13_\xA1\xA1Gm\xE0\xCC\\\xC6\xC5,y\x8B\xD7\x9E\x0E\x130\xA0\x8FV9\x1Fu\xA8`4\xD3\x88\xBE\xFB\xDD;WM\xE1;\xFBJ9\xA8\x1E\r\x97\xE2Rp\x05A,\xEC\x17\xEFNht\xF0,Z\x87\xFF\xE6\xA36^\xE6E\x8A\xD3Q\x1E\x1D\xDC\xC3\xFF\xA8F\xE1P\x98u\x03]7\xA2\xD6,N\xD2\xE0u\t~\x98\x11\xD1x\xD63\x11+\x94\t\xA8W\xE5fa;c\xE0/\xB8\xDC\x9A\xB5\x03\xED\xDEn\xDD>\xB8b\xDFi\x15\xBD\xA5\xBE~u1.\xAC*\\\xAA\xFEH\x81\xECS\x92$\x9F\xED\v\xEDK\x1C\x8E\x03\xF0\x9E)\x98\xFA\xAF\x9D\xB4\xB1\xB8\xB7\xF6\x1Cc\a\x98z\xC3\xFCz}\xD2\fv(8!+\xF6\xFB\xC3\xEEg\xF1\xE28s\x16\r\xEF\x18\xD9\x10J\xB3\x82&!\xA9\xD3:O\xF3*|\x8A\xEA2\x8C\xB34\t\xB3o\xDB$,\xD3\xA2,\xB3tC\xB7E\xE9\xFE\x04\xA5F9\xC3:l\x87,\xDEnI\x1C9\xA2\x9D\xE7h\xD5TR\xE8\xCB\xD6W\x8B7\xE4\xE2\xBAu&\x9B#\xF4 Z{\x1C\xD7cX'2\xDCn\x9C\xD0\a\xB2y\x88\b\xCD\x02\x12?\xC6\xE41\xDA\x06\xFBW/\xB1\xDE\x9CY\x14\xB2\xEA\xF0T?\xBFW\xC5\xA1\xFE\aC\x85\x1DS\x8C\x02\x00\x00" +read 421 bytes +reading 2 bytes... +-> "\r\n" +read 2 bytes +-> "0\r\n" +-> "\r\n" +Conn close +}} + end end From bac41ddbb9695a745c514af184f2d21d83454dde Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Thu, 4 Jan 2018 11:31:26 -0500 Subject: [PATCH 280/677] FirstData E4: improve scrubbing, add remote test Three remote tests fail, all involving what I believe are enhancements to how specified currency is handled. None are impacted by this change, and fixing them is beyond the scope of this change. Unit: 33 tests, 158 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 26 tests, 97 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 88.4615% passed --- .../billing/gateways/firstdata_e4.rb | 2 ++ test/remote/gateways/remote_firstdata_e4_test.rb | 13 +++++++++++-- test/unit/gateways/firstdata_e4_test.rb | 13 +++++-------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index 44b01586377..2644ecb53b1 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -144,7 +144,9 @@ def scrub(transcript) transcript .gsub(%r(().+()), '\1[FILTERED]\2') .gsub(%r(().+()), '\1[FILTERED]\2') + .gsub(%r(().+())i, '\1[FILTERED]\2') .gsub(%r(().+()), '\1[FILTERED]\2') + .gsub(%r((Card Number : ).*\d)i, '\1[FILTERED]') end def supports_network_tokenization? diff --git a/test/remote/gateways/remote_firstdata_e4_test.rb b/test/remote/gateways/remote_firstdata_e4_test.rb index ffcadb90518..51e1bf6af58 100755 --- a/test/remote/gateways/remote_firstdata_e4_test.rb +++ b/test/remote/gateways/remote_firstdata_e4_test.rb @@ -237,7 +237,16 @@ def test_verify_credentials assert !gateway.verify_credentials end - def test_dump_transcript - # See firstdata_e4_test.rb for an example of a scrubbed transcript + def test_transcript_scrubbing + cc_with_different_cvc = credit_card(verification_value: '999') + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, cc_with_different_cvc, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(cc_with_different_cvc.number, transcript) + assert_scrubbed(cc_with_different_cvc.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) end + end diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb index 45dfd718e49..284e2e952a8 100755 --- a/test/unit/gateways/firstdata_e4_test.rb +++ b/test/unit/gateways/firstdata_e4_test.rb @@ -315,12 +315,9 @@ def test_add_swipe_data_with_creditcard end.respond_with(successful_purchase_response) end - def test_supports_scrubbing? + def test_transcript_scrubbing assert @gateway.supports_scrubbing? - end - - def test_scrub - assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + assert_equal @gateway.scrub(pre_scrub), post_scrub end def test_supports_network_tokenization @@ -336,7 +333,7 @@ def assert_xml_valid_to_wsdl(data) assert_empty errors, "XSD validation errors in the following XML:\n#{doc}" end - def pre_scrubbed + def pre_scrub <<-PRE_SCRUBBED opening connection to api.demo.globalgatewaye4.firstdata.com:443... opened @@ -366,14 +363,14 @@ def pre_scrubbed PRE_SCRUBBED end - def post_scrubbed + def post_scrub <<-POST_SCRUBBED opening connection to api.demo.globalgatewaye4.firstdata.com:443... opened starting SSL for api.demo.globalgatewaye4.firstdata.com:443... SSL established <- "POST /transaction/v11 HTTP/1.1\r\nContent-Type: application/xml\r\nAccepts: application/xml\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.demo.globalgatewaye4.firstdata.com\r\nContent-Length: 593\r\n\r\n" - <- "REDACTEDREDACTED001.00[FILTERED]0916Longbob LongsenVisa1234 My Street|K1C2N6|Ottawa|ON|CA1[FILTERED]1Store Purchase[FILTERED]" + <- "REDACTED[FILTERED]001.00[FILTERED]0916Longbob LongsenVisa1234 My Street|K1C2N6|Ottawa|ON|CA1[FILTERED]1Store Purchase[FILTERED]" -> "HTTP/1.1 201 Created\r\n" -> "Cache-Control: max-age=0, private, must-revalidate\r\n" -> "Content-Type: application/xml; charset=utf-8\r\n" From 9fc79e25e39d6c41dbb96b320980309d86941684 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Mon, 8 Jan 2018 11:10:24 -0500 Subject: [PATCH 281/677] Global Transport: add transcript scrubbing Unit: 5 tests, 75 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 16 tests, 48 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- .../billing/gateways/global_transport.rb | 11 ++++ .../gateways/remote_global_transport_test.rb | 12 ++++ test/unit/gateways/global_transport_test.rb | 63 +++++++++++++++++++ 3 files changed, 86 insertions(+) diff --git a/lib/active_merchant/billing/gateways/global_transport.rb b/lib/active_merchant/billing/gateways/global_transport.rb index 3db9092cd26..865551d2382 100644 --- a/lib/active_merchant/billing/gateways/global_transport.rb +++ b/lib/active_merchant/billing/gateways/global_transport.rb @@ -75,6 +75,17 @@ def verify(payment_method, options={}) commit('CardVerify', post, options) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((&?CardNum=)[^&]*)i, '\1[FILTERED]'). + gsub(%r((&?CVNum=)[^&]*)i, '\1[FILTERED]'). + gsub(%r((&?GlobalPassword=)[^&]*)i, '\1[FILTERED]') + end + private def add_address(post, options) diff --git a/test/remote/gateways/remote_global_transport_test.rb b/test/remote/gateways/remote_global_transport_test.rb index 94afca9b67a..da308566248 100644 --- a/test/remote/gateways/remote_global_transport_test.rb +++ b/test/remote/gateways/remote_global_transport_test.rb @@ -126,4 +126,16 @@ def test_invalid_login assert_failure response assert_equal("Invalid Login Information", response.message) end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(500, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:global_password], transcript) + end + end diff --git a/test/unit/gateways/global_transport_test.rb b/test/unit/gateways/global_transport_test.rb index 878ef975ab0..bce3e7e4d28 100644 --- a/test/unit/gateways/global_transport_test.rb +++ b/test/unit/gateways/global_transport_test.rb @@ -167,6 +167,11 @@ def test_truncation end.respond_with(successful_purchase_response) end + def test_transcript_scrubbing + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrub), post_scrub + end + private def successful_purchase_response @@ -410,4 +415,62 @@ def failed_verify_response ) end + + def pre_scrub + %q{ +opening connection to certapia.globalpay.com:443... +opened +starting SSL for certapia.globalpay.com:443... +SSL established +<- "POST /GlobalPay/transact.asmx/ProcessCreditCard 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: certapia.globalpay.com\r\nContent-Length: 253\r\n\r\n" +<- "CardNum=4003002345678903&ExpDate=0919&NameOnCard=Longbob+Longsen&Amount=&PNRef=&Zip=K1C2N6&Street=456+My+Street&CVNum=123&MagData=&InvNum=1&ExtData=%3CTermType%3E1BJ%3C%2FTermType%3E&GlobalUserName=spre930948&GlobalPassword=AoaeYX2n3Y7wfr&TransType=Sale" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Mon, 08 Jan 2018 16:00:33 GMT\r\n" +-> "Content-Type: text/xml; charset=utf-8\r\n" +-> "Content-Length: 559\r\n" +-> "Connection: close\r\n" +-> "Cache-Control: private, no-store, max-age=0\r\n" +-> "Pragma: no-cache\r\n" +-> "X-Frame-Options: SAMEORIGIN\r\n" +-> "Set-Cookie: ASP.NET_SessionId=tawdjune2xixlighniqxcvkm; path=/; HttpOnly\r\n" +-> "X-AspNet-Version: 4.0.30319\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "Set-Cookie: TS012462a7=01cf83bd2f409aa8ee6c4cacb355788019f1a8ff3010306e6b8fe1c42e01745058ecc78aeff78d5071c2b7c56c186a470efd7c78f1; Path=/; Secure\r\n" +-> "Set-Cookie: TS012462a7_28=013b80ac89ca00c8b688533fc64e6f7b3fa3424b483ef82651a9f9a1c184ec131cc099732b39bf84f703f9f0754d2a12a53fe3d537; Path=/; Secure\r\n" +-> "\r\n" +reading 559 bytes... +-> "\r\n\r\n 12\r\n Declined\r\n INVLD AMOUNT\r\n 9169188\r\n Service Not Requested\r\n False\r\n InvNum=1,CardType=Visa<ReceiptData><MID>332518545311149</MID></ReceiptData>\r\n aY\r\n" +read 559 bytes +Conn close + } + end + + def post_scrub + %q{ +opening connection to certapia.globalpay.com:443... +opened +starting SSL for certapia.globalpay.com:443... +SSL established +<- "POST /GlobalPay/transact.asmx/ProcessCreditCard 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: certapia.globalpay.com\r\nContent-Length: 253\r\n\r\n" +<- "CardNum=[FILTERED]&ExpDate=0919&NameOnCard=Longbob+Longsen&Amount=&PNRef=&Zip=K1C2N6&Street=456+My+Street&CVNum=[FILTERED]&MagData=&InvNum=1&ExtData=%3CTermType%3E1BJ%3C%2FTermType%3E&GlobalUserName=spre930948&GlobalPassword=[FILTERED]&TransType=Sale" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Mon, 08 Jan 2018 16:00:33 GMT\r\n" +-> "Content-Type: text/xml; charset=utf-8\r\n" +-> "Content-Length: 559\r\n" +-> "Connection: close\r\n" +-> "Cache-Control: private, no-store, max-age=0\r\n" +-> "Pragma: no-cache\r\n" +-> "X-Frame-Options: SAMEORIGIN\r\n" +-> "Set-Cookie: ASP.NET_SessionId=tawdjune2xixlighniqxcvkm; path=/; HttpOnly\r\n" +-> "X-AspNet-Version: 4.0.30319\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "Set-Cookie: TS012462a7=01cf83bd2f409aa8ee6c4cacb355788019f1a8ff3010306e6b8fe1c42e01745058ecc78aeff78d5071c2b7c56c186a470efd7c78f1; Path=/; Secure\r\n" +-> "Set-Cookie: TS012462a7_28=013b80ac89ca00c8b688533fc64e6f7b3fa3424b483ef82651a9f9a1c184ec131cc099732b39bf84f703f9f0754d2a12a53fe3d537; Path=/; Secure\r\n" +-> "\r\n" +reading 559 bytes... +-> "\r\n\r\n 12\r\n Declined\r\n INVLD AMOUNT\r\n 9169188\r\n Service Not Requested\r\n False\r\n InvNum=1,CardType=Visa<ReceiptData><MID>332518545311149</MID></ReceiptData>\r\n aY\r\n" +read 559 bytes +Conn close + } + end end From 97ddd115fecdaa566ed442a71af17efdc0d1efee Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Mon, 8 Jan 2018 13:11:32 -0500 Subject: [PATCH 282/677] HPS: Add scrubbing support Unit: 21 tests, 60 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 30 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/hps.rb | 13 ++++- test/remote/gateways/remote_hps_test.rb | 11 ++++ test/unit/gateways/hps_test.rb | 65 +++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/hps.rb b/lib/active_merchant/billing/gateways/hps.rb index a6e79e8534f..6bd1141e9d8 100644 --- a/lib/active_merchant/billing/gateways/hps.rb +++ b/lib/active_merchant/billing/gateways/hps.rb @@ -73,6 +73,17 @@ def void(transaction_id, options={}) end end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r(()[^<]*(<\/hps:CardNbr>))i, '\1[FILTERED]\2'). + gsub(%r(()[^<]*(<\/hps:CVV2>))i, '\1[FILTERED]\2'). + gsub(%r(()[^<]*(<\/hps:SecretAPIKey>))i, '\1[FILTERED]\2') + end + private def add_reference(xml, transaction_id) @@ -218,7 +229,7 @@ def commit(action, &request) data = build_request(action, &request) response = begin - parse(ssl_post((test? ? test_url : live_url), data, 'Content-type' => 'text/xml')) + parse(ssl_post((test? ? test_url : live_url), data, 'Content-Type' => 'text/xml')) rescue ResponseError => e parse(e.response.body) end diff --git a/test/remote/gateways/remote_hps_test.rb b/test/remote/gateways/remote_hps_test.rb index 132f3b7be61..4c183b092ef 100644 --- a/test/remote/gateways/remote_hps_test.rb +++ b/test/remote/gateways/remote_hps_test.rb @@ -250,4 +250,15 @@ def tests_failed_verify assert_failure response assert_equal 'The card number is not a valid credit card number.', response.message end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:secret_api_key], transcript) + end end diff --git a/test/unit/gateways/hps_test.rb b/test/unit/gateways/hps_test.rb index 3f964d51ec7..02112f260f3 100644 --- a/test/unit/gateways/hps_test.rb +++ b/test/unit/gateways/hps_test.rb @@ -190,6 +190,11 @@ def test_test_returns_false assert_false @gateway.send(:test?) end + def test_transcript_scrubbing + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrub), post_scrub + end + private def successful_charge_response @@ -604,4 +609,64 @@ def failed_verify_response RESPONSE end + def pre_scrub + %q{ +opening connection to posgateway.cert.secureexchange.net:443... +opened +starting SSL for posgateway.cert.secureexchange.net:443... +SSL established +<- "POST /Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl HTTP/1.1\r\nContent-Type: text/xml\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: posgateway.cert.secureexchange.net\r\nContent-Length: 1295\r\n\r\n" +<- "skapi_cert_MYl2AQAowiQAbLp5JesGKh7QFkcizOP2jcX9BrEMqQ1.00YLongbobLongsen456 My StreetOttawaONK1C2N6Store Purchase1400010001111222492019123NNN" +-> "HTTP/1.1 200 OK\r\n" +-> "Cache-Control: private, max-age=0\r\n" +-> "Content-Type: text/xml; charset=utf-8\r\n" +-> "Server: Microsoft-IIS/7.5\r\n" +-> "X-dynaTrace: PT=266421;PA=-1324159421;SP=Gateway Cert;PS=1926692524\r\n" +-> "dynaTrace: PT=266421;PA=-1324159421;SP=Gateway Cert;PS=1926692524\r\n" +-> "X-AspNet-Version: 4.0.30319\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "X-Frame-Options: DENY\r\n" +-> "X-Content-Type-Options: nosniff\r\n" +-> "Date: Mon, 08 Jan 2018 16:28:18 GMT\r\n" +-> "Connection: close\r\n" +-> "Content-Length: 1067\r\n" +-> "\r\n" +reading 1067 bytes... +-> "
9587895881240900010359677660Success2018-01-08T10:28:18.5555936
00APPROVAL64349A0M800818231451 "on>ACCEPTACCEPTVisaAVS Not Requested.Match.
" +read 1067 bytes +Conn close + } + end + + def post_scrub + %q{ +opening connection to posgateway.cert.secureexchange.net:443... +opened +starting SSL for posgateway.cert.secureexchange.net:443... +SSL established +<- "POST /Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl HTTP/1.1\r\nContent-Type: text/xml\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: posgateway.cert.secureexchange.net\r\nContent-Length: 1295\r\n\r\n" +<- "[FILTERED]1.00YLongbobLongsen456 My StreetOttawaONK1C2N6Store Purchase1[FILTERED]92019[FILTERED]NNN" +-> "HTTP/1.1 200 OK\r\n" +-> "Cache-Control: private, max-age=0\r\n" +-> "Content-Type: text/xml; charset=utf-8\r\n" +-> "Server: Microsoft-IIS/7.5\r\n" +-> "X-dynaTrace: PT=266421;PA=-1324159421;SP=Gateway Cert;PS=1926692524\r\n" +-> "dynaTrace: PT=266421;PA=-1324159421;SP=Gateway Cert;PS=1926692524\r\n" +-> "X-AspNet-Version: 4.0.30319\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "X-Frame-Options: DENY\r\n" +-> "X-Content-Type-Options: nosniff\r\n" +-> "Date: Mon, 08 Jan 2018 16:28:18 GMT\r\n" +-> "Connection: close\r\n" +-> "Content-Length: 1067\r\n" +-> "\r\n" +reading 1067 bytes... +-> "
9587895881240900010359677660Success2018-01-08T10:28:18.5555936
00APPROVAL64349A0M800818231451 "on>ACCEPTACCEPTVisaAVS Not Requested.Match.
" +read 1067 bytes +Conn close + } + end + end From 5a9a5e95e00fe0ed86974109fdbccbe83da10a29 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Mon, 8 Jan 2018 13:28:40 -0500 Subject: [PATCH 283/677] Ogone: add tests for scrubbing Five remote tests fail, two involving extended options for purchases, two on storing, and one on credits. None of these are impacted by this patch series, and fixing them is beyond the scope of this series. (The errors appears to be some sort of transient issue with their test card processing.) Unit: 48 tests, 206 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 27 tests, 91 assertions, 5 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications 77.7778% passed --- test/remote/gateways/remote_ogone_test.rb | 11 +++++ test/unit/gateways/ogone_test.rb | 53 +++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/test/remote/gateways/remote_ogone_test.rb b/test/remote/gateways/remote_ogone_test.rb index d5a369ebab6..b5ede03c640 100644 --- a/test/remote/gateways/remote_ogone_test.rb +++ b/test/remote/gateways/remote_ogone_test.rb @@ -239,4 +239,15 @@ def test_invalid_login assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end end diff --git a/test/unit/gateways/ogone_test.rb b/test/unit/gateways/ogone_test.rb index 6bae8080557..f3f241ba32b 100644 --- a/test/unit/gateways/ogone_test.rb +++ b/test/unit/gateways/ogone_test.rb @@ -445,6 +445,11 @@ def test_response_params_is_hash assert_instance_of Hash, response.params end + def test_transcript_scrubbing + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrub), post_scrub + end + private def string_to_digest @@ -754,4 +759,52 @@ def failed_authorization_response END end + def pre_scrub + %q{ +opening connection to secure.ogone.com:443... +opened +starting SSL for secure.ogone.com:443... +SSL established +<- "POST /ncol/test/orderdirect.asp 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.ogone.com\r\nContent-Length: 455\r\n\r\n" +<- "CARDNO=4000100011112224&CN=Longbob+Longsen&COM=Store+Purchase&CVC=123&ECI=7&ED=0919&Operation=SAL&OwnerZip=K1C2N6&Owneraddress=456+My+Street&PSPID=spreedlyinc&PSWD=spreedly1test&SHASign=A67038AB141C6E54C51315F993DC83F5C28A9E585C6C8A79346F802E6557C0C8EE233A5FF1352AAD3C6AA5D476CF49F2B0DF512C63BA624F0583B72C1DCABCEF&USERID=spreedlytest&amount=100¤cy=EUR&orderID=7de271d36c1c36999a6039d99179b2&ownercty=CA&ownertelno=%28555%29555-5555&ownertown=Ottawa" +-> "HTTP/1.1 200 OK\r\n" +-> "Cache-Control: private, max-age=0\r\n" +-> "Content-Length: 152\r\n" +-> "Content-Type: text/XML; Charset=iso-8859-1\r\n" +-> "Expires: Mon, 08 Jan 2018 18:13:04 GMT\r\n" +-> "Strict-Transport-Security: max-age=31536000;includeSubdomains\r\n" +-> "Date: Mon, 08 Jan 2018 18:14:05 GMT\r\n" +-> "Connection: close\r\n" +-> "\r\n" +reading 152 bytes... +-> "\r\n" +read 152 bytes +Conn close + } + end + + def post_scrub + %q{ +opening connection to secure.ogone.com:443... +opened +starting SSL for secure.ogone.com:443... +SSL established +<- "POST /ncol/test/orderdirect.asp 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.ogone.com\r\nContent-Length: 455\r\n\r\n" +<- "CARDNO=[FILTERED]&CN=Longbob+Longsen&COM=Store+Purchase&CVC=[FILTERED]&ECI=7&ED=0919&Operation=SAL&OwnerZip=K1C2N6&Owneraddress=456+My+Street&PSPID=spreedlyinc&PSWD=[FILTERED]&SHASign=A67038AB141C6E54C51315F993DC83F5C28A9E585C6C8A79346F802E6557C0C8EE233A5FF1352AAD3C6AA5D476CF49F2B0DF512C63BA624F0583B72C1DCABCEF&USERID=spreedlytest&amount=100¤cy=EUR&orderID=7de271d36c1c36999a6039d99179b2&ownercty=CA&ownertelno=%28555%29555-5555&ownertown=Ottawa" +-> "HTTP/1.1 200 OK\r\n" +-> "Cache-Control: private, max-age=0\r\n" +-> "Content-Length: 152\r\n" +-> "Content-Type: text/XML; Charset=iso-8859-1\r\n" +-> "Expires: Mon, 08 Jan 2018 18:13:04 GMT\r\n" +-> "Strict-Transport-Security: max-age=31536000;includeSubdomains\r\n" +-> "Date: Mon, 08 Jan 2018 18:14:05 GMT\r\n" +-> "Connection: close\r\n" +-> "\r\n" +reading 152 bytes... +-> "\r\n" +read 152 bytes +Conn close + } + end + end From 5ef97661487dc799e1bfde63f41cc71fac88330f Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Tue, 9 Jan 2018 08:52:28 -0500 Subject: [PATCH 284/677] Update CHANGELOG for new adapter scrubbing Closes #2700 --- CHANGELOG | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index d55cee54705..a231da99aaf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,12 @@ * Clearhaus: add remote scrubbing test [bpollack] #2695 * Borgun: add remote scrubbing test [bpollack] #2695 * Stripe: Added support for the quickchip entry mode option [rbalsdon] +* Ogone: Add tests for scrubbing [bpollack] #2700 +* Global Transport: Add scrubbing support [bpollack] #2700 +* HPS: Add scrubbing support [bpollack] #2700 +* FirstData E4: Improve scrubbing and add remote scrubbing test [bpollack] #2700 +* Elavon: Add scrubbing support [bpollack] #2700 +* Data Cash: Add scrubbing support [bpollack] #2700 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 From 99ceb6600e5657037641f98e3d0e62b4c0380924 Mon Sep 17 00:00:00 2001 From: Wendy Smoak Date: Mon, 11 Dec 2017 12:25:40 -0500 Subject: [PATCH 285/677] Vantiv (Litle): Update sandbox url for testing Previously the URL for live transactions was updated, however the test url wasn't, and it has now stopped working. This updates the sandbox url based on the documentation in https://developer.vantiv.com/docs/DOC-1375 Related to #2502 Closes #2673 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/litle.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a231da99aaf..fadddf654a3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * FirstData E4: Improve scrubbing and add remote scrubbing test [bpollack] #2700 * Elavon: Add scrubbing support [bpollack] #2700 * Data Cash: Add scrubbing support [bpollack] #2700 +* Litle: Fix testing URL [wsmoak] #2673 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index c79cf263399..88eb1a1e4a7 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -5,7 +5,7 @@ module Billing #:nodoc: class LitleGateway < Gateway SCHEMA_VERSION = '9.12' - self.test_url = 'https://www.testlitle.com/sandbox/communicator/online' + self.test_url = 'https://www.testvantivcnp.com/sandbox/communicator/online' self.live_url = 'https://payments.vantivcnp.com/vap/communicator/online' self.supported_countries = ['US'] From fc9e4e4673a1d66f64913a02b85552bfe0d04f06 Mon Sep 17 00:00:00 2001 From: Jon Pascoe Date: Tue, 10 Oct 2017 23:46:49 +0100 Subject: [PATCH 286/677] Add missing Entrust Root CA certificates for Barclays EPDQ Extra Plus gateway Closes #2614 --- CHANGELOG | 1 + lib/certs/cacert.pem | 60 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index fadddf654a3..c31f3006450 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * Elavon: Add scrubbing support [bpollack] #2700 * Data Cash: Add scrubbing support [bpollack] #2700 * Litle: Fix testing URL [wsmoak] #2673 +* Barclays ePDQ Extra Plus: Add missing Entrust root certificates [pacso] #2614 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/certs/cacert.pem b/lib/certs/cacert.pem index 9794dfb70f4..37c56879f45 100644 --- a/lib/certs/cacert.pem +++ b/lib/certs/cacert.pem @@ -501,6 +501,66 @@ W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0 tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8 -----END CERTIFICATE----- +Entrust G2 Root Certificate Authority +===================================== +-----BEGIN CERTIFICATE----- +MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMC +VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50 +cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3Qs +IEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEyMDAGA1UEAxMpRW50cnVz +dCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwHhcNMDkwNzA3MTcy +NTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUVu +dHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwt +dGVybXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0 +aG9yaXplZCB1c2Ugb25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5IC0gRzIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK +AoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP/vaCeb9zYQYKpSfYs1/T +RU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXzHHfV1IWN +cCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hW +wcKUs/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1 +U1+cPvQXLOZprE4yTGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0 +jaWvYkxN4FisZDQSA/i2jZRjJKRxAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAP +BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ60B7vfec7aVHUbI2fkBJmqzAN +BgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5ZiXMRrEPR9RP/ +jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ +Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v +1fN2D807iDginWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4R +nAuknZoh8/CbCzB428Hch0P+vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmH +VHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xOe4pIb4tF9g== +-----END CERTIFICATE----- + +Entrust L1M Chain Root Certificate +================================== +-----BEGIN CERTIFICATE----- +MIIE/zCCA+egAwIBAgIEUdNARDANBgkqhkiG9w0BAQsFADCBsDELMAkGA1UEBhMC +VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0 +Lm5ldC9DUFMgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW +KGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsGA1UEAxMkRW50cnVzdCBSb290IENl +cnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTE0MDkyMjE3MTQ1N1oXDTI0MDkyMzAx +MzE1M1owgb4xCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgw +JgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQL +EzAoYykgMjAwOSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQgdXNlIG9u +bHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0 +eSAtIEcyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuoS2ctueDGvi +mekwAad26jK4lUEaydphTlhyz/72gnm/c2EGCqUn2LNf00VOHHLWTjLycooP94MZ +0GqAgABFHrDH55q/ElcnHKNoLwqHvWprDl5l8xx31dSFjXAhtLMy54ui1YY5ArG4 +0kfO5MlJxDun3vtUfVe+8OhuwnmyOgtV4lCYFjITXC94VsHClLPyWuQnmp8k18bs +0JslguPMwsRFxYyXegZrKhGfqQpuSDtv29QRGUL3jwe/9VNfnD70FyzmaaxOMkxi +d+q36OW7NLwZi66cUee3frVTsTMi5W3PcDwa+uKbZ7aD9I2lr2JMTeBYrGQ0EgP4 +to2UYySkcQIDAQABo4IBDzCCAQswDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQI +MAYBAf8CAQEwMwYIKwYBBQUHAQEEJzAlMCMGCCsGAQUFBzABhhdodHRwOi8vb2Nz +cC5lbnRydXN0Lm5ldDAzBgNVHR8ELDAqMCigJqAkhiJodHRwOi8vY3JsLmVudHJ1 +c3QubmV0L3Jvb3RjYTEuY3JsMDsGA1UdIAQ0MDIwMAYEVR0gADAoMCYGCCsGAQUF +BwIBFhpodHRwOi8vd3d3LmVudHJ1c3QubmV0L0NQUzAdBgNVHQ4EFgQUanImetAe +733nO2lR1GyNn5ASZqswHwYDVR0jBBgwFoAUaJDkZ6SmU4DHhmak8fdLQ/uEvW0w +DQYJKoZIhvcNAQELBQADggEBAGkzg/woem99751V68U+ep11s8zDODbZNKIoaBjq +HmnTvefQd9q4AINOSs9v0fHBIj905PeYSZ6btp7h25h3LVY0sag82f3Azce/BQPU +AsXx5cbaCKUTx2IjEdFhMB1ghEXveajGJpOkt800uGnFE/aRs8lFc3a2kvZ2Clvh +A0e36SlMkTIjN0qcNdh4/R0f5IOJJICtt/nP5F2l1HHEhVtwH9s/HAHrGkUmMRTM +Zb9n3srMM2XlQZHXN75BGpad5oqXnafOrE6aPb0BoGrZTyIAi0TVaWJ7LuvMuueS +fWlnPfy4fN5Bh9Bp6roKGHoalUOzeXEodm2h+1dK7E3IDhA= +-----END CERTIFICATE----- + RSA Security 2048 v3 ==================== -----BEGIN CERTIFICATE----- From 66223368a4abc42c9a5bf3c29fc9f0f32d893c0e Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Mon, 8 Jan 2018 14:25:20 -0500 Subject: [PATCH 287/677] Moneris US: add transcript scrubbing One remote test involving CVV validation fails, but that is not impacted by this patch. Unit: 33 tests, 164 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 25 tests, 91 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 96% passed --- .../billing/gateways/moneris_us.rb | 11 ++++ .../remote/gateways/remote_moneris_us_test.rb | 11 ++++ test/unit/gateways/moneris_us_test.rb | 53 +++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb index 6f1ac826bc7..2986746cfe6 100644 --- a/lib/active_merchant/billing/gateways/moneris_us.rb +++ b/lib/active_merchant/billing/gateways/moneris_us.rb @@ -137,6 +137,17 @@ def update(data_key, credit_card, options = {}) commit('us_res_update_cc', post) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r(()[^<]*())i, '\1[FILTERED]\2'). + gsub(%r(()[^<]*())i, '\1[FILTERED]\2'). + gsub(%r(()[^<]*())i, '\1[FILTERED]\2') + end + private # :nodoc: all def expdate(creditcard) diff --git a/test/remote/gateways/remote_moneris_us_test.rb b/test/remote/gateways/remote_moneris_us_test.rb index 51b75e843e9..602d56f5d5e 100644 --- a/test/remote/gateways/remote_moneris_us_test.rb +++ b/test/remote/gateways/remote_moneris_us_test.rb @@ -203,4 +203,15 @@ def test_avs_result_nil_when_efraud_disabled }) end + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end + end diff --git a/test/unit/gateways/moneris_us_test.rb b/test/unit/gateways/moneris_us_test.rb index f9f997b5d0a..daac3648e0c 100644 --- a/test/unit/gateways/moneris_us_test.rb +++ b/test/unit/gateways/moneris_us_test.rb @@ -312,6 +312,11 @@ def test_customer_not_specified_card_name_used end.respond_with(successful_purchase_response) end + def test_transcript_scrubbing + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrub), post_scrub + end + private def successful_purchase_response @@ -554,4 +559,52 @@ def xml_capture_fixture 'monusqa002qatoken1.01424242424242424203037order1' end + def pre_scrub + %q{ +opening connection to esplusqa.moneris.com:443... +opened +starting SSL for esplusqa.moneris.com:443... +SSL established +<- "POST /gateway_us/servlet/MpgRequest 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: esplusqa.moneris.com\r\nContent-Length: 291\r\n\r\n" +<- "monusqa002qatokencec9ca34132f0945446589e36fff9cceLongbob Longsen1.00424242424242424219097" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Mon, 08 Jan 2018 19:20:26 GMT\r\n" +-> "Content-Length: 659\r\n" +-> "X-UA-Compatible: IE=Edge\r\n" +-> "Connection: close\r\n" +-> "Content-Type: text/html; charset=UTF-8\r\n" +-> "Set-Cookie: TS01d02998=01649737b16d4ca54c296a0a369f4e549e4191e85d8d022d01468e559975e945b419002a42; Path=/\r\n" +-> "Set-Cookie: TS01d02998_28=01e24a44e55591744bc115f421ddccd549b1655d75bda586c8ea625670efaa4432f67c8b7e06e7af82c70ef3ac4f46d7435664f2ac; Path=/\r\n" +-> "\r\n" +reading 659 bytes... +-> "cec9ca34132f0945446589e36fff9cce6400000300136301900010082712513:20:242018-01-0800trueAPPROVED*1.00V113295-0_25falsenullnullfalseA " +read 659 bytes +Conn close + } + end + + def post_scrub + %q{ +opening connection to esplusqa.moneris.com:443... +opened +starting SSL for esplusqa.moneris.com:443... +SSL established +<- "POST /gateway_us/servlet/MpgRequest 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: esplusqa.moneris.com\r\nContent-Length: 291\r\n\r\n" +<- "monusqa002[FILTERED]cec9ca34132f0945446589e36fff9cceLongbob Longsen1.00[FILTERED]19097" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Mon, 08 Jan 2018 19:20:26 GMT\r\n" +-> "Content-Length: 659\r\n" +-> "X-UA-Compatible: IE=Edge\r\n" +-> "Connection: close\r\n" +-> "Content-Type: text/html; charset=UTF-8\r\n" +-> "Set-Cookie: TS01d02998=01649737b16d4ca54c296a0a369f4e549e4191e85d8d022d01468e559975e945b419002a42; Path=/\r\n" +-> "Set-Cookie: TS01d02998_28=01e24a44e55591744bc115f421ddccd549b1655d75bda586c8ea625670efaa4432f67c8b7e06e7af82c70ef3ac4f46d7435664f2ac; Path=/\r\n" +-> "\r\n" +reading 659 bytes... +-> "cec9ca34132f0945446589e36fff9cce6400000300136301900010082712513:20:242018-01-0800trueAPPROVED*1.00V113295-0_25falsenullnullfalseA " +read 659 bytes +Conn close + } + end + end From 4e15f88e27f202447b24f2697f1ee014c2ffbced Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Mon, 8 Jan 2018 15:23:20 -0500 Subject: [PATCH 288/677] Mercury: add transcript scrubbing Note that some remote tests fail. The original cards used for remote tests expired in 2015; while I updated the dates and most tests now pass ,those that that involve credit card track data still fail, since I cannot find documentation on how to generate the LRC for track one (which is where dates are stored). These are not negatively impacted by this patch. Unit: 9 tests, 47 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 20 tests, 61 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 85% passed --- .../billing/gateways/mercury.rb | 15 +- test/remote/gateways/remote_mercury_test.rb | 17 +- test/unit/gateways/mercury_test.rb | 189 +++++++++++------- 3 files changed, 149 insertions(+), 72 deletions(-) diff --git a/lib/active_merchant/billing/gateways/mercury.rb b/lib/active_merchant/billing/gateways/mercury.rb index 7af43962755..bda96b1ab04 100644 --- a/lib/active_merchant/billing/gateways/mercury.rb +++ b/lib/active_merchant/billing/gateways/mercury.rb @@ -81,6 +81,19 @@ def store(credit_card, options={}) commit('CardLookup', request) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r(<), "<"). + gsub(%r(>), ">"). + gsub(%r(().*())i, '\1[FILTERED]\2'). + gsub(%r(()(\d|x)*())i, '\1[FILTERED]\3'). + gsub(%r(()\d*())i, '\1[FILTERED]\2') + end + private def build_non_authorized_request(action, money, credit_card, options) @@ -126,7 +139,7 @@ def build_authorized_request(action, money, authorization, credit_card, options) xml.tag! 'TranInfo' do xml.tag! "AuthCode", auth_code xml.tag! "AcqRefData", acq_ref_data - xml.tag! "ProcessData", process_data + xml.tag! "ProcessData", process_data end end end diff --git a/test/remote/gateways/remote_mercury_test.rb b/test/remote/gateways/remote_mercury_test.rb index 4930ddc2417..b2fb7157cd3 100644 --- a/test/remote/gateways/remote_mercury_test.rb +++ b/test/remote/gateways/remote_mercury_test.rb @@ -9,9 +9,9 @@ def setup @amount = 100 - @credit_card = credit_card("4003000123456781", :brand => "visa", :month => "12", :year => "15") + @credit_card = credit_card("4003000123456781", :brand => "visa", :month => "12", :year => "18") - @track_1_data = "%B4003000123456781^LONGSEN/L. ^15121200000000000000**123******?*" + @track_1_data = "%B4003000123456781^LONGSEN/L. ^18121200000000000000**123******?*" @track_2_data = ";5413330089010608=2512101097750213?" @options = { @@ -210,7 +210,7 @@ def test_authorize_and_capture_without_tokenization assert_success capture assert_equal '1.00', capture.params['authorize'] end - + def test_successful_authorize_and_capture_with_track_1_data @credit_card.track_data = @track_1_data response = @gateway.authorize(100, @credit_card, @options) @@ -241,4 +241,15 @@ def test_authorize_and_void void = @gateway.void(response.authorization) assert_success void end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end end diff --git a/test/unit/gateways/mercury_test.rb b/test/unit/gateways/mercury_test.rb index 5b756f07ee7..fae8efc7143 100644 --- a/test/unit/gateways/mercury_test.rb +++ b/test/unit/gateways/mercury_test.rb @@ -117,91 +117,144 @@ def test_card_present_with_invalid_data assert_success response end + def test_transcript_scrubbing + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrub), post_scrub + end + private def successful_purchase_response <<-RESPONSE -<?xml version="1.0"?> -<RStream> - <CmdResponse> - <ResponseOrigin>Processor</ResponseOrigin> - <DSIXReturnCode>000000</DSIXReturnCode> - <CmdStatus>Approved</CmdStatus> - <TextResponse>AP*</TextResponse> - <UserTraceData></UserTraceData> - </CmdResponse> - <TranResponse> - <MerchantID>595901</MerchantID> - <AcctNo>5499990123456781</AcctNo> - <ExpDate>0813</ExpDate> - <CardType>M/C</CardType> - <TranCode>Sale</TranCode> - <AuthCode>000011</AuthCode> - <CaptureStatus>Captured</CaptureStatus> - <RefNo>0194</RefNo> - <InvoiceNo>1</InvoiceNo> - <AVSResult>Y</AVSResult> - <CVVResult>M</CVVResult> - <OperatorID>999</OperatorID> - <Memo>LM Integration (Ruby)</Memo> - <Amount> - <Purchase>1.00</Purchase> - <Authorize>1.00</Authorize> - </Amount> - <AcqRefData>KbMCC0742510421 </AcqRefData> - <ProcessData>|17|410100700000</ProcessData> - </TranResponse> -</RStream> + + + + Processor + 000000 + Approved + AP* + + + + 595901 + 5499990123456781 + 0813 + M/C + Sale + 000011 + Captured + 0194 + 1 + Y + M + 999 + LM Integration (Ruby) + + 1.00 + 1.00 + + KbMCC0742510421 + |17|410100700000 + + RESPONSE end def failed_purchase_response <<-RESPONSE -<?xml version="1.0"?> -<RStream> - <CmdResponse> - <ResponseOrigin>Server</ResponseOrigin> - <DSIXReturnCode>000000</DSIXReturnCode> - <CmdStatus>Error</CmdStatus> - <TextResponse>No Live Cards on Test Merchant ID Allowed.</TextResponse> - <UserTraceData></UserTraceData> - </CmdResponse> -</RStream> + + + + Server + 000000 + Error + No Live Cards on Test Merchant ID Allowed. + + + RESPONSE end def successful_refund_response <<-RESPONSE -<?xml version="1.0"?> -<RStream> - <CmdResponse> - <ResponseOrigin>Processor</ResponseOrigin> - <DSIXReturnCode>000000</DSIXReturnCode> - <CmdStatus>Approved</CmdStatus> - <TextResponse>AP</TextResponse> - <UserTraceData></UserTraceData> - </CmdResponse> - <TranResponse> - <MerchantID>595901</MerchantID> - <AcctNo>5499990123456781</AcctNo> - <ExpDate>0813</ExpDate> - <CardType>M/C</CardType> - <TranCode>VoidSale</TranCode> - <AuthCode>VOIDED</AuthCode> - <CaptureStatus>Captured</CaptureStatus> - <RefNo>0568</RefNo> - <InvoiceNo>123</InvoiceNo> - <OperatorID>999</OperatorID> - <Amount> - <Purchase>1.00</Purchase> - <Authorize>1.00</Authorize> - </Amount> - <AcqRefData>K</AcqRefData> - </TranResponse> -</RStream> + + + + Processor + 000000 + Approved + AP + + + + 595901 + 5499990123456781 + 0813 + M/C + VoidSale + VOIDED + Captured + 0568 + 123 + 999 + + 1.00 + 1.00 + + K + + RESPONSE end + + def pre_scrub + %q{ +opening connection to w1.mercurycert.net:443... +opened +starting SSL for w1.mercurycert.net:443... +SSL established +<- "POST /ws/ws.asmx HTTP/1.1\r\nContent-Type: text/xml; charset=utf-8\r\nSoapaction: http://www.mercurypay.com/CreditTransaction\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: w1.mercurycert.net\r\nContent-Length: 823\r\n\r\n" +<- "\nCreditSalec111111111.1c111111111.1ActiveMerchantOneTimeRecordNumberRequested0897167417014451.0040030001234567811218VISA123\n]]>\nxyz" +-> "HTTP/1.1 200 OK\r\n" +-> "Cache-Control: private, max-age=0\r\n" +-> "Content-Type: text/xml; charset=utf-8\r\n" +-> "X-AspNet-Version: 4.0.30319\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "Date: Mon, 08 Jan 2018 19:49:31 GMT\r\n" +-> "Connection: close\r\n" +-> "Content-Length: 1648\r\n" +-> "\r\n" +reading 1648 bytes... +-> "\r\n\r\n\t\r\n\t\tProcessor\r\n\t\t000000\r\n\t\tApproved\r\n\t\tAP*\r\n\t\t\r\n\t\r\n\t\r\n\t\t089716741701445\r\n\t\t400300XXXXXX6781\r\n\t\tXXXX\r\n\t\tVISA\r\n\t\tSale\r\n\t\tVI0100\r\n\t\tCaptured\r\n\t\t0001\r\n\t\tC111111111.1\r\n\t\tU\r\n\t\tActiveMerchant\r\n\t\t\r\n\t\t\t1.00\r\n\t\t\t1.00\r\n\t\t\r\n\t\tKaNb018008177003332cABCAd5e00fJlA m000005\r\n\t\twin4rRFHp8+AV/vstAfKvsUvZ5IH+bHblTktfumnY/EiEgUQFyIQGjMM\r\n\t\t|00|600550672000\r\n\t\r\n\r\n" +read 1648 bytes +Conn close + } + end + + def post_scrub + %q{ +opening connection to w1.mercurycert.net:443... +opened +starting SSL for w1.mercurycert.net:443... +SSL established +<- "POST /ws/ws.asmx HTTP/1.1\r\nContent-Type: text/xml; charset=utf-8\r\nSoapaction: http://www.mercurypay.com/CreditTransaction\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: w1.mercurycert.net\r\nContent-Length: 823\r\n\r\n" +<- "\nCreditSalec111111111.1c111111111.1ActiveMerchantOneTimeRecordNumberRequested0897167417014451.00[FILTERED]1218VISA[FILTERED]\n]]>\n[FILTERED]" +-> "HTTP/1.1 200 OK\r\n" +-> "Cache-Control: private, max-age=0\r\n" +-> "Content-Type: text/xml; charset=utf-8\r\n" +-> "X-AspNet-Version: 4.0.30319\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "Date: Mon, 08 Jan 2018 19:49:31 GMT\r\n" +-> "Connection: close\r\n" +-> "Content-Length: 1648\r\n" +-> "\r\n" +reading 1648 bytes... +-> "\r\n\r\n\t\r\n\t\tProcessor\r\n\t\t000000\r\n\t\tApproved\r\n\t\tAP*\r\n\t\t\r\n\t\r\n\t\r\n\t\t089716741701445\r\n\t\t[FILTERED]\r\n\t\tXXXX\r\n\t\tVISA\r\n\t\tSale\r\n\t\tVI0100\r\n\t\tCaptured\r\n\t\t0001\r\n\t\tC111111111.1\r\n\t\tU\r\n\t\tActiveMerchant\r\n\t\t\r\n\t\t\t1.00\r\n\t\t\t1.00\r\n\t\t\r\n\t\tKaNb018008177003332cABCAd5e00fJlA m000005\r\n\t\twin4rRFHp8+AV/vstAfKvsUvZ5IH+bHblTktfumnY/EiEgUQFyIQGjMM\r\n\t\t|00|600550672000\r\n\t\r\n\r\n" +read 1648 bytes +Conn close + } + end end From 44ca048639e5c15ee179b6c2295304fc80474fb2 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Wed, 10 Jan 2018 13:09:31 -0500 Subject: [PATCH 289/677] Add CHANGELOG for scrubbing support Closes #2702 --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index c31f3006450..a67724ca802 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,8 @@ * Data Cash: Add scrubbing support [bpollack] #2700 * Litle: Fix testing URL [wsmoak] #2673 * Barclays ePDQ Extra Plus: Add missing Entrust root certificates [pacso] #2614 +* Moneris US: Add scrubbing support [bpollack] #2702 +* Mercury: Add scrubbing support [bpollack] #2702 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 From c22183391e65985d78df5bb92cbeaa88c83a1935 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Wed, 10 Jan 2018 14:26:23 -0500 Subject: [PATCH 290/677] Fat Zebra: tweak transcript scrubbing regex While the scrubbing as-written in ac0d721e works, it doesn't quite handle all types of transcripts Spreedly throws at it. This commit makes the regex slightly more flexible, without damaging its existing behavior (i.e., no tests had to be changed to handle this regex). Unit: 17 tests, 89 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 19 tests, 68 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 94.7368% passed Closes #2704 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/fat_zebra.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a67724ca802..b4f19c3c019 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,6 +22,7 @@ * Barclays ePDQ Extra Plus: Add missing Entrust root certificates [pacso] #2614 * Moneris US: Add scrubbing support [bpollack] #2702 * Mercury: Add scrubbing support [bpollack] #2702 +* Fat Zebra: Tweak remote scrubbing test [bpollack] #2704 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/gateways/fat_zebra.rb b/lib/active_merchant/billing/gateways/fat_zebra.rb index fadbbaa35c0..c63b0c2d1d5 100644 --- a/lib/active_merchant/billing/gateways/fat_zebra.rb +++ b/lib/active_merchant/billing/gateways/fat_zebra.rb @@ -78,8 +78,8 @@ def supports_scrubbing? def scrub(transcript) transcript. gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). - gsub(%r(("card_number\\":\\")[^"\\]*)i, '\1[FILTERED]'). - gsub(%r(("cvv\\":\\")\d+), '\1[FILTERED]') + gsub(%r(("card_number\\?":\\?")[^"\\]*)i, '\1[FILTERED]'). + gsub(%r(("cvv\\?":\\?")\d+), '\1[FILTERED]') end private From a7535b179b1002aca49b775ba00d91238b076b05 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Thu, 11 Jan 2018 10:04:28 -0500 Subject: [PATCH 291/677] Redsys: fix deprecation warnings scrub tests Redsys was using OpenSSL::Cipher::Cipher, which is deprecated and not required for any supported Ruby versions. While fixing this, I also realized that several of the scrubbing tests were incorrect: they were passing @amount, which was defined. This didn't impact behavior, but meant the scrub tests were scanning scrubs of failed purchase attempts, rather than legitimate ones. This patch defines an @amount so the scrub tests are against successful transactions. Unit: 32 tests, 95 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 18 tests, 54 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/redsys.rb | 2 +- test/remote/gateways/remote_redsys_test.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb index 59fe84a73ce..0867f2fcabd 100644 --- a/lib/active_merchant/billing/gateways/redsys.rb +++ b/lib/active_merchant/billing/gateways/redsys.rb @@ -491,7 +491,7 @@ def sign_request(xml_request_string, order_id) def encrypt(key, order_id) block_length = 8 - cipher = OpenSSL::Cipher::Cipher.new('DES3') + cipher = OpenSSL::Cipher.new('DES3') cipher.encrypt cipher.key = Base64.strict_decode64(key) diff --git a/test/remote/gateways/remote_redsys_test.rb b/test/remote/gateways/remote_redsys_test.rb index 7ecb83a1024..d05e234ae6a 100644 --- a/test/remote/gateways/remote_redsys_test.rb +++ b/test/remote/gateways/remote_redsys_test.rb @@ -9,6 +9,7 @@ def setup order_id: generate_order_id, description: 'Test Description' } + @amount = 100 end def test_successful_purchase From dcb5f3b80b9b7d49b8417ba8e8e95015e4a43474 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Thu, 11 Jan 2018 10:05:33 -0500 Subject: [PATCH 292/677] Fix indentation on two unit tests This changes nothing, but does remove some spurious warnings when running the full unit test suite (e.g., on Travis). Unit: 3762 tests, 67454 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- test/unit/gateways/adyen_test.rb | 2 +- test/unit/gateways/trans_first_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index 11ee8eae8a2..08b2d88ad95 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -53,7 +53,7 @@ def test_successful_capture assert response.test? end -def test_successful_capture_with_compount_psp_reference + def test_successful_capture_with_compount_psp_reference @gateway.expects(:ssl_post).returns(successful_capture_response) response = @gateway.capture(@amount, '7914775043909934#8514775559000000') assert_equal '7914775043909934#8814775564188305', response.authorization diff --git a/test/unit/gateways/trans_first_test.rb b/test/unit/gateways/trans_first_test.rb index 2cfd7cc3b72..25c1ef9545d 100644 --- a/test/unit/gateways/trans_first_test.rb +++ b/test/unit/gateways/trans_first_test.rb @@ -77,7 +77,7 @@ def test_failed_refund response = @gateway.refund(@amount, "TransID") assert_failure response end - + def test_successful_void @gateway.stubs(:ssl_post).returns(successful_void_response) @@ -365,6 +365,6 @@ def failed_void_response Canceled Transaction Is Not Allowed To Void or Refund - XML - end + XML + end end From b8903afbbb798f0ca210904b058b6c64a5e98d5e Mon Sep 17 00:00:00 2001 From: Niaja Date: Thu, 21 Dec 2017 16:34:45 -0500 Subject: [PATCH 293/677] CardConnect: Add new gateway Adds a new gateway card_connect to Active Merchant Loaded suite test/remote/gateways/remote_card_connect_test ................... 19 tests, 45 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/card_connect_test ................ 16 tests, 74 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/card_connect.rb | 286 ++++++++++++++++++ test/fixtures.yml | 6 + .../gateways/remote_card_connect_test.rb | 191 ++++++++++++ test/unit/gateways/card_connect_test.rb | 279 +++++++++++++++++ 5 files changed, 763 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/card_connect.rb create mode 100644 test/remote/gateways/remote_card_connect_test.rb create mode 100644 test/unit/gateways/card_connect_test.rb diff --git a/CHANGELOG b/CHANGELOG index b4f19c3c019..bfffd1289c8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,7 @@ * Moneris US: Add scrubbing support [bpollack] #2702 * Mercury: Add scrubbing support [bpollack] #2702 * Fat Zebra: Tweak remote scrubbing test [bpollack] #2704 +* Card Connect: Add new gateway [nfarve] #2706 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/gateways/card_connect.rb b/lib/active_merchant/billing/gateways/card_connect.rb new file mode 100644 index 00000000000..7fc67262623 --- /dev/null +++ b/lib/active_merchant/billing/gateways/card_connect.rb @@ -0,0 +1,286 @@ +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class CardConnectGateway < Gateway + self.test_url = 'https://fts.cardconnect.com:6443/cardconnect/rest/' + self.live_url = 'https://fts.cardconnect.com:8443/cardconnect/rest/' + + self.supported_countries = ['US'] + self.default_currency = 'USD' + self.supported_cardtypes = [:visa, :master, :american_express, :discover] + + self.homepage_url = 'https://cardconnect.com/' + self.display_name = 'Card Connect' + + STANDARD_ERROR_CODE_MAPPING = { + '11' => STANDARD_ERROR_CODE[:card_declined], + '12' => STANDARD_ERROR_CODE[:incorrect_number], + '13' => STANDARD_ERROR_CODE[:incorrect_cvc], + '14' => STANDARD_ERROR_CODE[:incorrect_cvc], + '15' => STANDARD_ERROR_CODE[:invalid_expiry_date], + '16' => STANDARD_ERROR_CODE[:expired_card], + '17' => STANDARD_ERROR_CODE[:incorrect_zip], + '21' => STANDARD_ERROR_CODE[:config_error], + '22' => STANDARD_ERROR_CODE[:config_error], + '23' => STANDARD_ERROR_CODE[:config_error], + '24' => STANDARD_ERROR_CODE[:processing_error], + '25' => STANDARD_ERROR_CODE[:processing_error], + '27' => STANDARD_ERROR_CODE[:processing_error], + '28' => STANDARD_ERROR_CODE[:processing_error], + '29' => STANDARD_ERROR_CODE[:processing_error], + '31' => STANDARD_ERROR_CODE[:processing_error], + '32' => STANDARD_ERROR_CODE[:processing_error], + '33' => STANDARD_ERROR_CODE[:card_declined], + '34' => STANDARD_ERROR_CODE[:card_declined], + '35' => STANDARD_ERROR_CODE[:incorrect_zip], + '36' => STANDARD_ERROR_CODE[:processing_error], + '37' => STANDARD_ERROR_CODE[:incorrect_cvc], + '41' => STANDARD_ERROR_CODE[:processing_error], + '42' => STANDARD_ERROR_CODE[:processing_error], + '43' => STANDARD_ERROR_CODE[:processing_error], + '44' => STANDARD_ERROR_CODE[:config_error], + '61' => STANDARD_ERROR_CODE[:processing_error], + '62' => STANDARD_ERROR_CODE[:processing_error], + '63' => STANDARD_ERROR_CODE[:processing_error], + '64' => STANDARD_ERROR_CODE[:config_error], + '65' => STANDARD_ERROR_CODE[:processing_error], + '66' => STANDARD_ERROR_CODE[:processing_error], + '91' => STANDARD_ERROR_CODE[:processing_error], + '92' => STANDARD_ERROR_CODE[:processing_error], + '93' => STANDARD_ERROR_CODE[:processing_error], + '94' => STANDARD_ERROR_CODE[:processing_error], + '95' => STANDARD_ERROR_CODE[:config_error], + '96' => STANDARD_ERROR_CODE[:processing_error], + 'NU' => STANDARD_ERROR_CODE[:card_declined], + 'N3' => STANDARD_ERROR_CODE[:card_declined], + 'NJ' => STANDARD_ERROR_CODE[:card_declined], + '51' => STANDARD_ERROR_CODE[:card_declined], + 'C2' => STANDARD_ERROR_CODE[:incorrect_cvc], + '54' => STANDARD_ERROR_CODE[:expired_card], + '05' => STANDARD_ERROR_CODE[:card_declined], + '03' => STANDARD_ERROR_CODE[:config_error], + '60' => STANDARD_ERROR_CODE[:pickup_card] + } + + def initialize(options = {}) + requires!(options, :merchant_id, :username, :password) + require_valid_domain!(options, :domain) + super + end + + def require_valid_domain!(options, param) + if options.key?(param) + raise ArgumentError.new('not a valid cardconnect domain') unless /\Dcardconnect.com:\d{1,}\D/ =~ options[param] + end + end + + def purchase(money, payment, options = {}) + if options[:po_number] + MultiResponse.run do |r| + r.process { authorize(money, payment, options) } + r.process { capture(money, r.authorization, options) } + end + else + post = {} + add_invoice(post, options) + add_money(post, money) + add_payment(post, payment) + add_currency(post, money, options) + add_address(post, options) + add_customer_data(post, options) + add_3DS(post, options) + post[:capture] = 'Y' + commit('auth', post) + end + end + + def authorize(money, payment, options = {}) + post = {} + add_money(post, money) + add_currency(post, money, options) + add_invoice(post, options) + add_payment(post, payment) + add_address(post, options) + add_customer_data(post, options) + add_3DS(post, options) + commit('auth', post) + end + + def capture(money, authorization, options = {}) + post = {} + add_money(post, money) + add_reference(post, authorization) + add_additional_data(post, options) + commit('capture', post) + end + + def refund(money, authorization, options = {}) + post = {} + add_money(post, money) + add_reference(post, authorization) + commit('refund', post) + end + + def void(authorization, options = {}) + post = {} + add_reference(post, authorization) + commit('void', post) + end + + def verify(credit_card, options = {}) + authorize(0, credit_card, options) + end + + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript + .gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]') + .gsub(%r(("cvv2\\":\\")\d*), '\1[FILTERED]') + .gsub(%r(("merchid\\":\\")\d*), '\1[FILTERED]') + .gsub(%r((&?"account\\":\\")\d*), '\1[FILTERED]') + .gsub(%r((&?"token\\":\\")\d*), '\1[FILTERED]') + end + + private + + def add_customer_data(post, options) + post[:email] = options[:email] if options[:email] + end + + def add_address(post, options) + if address = options[:billing_address] || options[:address] + post[:address] = address[:address1] if address[:address1] + post[:address].concat(" #{address[:address2]}") if address[:address2] + post[:city] = address[:city] if address[:city] + post[:region] = address[:state] if address[:state] + post[:country] = address[:country] if address[:country] + post[:postal] = address[:zip] if address[:zip] + post[:phone] = address[:phone] if address[:phone] + end + end + + def add_money(post, money) + post[:amount] = amount(money) + end + + def add_currency(post, money, options) + post[:currency] = (options[:currency] || currency(money)) + end + + def add_invoice(post, options) + post[:orderid] = options[:order_id] + post[:ecomind] = (options[:recurring] ? 'R' : 'E') + end + + def add_payment(post, payment) + post[:name] = payment.name + if card_brand(payment) == 'check' + add_echeck(post, payment) + else + post[:account] = payment.number + post[:expiry] = expdate(payment) + post[:cvv2] = payment.verification_value + end + end + + def add_echeck(post, payment) + post[:accttype] = 'ECHK' + post[:account] = payment.account_number + post[:bankaba] = payment.routing_number + end + + def add_reference(post, authorization) + post[:retref] = authorization + end + + def add_additional_data(post, options) + post[:ponumber] = options[:po_number] + post[:taxamnt] = options[:tax_amount] if options[:tax_amount] + post[:frtamnt] = options[:freight_amount] if options[:freight_amount] + post[:dutyamnt] = options[:duty_amount] if options[:duty_amount] + post[:orderdate] = options[:order_date] if options[:order_date] + post[:shipfromzip] = options[:ship_from_zip] if options[:ship_from_zip] + if (shipping_address = options[:shipping_address]) + post[:shiptozip] = shipping_address[:zip] + post[:shiptocountry] = shipping_address[:country] + end + if options[:items] + post[:items] = options[:items].map do |item| + updated = {} + item.each_pair do |k, v| + updated.merge!(k.to_s.gsub(/_/, '') => v) + end + end + end + end + + def add_3DS(post, options) + post[:secureflag] = options[:secure_flag] if options[:secure_flag] + post[:securevalue] = options[:secure_value] if options[:secure_value] + post[:securexid] = options[:secure_xid] if options[:secure_xid] + end + + def headers + { + 'Authorization' => 'Basic ' + Base64.strict_encode64("#{@options[:username]}:#{@options[:password]}"), + 'Content-Type' => 'application/json' + } + end + + def expdate(credit_card) + "#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}" + end + + def parse(body) + JSON.parse(body) + end + + def url(action) + if test? + test_url + action + else + (@options[:domain] ? @options[:domain] : live_url) + action + end + end + + def commit(action, parameters) + parameters[:merchid] = @options[:merchant_id] + url = url(action) + response = parse(ssl_request(:put, url, post_data(parameters), headers)) + + Response.new( + success_from(response), + message_from(response), + response, + authorization: authorization_from(response), + avs_result: AVSResult.new(code: response['avsresp']), + cvv_result: CVVResult.new(response['cvvresp']), + test: test?, + error_code: error_code_from(response) + ) + end + + def success_from(response) + response['respstat'] == 'A' + end + + def message_from(response) + response['setlstat'] ? "#{response['resptext']} #{response['setlstat']}" : response['resptext'] + end + + def authorization_from(response) + response['retref'] + end + + def post_data(parameters = {}) + parameters.to_json + end + + def error_code_from(response) + STANDARD_ERROR_CODE_MAPPING[response['respcode']] unless success_from(response) + end + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index 1e9105c3023..c1eeed84be6 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -122,6 +122,12 @@ cams: username: testintegrationc password: password9 +# Working credentials, no need to replace +card_connect: + merchant_id: "496160873888" + username: testing + password: testing123 + #Username/Password given in sign up email. Not MMS credentials card_save: login: merchant_id diff --git a/test/remote/gateways/remote_card_connect_test.rb b/test/remote/gateways/remote_card_connect_test.rb new file mode 100644 index 00000000000..77db6f0594e --- /dev/null +++ b/test/remote/gateways/remote_card_connect_test.rb @@ -0,0 +1,191 @@ +require 'test_helper' + +class RemoteCardConnectTest < Test::Unit::TestCase + def setup + @gateway = CardConnectGateway.new(fixtures(:card_connect)) + + @amount = 100 + @credit_card = credit_card('4788250000121443') + @declined_card = credit_card('4387751111111053') + @options = { + billing_address: address, + description: 'Store Purchase' + } + @check = check(routing_number: '053000196') + @invalid_txn = '23221' + end + + def test_successful_purchase + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Approval', response.message + end + + def test_successful_purchase_with_more_options + options = { + order_id: '1', + ip: "127.0.0.1", + email: "joe@example.com", + po_number: '5FSD4', + tax_amount: '50', + freight_amount: '29', + duty_amount: '67', + order_date: '20170507', + ship_from_date: '20877', + items: [ + { + line_no: '1', + material: 'MATERIAL-1', + description: 'DESCRIPTION-1', + upc: 'UPC-1', + quantity: '1000', + uom: 'CS', + unit_cost: '900', + net_amnt: '150', + tax_amnt: '117', + disc_amnt: '0' + }, + { + line_no: '2', + material: 'MATERIAL-2', + description: 'DESCRIPTION-2', + upc: 'UPC-1', + quantity: '2000', + uom: 'CS', + unit_cost: '450', + net_amnt: '300', + tax_amnt: '117', + disc_amnt: '0' + } + ] + } + + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_equal 'Approval Queued for Capture', response.message + end + + def test_successful_purchase_3DS + three_ds_options = @options.merge( + secure_flag: 'se3453', + secure_value: '233frdf', + secure_xid: '334ef34' + ) + response = @gateway.purchase(@amount, @credit_card, three_ds_options) + assert_success response + assert_equal 'Approval', response.message + end + + def test_failed_purchase + response = @gateway.purchase(@amount, @declined_card, @options) + assert_failure response + assert_equal 'Insufficient funds', response.message + end + + def test_successful_authorize_and_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + assert_includes ['Approval Queued for Capture', 'Approval Accepted'], capture.message + end + + def test_failed_authorize + response = @gateway.authorize(@amount, @declined_card, @options) + assert_failure response + assert_equal 'Insufficient funds', response.message + end + + def test_partial_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount - 1, auth.authorization) + assert_success capture + end + + def test_failed_capture + response = @gateway.capture(@amount, @invalid_txn) + assert_failure response + assert_equal 'Txn not found', response.message + end + + def test_successful_echeck_purchase + response = @gateway.purchase(@amount, @check, @options) + assert_equal 'Success', response.message + assert_success response + end + + def test_failed_echeck_purchase + response = @gateway.purchase(@amount, check(routing_number: '23433'), @options) + assert_failure response + assert_equal 'Invalid card', response.message + end + + def test_successful_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount, purchase.authorization) + assert_success refund + assert_equal 'Approval', refund.message + end + + def test_partial_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount - 1, purchase.authorization) + assert_success refund + end + + def test_failed_refund + response = @gateway.refund(@amount, @invalid_txn) + assert_failure response + assert_equal 'Txn not found', response.message + end + + def test_successful_void + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert void = @gateway.void(auth.authorization) + assert_success void + assert_equal 'Approval', void.message + end + + def test_failed_void + response = @gateway.void(@invalid_txn) + assert_failure response + end + + def test_successful_verify + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_match %r{Approval}, response.message + end + + def test_failed_verify + response = @gateway.verify(@declined_card, @options) + assert_failure response + assert_match %r{Insufficient funds}, response.message + end + + def test_invalid_login + gateway = CardConnectGateway.new(username: '', password: '', merchant_id: '') + assert_raises(ActiveMerchant::ResponseError) do + gateway.purchase(@amount, @credit_card, @options) + end + end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end +end diff --git a/test/unit/gateways/card_connect_test.rb b/test/unit/gateways/card_connect_test.rb new file mode 100644 index 00000000000..078f6f9256b --- /dev/null +++ b/test/unit/gateways/card_connect_test.rb @@ -0,0 +1,279 @@ +require 'test_helper' + +class CardConnectTest < Test::Unit::TestCase + include CommStub + def setup + @gateway = CardConnectGateway.new(username: 'username', password: 'password', merchant_id: 'merchand_id') + @credit_card = credit_card('4788250000121443') + @declined_card = credit_card('4387751111111053') + @amount = 100 + @check = check(routing_number: '053000196') + + @options = { + order_id: '1', + billing_address: address, + description: 'Store Purchase' + } + end + + def test_incorrect_domain + assert_raise(ArgumentError) { + CardConnectGateway.new(username: 'username', password: 'password', merchant_id: 'merchand_id', domain: 'www.google.com') + } + end + + def test_successful_purchase + @gateway.expects(:ssl_request).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + + assert_equal '363652261392', response.authorization + assert response.test? + end + + def test_successful_purchase_with_echeck + @gateway.expects(:ssl_request).returns(successful_echeck_purchase_response) + + response = @gateway.purchase(@amount, @check, @options) + assert_success response + + assert_equal '010136262668', response.authorization + assert response.test? + end + + def test_failed_purchase + @gateway.expects(:ssl_request).returns(failed_purchase_response) + + response = @gateway.purchase(@amount, @declined_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code + end + + def test_failed_purchase_with_echeck + @gateway.expects(:ssl_request).returns(failed_echeck_purchase_response) + + response = @gateway.purchase(@amount, check(routing_number: '23433'), @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code + end + + def test_successful_authorize + @gateway.expects(:ssl_request).returns(successful_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + + assert_equal '363168161558', response.authorization + assert response.test? + end + + def test_failed_authorize + @gateway.expects(:ssl_request).returns(failed_authorize_response) + + response = @gateway.authorize(@amount, @declined_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code + end + + def test_successful_capture + @gateway.expects(:ssl_request).returns(successful_capture_response) + + response = @gateway.capture(@amount,'363168161558', @options) + assert_success response + + assert_equal '363168161558', response.authorization + assert response.test? + end + + def test_failed_capture + @gateway.expects(:ssl_request).returns(failed_capture_response) + + response = @gateway.capture(@amount, '23221', @options) + assert_failure response + + assert_equal '23221', response.authorization + assert response.test? + + assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code + end + + def test_successful_refund + @gateway.expects(:ssl_request).returns(successful_refund_response) + + response = @gateway.refund(@amount, '36366126178', @options) + assert_success response + + assert_equal '363661261786', response.authorization + assert response.test? + end + + def test_failed_refund + @gateway.expects(:ssl_request).returns(failed_refund_response) + + response = @gateway.refund(@amount, '23221', @options) + assert_failure response + + assert_equal '23221', response.authorization + assert response.test? + + assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code + end + + def test_successful_void + @gateway.expects(:ssl_request).returns(successful_void_response) + + response = @gateway.void('363750268295') + assert_success response + + assert_equal '363664261982', response.authorization + assert response.test? + end + + def test_failed_void + @gateway.expects(:ssl_request).returns(failed_void_response) + + response = @gateway.void('23221') + assert_failure response + + assert response.test? + + assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code + end + + def test_successful_verify + @gateway.expects(:ssl_request).returns(successful_verify_response) + + response = @gateway.verify(@credit_card, @options) + assert_success response + + assert_equal '363272166977', response.authorization + assert response.test? + end + + def test_successful_verify_with_failed_void + response = stub_comms(@gateway, :ssl_request) do + @gateway.verify(@credit_card, @options) + end.respond_with(successful_authorize_response, failed_void_response) + assert_success response + end + + def test_failed_verify + @gateway.expects(:ssl_request).returns(failed_verify_response) + + response = @gateway.verify(@declined_card, @options) + assert_failure response + assert_equal "Insufficient funds", response.message + end + + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + + private + + def pre_scrubbed + %q( + opening connection to fts.cardconnect.com:6443... + opened + starting SSL for fts.cardconnect.com:6443... + SSL established + <- "PUT /cardconnect/rest/auth HTTP/1.1\r\nAuthorization: Basic dGVzdGluZzp0ZXN0aW5nMTIz\r\nContent-Type: application/json\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: fts.cardconnect.com:6443\r\nContent-Length: 298\r\n\r\n" + <- "{\"orderid\":null,\"ecomind\":\"E\",\"amount\":\"1.00\",\"name\":\"Longbob Longsen\",\"account\":\"4000100011112224\",\"expiry\":\"0918\",\"cvv2\":\"123\",\"currency\":\"USD\",\"address\":\"456 My Street\",\"city\":\"Ottawa\",\"region\":\"ON\",\"country\":\"CA\",\"postal\":\"K1C2N6\",\"phone\":\"(555)555-5555\",\"capture\":\"Y\",\"merchid\":\"496160873888\"}" + -> "HTTP/1.1 200 OK\r\n" + -> "X-FRAME-OPTIONS: DENY\r\n" + -> "Content-Type: application/json\r\n" + -> "Content-Length: 281\r\n" + -> "Date: Fri, 29 Dec 2017 23:51:22 GMT\r\n" + -> "Server: CardConnect\r\n" + -> "Connection: close\r\n" + -> "Set-Cookie: BIGipServerphu-smb-vip_8080=!3EyEfCvmvK/UDgCOaMq7McVUJtfXHaj0/1BWyxbacLNntp1E0Upt2onAMTKRSSu6r6mZaKuZm7N9ais=; path=/; Httponly; Secure\r\n" + -> "\r\n" + reading 281 bytes... + -> "{\"amount\":\"1.00\",\"resptext\":\"Approval\",\"commcard\":\" C \",\"cvvresp\":\"M\",\"batchid\":\"1900941444\",\"avsresp\":\" \",\"respcode\":\"00\",\"merchid\":\"496160873888\",\"token\":\"9405701444882224\",\"authcode\":\"PPS568\",\"respproc\":\"FNOR\",\"retref\":\"363743267882\",\"respstat\":\"A\",\"account\":\"9405701444882224\"}" + read 281 bytes + Conn close + ) + end + + def post_scrubbed + %q( + opening connection to fts.cardconnect.com:6443... + opened + starting SSL for fts.cardconnect.com:6443... + SSL established + <- "PUT /cardconnect/rest/auth HTTP/1.1\r\nAuthorization: Basic [FILTERED]\r\nContent-Type: application/json\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: fts.cardconnect.com:6443\r\nContent-Length: 298\r\n\r\n" + <- "{\"orderid\":null,\"ecomind\":\"E\",\"amount\":\"1.00\",\"name\":\"Longbob Longsen\",\"account\":\"[FILTERED]\",\"expiry\":\"0918\",\"cvv2\":\"[FILTERED]\",\"currency\":\"USD\",\"address\":\"456 My Street\",\"city\":\"Ottawa\",\"region\":\"ON\",\"country\":\"CA\",\"postal\":\"K1C2N6\",\"phone\":\"(555)555-5555\",\"capture\":\"Y\",\"merchid\":\"[FILTERED]\"}" + -> "HTTP/1.1 200 OK\r\n" + -> "X-FRAME-OPTIONS: DENY\r\n" + -> "Content-Type: application/json\r\n" + -> "Content-Length: 281\r\n" + -> "Date: Fri, 29 Dec 2017 23:51:22 GMT\r\n" + -> "Server: CardConnect\r\n" + -> "Connection: close\r\n" + -> "Set-Cookie: BIGipServerphu-smb-vip_8080=!3EyEfCvmvK/UDgCOaMq7McVUJtfXHaj0/1BWyxbacLNntp1E0Upt2onAMTKRSSu6r6mZaKuZm7N9ais=; path=/; Httponly; Secure\r\n" + -> "\r\n" + reading 281 bytes... + -> "{\"amount\":\"1.00\",\"resptext\":\"Approval\",\"commcard\":\" C \",\"cvvresp\":\"M\",\"batchid\":\"1900941444\",\"avsresp\":\" \",\"respcode\":\"00\",\"merchid\":\"[FILTERED]\",\"token\":\"[FILTERED]\",\"authcode\":\"PPS568\",\"respproc\":\"FNOR\",\"retref\":\"363743267882\",\"respstat\":\"A\",\"account\":\"[FILTERED]\"}" + read 281 bytes + Conn close + ) + end + + def successful_purchase_response + "{\"amount\":\"1.00\",\"resptext\":\"Approval\",\"commcard\":\" C \",\"cvvresp\":\"M\",\"batchid\":\"1900941444\",\"avsresp\":\" \",\"respcode\":\"00\",\"merchid\":\"496160873888\",\"token\":\"9405701444882224\",\"authcode\":\"PPS500\",\"respproc\":\"FNOR\",\"retref\":\"363652261392\",\"respstat\":\"A\",\"account\":\"9405701444882224\"}" + end + + def successful_echeck_purchase_response + "{\"amount\":\"1.00\",\"resptext\":\"Success\",\"cvvresp\":\"U\",\"batchid\":\"1900940633\",\"avsresp\":\"U\",\"respcode\":\"00\",\"merchid\":\"542041\",\"token\":\"9051769384108535\",\"authcode\":\"GF7PBR\",\"respproc\":\"PSTR\",\"retref\":\"010136262668\",\"respstat\":\"A\",\"account\":\"9051769384108535\"}" + end + + def failed_echeck_purchase_response + "{\"respproc\":\"PPS\",\"amount\":\"0.00\",\"resptext\":\"Invalid card\",\"cardproc\":\"PSTR\",\"retref\":\"010108164081\",\"respstat\":\"C\",\"respcode\":\"11\",\"account\":\"9235405400368535\",\"merchid\":\"542041\",\"token\":\"9235405400368535\"}" + end + + def failed_purchase_response + "{\"respproc\":\"FNOR\",\"amount\":\"0.00\",\"resptext\":\"Insufficient funds\",\"cardproc\":\"FNOR\",\"commcard\":\" C \",\"retref\":\"005533134378\",\"respstat\":\"C\",\"respcode\":\"NU\",\"account\":\"9435885049491053\",\"merchid\":\"496160873888\",\"token\":\"9435885049491053\"}" + end + + def successful_authorize_response + "{\"amount\":\"1.00\",\"resptext\":\"Approval\",\"commcard\":\" C \",\"cvvresp\":\"M\",\"avsresp\":\" \",\"respcode\":\"00\",\"merchid\":\"496160873888\",\"token\":\"9405701444882224\",\"authcode\":\"PPS454\",\"respproc\":\"FNOR\",\"retref\":\"363168161558\",\"respstat\":\"A\",\"account\":\"9405701444882224\"}" + end + + def failed_authorize_response + "{\"respproc\":\"FNOR\",\"amount\":\"0.00\",\"resptext\":\"Insufficient funds\",\"cardproc\":\"FNOR\",\"commcard\":\" C \",\"retref\":\"005737235263\",\"respstat\":\"C\",\"respcode\":\"NU\",\"account\":\"9435885049491053\",\"merchid\":\"496160873888\",\"token\":\"9435885049491053\"}" + end + + def successful_capture_response + "{\"respproc\":\"FNOR\",\"amount\":\"1.00\",\"resptext\":\"Approval\",\"setlstat\":\"Queued for Capture\",\"commcard\":\" C \",\"retref\":\"363168161558\",\"respstat\":\"A\",\"respcode\":\"00\",\"batchid\":\"1900941444\",\"account\":\"9405701444882224\",\"merchid\":\"496160873888\",\"token\":\"9405701444882224\"}" + end + + def failed_capture_response + "{\"respproc\":\"PPS\",\"resptext\":\"Txn not found\",\"retref\":\"23221\",\"respstat\":\"C\",\"respcode\":\"29\",\"batchid\":\"-1\",\"account\":\"\"}" + end + + def successful_refund_response + "{\"respproc\":\"PPS\",\"amount\":\"1.00\",\"resptext\":\"Approval\",\"retref\":\"363661261786\",\"respstat\":\"A\",\"respcode\":\"00\",\"merchid\":\"496160873888\"}" + end + + def failed_refund_response + "{\"respproc\":\"PPS\",\"resptext\":\"Txn not found\",\"retref\":\"23221\",\"respcode\":\"29\",\"respstat\":\"C\"}" + end + + def successful_void_response + "{\"authcode\":\"REVERS\",\"respproc\":\"FNOR\",\"amount\":\"0.00\",\"resptext\":\"Approval\",\"currency\":\"USD\",\"retref\":\"363664261982\",\"respstat\":\"A\",\"respcode\":\"00\",\"merchid\":\"496160873888\"}" + end + + def failed_void_response + "{\"respproc\":\"PPS\",\"resptext\":\"Txn not found\",\"retref\":\"23221\",\"respcode\":\"29\",\"respstat\":\"C\"}" + end + + def successful_verify_response + "{\"amount\":\"0.00\",\"resptext\":\"Approval\",\"commcard\":\" C \",\"cvvresp\":\"M\",\"avsresp\":\" \",\"respcode\":\"00\",\"merchid\":\"496160873888\",\"token\":\"9405701444882224\",\"authcode\":\"PPS585\",\"respproc\":\"FNOR\",\"retref\":\"363272166977\",\"respstat\":\"A\",\"account\":\"9405701444882224\"}" + end + + def failed_verify_response + "{\"respproc\":\"FNOR\",\"amount\":\"0.00\",\"resptext\":\"Insufficient funds\",\"cardproc\":\"FNOR\",\"commcard\":\" C \",\"retref\":\"005101240599\",\"respstat\":\"C\",\"respcode\":\"NU\",\"account\":\"9435885049491053\",\"merchid\":\"496160873888\",\"token\":\"9435885049491053\"}" + end +end From 1bb982f7fba1a4c4fd90b7e6f85b657ddcbed499 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Thu, 11 Jan 2018 18:12:41 -0500 Subject: [PATCH 294/677] Payeezy: Ensure store transactions are properly scrubbed Closes #2709 --- CHANGELOG | 1 + .../billing/gateways/payeezy.rb | 9 ++++++- test/remote/gateways/remote_payeezy_test.rb | 27 ++++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index bfffd1289c8..f9a51b0342a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,7 @@ * Mercury: Add scrubbing support [bpollack] #2702 * Fat Zebra: Tweak remote scrubbing test [bpollack] #2704 * Card Connect: Add new gateway [nfarve] #2706 +* Payeezy: Ensure store calls are properly scrubbed [dtykocki] #2591 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index e7c1e5f39a9..64b65ac15f8 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -104,10 +104,17 @@ def supports_scrubbing? def scrub(transcript) transcript. gsub(%r((Token: )(\w|-)+), '\1[FILTERED]'). + gsub(%r((Apikey: )(\w|-)+), '\1[FILTERED]'). gsub(%r((\\?"card_number\\?":\\?")\d+), '\1[FILTERED]'). gsub(%r((\\?"cvv\\?":\\?")\d+), '\1[FILTERED]'). gsub(%r((\\?"account_number\\?":\\?")\d+), '\1[FILTERED]'). - gsub(%r((\\?"routing_number\\?":\\?")\d+), '\1[FILTERED]') + gsub(%r((\\?"routing_number\\?":\\?")\d+), '\1[FILTERED]'). + gsub(%r((\\?card_number=)\d+(&?)), '\1[FILTERED]'). + gsub(%r((\\?cvv=)\d+(&?)), '\1[FILTERED]'). + gsub(%r((\\?apikey=)\w+(&?)), '\1[FILTERED]'). + gsub(%r{(\\?"credit_card\.card_number\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]'). + gsub(%r{(\\?"credit_card\.cvv\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]'). + gsub(%r{(\\?"apikey\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]') end private diff --git a/test/remote/gateways/remote_payeezy_test.rb b/test/remote/gateways/remote_payeezy_test.rb index 9e36909a592..ecc1c09076a 100644 --- a/test/remote/gateways/remote_payeezy_test.rb +++ b/test/remote/gateways/remote_payeezy_test.rb @@ -10,7 +10,7 @@ def setup @options = { :billing_address => address, :merchant_ref => 'Store Purchase', - :ta_token => '123' + :ta_token => '120' } @options_mdd = { soft_descriptors: { @@ -202,6 +202,31 @@ def test_trans_error assert_equal "500", response.error_code end + def test_transcript_scrubbing_store + transcript = capture_transcript(@gateway) do + @gateway.store(@credit_card, @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) + end + + transcript = @gateway.scrub(transcript) + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:token], transcript) + assert_scrubbed(@gateway.options[:apikey], transcript) + end + + def test_transcript_scrubbing_store_with_missing_ta_token + transcript = capture_transcript(@gateway) do + @options.delete(:ta_token) + @gateway.store(@credit_card, @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) + end + + transcript = @gateway.scrub(transcript) + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:token], transcript) + assert_scrubbed(@gateway.options[:apikey], transcript) + end + def test_transcript_scrubbing transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) From e05607e1c4921c372580f4c45047adc1d5013275 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Fri, 12 Jan 2018 04:43:01 -0500 Subject: [PATCH 295/677] Payeezy: Add unit test for scrubbing store call Also fixes `test_scrub_echeck` since Apikey was not previously scrubbed. Closes #2710 --- CHANGELOG | 3 +- test/unit/gateways/payeezy_test.rb | 62 +++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f9a51b0342a..d72eb78be10 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,7 +24,8 @@ * Mercury: Add scrubbing support [bpollack] #2702 * Fat Zebra: Tweak remote scrubbing test [bpollack] #2704 * Card Connect: Add new gateway [nfarve] #2706 -* Payeezy: Ensure store calls are properly scrubbed [dtykocki] #2591 +* Payeezy: Ensure store calls are properly scrubbed [dtykocki] #2709 +* Payeezy: Add unit test for scrubbing store call [dtykocki] #2710 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/test/unit/gateways/payeezy_test.rb b/test/unit/gateways/payeezy_test.rb index d3161920959..78f9f8f0ead 100644 --- a/test/unit/gateways/payeezy_test.rb +++ b/test/unit/gateways/payeezy_test.rb @@ -253,6 +253,10 @@ def test_scrub assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed end + def test_scrub_store + assert_equal @gateway.scrub(pre_scrubbed_store), post_scrubbed_store + end + def test_scrub_echeck assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed_echeck), post_scrubbed_echeck @@ -300,7 +304,7 @@ def post_scrubbed opened starting SSL for api-cert.payeezy.com:443... SSL established - <- "POST /v1/transactions HTTP/1.1\r\nContent-Type: application/json\r\nApikey: oKB61AAxbN3xwC6gVAH3dp58FmioHSAT\r\nToken: [FILTERED]\r\nNonce: 5803993876.636232\r\nTimestamp: 1449523748359\r\nAuthorization: NGRlZjJkMWNlMDc5NGI5OTVlYTQxZDRkOGQ4NjRhNmZhNDgwZmIyNTZkMWJhN2M3MDdkNDI0ZWI1OGUwMGExMA==\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api-cert.payeezy.com\r\nContent-Length: 365\r\n\r\n" + <- "POST /v1/transactions HTTP/1.1\r\nContent-Type: application/json\r\nApikey: [FILTERED]\r\nToken: [FILTERED]\r\nNonce: 5803993876.636232\r\nTimestamp: 1449523748359\r\nAuthorization: NGRlZjJkMWNlMDc5NGI5OTVlYTQxZDRkOGQ4NjRhNmZhNDgwZmIyNTZkMWJhN2M3MDdkNDI0ZWI1OGUwMGExMA==\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api-cert.payeezy.com\r\nContent-Length: 365\r\n\r\n" <- "{\"transaction_type\":\"purchase\",\"merchant_ref\":null,\"method\":\"credit_card\",\"credit_card\":{\"type\":\"Visa\",\"cardholder_name\":\"Longbob Longsen\",\"card_number\":\"[FILTERED]\",\"exp_date\":\"0916\",\"cvv\":\"[FILTERED]\"},\"billing_address\":{\"street\":\"456 My Street\",\"city\":\"Ottawa\",\"state_province\":\"ON\",\"zip_postal_code\":\"K1C2N6\",\"country\":\"CA\"},\"currency_code\":\"USD\",\"amount\":\"100\"}" -> "HTTP/1.1 201 Created\r\n" -> "Access-Control-Allow-Headers: Content-Type, apikey, token\r\n" @@ -382,6 +386,62 @@ def post_scrubbed_echeck TRANSCRIPT end + def pre_scrubbed_store + <<-TRANSCRIPT + opening connection to api-cert.payeezy.com:443... + opened + starting SSL for api-cert.payeezy.com:443... + SSL established + <- "GET /v1/securitytokens?apikey=UyDMTXx6TD9WErF6ynw7xeEfCAn8fcGs&js_security_key=js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c&ta_token=120&callback=Payeezy.callback&type=FDToken&credit_card.type=Visa&credit_card.cardholder_name=Longbob+Longsen&credit_card.card_number=4242424242424242&credit_card.exp_date=0919&credit_card.cvv=123 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: api-cert.payeezy.com\r\n\r\n" + -> "HTTP/1.1 200 Success\r\n" + -> "Content-Language: en-US\r\n" + -> "Content-Type: application/json\r\n" + -> "correlation_id: 228.1574930196886\r\n" + -> "Date: Fri, 12 Jan 2018 09:28:22 GMT\r\n" + -> "statuscode: 201\r\n" + -> "X-Archived-Client-IP: 10.180.205.250\r\n" + -> "X-Backside-Transport: OK OK,OK OK\r\n" + -> "X-Client-IP: 10.180.205.250,54.218.45.37\r\n" + -> "X-Global-Transaction-ID: 463881989\r\n" + -> "X-Powered-By: Servlet/3.0\r\n" + -> "Content-Length: 266\r\n" + -> "Connection: Close\r\n" + -> "\r\n" + reading 266 bytes... + -> "\n Payeezy.callback({\n \t\"status\":201,\n \t\"results\":{\"correlation_id\":\"228.1574930196886\",\"status\":\"success\",\"type\":\"FDToken\",\"token\":{\"type\":\"Visa\",\"cardholder_name\":\"Longbob Longsen\",\"exp_date\":\"0919\",\"value\":\"2158545373614242\"}}\n })\n " + read 266 bytes + Conn close + TRANSCRIPT + end + + def post_scrubbed_store + <<-TRANSCRIPT + opening connection to api-cert.payeezy.com:443... + opened + starting SSL for api-cert.payeezy.com:443... + SSL established + <- "GET /v1/securitytokens?apikey=[FILTERED]js_security_key=js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c&ta_token=120&callback=Payeezy.callback&type=FDToken&credit_card.type=Visa&credit_card.cardholder_name=Longbob+Longsen&credit_card.card_number=[FILTERED]credit_card.exp_date=0919&credit_card.cvv=[FILTERED] 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: api-cert.payeezy.com\r\n\r\n" + -> "HTTP/1.1 200 Success\r\n" + -> "Content-Language: en-US\r\n" + -> "Content-Type: application/json\r\n" + -> "correlation_id: 228.1574930196886\r\n" + -> "Date: Fri, 12 Jan 2018 09:28:22 GMT\r\n" + -> "statuscode: 201\r\n" + -> "X-Archived-Client-IP: 10.180.205.250\r\n" + -> "X-Backside-Transport: OK OK,OK OK\r\n" + -> "X-Client-IP: 10.180.205.250,54.218.45.37\r\n" + -> "X-Global-Transaction-ID: 463881989\r\n" + -> "X-Powered-By: Servlet/3.0\r\n" + -> "Content-Length: 266\r\n" + -> "Connection: Close\r\n" + -> "\r\n" + reading 266 bytes... + -> "\n Payeezy.callback({\n \t\"status\":201,\n \t\"results\":{\"correlation_id\":\"228.1574930196886\",\"status\":\"success\",\"type\":\"FDToken\",\"token\":{\"type\":\"Visa\",\"cardholder_name\":\"Longbob Longsen\",\"exp_date\":\"0919\",\"value\":\"2158545373614242\"}}\n })\n " + read 266 bytes + Conn close + TRANSCRIPT + end + def successful_purchase_response <<-RESPONSE {\"method\":\"credit_card\",\"amount\":\"1\",\"currency\":\"USD\",\"avs\":\"4\",\"card\":{\"type\":\"Visa\",\"cardholder_name\":\"Bobsen 995\",\"card_number\":\"4242\",\"exp_date\":\"0816\"},\"token\":{\"token_type\":\"transarmor\",\"token_data\":{\"value\":\"0152552999534242\"}},\"transaction_status\":\"approved\",\"validation_status\":\"success\",\"transaction_type\":\"purchase\",\"transaction_id\":\"ET114541\",\"transaction_tag\":\"55083431\",\"bank_resp_code\":\"100\",\"bank_message\":\"Approved\",\"gateway_resp_code\":\"00\",\"gateway_message\":\"Transaction Normal\",\"correlation_id\":\"124.1433862672836\"} From c6cc82c0cb0e63d04c980297c65ac0f9bb907c23 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Fri, 12 Jan 2018 12:54:57 -0500 Subject: [PATCH 296/677] Element: Correct URL used by store transactions Closes #2711 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/element.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index d72eb78be10..531403b4514 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,7 @@ * Card Connect: Add new gateway [nfarve] #2706 * Payeezy: Ensure store calls are properly scrubbed [dtykocki] #2709 * Payeezy: Add unit test for scrubbing store call [dtykocki] #2710 +* Element: Correct URL used by store transactions [dtykocki] #2711 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/gateways/element.rb b/lib/active_merchant/billing/gateways/element.rb index 9543fec46bd..d32c720cbf2 100644 --- a/lib/active_merchant/billing/gateways/element.rb +++ b/lib/active_merchant/billing/gateways/element.rb @@ -15,7 +15,7 @@ class ElementGateway < Gateway self.display_name = 'Element' SERVICE_TEST_URL = 'https://certservices.elementexpress.com/express.asmx' - SERVICE_LIVE_URL = 'https://service.elementexpress.com/express.asmx' + SERVICE_LIVE_URL = 'https://services.elementexpress.com/express.asmx' def initialize(options={}) requires!(options, :account_id, :account_token, :application_id, :acceptor_id, :application_name, :application_version) From 52f008a4be8b5d0cb862f11b87ace0a0987213fe Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Tue, 16 Jan 2018 09:18:15 -0500 Subject: [PATCH 297/677] Borgun: add TerminalID support TerminalID is required to handle recurring transactions (ID 3). One remote test (`test_invalid_login`) fails, but this is expected (see comment in the test), and at any rate wasn't altered by this commit. Unit: 8 tests, 37 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 20 tests, 45 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 95% passed Closes #2712 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/borgun.rb | 2 +- test/unit/gateways/borgun_test.rb | 11 ++++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 531403b4514..a59c33faee5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -27,6 +27,7 @@ * Payeezy: Ensure store calls are properly scrubbed [dtykocki] #2709 * Payeezy: Add unit test for scrubbing store call [dtykocki] #2710 * Element: Correct URL used by store transactions [dtykocki] #2711 +* Borgun: Add support for specifying TerminalID [bpollack] #2712 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb index 6544c786f50..a1e23d4c3f9 100644 --- a/lib/active_merchant/billing/gateways/borgun.rb +++ b/lib/active_merchant/billing/gateways/borgun.rb @@ -84,6 +84,7 @@ def scrub(transcript) def add_invoice(post, money, options) post[:TrAmount] = amount(money) post[:TrCurrency] = CURRENCY_CODES[options[:currency] || currency(money)] + post[:TerminalID] = options[:terminal_id] || '1' end def add_payment_method(post, payment_method) @@ -129,7 +130,6 @@ def commit(action, post) post[:Version] = '1000' post[:Processor] = @options[:processor] post[:MerchantID] = @options[:merchant_id] - post[:TerminalID] = 1 url = (test? ? test_url : live_url) request = build_request(action, post) diff --git a/test/unit/gateways/borgun_test.rb b/test/unit/gateways/borgun_test.rb index b7694e7adf1..6925d0c5c68 100644 --- a/test/unit/gateways/borgun_test.rb +++ b/test/unit/gateways/borgun_test.rb @@ -17,7 +17,8 @@ def setup @options = { order_id: '1', billing_address: address, - description: 'Store Purchase' + description: 'Store Purchase', + terminal_id: '3' } end @@ -97,6 +98,14 @@ def test_passing_cvv end.respond_with(successful_purchase_response) end + def test_passing_terminal_id + stub_comms do + @gateway.purchase(@amount, @credit_card, { terminal_id: '3' }) + end.check_request do |endpoint, data, headers| + assert_match(/TerminalID>3/, data) + end.respond_with(successful_purchase_response) + end + def test_transcript_scrubbing assert_equal scrubbed_transcript, @gateway.scrub(transcript) end From 3a5bc98312d3e79b720b856c168fb4a6e21c9c7c Mon Sep 17 00:00:00 2001 From: Niaja Date: Wed, 17 Jan 2018 10:49:19 -0500 Subject: [PATCH 298/677] Barclaycard Smartpay: 3DS Implementation Adds 3DS Support Loaded suite test/unit/gateways/barclaycard_smartpay_test 24 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_barclaycard_smartpay_test 28 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- .../billing/gateways/barclaycard_smartpay.rb | 8 ++++++++ .../remote_barclaycard_smartpay_test.rb | 11 +++++++++++ test/unit/gateways/barclaycard_smartpay_test.rb | 17 +++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index c79c7298816..3710a147f70 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -35,6 +35,7 @@ def authorize(money, creditcard, options = {}) post[:card] = credit_card_hash(creditcard) post[:billingAddress] = billing_address_hash(options) if options[:billing_address] post[:deliveryAddress] = shipping_address_hash(options) if options[:shipping_address] + add_3ds(post, options) if options[:execute_threed] commit('authorise', post) end @@ -222,6 +223,8 @@ def build_url(action) case action when 'store' "#{test? ? self.test_url : self.live_url}/Recurring/v12/storeToken" + when 'finalize3ds' + "#{test? ? self.test_url : self.live_url}/Payment/v12/authorise3d" else "#{test? ? self.test_url : self.live_url}/Payment/v12/#{action}" end @@ -312,6 +315,11 @@ def store_request(options) hash[:shopperReference] = options[:customer] if options[:customer] hash.keep_if { |_, v| v } end + + def add_3ds(post, options) + post[:additionalData] = { executeThreeD: 'true' } + post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] } + end end end end diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index 9d39afcb86a..96b6127f41f 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -8,6 +8,7 @@ def setup @amount = 100 @credit_card = credit_card('4111111111111111', :month => 8, :year => 2018, :verification_value => 737) @declined_card = credit_card('4000300011112220', :month => 8, :year => 2018, :verification_value => 737) + @three_ds_enrolled_card = credit_card('4212345678901237', brand: :visa) @options = { order_id: '1', @@ -152,6 +153,16 @@ def test_successful_purchase_with_no_address assert_equal '[capture-received]', response.message end + def test_successful_authorize_with_3ds + assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @options.merge(execute_threed: true)) + assert_equal 'RedirectShopper', response.message + assert response.test? + refute response.authorization.blank? + refute response.params['issuerUrl'].blank? + refute response.params['md'].blank? + refute response.params['paRequest'].blank? + end + def test_successful_authorize_and_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb index d7784ef6f69..23fc6d9238c 100644 --- a/test/unit/gateways/barclaycard_smartpay_test.rb +++ b/test/unit/gateways/barclaycard_smartpay_test.rb @@ -11,6 +11,7 @@ def setup ) @credit_card = credit_card + @three_ds_enrolled_card = credit_card('4212345678901237', brand: :visa) @amount = 100 @options = { @@ -165,6 +166,18 @@ def test_successful_authorize assert response.test? end + def test_successful_authorize_with_3ds + @gateway.stubs(:ssl_post).returns(successful_authorize_with_3ds_response) + + response = @gateway.authorize(@amount, @three_ds_enrolled_card, @options) + + assert_equal '8815161318854998', response.authorization + refute response.params['issuerUrl'].blank? + refute response.params['md'].blank? + refute response.params['paRequest'].blank? + assert response.test? + end + def test_failed_authorize @gateway.stubs(:ssl_post).returns(failed_authorize_response) @@ -328,6 +341,10 @@ def successful_authorize_response 'pspReference=7914002629995504&authCode=56469&resultCode=Authorised' end + def successful_authorize_with_3ds_response + "pspReference=8815161318854998&resultCode=RedirectShopper&issuerUrl=https%3A%2F%2Ftest.adyen.com%2Fhpp%2F3d%2Fvalidate.shtml&md=WIFa2sF3CuPyN53Txjt3U%2F%2BDuCsddzywiY5NLgEAdUAXPksHUzXL5E%2BsfvdpolkGWR8b1oh%2FNA3jNaUP9UCgfjhXqRslGFy9OGqcZ1ITMz54HHm%2FlsCKN9bTftKnYA4F7GqvOgcIIrinUZjbMvW9doGifwzSqYLo6ASOm6bARL5n7cIFV8IWtA2yPlO%2FztKSTRJt1glN4s8sMcpE57z4soWKMuycbdXdpp6d4ZRSa%2F1TPF0MnJF0zNaSAAkw9JpXqGMOz5sFF2Smpc38HXJzM%2FV%2B1mmoDhhWmXXOb5YQ0QSCS7DXKIcr8ZtuGuGmFp0QOfZiO41%2B2I2N7VhONVx8xSn%2BLu4m6vaDIg5qsnd9saxaWwbJpl9okKm6pB2MJap9ScuBCcvI496BPCrjQ2LHxvDWhk6M3Exemtv942NQIGlsiPaW0KXoC2dQvBsxWh0K&paRequest=eNpVUtuOgjAQ%2FRXj%2B1KKoIWMTVgxWR%2B8RNkPaMpEycrFUlb8%2B20B190%2BnXPm0pnTQnpRiMkJZauQwxabRpxxkmfLacQYDeiczihjgR%2BGbMrhEB%2FxxuEbVZNXJaeO63hAntSUK3kRpeYg5O19s%2BPUm%2FnBHMhIoUC1SXiKjT4URSxvba5QARlkKEWB%2FFSbgbLr41QIpXFVFUB6HWTVllo9OPNMwyeBVl35Reu6iQi53%2B9OM5Y7sipMVqmF1G9tA8QmAnlNeGgtakzjLs%2F4Pjl3u3TtbdNtZzDdJV%2FBPu7PEojNgExo5J5LmUvpfELDyPcjPwDS6yAKOxFffx4nxhXXrDwIUNt74oFQG%2FgrgLFdYSkfPFwws9WTAXZ1VaLJMPb%2BYiCvoVcf1mSpjW%2B%2BN9i8YKFr0MLa3Qdsl9yYREM37NtYAsSWkvElyfjiBv37CT9ySbE1" + end + def failed_authorize_response 'pspReference=7914002630895750&refusalReason=Refused&resultCode=Refused' end From aef7c2f43f2d4ab21fadda8e3f71cd64a82cf229 Mon Sep 17 00:00:00 2001 From: Niaja Date: Wed, 17 Jan 2018 10:49:19 -0500 Subject: [PATCH 299/677] Changelog Update Barclaycard Smartpay 3DS implementation changelog --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index a59c33faee5..566024c937e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -28,6 +28,7 @@ * Payeezy: Add unit test for scrubbing store call [dtykocki] #2710 * Element: Correct URL used by store transactions [dtykocki] #2711 * Borgun: Add support for specifying TerminalID [bpollack] #2712 +* Barclaycard Smartpay: 3DS Implementation [nfarve] #2714 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 From b9f248f97852e78a6309bf8cf65115a5b3e211e0 Mon Sep 17 00:00:00 2001 From: David Perry Date: Fri, 19 Jan 2018 11:10:24 -0500 Subject: [PATCH 300/677] Payeezy: Surface gateway_message on failure Useful gateway messages were not making it to the AM response in certain cases. This surfaces them as a fallback. Also corrects an authorize unit test. Closes #2717 Remote: 27 tests, 98 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 32 tests, 153 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/payeezy.rb | 2 +- test/unit/gateways/payeezy_test.rb | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 566024c937e..e6a8d9ef7ac 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -29,6 +29,7 @@ * Element: Correct URL used by store transactions [dtykocki] #2711 * Borgun: Add support for specifying TerminalID [bpollack] #2712 * Barclaycard Smartpay: 3DS Implementation [nfarve] #2714 +* Payeezy: Surface gateway_message on failure [curiousepic] #2717 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index 64b65ac15f8..2bdd62f7ac4 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -352,7 +352,7 @@ def handle_message(response, success) elsif response.key?('fault') response['fault'].to_h['faultstring'] else - response['bank_message'] || 'Failure to successfully create token.' + response['bank_message'] || response['gateway_message'] || 'Failure to successfully create token.' end end diff --git a/test/unit/gateways/payeezy_test.rb b/test/unit/gateways/payeezy_test.rb index 78f9f8f0ead..c257f47aa85 100644 --- a/test/unit/gateways/payeezy_test.rb +++ b/test/unit/gateways/payeezy_test.rb @@ -125,7 +125,7 @@ def test_failed_purchase def test_successful_authorize @gateway.expects(:ssl_post).returns(successful_authorize_response) - assert response = @gateway.purchase(@amount, @credit_card, @options) + assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response assert_equal 'ET156862|69601979|credit_card|100', response.authorization assert response.test? @@ -240,6 +240,13 @@ def test_requests_include_verification_string end.respond_with(successful_purchase_response) end + def test_gateway_message_surfaces + @gateway.expects(:ssl_post).returns(below_minimum_response) + assert response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_equal 'Below Minimum Sale', response.message + end + def test_card_type assert_equal 'Visa', PayeezyGateway::CREDIT_CARD_BRAND['visa'] assert_equal 'Mastercard', PayeezyGateway::CREDIT_CARD_BRAND['master'] @@ -537,6 +544,12 @@ def successful_refund_echeck_response RESPONSE end + def below_minimum_response + <<-RESPONSE + {\"correlation_id\":\"123.1234678982\",\"transaction_status\":\"declined\",\"validation_status\":\"success\",\"transaction_type\":\"authorize\",\"transaction_tag\":\"92384753\",\"method\":\"credit_card\",\"amount\":\"250\",\"currency\":\"USD\",\"card\":{\"type\":\"Mastercard\",\"cardholder_name\":\"Omri Test\",\"card_number\":\"[FILTERED]\",\"exp_date\":\"0123\"},\"gateway_resp_code\":\"36\",\"gateway_message\":\"Below Minimum Sale\"} + RESPONSE + end + def failed_refund_response yamlexcep = <<-RESPONSE --- !ruby/exception:ActiveMerchant::ResponseError From 6ccfb00d6ec42342ded893468e1cfdd30e35fae0 Mon Sep 17 00:00:00 2001 From: Niaja Date: Thu, 25 Jan 2018 11:08:39 -0500 Subject: [PATCH 301/677] Ogone: Add field ORIG Add the field ORIG if sent Two failing tests unrelated to this change Loaded suite test/remote/gateways/remote_ogone_test Failure: test_successful_credit(RemoteOgoneTest) "Refunds are not allowed for your PSPID. Please contact helpdesk."}, Error: test_successful_store_generated_alias(RemoteOgoneTest): NoMethodError: undefined method `name' for nil:NilClass 27 tests, 99 assertions, 1 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications Loaded suite test/unit/gateways/ogone_test 48 tests, 206 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/ogone.rb | 1 + test/remote/gateways/remote_ogone_test.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb index 3700b334782..67ab2ff6d4e 100644 --- a/lib/active_merchant/billing/gateways/ogone.rb +++ b/lib/active_merchant/billing/gateways/ogone.rb @@ -334,6 +334,7 @@ def add_address(post, creditcard, options) def add_invoice(post, options) add_pair post, 'orderID', options[:order_id] || generate_unique_id[0...30] add_pair post, 'COM', options[:description] + add_pair post, 'ORIG', options[:origin] if options[:origin] end def add_creditcard(post, creditcard) diff --git a/test/remote/gateways/remote_ogone_test.rb b/test/remote/gateways/remote_ogone_test.rb index b5ede03c640..8dd7ae9264e 100644 --- a/test/remote/gateways/remote_ogone_test.rb +++ b/test/remote/gateways/remote_ogone_test.rb @@ -14,7 +14,8 @@ def setup :order_id => generate_unique_id[0...30], :billing_address => address, :description => 'Store Purchase', - :currency => fixtures(:ogone)[:currency] || 'EUR' + :currency => fixtures(:ogone)[:currency] || 'EUR', + :origin => 'STORE' } end From b812a07377ce22f8648d81632c662cc6174bad7c Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Thu, 25 Jan 2018 11:53:10 -0500 Subject: [PATCH 302/677] CenPos: Switch to new endpoint URL In addition to changing the endpoint, something in Active Merchant or this adapter isn't dealing well with Gzip'd responses, so I've removed that header for now. (Requests at the old endpoint weren't ever Gzip'd, so the old path was effectively untested.) I also patched one remote test that was trivial to fix while I was in here. The six remote test failures are identical with or without this patch. (Well, you'll get seven without it due to the above-mentioned trivial fix.) Unit: 23 tests, 98 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 23 tests, 51 assertions, 6 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 73.913% passed Closes #2722 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/cenpos.rb | 3 +-- test/remote/gateways/remote_cenpos_test.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e6a8d9ef7ac..f816cc349e1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -30,6 +30,7 @@ * Borgun: Add support for specifying TerminalID [bpollack] #2712 * Barclaycard Smartpay: 3DS Implementation [nfarve] #2714 * Payeezy: Surface gateway_message on failure [curiousepic] #2717 +* CenPos: Switch main transaction URL [bpollack] #2722 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/gateways/cenpos.rb b/lib/active_merchant/billing/gateways/cenpos.rb index cc208e39661..c72c271afc7 100644 --- a/lib/active_merchant/billing/gateways/cenpos.rb +++ b/lib/active_merchant/billing/gateways/cenpos.rb @@ -6,7 +6,7 @@ class CenposGateway < Gateway self.display_name = "CenPOS" self.homepage_url = "https://www.cenpos.com/" - self.live_url = "https://ww3.cenpos.net/6/transact.asmx" + self.live_url = "https://ww2.payment1.cenpos.net/6/transact.asmx" self.supported_countries = %w(AD AI AG AR AU AT BS BB BE BZ BM BR BN BG CA HR CY CZ DK DM EE FI FR DE GR GD GY HK HU IS IN IL IT JP LV LI LT LU MY MT MX MC MS NL PA PL PT KN LC MF VC SM SG SK SI ZA ES SR SE CH TR GB US UY) self.default_currency = "USD" @@ -180,7 +180,6 @@ def commit(action, post) def headers { - "Accept-Encoding" => "gzip,deflate", "Content-Type" => "text/xml;charset=UTF-8", "SOAPAction" => "http://tempuri.org/Transactional/ProcessCreditCard" } diff --git a/test/remote/gateways/remote_cenpos_test.rb b/test/remote/gateways/remote_cenpos_test.rb index 64adf71cf44..29024454559 100644 --- a/test/remote/gateways/remote_cenpos_test.rb +++ b/test/remote/gateways/remote_cenpos_test.rb @@ -107,7 +107,7 @@ def test_failed_capture capture = @gateway.capture(@amount, response.authorization) capture = @gateway.capture(@amount, response.authorization) assert_failure capture - assert_equal "Duplicated transaction", capture.message + assert_equal "Duplicated force transaction.", capture.message end def test_successful_void From 7c2590c32c9dd15fb37429ebe24ffc25eb8c549b Mon Sep 17 00:00:00 2001 From: David Perry Date: Thu, 25 Jan 2018 13:47:53 -0500 Subject: [PATCH 303/677] Payment Express: Scrub merchant password Merchant password credential was not being scrubbed. There are many failing remote tests but they are not related to this change. Closes #2723 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/payment_express.rb | 3 ++- test/remote/gateways/remote_payment_express_test.rb | 1 + test/unit/gateways/payment_express_test.rb | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f816cc349e1..d87cdfa6ad6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -31,6 +31,7 @@ * Barclaycard Smartpay: 3DS Implementation [nfarve] #2714 * Payeezy: Surface gateway_message on failure [curiousepic] #2717 * CenPos: Switch main transaction URL [bpollack] #2722 +* Payment Express: Scrub merchant password [curiousepic] #2723 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb index 2c6cedb74a9..f8a1cc41df2 100644 --- a/lib/active_merchant/billing/gateways/payment_express.rb +++ b/lib/active_merchant/billing/gateways/payment_express.rb @@ -128,7 +128,8 @@ def supports_scrubbing def scrub(transcript) transcript. - gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). + gsub(%r(().+()), '\1[FILTERED]\2'). + gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]\2'). gsub(%r(()\d+()), '\1[FILTERED]\2'). gsub(%r(()\d+()), '\1[FILTERED]\2') end diff --git a/test/remote/gateways/remote_payment_express_test.rb b/test/remote/gateways/remote_payment_express_test.rb index 01acdb8fc54..cc18a63de57 100644 --- a/test/remote/gateways/remote_payment_express_test.rb +++ b/test/remote/gateways/remote_payment_express_test.rb @@ -138,6 +138,7 @@ def test_transcript_scrubbing assert_scrubbed(@credit_card.number, clean_transcript) assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript) + assert_scrubbed(@gateway.options[:password], clean_transcript) end end diff --git a/test/unit/gateways/payment_express_test.rb b/test/unit/gateways/payment_express_test.rb index d97343b8ea6..f892ab3f715 100644 --- a/test/unit/gateways/payment_express_test.rb +++ b/test/unit/gateways/payment_express_test.rb @@ -433,6 +433,6 @@ def transcript end def scrubbed_transcript - %(Longbob Longsen[FILTERED]0916[FILTERED]11.00NZD59956b468905bde7Store purchase11456 My StreetK1C2N6WaysactDevkvr52dw9Purchase) + %(Longbob Longsen[FILTERED]0916[FILTERED]11.00NZD59956b468905bde7Store purchase11456 My StreetK1C2N6WaysactDev[FILTERED]Purchase) end end From cef196efb23295388aa16d09c835ee0cd7be199a Mon Sep 17 00:00:00 2001 From: Benjamin Pollack Date: Thu, 25 Jan 2018 15:21:13 -0500 Subject: [PATCH 304/677] Revert "CenPos: Switch to new endpoint URL" This reverts commit b812a07377ce22f8648d81632c662cc6174bad7c. --- CHANGELOG | 1 - lib/active_merchant/billing/gateways/cenpos.rb | 3 ++- test/remote/gateways/remote_cenpos_test.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d87cdfa6ad6..2b1c31f7f1b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -30,7 +30,6 @@ * Borgun: Add support for specifying TerminalID [bpollack] #2712 * Barclaycard Smartpay: 3DS Implementation [nfarve] #2714 * Payeezy: Surface gateway_message on failure [curiousepic] #2717 -* CenPos: Switch main transaction URL [bpollack] #2722 * Payment Express: Scrub merchant password [curiousepic] #2723 == Version 1.76.0 (January 3, 2018) diff --git a/lib/active_merchant/billing/gateways/cenpos.rb b/lib/active_merchant/billing/gateways/cenpos.rb index c72c271afc7..cc208e39661 100644 --- a/lib/active_merchant/billing/gateways/cenpos.rb +++ b/lib/active_merchant/billing/gateways/cenpos.rb @@ -6,7 +6,7 @@ class CenposGateway < Gateway self.display_name = "CenPOS" self.homepage_url = "https://www.cenpos.com/" - self.live_url = "https://ww2.payment1.cenpos.net/6/transact.asmx" + self.live_url = "https://ww3.cenpos.net/6/transact.asmx" self.supported_countries = %w(AD AI AG AR AU AT BS BB BE BZ BM BR BN BG CA HR CY CZ DK DM EE FI FR DE GR GD GY HK HU IS IN IL IT JP LV LI LT LU MY MT MX MC MS NL PA PL PT KN LC MF VC SM SG SK SI ZA ES SR SE CH TR GB US UY) self.default_currency = "USD" @@ -180,6 +180,7 @@ def commit(action, post) def headers { + "Accept-Encoding" => "gzip,deflate", "Content-Type" => "text/xml;charset=UTF-8", "SOAPAction" => "http://tempuri.org/Transactional/ProcessCreditCard" } diff --git a/test/remote/gateways/remote_cenpos_test.rb b/test/remote/gateways/remote_cenpos_test.rb index 29024454559..64adf71cf44 100644 --- a/test/remote/gateways/remote_cenpos_test.rb +++ b/test/remote/gateways/remote_cenpos_test.rb @@ -107,7 +107,7 @@ def test_failed_capture capture = @gateway.capture(@amount, response.authorization) capture = @gateway.capture(@amount, response.authorization) assert_failure capture - assert_equal "Duplicated force transaction.", capture.message + assert_equal "Duplicated transaction", capture.message end def test_successful_void From 4771e0e667ec8aad58cab6e347117a5f774d1df8 Mon Sep 17 00:00:00 2001 From: Niaja Date: Fri, 26 Jan 2018 09:11:31 -0500 Subject: [PATCH 305/677] Global Collect: Add Creator Info Fields Adds creator fields to all transactions if present. Loaded suite test/remote/gateways/remote_global_collect_test ............... 15 tests, 35 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/global_collect_test ................ 16 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- .../billing/gateways/global_collect.rb | 15 +++++++++++++++ .../remote/gateways/remote_global_collect_test.rb | 9 ++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index b8fc6be69c9..35a0674aa90 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -33,6 +33,7 @@ def authorize(money, payment, options={}) add_payment(post, payment, options) add_customer_data(post, options, payment) add_address(post, payment, options) + add_creator_info(post, options) commit(:authorize, post) end @@ -41,6 +42,7 @@ def capture(money, authorization, options={}) post = nestable_hash add_order(post, money, options) add_customer_data(post, options) + add_creator_info(post, options) commit(:capture, post, authorization) end @@ -48,11 +50,13 @@ def refund(money, authorization, options={}) post = nestable_hash add_amount(post, money, options) add_refund_customer_data(post, options) + add_creator_info(post, options) commit(:refund, post, authorization) end def void(authorization, options={}) post = nestable_hash + add_creator_info(post, options) commit(:void, post, authorization) end @@ -99,6 +103,17 @@ def add_order(post, money, options) } end + def add_creator_info(post, options) + post['sdkIdentifier'] = options[:sdk_identifier] if options[:sdk_identifier] + post['sdkCreator'] = options[:sdk_creator] if options[:sdk_creator] + post['integrator'] = options[:integrator] if options[:integrator] + post['shoppingCartExtension'] = {} + post['shoppingCartExtension']['creator'] = options[:creator] if options[:creator] + post['shoppingCartExtension']['name'] = options[:name] if options[:name] + post['shoppingCartExtension']['version'] = options[:version] if options[:version] + post['shoppingCartExtension']['extensionID'] = options[:extension_ID] if options[:extension_ID] + end + def add_amount(post, money, options={}) post["amountOfMoney"] = { "amount" => amount(money), diff --git a/test/remote/gateways/remote_global_collect_test.rb b/test/remote/gateways/remote_global_collect_test.rb index f2760af7b76..dba8d6fc6bf 100644 --- a/test/remote/gateways/remote_global_collect_test.rb +++ b/test/remote/gateways/remote_global_collect_test.rb @@ -25,7 +25,14 @@ def test_successful_purchase_with_more_options options = @options.merge( order_id: '1', ip: "127.0.0.1", - email: "joe@example.com" + email: "joe@example.com", + sdk_identifier: 'Channel', + sdk_creator: 'Bob', + integrator: 'Bill', + creator: 'Super', + name: 'Cala', + version: '1.0', + extension_ID: '5555555' ) response = @gateway.purchase(@amount, @credit_card, options) From 5737c272bf1fa37c177e35f8bf30835333ff77da Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 12 Dec 2017 10:03:11 -0500 Subject: [PATCH 306/677] Stripe: Fix Partial Application Fee Refunds Previously, when a partial application fee refund was requested, the connected stripe_account option was sent in the authentication header for both the fee retrieval call AND the application fee refund itself. Since the fee exists only on the main Platform account, sending the connected stripe_account for the refund meant it was looking in the wrong place, and failed. Now we remove the stripe_account field before the partial refund, so it is not sent in headers. This also switches to a method of fetching the transaction to obtain the id of the application fee, rather than querying all application fees associated with the transaction, since it simplifies things, and the prior method did not seem to have any benefits over this (having multiple application fees doesn't seem possible currently). Error messaging around this has been updated as well. This also involved updating the aging remote_stripe_connect_tests to use the stripe_destination in fixtures as the stripe_account option, and to remove assertions that are now invalid due to the changes to response structure in https://stripe.com/docs/upgrades#2013-08-13 Unit tests were likewise updated for the partial fee refund method changes. Closes #2713 Remote (two failing likely due to unrelated stale test data): 59 tests, 253 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 96.6102% passed Remote Connect: 3 tests, 10 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 122 tests, 651 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/stripe.rb | 23 +++--- .../gateways/remote_stripe_connect_test.rb | 27 ++++--- test/remote/gateways/remote_stripe_test.rb | 2 + test/unit/gateways/stripe_test.rb | 78 ++++++++++--------- 5 files changed, 75 insertions(+), 56 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2b1c31f7f1b..9517f5286b0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -31,6 +31,7 @@ * Barclaycard Smartpay: 3DS Implementation [nfarve] #2714 * Payeezy: Surface gateway_message on failure [curiousepic] #2717 * Payment Express: Scrub merchant password [curiousepic] #2723 +* Stripe: Fix Partial Application Fee Refunds [curiousepic] #2713 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 65a95003838..ec773c6ad64 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -151,7 +151,7 @@ def refund(money, identification, options = {}) return r unless options[:refund_fee_amount] - r.process { fetch_application_fees(identification, options) } + r.process { fetch_application_fee(identification, options) } r.process { refund_application_fee(options[:refund_fee_amount], application_fee_from_response(r.responses.last), options) } end end @@ -166,9 +166,7 @@ def verify(payment, options = {}) def application_fee_from_response(response) return unless response.success? - - application_fees = response.params["data"].select { |fee| fee["object"] == "application_fee" } - application_fees.first["id"] unless application_fees.empty? + response.params["application_fee"] unless response.params["application_fee"].empty? end def refund_application_fee(money, identification, options = {}) @@ -176,9 +174,11 @@ def refund_application_fee(money, identification, options = {}) post = {} add_amount(post, money, options) - options.merge!(:key => @fee_refund_api_key) + options.merge!(:key => @fee_refund_api_key) if @fee_refund_api_key + options.delete(:stripe_account) - commit(:post, "application_fees/#{CGI.escape(identification)}/refund", post, options) + refund_fee = commit(:post, "application_fees/#{CGI.escape(identification)}/refunds", post, options) + application_fee_response!(refund_fee, "Application fee could not be refunded: #{refund_fee.message}") end # Note: creating a new credit card will not change the customer's existing default credit card (use :set_default => true) @@ -371,7 +371,7 @@ def add_address(post, options) def add_statement_address(post, options) return unless statement_address = options[:statement_address] - return unless [:address1, :city, :zip, :state].all? { |key| statement_address[key].present? } + return unless [:address1, :city, :zip, :state].all? { |key| statement_address[key].present? } post[:statement_address] = {} post[:statement_address][:line1] = statement_address[:address1] @@ -461,10 +461,15 @@ def add_emv_metadata(post, creditcard) post[:metadata][:card_read_method] = creditcard.read_method if creditcard.respond_to?(:read_method) end - def fetch_application_fees(identification, options = {}) + def fetch_application_fee(identification, options = {}) options.merge!(:key => @fee_refund_api_key) - commit(:get, "application_fees?charge=#{identification}", nil, options) + fetch_charge = commit(:get, "charges/#{CGI.escape(identification)}", nil, options) + application_fee_response!(fetch_charge, "Application fee id could not be retrieved: #{fetch_charge.message}") + end + + def application_fee_response!(response, message) + response.success? ? response : Response.new(false, message) end def parse(body) diff --git a/test/remote/gateways/remote_stripe_connect_test.rb b/test/remote/gateways/remote_stripe_connect_test.rb index c5bbd77d339..3843a46a79a 100644 --- a/test/remote/gateways/remote_stripe_connect_test.rb +++ b/test/remote/gateways/remote_stripe_connect_test.rb @@ -12,31 +12,38 @@ def setup @options = { :currency => "USD", :description => 'ActiveMerchant Test Purchase', - :email => 'wow@example.com' + :email => 'wow@example.com', + :stripe_account => fixtures(:stripe_destination)[:stripe_user_id] } end def test_application_fee_for_stripe_connect assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:application_fee => 12 )) - assert response.params['fee_details'], 'This test will only work if your gateway login is a Stripe Connect access_token.' - assert response.params['fee_details'].any? do |fee| - (fee['type'] == 'application_fee') && (fee['amount'] == 12) - end + assert_success response end def test_successful_refund_with_application_fee assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:application_fee => 12)) - assert response.params['fee_details'], 'This test will only work if your gateway login is a Stripe Connect access_token.' - assert refund = @gateway.refund(@amount, response.authorization, :refund_application_fee => true) + assert refund = @gateway.refund(@amount, response.authorization, @options.merge(:refund_application_fee => true)) assert_success refund - assert_equal 0, refund.params["fee"] + + # Verify the application fee is refunded + fetch_fee_id = @gateway.send(:fetch_application_fee, response.authorization, @options) + fee_id = @gateway.send(:application_fee_from_response, fetch_fee_id) + refund_check = @gateway.send(:refund_application_fee, 10, fee_id, @options) + assert_equal "Application fee could not be refunded: Refund amount ($0.10) is greater than unrefunded amount on fee ($0.00)", refund_check.message end def test_refund_partial_application_fee assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:application_fee => 12)) - assert response.params['fee_details'], 'This test will only work if your gateway login is a Stripe Connect access_token.' - assert refund = @gateway.refund(@amount - 20, response.authorization, { :refund_fee_amount => 10 }) + assert refund = @gateway.refund(@amount-20, response.authorization, @options.merge(:refund_fee_amount => 10)) assert_success refund + + # Verify the application fee is partially refunded + fetch_fee_id = @gateway.send(:fetch_application_fee, response.authorization, @options) + fee_id = @gateway.send(:application_fee_from_response, fetch_fee_id) + refund_check = @gateway.send(:refund_application_fee, 10, fee_id, @options) + assert_equal "Application fee could not be refunded: Refund amount ($0.10) is greater than unrefunded amount on fee ($0.02)", refund_check.message end end diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb index 854f0672a83..ed01060946a 100644 --- a/test/remote/gateways/remote_stripe_test.rb +++ b/test/remote/gateways/remote_stripe_test.rb @@ -423,6 +423,8 @@ def test_invalid_login assert_match "Invalid API Key provided", response.message end + # These "track data present" tests fail with invalid expiration dates. The + # test track data probably needs to be updated. def test_card_present_purchase @credit_card.track_data = '%B378282246310005^LONGSON/LONGBOB^1705101130504392?' assert response = @gateway.purchase(@amount, @credit_card, @options) diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index a7619782f10..59cf953e84e 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -611,18 +611,19 @@ def test_successful_refund_with_reverse_transfer def test_successful_refund_with_refund_fee_amount s = sequence("request") @gateway.expects(:ssl_request).returns(successful_partially_refunded_response).in_sequence(s) - @gateway.expects(:ssl_request).returns(successful_application_fee_list_response).in_sequence(s) - @gateway.expects(:ssl_request).returns(successful_refunded_application_fee_response).in_sequence(s) + @gateway.expects(:ssl_request).returns(successful_fetch_application_fee_response).in_sequence(s) + @gateway.expects(:ssl_request).returns(successful_partially_refunded_application_fee_response).in_sequence(s) assert response = @gateway.refund(@refund_amount, 'ch_test_charge', :refund_fee_amount => 100) assert_success response end + # What is the significance of this??? it's to test that the first response is used as primary. so identical to above with an extra assertion def test_refund_with_fee_response_gives_a_charge_authorization s = sequence("request") @gateway.expects(:ssl_request).returns(successful_partially_refunded_response).in_sequence(s) - @gateway.expects(:ssl_request).returns(successful_application_fee_list_response).in_sequence(s) - @gateway.expects(:ssl_request).returns(successful_refunded_application_fee_response).in_sequence(s) + @gateway.expects(:ssl_request).returns(successful_fetch_application_fee_response).in_sequence(s) + @gateway.expects(:ssl_request).returns(successful_partially_refunded_application_fee_response).in_sequence(s) assert response = @gateway.refund(@refund_amount, 'ch_test_charge', :refund_fee_amount => 100) assert_success response @@ -632,17 +633,17 @@ def test_refund_with_fee_response_gives_a_charge_authorization def test_unsuccessful_refund_with_refund_fee_amount_when_application_fee_id_not_found s = sequence("request") @gateway.expects(:ssl_request).returns(successful_partially_refunded_response).in_sequence(s) - @gateway.expects(:ssl_request).returns(unsuccessful_application_fee_list_response).in_sequence(s) + @gateway.expects(:ssl_request).returns(unsuccessful_fetch_application_fee_response).in_sequence(s) assert response = @gateway.refund(@refund_amount, 'ch_test_charge', :refund_fee_amount => 100) assert_failure response - assert_match(/^Application fee id could not be found/, response.message) + assert_match(/^Application fee id could not be retrieved/, response.message) end def test_unsuccessful_refund_with_refund_fee_amount_when_refunding_application_fee s = sequence("request") @gateway.expects(:ssl_request).returns(successful_partially_refunded_response).in_sequence(s) - @gateway.expects(:ssl_request).returns(successful_application_fee_list_response).in_sequence(s) + @gateway.expects(:ssl_request).returns(successful_fetch_application_fee_response).in_sequence(s) @gateway.expects(:ssl_request).returns(generic_error_response).in_sequence(s) assert response = @gateway.refund(@refund_amount, 'ch_test_charge', :refund_fee_amount => 100) @@ -1939,52 +1940,55 @@ def failed_void_response RESPONSE end - def successful_refunded_application_fee_response + def successful_partially_refunded_application_fee_response <<-RESPONSE { - "id": "fee_id", - "object": "application_fee", - "created": 1375375417, - "livemode": false, + "id": "fr_C8qmJKrZVMTjjF", + "object": "fee_refund", "amount": 10, + "balance_transaction": "txn_1BkZ4uAWOtgoysognvusG5N5", + "created": 1516027008, "currency": "usd", - "user": "acct_id", - "user_email": "acct_id", - "application": "ca_application", - "charge": "ch_test_charge", - "refunded": false, - "amount_refunded": 10 + "fee": "fee_1BkZ4rIPBJTitsenGWcxYWCZ", + "metadata": {} } RESPONSE end - def successful_application_fee_list_response + def successful_fetch_application_fee_response <<-RESPONSE { - "object": "list", - "count": 2, - "url": "/v1/application_fees", - "data": [ - { - "object": "application_fee", - "id": "application_fee_id" - }, - { - "object": "another_fee", - "id": "another_fee_id" - } - ] + "id": "ch_1Bja3MIPBJTitsenv28Gy6iN", + "object": "charge", + "amount": 100, + "amount_refunded": 100, + "application": "ca_6E9gvTfZGEMknxpoHhC8xoeyMit55FAV", + "application_fee": "fee_1Bja3MIPBJTitsenKqV8Hc6R", + "balance_transaction": "txn_1Bja3OIPBJTitsenJ5amtW58", + "captured": true, + "created": 1515792428, + "currency": "usd", + "customer": null, + "description": "ActiveMerchant Test Purchase", + "destination": null, + "dispute": null, + "failure_code": null, + "failure_message": null, + "fraud_details": {}, + "invoice": null, + "livemode": false } RESPONSE end - def unsuccessful_application_fee_list_response + def unsuccessful_fetch_application_fee_response <<-RESPONSE { - "object": "list", - "count": 0, - "url": "/v1/application_fees", - "data": [] + "error": { + "type": "invalid_request_error", + "message": "No such charge: bad_auth", + "param": "id" + } } RESPONSE end From 5ea7c4a1833c166fe16ed0e5e318727bfb5e05a2 Mon Sep 17 00:00:00 2001 From: Joshua Nussbaum Date: Wed, 31 Jan 2018 13:33:08 -0500 Subject: [PATCH 307/677] Adds support for Google Pay sourced cards (#2725) --- CHANGELOG | 1 + .../billing/network_tokenization_credit_card.rb | 2 +- test/unit/network_tokenization_credit_card_test.rb | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 9517f5286b0..a85b0d92700 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -32,6 +32,7 @@ * Payeezy: Surface gateway_message on failure [curiousepic] #2717 * Payment Express: Scrub merchant password [curiousepic] #2723 * Stripe: Fix Partial Application Fee Refunds [curiousepic] #2713 +* GooglePay: Support network tokenized cards [joshnuss] #2725 == Version 1.76.0 (January 3, 2018) * PayU Latam: Change default text for description [nfarve] #2669 diff --git a/lib/active_merchant/billing/network_tokenization_credit_card.rb b/lib/active_merchant/billing/network_tokenization_credit_card.rb index cab84f2b748..955557a67d0 100644 --- a/lib/active_merchant/billing/network_tokenization_credit_card.rb +++ b/lib/active_merchant/billing/network_tokenization_credit_card.rb @@ -17,7 +17,7 @@ class NetworkTokenizationCreditCard < CreditCard attr_accessor :payment_cryptogram, :eci, :transaction_id attr_writer :source - SOURCES = [:apple_pay, :android_pay] + SOURCES = %i(apple_pay android_pay google_pay) def source if defined?(@source) && SOURCES.include?(@source) diff --git a/test/unit/network_tokenization_credit_card_test.rb b/test/unit/network_tokenization_credit_card_test.rb index 30a6ec95557..c864240d91e 100644 --- a/test/unit/network_tokenization_credit_card_test.rb +++ b/test/unit/network_tokenization_credit_card_test.rb @@ -14,6 +14,9 @@ def setup @tokenized_android_pay_card = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new({ source: :android_pay }) + @tokenized_google_pay_card = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new({ + source: :google_pay + }) @tokenized_bogus_pay_card = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new({ source: :bogus_pay }) @@ -27,6 +30,7 @@ def test_credit_card? assert @tokenized_card.credit_card? assert @tokenized_apple_pay_card.credit_card? assert @tokenized_android_pay_card.credit_card? + assert @tokenized_google_pay_card.credit_card? assert @tokenized_bogus_pay_card.credit_card? end @@ -38,6 +42,7 @@ def test_source assert_equal @tokenized_card.source, :apple_pay assert_equal @tokenized_apple_pay_card.source, :apple_pay assert_equal @tokenized_android_pay_card.source, :android_pay + assert_equal @tokenized_google_pay_card.source, :google_pay assert_equal @tokenized_bogus_pay_card.source, :apple_pay end end From 114ec71e9d8a9a51d867a35753d308868a993a32 Mon Sep 17 00:00:00 2001 From: Pierre Nespo Date: Wed, 31 Jan 2018 16:47:00 -0500 Subject: [PATCH 308/677] Release v1.77.0 --- CHANGELOG | 2 ++ lib/active_merchant/version.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a85b0d92700..ba311609b2b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ = ActiveMerchant CHANGELOG == HEAD + +== Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 * Forte: ensure unit tests are local-only [bpollack] #2696 * Moneris US: ensure unit tests are local-only [bpollack] #2696 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index be277160218..fcd84d92701 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.76.0" + VERSION = "1.77.0" end From 55b7b2576cdcadaf9eb5412f2c21a7f908eaed81 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Wed, 31 Jan 2018 18:07:42 -0500 Subject: [PATCH 309/677] Orbital: Handles level 2 tax data correctly Level 2 tax amount may be passed in as a string, which was throwing an error. This will now convert tax data to an integer format. Closes #2729 Remote Tests: 22 tests, 137 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit Tests: 69 tests, 418 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/orbital.rb | 4 ++-- test/remote/gateways/remote_orbital_test.rb | 4 ++-- test/unit/gateways/orbital_test.rb | 8 ++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ba311609b2b..a9852d24657 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Orbital: Correct level 2 tax handling [deedeelavinder] #2729 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index f9f3db25de7..e6527508ba3 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -356,8 +356,8 @@ def add_soft_descriptors_from_hash(xml, soft_desc) def add_level_2_tax(xml, options={}) if (level_2 = options[:level_2_data]) - xml.tag! :TaxInd, level_2[:tax_indicator] if [TAX_NOT_PROVIDED, TAX_INCLUDED, NON_TAXABLE_TRANSACTION].include?(level_2[:tax_indicator]) - xml.tag! :Tax, amount(level_2[:tax]) if level_2[:tax] + xml.tag! :TaxInd, level_2[:tax_indicator] if [TAX_NOT_PROVIDED, TAX_INCLUDED, NON_TAXABLE_TRANSACTION].include?(level_2[:tax_indicator].to_i) + xml.tag! :Tax, level_2[:tax].to_i if level_2[:tax] end end diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb index c5329b1be40..dc923dd8518 100644 --- a/test/remote/gateways/remote_orbital_test.rb +++ b/test/remote/gateways/remote_orbital_test.rb @@ -23,8 +23,8 @@ def setup :jcb => "3566002020140006"} @level_2_options = { - tax_indicator: 1, - tax: 10, + tax_indicator: "1", + tax: "75", advice_addendum_1: 'taa1 - test', advice_addendum_2: 'taa2 - test', advice_addendum_3: 'taa3 - test', diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index c029f71dcf9..0dc06032ce2 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -15,8 +15,8 @@ def setup @customer_ref_num = "ABC" @level_2 = { - tax_indicator: 1, - tax: 10, + tax_indicator: "1", + tax: "10", advice_addendum_1: 'taa1 - test', advice_addendum_2: 'taa2 - test', advice_addendum_3: 'taa3 - test', @@ -46,8 +46,8 @@ def test_level_2_data stub_comms do @gateway.purchase(50, credit_card, @options.merge(level_2_data: @level_2)) end.check_request do |endpoint, data, headers| - assert_match %{#{@level_2[:tax_indicator]}}, data - assert_match %{#{@level_2[:tax]}}, data + assert_match %{#{@level_2[:tax_indicator].to_i}}, data + assert_match %{#{@level_2[:tax].to_i}}, data assert_match %{#{@level_2[:advice_addendum_1]}}, data assert_match %{#{@level_2[:advice_addendum_2]}}, data assert_match %{#{@level_2[:advice_addendum_3]}}, data From 65fd674cb716f5fe70db0e3b0bfcaeccfd14eff4 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder Date: Fri, 2 Feb 2018 07:03:54 -0500 Subject: [PATCH 310/677] Payeezy: changes assessment of store endpoint Although 'store' does not officially require a 'transaction_type', it is used here to determine the correct endpoint for a 'store' request. Closes #2731 Unit Tests: 32 tests, 153 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote Tests: 27 tests, 98 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/payeezy.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a9852d24657..45025ec49cd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * Orbital: Correct level 2 tax handling [deedeelavinder] #2729 +* Payeezy: Change determination method of endpoint for store request [deedeelavinder] #2731 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index 2bdd62f7ac4..9361b258f8a 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -74,7 +74,7 @@ def refund(amount, authorization, options = {}) end def store(payment_method, options = {}) - params = {} + params = {transaction_type: 'store'} add_creditcard_for_tokenization(params, payment_method, options) @@ -149,7 +149,7 @@ def add_creditcard_for_tokenization(params, payment_method, options) end def is_store_action?(params) - params[:ta_token].present? + params[:transaction_type] == 'store' end def add_payment_method(params, payment_method, options) From 10be4846ff4a1f4a26dac759efef02b4eb2aebf6 Mon Sep 17 00:00:00 2001 From: David Perry Date: Wed, 31 Jan 2018 12:06:42 -0500 Subject: [PATCH 311/677] Adyen: Return refusal_reason_raw when present Concatentates further detail of refusals onto the response's message. Closes #2728 Remote: 28 tests, 65 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 17 tests, 83 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 12 ++++++++---- test/unit/gateways/adyen_test.rb | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 45025ec49cd..c4e2f33694a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * Orbital: Correct level 2 tax handling [deedeelavinder] #2729 * Payeezy: Change determination method of endpoint for store request [deedeelavinder] #2731 +* Adyen: Return refusal_reason_raw when present [curiousepic] #2728 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index 68bfeae774e..e199ed15282 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -205,11 +205,15 @@ def success_from(action, response) end def message_from(action, response) - case action.to_s - when 'authorise' + return authorize_message_from(response) if action.to_s == 'authorise' + response['response'] || response['message'] + end + + def authorize_message_from(response) + if response['refusalReason'] && response['additionalData'] && response['additionalData']['refusalReasonRaw'] + "#{response['refusalReason']} | #{response['additionalData']['refusalReasonRaw']}" + else response['refusalReason'] || response['resultCode'] || response['message'] - when 'capture', 'refund', 'cancel' - response['response'] || response['message'] end end diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index 08b2d88ad95..933a76af945 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -146,6 +146,14 @@ def test_failed_verify assert response.test? end + def test_failed_avs_check_returns_refusal_reason_raw + @gateway.expects(:ssl_post).returns(failed_authorize_avs_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_equal 'Refused | 05 : Do not honor', response.message + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed @@ -341,4 +349,10 @@ def failed_verify_response } RESPONSE end + + def failed_authorize_avs_response + <<-RESPONSE + {\"additionalData\":{\"cvcResult\":\"0 Unknown\",\"fraudResultType\":\"GREEN\",\"avsResult\":\"3 AVS unavailable\",\"fraudManualReview\":\"false\",\"avsResultRaw\":\"U\",\"refusalReasonRaw\":\"05 : Do not honor\",\"authorisationMid\":\"494619000001174\",\"acquirerCode\":\"AdyenVisa_BR_494619\",\"acquirerReference\":\"802320302458\",\"acquirerAccountCode\":\"AdyenVisa_BR_Cabify\"},\"fraudResult\":{\"accountScore\":0,\"results\":[{\"FraudCheckResult\":{\"accountScore\":0,\"checkId\":46,\"name\":\"DistinctCountryUsageByShopper\"}}]},\"pspReference\":\"1715167376763498\",\"refusalReason\":\"Refused\",\"resultCode\":\"Refused\"} + RESPONSE + end end From 37000bf94e9eedfb3d8f325faf7bf1e313dfead0 Mon Sep 17 00:00:00 2001 From: Niaja Date: Tue, 6 Feb 2018 10:05:54 -0500 Subject: [PATCH 312/677] Payeezy: Update Store This updates the store method based on changes in the Payeezy documentation taking effect at the end of March. Loaded suite test/remote/gateways/remote_payeezy_test ........................... 27 tests, 98 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/payeezy_test ................................ 32 tests, 153 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/payeezy.rb | 32 +++++++------------ test/remote/gateways/remote_payeezy_test.rb | 2 +- test/unit/gateways/payeezy_test.rb | 6 ++-- 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c4e2f33694a..bc85dc01ca0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * Orbital: Correct level 2 tax handling [deedeelavinder] #2729 * Payeezy: Change determination method of endpoint for store request [deedeelavinder] #2731 * Adyen: Return refusal_reason_raw when present [curiousepic] #2728 +* Payeezy: Update Store method [nfarve] #2733 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index 9361b258f8a..509d9c576a4 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -136,16 +136,10 @@ def add_authorization_info(params, authorization) def add_creditcard_for_tokenization(params, payment_method, options) params[:apikey] = @options[:apikey] - params[:js_security_key] = options[:js_security_key] params[:ta_token] = options[:ta_token] - params[:callback] = 'Payeezy.callback' params[:type] = 'FDToken' - card = add_card_data(payment_method) - params['credit_card.type'] = card[:type] - params['credit_card.cardholder_name'] = card[:cardholder_name] - params['credit_card.card_number'] = card[:card_number] - params['credit_card.exp_date'] = card[:exp_date] - params['credit_card.cvv'] = card[:cvv] + params[:credit_card] = add_card_data(payment_method) + params[:auth] = 'false' end def is_store_action?(params) @@ -277,18 +271,12 @@ def base_url(options) end def endpoint(params) - is_store_action?(params) ? '/securitytokens' : '/transactions' + is_store_action?(params) ? '/transactions/tokens' : '/transactions' end def api_request(url, params) - if is_store_action?(params) - callback = ssl_request(:get, "#{url}?#{post_data(params)}", nil, {}) - payload = callback[/{(?:\n|.)*}/] - parse(payload) - else - body = params.to_json - parse(ssl_post(url, body, headers(body))) - end + body = params.to_json + parse(ssl_post(url, body, headers(body))) end def post_data(params) @@ -331,6 +319,8 @@ def success_from(response) response['transaction_status'] == 'approved' elsif response['results'] response['results']['status'] == 'success' + elsif response['status'] + response['status'] == 'success' else false end @@ -360,10 +350,10 @@ def authorization_from(params, response) if is_store_action?(params) if success_from(response) [ - response['results']['token']['type'], - response['results']['token']['cardholder_name'], - response['results']['token']['exp_date'], - response['results']['token']['value'] + response['token']['type'], + response['token']['cardholder_name'], + response['token']['exp_date'], + response['token']['value'] ].join('|') else nil diff --git a/test/remote/gateways/remote_payeezy_test.rb b/test/remote/gateways/remote_payeezy_test.rb index ecc1c09076a..e3f157df6e1 100644 --- a/test/remote/gateways/remote_payeezy_test.rb +++ b/test/remote/gateways/remote_payeezy_test.rb @@ -10,7 +10,7 @@ def setup @options = { :billing_address => address, :merchant_ref => 'Store Purchase', - :ta_token => '120' + :ta_token => 'NOIW' } @options_mdd = { soft_descriptors: { diff --git a/test/unit/gateways/payeezy_test.rb b/test/unit/gateways/payeezy_test.rb index c257f47aa85..b6b73fad994 100644 --- a/test/unit/gateways/payeezy_test.rb +++ b/test/unit/gateways/payeezy_test.rb @@ -463,13 +463,13 @@ def successful_purchase_echeck_response def successful_store_response <<-RESPONSE - "\n Payeezy.callback({\n \t\"status\":201,\n \t\"results\":{\"correlation_id\":\"228.0715530338021\",\"status\":\"success\",\"type\":\"FDToken\",\"token\":{\"type\":\"Visa\",\"cardholder_name\":\"Longbob Longsen\",\"exp_date\":\"0918\",\"value\":\"9715442510284242\"}}\n })\n " - RESPONSE + {\"correlation_id\":\"124.1792879391754\",\"status\":\"success\",\"type\":\"FDToken\",\"token\":{\"type\":\"Visa\",\"cardholder_name\":\"Longbob Longsen\",\"exp_date\":\"0919\",\"value\":\"9045348309244242\"}} + RESPONSE end def failed_store_response <<-RESPONSE - "\n Payeezy.callback({\n \t\"status\":400,\n \t\"results\":{\"correlation_id\":\"228.0715669121910\",\"status\":\"failed\",\"Error\":{\"messages\":[{\"code\":\"invalid_card_number\",\"description\":\"The credit card number check failed\"}]},\"type\":\"FDToken\"}\n })\n " + {\"correlation_id\":\"124.1792940806770\",\"status\":\"failed\",\"Error\":{\"messages\":[{\"code\":\"invalid_card_number\",\"description\":\"The credit card number check failed\"}]},\"type\":\"FDToken\"} RESPONSE end From 30e4cd191e67e829d67fc94ce27a9874aba89cad Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 6 Feb 2018 13:24:01 -0500 Subject: [PATCH 313/677] CenPOS: Remove gzip encoding header Production transactions are now failing due to the gzip encoding header; this removes it. 6 remote tests are failing due to changes in response values which shouldn't be a result of this change. Closes #2735 Remote: 23 tests, 51 assertions, 6 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 73.913% passed Unit: 23 tests, 98 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/cenpos.rb | 2 +- test/remote/gateways/remote_cenpos_test.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index bc85dc01ca0..4a56e660f6b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Payeezy: Change determination method of endpoint for store request [deedeelavinder] #2731 * Adyen: Return refusal_reason_raw when present [curiousepic] #2728 * Payeezy: Update Store method [nfarve] #2733 +* CenPOS: Remove gzip encoding header [curiousepic] #2735 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/cenpos.rb b/lib/active_merchant/billing/gateways/cenpos.rb index cc208e39661..e019001d464 100644 --- a/lib/active_merchant/billing/gateways/cenpos.rb +++ b/lib/active_merchant/billing/gateways/cenpos.rb @@ -180,7 +180,7 @@ def commit(action, post) def headers { - "Accept-Encoding" => "gzip,deflate", + "Accept-Encoding" => "identity", "Content-Type" => "text/xml;charset=UTF-8", "SOAPAction" => "http://tempuri.org/Transactional/ProcessCreditCard" } diff --git a/test/remote/gateways/remote_cenpos_test.rb b/test/remote/gateways/remote_cenpos_test.rb index 64adf71cf44..29024454559 100644 --- a/test/remote/gateways/remote_cenpos_test.rb +++ b/test/remote/gateways/remote_cenpos_test.rb @@ -107,7 +107,7 @@ def test_failed_capture capture = @gateway.capture(@amount, response.authorization) capture = @gateway.capture(@amount, response.authorization) assert_failure capture - assert_equal "Duplicated transaction", capture.message + assert_equal "Duplicated force transaction.", capture.message end def test_successful_void From dc38b09039cb99a75d18afa81a2316aac1a3261b Mon Sep 17 00:00:00 2001 From: Niaja Date: Tue, 6 Feb 2018 15:05:18 -0500 Subject: [PATCH 314/677] Mercado Pago: Allow binary_mode to be changed Allows binary_mode to be set to a value rather than the current default of true. Loaded suite test/unit/gateways/mercado_pago_test Started ................... 19 tests, 95 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_mercado_pago_test Started ................. 17 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/mercado_pago.rb | 2 +- test/remote/gateways/remote_mercado_pago_test.rb | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 4a56e660f6b..d05908afd53 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * Adyen: Return refusal_reason_raw when present [curiousepic] #2728 * Payeezy: Update Store method [nfarve] #2733 * CenPOS: Remove gzip encoding header [curiousepic] #2735 +* Mercado Pago: Allow binary_mode to be changed [nfarve] #2736 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index 65e4b40aef2..bc4a6dafa54 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -102,7 +102,7 @@ def purchase_request(money, payment, options = {}) add_additional_data(post, options) add_customer_data(post, payment, options) add_address(post, options) - post[:binary_mode] = true + post[:binary_mode] = (options[:binary_mode].nil? ? true : options[:binary_mode]) post end diff --git a/test/remote/gateways/remote_mercado_pago_test.rb b/test/remote/gateways/remote_mercado_pago_test.rb index 43e5e659965..415de94fbb2 100644 --- a/test/remote/gateways/remote_mercado_pago_test.rb +++ b/test/remote/gateways/remote_mercado_pago_test.rb @@ -21,6 +21,13 @@ def test_successful_purchase assert_equal 'accredited', response.message end + def test_successful_purchase_with_binary_false + @options.update(binary_mode: false) + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'accredited', response.message + end + def test_successful_purchase_with_american_express amex_card = credit_card('375365153556885', brand: 'american_express', verification_value: '1234') From 33b2ac2ccb36aa4f19932f45731857d2b9badccb Mon Sep 17 00:00:00 2001 From: Niaja Date: Tue, 6 Feb 2018 15:05:18 -0500 Subject: [PATCH 315/677] Mercado Pago: Allow binary_mode to be changed Allows binary_mode to be set to a value rather than the current default of true. Loaded suite test/unit/gateways/mercado_pago_test Started ................... 19 tests, 95 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_mercado_pago_test Started ................. 17 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/mercado_pago.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index bc4a6dafa54..c7262d47bfd 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -210,7 +210,7 @@ def success_from(action, response) if action == "refund" response["error"].nil? else - ["active", "approved", "authorized", "cancelled"].include?(response["status"]) + ["active", "approved", "authorized", "cancelled", "in_process"].include?(response["status"]) end end From 1a208e1d490c157c435488db2b8fe2669bc9d040 Mon Sep 17 00:00:00 2001 From: David Perry Date: Wed, 7 Feb 2018 16:05:29 -0500 Subject: [PATCH 316/677] Stripe: Accept strings for refund_fee_amount This now accounts for a string value for the refund_fee_amount or a value of 0 when requesting refunds through Stripe Connect. Closes #2738 Remote (2 failing for stale test card data): 59 tests, 253 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 96.6102% passed Connect Remote: 4 tests, 14 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 3 tests, 10 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/stripe.rb | 8 ++++---- test/remote/gateways/remote_stripe_connect_test.rb | 13 ++++++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d05908afd53..ce4d4737047 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * Payeezy: Update Store method [nfarve] #2733 * CenPOS: Remove gzip encoding header [curiousepic] #2735 * Mercado Pago: Allow binary_mode to be changed [nfarve] #2736 +* Stripe: Accept strings for refund_fee_amount [curiousepic] #2738 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index ec773c6ad64..616ad1d4a82 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -149,10 +149,10 @@ def refund(money, identification, options = {}) MultiResponse.run(:first) do |r| r.process { commit(:post, "charges/#{CGI.escape(identification)}/refunds", post, options) } - return r unless options[:refund_fee_amount] - - r.process { fetch_application_fee(identification, options) } - r.process { refund_application_fee(options[:refund_fee_amount], application_fee_from_response(r.responses.last), options) } + if options[:refund_fee_amount] && options[:refund_fee_amount].to_s != '0' + r.process { fetch_application_fee(identification, options) } + r.process { refund_application_fee(options[:refund_fee_amount].to_i, application_fee_from_response(r.responses.last), options) } + end end end diff --git a/test/remote/gateways/remote_stripe_connect_test.rb b/test/remote/gateways/remote_stripe_connect_test.rb index 3843a46a79a..2117eb43b92 100644 --- a/test/remote/gateways/remote_stripe_connect_test.rb +++ b/test/remote/gateways/remote_stripe_connect_test.rb @@ -36,7 +36,7 @@ def test_successful_refund_with_application_fee def test_refund_partial_application_fee assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:application_fee => 12)) - assert refund = @gateway.refund(@amount-20, response.authorization, @options.merge(:refund_fee_amount => 10)) + assert refund = @gateway.refund(@amount-20, response.authorization, @options.merge(:refund_fee_amount => "10")) assert_success refund # Verify the application fee is partially refunded @@ -46,4 +46,15 @@ def test_refund_partial_application_fee assert_equal "Application fee could not be refunded: Refund amount ($0.10) is greater than unrefunded amount on fee ($0.02)", refund_check.message end + def test_refund_application_fee_amount_zero + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:application_fee => 12)) + assert refund = @gateway.refund(@amount-20, response.authorization, @options.merge(:refund_fee_amount => "0")) + assert_success refund + + # Verify the application fee is not refunded + fetch_fee_id = @gateway.send(:fetch_application_fee, response.authorization, @options) + fee_id = @gateway.send(:application_fee_from_response, fetch_fee_id) + refund_check = @gateway.send(:refund_application_fee, 14, fee_id, @options) + assert_equal "Application fee could not be refunded: Refund amount ($0.14) is greater than fee amount ($0.12)", refund_check.message + end end From e4accf2b75731275f0037d8faa77caa0c7d2a6ae Mon Sep 17 00:00:00 2001 From: David Perry Date: Fri, 9 Feb 2018 15:41:22 -0500 Subject: [PATCH 317/677] Orbital: Complete scrub test coverage Two fields scrubbed by the adapter were not asserted in the remote scrub test. Closes #2739 Remote: 22 tests, 139 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 69 tests, 418 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + test/remote/gateways/remote_orbital_test.rb | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index ce4d4737047..671a8355354 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * CenPOS: Remove gzip encoding header [curiousepic] #2735 * Mercado Pago: Allow binary_mode to be changed [nfarve] #2736 * Stripe: Accept strings for refund_fee_amount [curiousepic] #2738 +* Orbital: Complete scrub test coverage [curiousepic] #2739 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb index dc923dd8518..03642b603b9 100644 --- a/test/remote/gateways/remote_orbital_test.rb +++ b/test/remote/gateways/remote_orbital_test.rb @@ -12,6 +12,7 @@ def setup @options = { :order_id => generate_unique_id, :address => address, + :merchant_id => 'merchant1234' } @cards = { @@ -293,5 +294,7 @@ def test_transcript_scrubbing assert_scrubbed(@credit_card.number, transcript) assert_scrubbed(@credit_card.verification_value, transcript) assert_scrubbed(@gateway.options[:password], transcript) + assert_scrubbed(@gateway.options[:login], transcript) + assert_scrubbed(@gateway.options[:merchant_id], transcript) end end From febcb8d0f0781fede60daf4f4fbab8c733886708 Mon Sep 17 00:00:00 2001 From: David Perry Date: Fri, 9 Feb 2018 16:46:40 -0500 Subject: [PATCH 318/677] MIGS: Scrub sensitive data Closes #2740 Remote: 12 tests, 38 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 4 tests, 15 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/migs.rb | 12 ++++++++++ test/remote/gateways/remote_migs_test.rb | 25 ++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 671a8355354..f318cdbfc24 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * Mercado Pago: Allow binary_mode to be changed [nfarve] #2736 * Stripe: Accept strings for refund_fee_amount [curiousepic] #2738 * Orbital: Complete scrub test coverage [curiousepic] #2739 +* MIGS: Scrub sensitive data [curiousepic] #2740 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb index 867c080e973..9a9a938fc90 100644 --- a/lib/active_merchant/billing/gateways/migs.rb +++ b/lib/active_merchant/billing/gateways/migs.rb @@ -206,6 +206,18 @@ def test? @options[:login].start_with?('TEST') end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((&?CardNum=)\d*(&?)), '\1[FILTERED]\2'). + gsub(%r((&?CardSecurityCode=)\d*(&?)), '\1[FILTERED]\2'). + gsub(%r((&?AccessCode=)[^&]*(&?)), '\1[FILTERED]\2'). + gsub(%r((&?Password=)[^&]*(&?)), '\1[FILTERED]\2') + end + private def add_amount(post, money, options) diff --git a/test/remote/gateways/remote_migs_test.rb b/test/remote/gateways/remote_migs_test.rb index a1ba53a0551..c6b83c56195 100644 --- a/test/remote/gateways/remote_migs_test.rb +++ b/test/remote/gateways/remote_migs_test.rb @@ -109,6 +109,31 @@ def test_invalid_login assert_equal 'Required field vpc_Merchant was not present in the request', response.message end + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end + + def test_transcript_scrubbing_of_advanced_password + gateway = MigsGateway.new(fixtures(:migs).merge(advanced_login: 'advlogin', advanced_password: 'advpass')) + purchase = gateway.purchase(@amount, @credit_card, @options) + + transcript = capture_transcript(@gateway) do + gateway.refund(@amount, purchase.authorization, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:advanced_password], transcript) + end + private def assert_response_match(regexp, url) From 5ac46c41c5e532f8f7a4fbc001506de33a42c2c9 Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 12 Feb 2018 10:15:20 -0500 Subject: [PATCH 319/677] Worldpay US: Scrub sensitive data One remote test failing before and after changes, unrelated. Closes #2742 Remote: 15 tests, 45 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 93.3333% passed Unit: 16 tests, 71 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/worldpay_us.rb | 12 ++++++++++ .../gateways/remote_worldpay_us_test.rb | 22 +++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f318cdbfc24..a7165bfd629 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * Stripe: Accept strings for refund_fee_amount [curiousepic] #2738 * Orbital: Complete scrub test coverage [curiousepic] #2739 * MIGS: Scrub sensitive data [curiousepic] #2740 +* Worldpay US: Scrub sensitive data [curiousepic] #2742 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/worldpay_us.rb b/lib/active_merchant/billing/gateways/worldpay_us.rb index 21922940277..afd0847dcb3 100644 --- a/lib/active_merchant/billing/gateways/worldpay_us.rb +++ b/lib/active_merchant/billing/gateways/worldpay_us.rb @@ -72,6 +72,18 @@ def verify(credit_card, options={}) end end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((&?merchantpin=)[^&]*)i, '\1[FILTERED]'). + gsub(%r((&?ccnum=)[^&]*)i, '\1[FILTERED]'). + gsub(%r((&?ckno=)[^&]*)i, '\1[FILTERED]'). + gsub(%r((&?cvv2=)[^&]*)i, '\1[FILTERED]') + end + private def url(options) diff --git a/test/remote/gateways/remote_worldpay_us_test.rb b/test/remote/gateways/remote_worldpay_us_test.rb index 933127f769e..b03d6df75b3 100644 --- a/test/remote/gateways/remote_worldpay_us_test.rb +++ b/test/remote/gateways/remote_worldpay_us_test.rb @@ -5,9 +5,9 @@ def setup @gateway = WorldpayUsGateway.new(fixtures(:worldpay_us)) @amount = 100 - @credit_card = credit_card('4446661234567892') + @credit_card = credit_card('4446661234567892', :verification_value => '987') @declined_card = credit_card('4000300011112220') - @check = check + @check = check(:number => '12345654321') @options = { order_id: generate_unique_id, @@ -116,4 +116,22 @@ def test_invalid_login assert response.message =~ /DECLINED/ end + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:merchantpin], transcript) + + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @check, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@check.number, transcript) + assert_scrubbed(@gateway.options[:merchantpin], transcript) + end end From e215d7434cd1bb4ca22e1c83fb690a7bc96097d7 Mon Sep 17 00:00:00 2001 From: dtykocki Date: Tue, 13 Feb 2018 09:32:05 -0500 Subject: [PATCH 320/677] Remove Israel from WorldPay supported countries Resolves #2746 Remote: 23 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 37 tests, 210 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/worldpay.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a7165bfd629..cb7bb15e762 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Orbital: Complete scrub test coverage [curiousepic] #2739 * MIGS: Scrub sensitive data [curiousepic] #2740 * Worldpay US: Scrub sensitive data [curiousepic] #2742 +* WorldPay: Remove Israel from supported country list [dtykocki] #2746 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index 54746246ef7..bf0fbd8f61d 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -6,7 +6,7 @@ class WorldpayGateway < Gateway self.default_currency = 'GBP' self.money_format = :cents - self.supported_countries = %w(HK GB AU AD BE CH CY CZ DE DK ES FI FR GI GR HU IE IL IT LI LU MC MT NL NO NZ PL PT SE SG SI SM TR UM VA) + self.supported_countries = %w(HK GB AU AD BE CH CY CZ DE DK ES FI FR GI GR HU IE IT LI LU MC MT NL NO NZ PL PT SE SG SI SM TR UM VA) self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :laser, :switch] self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW) self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND) From 542d08f1bc66effb4716e2d8fcfed42493b6ac15 Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 12 Feb 2018 10:52:02 -0500 Subject: [PATCH 321/677] Optimal Payments: Scrub sensitive data Closes #2743 Remote: 15 tests, 71 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 19 tests, 74 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/optimal_payment.rb | 11 ++++ .../gateways/remote_optimal_payment_test.rb | 12 +++++ test/unit/gateways/optimal_payment_test.rb | 52 +++++++++++++++++++ 4 files changed, 76 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index cb7bb15e762..ccdc86ed918 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * MIGS: Scrub sensitive data [curiousepic] #2740 * Worldpay US: Scrub sensitive data [curiousepic] #2742 * WorldPay: Remove Israel from supported country list [dtykocki] #2746 +* Optimal Payments: Scrub sensitive data [curiousepic] #2743 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb index c1d2ced8671..a1633b8847d 100644 --- a/lib/active_merchant/billing/gateways/optimal_payment.rb +++ b/lib/active_merchant/billing/gateways/optimal_payment.rb @@ -59,6 +59,17 @@ def capture(money, authorization, options = {}) commit('ccSettlement', money, options) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((%3CstorePwd%3E).*(%3C(%3F|/)storePwd%3E))i, '\1[FILTERED]\2'). + gsub(%r((%3CcardNum%3E)\d*(%3C(%3F|/)cardNum%3E))i, '\1[FILTERED]\2'). + gsub(%r((%3Ccvd%3E)\d*(%3C(%3F|/)cvd%3E))i, '\1[FILTERED]\2') + end + private def parse_card_or_auth(card_or_auth, options) diff --git a/test/remote/gateways/remote_optimal_payment_test.rb b/test/remote/gateways/remote_optimal_payment_test.rb index f4a84194904..20f56fbd196 100644 --- a/test/remote/gateways/remote_optimal_payment_test.rb +++ b/test/remote/gateways/remote_optimal_payment_test.rb @@ -143,4 +143,16 @@ def test_invalid_login assert_failure response assert_equal 'invalid merchant account', response.message end + + # Password assertion hard-coded due to the value being the same as the login, which would cause a false-positive + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed('%3CstorePwd%3Etest%3C/storePwd%3E', transcript) + end end diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb index 1e0ddb93914..e927cb66fa0 100644 --- a/test/unit/gateways/optimal_payment_test.rb +++ b/test/unit/gateways/optimal_payment_test.rb @@ -232,6 +232,10 @@ def test_deprecated_options end end + def test_scrub + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + private def full_request @@ -384,4 +388,52 @@ def failed_purchase_response XML end + + def pre_scrubbed + <<-EOS +opening connection to webservices.test.optimalpayments.com:443... +opened +starting SSL for webservices.test.optimalpayments.com:443... +SSL established +<- "POST /creditcardWS/CreditCardServlet/v1 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: webservices.test.optimalpayments.com\r\nContent-Length: 1616\r\n\r\n" +<- "txnMode=ccPurchase&txnRequest=%3CccAuthRequestV1%20xmlns=%22http://www.optimalpayments.com/creditcard/xmlschema/v1%22%20xmlns:xsi=%22http://www.w3.org/2001/XMLSchema-instance%22%20xsi:schemaLocation=%22http://www.optimalpayments.com/creditcard/xmlschema/v1%22%3E%0A%20%20%3CmerchantAccount%3E%0A%20%20%20%20%3CaccountNum%3E1001134550%3C/accountNum%3E%0A%20%20%20%20%3CstoreID%3Etest%3C/storeID%3E%0A%20%20%20%20%3CstorePwd%3Etest%3C/storePwd%3E%0A%20%20%3C/merchantAccount%3E%0A%20%20%3CmerchantRefNum%3E1%3C/merchantRefNum%3E%0A%20%20%3Camount%3E1.0%3C/amount%3E%0A%20%20%3Ccard%3E%0A%20%20%20%20%3CcardNum%3E4387751111011%3C/cardNum%3E%0A%20%20%20%20%3CcardExpiry%3E%0A%20%20%20%20%20%20%3Cmonth%3E9%3C/month%3E%0A%20%20%20%20%20%20%3Cyear%3E2019%3C/year%3E%0A%20%20%20%20%3C/cardExpiry%3E%0A%20%20%20%20%3CcardType%3EVI%3C/cardType%3E%0A%20%20%20%20%3CcvdIndicator%3E1%3C/cvdIndicator%3E%0A%20%20%20%20%3Ccvd%3E123%3C/cvd%3E%0A%20%20%3C/card%3E%0A%20%20%3CbillingDetails%3E%0A%20%20%20%20%3CcardPayMethod%3EWEB%3C/cardPayMethod%3E%0A%20%20%20%20%3CfirstName%3EJim%3C/firstName%3E%0A%20%20%20%20%3ClastName%3ESmith%3C/lastName%3E%0A%20%20%20%20%3Cstreet%3E456%20My%20Street%3C/street%3E%0A%20%20%20%20%3Cstreet2%3EApt%201%3C/street2%3E%0A%20%20%20%20%3Ccity%3EOttawa%3C/city%3E%0A%20%20%20%20%3Cstate%3EON%3C/state%3E%0A%20%20%20%20%3Ccountry%3ECA%3C/country%3E%0A%20%20%20%20%3Czip%3EK1C2N6%3C/zip%3E%0A%20%20%20%20%3Cphone%3E(555)555-5555%3C/phone%3E%0A%20%20%20%20%3Cemail%3Eemail@example.com%3C/email%3E%0A%20%20%3C/billingDetails%3E%0A%20%20%3CcustomerIP%3E1.2.3.4%3C/customerIP%3E%0A%3C/ccAuthRequestV1%3E%0A" +-> "HTTP/1.1 200 OK\r\n" +-> "Server: WebServer32xS10i3\r\n" +-> "Content-Length: 632\r\n" +-> "X-ApplicationUid: GUID=610a301289c34e8254330b7edc724f5b\r\n" +-> "Content-Type: application/xml\r\n" +-> "Date: Mon, 12 Feb 2018 21:57:42 GMT\r\n" +-> "Connection: close\r\n" +-> "\r\n" +reading 632 bytes... +-> "<" +-> "?xml version=\"1.0\" encoding=\"UTF-8\"?>\n498871860ACCEPTED0No Error369231XMInternalResponseCode0SubErrorCode0InternalResponseDescriptionno_error2018-02-12T16:57:42.289-05:00false" +read 632 bytes +Conn close + EOS + end + + def post_scrubbed + <<-EOS +opening connection to webservices.test.optimalpayments.com:443... +opened +starting SSL for webservices.test.optimalpayments.com:443... +SSL established +<- "POST /creditcardWS/CreditCardServlet/v1 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: webservices.test.optimalpayments.com\r\nContent-Length: 1616\r\n\r\n" +<- "txnMode=ccPurchase&txnRequest=%3CccAuthRequestV1%20xmlns=%22http://www.optimalpayments.com/creditcard/xmlschema/v1%22%20xmlns:xsi=%22http://www.w3.org/2001/XMLSchema-instance%22%20xsi:schemaLocation=%22http://www.optimalpayments.com/creditcard/xmlschema/v1%22%3E%0A%20%20%3CmerchantAccount%3E%0A%20%20%20%20%3CaccountNum%3E1001134550%3C/accountNum%3E%0A%20%20%20%20%3CstoreID%3Etest%3C/storeID%3E%0A%20%20%20%20%3CstorePwd%3E[FILTERED]%3C/storePwd%3E%0A%20%20%3C/merchantAccount%3E%0A%20%20%3CmerchantRefNum%3E1%3C/merchantRefNum%3E%0A%20%20%3Camount%3E1.0%3C/amount%3E%0A%20%20%3Ccard%3E%0A%20%20%20%20%3CcardNum%3E[FILTERED]%3C/cardNum%3E%0A%20%20%20%20%3CcardExpiry%3E%0A%20%20%20%20%20%20%3Cmonth%3E9%3C/month%3E%0A%20%20%20%20%20%20%3Cyear%3E2019%3C/year%3E%0A%20%20%20%20%3C/cardExpiry%3E%0A%20%20%20%20%3CcardType%3EVI%3C/cardType%3E%0A%20%20%20%20%3CcvdIndicator%3E1%3C/cvdIndicator%3E%0A%20%20%20%20%3Ccvd%3E[FILTERED]%3C/cvd%3E%0A%20%20%3C/card%3E%0A%20%20%3CbillingDetails%3E%0A%20%20%20%20%3CcardPayMethod%3EWEB%3C/cardPayMethod%3E%0A%20%20%20%20%3CfirstName%3EJim%3C/firstName%3E%0A%20%20%20%20%3ClastName%3ESmith%3C/lastName%3E%0A%20%20%20%20%3Cstreet%3E456%20My%20Street%3C/street%3E%0A%20%20%20%20%3Cstreet2%3EApt%201%3C/street2%3E%0A%20%20%20%20%3Ccity%3EOttawa%3C/city%3E%0A%20%20%20%20%3Cstate%3EON%3C/state%3E%0A%20%20%20%20%3Ccountry%3ECA%3C/country%3E%0A%20%20%20%20%3Czip%3EK1C2N6%3C/zip%3E%0A%20%20%20%20%3Cphone%3E(555)555-5555%3C/phone%3E%0A%20%20%20%20%3Cemail%3Eemail@example.com%3C/email%3E%0A%20%20%3C/billingDetails%3E%0A%20%20%3CcustomerIP%3E1.2.3.4%3C/customerIP%3E%0A%3C/ccAuthRequestV1%3E%0A" +-> "HTTP/1.1 200 OK\r\n" +-> "Server: WebServer32xS10i3\r\n" +-> "Content-Length: 632\r\n" +-> "X-ApplicationUid: GUID=610a301289c34e8254330b7edc724f5b\r\n" +-> "Content-Type: application/xml\r\n" +-> "Date: Mon, 12 Feb 2018 21:57:42 GMT\r\n" +-> "Connection: close\r\n" +-> "\r\n" +reading 632 bytes... +-> "<" +-> "?xml version=\"1.0\" encoding=\"UTF-8\"?>\n498871860ACCEPTED0No Error369231XMInternalResponseCode0SubErrorCode0InternalResponseDescriptionno_error2018-02-12T16:57:42.289-05:00false" +read 632 bytes +Conn close + EOS + end end From 3a398935c08a4740c02d20eaad61a13c405ce10d Mon Sep 17 00:00:00 2001 From: David Perry Date: Mon, 12 Feb 2018 16:11:10 -0500 Subject: [PATCH 322/677] USA Epay Transaction: Scrub sensitive data Closes #2745 Remote: 20 tests, 73 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 41 tests, 241 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/usa_epay_transaction.rb | 12 +++ .../remote_usa_epay_transaction_test.rb | 18 ++++ .../gateways/usa_epay_transaction_test.rb | 102 ++++++++++++++++++ 4 files changed, 133 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index ccdc86ed918..8962cbc160d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * Worldpay US: Scrub sensitive data [curiousepic] #2742 * WorldPay: Remove Israel from supported country list [dtykocki] #2746 * Optimal Payments: Scrub sensitive data [curiousepic] #2743 +* USA Epay Transaction: Scrub sensitive data [curiousepic] #2745 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb index 65cde2fe40d..5b4cb4cb4e0 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb @@ -106,6 +106,18 @@ def void(authorization, options = {}) commit(command, post) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((&?UMcard=)\d*(&?))i, '\1[FILTERED]\2'). + gsub(%r((&?UMcvv2=)\d*(&?))i, '\1[FILTERED]\2'). + gsub(%r((&?UMmagstripe=)[^&]*)i, '\1[FILTERED]\2'). + gsub(%r((&?UMkey=)[^&]*)i, '\1[FILTERED]') + end + private def add_amount(post, money) diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb index 9aafa893b3f..8f6d6df64cf 100644 --- a/test/remote/gateways/remote_usa_epay_transaction_test.rb +++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb @@ -143,4 +143,22 @@ def test_failed_verify assert_match "Card Declined (00)", response.message end + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:login], transcript) + + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card_with_track_data, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card_with_track_data.track_data, transcript) + assert_scrubbed(@gateway.options[:login], transcript) + end end diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb index fda1226a1c8..ad3aa238617 100644 --- a/test/unit/gateways/usa_epay_transaction_test.rb +++ b/test/unit/gateways/usa_epay_transaction_test.rb @@ -374,6 +374,12 @@ def test_does_not_raise_error_on_missing_values end end + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + assert_equal @gateway.scrub(pre_scrubbed_track_data), post_scrubbed_track_data + end + private def assert_address(type, post, expected_first_name = nil, expected_last_name = nil) @@ -436,4 +442,100 @@ def successful_refund_response def successful_void_response "UMversion=2.9&UMstatus=Approved&UMauthCode=&UMrefNum=63812270&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=Transaction%20Voided%20Successfully&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled" end + + def pre_scrubbed + <<-EOS +opening connection to sandbox.usaepay.com:443... +opened +starting SSL for sandbox.usaepay.com:443... +SSL established +<- "POST /gate 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: sandbox.usaepay.com\r\nContent-Length: 774\r\n\r\n" +<- "UMamount=1.00&UMinvoice=&UMdescription=&UMcard=4000100011112224&UMcvv2=123&UMexpir=0919&UMname=Longbob+Longsen&UMbillfname=Jim&UMbilllname=Smith&UMbillcompany=Widgets+Inc&UMbillstreet=456+My+Street&UMbillstreet2=Apt+1&UMbillcity=Ottawa&UMbillstate=NC&UMbillzip=27614&UMbillcountry=CA&UMbillphone=%28555%29555-5555&UMshipfname=Jim&UMshiplname=Smith&UMshipcompany=Widgets+Inc&UMshipstreet=456+My+Street&UMshipstreet2=Apt+1&UMshipcity=Ottawa&UMshipstate=ON&UMshipzip=K1C2N6&UMshipcountry=CA&UMshipphone=%28555%29555-5555&UMstreet=456+My+Street&UMzip=27614&UMcommand=cc%3Asale&UMkey=4EoZ5U2Q55j976W7eplC71i6b7kn4pcV&UMsoftware=Active+Merchant&UMtestmode=0&UMhash=s%2F5268F91058BC9F9FA944693D799F324B2497B7247850A51E53226309FB2540F0%2F7b4c4f6a4e775141cc0e4e10c0388d9adeb47fd1%2Fn" +-> "HTTP/1.1 200 OK\r\n" +-> "Server: http\r\n" +-> "Date: Tue, 13 Feb 2018 18:17:20 GMT\r\n" +-> "Content-Type: text/html\r\n" +-> "Content-Length: 485\r\n" +-> "Connection: close\r\n" +-> "P3P: policyref=\"http://www.usaepay.com/w3c/p3p.xml\", CP=\"NON TAIa IVAa IVDa OUR NOR PHY ONL UNI FIN INT DEM\"\r\n" +-> "Strict-Transport-Security: max-age=15768000\r\n" +-> "\r\n" +reading 485 bytes... +-> "UMversion=2.9&UMstatus=Approved&UMauthCode=042366&UMrefNum=132020588&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=YYY&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=120&UMbatchRefNum=848&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=A&UMauthAmount=1&UMfiller=filled" +read 485 bytes +Conn close + EOS + end + + def post_scrubbed + <<-EOS +opening connection to sandbox.usaepay.com:443... +opened +starting SSL for sandbox.usaepay.com:443... +SSL established +<- "POST /gate 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: sandbox.usaepay.com\r\nContent-Length: 774\r\n\r\n" +<- "UMamount=1.00&UMinvoice=&UMdescription=&UMcard=[FILTERED]&UMcvv2=[FILTERED]&UMexpir=0919&UMname=Longbob+Longsen&UMbillfname=Jim&UMbilllname=Smith&UMbillcompany=Widgets+Inc&UMbillstreet=456+My+Street&UMbillstreet2=Apt+1&UMbillcity=Ottawa&UMbillstate=NC&UMbillzip=27614&UMbillcountry=CA&UMbillphone=%28555%29555-5555&UMshipfname=Jim&UMshiplname=Smith&UMshipcompany=Widgets+Inc&UMshipstreet=456+My+Street&UMshipstreet2=Apt+1&UMshipcity=Ottawa&UMshipstate=ON&UMshipzip=K1C2N6&UMshipcountry=CA&UMshipphone=%28555%29555-5555&UMstreet=456+My+Street&UMzip=27614&UMcommand=cc%3Asale&UMkey=[FILTERED]&UMsoftware=Active+Merchant&UMtestmode=0&UMhash=s%2F5268F91058BC9F9FA944693D799F324B2497B7247850A51E53226309FB2540F0%2F7b4c4f6a4e775141cc0e4e10c0388d9adeb47fd1%2Fn" +-> "HTTP/1.1 200 OK\r\n" +-> "Server: http\r\n" +-> "Date: Tue, 13 Feb 2018 18:17:20 GMT\r\n" +-> "Content-Type: text/html\r\n" +-> "Content-Length: 485\r\n" +-> "Connection: close\r\n" +-> "P3P: policyref=\"http://www.usaepay.com/w3c/p3p.xml\", CP=\"NON TAIa IVAa IVDa OUR NOR PHY ONL UNI FIN INT DEM\"\r\n" +-> "Strict-Transport-Security: max-age=15768000\r\n" +-> "\r\n" +reading 485 bytes... +-> "UMversion=2.9&UMstatus=Approved&UMauthCode=042366&UMrefNum=132020588&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=YYY&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=120&UMbatchRefNum=848&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=A&UMauthAmount=1&UMfiller=filled" +read 485 bytes +Conn close + EOS + end + + def pre_scrubbed_track_data + <<-EOS +opening connection to sandbox.usaepay.com:443... +opened +starting SSL for sandbox.usaepay.com:443... +SSL established +<- "POST /gate 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: sandbox.usaepay.com\r\nContent-Length: 382\r\n\r\n" +<- "UMamount=1.00&UMinvoice=&UMdescription=&UMmagstripe=%25B4000100011112224%5ELONGSEN%2FL.+%5E19091200000000000000%2A%2A123%2A%2A%2A%2A%2A%2A%3F&UMcardpresent=true&UMcommand=cc%3Asale&UMkey=4EoZ5U2Q55j976W7eplC71i6b7kn4pcV&UMsoftware=Active+Merchant&UMtestmode=0&UMhash=s%2FE27734F076643B23131E5432C1E225EFF982A73D350179EFC2F191CA499B59A4%2F13391bd14ab6e61058cc9a1b78f259a4c26aa8e1%2Fn" +-> "HTTP/1.1 200 OK\r\n" +-> "Server: http\r\n" +-> "Date: Tue, 13 Feb 2018 18:13:11 GMT\r\n" +-> "Content-Type: text/html\r\n" +-> "Content-Length: 485\r\n" +-> "Connection: close\r\n" +-> "P3P: policyref=\"http://www.usaepay.com/w3c/p3p.xml\", CP=\"NON TAIa IVAa IVDa OUR NOR PHY ONL UNI FIN INT DEM\"\r\n" +-> "Strict-Transport-Security: max-age=15768000\r\n" +-> "\r\n" +reading 485 bytes... +-> "UMversion=2.9&UMstatus=Approved&UMauthCode=042087&UMrefNum=132020522&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=YYY&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=120&UMbatchRefNum=848&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=A&UMauthAmount=1&UMfiller=filled" +read 485 bytes +Conn close + EOS + end + + def post_scrubbed_track_data + <<-EOS +opening connection to sandbox.usaepay.com:443... +opened +starting SSL for sandbox.usaepay.com:443... +SSL established +<- "POST /gate 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: sandbox.usaepay.com\r\nContent-Length: 382\r\n\r\n" +<- "UMamount=1.00&UMinvoice=&UMdescription=&UMmagstripe=[FILTERED]&UMcardpresent=true&UMcommand=cc%3Asale&UMkey=[FILTERED]&UMsoftware=Active+Merchant&UMtestmode=0&UMhash=s%2FE27734F076643B23131E5432C1E225EFF982A73D350179EFC2F191CA499B59A4%2F13391bd14ab6e61058cc9a1b78f259a4c26aa8e1%2Fn" +-> "HTTP/1.1 200 OK\r\n" +-> "Server: http\r\n" +-> "Date: Tue, 13 Feb 2018 18:13:11 GMT\r\n" +-> "Content-Type: text/html\r\n" +-> "Content-Length: 485\r\n" +-> "Connection: close\r\n" +-> "P3P: policyref=\"http://www.usaepay.com/w3c/p3p.xml\", CP=\"NON TAIa IVAa IVDa OUR NOR PHY ONL UNI FIN INT DEM\"\r\n" +-> "Strict-Transport-Security: max-age=15768000\r\n" +-> "\r\n" +reading 485 bytes... +-> "UMversion=2.9&UMstatus=Approved&UMauthCode=042087&UMrefNum=132020522&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=YYY&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=120&UMbatchRefNum=848&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=A&UMauthAmount=1&UMfiller=filled" +read 485 bytes +Conn close + EOS + end end From 63067a8536f9703c61fcacab460decdfd67f2869 Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 13 Feb 2018 14:05:24 -0500 Subject: [PATCH 323/677] MIGS: Add unit test for scrub Closes #2747 Remote: 12 tests, 38 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 5 tests, 17 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + test/unit/gateways/migs_test.rb | 77 ++++++++++++++++++++++++++++----- 2 files changed, 68 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8962cbc160d..a31ea19d161 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * WorldPay: Remove Israel from supported country list [dtykocki] #2746 * Optimal Payments: Scrub sensitive data [curiousepic] #2743 * USA Epay Transaction: Scrub sensitive data [curiousepic] #2745 +* MIGS: Add unit test for scrub [curiousepic] #2747 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/test/unit/gateways/migs_test.rb b/test/unit/gateways/migs_test.rb index 9dfcbce5ff0..869e1657a5d 100644 --- a/test/unit/gateways/migs_test.rb +++ b/test/unit/gateways/migs_test.rb @@ -11,32 +11,32 @@ def setup @credit_card = credit_card @amount = 100 - - @options = { + + @options = { :order_id => '1', :billing_address => address, :description => 'Store Purchase' } end - + def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) - + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response assert_success response - + # Replace with authorization number from the successful response assert_equal '123456', response.authorization end def test_unsuccessful_request @gateway.expects(:ssl_post).returns(failed_purchase_response) - + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response assert_failure response - + assert_equal '654321', response.authorization end @@ -70,8 +70,13 @@ def test_purchase_offsite_response assert_raise(SecurityError){@gateway.purchase_offsite_response(tampered_response2)} end + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + private - + # Place raw successful response from gateway here def successful_purchase_response build_response( @@ -79,7 +84,7 @@ def successful_purchase_response :TransactionNo => '123456' ) end - + # Place raw failed response from gateway here def failed_purchase_response build_response( @@ -87,8 +92,60 @@ def failed_purchase_response :TransactionNo => '654321' ) end - + def build_response(options) options.collect { |key, value| "vpc_#{key}=#{CGI.escape(value.to_s)}"}.join('&') end + + def pre_scrubbed + <<-EOS +opening connection to migs.mastercard.com.au:443... +opened +starting SSL for migs.mastercard.com.au:443... +SSL established +<- "POST /vpcdps 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: migs.mastercard.com.au\r\nContent-Length: 354\r\n\r\n" +<- "vpc_Amount=100&vpc_Currency=SAR&vpc_OrderInfo=1&vpc_CardNum=4987654321098769&vpc_CardSecurityCode=123&vpc_CardExp=2105&vpc_Version=1&vpc_Merchant=TESTH-STATION&vpc_AccessCode=F1CE6F32&vpc_Command=pay&vpc_MerchTxnRef=84c1f31ded35dea26ac297fd7ba092da&vpc_SecureHash=CD1B2B8BC325C6C8FC1A041AD6AC90821984277113DF708B16B37809E7B0EC33&vpc_SecureHashType=SHA256" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Tue, 13 Feb 2018 19:02:18 GMT\r\n" +-> "Expires: Sun, 15 Jul 1990 00:00:00 GMT\r\n" +-> "Pragma: no-cache\r\n" +-> "Cache-Control: no-cache\r\n" +-> "Content-Length: 595\r\n" +-> "P3P: CP=\"NOI DSP COR CURa ADMa TA1a OUR BUS IND UNI COM NAV INT\"\r\n" +-> "Content-Type: text/plain;charset=iso-8859-1\r\n" +-> "Connection: close\r\n" +-> "Set-Cookie: TS01c4b9ca=01fb8d8de2ba6ffaf7439497dd78d9b3348c82bcf24d4619e65a406161e57276b6b293e77732a293be63bf750213e588797bc86f05; Path=/; Secure; HTTPOnly\r\n" +-> "\r\n" +reading 595 bytes... +-> "vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=100&vpc_AuthorizeId=239491&vpc_BatchNo=20180214&vpc_CSCResultCode=Unsupported&vpc_Card=VC&vpc_Command=pay&vpc_Currency=SAR&vpc_Locale=en_SA&vpc_MerchTxnRef=84c1f31ded35dea26ac297fd7ba092da&vpc_Merchant=TESTH-STATION&vpc_Message=Approved&vpc_OrderInfo=1&vpc_ReceiptNo=804506239491&vpc_RiskOverallResult=ACC&vpc_SecureHash=99993E000461810D9F71B1A4FC5EA2D68DF6BA1F7EBA6A9FC544DA035627C03C&vpc_SecureHashType=SHA256&vpc_TransactionNo=372&vpc_TxnResponseCode=0&vpc_Version=1" +read 595 bytes +Conn close + EOS + end + + def post_scrubbed + <<-EOS +opening connection to migs.mastercard.com.au:443... +opened +starting SSL for migs.mastercard.com.au:443... +SSL established +<- "POST /vpcdps 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: migs.mastercard.com.au\r\nContent-Length: 354\r\n\r\n" +<- "vpc_Amount=100&vpc_Currency=SAR&vpc_OrderInfo=1&vpc_CardNum=[FILTERED]&vpc_CardSecurityCode=[FILTERED]&vpc_CardExp=2105&vpc_Version=1&vpc_Merchant=TESTH-STATION&vpc_AccessCode=[FILTERED]&vpc_Command=pay&vpc_MerchTxnRef=84c1f31ded35dea26ac297fd7ba092da&vpc_SecureHash=CD1B2B8BC325C6C8FC1A041AD6AC90821984277113DF708B16B37809E7B0EC33&vpc_SecureHashType=SHA256" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Tue, 13 Feb 2018 19:02:18 GMT\r\n" +-> "Expires: Sun, 15 Jul 1990 00:00:00 GMT\r\n" +-> "Pragma: no-cache\r\n" +-> "Cache-Control: no-cache\r\n" +-> "Content-Length: 595\r\n" +-> "P3P: CP=\"NOI DSP COR CURa ADMa TA1a OUR BUS IND UNI COM NAV INT\"\r\n" +-> "Content-Type: text/plain;charset=iso-8859-1\r\n" +-> "Connection: close\r\n" +-> "Set-Cookie: TS01c4b9ca=01fb8d8de2ba6ffaf7439497dd78d9b3348c82bcf24d4619e65a406161e57276b6b293e77732a293be63bf750213e588797bc86f05; Path=/; Secure; HTTPOnly\r\n" +-> "\r\n" +reading 595 bytes... +-> "vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=100&vpc_AuthorizeId=239491&vpc_BatchNo=20180214&vpc_CSCResultCode=Unsupported&vpc_Card=VC&vpc_Command=pay&vpc_Currency=SAR&vpc_Locale=en_SA&vpc_MerchTxnRef=84c1f31ded35dea26ac297fd7ba092da&vpc_Merchant=TESTH-STATION&vpc_Message=Approved&vpc_OrderInfo=1&vpc_ReceiptNo=804506239491&vpc_RiskOverallResult=ACC&vpc_SecureHash=99993E000461810D9F71B1A4FC5EA2D68DF6BA1F7EBA6A9FC544DA035627C03C&vpc_SecureHashType=SHA256&vpc_TransactionNo=372&vpc_TxnResponseCode=0&vpc_Version=1" +read 595 bytes +Conn close + EOS + end end From 6f720158ea08767cbe2ff71f44d8e3555f3fdd0d Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 13 Feb 2018 14:34:23 -0500 Subject: [PATCH 324/677] Worldpay US: Fix bank account scrub The wrong field was being scrubbed for the bank account number. Also adds unit tests for scrubbing. One known unrelated remote test failure. Closes #2748 Unit: 17 tests, 75 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 15 tests, 45 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 93.3333% passed --- CHANGELOG | 1 + .../billing/gateways/worldpay_us.rb | 2 +- .../gateways/remote_worldpay_us_test.rb | 2 +- test/unit/gateways/worldpay_us_test.rb | 98 +++++++++++++++++++ 4 files changed, 101 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a31ea19d161..939bdaa4112 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * Optimal Payments: Scrub sensitive data [curiousepic] #2743 * USA Epay Transaction: Scrub sensitive data [curiousepic] #2745 * MIGS: Add unit test for scrub [curiousepic] #2747 +* Worldpay US: Fix bank account scrub [curiousepic] #2748 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/worldpay_us.rb b/lib/active_merchant/billing/gateways/worldpay_us.rb index afd0847dcb3..084169424a5 100644 --- a/lib/active_merchant/billing/gateways/worldpay_us.rb +++ b/lib/active_merchant/billing/gateways/worldpay_us.rb @@ -80,7 +80,7 @@ def scrub(transcript) transcript. gsub(%r((&?merchantpin=)[^&]*)i, '\1[FILTERED]'). gsub(%r((&?ccnum=)[^&]*)i, '\1[FILTERED]'). - gsub(%r((&?ckno=)[^&]*)i, '\1[FILTERED]'). + gsub(%r((&?ckacct=)[^&]*)i, '\1[FILTERED]'). gsub(%r((&?cvv2=)[^&]*)i, '\1[FILTERED]') end diff --git a/test/remote/gateways/remote_worldpay_us_test.rb b/test/remote/gateways/remote_worldpay_us_test.rb index b03d6df75b3..db2adc37c01 100644 --- a/test/remote/gateways/remote_worldpay_us_test.rb +++ b/test/remote/gateways/remote_worldpay_us_test.rb @@ -131,7 +131,7 @@ def test_transcript_scrubbing end transcript = @gateway.scrub(transcript) - assert_scrubbed(@check.number, transcript) + assert_scrubbed(@check.account_number, transcript) assert_scrubbed(@gateway.options[:merchantpin], transcript) end end diff --git a/test/unit/gateways/worldpay_us_test.rb b/test/unit/gateways/worldpay_us_test.rb index 51082dc3743..55797ebbe2b 100644 --- a/test/unit/gateways/worldpay_us_test.rb +++ b/test/unit/gateways/worldpay_us_test.rb @@ -184,6 +184,12 @@ def test_backup_url assert_success response end + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + assert_equal @gateway.scrub(pre_scrubbed_check), post_scrubbed_check + end + private def successful_purchase_response @@ -428,4 +434,96 @@ def failed_void_response transid=0 ) end + + def pre_scrubbed + <<-EOS +opening connection to trans.worldpay.us:443... +opened +starting SSL for trans.worldpay.us:443... +SSL established +<- "POST /cgi-bin/process.cgi 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: trans.worldpay.us\r\nContent-Length: 425\r\n\r\n" +<- "acctid=MPNAB&action=ns_quicksale_cc&amount=1.00&ccname=Longbob+Longsen&ccnum=4446661234567892&ci_billaddr1=456+My+Street&ci_billaddr2=Apt+1&ci_billcity=Ottawa&ci_billcountry=CA&ci_billstate=ON&ci_billzip=K1C2N6&ci_companyname=Widgets+Inc&ci_email=&ci_ipaddress=&ci_phone=%28555%29555-5555¤cycode=USD&cvv2=987&expmon=09&expyear=2019&merchantordernumber=67f4f20082e79684f036f25dafe96304&merchantpin=1234567890&subid=SPREE" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Tue, 13 Feb 2018 19:28:27 GMT\r\n" +-> "Server: Apache\r\n" +-> "X-Frame-Options: SAMEORIGIN\r\n" +-> "Content-Type: text/html;charset=ISO-8859-1\r\n" +-> "Content-Length: 962\r\n" +-> "Connection: close\r\n" +-> "\r\n" +reading 962 bytes... +-> "\r\nAccepted=SALE:036586:477::919067116:N::N\r\nhistoryid=919067116\r\norderid=722189706\r\nAccepted=SALE:036586:477::919067116:N::N\r\nACCOUNTNUMBER=************7892\r\nACCTID=MPNAB\r\nauthcode=036586\r\nAuthNo=SALE:036586:477::919067116:N::N\r\nAVS_RESULT=N\r\nBATCHNUMBER=\r\nCVV2_RESULT=N\r\nDEBIT_TRACE_NUMBER=\r\nENTRYMETHOD=M\r\nhistoryid=919067116\r\nMERCHANT_DBA_ADDR=11121 Willows Road NE\r\nMERCHANT_DBA_CITY=Redmond\r\nMERCHANT_DBA_NAME=Merchant Partners\r\nMERCHANT_DBA_PHONE=4254979909\r\nMERCHANT_DBA_STATE=WA\r\nMERCHANTID=542929804946788\r\nMERCHANTORDERNUMBER=67f4f20082e79684f036f25dafe96304\r\norderid=722189706\r\nPAYTYPE=Visa\r\nPRODUCT_DESCRIPTION=\r\nReason=\r\nRECEIPT_FOOTER=Thank You\r\nrecurid=0\r\nrefcode=919067116-036586\r\nresult=1\r\nSEQUENCE_NUMBER=370609730\r\nStatus=Accepted\r\nSUBID=SPREE\r\nSYSTEMAUDITTRACENUMBER=477\r\nTERMINALID=160551\r\nTRANSGUID=d5701d57-9147-4ded-b596-6805581f081c:266\r\ntransid=370609730\r\ntransresult=APPROVED\r\nVISATRANSACTIONID=088044000036586\r\n" +read 962 bytes +Conn close + EOS + end + + def post_scrubbed + <<-EOS +opening connection to trans.worldpay.us:443... +opened +starting SSL for trans.worldpay.us:443... +SSL established +<- "POST /cgi-bin/process.cgi 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: trans.worldpay.us\r\nContent-Length: 425\r\n\r\n" +<- "acctid=MPNAB&action=ns_quicksale_cc&amount=1.00&ccname=Longbob+Longsen&ccnum=[FILTERED]&ci_billaddr1=456+My+Street&ci_billaddr2=Apt+1&ci_billcity=Ottawa&ci_billcountry=CA&ci_billstate=ON&ci_billzip=K1C2N6&ci_companyname=Widgets+Inc&ci_email=&ci_ipaddress=&ci_phone=%28555%29555-5555&currencycode=USD&cvv2=[FILTERED]&expmon=09&expyear=2019&merchantordernumber=67f4f20082e79684f036f25dafe96304&merchantpin=[FILTERED]&subid=SPREE" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Tue, 13 Feb 2018 19:28:27 GMT\r\n" +-> "Server: Apache\r\n" +-> "X-Frame-Options: SAMEORIGIN\r\n" +-> "Content-Type: text/html;charset=ISO-8859-1\r\n" +-> "Content-Length: 962\r\n" +-> "Connection: close\r\n" +-> "\r\n" +reading 962 bytes... +-> "<html><body><plaintext>\r\nAccepted=SALE:036586:477::919067116:N::N\r\nhistoryid=919067116\r\norderid=722189706\r\nAccepted=SALE:036586:477::919067116:N::N\r\nACCOUNTNUMBER=************7892\r\nACCTID=MPNAB\r\nauthcode=036586\r\nAuthNo=SALE:036586:477::919067116:N::N\r\nAVS_RESULT=N\r\nBATCHNUMBER=\r\nCVV2_RESULT=N\r\nDEBIT_TRACE_NUMBER=\r\nENTRYMETHOD=M\r\nhistoryid=919067116\r\nMERCHANT_DBA_ADDR=11121 Willows Road NE\r\nMERCHANT_DBA_CITY=Redmond\r\nMERCHANT_DBA_NAME=Merchant Partners\r\nMERCHANT_DBA_PHONE=4254979909\r\nMERCHANT_DBA_STATE=WA\r\nMERCHANTID=542929804946788\r\nMERCHANTORDERNUMBER=67f4f20082e79684f036f25dafe96304\r\norderid=722189706\r\nPAYTYPE=Visa\r\nPRODUCT_DESCRIPTION=\r\nReason=\r\nRECEIPT_FOOTER=Thank You\r\nrecurid=0\r\nrefcode=919067116-036586\r\nresult=1\r\nSEQUENCE_NUMBER=370609730\r\nStatus=Accepted\r\nSUBID=SPREE\r\nSYSTEMAUDITTRACENUMBER=477\r\nTERMINALID=160551\r\nTRANSGUID=d5701d57-9147-4ded-b596-6805581f081c:266\r\ntransid=370609730\r\ntransresult=APPROVED\r\nVISATRANSACTIONID=088044000036586\r\n" +read 962 bytes +Conn close + EOS + end + + def pre_scrubbed_check + <<-EOS +opening connection to trans.worldpay.us:443... +opened +starting SSL for trans.worldpay.us:443... +SSL established +<- "POST /cgi-bin/process.cgi 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: trans.worldpay.us\r\nContent-Length: 412\r\n\r\n" +<- "acctid=MPNAB&action=ns_quicksale_check&amount=1.00&ci_billaddr1=456+My+Street&ci_billaddr2=Apt+1&ci_billcity=Ottawa&ci_billcountry=CA&ci_billstate=ON&ci_billzip=K1C2N6&ci_companyname=Widgets+Inc&ci_email=&ci_ipaddress=&ci_phone=%28555%29555-5555&ckaba=244183602&ckacct=15378535&ckaccttype=1&ckno=12345654321&currencycode=USD&merchantordernumber=5ec80ff8210dc9d24248ac2777d6b4f3&merchantpin=1234567890&subid=SPREE" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Tue, 13 Feb 2018 19:29:38 GMT\r\n" +-> "Server: Apache\r\n" +-> "X-Frame-Options: SAMEORIGIN\r\n" +-> "Content-Type: text/html;charset=ISO-8859-1\r\n" +-> "Content-Length: 414\r\n" +-> "Connection: close\r\n" +-> "\r\n" +reading 414 bytes... +-> "<html><body><plaintext>\r\nDeclined=DECLINED:1103180001:Invalid Bank:\r\nhistoryid=919060608\r\norderid=722196666\r\nACCOUNTNUMBER=****8535\r\nDeclined=DECLINED:1103180001:Invalid Bank:\r\nENTRYMETHOD=KEYED\r\nhistoryid=919060608\r\nMERCHANTORDERNUMBER=5ec80ff8210dc9d24248ac2777d6b4f3\r\norderid=722196666\r\nPAYTYPE=Check\r\nrcode=1103180001\r\nReason=DECLINED:1103180001:Invalid Bank:\r\nrecurid=0\r\nresult=0\r\nStatus=Declined\r\ntransid=0\r\n" +read 414 bytes +Conn close + EOS + end + + def post_scrubbed_check + <<-EOS +opening connection to trans.worldpay.us:443... +opened +starting SSL for trans.worldpay.us:443... +SSL established +<- "POST /cgi-bin/process.cgi 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: trans.worldpay.us\r\nContent-Length: 412\r\n\r\n" +<- "acctid=MPNAB&action=ns_quicksale_check&amount=1.00&ci_billaddr1=456+My+Street&ci_billaddr2=Apt+1&ci_billcity=Ottawa&ci_billcountry=CA&ci_billstate=ON&ci_billzip=K1C2N6&ci_companyname=Widgets+Inc&ci_email=&ci_ipaddress=&ci_phone=%28555%29555-5555&ckaba=244183602&ckacct=[FILTERED]&ckaccttype=1&ckno=12345654321&currencycode=USD&merchantordernumber=5ec80ff8210dc9d24248ac2777d6b4f3&merchantpin=[FILTERED]&subid=SPREE" +-> "HTTP/1.1 200 OK\r\n" +-> "Date: Tue, 13 Feb 2018 19:29:38 GMT\r\n" +-> "Server: Apache\r\n" +-> "X-Frame-Options: SAMEORIGIN\r\n" +-> "Content-Type: text/html;charset=ISO-8859-1\r\n" +-> "Content-Length: 414\r\n" +-> "Connection: close\r\n" +-> "\r\n" +reading 414 bytes... +-> "<html><body><plaintext>\r\nDeclined=DECLINED:1103180001:Invalid Bank:\r\nhistoryid=919060608\r\norderid=722196666\r\nACCOUNTNUMBER=****8535\r\nDeclined=DECLINED:1103180001:Invalid Bank:\r\nENTRYMETHOD=KEYED\r\nhistoryid=919060608\r\nMERCHANTORDERNUMBER=5ec80ff8210dc9d24248ac2777d6b4f3\r\norderid=722196666\r\nPAYTYPE=Check\r\nrcode=1103180001\r\nReason=DECLINED:1103180001:Invalid Bank:\r\nrecurid=0\r\nresult=0\r\nStatus=Declined\r\ntransid=0\r\n" +read 414 bytes +Conn close + EOS + end end From 747d12d74fa659fcbd58a80fcc3512ba2c65a9fa Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Wed, 14 Feb 2018 16:13:34 -0500 Subject: [PATCH 325/677] Vantiv: Add support for merchantData elements Adds the optional `affiliate`, `campaign` and `merchantGroupingId` elements as children of the `merchantData` element. Closes #2751 Unit: 33 tests, 142 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 31 tests, 126 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/litle.rb | 12 ++++++++++ test/remote/gateways/remote_litle_test.rb | 22 +++++++++++++++++++ test/unit/gateways/litle_test.rb | 15 +++++++++++++ 4 files changed, 50 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 939bdaa4112..b252375cbfc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * USA Epay Transaction: Scrub sensitive data [curiousepic] #2745 * MIGS: Add unit test for scrub [curiousepic] #2747 * Worldpay US: Fix bank account scrub [curiousepic] #2748 +* Litle: Add support for merchantData elements [dtykocki] #2751 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index 88eb1a1e4a7..bbf9f231984 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -131,6 +131,7 @@ def scrub(transcript) end private + CARD_TYPE = { 'visa' => 'VI', 'master' => 'MC', @@ -178,9 +179,20 @@ def add_auth_purchase_params(doc, money, payment_method, options) add_payment_method(doc, payment_method, options) add_pos(doc, payment_method) add_descriptor(doc, options) + add_merchant_data(doc, options) add_debt_repayment(doc, options) end + def add_merchant_data(doc, options={}) + if options[:affiliate] || options[:campaign] || options[:merchant_grouping_id] + doc.merchantData do + doc.affiliate(options[:affiliate]) if options[:affiliate] + doc.campaign(options[:campaign]) if options[:campaign] + doc.merchantGroupingId(options[:merchant_grouping_id]) if options[:merchant_grouping_id] + end + end + end + def add_descriptor(doc, options) if options[:descriptor_name] || options[:descriptor_phone] doc.customBilling do diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb index 05b43f1d781..6ac94ec75e9 100644 --- a/test/remote/gateways/remote_litle_test.rb +++ b/test/remote/gateways/remote_litle_test.rb @@ -71,6 +71,17 @@ def test_successful_authorization assert_equal 'Approved', response.message end + def test_successful_authorization_with_merchant_data + options = @options.merge( + affiliate: 'some-affiliate', + campaign: 'super-awesome-campaign', + merchant_grouping_id: 'brilliant-group' + ) + assert response = @gateway.authorize(10010, @credit_card1, options) + assert_success response + assert_equal 'Approved', response.message + end + def test_avs_and_cvv_result assert response = @gateway.authorize(10010, @credit_card1, @options) assert_equal "X", response.avs_result["code"] @@ -141,6 +152,17 @@ def test_successful_purchase_with_android_pay assert_equal 'Approved', response.message end + def test_successful_purchase_with_merchant_data + options = @options.merge( + affiliate: 'some-affiliate', + campaign: 'super-awesome-campaign', + merchant_grouping_id: 'brilliant-group' + ) + assert response = @gateway.purchase(10010, @credit_card1, options) + assert_success response + assert_equal 'Approved', response.message + end + def test_unsuccessful_purchase assert response = @gateway.purchase(60060, @credit_card2, { :order_id=>'6', diff --git a/test/unit/gateways/litle_test.rb b/test/unit/gateways/litle_test.rb index 425af365acb..68936b4cb9d 100644 --- a/test/unit/gateways/litle_test.rb +++ b/test/unit/gateways/litle_test.rb @@ -56,6 +56,21 @@ def test_failed_purchase assert response.test? end + def test_passing_merchant_data + options = @options.merge( + affiliate: 'some-affiliate', + campaign: 'super-awesome-campaign', + merchant_grouping_id: 'brilliant-group' + ) + stub_comms do + @gateway.purchase(@amount, @credit_card, options) + end.check_request do |endpoint, data, headers| + assert_match(%r(<affiliate>some-affiliate</affiliate>), data) + assert_match(%r(<campaign>super-awesome-campaign</campaign>), data) + assert_match(%r(<merchantGroupingId>brilliant-group</merchantGroupingId>), data) + end.respond_with(successful_purchase_response) + end + def test_passing_name_on_card stub_comms do @gateway.purchase(@amount, @credit_card) From c2a022fcb0e2b28d7a168c2595170117a9319079 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 19 Feb 2018 10:36:40 -0500 Subject: [PATCH 326/677] Paymentez: add support for explicitly using tokens Also tweaks the exact error message phrasing expected from one remote test to allow for 100% remote tests passing. Remote: 15 tests, 36 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 32 tests, 153 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2753 --- CHANGELOG | 1 + .../billing/gateways/paymentez.rb | 32 ++++++++++++------- test/remote/gateways/remote_paymentez_test.rb | 21 +++++++++++- test/unit/gateways/paymentez_test.rb | 19 +++++++++++ 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b252375cbfc..4c12b2c91f5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ * MIGS: Add unit test for scrub [curiousepic] #2747 * Worldpay US: Fix bank account scrub [curiousepic] #2748 * Litle: Add support for merchantData elements [dtykocki] #2751 +* Paymentez: Add support for purchasing and authorizatin with tokens [bpollack] #2753 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index 6ca8fef27ea..682ee743f4a 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -52,8 +52,9 @@ def purchase(money, payment, options = {}) add_invoice(post, money, options) add_payment(post, payment) add_customer_data(post, options) + action = payment.is_a?(String) ? 'debit' : 'debit_cc' - commit_transaction('debit_cc', post) + commit_transaction(action, post) end def authorize(money, payment, options = {}) @@ -62,10 +63,15 @@ def authorize(money, payment, options = {}) add_invoice(post, money, options) add_customer_data(post, options) - MultiResponse.run do |r| - r.process { store(payment, options) } - post[:card] = { token: r.authorization } - r.process { commit_transaction('authorize', post) } + if payment.is_a?(String) + post[:card] = { token: payment } + commit_transaction('authorize', post) + else + MultiResponse.run do |r| + r.process { store(payment, options) } + post[:card] = { token: r.authorization } + r.process { commit_transaction('authorize', post) } + end end end @@ -148,12 +154,16 @@ def add_invoice(post, money, options) def add_payment(post, payment) post[:card] ||= {} - post[:card][:number] = payment.number - post[:card][:holder_name] = payment.name - post[:card][:expiry_month] = payment.month - post[:card][:expiry_year] = payment.year - post[:card][:cvc] = payment.verification_value - post[:card][:type] = CARD_MAPPING[payment.brand] + if payment.is_a?(String) + post[:card][:token] = payment + else + post[:card][:number] = payment.number + post[:card][:holder_name] = payment.name + post[:card][:expiry_month] = payment.month + post[:card][:expiry_year] = payment.year + post[:card][:cvc] = payment.verification_value + post[:card][:type] = CARD_MAPPING[payment.brand] + end end def parse(body) diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb index 695d00da0d2..ee4c866e2cc 100644 --- a/test/remote/gateways/remote_paymentez_test.rb +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -32,6 +32,14 @@ def test_successful_purchase_with_more_options assert_success response end + def test_successful_purchase_with_token + store_response = @gateway.store(@credit_card, @options) + assert_success store_response + token = store_response.authorization + purchase_response = @gateway.purchase(@amount, token, @options) + assert_success purchase_response + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response @@ -61,6 +69,17 @@ def test_successful_authorize_and_capture assert_equal 'Operation Successful', capture.message end + def test_successful_authorize_and_capture_with_token + store_response = @gateway.store(@credit_card, @options) + assert_success store_response + token = store_response.authorization + auth = @gateway.authorize(@amount, token, @options) + assert_success auth + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + assert_equal 'Operation Successful', capture.message + end + def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response @@ -77,7 +96,7 @@ def test_partial_capture def test_failed_capture response = @gateway.capture(@amount, '') assert_failure response - assert_equal 'Carrier not supported', response.message + assert_equal 'The capture method is not supported by carrier', response.message end def test_store diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb index 97c1c03a77a..6473c7b7a3a 100644 --- a/test/unit/gateways/paymentez_test.rb +++ b/test/unit/gateways/paymentez_test.rb @@ -25,6 +25,16 @@ def test_successful_purchase assert response.test? end + def test_successful_purchase_with_token + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, '123456789012345678901234567890', @options) + assert_success response + + assert_equal 'PR-926', response.authorization + assert response.test? + end + def test_failed_purchase @gateway.expects(:ssl_post).returns(failed_purchase_response) @@ -42,6 +52,15 @@ def test_successful_authorize assert response.test? end + def test_successful_authorize_with_token + @gateway.stubs(:ssl_post).returns(successful_authorize_response) + + response = @gateway.authorize(@amount, '123456789012345678901234567890', @options) + assert_success response + assert_equal 'CI-635', response.authorization + assert response.test? + end + def test_failed_authorize @gateway.expects(:ssl_post).returns(failed_store_response) From c13776d1d7acdda7ea2eaea9de38176676946adc Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 20 Feb 2018 12:51:22 -0500 Subject: [PATCH 327/677] GlobalCollector: remove Trinidad as a supported country Also fix the capitalization of the Content-Type header, which avoids having an unused Content-type header inserted alongside the normal Content-Type one. Unit: 16 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 15 tests, 35 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2754 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/global_collect.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4c12b2c91f5..613cfc5f25d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * Worldpay US: Fix bank account scrub [curiousepic] #2748 * Litle: Add support for merchantData elements [dtykocki] #2751 * Paymentez: Add support for purchasing and authorizatin with tokens [bpollack] #2753 +* Ingenico: Remove Trinidad and Tobego from supported country list [bpollack] #2754 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 35a0674aa90..b898100b97f 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -9,7 +9,7 @@ class GlobalCollectGateway < Gateway self.supported_countries = %w(AD AE AT AU BD BE BG BN CA CH CY CZ DE DK EE EG ES FI FR GB GI GR HK HU ID IE IL IM IN IS IT JO KW LB LI LK LT LU - LV MC MT MU MV MX MY NL NO NZ OM PH PL PT QA RO SA SE SG SI SK SM TR TT + LV MC MT MU MV MX MY NL NO NZ OM PH PL PT QA RO SA SE SG SI SK SM TR UM US VA VN ZA) self.default_currency = "USD" self.money_format = :cents @@ -252,7 +252,7 @@ def commit(action, post, authorization = nil) def headers(action, post, authorization = nil) { - "Content-type" => content_type, + "Content-Type" => content_type, "Authorization" => auth_digest(action, post, authorization), "Date" => date } From bc5a8239bdd0e50281d2590251d4a9b77d160e2c Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 20 Feb 2018 12:54:48 -0500 Subject: [PATCH 328/677] Barclaycard Smartpay: Georgia is no longer supported Closes #2755 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/barclaycard_smartpay.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 613cfc5f25d..76d3a9c04b9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * Litle: Add support for merchantData elements [dtykocki] #2751 * Paymentez: Add support for purchasing and authorizatin with tokens [bpollack] #2753 * Ingenico: Remove Trinidad and Tobego from supported country list [bpollack] #2754 +* Barclaycard Smartpay: Remove Georgia from supported country list [bpollack] #2755 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index 3710a147f70..513821bd95e 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -4,7 +4,7 @@ class BarclaycardSmartpayGateway < Gateway self.test_url = 'https://pal-test.barclaycardsmartpay.com/pal/servlet' self.live_url = 'https://pal-live.barclaycardsmartpay.com/pal/servlet' - self.supported_countries = ['AL', 'AD', 'AM', 'AT', 'AZ', 'BY', 'BE', 'BA', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'GE', 'DE', 'GR', 'HU', 'IS', 'IE', 'IT', 'KZ', 'LV', 'LI', 'LT', 'LU', 'MK', 'MT', 'MD', 'MC', 'ME', 'NL', 'NO', 'PL', 'PT', 'RO', 'RU', 'SM', 'RS', 'SK', 'SI', 'ES', 'SE', 'CH', 'TR', 'UA', 'GB', 'VA'] + self.supported_countries = ['AL', 'AD', 'AM', 'AT', 'AZ', 'BY', 'BE', 'BA', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IS', 'IE', 'IT', 'KZ', 'LV', 'LI', 'LT', 'LU', 'MK', 'MT', 'MD', 'MC', 'ME', 'NL', 'NO', 'PL', 'PT', 'RO', 'RU', 'SM', 'RS', 'SK', 'SI', 'ES', 'SE', 'CH', 'TR', 'UA', 'GB', 'VA'] self.default_currency = 'EUR' self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND) self.money_format = :cents From f1e678166cc04a6d0f24348863056e4cc051a772 Mon Sep 17 00:00:00 2001 From: Joshua Nussbaum <joshnuss@gmail.com> Date: Thu, 22 Feb 2018 17:19:43 -0500 Subject: [PATCH 329/677] [Merchant Warrior] Adds default for empty state field (#2638) --- CHANGELOG | 1 + .../billing/gateways/merchant_warrior.rb | 8 ++-- test/unit/gateways/merchant_warrior_test.rb | 41 +++++++++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 76d3a9c04b9..9217e30c4b8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ * Paymentez: Add support for purchasing and authorizatin with tokens [bpollack] #2753 * Ingenico: Remove Trinidad and Tobego from supported country list [bpollack] #2754 * Barclaycard Smartpay: Remove Georgia from supported country list [bpollack] #2755 +* Merchant Warrior: Remove requirement for state field [joshnuss] #2638 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/merchant_warrior.rb b/lib/active_merchant/billing/gateways/merchant_warrior.rb index 90dff734d9b..30e34e4edb3 100644 --- a/lib/active_merchant/billing/gateways/merchant_warrior.rb +++ b/lib/active_merchant/billing/gateways/merchant_warrior.rb @@ -79,13 +79,13 @@ def add_address(post, options) post['customerName'] = scrub_name(address[:name]) post['customerCountry'] = address[:country] - post['customerState'] = address[:state] + post['customerState'] = address[:state] || 'N/A' post['customerCity'] = address[:city] post['customerAddress'] = address[:address1] post['customerPostCode'] = address[:zip] - post['customerIP'] = address[:ip] - post['customerPhone'] = address[:phone] - post['customerEmail'] = address[:email] + post['customerIP'] = address[:ip] + post['customerPhone'] = address[:phone] + post['customerEmail'] = address[:email] end def add_order_id(post, options) diff --git a/test/unit/gateways/merchant_warrior_test.rb b/test/unit/gateways/merchant_warrior_test.rb index 17e098d5849..8b9da664447 100644 --- a/test/unit/gateways/merchant_warrior_test.rb +++ b/test/unit/gateways/merchant_warrior_test.rb @@ -90,6 +90,47 @@ def test_scrub_name end.respond_with(successful_purchase_response) end + def test_address + @options[:address] = { + name: 'Bat Man', + address1: '123 Main', + city: 'Brooklyn', + state: 'NY', + country: 'US', + zip: '11111', + phone: '555-1212', + email: 'user@aol.com', + ip: '1.2.3.4' + } + + stub_comms do + @gateway.purchase(@success_amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match(/customerName=Bat\+Man/, data) + assert_match(/customerCountry=US/, data) + assert_match(/customerState=NY/, data) + assert_match(/customerCity=Brooklyn/, data) + assert_match(/customerAddress=123\+Main/, data) + assert_match(/customerPostCode=11111/, data) + assert_match(/customerIP=1.2.3.4/, data) + assert_match(/customerPhone=555-1212/, data) + assert_match(/customerEmail=user%40aol.com/, data) + end.respond_with(successful_purchase_response) + end + + def test_address_without_state + @options[:address] = { + name: 'Bat Man', + state: nil + } + + stub_comms do + @gateway.purchase(@success_amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match(/customerState=N%2FA/, data) + end.respond_with(successful_purchase_response) + end + def test_orderid_truncated stub_comms do @gateway.purchase(@success_amount, @credit_card, order_id: "ThisIsQuiteALongDescriptionWithLotsOfChars") From 7ebdc250a7f802d64731f826135b5b8ff86c663d Mon Sep 17 00:00:00 2001 From: Filipe Costa <filipebarcos@users.noreply.github.com> Date: Fri, 23 Feb 2018 14:56:48 -0500 Subject: [PATCH 330/677] Wirecard: Adding missing DigiCert Global Root G2 Cert (#2759) Closes https://github.com/activemerchant/active_merchant/issues/2758 --- CHANGELOG | 1 + lib/certs/cacert.pem | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 9217e30c4b8..c901d12c9c2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,7 @@ * Ingenico: Remove Trinidad and Tobego from supported country list [bpollack] #2754 * Barclaycard Smartpay: Remove Georgia from supported country list [bpollack] #2755 * Merchant Warrior: Remove requirement for state field [joshnuss] #2638 +* Wirecard: Adding missing DigiCert Global Root G2 Cert [filipebarcos] #2759 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/certs/cacert.pem b/lib/certs/cacert.pem index 37c56879f45..e353e84e1c0 100644 --- a/lib/certs/cacert.pem +++ b/lib/certs/cacert.pem @@ -1454,6 +1454,31 @@ UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4= -----END CERTIFICATE----- +DigiCert Global Root G2 +======================= +-----BEGIN CERTIFICATE----- +MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBh +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH +MjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVT +MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j +b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI +2/Ou8jqJkTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx +1x7e/dfgy5SDN67sH0NO3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQ +q2EGnI/yuum06ZIya7XzV+hdG82MHauVBJVJ8zUtluNJbd134/tJS7SsVQepj5Wz +tCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyMUNGPHgm+F6HmIcr9g+UQ +vIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQABo0IwQDAP +BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV +5uNu5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY +1Yl9PMWLSn/pvtsrF9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4 +NeF22d+mQrvHRAiGfzZ0JFrabA0UWTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NG +Fdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBHQRFXGU7Aj64GxJUTFy8bJZ91 +8rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/iyK5S9kJRaTe +pLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl +MrY= +-----END CERTIFICATE----- + DigiCert High Assurance EV Root CA ================================== -----BEGIN CERTIFICATE----- From dde12ccec4e3819267dc0ce681d103b0c8e82042 Mon Sep 17 00:00:00 2001 From: JoseLuis Vilar <Gjoseluisvilar@gmail.com> Date: Thu, 22 Feb 2018 00:53:44 +0100 Subject: [PATCH 331/677] Added support for CNY, IDR, INR, KRW and TWD Additional currencies to be supported by Redsys Closes #2761, #2756 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/redsys.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index c901d12c9c2..1775799090e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,6 +22,7 @@ * Barclaycard Smartpay: Remove Georgia from supported country list [bpollack] #2755 * Merchant Warrior: Remove requirement for state field [joshnuss] #2638 * Wirecard: Adding missing DigiCert Global Root G2 Cert [filipebarcos] #2759 +* Redsys: Add support for CNY, IDR, INR, KRW and TWD [chopenhauer] #2761 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb index 0867f2fcabd..9ab1264a196 100644 --- a/lib/active_merchant/billing/gateways/redsys.rb +++ b/lib/active_merchant/billing/gateways/redsys.rb @@ -56,6 +56,7 @@ class RedsysGateway < Gateway "CAD" => '124', "CHF" => '756', "CLP" => '152', + "CNY" => '156', "COP" => '170', "CRC" => '188', "CZK" => '203', @@ -65,7 +66,10 @@ class RedsysGateway < Gateway "GBP" => '826', "GTQ" => '320', "HUF" => '348', + "IDR" => '360', + "INR" => '356', "JPY" => '392', + "KRW" => '410', "MYR" => '458', "MXN" => '484', "NOK" => '578', @@ -77,6 +81,7 @@ class RedsysGateway < Gateway "SEK" => '752', "SGD" => '702', "THB" => '764', + "TWD" => '901', "USD" => '840', "UYU" => '858' } From 6e3a45052569920760ac35f6f1c4222600682ee3 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Mon, 26 Feb 2018 15:24:41 -0500 Subject: [PATCH 332/677] Optimal Payments: Fix scrub for double escaping The scrub method was looking for the wrong encoding for closing tag slashes for double-escaped transcripts Closes #2763 Unit: 19 tests, 75 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 15 tests, 71 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/optimal_payment.rb | 6 +++--- test/unit/gateways/optimal_payment_test.rb | 13 +++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1775799090e..66219cde7b6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,7 @@ * Merchant Warrior: Remove requirement for state field [joshnuss] #2638 * Wirecard: Adding missing DigiCert Global Root G2 Cert [filipebarcos] #2759 * Redsys: Add support for CNY, IDR, INR, KRW and TWD [chopenhauer] #2761 +* Optimal Payments: Fix scrub for double escaping [curiousepic] #2763 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb index a1633b8847d..10c809fdc04 100644 --- a/lib/active_merchant/billing/gateways/optimal_payment.rb +++ b/lib/active_merchant/billing/gateways/optimal_payment.rb @@ -65,9 +65,9 @@ def supports_scrubbing? def scrub(transcript) transcript. - gsub(%r((%3CstorePwd%3E).*(%3C(%3F|/)storePwd%3E))i, '\1[FILTERED]\2'). - gsub(%r((%3CcardNum%3E)\d*(%3C(%3F|/)cardNum%3E))i, '\1[FILTERED]\2'). - gsub(%r((%3Ccvd%3E)\d*(%3C(%3F|/)cvd%3E))i, '\1[FILTERED]\2') + gsub(%r((%3CstorePwd%3E).*(%3C(%2F|/)storePwd%3E))i, '\1[FILTERED]\2'). + gsub(%r((%3CcardNum%3E)\d*(%3C(%2F|/)cardNum%3E))i, '\1[FILTERED]\2'). + gsub(%r((%3Ccvd%3E)\d*(%3C(%2F|/)cvd%3E))i, '\1[FILTERED]\2') end private diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb index e927cb66fa0..d37bc29d476 100644 --- a/test/unit/gateways/optimal_payment_test.rb +++ b/test/unit/gateways/optimal_payment_test.rb @@ -234,6 +234,7 @@ def test_deprecated_options def test_scrub assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + assert_equal @gateway.scrub(pre_scrubbed_double_escaped), post_scrubbed_double_escaped end private @@ -436,4 +437,16 @@ def post_scrubbed Conn close EOS end + + def pre_scrubbed_double_escaped + <<-PRE_SCRUBBED +txnMode=ccPurchase&txnRequest=%3CccAuthRequestV1+xmlns%3D%22http%3A%2F%2Fwww.optimalpayments.com%2Fcreditcard%2Fxmlschema%2Fv1%22+xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22+xsi%3AschemaLocation%3D%22http%3A%2F%2Fwww.optimalpayments.com%2Fcreditcard%2Fxmlschema%2Fv1%22%3E%0A++%3CmerchantAccount%3E%0A++++%3CaccountNum%3E89986098%3C%2FaccountNum%3E%0A++++%3CstoreID%3Etest%3C%2FstoreID%3E%0A++++%3CstorePwd%3Etest%3C%2FstorePwd%3E%0A++%3C%2FmerchantAccount%3E%0A++%3CmerchantRefNum%3E1%3C%2FmerchantRefNum%3E%0A++%3Camount%3E1.0%3C%2Famount%3E%0A++%3Ccard%3E%0A++++%3CcardNum%3E4387751111011%3C%2FcardNum%3E%0A++++%3CcardExpiry%3E%0A++++++%3Cmonth%3E9%3C%2Fmonth%3E%0A++++++%3Cyear%3E2015%3C%2Fyear%3E%0A++++%3C%2FcardExpiry%3E%0A++++%3CcardType%3EVI%3C%2FcardType%3E%0A++++%3CcvdIndicator%3E1%3C%2FcvdIndicator%3E%0A++++%3Ccvd%3E123%3C%2Fcvd%3E%0A++%3C%2Fcard%3E%0A++%3CbillingDetails%3E%0A++++%3CcardPayMethod%3EWEB%3C%2FcardPayMethod%3E%0A++++%3CfirstName%3EJim%3C%2FfirstName%3E%0A++++%3ClastName%3ESmith%3C%2FlastName%3E%0A++++%3Cstreet%3E1234+My+Street%3C%2Fstreet%3E%0A++++%3Cstreet2%3EApt+1%3C%2Fstreet2%3E%0A++++%3Ccity%3EOttawa%3C%2Fcity%3E%0A++++%3Cstate%3EON%3C%2Fstate%3E%0A++++%3Ccountry%3ECA%3C%2Fcountry%3E%0A++++%3Czip%3EK1C2N6%3C%2Fzip%3E%0A++++%3Cphone%3E%28555%29555-5555%3C%2Fphone%3E%0A++++%3Cemail%3Eemail%40example.com%3C%2Femail%3E%0A++%3C%2FbillingDetails%3E%0A++%3CcustomerIP%3E1.2.3.4%3C%2FcustomerIP%3E%0A%3C%2FccAuthRequestV1%3E%0A + PRE_SCRUBBED +end + +def post_scrubbed_double_escaped + <<-POST_SCRUBBED +txnMode=ccPurchase&txnRequest=%3CccAuthRequestV1+xmlns%3D%22http%3A%2F%2Fwww.optimalpayments.com%2Fcreditcard%2Fxmlschema%2Fv1%22+xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22+xsi%3AschemaLocation%3D%22http%3A%2F%2Fwww.optimalpayments.com%2Fcreditcard%2Fxmlschema%2Fv1%22%3E%0A++%3CmerchantAccount%3E%0A++++%3CaccountNum%3E89986098%3C%2FaccountNum%3E%0A++++%3CstoreID%3Etest%3C%2FstoreID%3E%0A++++%3CstorePwd%3E[FILTERED]%3C%2FstorePwd%3E%0A++%3C%2FmerchantAccount%3E%0A++%3CmerchantRefNum%3E1%3C%2FmerchantRefNum%3E%0A++%3Camount%3E1.0%3C%2Famount%3E%0A++%3Ccard%3E%0A++++%3CcardNum%3E[FILTERED]%3C%2FcardNum%3E%0A++++%3CcardExpiry%3E%0A++++++%3Cmonth%3E9%3C%2Fmonth%3E%0A++++++%3Cyear%3E2015%3C%2Fyear%3E%0A++++%3C%2FcardExpiry%3E%0A++++%3CcardType%3EVI%3C%2FcardType%3E%0A++++%3CcvdIndicator%3E1%3C%2FcvdIndicator%3E%0A++++%3Ccvd%3E[FILTERED]%3C%2Fcvd%3E%0A++%3C%2Fcard%3E%0A++%3CbillingDetails%3E%0A++++%3CcardPayMethod%3EWEB%3C%2FcardPayMethod%3E%0A++++%3CfirstName%3EJim%3C%2FfirstName%3E%0A++++%3ClastName%3ESmith%3C%2FlastName%3E%0A++++%3Cstreet%3E1234+My+Street%3C%2Fstreet%3E%0A++++%3Cstreet2%3EApt+1%3C%2Fstreet2%3E%0A++++%3Ccity%3EOttawa%3C%2Fcity%3E%0A++++%3Cstate%3EON%3C%2Fstate%3E%0A++++%3Ccountry%3ECA%3C%2Fcountry%3E%0A++++%3Czip%3EK1C2N6%3C%2Fzip%3E%0A++++%3Cphone%3E%28555%29555-5555%3C%2Fphone%3E%0A++++%3Cemail%3Eemail%40example.com%3C%2Femail%3E%0A++%3C%2FbillingDetails%3E%0A++%3CcustomerIP%3E1.2.3.4%3C%2FcustomerIP%3E%0A%3C%2FccAuthRequestV1%3E%0A + POST_SCRUBBED +end end From 550a95202c0cbee38e1e188ef24c00eff9545dc5 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Mon, 26 Feb 2018 14:52:07 -0500 Subject: [PATCH 333/677] Orbital: Scrub profile transactions Previously, credit card number and merchant ID were not scrubbed from profile transactions. Closes #2762 Remote: 23 tests, 144 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 69 tests, 418 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/orbital.rb | 4 +++- test/remote/gateways/remote_orbital_test.rb | 13 +++++++++++++ test/unit/gateways/orbital_test.rb | 12 ++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 66219cde7b6..514037f5317 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,7 @@ * Wirecard: Adding missing DigiCert Global Root G2 Cert [filipebarcos] #2759 * Redsys: Add support for CNY, IDR, INR, KRW and TWD [chopenhauer] #2761 * Optimal Payments: Fix scrub for double escaping [curiousepic] #2763 +* Orbital: Scrub profile transactions [curiousepic] #2762 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index e6527508ba3..94143ac7eef 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -306,8 +306,10 @@ def scrub(transcript) gsub(%r((<OrbitalConnectionUsername>).+(</OrbitalConnectionUsername>)), '\1[FILTERED]\2'). gsub(%r((<OrbitalConnectionPassword>).+(</OrbitalConnectionPassword>)), '\1[FILTERED]\2'). gsub(%r((<AccountNum>).+(</AccountNum>)), '\1[FILTERED]\2'). + gsub(%r((<CCAccountNum>).+(</CCAccountNum>)), '\1[FILTERED]\2'). gsub(%r((<CardSecVal>).+(</CardSecVal>)), '\1[FILTERED]\2'). - gsub(%r((<MerchantID>).+(</MerchantID>)), '\1[FILTERED]\2') + gsub(%r((<MerchantID>).+(</MerchantID>)), '\1[FILTERED]\2'). + gsub(%r((<CustomerMerchantID>).+(</CustomerMerchantID>)), '\1[FILTERED]\2') end private diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb index 03642b603b9..c608bdd823f 100644 --- a/test/remote/gateways/remote_orbital_test.rb +++ b/test/remote/gateways/remote_orbital_test.rb @@ -297,4 +297,17 @@ def test_transcript_scrubbing assert_scrubbed(@gateway.options[:login], transcript) assert_scrubbed(@gateway.options[:merchant_id], transcript) end + + def test_transcript_scrubbing_profile + transcript = capture_transcript(@gateway) do + @gateway.add_customer_profile(@credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + assert_scrubbed(@gateway.options[:login], transcript) + assert_scrubbed(@gateway.options[:merchant_id], transcript) + end end diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index 0dc06032ce2..69ac058dab5 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -811,4 +811,16 @@ def post_scrubbed Conn close EOS end + + def pre_scrubbed_profile + <<-EOS +<?xml version="1.0" encoding="UTF-8"?><Response><ProfileResp><CustomerBin>000001</CustomerBin><CustomerMerchantID>253997</CustomerMerchantID><CustomerName>LONGBOB LONGSEN</CustomerName><CustomerRefNum>109273631</CustomerRefNum><CustomerProfileAction>CREATE</CustomerProfileAction><ProfileProcStatus>0</ProfileProcStatus><CustomerProfileMessage>Profile Request Processed</CustomerProfileMessage><CustomerAddress1>456 MY STREET</CustomerAddress1><CustomerAddress2>APT 1</CustomerAddress2><CustomerCity>OTTAWA</CustomerCity><CustomerState>ON</CustomerState><CustomerZIP>K1C2N6</CustomerZIP><CustomerEmail></CustomerEmail><CustomerPhone>5555555555</CustomerPhone><CustomerCountryCode>CA</CustomerCountryCode><CustomerProfileOrderOverrideInd>NO</CustomerProfileOrderOverrideInd><OrderDefaultDescription></OrderDefaultDescription><OrderDefaultAmount></OrderDefaultAmount><CustomerAccountType>CC</CustomerAccountType><Status>A</Status><CCAccountNum>4112344112344113</CCAccountNum><CCExpireDate>0919</CCExpireDate><ECPAccountDDA></ECPAccountDDA><ECPAccountType></ECPAccountType><ECPAccountRT></ECPAccountRT><ECPBankPmtDlv></ECPBankPmtDlv><SwitchSoloStartDate></SwitchSoloStartDate><SwitchSoloIssueNum></SwitchSoloIssueNum><RespTime></RespTime></ProfileResp></Response> + EOS + end + + def post_scrubbed_profile + <<-EOS +<?xml version="1.0" encoding="UTF-8"?><Response><ProfileResp><CustomerBin>000001</CustomerBin><CustomerMerchantID>[FILTERED]</CustomerMerchantID><CustomerName>LONGBOB LONGSEN</CustomerName><CustomerRefNum>109273631</CustomerRefNum><CustomerProfileAction>CREATE</CustomerProfileAction><ProfileProcStatus>0</ProfileProcStatus><CustomerProfileMessage>Profile Request Processed</CustomerProfileMessage><CustomerAddress1>456 MY STREET</CustomerAddress1><CustomerAddress2>APT 1</CustomerAddress2><CustomerCity>OTTAWA</CustomerCity><CustomerState>ON</CustomerState><CustomerZIP>K1C2N6</CustomerZIP><CustomerEmail></CustomerEmail><CustomerPhone>5555555555</CustomerPhone><CustomerCountryCode>CA</CustomerCountryCode><CustomerProfileOrderOverrideInd>NO</CustomerProfileOrderOverrideInd><OrderDefaultDescription></OrderDefaultDescription><OrderDefaultAmount></OrderDefaultAmount><CustomerAccountType>CC</CustomerAccountType><Status>A</Status><CCAccountNum>[FILTERED]</CCAccountNum><CCExpireDate>0919</CCExpireDate><ECPAccountDDA></ECPAccountDDA><ECPAccountType></ECPAccountType><ECPAccountRT></ECPAccountRT><ECPBankPmtDlv></ECPBankPmtDlv><SwitchSoloStartDate></SwitchSoloStartDate><SwitchSoloIssueNum></SwitchSoloIssueNum><RespTime></RespTime></ProfileResp></Response> + EOS + end end From e16133354d0f28bb7b5dd559bb50a9e91061ecf7 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 27 Feb 2018 15:29:24 -0500 Subject: [PATCH 334/677] BlueSnap: Fix currency passing Options was not being passed to add_amount, so a currency sent in options was never getting added. Also removes an add_invoice method that was not being used, and updates the declined test card to fix some remote tests. One unrelated failing remote test, a store call with a declined card expecting a failure now succeeds for some reason. Furthermore, the test for partial refunds now correctly succeeds instead of failing (assuming it was a sandbox quirk). Closes #2765 Remote: 25 tests, 72 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 96% passed Unit: 18 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/blue_snap.rb | 11 +++-------- test/remote/gateways/remote_blue_snap_test.rb | 13 ++++++++++--- test/unit/gateways/blue_snap_test.rb | 10 ++++++++++ 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 514037f5317..7dc67d98fc0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -25,6 +25,7 @@ * Redsys: Add support for CNY, IDR, INR, KRW and TWD [chopenhauer] #2761 * Optimal Payments: Fix scrub for double escaping [curiousepic] #2763 * Orbital: Scrub profile transactions [curiousepic] #2762 +* BlueSnap: Fix currency passing [curiousepic] #2765 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb index 564a0e13f85..c2ee9385990 100644 --- a/lib/active_merchant/billing/gateways/blue_snap.rb +++ b/lib/active_merchant/billing/gateways/blue_snap.rb @@ -86,7 +86,7 @@ def capture(money, authorization, options={}) def refund(money, authorization, options={}) commit(:refund, :put) do |doc| add_authorization(doc, authorization) - add_amount(doc, money) + add_amount(doc, money, options) add_order(doc, options) end end @@ -140,7 +140,7 @@ def scrub(transcript) def add_auth_purchase(doc, money, payment_method, options) doc.send("recurring-transaction", options[:recurring] ? "RECURRING" : "ECOMMERCE") add_order(doc, options) - add_amount(doc, money) + add_amount(doc, money, options) doc.send("transaction-fraud-info") do doc.send("shopper-ip-address", options[:ip]) if options[:ip] end @@ -155,7 +155,7 @@ def add_auth_purchase(doc, money, payment_method, options) end end - def add_amount(doc, money) + def add_amount(doc, money, options) doc.amount(amount(money)) doc.currency(options[:currency] || currency(money)) end @@ -203,11 +203,6 @@ def add_address(doc, options) doc.zip(address[:zip]) if address[:zip] end - def add_invoice(post, money, options) - post[:amount] = amount(money) - post[:currency] = (options[:currency] || currency(money)) - end - def add_authorization(doc, authorization) doc.send("transaction-id", authorization) end diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb index 6f92f30ca6b..81748aac0e3 100644 --- a/test/remote/gateways/remote_blue_snap_test.rb +++ b/test/remote/gateways/remote_blue_snap_test.rb @@ -6,7 +6,7 @@ def setup @amount = 100 @credit_card = credit_card('4263982640269299') - @declined_card = credit_card('4917484589897107', month: 1, year: 2018) + @declined_card = credit_card('4917484589897107', month: 1, year: 2023) @options = { billing_address: address } end @@ -36,6 +36,14 @@ def test_successful_purchase_with_more_options assert_equal "Success", response.message end + def test_successful_purchase_with_currency + response = @gateway.purchase(@amount, @credit_card, @options.merge(currency: 'CAD')) + assert_success response + + assert_equal 'Success', response.message + assert_equal 'CAD', response.params["currency"] + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response @@ -100,8 +108,7 @@ def test_partial_refund assert_success purchase assert refund = @gateway.refund(@amount-1, purchase.authorization) - assert_failure refund - assert_match /failed because the financial transaction was created less than 24 hours ago/, refund.message + assert_success refund end def test_failed_refund diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb index cc84a920f9b..19689062d91 100644 --- a/test/unit/gateways/blue_snap_test.rb +++ b/test/unit/gateways/blue_snap_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class BlueSnapTest < Test::Unit::TestCase + include CommStub + def setup @gateway = BlueSnapGateway.new(api_username: 'login', api_password: 'password') @credit_card = credit_card @@ -120,6 +122,14 @@ def test_failed_store assert_equal "14002", response.error_code end + def test_currency_added_correctly + stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(currency: 'CAD')) + end.check_request do |endpoint, data, headers| + assert_match(/<currency>CAD<\/currency>/, data) + end.respond_with(successful_purchase_response) + end + def test_verify_good_credentials @gateway.expects(:raw_ssl_request).returns(credentials_are_legit_response) assert @gateway.verify_credentials From d3bfa7545cbee6d97147ea923e441ed02238b127 Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Tue, 27 Feb 2018 15:02:08 -0500 Subject: [PATCH 335/677] Stripe: Support pickup_card decline code Adds the `pickup_card` decline code to the `STANDARD_ERROR_CODE_MAPPING` hash. This also fixes two failing remote tests by updating the expiration dates on card track data. Remote: 59 tests, 258 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 123 tests, 658 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/stripe.rb | 3 ++- test/remote/gateways/remote_stripe_test.rb | 4 +-- test/unit/gateways/stripe_test.rb | 25 +++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7dc67d98fc0..0ea3058a51f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,7 @@ * Optimal Payments: Fix scrub for double escaping [curiousepic] #2763 * Orbital: Scrub profile transactions [curiousepic] #2762 * BlueSnap: Fix currency passing [curiousepic] #2765 +* Stripe: Support pickup_card decline code [dtykocki] #2764 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 616ad1d4a82..ad8b85203f7 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -43,7 +43,8 @@ class StripeGateway < Gateway 'call_issuer' => STANDARD_ERROR_CODE[:call_issuer], 'processing_error' => STANDARD_ERROR_CODE[:processing_error], 'incorrect_pin' => STANDARD_ERROR_CODE[:incorrect_pin], - 'test_mode_live_card' => STANDARD_ERROR_CODE[:test_mode_live_card] + 'test_mode_live_card' => STANDARD_ERROR_CODE[:test_mode_live_card], + 'pickup_card' => STANDARD_ERROR_CODE[:pickup_card] } BANK_ACCOUNT_HOLDER_TYPE_MAPPING = { diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb index ed01060946a..1e400349583 100644 --- a/test/remote/gateways/remote_stripe_test.rb +++ b/test/remote/gateways/remote_stripe_test.rb @@ -426,7 +426,7 @@ def test_invalid_login # These "track data present" tests fail with invalid expiration dates. The # test track data probably needs to be updated. def test_card_present_purchase - @credit_card.track_data = '%B378282246310005^LONGSON/LONGBOB^1705101130504392?' + @credit_card.track_data = '%B378282246310005^LONGSON/LONGBOB^2205101130504392?' assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal "charge", response.params["object"] @@ -434,7 +434,7 @@ def test_card_present_purchase end def test_card_present_authorize_and_capture - @credit_card.track_data = '%B378282246310005^LONGSON/LONGBOB^1705101130504392?' + @credit_card.track_data = '%B378282246310005^LONGSON/LONGBOB^2205101130504392?' assert authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization refute authorization.params["captured"] diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index 59cf953e84e..7edd06c1807 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -713,6 +713,17 @@ def test_declined_request_advanced_decline_codes assert_equal 'ch_test_charge', response.authorization end + def test_declined_request_advanced_pickup_card_code + @gateway.expects(:ssl_request).returns(declined_pickup_card_purchase_response) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + + assert_equal Gateway::STANDARD_ERROR_CODE[:pickup_card], response.error_code + refute response.test? # unsuccessful request defaults to live + assert_equal 'ch_test_charge', response.authorization + end + def test_declined_request_advanced_decline_code_not_in_standard_mapping @gateway.expects(:ssl_request).returns(declined_generic_decline_purchase_response) @@ -2033,6 +2044,20 @@ def declined_call_issuer_purchase_response RESPONSE end + def declined_pickup_card_purchase_response + <<-RESPONSE + { + "error": { + "message": "Your card was declined.", + "type": "card_error", + "code": "card_declined", + "decline_code": "pickup_card", + "charge": "ch_test_charge" + } + } + RESPONSE + end + def declined_generic_decline_purchase_response <<-RESPONSE { From af85cd12cb6666ada3018bcf6607cf3d44c84a5b Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Wed, 28 Feb 2018 16:29:39 -0500 Subject: [PATCH 336/677] Improve scrub testing for five gateways Adds missing remote test scrubbing assertions for sensitive data to the Paymentez, Adyen, Dibs, CardConnect and CardProcess gateways. Closes #2767 Paymentez Remote: 15 tests, 37 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Paymentez Unit: 15 tests, 44 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Adyen Remote: 28 tests, 66 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Adyen Unit: 17 tests, 83 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Dibs Remote (most failing with a test card issue, scrub test succeeds): 19 tests, 28 assertions, 14 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 26.3158% passed Dibs Unit: 17 tests, 79 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed CardConnect Remote: 19 tests, 47 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed CardConnect Unit: 17 tests, 76 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed CardProcess Remote (4 unrelated failures): 17 tests, 42 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 76.4706% passed CardProcess Unit: 16 tests, 69 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + test/remote/gateways/remote_adyen_test.rb | 1 + test/remote/gateways/remote_card_connect_test.rb | 9 +++++++++ test/remote/gateways/remote_cardprocess_test.rb | 1 + test/remote/gateways/remote_dibs_test.rb | 2 ++ test/remote/gateways/remote_paymentez_test.rb | 1 + 6 files changed, 15 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 0ea3058a51f..7e8d3d31ec0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -27,6 +27,7 @@ * Orbital: Scrub profile transactions [curiousepic] #2762 * BlueSnap: Fix currency passing [curiousepic] #2765 * Stripe: Support pickup_card decline code [dtykocki] #2764 +* Improve scrub testing for five gateways [curiousepic] #2767 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb index db3202542e3..672a41ee754 100644 --- a/test/remote/gateways/remote_adyen_test.rb +++ b/test/remote/gateways/remote_adyen_test.rb @@ -154,6 +154,7 @@ def test_transcript_scrubbing assert_scrubbed(@credit_card.number, transcript) assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) end def test_incorrect_number_for_purchase diff --git a/test/remote/gateways/remote_card_connect_test.rb b/test/remote/gateways/remote_card_connect_test.rb index 77db6f0594e..87d1ae47ff9 100644 --- a/test/remote/gateways/remote_card_connect_test.rb +++ b/test/remote/gateways/remote_card_connect_test.rb @@ -184,8 +184,17 @@ def test_transcript_scrubbing @gateway.purchase(@amount, @credit_card, @options) end transcript = @gateway.scrub(transcript) + assert_scrubbed(@credit_card.number, transcript) assert_scrubbed(@credit_card.verification_value, transcript) assert_scrubbed(@gateway.options[:password], transcript) + + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @check, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@check.account_number, transcript) + assert_scrubbed(@gateway.options[:password], transcript) end end diff --git a/test/remote/gateways/remote_cardprocess_test.rb b/test/remote/gateways/remote_cardprocess_test.rb index e589c19cda2..951c07e0ab3 100644 --- a/test/remote/gateways/remote_cardprocess_test.rb +++ b/test/remote/gateways/remote_cardprocess_test.rb @@ -144,5 +144,6 @@ def test_transcript_scrubbing assert_scrubbed(@credit_card.number, transcript) assert_scrubbed(@credit_card.verification_value, transcript) assert_scrubbed(@gateway.options[:password], transcript) + assert_scrubbed(@gateway.options[:entity_id], transcript) end end diff --git a/test/remote/gateways/remote_dibs_test.rb b/test/remote/gateways/remote_dibs_test.rb index ab7079dfc93..532be65a61a 100644 --- a/test/remote/gateways/remote_dibs_test.rb +++ b/test/remote/gateways/remote_dibs_test.rb @@ -172,7 +172,9 @@ def test_transcript_scrubbing @gateway.purchase(@amount, @credit_card, @options) end clean_transcript = @gateway.scrub(transcript) + assert_scrubbed(@credit_card.number, clean_transcript) assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript) + assert_scrubbed(@gateway.options[:secret_key], clean_transcript) end end diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb index ee4c866e2cc..c22083655ea 100644 --- a/test/remote/gateways/remote_paymentez_test.rb +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -129,5 +129,6 @@ def test_transcript_scrubbing assert_scrubbed(@credit_card.number, transcript) assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:app_key], transcript) end end From 18bec35f243909ca4f9a09f49b2af3247733ab50 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Thu, 1 Mar 2018 10:58:55 -0500 Subject: [PATCH 337/677] Payflow: Support scrub Scrubs Payflow transcripts of all sensitive data. Note that this doesn't cover Payflow Express. Closes #2768 Remote (10 failures for ACH and other unrelated features): 28 tests, 104 assertions, 10 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 64.2857% passed Unit: 45 tests, 196 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/payflow.rb | 13 ++- test/remote/gateways/remote_payflow_test.rb | 19 ++++ test/unit/gateways/payflow_test.rb | 99 +++++++++++++++++++ 4 files changed, 131 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7e8d3d31ec0..808f5adc215 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -28,6 +28,7 @@ * BlueSnap: Fix currency passing [curiousepic] #2765 * Stripe: Support pickup_card decline code [dtykocki] #2764 * Improve scrub testing for five gateways [curiousepic] #2767 +* Payflow: Support scrub [curiousepic] #2768 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb index 5d9315dc29a..f77cd20dda2 100644 --- a/lib/active_merchant/billing/gateways/payflow.rb +++ b/lib/active_merchant/billing/gateways/payflow.rb @@ -100,8 +100,20 @@ def express @express ||= PayflowExpressGateway.new(@options) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((<CardNum>)[^<]*(</CardNum>)), '\1[FILTERED]\2'). + gsub(%r((<CVNum>)[^<]*(</CVNum>)), '\1[FILTERED]\2'). + gsub(%r((<AcctNum>)[^<]*(</AcctNum>)), '\1[FILTERED]\2'). + gsub(%r((<Password>)[^<]*(</Password>)), '\1[FILTERED]\2') + end private + def build_sale_or_authorization_request(action, money, funding_source, options) if funding_source.is_a?(String) build_reference_sale_or_authorization_request(action, money, funding_source, options) @@ -332,4 +344,3 @@ def build_response(success, message, response, options = {}) end end end - diff --git a/test/remote/gateways/remote_payflow_test.rb b/test/remote/gateways/remote_payflow_test.rb index fbc5f2f2589..09e6fe0b682 100644 --- a/test/remote/gateways/remote_payflow_test.rb +++ b/test/remote/gateways/remote_payflow_test.rb @@ -360,4 +360,23 @@ def three_d_secure_option } } end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + + transcript = capture_transcript(@gateway) do + @gateway.purchase(50, @check) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@check.account_number, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end end diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb index b2dc750d51f..e35be01e5be 100644 --- a/test/unit/gateways/payflow_test.rb +++ b/test/unit/gateways/payflow_test.rb @@ -412,7 +412,106 @@ def test_paypal_nvp_option_sends_header PayflowGateway.use_paypal_nvp = old_use_paypal_nvp end + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + assert_equal @gateway.scrub(pre_scrubbed_check), post_scrubbed_check + end + private + + def pre_scrubbed + <<-EOS +opening connection to pilot-payflowpro.paypal.com:443... +opened +starting SSL for pilot-payflowpro.paypal.com:443... +SSL established +<- "POST / HTTP/1.1\r\nContent-Type: text/xml\r\nContent-Length: 1017\r\nX-Vps-Client-Timeout: 60\r\nX-Vps-Vit-Integration-Product: ActiveMerchant\r\nX-Vps-Vit-Runtime-Version: 2.1.7\r\nX-Vps-Request-Id: 3b2f9831949b48b4b0b89a33a60f9b0c\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: pilot-payflowpro.paypal.com\r\n\r\n" +<- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><XMLPayRequest Timeout=\"60\" version=\"2.1\" xmlns=\"http://www.paypal.com/XMLPay\"><RequestData><Vendor>spreedlyIntegrations</Vendor><Partner>PayPal</Partner><Transactions><Transaction CustRef=\"codyexample\"><Verbosity>MEDIUM</Verbosity><Sale><PayData><Invoice><EMail>cody@example.com</EMail><BillTo><Name>Jim Smith</Name><EMail>cody@example.com</EMail><Phone>(555)555-5555</Phone><CustCode>codyexample</CustCode><Address><Street>456 My Street</Street><City>Ottawa</City><State>ON</State><Country>CA</Country><Zip>K1C2N6</Zip></Address></BillTo><TotalAmt Currency=\"USD\"/></Invoice><Tender><Card><CardType>MasterCard</CardType><CardNum>5105105105105100</CardNum><ExpDate>201909</ExpDate><NameOnCard>Longbob</NameOnCard><CVNum>123</CVNum><ExtData Name=\"LASTNAME\" Value=\"Longsen\"/></Card></Tender></PayData></Sale></Transaction></Transactions></RequestData><RequestAuth><UserPass><User>spreedlyIntegrations</User><Password>L9DjqEKjXCkU</Password></UserPass></RequestAuth></XMLPayRequest>" +-> "HTTP/1.1 200 OK\r\n" +-> "Connection: close\r\n" +-> "Server: VPS-3.033.00\r\n" +-> "X-VPS-Request-ID: 3b2f9831949b48b4b0b89a33a60f9b0c\r\n" +-> "Date: Thu, 01 Mar 2018 15:42:15 GMT\r\n" +-> "Content-type: text/xml\r\n" +-> "Content-length: 267\r\n" +-> "\r\n" +reading 267 bytes... +-> "<XMLPayResponse xmlns=\"http://www.paypal.com/XMLPay\"><ResponseData><Vendor></Vendor><Partner></Partner><TransactionResults><TransactionResult><Result>4</Result><Message>Invalid amount</Message></TransactionResult></TransactionResults></ResponseData></XMLPayResponse>" +read 267 bytes +Conn close + EOS + end + + def post_scrubbed + <<-EOS +opening connection to pilot-payflowpro.paypal.com:443... +opened +starting SSL for pilot-payflowpro.paypal.com:443... +SSL established +<- "POST / HTTP/1.1\r\nContent-Type: text/xml\r\nContent-Length: 1017\r\nX-Vps-Client-Timeout: 60\r\nX-Vps-Vit-Integration-Product: ActiveMerchant\r\nX-Vps-Vit-Runtime-Version: 2.1.7\r\nX-Vps-Request-Id: 3b2f9831949b48b4b0b89a33a60f9b0c\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: pilot-payflowpro.paypal.com\r\n\r\n" +<- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><XMLPayRequest Timeout=\"60\" version=\"2.1\" xmlns=\"http://www.paypal.com/XMLPay\"><RequestData><Vendor>spreedlyIntegrations</Vendor><Partner>PayPal</Partner><Transactions><Transaction CustRef=\"codyexample\"><Verbosity>MEDIUM</Verbosity><Sale><PayData><Invoice><EMail>cody@example.com</EMail><BillTo><Name>Jim Smith</Name><EMail>cody@example.com</EMail><Phone>(555)555-5555</Phone><CustCode>codyexample</CustCode><Address><Street>456 My Street</Street><City>Ottawa</City><State>ON</State><Country>CA</Country><Zip>K1C2N6</Zip></Address></BillTo><TotalAmt Currency=\"USD\"/></Invoice><Tender><Card><CardType>MasterCard</CardType><CardNum>[FILTERED]</CardNum><ExpDate>201909</ExpDate><NameOnCard>Longbob</NameOnCard><CVNum>[FILTERED]</CVNum><ExtData Name=\"LASTNAME\" Value=\"Longsen\"/></Card></Tender></PayData></Sale></Transaction></Transactions></RequestData><RequestAuth><UserPass><User>spreedlyIntegrations</User><Password>[FILTERED]</Password></UserPass></RequestAuth></XMLPayRequest>" +-> "HTTP/1.1 200 OK\r\n" +-> "Connection: close\r\n" +-> "Server: VPS-3.033.00\r\n" +-> "X-VPS-Request-ID: 3b2f9831949b48b4b0b89a33a60f9b0c\r\n" +-> "Date: Thu, 01 Mar 2018 15:42:15 GMT\r\n" +-> "Content-type: text/xml\r\n" +-> "Content-length: 267\r\n" +-> "\r\n" +reading 267 bytes... +-> "<XMLPayResponse xmlns=\"http://www.paypal.com/XMLPay\"><ResponseData><Vendor></Vendor><Partner></Partner><TransactionResults><TransactionResult><Result>4</Result><Message>Invalid amount</Message></TransactionResult></TransactionResults></ResponseData></XMLPayResponse>" +read 267 bytes +Conn close + EOS + end + + def pre_scrubbed_check + <<-EOS +opening connection to pilot-payflowpro.paypal.com:443... +opened +starting SSL for pilot-payflowpro.paypal.com:443... +SSL established +<- "POST / HTTP/1.1\r\nContent-Type: text/xml\r\nContent-Length: 658\r\nX-Vps-Client-Timeout: 60\r\nX-Vps-Vit-Integration-Product: ActiveMerchant\r\nX-Vps-Vit-Runtime-Version: 2.1.7\r\nX-Vps-Request-Id: 863021e6890a0660238ef22d0a21c5f2\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: pilot-payflowpro.paypal.com\r\n\r\n" +<- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><XMLPayRequest Timeout=\"60\" version=\"2.1\" xmlns=\"http://www.paypal.com/XMLPay\"><RequestData><Vendor>spreedlyIntegrations</Vendor><Partner>PayPal</Partner><Transactions><Transaction CustRef=\"codyexample\"><Verbosity>MEDIUM</Verbosity><Sale><PayData><Invoice><BillTo><Name>Jim Smith</Name></BillTo><TotalAmt Currency=\"USD\"/></Invoice><Tender><ACH><AcctType>C</AcctType><AcctNum>1234567801</AcctNum><ABA>111111118</ABA></ACH></Tender></PayData></Sale></Transaction></Transactions></RequestData><RequestAuth><UserPass><User>spreedlyIntegrations</User><Password>L9DjqEKjXCkU</Password></UserPass></RequestAuth></XMLPayRequest>" +-> "HTTP/1.1 200 OK\r\n" +-> "Connection: close\r\n" +-> "Server: VPS-3.033.00\r\n" +-> "X-VPS-Request-ID: 863021e6890a0660238ef22d0a21c5f2\r\n" +-> "Date: Thu, 01 Mar 2018 15:45:59 GMT\r\n" +-> "Content-type: text/xml\r\n" +-> "Content-length: 267\r\n" +-> "\r\n" +reading 267 bytes... +-> "<XMLPayResponse xmlns=\"http://www.paypal.com/XMLPay\"><ResponseData><Vendor></Vendor><Partner></Partner><TransactionResults><TransactionResult><Result>4</Result><Message>Invalid amount</Message></TransactionResult></TransactionResults></ResponseData></XMLPayResponse>" +read 267 bytes +Conn close + EOS + end + + def post_scrubbed_check + <<-EOS +opening connection to pilot-payflowpro.paypal.com:443... +opened +starting SSL for pilot-payflowpro.paypal.com:443... +SSL established +<- "POST / HTTP/1.1\r\nContent-Type: text/xml\r\nContent-Length: 658\r\nX-Vps-Client-Timeout: 60\r\nX-Vps-Vit-Integration-Product: ActiveMerchant\r\nX-Vps-Vit-Runtime-Version: 2.1.7\r\nX-Vps-Request-Id: 863021e6890a0660238ef22d0a21c5f2\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: pilot-payflowpro.paypal.com\r\n\r\n" +<- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><XMLPayRequest Timeout=\"60\" version=\"2.1\" xmlns=\"http://www.paypal.com/XMLPay\"><RequestData><Vendor>spreedlyIntegrations</Vendor><Partner>PayPal</Partner><Transactions><Transaction CustRef=\"codyexample\"><Verbosity>MEDIUM</Verbosity><Sale><PayData><Invoice><BillTo><Name>Jim Smith</Name></BillTo><TotalAmt Currency=\"USD\"/></Invoice><Tender><ACH><AcctType>C</AcctType><AcctNum>[FILTERED]</AcctNum><ABA>111111118</ABA></ACH></Tender></PayData></Sale></Transaction></Transactions></RequestData><RequestAuth><UserPass><User>spreedlyIntegrations</User><Password>[FILTERED]</Password></UserPass></RequestAuth></XMLPayRequest>" +-> "HTTP/1.1 200 OK\r\n" +-> "Connection: close\r\n" +-> "Server: VPS-3.033.00\r\n" +-> "X-VPS-Request-ID: 863021e6890a0660238ef22d0a21c5f2\r\n" +-> "Date: Thu, 01 Mar 2018 15:45:59 GMT\r\n" +-> "Content-type: text/xml\r\n" +-> "Content-length: 267\r\n" +-> "\r\n" +reading 267 bytes... +-> "<XMLPayResponse xmlns=\"http://www.paypal.com/XMLPay\"><ResponseData><Vendor></Vendor><Partner></Partner><TransactionResults><TransactionResult><Result>4</Result><Message>Invalid amount</Message></TransactionResult></TransactionResults></ResponseData></XMLPayResponse>" +read 267 bytes +Conn close + EOS + end + def successful_recurring_response <<-XML <ResponseData> From b9951dc0bb1e393df0be0c39c13ff52d8de356f3 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Thu, 1 Mar 2018 13:19:04 -0500 Subject: [PATCH 338/677] SecureNet: Support scrub Closes #2769 Remote (sandbox frequently times out, scrub tests pass): 12 tests, 24 assertions, 0 failures, 7 errors, 0 pendings, 0 omissions, 0 notifications 41.6667% passed Unit: 19 tests, 92 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/secure_net.rb | 12 ++++- .../remote/gateways/remote_secure_net_test.rb | 11 ++++ test/unit/gateways/secure_net_test.rb | 50 +++++++++++++++++++ 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 808f5adc215..5954539c1e5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -29,6 +29,7 @@ * Stripe: Support pickup_card decline code [dtykocki] #2764 * Improve scrub testing for five gateways [curiousepic] #2767 * Payflow: Support scrub [curiousepic] #2768 +* SecureNet: Support scrub [curiousepic] #2769 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/secure_net.rb b/lib/active_merchant/billing/gateways/secure_net.rb index abf9d4ebccd..4c18c3b54a4 100644 --- a/lib/active_merchant/billing/gateways/secure_net.rb +++ b/lib/active_merchant/billing/gateways/secure_net.rb @@ -61,8 +61,19 @@ def credit(money, authorization, options = {}) refund(money, authorization, options) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((<CARDNUMBER>)\d+(</CARDNUMBER>))i, '\1[FILTERED]\2'). + gsub(%r((<CARDCODE>)\d+(</CARDCODE>))i, '\1[FILTERED]\2'). + gsub(%r((<SECUREKEY>).+(</SECUREKEY>))i, '\1[FILTERED]\2') + end private + def commit(request) xml = build_request(request) url = test? ? self.test_url : self.live_url @@ -255,4 +266,3 @@ def build_authorization(response) end end end - diff --git a/test/remote/gateways/remote_secure_net_test.rb b/test/remote/gateways/remote_secure_net_test.rb index 424f16f44e6..784c7d42d4d 100644 --- a/test/remote/gateways/remote_secure_net_test.rb +++ b/test/remote/gateways/remote_secure_net_test.rb @@ -125,4 +125,15 @@ def test_invoice_description_and_number assert_equal 'Approved', capture.message end + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end + end diff --git a/test/unit/gateways/secure_net_test.rb b/test/unit/gateways/secure_net_test.rb index 495a733ea27..f1c83e93698 100644 --- a/test/unit/gateways/secure_net_test.rb +++ b/test/unit/gateways/secure_net_test.rb @@ -182,6 +182,11 @@ def test_passes_without_test_mode end.respond_with(successful_purchase_response) end + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + private # Place raw successful response from gateway here @@ -225,4 +230,49 @@ def failed_refund_response '<GATEWAYRESPONSE xmlns="http://gateway.securenet.com/API/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ASPREPONSE i:nil="true"/><TRANSACTIONRESPONSE><RESPONSE_CODE>3</RESPONSE_CODE><RESPONSE_REASON_CODE>01R3</RESPONSE_REASON_CODE><RESPONSE_REASON_TEXT>CREDIT CANNOT BE COMPLETED ON AN UNSETTLED TRANSACTION</RESPONSE_REASON_TEXT><RESPONSE_SUBCODE/><ADDITIONALAMOUNT>0</ADDITIONALAMOUNT><ADDITIONALDATA1 i:nil="true"/><ADDITIONALDATA2 i:nil="true"/><ADDITIONALDATA3 i:nil="true"/><ADDITIONALDATA4 i:nil="true"/><ADDITIONALDATA5 i:nil="true"/><AUTHCODE/><AUTHORIZEDAMOUNT>0</AUTHORIZEDAMOUNT><AVS_RESULT_CODE/><BANK_ACCOUNTNAME i:nil="true"/><BANK_ACCOUNTTYPE i:nil="true"/><BATCHID i:nil="true"/><CARDHOLDER_FIRSTNAME i:nil="true"/><CARDHOLDER_LASTNAME i:nil="true"/><CARDLEVEL_RESULTS i:nil="true"/><CARDTYPE i:nil="true"/><CARD_CODE_RESPONSE_CODE/><CASHBACK_AMOUNT>0</CASHBACK_AMOUNT><CAVV_RESPONSE_CODE/><CHECKNUM i:nil="true"/><CODE>0500</CODE><CUSTOMERID/><CUSTOMER_BILL><ADDRESS/><CITY/><COMPANY/><COUNTRY/><EMAIL/><EMAILRECEIPT>FALSE</EMAILRECEIPT><FIRSTNAME/><LASTNAME/><PHONE/><STATE/><ZIP/></CUSTOMER_BILL><EXPIRYDATE i:nil="true"/><GRATUITY>0</GRATUITY><INDUSTRYSPECIFICDATA i:nil="true"/><LAST4DIGITS i:nil="true"/><LEVEL2_VALID>FALSE</LEVEL2_VALID><LEVEL3_VALID>FALSE</LEVEL3_VALID><MARKETSPECIFICDATA i:nil="true"/><METHOD>CC</METHOD><NETWORKCODE i:nil="true"/><NETWORKID i:nil="true"/><ORDERID>1285171984419000</ORDERID><PAYMENTID i:nil="true"/><RETREFERENCENUM i:nil="true"/><SECURENETID>1002550</SECURENETID><SETTLEMENTAMOUNT>0</SETTLEMENTAMOUNT><SETTLEMENTDATETIME i:nil="true"/><SYSTEM_TRACENUM i:nil="true"/><TRACKTYPE i:nil="true"/><TRANSACTIONAMOUNT>1.00</TRANSACTIONAMOUNT><TRANSACTIONDATETIME i:nil="true"/><TRANSACTIONID>0</TRANSACTIONID></TRANSACTIONRESPONSE><VAULTACCOUNTRESPONSE i:nil="true"/><VAULTCUSTOMERRESPONSE i:nil="true"/></GATEWAYRESPONSE>' end + def pre_scrubbed + <<-EOS +opening connection to certify.securenet.com:443... +opened +starting SSL for certify.securenet.com:443... +SSL established +<- "POST /API/gateway.svc/webHttp/ProcessTransaction HTTP/1.1\r\nContent-Type: text/xml\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: certify.securenet.com\r\nContent-Length: 1044\r\n\r\n" +<- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><TRANSACTION xmlns=\"http://gateway.securenet.com/API/Contracts\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><AMOUNT>1.00</AMOUNT><CARD><CARDCODE>123</CARDCODE><CARDNUMBER>4000100011112224</CARDNUMBER><EXPDATE>0919</EXPDATE></CARD><CODE>0100</CODE><CUSTOMER_BILL><ADDRESS>456 My Street</ADDRESS><CITY>Ottawa</CITY><COMPANY>Widgets Inc</COMPANY><COUNTRY>CA</COUNTRY><FIRSTNAME>Longbob</FIRSTNAME><LASTNAME>Longsen</LASTNAME><PHONE>(555)555-5555</PHONE><STATE>ON</STATE><ZIP>K1C2N6</ZIP></CUSTOMER_BILL><CUSTOMER_SHIP i:nil=\"true\"></CUSTOMER_SHIP><DCI>0</DCI><INSTALLMENT_SEQUENCENUM>1</INSTALLMENT_SEQUENCENUM><MERCHANT_KEY><GROUPID>0</GROUPID><SECUREKEY>BI8gL8HO1dKP</SECUREKEY><SECURENETID>7001218</SECURENETID></MERCHANT_KEY><METHOD>CC</METHOD><NOTE>Store Purchase</NOTE><ORDERID>1519921868962609</ORDERID><OVERRIDE_FROM>0</OVERRIDE_FROM><RETAIL_LANENUM>0</RETAIL_LANENUM><TEST>TRUE</TEST><TOTAL_INSTALLMENTCOUNT>0</TOTAL_INSTALLMENTCOUNT><TRANSACTION_SERVICE>0</TRANSACTION_SERVICE></TRANSACTION>" +-> "HTTP/1.1 200 OK\r\n" +-> "Content-Length: 2547\r\n" +-> "Content-Type: application/xml; charset=utf-8\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "Date: Thu, 01 Mar 2018 16:31:01 GMT\r\n" +-> "Connection: close\r\n" +-> "Set-Cookie: TS01e56b0e=010bfb2c76b6671aabf6f176a4e5aefd8e7a6ce7f697d82dfcfd424edede4ae7d4dba7557a4a7a13a539cfc1c5c061e08d5040811a; Path=/\r\n" +-> "\r\n" +reading 2547 bytes... +-> "<GATEWAYRESPONSE xmlns=\"http://gateway.securenet.com/API/Contracts\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><ABRESPONSE i:nil=\"true\"/><TRANSACTIONRESPONSE><RESPONSE_CODE>1</RESPONSE_CODE><RESPONSE_REASON_CODE>0000</RESPONSE_REASON_CODE><RESPONSE_REASON_TEXT>Approved</RESPONSE_REASON_TEXT><RESPONSE_SUBCODE/><ADDITIONALAMOUNT>0</ADDITIONALAMOUNT><ADDITIONALDATA1/><ADDITIONALDATA2/><ADDITIONALDATA3/><ADDITIONALDATA4/><ADDITIONALDATA5/><AUTHCODE>JUJQLQ</AUTHCODE><AUTHORIZATIONMODE i:nil=\"true\"/><AUTHORIZEDAMOUNT>1.00</AUTHORIZEDAMOUNT><AVS_RESULT_CODE>Y</AVS_RESULT_CODE><BANK_ACCOUNTNAME/><BANK_ACCOUNTTYPE/><BATCHID>0</BATCHID><CALLID/><CARDENTRYMODE i:nil=\"true\"/><CARDHOLDERVERIFICATION i:nil=\"true\"/><CARDHOLDER_FIRSTNAME>Longbob</CARDHOLDER_FIRSTNAME><CARDHOLDER_LASTNAME>Longsen</CARDHOLDER_LASTNAME><CARDLEVEL_RESULTS/><CARDTYPE>VI</CARDTYPE><CARD_CODE_RESPONSE_CODE>M</CARD_CODE_RESPONSE_CODE><CASHBACK_AMOUNT>0</CASHBACK_AMOUNT><CATINDICATOR>0</CATINDICATOR><CAVV_RESPONSE_CODE/><CHECKNUM i:nil=\"true\"/><CODE>0100</CODE><CUSTOMERID/><CUSTOMER_BILL><ADDRESS>456 My Street</ADDRESS><CITY>Ottawa</CITY><COMPANY>Widgets Inc</COMPANY><COUNTRY>CA</COUNTRY><EMAIL/><EMAILRECEIPT>FALSE</EMAILRECEIPT><FIRSTNAME>Longbob</FIRSTNAME><LASTNAME>Longsen</LASTNAME><PHONE>(555)555-5555</PHONE><STATE>ON</STATE><ZIP>K1C2N6</ZIP></CUSTOMER_BILL><DYNAMICMCC i:nil=\"true\"/><EMVRESPONSE><ISSUERAUTHENTICATIONDATA i:nil=\"true\"/><ISSUERSCRIPTTEMPLATE1 i:nil=\"true\"/><ISSUERSCRIPTTEMPLATE2 i:nil=\"true\"/></EMVRESPONSE><EXPIRYDATE>0919</EXPIRYDATE><GRATUITY>0</GRATUITY><INDUSTRYSPECIFICDATA>P</INDUSTRYSPECIFICDATA><INVOICEDESCRIPTION i:nil=\"true\"/><LAST4DIGITS>2224</LAST4DIGITS><LEVEL2_VALID>FALSE</LEVEL2_VALID><LEVEL3_VALID>FALSE</LEVEL3_VALID><MARKETSPECIFICDATA/><METHOD>CC</METHOD><NETWORKCODE/><NETWORKID/><NOTES>Store Purchase</NOTES><ORDERID>1519921868962609</ORDERID><PAYMENTID/><RETREFERENCENUM/><RISK_CATEGORY i:nil=\"true\"/><RISK_REASON1 i:nil=\"true\"/><RISK_REASON2 i:nil=\"true\"/><RISK_REASON3 i:nil=\"true\"/><RISK_REASON4 i:nil=\"true\"/><RISK_REASON5 i:nil=\"true\"/><SECURENETID>7001218</SECURENETID><SETTLEMENTAMOUNT>1.00</SETTLEMENTAMOUNT><SETTLEMENTDATETIME>03012018113101</SETTLEMENTDATETIME><SOFTDESCRIPTOR/><SYSTEM_TRACENUM/><TRACKTYPE>0</TRACKTYPE><TRANSACTIONAMOUNT>1.00</TRANSACTIONAMOUNT><TRANSACTIONDATETIME>03012018113101</TRANSACTIONDATETIME><TRANSACTIONID>116186071</TRANSACTIONID><USERDEFINED i:nil=\"true\"/></TRANSACTIONRESPONSE><VAULTACCOUNTRESPONSE i:nil=\"true\"/><VAULTCUSTOMERRESPONSE i:nil=\"true\"/></GATEWAYRESPONSE>" +read 2547 bytes +Conn close + EOS + end + + def post_scrubbed + <<-EOS +opening connection to certify.securenet.com:443... +opened +starting SSL for certify.securenet.com:443... +SSL established +<- "POST /API/gateway.svc/webHttp/ProcessTransaction HTTP/1.1\r\nContent-Type: text/xml\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: certify.securenet.com\r\nContent-Length: 1044\r\n\r\n" +<- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><TRANSACTION xmlns=\"http://gateway.securenet.com/API/Contracts\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><AMOUNT>1.00</AMOUNT><CARD><CARDCODE>[FILTERED]</CARDCODE><CARDNUMBER>[FILTERED]</CARDNUMBER><EXPDATE>0919</EXPDATE></CARD><CODE>0100</CODE><CUSTOMER_BILL><ADDRESS>456 My Street</ADDRESS><CITY>Ottawa</CITY><COMPANY>Widgets Inc</COMPANY><COUNTRY>CA</COUNTRY><FIRSTNAME>Longbob</FIRSTNAME><LASTNAME>Longsen</LASTNAME><PHONE>(555)555-5555</PHONE><STATE>ON</STATE><ZIP>K1C2N6</ZIP></CUSTOMER_BILL><CUSTOMER_SHIP i:nil=\"true\"></CUSTOMER_SHIP><DCI>0</DCI><INSTALLMENT_SEQUENCENUM>1</INSTALLMENT_SEQUENCENUM><MERCHANT_KEY><GROUPID>0</GROUPID><SECUREKEY>[FILTERED]</SECUREKEY><SECURENETID>7001218</SECURENETID></MERCHANT_KEY><METHOD>CC</METHOD><NOTE>Store Purchase</NOTE><ORDERID>1519921868962609</ORDERID><OVERRIDE_FROM>0</OVERRIDE_FROM><RETAIL_LANENUM>0</RETAIL_LANENUM><TEST>TRUE</TEST><TOTAL_INSTALLMENTCOUNT>0</TOTAL_INSTALLMENTCOUNT><TRANSACTION_SERVICE>0</TRANSACTION_SERVICE></TRANSACTION>" +-> "HTTP/1.1 200 OK\r\n" +-> "Content-Length: 2547\r\n" +-> "Content-Type: application/xml; charset=utf-8\r\n" +-> "X-Powered-By: ASP.NET\r\n" +-> "Date: Thu, 01 Mar 2018 16:31:01 GMT\r\n" +-> "Connection: close\r\n" +-> "Set-Cookie: TS01e56b0e=010bfb2c76b6671aabf6f176a4e5aefd8e7a6ce7f697d82dfcfd424edede4ae7d4dba7557a4a7a13a539cfc1c5c061e08d5040811a; Path=/\r\n" +-> "\r\n" +reading 2547 bytes... +-> "<GATEWAYRESPONSE xmlns=\"http://gateway.securenet.com/API/Contracts\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><ABRESPONSE i:nil=\"true\"/><TRANSACTIONRESPONSE><RESPONSE_CODE>1</RESPONSE_CODE><RESPONSE_REASON_CODE>0000</RESPONSE_REASON_CODE><RESPONSE_REASON_TEXT>Approved</RESPONSE_REASON_TEXT><RESPONSE_SUBCODE/><ADDITIONALAMOUNT>0</ADDITIONALAMOUNT><ADDITIONALDATA1/><ADDITIONALDATA2/><ADDITIONALDATA3/><ADDITIONALDATA4/><ADDITIONALDATA5/><AUTHCODE>JUJQLQ</AUTHCODE><AUTHORIZATIONMODE i:nil=\"true\"/><AUTHORIZEDAMOUNT>1.00</AUTHORIZEDAMOUNT><AVS_RESULT_CODE>Y</AVS_RESULT_CODE><BANK_ACCOUNTNAME/><BANK_ACCOUNTTYPE/><BATCHID>0</BATCHID><CALLID/><CARDENTRYMODE i:nil=\"true\"/><CARDHOLDERVERIFICATION i:nil=\"true\"/><CARDHOLDER_FIRSTNAME>Longbob</CARDHOLDER_FIRSTNAME><CARDHOLDER_LASTNAME>Longsen</CARDHOLDER_LASTNAME><CARDLEVEL_RESULTS/><CARDTYPE>VI</CARDTYPE><CARD_CODE_RESPONSE_CODE>M</CARD_CODE_RESPONSE_CODE><CASHBACK_AMOUNT>0</CASHBACK_AMOUNT><CATINDICATOR>0</CATINDICATOR><CAVV_RESPONSE_CODE/><CHECKNUM i:nil=\"true\"/><CODE>0100</CODE><CUSTOMERID/><CUSTOMER_BILL><ADDRESS>456 My Street</ADDRESS><CITY>Ottawa</CITY><COMPANY>Widgets Inc</COMPANY><COUNTRY>CA</COUNTRY><EMAIL/><EMAILRECEIPT>FALSE</EMAILRECEIPT><FIRSTNAME>Longbob</FIRSTNAME><LASTNAME>Longsen</LASTNAME><PHONE>(555)555-5555</PHONE><STATE>ON</STATE><ZIP>K1C2N6</ZIP></CUSTOMER_BILL><DYNAMICMCC i:nil=\"true\"/><EMVRESPONSE><ISSUERAUTHENTICATIONDATA i:nil=\"true\"/><ISSUERSCRIPTTEMPLATE1 i:nil=\"true\"/><ISSUERSCRIPTTEMPLATE2 i:nil=\"true\"/></EMVRESPONSE><EXPIRYDATE>0919</EXPIRYDATE><GRATUITY>0</GRATUITY><INDUSTRYSPECIFICDATA>P</INDUSTRYSPECIFICDATA><INVOICEDESCRIPTION i:nil=\"true\"/><LAST4DIGITS>2224</LAST4DIGITS><LEVEL2_VALID>FALSE</LEVEL2_VALID><LEVEL3_VALID>FALSE</LEVEL3_VALID><MARKETSPECIFICDATA/><METHOD>CC</METHOD><NETWORKCODE/><NETWORKID/><NOTES>Store Purchase</NOTES><ORDERID>1519921868962609</ORDERID><PAYMENTID/><RETREFERENCENUM/><RISK_CATEGORY i:nil=\"true\"/><RISK_REASON1 i:nil=\"true\"/><RISK_REASON2 i:nil=\"true\"/><RISK_REASON3 i:nil=\"true\"/><RISK_REASON4 i:nil=\"true\"/><RISK_REASON5 i:nil=\"true\"/><SECURENETID>7001218</SECURENETID><SETTLEMENTAMOUNT>1.00</SETTLEMENTAMOUNT><SETTLEMENTDATETIME>03012018113101</SETTLEMENTDATETIME><SOFTDESCRIPTOR/><SYSTEM_TRACENUM/><TRACKTYPE>0</TRACKTYPE><TRANSACTIONAMOUNT>1.00</TRANSACTIONAMOUNT><TRANSACTIONDATETIME>03012018113101</TRANSACTIONDATETIME><TRANSACTIONID>116186071</TRANSACTIONID><USERDEFINED i:nil=\"true\"/></TRANSACTIONRESPONSE><VAULTACCOUNTRESPONSE i:nil=\"true\"/><VAULTCUSTOMERRESPONSE i:nil=\"true\"/></GATEWAYRESPONSE>" +read 2547 bytes +Conn close + EOS + end end From f592de6a21b9611ec12225417da678c1a7eb1558 Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Thu, 1 Mar 2018 14:03:35 -0500 Subject: [PATCH 339/677] Payeezy: Update transaction method when using stored cards For reference based transactions that accept stored cards, we'll now pass `credit_card` instead of `token` in the `method` option. It's not entirely clear from Payeezy's documentation that this is the correct value to use, but with `credit_card` we no longer see the "Token information is missing" error message on `capture`, `void`, and `refund` calls. Closes #2770 Unit: 32 tests, 153 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 30 tests, 118 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/payeezy.rb | 2 +- test/remote/gateways/remote_payeezy_test.rb | 51 ++++++++++++++++--- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5954539c1e5..968be88cc7b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -30,6 +30,7 @@ * Improve scrub testing for five gateways [curiousepic] #2767 * Payflow: Support scrub [curiousepic] #2768 * SecureNet: Support scrub [curiousepic] #2769 +* Payeezy: Update transaction method when using stored cards [dtykocki] #2770 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index 509d9c576a4..b26f74a710a 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -131,7 +131,7 @@ def add_authorization_info(params, authorization) transaction_id, transaction_tag, method, _ = authorization.split('|') params[:transaction_id] = transaction_id params[:transaction_tag] = transaction_tag - params[:method] = method + params[:method] = (method == 'token') ? 'credit_card' : method end def add_creditcard_for_tokenization(params, payment_method, options) diff --git a/test/remote/gateways/remote_payeezy_test.rb b/test/remote/gateways/remote_payeezy_test.rb index e3f157df6e1..155991fc847 100644 --- a/test/remote/gateways/remote_payeezy_test.rb +++ b/test/remote/gateways/remote_payeezy_test.rb @@ -28,16 +28,14 @@ def setup end def test_successful_store - assert response = @gateway.store(@credit_card, - @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) + assert response = @gateway.store(@credit_card, @options) assert_success response assert_equal 'Token successfully created.', response.message assert response.authorization end def test_successful_store_and_purchase - assert response = @gateway.store(@credit_card, - @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) + assert response = @gateway.store(@credit_card, @options) assert_success response assert !response.authorization.blank? assert purchase = @gateway.purchase(@amount, response.authorization, @options) @@ -45,8 +43,7 @@ def test_successful_store_and_purchase end def test_unsuccessful_store - assert response = @gateway.store(@bad_credit_card, - @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) + assert response = @gateway.store(@bad_credit_card, @options) assert_failure response assert_equal 'The credit card number check failed', response.message end @@ -85,6 +82,18 @@ def test_authorize_and_capture assert_success capture end + def test_successful_store_and_auth_and_capture + assert response = @gateway.store(@credit_card, @options) + assert_success response + + assert auth = @gateway.authorize(@amount, response.authorization, @options) + assert_success auth + assert auth.authorization + + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + end + def test_failed_authorize @amount = 501300 assert auth = @gateway.authorize(@amount, @credit_card, @options) @@ -127,6 +136,20 @@ def test_successful_refund_with_echeck assert response.authorization end + def test_successful_refund_with_stored_card + response = @gateway.store(@credit_card, @options) + assert_success response + + assert purchase = @gateway.purchase(@amount, response.authorization, @options) + assert_match(/Transaction Normal/, purchase.message) + assert_success purchase + + assert response = @gateway.refund(50, purchase.authorization) + assert_success response + assert_match(/Transaction Normal/, response.message) + assert response.authorization + end + def test_partial_refund purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase @@ -155,6 +178,18 @@ def test_successful_void assert_equal 'Transaction Normal - Approved', void.message end + def test_successful_void_with_stored_card + response = @gateway.store(@credit_card, @options) + assert_success response + + auth = @gateway.authorize(@amount, response.authorization, @options) + assert_success auth + + assert void = @gateway.void(auth.authorization) + assert_success void + assert_equal 'Transaction Normal - Approved', void.message + end + def test_failed_void response = @gateway.void('') assert_failure response @@ -204,7 +239,7 @@ def test_trans_error def test_transcript_scrubbing_store transcript = capture_transcript(@gateway) do - @gateway.store(@credit_card, @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) + @gateway.store(@credit_card, @options) end transcript = @gateway.scrub(transcript) @@ -217,7 +252,7 @@ def test_transcript_scrubbing_store def test_transcript_scrubbing_store_with_missing_ta_token transcript = capture_transcript(@gateway) do @options.delete(:ta_token) - @gateway.store(@credit_card, @options.merge(js_security_key: 'js-f4c4b54f08d6c44c8cad3ea80bbf92c4f4c4b54f08d6c44c')) + @gateway.store(@credit_card, @options) end transcript = @gateway.scrub(transcript) From 76de040e6f88b4a58f62c1959f783c555bb6e627 Mon Sep 17 00:00:00 2001 From: Bart <bartdewater@gmail.com> Date: Mon, 5 Mar 2018 15:46:11 -0500 Subject: [PATCH 340/677] Remove all TLS 1.0 version pins (#2774) Most of these were added years ago as workarounds. They were never revisited to see if gateways had fixed their SSL setup. By removing the pinned version requirement, the highest supported version will be negotiated between the client and the server. TLS 1.0 is old with known vulnerabilities that require server mitigations to be properly configured. Version 1.2 was released in 2008 and is considered secure with most cipher configurations. The PCI DSS v3.2 disallows TLS 1.0 unless existing implementations have applied for an exception. However, this exception is not valid after June 30, 2018. I have verified (with `curl -v`) that all live and test URLs of the affected gateways support TLS 1.2. --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/citrus_pay.rb | 1 - lib/active_merchant/billing/gateways/dibs.rb | 1 - lib/active_merchant/billing/gateways/first_pay.rb | 1 - lib/active_merchant/billing/gateways/global_transport.rb | 1 - lib/active_merchant/billing/gateways/netbilling.rb | 1 - lib/active_merchant/billing/gateways/ogone.rb | 1 - lib/active_merchant/billing/gateways/tns.rb | 1 - 8 files changed, 1 insertion(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 968be88cc7b..1c6d41183d7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -31,6 +31,7 @@ * Payflow: Support scrub [curiousepic] #2768 * SecureNet: Support scrub [curiousepic] #2769 * Payeezy: Update transaction method when using stored cards [dtykocki] #2770 +* Citrus Pay, DIBS, 1stPayGateway, Global Transport, NETbilling, Ogone, TNS: remove TLS 1.0 requirement [bdewater] #2774 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/citrus_pay.rb b/lib/active_merchant/billing/gateways/citrus_pay.rb index ae6d068818f..f8661e23e1d 100644 --- a/lib/active_merchant/billing/gateways/citrus_pay.rb +++ b/lib/active_merchant/billing/gateways/citrus_pay.rb @@ -16,7 +16,6 @@ class CitrusPayGateway < Gateway self.supported_countries = %w(AR AU BR FR DE HK MX NZ SG GB US) self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :laser] - self.ssl_version = :TLSv1 end end diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb index da5be718a3e..0121a7c6e34 100644 --- a/lib/active_merchant/billing/gateways/dibs.rb +++ b/lib/active_merchant/billing/gateways/dibs.rb @@ -9,7 +9,6 @@ class DibsGateway < Gateway self.supported_countries = ["US", "FI", "NO", "SE", "GB"] self.default_currency = "USD" self.money_format = :cents - self.ssl_version = :TLSv1 self.supported_cardtypes = [:visa, :master, :american_express, :discover] def initialize(options={}) diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb index 3627b37cc44..ad9a62c03d4 100644 --- a/lib/active_merchant/billing/gateways/first_pay.rb +++ b/lib/active_merchant/billing/gateways/first_pay.rb @@ -12,7 +12,6 @@ class FirstPayGateway < Gateway self.homepage_url = 'http://1stpaygateway.net/' self.display_name = '1stPayGateway.Net' - self.ssl_version = :TLSv1 def initialize(options={}) requires!(options, :transaction_center_id, :gateway_id) diff --git a/lib/active_merchant/billing/gateways/global_transport.rb b/lib/active_merchant/billing/gateways/global_transport.rb index 865551d2382..3ccd1159513 100644 --- a/lib/active_merchant/billing/gateways/global_transport.rb +++ b/lib/active_merchant/billing/gateways/global_transport.rb @@ -9,7 +9,6 @@ class GlobalTransportGateway < Gateway self.supported_countries = %w(CA PR US) self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb] - self.ssl_version = :TLSv1 self.homepage_url = 'https://www.globalpaymentsinc.com' self.display_name = 'Global Transport' diff --git a/lib/active_merchant/billing/gateways/netbilling.rb b/lib/active_merchant/billing/gateways/netbilling.rb index d0c1fee0167..32d48b71d6c 100644 --- a/lib/active_merchant/billing/gateways/netbilling.rb +++ b/lib/active_merchant/billing/gateways/netbilling.rb @@ -31,7 +31,6 @@ class NetbillingGateway < Gateway self.display_name = 'NETbilling' self.homepage_url = 'http://www.netbilling.com' self.supported_countries = ['US'] - self.ssl_version = :TLSv1 self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club] def initialize(options = {}) diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb index 67ab2ff6d4e..792f3f07984 100644 --- a/lib/active_merchant/billing/gateways/ogone.rb +++ b/lib/active_merchant/billing/gateways/ogone.rb @@ -141,7 +141,6 @@ class OgoneGateway < Gateway self.display_name = 'Ogone' self.default_currency = 'EUR' self.money_format = :cents - self.ssl_version = :TLSv1 def initialize(options = {}) requires!(options, :login, :user, :password) diff --git a/lib/active_merchant/billing/gateways/tns.rb b/lib/active_merchant/billing/gateways/tns.rb index e1568130a9e..0aa15904050 100644 --- a/lib/active_merchant/billing/gateways/tns.rb +++ b/lib/active_merchant/billing/gateways/tns.rb @@ -16,7 +16,6 @@ class TnsGateway < Gateway self.supported_countries = %w(AR AU BR FR DE HK MX NZ SG GB US) self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :laser] - self.ssl_version = :TLSv1 end end From 37738093b0f10236ccc2dad208ba858b9a7ae64a Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Mon, 5 Mar 2018 05:17:05 -0500 Subject: [PATCH 341/677] CardStream: Default IP and customer country Per a request from CardStream, when no IP address is specified, the default of 1.1.1.1 should be used. Additionally, when no customer country code is specified, GB should be used as a default. This also removes a Maestro remote test since Maestro now requires 3DS. Closes #2773 Remote: 26 tests, 164 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 22 tests, 114 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/card_stream.rb | 12 +++ .../gateways/remote_card_stream_test.rb | 96 ++++++++----------- test/unit/gateways/card_stream_test.rb | 18 +++- 4 files changed, 69 insertions(+), 58 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1c6d41183d7..07088b0f42c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -32,6 +32,7 @@ * SecureNet: Support scrub [curiousepic] #2769 * Payeezy: Update transaction method when using stored cards [dtykocki] #2770 * Citrus Pay, DIBS, 1stPayGateway, Global Transport, NETbilling, Ogone, TNS: remove TLS 1.0 requirement [bdewater] #2774 +* CardStream: Default IP and customer country [dtykocki] #2773 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb index fc33a4db0ca..401efe6ec4d 100644 --- a/lib/active_merchant/billing/gateways/card_stream.rb +++ b/lib/active_merchant/billing/gateways/card_stream.rb @@ -155,6 +155,7 @@ def authorize(money, credit_card_or_reference, options = {}) add_invoice(post, credit_card_or_reference, money, options) add_credit_card_or_reference(post, credit_card_or_reference) add_customer_data(post, options) + add_remote_address(post, options) commit('SALE', post) end @@ -165,6 +166,7 @@ def purchase(money, credit_card_or_reference, options = {}) add_invoice(post, credit_card_or_reference, money, options) add_credit_card_or_reference(post, credit_card_or_reference) add_customer_data(post, options) + add_remote_address(post, options) commit('SALE', post) end @@ -172,6 +174,7 @@ def capture(money, authorization, options = {}) post = {} add_pair(post, :xref, authorization) add_pair(post, :amount, amount(money), :required => true) + add_remote_address(post, options) commit('CAPTURE', post) end @@ -180,12 +183,14 @@ def refund(money, authorization, options = {}) post = {} add_pair(post, :xref, authorization) add_amount(post, money, options) + add_remote_address(post, options) commit('REFUND', post) end def void(authorization, options = {}) post = {} add_pair(post, :xref, authorization) + add_remote_address(post, options) commit('CANCEL', post) end @@ -220,6 +225,9 @@ def add_customer_data(post, options) add_pair(post, :customerAddress, "#{address[:address1]} #{address[:address2]}".strip) add_pair(post, :customerPostCode, address[:zip]) add_pair(post, :customerPhone, options[:phone]) + add_pair(post, :customerCountryCode, address[:country] || 'GB') + else + add_pair(post, :customerCountryCode, 'GB') end end @@ -273,6 +281,10 @@ def add_threeds_required(post, options) add_pair(post, :threeDSRequired, (options[:threeds_required] || @threeds_required) ? 'Y' : 'N') end + def add_remote_address(post, options={}) + add_pair(post, :remoteAddress, options[:ip] || '1.1.1.1') + end + def normalize_line_endings(str) str.gsub(/%0D%0A|%0A%0D|%0D/, "%0A") end diff --git a/test/remote/gateways/remote_card_stream_test.rb b/test/remote/gateways/remote_card_stream_test.rb index 99b6282f80d..98790c6c374 100644 --- a/test/remote/gateways/remote_card_stream_test.rb +++ b/test/remote/gateways/remote_card_stream_test.rb @@ -13,14 +13,6 @@ def setup :brand => :american_express ) - @uk_maestro = credit_card('6759015050123445002', - :month => '12', - :year => '2014', - :issue_number => '0', - :verification_value => '309', - :brand => :switch - ) - @mastercard = credit_card('5301250070000191', :month => '12', :year => '2014', @@ -29,10 +21,10 @@ def setup ) @visacreditcard = credit_card('4929421234600821', - :month => '12', - :year => '2014', - :verification_value => '356', - :brand => :visa + :month => '12', + :year => '2014', + :verification_value => '356', + :brand => :visa ) @visadebitcard = credit_card('4539791001730106', @@ -52,10 +44,12 @@ def setup :address1 => 'The Hunts Way', :city => "", :state => "Leicester", - :zip => 'SO18 1GW' + :zip => 'SO18 1GW', + :country => 'GB' }, :order_id => generate_unique_id, - :description => 'AM test purchase' + :description => 'AM test purchase', + :ip => '1.1.1.1' } @visacredit_options = { @@ -64,10 +58,12 @@ def setup :address2 => "347 Lavender Road", :city => "", :state => "Northampton", - :zip => 'NN17 8YG ' + :zip => 'NN17 8YG', + :country => 'GB' }, :order_id => generate_unique_id, - :description => 'AM test purchase' + :description => 'AM test purchase', + :ip => '1.1.1.1' } @visacredit_descriptor_options = { @@ -76,16 +72,19 @@ def setup :address2 => "347 Lavender Road", :city => "", :state => "Northampton", - :zip => 'NN17 8YG ' + :zip => 'NN17 8YG', + :country => 'GB' }, :merchant_name => 'merchant', - :dynamic_descriptor => 'product' + :dynamic_descriptor => 'product', + :ip => '1.1.1.1', } @visacredit_reference_options = { :order_id => generate_unique_id, - :description => 'AM test purchase' - } + :description => 'AM test purchase', + :ip => '1.1.1.1' + } @visadebit_options = { :billing_address => { @@ -93,10 +92,12 @@ def setup :address2 => "120 Uxbridge Road", :city => "Hatch End", :state => "Middlesex", - :zip => "HA6 7HJ" + :zip => "HA6 7HJ", + :country => 'GB' }, :order_id => generate_unique_id, - :description => 'AM test purchase' + :description => 'AM test purchase', + :ip => '1.1.1.1' } @mastercard_options = { @@ -104,22 +105,12 @@ def setup :address1 => '25 The Larches', :city => "Narborough", :state => "Leicester", - :zip => 'LE10 2RT' + :zip => 'LE10 2RT', + :country => 'GB' }, :order_id => generate_unique_id, - :description => 'AM test purchase' - } - - @uk_maestro_options = { - :billing_address => { - :address1 => 'The Parkway', - :address2 => "5258 Larches Approach", - :city => "Hull", - :state => "North Humberside", - :zip => 'HU10 5OP' - }, - :order_id => generate_unique_id, - :description => 'AM test purchase' + :description => 'AM test purchase', + :ip => '1.1.1.1' } @three_ds_enrolled_card = credit_card('4012001037141112', @@ -141,6 +132,18 @@ def test_successful_visacreditcard_authorization_and_capture assert responseCapture.test? end + def test_successful_visacreditcard_authorization_and_capture_no_billing_address + assert responseAuthorization = @gateway.authorize(142, @visacreditcard, @visacredit_options.delete(:billing_address)) + assert_equal 'APPROVED', responseAuthorization.message + assert_success responseAuthorization + assert responseAuthorization.test? + assert !responseAuthorization.authorization.blank? + assert responseCapture = @gateway.capture(142, responseAuthorization.authorization, @visacredit_options) + assert_equal 'APPROVED', responseCapture.message + assert_success responseCapture + assert responseCapture.test? + end + def test_successful_visacreditcard_purchase_and_refund assert responsePurchase = @gateway.purchase(284, @visacreditcard, @visacredit_options) assert_equal 'APPROVED', responsePurchase.message @@ -307,20 +310,6 @@ def test_declined_mastercard_purchase assert response.test? end - def test_expired_mastercard - @mastercard.year = 2012 - assert response = @gateway.purchase(142, @mastercard, @mastercard_options) - assert_equal 'CARD EXPIRED', response.message - assert_failure response - assert response.test? - end - - def test_successful_maestro_purchase - assert response = @gateway.purchase(142, @uk_maestro, @uk_maestro_options) - assert_equal 'APPROVED', response.message - assert_success response - end - def test_successful_amex_purchase assert response = @gateway.purchase(142, @amex, @amex_options) assert_equal 'APPROVED', response.message @@ -339,13 +328,6 @@ def test_invalid_login assert_failure response end - def test_usd_merchant_currency - assert response = @gateway.purchase(142, @mastercard, @mastercard_options.update(:currency => 'USD')) - assert_equal 'APPROVED', response.message - assert_success response - assert response.test? - end - def test_successful_verify response = @gateway.verify(@mastercard, @mastercard_options) assert_success response diff --git a/test/unit/gateways/card_stream_test.rb b/test/unit/gateways/card_stream_test.rb index c9bd4f98447..65a7380dd3c 100644 --- a/test/unit/gateways/card_stream_test.rb +++ b/test/unit/gateways/card_stream_test.rb @@ -116,6 +116,22 @@ def test_successful_visacreditcard_purchase_with_descriptors end.respond_with(successful_purchase_response_with_descriptors) end + def test_successful_visacreditcard_purchase_with_default_ip + stub_comms do + @gateway.purchase(284, @visacreditcard, @visacredit_options) + end.check_request do |endpoint, data, headers| + assert_match(/remoteAddress=1\.1\.1\.1/, data) + end.respond_with(successful_purchase_response_with_descriptors) + end + + 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| + assert_match(/customerCountryCode=GB/, data) + end.respond_with(successful_purchase_response) + end + def test_successful_visacreditcard_purchase_via_reference @gateway.expects(:ssl_post).returns(successful_reference_purchase_response) @@ -200,7 +216,7 @@ def test_successful_purchase_without_any_address end 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&currencyCode=826&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerName=Longbob+Longsen&customerPostCode=NN17+8YG+&merchantID=login&orderRef=AM+test+purchase&threeDSRequired=N&transactionUnique=#{@visacredit_options[:order_id]}&type=1" + post_params = "action=SALE&amount=10000&captureDelay=0&cardCVV=356&cardExpiryMonth=12&cardExpiryYear=14&cardNumber=4929421234600821&countryCode=GB&currencyCode=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| From 81e571813601216875394a549d2edf32d86f41cb Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Wed, 7 Mar 2018 09:07:27 -0500 Subject: [PATCH 342/677] Stripe: Support destination amount By default, when no destination amount is present, Stripe applies the full amount of the transction to the account when creating destination charges. With this, we'll now be able to specify a destination amount when both `destination` and `destination_amount` are present. Ref: https://stripe.com/docs/connect/destination-charges Closes #2777 Remote: 64 tests, 291 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 124 tests, 661 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/stripe.rb | 6 +- test/remote/gateways/remote_stripe_test.rb | 62 +++++++++++++++++++ test/unit/gateways/stripe_test.rb | 10 ++- 4 files changed, 77 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 07088b0f42c..0e04214f915 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -33,6 +33,7 @@ * Payeezy: Update transaction method when using stored cards [dtykocki] #2770 * Citrus Pay, DIBS, 1stPayGateway, Global Transport, NETbilling, Ogone, TNS: remove TLS 1.0 requirement [bdewater] #2774 * CardStream: Default IP and customer country [dtykocki] #2773 +* Stripe: Support destination amount [dtykocki] #2777 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index ad8b85203f7..22fc636b43d 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -335,7 +335,11 @@ def add_application_fee(post, options) end def add_destination(post, options) - post[:destination] = options[:destination] if options[:destination] + if options[:destination] + post[:destination] = {} + post[:destination][:account] = options[:destination] + post[:destination][:amount] = options[:destination_amount] if options[:destination_amount] + end end def add_expand_parameters(post, options) diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb index 1e400349583..b93cc05b795 100644 --- a/test/remote/gateways/remote_stripe_test.rb +++ b/test/remote/gateways/remote_stripe_test.rb @@ -66,6 +66,30 @@ def test_successful_purchase_with_recurring_flag assert_equal "wow@example.com", response.params["metadata"]["email"] end + def test_successful_purchase_with_destination + destination = fixtures(:stripe_destination)[:stripe_user_id] + custom_options = @options.merge(:destination => destination) + assert response = @gateway.purchase(@amount, @credit_card, custom_options) + assert_success response + assert_equal "charge", response.params["object"] + assert_equal destination, response.params["destination"] + assert response.params["paid"] + assert_equal "ActiveMerchant Test Purchase", response.params["description"] + assert_equal "wow@example.com", response.params["metadata"]["email"] + end + + def test_successful_purchase_with_destination_and_amount + destination = fixtures(:stripe_destination)[:stripe_user_id] + custom_options = @options.merge(:destination => destination, :destination_amount => @amount - 20) + assert response = @gateway.purchase(@amount, @credit_card, custom_options) + assert_success response + assert_equal "charge", response.params["object"] + assert_equal destination, response.params["destination"] + assert response.params["paid"] + assert_equal "ActiveMerchant Test Purchase", response.params["description"] + assert_equal "wow@example.com", response.params["metadata"]["email"] + end + def test_unsuccessful_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response @@ -74,6 +98,14 @@ def test_unsuccessful_purchase assert_match /ch_[a-zA-Z\d]+/, response.authorization end + def test_unsuccessful_purchase_with_destination_and_amount + destination = fixtures(:stripe_destination)[:stripe_user_id] + custom_options = @options.merge(:destination => destination, :destination_amount => @amount + 20) + assert response = @gateway.purchase(@amount, @credit_card, custom_options) + assert_failure response + assert_match %r{must be less than or equal to the charge amount}, response.message + end + def test_successful_echeck_purchase_with_verified_account customer_id = @verified_bank_account[:customer_id] bank_account_id = @verified_bank_account[:bank_account_id] @@ -103,6 +135,36 @@ def test_authorization_and_capture assert_success capture end + def test_authorization_and_capture_with_destination + destination = fixtures(:stripe_destination)[:stripe_user_id] + custom_options = @options.merge(:destination => destination) + + assert authorization = @gateway.authorize(@amount, @credit_card, custom_options) + assert_success authorization + refute authorization.params["captured"] + assert_equal destination, authorization.params["destination"] + assert_equal "ActiveMerchant Test Purchase", authorization.params["description"] + assert_equal "wow@example.com", authorization.params["metadata"]["email"] + + assert capture = @gateway.capture(@amount, authorization.authorization) + assert_success capture + end + + def test_authorization_and_capture_with_destination_and_amount + destination = fixtures(:stripe_destination)[:stripe_user_id] + custom_options = @options.merge(:destination => destination, :destination_amount => @amount - 20) + + assert authorization = @gateway.authorize(@amount, @credit_card, custom_options) + assert_success authorization + refute authorization.params["captured"] + assert_equal destination, authorization.params["destination"] + assert_equal "ActiveMerchant Test Purchase", authorization.params["description"] + assert_equal "wow@example.com", authorization.params["metadata"]["email"] + + assert capture = @gateway.capture(@amount, authorization.authorization) + assert_success capture + end + def test_authorization_and_void assert authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index 7edd06c1807..ed5f1ba319e 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -857,7 +857,15 @@ def test_destination_is_submitted_for_purchase stub_comms(@gateway, :ssl_request) do @gateway.purchase(@amount, @credit_card, @options.merge({:destination => 'subaccountid'})) end.check_request do |method, endpoint, data, headers| - assert_match(/destination=subaccountid/, data) + assert_match(/destination\[account\]=subaccountid/, data) + end.respond_with(successful_purchase_response) + end + + def test_destination_amount_is_submitted_for_purchase + stub_comms(@gateway, :ssl_request) do + @gateway.purchase(@amount, @credit_card, @options.merge({:destination => 'subaccountid', :destination_amount => @amount - 20})) + end.check_request do |method, endpoint, data, headers| + assert_match(/destination\[amount\]=#{@amount - 20}/, data) end.respond_with(successful_purchase_response) end From 941adb698e3033af6055f37daf89f68d50550f46 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Tue, 9 Jan 2018 15:18:12 -0500 Subject: [PATCH 343/677] Litle: Add Support for Echeck Adds support for Echeck and tests for certification. Loaded suite test/remote/gateways/remote_litle_test ................................... 35 tests, 136 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Loaded suite test/unit/gateways/litle_test Started ................................... 35 tests, 151 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/litle.rb | 93 +++- .../remote_litle_certification_test.rb | 410 ++++++++++++++++++ test/remote/gateways/remote_litle_test.rb | 76 +++- test/unit/gateways/litle_test.rb | 60 +++ 5 files changed, 620 insertions(+), 20 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0e04214f915..6d951dcdcef 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Litle: Add Support for Echeck [nfarve] #2776 * Orbital: Correct level 2 tax handling [deedeelavinder] #2729 * Payeezy: Change determination method of endpoint for store request [deedeelavinder] #2731 * Adyen: Return refusal_reason_raw when present [curiousepic] #2728 diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index bbf9f231984..54550cd6d17 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -23,23 +23,33 @@ def initialize(options={}) def purchase(money, payment_method, options={}) request = build_xml_request do |doc| add_authentication(doc) - doc.sale(transaction_attributes(options)) do - add_auth_purchase_params(doc, money, payment_method, options) + if check?(payment_method) + doc.echeckSale(transaction_attributes(options)) do + add_echeck_purchase_params(doc, money, payment_method, options) + end + else + doc.sale(transaction_attributes(options)) do + add_auth_purchase_params(doc, money, payment_method, options) + end end end - - commit(:sale, request, money) + check?(payment_method) ? commit(:echeckSales, request, money) : commit(:sale, request, money) end def authorize(money, payment_method, options={}) request = build_xml_request do |doc| add_authentication(doc) - doc.authorization(transaction_attributes(options)) do - add_auth_purchase_params(doc, money, payment_method, options) + if check?(payment_method) + doc.echeckVerification(transaction_attributes(options)) do + add_echeck_purchase_params(doc, money, payment_method, options) + end + else + doc.authorization(transaction_attributes(options)) do + add_auth_purchase_params(doc, money, payment_method, options) + end end end - - commit(:authorization, request, money) + check?(payment_method) ? commit(:echeckVerification, request, money) : commit(:authorization, request, money) end def capture(money, authorization, options={}) @@ -62,19 +72,24 @@ def credit(money, authorization, options = {}) refund(money, authorization, options) end - def refund(money, authorization, options={}) - transaction_id, _, _ = split_authorization(authorization) - + def refund(money, payment, options={}) request = build_xml_request do |doc| add_authentication(doc) add_descriptor(doc, options) - doc.credit(transaction_attributes(options)) do - doc.litleTxnId(transaction_id) - doc.amount(money) if money + doc.send(refund_type(payment), transaction_attributes(options)) do + if payment.is_a?(String) + transaction_id, kind, _ = split_authorization(payment) + doc.litleTxnId(transaction_id) + doc.amount(money) if money + elsif check?(payment) + add_echeck_purchase_params(doc, money, payment, options) + else + add_auth_purchase_params(doc, money, payment, options) + end end end - commit(:credit, request) + commit(refund_type(payment), request) end def verify(creditcard, options = {}) @@ -124,6 +139,8 @@ def scrub(transcript) gsub(%r((<user>).+(</user>)), '\1[FILTERED]\2'). gsub(%r((<password>).+(</password>)), '\1[FILTERED]\2'). gsub(%r((<number>).+(</number>)), '\1[FILTERED]\2'). + gsub(%r((<accNum>).+(</accNum>)), '\1[FILTERED]\2'). + gsub(%r((<routingNum>).+(</routingNum>)), '\1[FILTERED]\2'). gsub(%r((<cardValidationNum>).+(</cardValidationNum>)), '\1[FILTERED]\2'). gsub(%r((<accountNumber>).+(</accountNumber>)), '\1[FILTERED]\2'). gsub(%r((<paypageRegistrationId>).+(</paypageRegistrationId>)), '\1[FILTERED]\2'). @@ -160,7 +177,27 @@ def scrub(transcript) } def void_type(kind) - (kind == 'authorization') ? :authReversal : :void + if kind == 'authorization' + :authReversal + elsif kind == 'echeckSales' + :echeckVoid + else + :void + end + end + + def refund_type(payment) + transaction_id, kind, _ = split_authorization(payment) + if check?(payment) || kind == 'echeckSales' + :echeckCredit + else + :credit + end + end + + def check?(payment_method) + return false if payment_method.is_a?(String) + card_brand(payment_method) == 'check' end def add_authentication(doc) @@ -193,6 +230,15 @@ def add_merchant_data(doc, options={}) end end + def add_echeck_purchase_params(doc, money, payment_method, options) + doc.orderId(truncate(options[:order_id], 24)) + doc.amount(money) + add_order_source(doc, payment_method, options) + add_billing_address(doc, payment_method, options) + add_payment_method(doc, payment_method, options) + add_descriptor(doc, options) + end + def add_descriptor(doc, options) if options[:descriptor_name] || options[:descriptor_phone] doc.customBilling do @@ -215,6 +261,13 @@ def add_payment_method(doc, payment_method, options) doc.card do doc.track(payment_method.track_data) end + elsif check?(payment_method) + doc.echeck do + doc.accType(payment_method.account_type) + doc.accNum(payment_method.account_number) + doc.routingNum(payment_method.routing_number) + doc.checkNum(payment_method.number) + end else doc.card do doc.type_(CARD_TYPE[payment_method.brand]) @@ -239,7 +292,13 @@ def add_billing_address(doc, payment_method, options) return if payment_method.is_a?(String) doc.billToAddress do - doc.name(payment_method.name) + if check?(payment_method) + doc.name(payment_method.name) + doc.firstName(payment_method.first_name) + doc.lastName(payment_method.last_name) + else + doc.name(payment_method.name) + end doc.email(options[:email]) if options[:email] add_address(doc, options[:billing_address]) diff --git a/test/remote/gateways/remote_litle_certification_test.rb b/test/remote/gateways/remote_litle_certification_test.rb index f7bfe2b5704..bf7a50c81ae 100644 --- a/test/remote/gateways/remote_litle_certification_test.rb +++ b/test/remote/gateways/remote_litle_certification_test.rb @@ -433,6 +433,416 @@ def test36 puts "Test #{options[:order_id]}A: #{txn_id(reversal_response)}" end + # Echeck + def test37 + check = check( + name: 'Tom Black', + routing_number: '053100300', + account_number: '10@BC99999', + account_type: 'Checking' + ) + options = { + :order_id => '37', + :billing_address => { + :name => 'Tom Black', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :email => 'test@test.com', + :phone => '2233334444' + } + } + assert auth_response = @gateway.authorize(3001, check, options) + assert_failure auth_response + assert_equal 'Invalid Account Number', auth_response.message + assert_equal '301', auth_response.params['response'] + puts "Test #{options[:order_id]}: #{txn_id(auth_response)}" + end + + def test38 + check = check( + name: 'John Smith', + routing_number: '011075150', + account_number: '1099999999', + account_type: 'Checking' + ) + options = { + :order_id => '38', + :billing_address => { + :name => 'John Smith', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :email => 'test@test.com', + :phone => '2233334444' + } + } + assert auth_response = @gateway.authorize(3002, check, options) + assert_success auth_response + assert_equal 'Approved', auth_response.message + assert_equal '000', auth_response.params['response'] + puts "Test #{options[:order_id]}: #{txn_id(auth_response)}" + end + + def test39 + check = check( + name: 'Robert Jones', + routing_number: '053100300', + account_number: '3099999999', + account_type: 'Corporate' + ) + options = { + :order_id => '39', + :billing_address => { + :name => 'John Smith', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :company => 'Good Goods Inc', + :email => 'test@test.com', + :phone => '2233334444' + } + } + assert auth_response = @gateway.authorize(3003, check, options) + assert_failure auth_response + assert_equal 'Decline - Negative Information on File', auth_response.message + assert_equal '950', auth_response.params['response'] + puts "Test #{options[:order_id]}: #{txn_id(auth_response)}" + end + + def test40 + declined_authorize_check = check( + name: 'Peter Green', + routing_number: '011075150', + account_number: '8099999999', + account_type: 'Corporate' + ) + options = { + :order_id => '40', + :billing_address => { + :name => 'Peter Green', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :company => 'Green Co', + :email => 'test@test.com', + :phone => '2233334444' + } + } + assert auth_response = @gateway.authorize(3004, declined_authorize_check, options) + assert_failure auth_response + assert_equal 'Absolute Decline', auth_response.message + assert_equal '951', auth_response.params['response'] + puts "Test #{options[:order_id]}: #{txn_id(auth_response)}" + end + + def test41 + check = check( + name: 'Mike Hammer', + routing_number: '053100300', + account_number: '10@BC99999', + account_type: 'Checking' + ) + options = { + :order_id => '41', + :billing_address => { + :name => 'Mike Hammer', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :email => 'test@test.com', + :phone => '2233334444' + } + } + assert purchase_response = @gateway.purchase(2008, check, options) + assert_failure purchase_response + assert_equal 'Invalid Account Number', purchase_response.message + assert_equal '301', purchase_response.params['response'] + puts "Test #{options[:order_id]}: #{txn_id(purchase_response)}" + end + + def test42 + check = check( + name: 'Tom Black', + routing_number: '011075150', + account_number: '4099999992', + account_type: 'Checking' + ) + options = { + :order_id => '42', + :billing_address => { + :name => 'Tom Black', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :email => 'test@test.com', + :phone => '2233334444' + } + } + assert purchase_response = @gateway.purchase(2004, check, options) + assert_success purchase_response + assert_equal 'Approved', purchase_response.message + assert_equal '000', purchase_response.params['response'] + puts "Test #{options[:order_id]}: #{txn_id(purchase_response)}" + end + + def test43 + check = check( + name: 'Peter Green', + routing_number: '011075150', + account_number: '6099999992', + account_type: 'Corporate' + ) + options = { + :order_id => '43', + :billing_address => { + :name => 'Peter Green', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :company => 'Green Co', + :email => 'test@test.com', + :phone => '2233334444' + } + } + assert purchase_response = @gateway.purchase(2007, check, options) + assert_success purchase_response + assert_equal 'Approved', purchase_response.message + assert_equal '000', purchase_response.params['response'] + puts "Test #{options[:order_id]}: #{txn_id(purchase_response)}" + end + + def test44 + check = check( + name: 'Peter Green', + routing_number: '053133052', + account_number: '9099999992', + account_type: 'Corporate' + ) + options = { + :order_id => '44', + :billing_address => { + :name => 'Peter Green', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :company => 'Green Co', + :email => 'test@test.com', + :phone => '2233334444' + } + } + assert purchase_response = @gateway.purchase(2009, check, options) + assert_failure purchase_response + assert_equal 'Invalid Bank Routing Number', purchase_response.message + assert_equal '900', purchase_response.params['response'] + puts "Test #{options[:order_id]}: #{txn_id(purchase_response)}" + end + + def test45 + check = check( + name: 'John Smith', + routing_number: '053100300', + account_number: '10@BC99999', + account_type: 'Checking' + ) + options = { + :order_id => '45', + :billing_address => { + :name => 'John Smith', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :email => 'test@test.com', + :phone => '2233334444' + } + } + assert refund_response = @gateway.refund(1001, check, options) + assert_failure refund_response + assert_equal 'Invalid Account Number', refund_response.message + assert_equal '301', refund_response.params['response'] + puts "Test #{options[:order_id]}: #{txn_id(refund_response)}" + end + + def test46 + check = check( + name: 'Robert Jones', + routing_number: '011075150', + account_number: '3099999999', + account_type: 'Corporate' + ) + options = { + :order_id => '46', + :order_source => 'telephone', + :billing_address => { + :name => 'Robert Jones', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :email => 'test@test.com', + :phone => '2233334444', + :company => 'Widget Inc' + } + } + assert purchase_response = @gateway.purchase(1003, check, options) + sleep(10) + assert refund_response = @gateway.refund(1003, purchase_response.authorization, options) + assert_success refund_response + assert_equal 'Approved', refund_response.message + assert_equal '000', refund_response.params['response'] + puts "Test #{options[:order_id]}: #{txn_id(refund_response)}" + end + + def test47 + check = check( + name: 'Peter Green', + routing_number: '211370545', + account_number: '6099999993', + account_type: 'Corporate' + ) + options = { + :order_id => '47', + :billing_address => { + :name => 'Peter Green', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :company => 'Green Co', + :email => 'test@test.com', + :phone => '2233334444' + } + } + assert purchase_response = @gateway.purchase(1007, check, options) + assert refund_response = @gateway.refund(1007, purchase_response.authorization, options) + assert_success refund_response + assert_equal 'Approved', refund_response.message + assert_equal '000', refund_response.params['response'] + puts "Test #{options[:order_id]}: #{txn_id(refund_response)}" + end + + def test48 + check = check( + name: 'Peter Green', + routing_number: '011075150', + account_number: '6099999992', + account_type: 'Corporate' + ) + options = { + :order_id => '43', + :billing_address => { + :name => 'Peter Green', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :company => 'Green Co', + :email => 'test@test.com', + :phone => '2233334444' + } + } + assert purchase_response = @gateway.purchase(2007, check, options) + assert_success purchase_response + assert refund_response = @gateway.refund(2007, purchase_response.authorization, options) + assert_equal '000', refund_response.params['response'] + puts "Test 48: #{txn_id(refund_response)}" + end + + def test49 + assert refund_response = @gateway.refund(2007, 2) + assert_failure refund_response + assert_equal '360', refund_response.params['response'] + assert_equal 'No transaction found with specified transaction Id', refund_response.message + puts "Test 49: #{txn_id(refund_response)}" + end + + def test_echeck_void1 + check = check( + name: 'Tom Black', + routing_number: '011075150', + account_number: '4099999992', + account_type: 'Checking' + ) + options = { + :order_id => '42', + :id => '236222', + :billing_address => { + :name => 'Tom Black', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :email => 'test@test.com', + :phone => '2233334444' + } + } + assert purchase_response = @gateway.purchase(2004, check, options) + assert_success purchase_response + sleep(10) + assert void_response = @gateway.void(purchase_response.authorization) + assert_equal '000', void_response.params['response'] + puts "Test void1: #{txn_id(void_response)}" + end + + def test_echeck_void2 + check = check( + name: 'Robert Jones', + routing_number: '011075150', + account_number: '3099999999', + account_type: 'Checking' + ) + options = { + :order_id => '46', + :id => '232222', + :billing_address => { + :name => 'Robert Jones', + :address1 => '8 Main St.', + :city => 'Manchester', + :state => 'NH', + :zip => '03101', + :country => 'US', + :email => 'test@test.com', + :phone => '2233334444' + } + } + assert purchase_response = @gateway.purchase(1003, check, options) + assert_success purchase_response + sleep(20) + assert void_response = @gateway.void(purchase_response.authorization) + assert_equal '000', void_response.params['response'] + puts "Test void2: #{txn_id(void_response)}" + end + + def test_echeck_void3 + assert void_response = @gateway.void(2) + assert_failure void_response + assert_equal '360', void_response.params['response'] + assert_equal 'No transaction found with specified transaction Id', void_response.message + puts "Test void3: #{txn_id(void_response)}" + end + # Explicit Token Registration Tests def test50 credit_card = CreditCard.new(:number => '4457119922390123') diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb index 6ac94ec75e9..051a7b9f913 100644 --- a/test/remote/gateways/remote_litle_test.rb +++ b/test/remote/gateways/remote_litle_test.rb @@ -63,6 +63,18 @@ def setup number: "4457000300000007", payment_cryptogram: "BwABBJQ1AgAAAAAgJDUCAAAAAAA=" }) + @check = check( + name: 'Tom Black', + routing_number: '011075150', + account_number: '4099999992', + account_type: 'Checking' + ) + @authorize_check = check( + name: 'John Smith', + routing_number: '011075150', + account_number: '1099999999', + account_type: 'Checking' + ) end def test_successful_authorization @@ -78,6 +90,14 @@ def test_successful_authorization_with_merchant_data merchant_grouping_id: 'brilliant-group' ) assert response = @gateway.authorize(10010, @credit_card1, options) + end + + def test_successful_authorization_with_echeck + options = @options.merge({ + order_id: '38', + order_source: 'telephone' + }) + assert response = @gateway.authorize(3002, @authorize_check, options) assert_success response assert_equal 'Approved', response.message end @@ -163,6 +183,16 @@ def test_successful_purchase_with_merchant_data assert_equal 'Approved', response.message end + def test_successful_purchase_with_echeck + options = @options.merge({ + order_id: '42', + order_source: 'telephone' + }) + assert response = @gateway.purchase(2004, @check, options) + assert_success response + assert_equal 'Approved', response.message + end + def test_unsuccessful_purchase assert response = @gateway.purchase(60060, @credit_card2, { :order_id=>'6', @@ -198,6 +228,18 @@ def test_authorization_capture_refund_void assert_equal 'Approved', void.message end + def test_void_with_echeck + options = @options.merge({ + order_id: '42', + order_source: 'telephone' + }) + assert sale = @gateway.purchase(2004, @check, options) + + assert void = @gateway.void(sale.authorization) + assert_success void + assert_equal 'Approved', void.message + end + def test_void_authorization assert auth = @gateway.authorize(10010, @credit_card1, @options) @@ -220,6 +262,18 @@ def test_partial_refund assert_equal 'Approved', refund.message end + def test_partial_refund_with_echeck + options = @options.merge({ + order_id: '82', + order_source: 'telephone' + }) + assert purchase = @gateway.purchase(2004, @check, options) + + assert refund = @gateway.refund(444, purchase.authorization) + assert_success refund + assert_equal 'Approved', refund.message + end + def test_partial_capture assert auth = @gateway.authorize(10010, @credit_card1, @options) assert_success auth @@ -251,19 +305,19 @@ def test_nil_amount_capture end def test_capture_unsuccessful - assert capture_response = @gateway.capture(10010, 123456789012345360) + assert capture_response = @gateway.capture(10010, '123456789012345360') assert_failure capture_response assert_equal 'No transaction found with specified litleTxnId', capture_response.message end def test_refund_unsuccessful - assert credit_response = @gateway.refund(10010, 123456789012345360) + assert credit_response = @gateway.refund(10010, '123456789012345360') assert_failure credit_response assert_equal 'No transaction found with specified litleTxnId', credit_response.message end def test_void_unsuccessful - assert void_response = @gateway.void(123456789012345360) + assert void_response = @gateway.void('123456789012345360') assert_failure void_response assert_equal 'No transaction found with specified litleTxnId', void_response.message end @@ -355,4 +409,20 @@ def test_purchase_scrubbing assert_scrubbed(@gateway.options[:login], transcript) assert_scrubbed(@gateway.options[:password], transcript) end + + def test_echeck_scrubbing + options = @options.merge({ + order_id: '42', + order_source: 'telephone' + }) + transcript = capture_transcript(@gateway) do + @gateway.purchase(2004, @check, options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@check.account_number, transcript) + assert_scrubbed(@check.routing_number, transcript) + assert_scrubbed(@gateway.options[:login], transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end end diff --git a/test/unit/gateways/litle_test.rb b/test/unit/gateways/litle_test.rb index 68936b4cb9d..0687e48ea35 100644 --- a/test/unit/gateways/litle_test.rb +++ b/test/unit/gateways/litle_test.rb @@ -32,6 +32,18 @@ def setup }) @amount = 100 @options = {} + @check = check( + name: 'Tom Black', + routing_number: '011075150', + account_number: '4099999992', + account_type: 'Checking' + ) + @authorize_check = check( + name: 'John Smith', + routing_number: '011075150', + account_number: '1099999999', + account_type: 'Checking' + ) end def test_successful_purchase @@ -45,6 +57,17 @@ def test_successful_purchase assert response.test? end + def test_successful_purchase_with_echeck + response = stub_comms do + @gateway.purchase(2004, @check) + end.respond_with(successful_purchase_with_echeck_response) + + assert_success response + + assert_equal "621100411297330000;echeckSales;2004", response.authorization + assert response.test? + end + def test_failed_purchase response = stub_comms do @gateway.purchase(@amount, @credit_card) @@ -264,6 +287,15 @@ def test_failed_void_of_other_things assert_equal "360", response.params["response"] end + def test_successful_void_of_echeck + response = stub_comms do + @gateway.void("945032206979933000;echeckSales;2004") + end.respond_with(successful_void_of_echeck_response) + + assert_success response + assert_equal "986272331806746000;echeckVoid;", response.authorization + end + def test_successful_store response = stub_comms do @gateway.store(@credit_card) @@ -386,6 +418,20 @@ def successful_purchase_response ) end + def successful_purchase_with_echeck_response + %( + <litleOnlineResponse version='9.12' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'> + <echeckSalesResponse id='42' reportGroup='Default Report Group' customerId=''> + <litleTxnId>621100411297330000</litleTxnId> + <orderId>42</orderId> + <response>000</response> + <responseTime>2018-01-09T14:02:20</responseTime> + <message>Approved</message> + </echeckSalesResponse> + </litleOnlineResponse> + ) + end + def failed_purchase_response %( <litleOnlineResponse version='8.22' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'> @@ -520,6 +566,20 @@ def successful_void_of_other_things_response ) end + def successful_void_of_echeck_response + %( + <litleOnlineResponse version='9.12' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'> + <echeckVoidResponse id='' reportGroup='Default Report Group' customerId=''> + <litleTxnId>986272331806746000</litleTxnId> + <response>000</response> + <responseTime>2018-01-09T14:20:00</responseTime> + <message>Approved</message> + <postDate>2018-01-09</postDate> + </echeckVoidResponse> + </litleOnlineResponse> + ) + end + def failed_void_of_authorization_response %( <litleOnlineResponse version='8.22' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'> From 4087e3dd32d62a15d2eb6638325343e16f6f2ef7 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Fri, 9 Mar 2018 09:33:02 -0500 Subject: [PATCH 344/677] Litle: Add store for echecks Adds the ability to store ehecks if merchant has enabled the tokenization feature. Loaded suite test/remote/gateways/remote_litle_test ..................................... 37 tests, 145 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Loaded suite test/unit/gateways/litle_test ................................... 35 tests, 151 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/litle.rb | 5 +++ .../remote_litle_certification_test.rb | 36 +++++++++++++++++++ test/remote/gateways/remote_litle_test.rb | 17 +++++++++ 4 files changed, 59 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 6d951dcdcef..8c2f23ba82a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Litle: Add store for echecks [nfarve] #2779 * Litle: Add Support for Echeck [nfarve] #2776 * Orbital: Correct level 2 tax handling [deedeelavinder] #2729 * Payeezy: Change determination method of endpoint for store request [deedeelavinder] #2731 diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index 54550cd6d17..14b3658b0d5 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -120,6 +120,11 @@ def store(payment_method, options = {}) doc.orderId(truncate(options[:order_id], 24)) if payment_method.is_a?(String) doc.paypageRegistrationId(payment_method) + elsif check?(payment_method) + doc.echeckForToken do + doc.accNum(payment_method.account_number) + doc.routingNum(payment_method.routing_number) + end else doc.accountNumber(payment_method.number) doc.cardValidationNum(payment_method.verification_value) if payment_method.verification_value diff --git a/test/remote/gateways/remote_litle_certification_test.rb b/test/remote/gateways/remote_litle_certification_test.rb index bf7a50c81ae..23bd7fafd13 100644 --- a/test/remote/gateways/remote_litle_certification_test.rb +++ b/test/remote/gateways/remote_litle_certification_test.rb @@ -895,6 +895,42 @@ def test52 puts "Test #{options[:order_id]}: #{txn_id(store_response)}" end + def test53 + check = check( + routing_number: '011100012', + account_number: '1099999998' + ) + options = { + :order_id => '53' + } + + store_response = @gateway.store(check, options) + + assert_success store_response + assert_equal '998', store_response.params['eCheckAccountSuffix'] + assert_equal 'EC', store_response.params['type'] + assert_equal '801', store_response.params['response'] + assert_equal 'Account number was successfully registered', store_response.message + puts "Test #{options[:order_id]}: #{txn_id(store_response)}" + end + + def test54 + check = check( + routing_number: '1145_7895', + account_number: '1022222102' + ) + options = { + :order_id => '54' + } + + store_response = @gateway.store(check, options) + + assert_failure store_response + assert_equal '900', store_response.params['response'] + assert_equal 'Invalid Bank Routing Number', store_response.message + puts "Test #{options[:order_id]}: #{txn_id(store_response)}" + end + # Implicit Token Registration Tests def test55 credit_card = CreditCard.new(:number => '5435101234510196', diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb index 051a7b9f913..014cbdd8afe 100644 --- a/test/remote/gateways/remote_litle_test.rb +++ b/test/remote/gateways/remote_litle_test.rb @@ -75,6 +75,10 @@ def setup account_number: '1099999999', account_type: 'Checking' ) + @store_check = check( + routing_number: '011100012', + account_number: '1099999998' + ) end def test_successful_authorization @@ -366,6 +370,19 @@ def test_store_and_purchase_with_token_successful assert_equal 'Approved', response.message end + def test_echeck_store_and_purchase + assert store_response = @gateway.store(@store_check) + assert_success store_response + assert_equal 'Account number was successfully registered', store_response.message + + token = store_response.authorization + assert_equal store_response.params['litleToken'], token + + assert response = @gateway.purchase(10010, token) + assert_success response + assert_equal 'Approved', response.message + end + def test_successful_verify assert response = @gateway.verify(@credit_card1, @options) assert_success response From 04d213a01dbe2a7659b626d5a8a1371bcdecf606 Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Wed, 14 Mar 2018 15:14:30 -0400 Subject: [PATCH 345/677] GlobalCollect: Update supported country list Remote: 15 tests, 35 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 6 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2783 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/global_collect.rb | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8c2f23ba82a..e5dd3f57b4b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -36,6 +36,7 @@ * Citrus Pay, DIBS, 1stPayGateway, Global Transport, NETbilling, Ogone, TNS: remove TLS 1.0 requirement [bdewater] #2774 * CardStream: Default IP and customer country [dtykocki] #2773 * Stripe: Support destination amount [dtykocki] #2777 +* GlobalCollect: Update supported country list [dtykocki] #2783 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index b898100b97f..67c4afeca69 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -7,10 +7,7 @@ class GlobalCollectGateway < Gateway self.test_url = "https://api-sandbox.globalcollect.com/" self.live_url = "https://api.globalcollect.com/" - self.supported_countries = %w(AD AE AT AU BD BE BG BN CA CH CY CZ DE DK - EE EG ES FI FR GB GI GR HK HU ID IE IL IM IN IS IT JO KW LB LI LK LT LU - LV MC MT MU MV MX MY NL NO NZ OM PH PL PT QA RO SA SE SG SI SK SM TR - UM US VA VN ZA) + self.supported_countries = ["AD", "AE", "AG", "AI", "AL", "AM", "AO", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PL", "PN", "PS", "PT", "PW", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SR", "ST", "SV", "SZ", "TC", "TD", "TG", "TH", "TJ", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "US", "UY", "UZ", "VC", "VE", "VG", "VI", "VN", "WF", "WS", "ZA", "ZM", "ZW"] self.default_currency = "USD" self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express, :discover] From 09ae8688b7713cf6da888bd8cd54eab9364c3ec5 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Mon, 5 Mar 2018 14:04:33 -0500 Subject: [PATCH 346/677] Adyen: Support store action As part of implementation, I preserved the behavior of retaining original psp references for refunds, and account for backwards compatability with pre-existing non-compound authorizations. Also removes an irrelevant test case (a capture should never have a compound authorization) and switches Verify to a 0 amount, since it is supported. Closes #2784 Remote: 32 tests, 81 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 18 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 92 ++++++++++++++----- test/remote/gateways/remote_adyen_test.rb | 33 +++++++ test/unit/gateways/adyen_test.rb | 51 ++++++---- 4 files changed, 136 insertions(+), 41 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e5dd3f57b4b..6ef99421a2f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -37,6 +37,7 @@ * CardStream: Default IP and customer country [dtykocki] #2773 * Stripe: Support destination amount [dtykocki] #2777 * GlobalCollect: Update supported country list [dtykocki] #2783 +* Adyen: Support store action [curiousepic] #2784 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index e199ed15282..e6a60ee63fd 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -45,34 +45,45 @@ def authorize(money, payment, options={}) add_invoice(post, money, options) add_payment(post, payment) add_extra_data(post, options) - add_shopper_interaction(post,payment,options) + add_shopper_interaction(post, payment, options) add_address(post, options) commit('authorise', post) end def capture(money, authorization, options={}) post = init_post(options) - add_invoice_for_modification(post, money, authorization, options) - add_references(post, authorization, options) + add_invoice_for_modification(post, money, options) + add_reference(post, authorization, options) commit('capture', post) end def refund(money, authorization, options={}) post = init_post(options) - add_invoice_for_modification(post, money, authorization, options) - add_references(post, authorization, options) + add_invoice_for_modification(post, money, options) + add_original_reference(post, authorization, options) commit('refund', post) end def void(authorization, options={}) post = init_post(options) - add_references(post, authorization, options) + add_reference(post, authorization, options) commit('cancel', post) end + def store(credit_card, options={}) + requires!(options, :order_id) + post = init_post(options) + add_invoice(post, 0, options) + add_payment(post, credit_card) + add_extra_data(post, options) + add_recurring_contract(post, options) + add_address(post, options) + commit('authorise', post) + end + def verify(credit_card, options={}) MultiResponse.run(:use_first_response) do |r| - r.process { authorize(100, credit_card, options) } + r.process { authorize(0, credit_card, options) } r.process(:ignore_result) { void(r.authorization, options) } end end @@ -101,7 +112,12 @@ def add_extra_data(post, options) end def add_shopper_interaction(post, payment, options={}) - shopper_interaction = payment.verification_value ? "Ecommerce" : "ContAuth" + if payment.respond_to?(:verification_value) && payment.verification_value + shopper_interaction = "Ecommerce" + else + shopper_interaction = "ContAuth" + end + post[:shopperInteraction] = options[:shopper_interaction] || shopper_interaction end @@ -123,11 +139,10 @@ def add_invoice(post, money, options) value: amount(money), currency: options[:currency] || currency(money) } - post[:reference] = options[:order_id] post[:amount] = amount end - def add_invoice_for_modification(post, money, authorization, options) + def add_invoice_for_modification(post, money, options) amount = { value: amount(money), currency: options[:currency] || currency(money) @@ -136,12 +151,22 @@ def add_invoice_for_modification(post, money, authorization, options) end def add_payment(post, payment) + if payment.is_a?(String) + _, _, recurring_detail_reference = payment.split("#") + post[:selectedRecurringDetailReference] = recurring_detail_reference + add_recurring_contract(post, options) + else + add_card(post, payment) + end + end + + def add_card(post, credit_card) card = { - expiryMonth: payment.month, - expiryYear: payment.year, - holderName: payment.name, - number: payment.number, - cvc: payment.verification_value + expiryMonth: credit_card.month, + expiryYear: credit_card.year, + holderName: credit_card.name, + number: credit_card.number, + cvc: credit_card.verification_value } card.delete_if{|k,v| v.blank? } @@ -149,9 +174,26 @@ def add_payment(post, payment) post[:card] = card end - def add_references(post, authorization, options = {}) - post[:originalReference] = psp_reference_from(authorization) - post[:reference] = options[:order_id] + def add_reference(post, authorization, options = {}) + _, psp_reference, _ = authorization.split("#") + post[:originalReference] = single_reference(authorization) || psp_reference + end + + def add_original_reference(post, authorization, options = {}) + original_psp_reference, _, _ = authorization.split("#") + post[:originalReference] = single_reference(authorization) || original_psp_reference + end + + def single_reference(authorization) + authorization if !authorization.include?("#") + end + + def add_recurring_contract(post, options = {}) + recurring = { + contract: "RECURRING" + } + + post[:recurring] = recurring end def parse(body) @@ -218,11 +260,16 @@ def authorize_message_from(response) end def authorization_from(action, parameters, response) - [parameters[:originalReference], response['pspReference']].compact.join("#").presence + return nil if response['pspReference'].nil? + recurring = response['additionalData']['recurring.recurringDetailReference'] if response['additionalData'] + "#{parameters[:originalReference]}##{response['pspReference']}##{recurring}" end def init_post(options = {}) - {merchantAccount: options[:merchant_account] || @merchant_account} + post = {} + post[:merchantAccount] = options[:merchant_account] || @merchant_account + post[:reference] = options[:order_id] if options[:order_id] + post end def post_data(action, parameters = {}) @@ -232,11 +279,6 @@ def post_data(action, parameters = {}) def error_code_from(response) STANDARD_ERROR_CODE_MAPPING[response['errorCode']] end - - def psp_reference_from(authorization) - authorization.nil? ? nil : authorization.split("#").first - end - end end end diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb index 672a41ee754..21232d33bed 100644 --- a/test/remote/gateways/remote_adyen_test.rb +++ b/test/remote/gateways/remote_adyen_test.rb @@ -127,6 +127,39 @@ def test_failed_void assert_equal 'Original pspReference required for this operation', response.message end + def test_successful_store + assert response = @gateway.store(@credit_card, @options) + + assert_success response + assert !response.authorization.split("#")[2].nil? + assert_equal 'Authorised', response.message + end + + def test_failed_store + assert response = @gateway.store(@declined_card, @options) + + assert_failure response + assert_equal 'Refused', response.message + end + + def test_successful_purchase_using_stored_card + assert store_response = @gateway.store(@credit_card, @options) + assert_success store_response + + response = @gateway.purchase(@amount, store_response.authorization, @options) + assert_success response + assert_equal '[capture-received]', response.message + end + + def test_successful_authorize_using_stored_card + assert store_response = @gateway.store(@credit_card, @options) + assert_success store_response + + response = @gateway.authorize(@amount, store_response.authorization, @options) + assert_success response + assert_equal 'Authorised', response.message + end + def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index 933a76af945..1411a477460 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -23,6 +23,7 @@ def setup @options = { billing_address: address(), + shopper_reference: "John Smith", order_id: '345123' } end @@ -33,7 +34,7 @@ def test_successful_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal '7914775043909934', response.authorization + assert_equal '#7914775043909934#', response.authorization assert response.test? end @@ -48,15 +49,7 @@ def test_failed_authorize def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) response = @gateway.capture(@amount, '7914775043909934') - assert_equal '7914775043909934#8814775564188305', response.authorization - assert_success response - assert response.test? - end - - def test_successful_capture_with_compount_psp_reference - @gateway.expects(:ssl_post).returns(successful_capture_response) - response = @gateway.capture(@amount, '7914775043909934#8514775559000000') - assert_equal '7914775043909934#8814775564188305', response.authorization + assert_equal '7914775043909934#8814775564188305#', response.authorization assert_success response assert response.test? end @@ -74,7 +67,7 @@ def test_successful_purchase @gateway.purchase(@amount, @credit_card, @options) end.respond_with(successful_authorize_response, successful_capture_response) assert_success response - assert_equal '7914775043909934#8814775564188305', response.authorization + assert_equal '7914775043909934#8814775564188305#', response.authorization assert response.test? end @@ -90,7 +83,7 @@ def test_failed_purchase def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) response = @gateway.refund(@amount, '7914775043909934') - assert_equal '7914775043909934#8514775559925128', response.authorization + assert_equal '7914775043909934#8514775559925128#', response.authorization assert_equal '[refund-received]', response.message assert response.test? end @@ -98,7 +91,7 @@ def test_successful_refund def test_successful_refund_with_compound_psp_reference @gateway.expects(:ssl_post).returns(successful_refund_response) response = @gateway.refund(@amount, '7914775043909934#8514775559000000') - assert_equal '7914775043909934#8514775559925128', response.authorization + assert_equal '7914775043909934#8514775559925128#', response.authorization assert_equal '[refund-received]', response.message assert response.test? end @@ -114,7 +107,7 @@ def test_failed_refund def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) response = @gateway.void('7914775043909934') - assert_equal '7914775043909934#8614775821628806', response.authorization + assert_equal '7914775043909934#8614775821628806#', response.authorization assert_equal '[cancel-received]', response.message assert response.test? end @@ -126,12 +119,26 @@ def test_failed_void assert_failure response end + def test_successful_store + @gateway.expects(:ssl_post).returns(successful_store_response) + response = @gateway.store(@credit_card, @options) + assert_success response + assert_equal "#8835205392522157#8315202663743702", response.authorization + end + + def test_failed_store + @gateway.expects(:ssl_post).returns(failed_store_response) + response = @gateway.store(@credit_card, @options) + assert_failure response + assert_equal 'Refused', response.message + end + def test_successful_verify response = stub_comms do @gateway.verify(@credit_card, @options) end.respond_with(successful_verify_response) assert_success response - assert_equal '7914776426645103', response.authorization + assert_equal '#7914776426645103#', response.authorization assert_equal 'Authorised', response.message assert response.test? end @@ -141,7 +148,7 @@ def test_failed_verify @gateway.verify(@credit_card, @options) end.respond_with(failed_verify_response) assert_failure response - assert_equal '7914776433387947', response.authorization + assert_equal '#7914776433387947#', response.authorization assert_equal 'Refused', response.message assert response.test? end @@ -355,4 +362,16 @@ def failed_authorize_avs_response {\"additionalData\":{\"cvcResult\":\"0 Unknown\",\"fraudResultType\":\"GREEN\",\"avsResult\":\"3 AVS unavailable\",\"fraudManualReview\":\"false\",\"avsResultRaw\":\"U\",\"refusalReasonRaw\":\"05 : Do not honor\",\"authorisationMid\":\"494619000001174\",\"acquirerCode\":\"AdyenVisa_BR_494619\",\"acquirerReference\":\"802320302458\",\"acquirerAccountCode\":\"AdyenVisa_BR_Cabify\"},\"fraudResult\":{\"accountScore\":0,\"results\":[{\"FraudCheckResult\":{\"accountScore\":0,\"checkId\":46,\"name\":\"DistinctCountryUsageByShopper\"}}]},\"pspReference\":\"1715167376763498\",\"refusalReason\":\"Refused\",\"resultCode\":\"Refused\"} RESPONSE end + + def successful_store_response + <<-RESPONSE + {"additionalData":{"recurring.recurringDetailReference":"8315202663743702","recurring.shopperReference":"John Smith"},"pspReference":"8835205392522157","resultCode":"Authorised","authCode":"94571"} + RESPONSE + end + + def failed_store_response + <<-RESPONSE + {"pspReference":"8835205393394754","refusalReason":"Refused","resultCode":"Refused"} + RESPONSE + end end From 71074fa13f4497dade9257be6ca9b771322a30d8 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Thu, 15 Mar 2018 15:18:19 -0400 Subject: [PATCH 347/677] Psigate: Update Test URL and Card Update the test url and the test card number for Psigate. Loaded suite test/remote/gateways/remote_psigate_test ...... 6 tests, 20 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Loaded suite test/unit/gateways/psigate_test ........... 11 tests, 28 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/psigate.rb | 2 +- test/remote/gateways/remote_psigate_test.rb | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6ef99421a2f..21cc9f4af54 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -38,6 +38,7 @@ * Stripe: Support destination amount [dtykocki] #2777 * GlobalCollect: Update supported country list [dtykocki] #2783 * Adyen: Support store action [curiousepic] #2784 +* Psigate: Update Test URL and Card [nfarve] #2785 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/psigate.rb b/lib/active_merchant/billing/gateways/psigate.rb index f6e017359e2..aa9a5fa53f1 100644 --- a/lib/active_merchant/billing/gateways/psigate.rb +++ b/lib/active_merchant/billing/gateways/psigate.rb @@ -35,7 +35,7 @@ module Billing #:nodoc: # :email => 'jack@yahoo.com' # ) class PsigateGateway < Gateway - self.test_url = 'https://dev.psigate.com:7989/Messenger/XMLMessenger' + self.test_url = 'https://staging.psigate.com:17989/Messenger/XMLMessenger' self.live_url = 'https://secure.psigate.com:17934/Messenger/XMLMessenger' self.supported_cardtypes = [:visa, :master, :american_express] diff --git a/test/remote/gateways/remote_psigate_test.rb b/test/remote/gateways/remote_psigate_test.rb index ec740a3ed37..ea414c797da 100644 --- a/test/remote/gateways/remote_psigate_test.rb +++ b/test/remote/gateways/remote_psigate_test.rb @@ -5,9 +5,10 @@ class PsigateRemoteTest < Test::Unit::TestCase def setup Base.mode = :test @gateway = PsigateGateway.new(fixtures(:psigate)) + PsigateGateway.ssl_strict = false @amount = 2400 - @creditcard = credit_card('4242424242424242') + @creditcard = credit_card('4111111111111111') @options = { :order_id => generate_unique_id, :billing_address => address, From 8939f396942c722a80ea969f0003ef98305726da Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Wed, 7 Mar 2018 16:14:43 -0500 Subject: [PATCH 348/677] USA ePay Transaction: Support ACH/eChecks Closes #2786 Remote: 24 tests, 95 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 44 tests, 257 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/usa_epay_transaction.rb | 48 +++++----- .../remote_usa_epay_transaction_test.rb | 39 ++++++++ .../gateways/usa_epay_transaction_test.rb | 90 +++++++++++++++++++ 4 files changed, 157 insertions(+), 21 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 21cc9f4af54..d3ac51fcd84 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -39,6 +39,7 @@ * GlobalCollect: Update supported country list [dtykocki] #2783 * Adyen: Support store action [curiousepic] #2784 * Psigate: Update Test URL and Card [nfarve] #2785 +* USA ePay Transaction: Support ACH/eChecks [curiousepic] #2786 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb index 5b4cb4cb4e0..27acbf6c0c5 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb @@ -16,7 +16,8 @@ class UsaEpayTransactionGateway < Gateway :capture => 'cc:capture', :refund => 'cc:refund', :void => 'cc:void', - :void_release => 'cc:void:release' + :void_release => 'cc:void:release', + :check_purchase => 'check:sale' } STANDARD_ERROR_CODE_MAPPING = { @@ -48,7 +49,7 @@ def authorize(money, credit_card, options = {}) add_amount(post, money) add_invoice(post, options) - add_credit_card(post, credit_card) + add_payment(post, credit_card) unless credit_card.track_data.present? add_address(post, credit_card, options) add_customer_data(post, options) @@ -59,20 +60,20 @@ def authorize(money, credit_card, options = {}) commit(:authorization, post) end - def purchase(money, credit_card, options = {}) + def purchase(money, payment, options = {}) post = {} add_amount(post, money) add_invoice(post, options) - add_credit_card(post, credit_card) - unless credit_card.track_data.present? - add_address(post, credit_card, options) + add_payment(post, payment) + unless payment.respond_to?(:track_data) && payment.track_data.present? + add_address(post, payment, options) add_customer_data(post, options) end add_split_payments(post, options) add_test_mode(post, options) - commit(:purchase, post) + payment.respond_to?(:routing_number) ? commit(:check_purchase, post) : commit(:purchase, post) end def capture(money, authorization, options = {}) @@ -115,6 +116,7 @@ def scrub(transcript) gsub(%r((&?UMcard=)\d*(&?))i, '\1[FILTERED]\2'). gsub(%r((&?UMcvv2=)\d*(&?))i, '\1[FILTERED]\2'). gsub(%r((&?UMmagstripe=)[^&]*)i, '\1[FILTERED]\2'). + gsub(%r((&?UMaccount=)[^&]*)i, '\1[FILTERED]'). gsub(%r((&?UMkey=)[^&]*)i, '\1[FILTERED]') end @@ -150,19 +152,19 @@ def add_customer_data(post, options) end end - def add_address(post, credit_card, options) + def add_address(post, payment, options) billing_address = options[:billing_address] || options[:address] - add_address_for_type(:billing, post, credit_card, billing_address) if billing_address - add_address_for_type(:shipping, post, credit_card, options[:shipping_address]) if options[:shipping_address] + add_address_for_type(:billing, post, payment, billing_address) if billing_address + add_address_for_type(:shipping, post, payment, options[:shipping_address]) if options[:shipping_address] end - def add_address_for_type(type, post, credit_card, address) + def add_address_for_type(type, post, payment, address) prefix = address_key_prefix(type) first_name, last_name = split_names(address[:name]) - post[address_key(prefix, 'fname')] = first_name.blank? && last_name.blank? ? credit_card.first_name : first_name - post[address_key(prefix, 'lname')] = first_name.blank? && last_name.blank? ? credit_card.last_name : last_name + post[address_key(prefix, 'fname')] = first_name.blank? && last_name.blank? ? payment.first_name : first_name + post[address_key(prefix, 'lname')] = first_name.blank? && last_name.blank? ? payment.last_name : last_name post[address_key(prefix, 'company')] = address[:company] unless address[:company].blank? post[address_key(prefix, 'street')] = address[:address1] unless address[:address1].blank? post[address_key(prefix, 'street2')] = address[:address2] unless address[:address2].blank? @@ -189,16 +191,20 @@ def add_invoice(post, options) post[:description] = options[:description] end - def add_credit_card(post, credit_card) - if credit_card.track_data.present? - post[:magstripe] = credit_card.track_data + def add_payment(post, payment) + if payment.respond_to?(:routing_number) + post[:account] = payment.account_number + post[:routing] = payment.routing_number + post[:name] = payment.name unless payment.name.blank? + elsif payment.respond_to?(:track_data) && payment.track_data.present? + post[:magstripe] = payment.track_data post[:cardpresent] = true else - post[:card] = credit_card.number - post[:cvv2] = credit_card.verification_value if credit_card.verification_value? - post[:expir] = expdate(credit_card) - post[:name] = credit_card.name unless credit_card.name.blank? - post[:cardpresent] = true if credit_card.manual_entry + post[:card] = payment.number + post[:cvv2] = payment.verification_value if payment.verification_value? + post[:expir] = expdate(payment) + post[:name] = payment.name unless payment.name.blank? + post[:cardpresent] = true if payment.manual_entry end end diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb index 8f6d6df64cf..c1e9a6469bc 100644 --- a/test/remote/gateways/remote_usa_epay_transaction_test.rb +++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb @@ -6,6 +6,7 @@ def setup @credit_card = credit_card('4000100011112224') @declined_card = credit_card('4000300011112220') @credit_card_with_track_data = credit_card_with_track_data('4000100011112224') + @check = check @options = { :billing_address => address(:zip => "27614", :state => "NC"), :shipping_address => address } @amount = 100 end @@ -22,6 +23,12 @@ def test_successful_purchase_with_track_data assert_success response end + def test_successful_purchase_with_echeck + assert response = @gateway.purchase(@amount, @check, @options) + assert_equal 'Success', response.message + assert_success response + end + def test_successful_authorization_with_manual_entry @credit_card.manual_entry = true assert response = @gateway.authorize(@amount, @credit_card, @options) @@ -89,6 +96,14 @@ def test_successful_refund_with_track_data assert_success refund end + def test_successful_refund_of_echeck + assert response = @gateway.purchase(@amount, @check, @options) + assert_success response + assert response.authorization + assert refund = @gateway.refund(@amount - 20, response.authorization) + assert_success refund + end + def test_unsuccessful_refund assert refund = @gateway.refund(@amount - 20, "unknown_authorization") assert_failure refund @@ -103,6 +118,14 @@ def test_successful_void assert_success void end + def test_successful_void_with_echeck + assert response = @gateway.purchase(@amount, @check, @options) + assert_success response + assert response.authorization + assert void = @gateway.void(response.authorization) + assert_success void + end + def test_unsuccessful_void assert void = @gateway.void("unknown_authorization") assert_failure void @@ -117,6 +140,14 @@ def test_successful_void_release assert_success void end + def test_successful_void_release_with_echeck + assert response = @gateway.purchase(@amount, @check, @options) + assert_success response + assert response.authorization + assert void = @gateway.void(response.authorization, void_mode: :void_release) + assert_success void + end + def test_unsuccessful_void_release assert void = @gateway.void("unknown_authorization", void_mode: :void_release) assert_failure void @@ -160,5 +191,13 @@ def test_transcript_scrubbing assert_scrubbed(@credit_card_with_track_data.track_data, transcript) assert_scrubbed(@gateway.options[:login], transcript) + + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @check, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@check.account_number, transcript) + assert_scrubbed(@gateway.options[:login], transcript) end end diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb index ad3aa238617..b427560ad1a 100644 --- a/test/unit/gateways/usa_epay_transaction_test.rb +++ b/test/unit/gateways/usa_epay_transaction_test.rb @@ -7,6 +7,7 @@ def setup @gateway = UsaEpayTransactionGateway.new(:login => 'LOGIN') @credit_card = credit_card('4242424242424242') + @check = check @options = { :billing_address => address, :shipping_address => address @@ -43,6 +44,15 @@ def test_successful_request assert response.test? end + def test_successful_request_with_echeck + @gateway.expects(:ssl_post).returns(successful_purchase_response_echeck) + + response = @gateway.purchase(@amount, @check, @options) + assert_success response + assert_equal '133134803', response.authorization + assert response.test? + end + def test_unsuccessful_request @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response) @@ -174,6 +184,15 @@ def test_successful_refund_request assert response.test? end + def test_successful_refund_request_with_echeck + @gateway.expects(:ssl_post).returns(successful_refund_response_echeck) + + response = @gateway.refund(@amount, '65074409', @options) + assert_success response + assert_equal '133134926', response.authorization + assert response.test? + end + def test_successful_refund_passing_extra_info response = stub_comms do @gateway.refund(@amount, '65074409', @options) @@ -202,6 +221,15 @@ def test_successful_void_request assert response.test? end + def test_successful_void_request_with_echeck + @gateway.expects(:ssl_post).returns(successful_void_response_echeck) + + response = @gateway.void('65074409', @options) + assert_success response + assert_equal '133134971', response.authorization + assert response.test? + end + def test_successful_void_passing_extra_info response = stub_comms do @gateway.void('65074409', @options.merge(:no_release => true)) @@ -378,6 +406,7 @@ def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed assert_equal @gateway.scrub(pre_scrubbed_track_data), post_scrubbed_track_data + assert_equal @gateway.scrub(pre_scrubbed_echeck), post_scrubbed_echeck end private @@ -443,6 +472,19 @@ def successful_void_response "UMversion=2.9&UMstatus=Approved&UMauthCode=&UMrefNum=63812270&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=Transaction%20Voided%20Successfully&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled" end + def successful_purchase_response_echeck + "UMversion=2.9&UMstatus=Approved&UMauthCode=TMEC4D&UMrefNum=133134803&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=180316&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=18031621233065&UMcardLevelResult=&UMauthAmount=&UMfiller=filled" + end + + def successful_refund_response_echeck + "UMversion=2.9&UMstatus=Approved&UMauthCode=TM1E74&UMrefNum=133134926&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled" + end + + def successful_void_response_echeck + "UMversion=2.9&UMstatus=Approved&UMauthCode=TM80A5&UMrefNum=133134971&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled" + end + + def pre_scrubbed <<-EOS opening connection to sandbox.usaepay.com:443... @@ -535,6 +577,54 @@ def post_scrubbed_track_data reading 485 bytes... -> "UMversion=2.9&UMstatus=Approved&UMauthCode=042087&UMrefNum=132020522&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=YYY&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=120&UMbatchRefNum=848&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=A&UMauthAmount=1&UMfiller=filled" read 485 bytes +Conn close + EOS + end + + def pre_scrubbed_echeck + <<-EOS +opening connection to sandbox.usaepay.com:443... +opened +starting SSL for sandbox.usaepay.com:443... +SSL established +<- "POST /gate 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: sandbox.usaepay.com\r\nContent-Length: 762\r\n\r\n" +<- "UMamount=1.00&UMinvoice=&UMdescription=&UMaccount=15378535&UMrouting=244183602&UMname=Jim+Smith&UMbillfname=Jim&UMbilllname=Smith&UMbillcompany=Widgets+Inc&UMbillstreet=456+My+Street&UMbillstreet2=Apt+1&UMbillcity=Ottawa&UMbillstate=NC&UMbillzip=27614&UMbillcountry=CA&UMbillphone=%28555%29555-5555&UMshipfname=Jim&UMshiplname=Smith&UMshipcompany=Widgets+Inc&UMshipstreet=456+My+Street&UMshipstreet2=Apt+1&UMshipcity=Ottawa&UMshipstate=ON&UMshipzip=K1C2N6&UMshipcountry=CA&UMshipphone=%28555%29555-5555&UMstreet=456+My+Street&UMzip=27614&UMcommand=check%3Asale&UMkey=4EoZ5U2Q55j976W7eplC71i6b7kn4pcV&UMsoftware=Active+Merchant&UMtestmode=0&UMhash=s%2F7F71E7DCB851901EA1D4E2CA1C60D2A7E8BAB99FA10F6220E821BD8B8331114B%2F85f1a7ab01b725c4eed80a12c78ef65d3fa367e6%2Fn" +-> "HTTP/1.1 200 OK\r\n" +-> "Server: http\r\n" +-> "Date: Fri, 16 Mar 2018 20:54:49 GMT\r\n" +-> "Content-Type: text/html\r\n" +-> "Content-Length: 572\r\n" +-> "Connection: close\r\n" +-> "P3P: policyref=\"http://www.usaepay.com/w3c/p3p.xml\", CP=\"NON TAIa IVAa IVDa OUR NOR PHY ONL UNI FIN INT DEM\"\r\n" +-> "Strict-Transport-Security: max-age=15768000\r\n" +-> "\r\n" +reading 572 bytes... +-> "UMversion=2.9&UMstatus=Approved&UMauthCode=TMEAAF&UMrefNum=133135121&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=180316&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=18031621233689&UMcardLevelResult=&UMauthAmount=&UMfiller=filled" +read 572 bytes +Conn close + EOS + end + + def post_scrubbed_echeck + <<-EOS +opening connection to sandbox.usaepay.com:443... +opened +starting SSL for sandbox.usaepay.com:443... +SSL established +<- "POST /gate 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: sandbox.usaepay.com\r\nContent-Length: 762\r\n\r\n" +<- "UMamount=1.00&UMinvoice=&UMdescription=&UMaccount=[FILTERED]&UMrouting=244183602&UMname=Jim+Smith&UMbillfname=Jim&UMbilllname=Smith&UMbillcompany=Widgets+Inc&UMbillstreet=456+My+Street&UMbillstreet2=Apt+1&UMbillcity=Ottawa&UMbillstate=NC&UMbillzip=27614&UMbillcountry=CA&UMbillphone=%28555%29555-5555&UMshipfname=Jim&UMshiplname=Smith&UMshipcompany=Widgets+Inc&UMshipstreet=456+My+Street&UMshipstreet2=Apt+1&UMshipcity=Ottawa&UMshipstate=ON&UMshipzip=K1C2N6&UMshipcountry=CA&UMshipphone=%28555%29555-5555&UMstreet=456+My+Street&UMzip=27614&UMcommand=check%3Asale&UMkey=[FILTERED]&UMsoftware=Active+Merchant&UMtestmode=0&UMhash=s%2F7F71E7DCB851901EA1D4E2CA1C60D2A7E8BAB99FA10F6220E821BD8B8331114B%2F85f1a7ab01b725c4eed80a12c78ef65d3fa367e6%2Fn" +-> "HTTP/1.1 200 OK\r\n" +-> "Server: http\r\n" +-> "Date: Fri, 16 Mar 2018 20:54:49 GMT\r\n" +-> "Content-Type: text/html\r\n" +-> "Content-Length: 572\r\n" +-> "Connection: close\r\n" +-> "P3P: policyref=\"http://www.usaepay.com/w3c/p3p.xml\", CP=\"NON TAIa IVAa IVDa OUR NOR PHY ONL UNI FIN INT DEM\"\r\n" +-> "Strict-Transport-Security: max-age=15768000\r\n" +-> "\r\n" +reading 572 bytes... +-> "UMversion=2.9&UMstatus=Approved&UMauthCode=TMEAAF&UMrefNum=133135121&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=180316&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=18031621233689&UMcardLevelResult=&UMauthAmount=&UMfiller=filled" +read 572 bytes Conn close EOS end From b2c45ee1a2890645e6994756fdd680d638cb83e9 Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Mon, 19 Mar 2018 16:36:45 -0400 Subject: [PATCH 349/677] PayULatam: Support language parameter The `language` option can be used to specify the language used in error messages and emails. Instead of hardcoding to `en`, we'll now default to `en` when no `language` option is present. Closes #2787 Remote: 30 tests, 74 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 27 tests, 101 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/payu_latam.rb | 14 ++--- .../remote/gateways/remote_payu_latam_test.rb | 54 +++++++++++++++++++ test/unit/gateways/payu_latam_test.rb | 40 ++++++++++++++ 4 files changed, 102 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d3ac51fcd84..044cbacb3e2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -40,6 +40,7 @@ * Adyen: Support store action [curiousepic] #2784 * Psigate: Update Test URL and Card [nfarve] #2785 * USA ePay Transaction: Support ACH/eChecks [curiousepic] #2786 +* PayU Latam: Support language parameter [dtykocki] #2787 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index 4d24aaf1934..3d5904348d0 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -48,7 +48,7 @@ def authorize(amount, payment_method, options={}) def capture(amount, authorization, options={}) post = {} - add_credentials(post, 'SUBMIT_TRANSACTION') + add_credentials(post, 'SUBMIT_TRANSACTION', options) add_transaction_elements(post, 'CAPTURE', options) add_reference(post, authorization) @@ -58,7 +58,7 @@ def capture(amount, authorization, options={}) def void(authorization, options={}) post = {} - add_credentials(post, 'SUBMIT_TRANSACTION') + add_credentials(post, 'SUBMIT_TRANSACTION', options) add_transaction_elements(post, 'VOID', options) add_reference(post, authorization) @@ -68,7 +68,7 @@ def void(authorization, options={}) def refund(amount, authorization, options={}) post = {} - add_credentials(post, 'SUBMIT_TRANSACTION') + add_credentials(post, 'SUBMIT_TRANSACTION', options) add_transaction_elements(post, 'REFUND', options) add_reference(post, authorization) @@ -115,7 +115,7 @@ def scrub(transcript) private def auth_or_sale(post, transaction_type, amount, payment_method, options) - add_credentials(post, 'SUBMIT_TRANSACTION') + add_credentials(post, 'SUBMIT_TRANSACTION', options) add_transaction_elements(post, transaction_type, options) add_order(post, options) add_buyer(post, payment_method, options) @@ -126,9 +126,9 @@ def auth_or_sale(post, transaction_type, amount, payment_method, options) add_extra_parameters(post, options) end - def add_credentials(post, command) + def add_credentials(post, command, options={}) post[:test] = test? unless command == 'CREATE_TOKEN' - post[:language] = 'en' + post[:language] = options[:language] || 'en' post[:command] = command merchant = {} merchant[:apiLogin] = @options[:api_login] @@ -153,7 +153,7 @@ def add_order(post, options) order[:partnerId] = options[:partner_id] if options[:partner_id] order[:referenceCode] = options[:order_id] || generate_unique_id order[:description] = options[:description] || 'Compra en ' + @options[:merchant_id] - order[:language] = 'en' + order[:language] = options[:language] || 'en' order[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address] post[:transaction][:order] = order end diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index 95c25daa69e..e6edb50f82f 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -49,6 +49,13 @@ def test_successful_purchase assert response.test? end + def test_successful_purchase_with_specified_language + response = @gateway.purchase(@amount, @credit_card, @options.merge(language: 'es')) + assert_success response + assert_equal "APPROVED", response.message + assert response.test? + end + def test_successul_purchase_with_buyer gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512327", payment_country: "BR")) @@ -210,6 +217,13 @@ def test_failed_purchase_with_no_options assert_equal "DECLINED", response.params["transactionResponse"]["state"] end + def test_failed_purchase_with_specified_language + gateway = PayuLatamGateway.new(merchant_id: "", account_id: "", api_login: "U", api_key: "U", payment_country: "AR") + response = gateway.purchase(@amount, @declined_card, @options.merge(language: 'es')) + assert_failure response + assert_equal "Credenciales inválidas", response.message + end + def test_successful_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_success response @@ -217,12 +231,26 @@ def test_successful_authorize assert_match %r(^\d+\|(\w|-)+$), response.authorization end + def test_successful_authorize_with_specified_language + response = @gateway.authorize(@amount, @credit_card, @options.merge(language: 'es')) + assert_success response + assert_equal "APPROVED", response.message + assert_match %r(^\d+\|(\w|-)+$), response.authorization + end + def test_failed_authorize response = @gateway.authorize(@amount, @pending_card, @options) assert_failure response assert_equal "DECLINED", response.params["transactionResponse"]["state"] end + def test_failed_authorize_with_specified_language + gateway = PayuLatamGateway.new(merchant_id: "", account_id: "", api_login: "U", api_key: "U", payment_country: "AR") + response = gateway.authorize(@amount, @pending_card, @options.merge(language: 'es')) + assert_failure response + assert_equal "Credenciales inválidas", response.message + end + def test_well_formed_refund_fails_as_expected purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase @@ -237,6 +265,12 @@ def test_failed_refund assert_match (/property: parentTransactionId, message: must not be null/), response.message end + def test_failed_refund_with_specified_language + response = @gateway.refund(@amount, '', language: 'es') + assert_failure response + assert_match (/property: parentTransactionId, message: No puede ser vacio/), response.message + end + # If this test fails, support for void may have been added to the sandbox def test_unsupported_test_void_fails_as_expected auth = @gateway.authorize(@amount, @credit_card, @options) @@ -253,6 +287,12 @@ def test_failed_void assert_match (/property: parentTransactionId, message: must not be null/), response.message end + def test_failed_void_with_specified_language + response = @gateway.void('', language: 'es') + assert_failure response + assert_match (/property: parentTransactionId, message: No puede ser vacio/), response.message + end + # If this test fails, support for captures may have been added to the sandbox def test_unsupported_test_capture_fails_as_expected auth = @gateway.authorize(@amount, @credit_card, @options) @@ -290,6 +330,13 @@ def test_successful_verify_with_specified_amount assert_equal "APPROVED", verify.message end + def test_successful_verify_with_specified_language + verify = @gateway.verify(@credit_card, @options.merge(language: 'es')) + + assert_success verify + assert_equal "APPROVED", verify.message + end + def test_failed_verify_with_specified_amount verify = @gateway.verify(@credit_card, @options.merge(verify_amount: 1699)) @@ -297,6 +344,13 @@ def test_failed_verify_with_specified_amount assert_equal "The order value is less than minimum allowed. Minimum value allowed 17 ARS", verify.message end + def test_failed_verify_with_specified_language + verify = @gateway.verify(@credit_card, @options.merge(verify_amount: 1699, language: 'es')) + + assert_failure verify + assert_equal "The order value is less than minimum allowed. Minimum value allowed 17 ARS", verify.message + end + def test_transcript_scrubbing transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb index f3d3480f2d2..7ce307432c9 100644 --- a/test/unit/gateways/payu_latam_test.rb +++ b/test/unit/gateways/payu_latam_test.rb @@ -48,6 +48,14 @@ def test_successful_purchase assert response.test? end + def test_successful_purchase_with_specified_language + stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(language: 'es')) + end.check_request do |endpoint, data, headers| + assert_match(/"language":"es"/, data) + end.respond_with(successful_purchase_response) + end + def test_failed_purchase @gateway.expects(:ssl_post).returns(failed_purchase_response) @@ -66,6 +74,14 @@ def test_successful_authorize assert_match %r(^\d+\|(\w|-)+$), response.authorization end + def test_successful_authorize_with_specified_language + stub_comms do + @gateway.authorize(@amount, @credit_card, @options.merge(language: 'es')) + end.check_request do |endpoint, data, headers| + assert_match(/"language":"es"/, data) + end.respond_with(successful_purchase_response) + end + def test_failed_authorize @gateway.expects(:ssl_post).returns(pending_authorize_response) @@ -83,6 +99,14 @@ def test_pending_refund assert_equal "PENDING", response.params["transactionResponse"]["state"] end + def test_pending_refund_with_specified_language + stub_comms do + @gateway.refund(@amount, "7edbaf68-8f3a-4ae7-b9c7-d1e27e314999", @options.merge(language: 'es')) + end.check_request do |endpoint, data, headers| + assert_match(/"language":"es"/, data) + end.respond_with(pending_refund_response) + end + def test_failed_refund @gateway.expects(:ssl_post).returns(failed_refund_response) @@ -99,6 +123,14 @@ def test_successful_void assert_equal "PENDING_REVIEW", response.message end + def test_successful_void_with_specified_language + stub_comms do + @gateway.void("7edbaf68-8f3a-4ae7-b9c7-d1e27e314999", @options.merge(language: 'es')) + end.check_request do |endpoint, data, headers| + assert_match(/"language":"es"/, data) + end.respond_with(successful_void_response) + end + def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) @@ -167,6 +199,14 @@ def test_successful_capture assert_equal "APPROVED", response.message end + def test_successful_capture_with_specified_language + stub_comms do + @gateway.capture(@amount, "4000|authorization", @options.merge(language: 'es')) + end.check_request do |endpoint, data, headers| + assert_match(/"language":"es"/, data) + end.respond_with(successful_purchase_response) + end + def test_failed_capture @gateway.expects(:ssl_post).returns(failed_void_response) From cb3305ef06bf0b619ee545dc774c21a38607a394 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 20 Mar 2018 11:37:49 -0400 Subject: [PATCH 350/677] Payflow: Pass OrderDesc field Also adds tests for similar fields. Closes #2789 Remote (10 failures for unrelated account-specific features): 29 tests, 110 assertions, 10 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 65.5172% passed Unit: 46 tests, 208 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/payflow.rb | 3 +++ test/remote/gateways/remote_payflow_test.rb | 17 ++++++++++++ test/unit/gateways/payflow_test.rb | 27 +++++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 044cbacb3e2..876d2d6925a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -41,6 +41,7 @@ * Psigate: Update Test URL and Card [nfarve] #2785 * USA ePay Transaction: Support ACH/eChecks [curiousepic] #2786 * PayU Latam: Support language parameter [dtykocki] #2787 +* Payflow: Pass OrderDesc field [curiousepic] #2789 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb index f77cd20dda2..523d3c746c5 100644 --- a/lib/active_merchant/billing/gateways/payflow.rb +++ b/lib/active_merchant/billing/gateways/payflow.rb @@ -133,6 +133,7 @@ def build_reference_sale_or_authorization_request(action, money, reference, opti xml.tag! 'CustIP', options[:ip] unless options[:ip].blank? xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank? xml.tag! 'Description', options[:description] unless options[:description].blank? + xml.tag! 'OrderDesc', options[:order_desc] unless options[:order_desc].blank? xml.tag! 'Comment', options[:comment] unless options[:comment].blank? xml.tag!('ExtData', 'Name'=> 'COMMENT2', 'Value'=> options[:comment2]) unless options[:comment2].blank? xml.tag! 'TaxAmt', options[:taxamt] unless options[:taxamt].blank? @@ -164,6 +165,7 @@ def build_credit_card_request(action, money, credit_card, options) xml.tag! 'CustIP', options[:ip] unless options[:ip].blank? xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank? xml.tag! 'Description', options[:description] unless options[:description].blank? + xml.tag! 'OrderDesc', options[:order_desc] unless options[:order_desc].blank? # Comment and Comment2 will show up in manager.paypal.com as Comment1 and Comment2 xml.tag! 'Comment', options[:comment] unless options[:comment].blank? xml.tag!('ExtData', 'Name'=> 'COMMENT2', 'Value'=> options[:comment2]) unless options[:comment2].blank? @@ -196,6 +198,7 @@ def build_check_request(action, money, check, options) xml.tag! 'CustIP', options[:ip] unless options[:ip].blank? xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank? xml.tag! 'Description', options[:description] unless options[:description].blank? + xml.tag! 'OrderDesc', options[:order_desc] unless options[:order_desc].blank? xml.tag! 'BillTo' do xml.tag! 'Name', check.name end diff --git a/test/remote/gateways/remote_payflow_test.rb b/test/remote/gateways/remote_payflow_test.rb index 09e6fe0b682..d9384f08854 100644 --- a/test/remote/gateways/remote_payflow_test.rb +++ b/test/remote/gateways/remote_payflow_test.rb @@ -17,6 +17,14 @@ def setup :customer => 'codyexample' } + @extra_options = { + :order_id => "123", + :description => "Description string", + :order_desc => "OrderDesc string", + :comment => "Comment string", + :comment2 => "Comment2 string" + } + @check = check( :routing_number => '111111118', :account_number => '1234567801' @@ -32,6 +40,15 @@ def test_successful_purchase assert !response.fraud_review? end + def test_successful_purchase_with_extra_options + assert response = @gateway.purchase(100000, @credit_card, @options.merge(@extra_options)) + assert_equal "Approved", response.message + assert_success response + assert response.test? + assert_not_nil response.authorization + assert !response.fraud_review? + end + # In order for this remote test to pass, you must go into your Payflow test # backend and enable the correct filter. Once logged in: # "Service Settings" -> diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb index e35be01e5be..119f2d4cc7d 100644 --- a/test/unit/gateways/payflow_test.rb +++ b/test/unit/gateways/payflow_test.rb @@ -50,6 +50,33 @@ def test_authorization_with_three_d_secure_option refute response.fraud_review? end + def test_successful_authorization_with_more_options + options = @options.merge( + { + order_id: "123", + description: "Description string", + order_desc: "OrderDesc string", + comment: "Comment string", + comment2: "Comment2 string" + } + ) + + response = stub_comms do + @gateway.authorize(@amount, @credit_card, options) + end.check_request do |endpoint, data, headers| + assert_match %r(<InvNum>123</InvNum>), data + assert_match %r(<Description>Description string</Description>), data + assert_match %r(<OrderDesc>OrderDesc string</OrderDesc>), data + assert_match %r(<Comment>Comment string</Comment>), data + assert_match %r(<ExtData Name=\"COMMENT2\" Value=\"Comment2 string\"/>), data + end.respond_with(successful_authorization_response) + assert_equal "Approved", response.message + assert_success response + assert response.test? + assert_equal "VUJN1A6E11D9", response.authorization + refute response.fraud_review? + end + def test_successful_purchase_with_fraud_review @gateway.stubs(:ssl_post).returns(successful_purchase_with_fraud_review_response) From a6e597d955e452fb1f2694b2e381137ea568013e Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 20 Mar 2018 14:05:02 -0400 Subject: [PATCH 351/677] Global Collect: Add arbitrary fraudField params Remote: 16 tests, 37 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 17 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/global_collect.rb | 9 ++++++++ .../gateways/remote_global_collect_test.rb | 14 +++++++++++ test/unit/gateways/global_collect_test.rb | 23 +++++++++++++++++++ 4 files changed, 47 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 876d2d6925a..7208ec320ca 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -42,6 +42,7 @@ * USA ePay Transaction: Support ACH/eChecks [curiousepic] #2786 * PayU Latam: Support language parameter [dtykocki] #2787 * Payflow: Pass OrderDesc field [curiousepic] #2789 +* Global Collect: Add arbitrary fraudField params [curiousepic] #2790 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 67c4afeca69..4c069323eb2 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -31,6 +31,7 @@ def authorize(money, payment, options={}) add_customer_data(post, options, payment) add_address(post, payment, options) add_creator_info(post, options) + add_fraud_fields(post, options) commit(:authorize, post) end @@ -204,6 +205,14 @@ def add_address(post, creditcard, options) end end + def add_fraud_fields(post, options) + fraud_fields = {} + fraud_fields.merge!(options[:fraud_fields]) if options[:fraud_fields] + fraud_fields.merge!({customerIpAddress: options[:ip]}) if options[:ip] + + post["fraudFields"] = fraud_fields unless fraud_fields.empty? + end + def parse(body) JSON.parse(body) end diff --git a/test/remote/gateways/remote_global_collect_test.rb b/test/remote/gateways/remote_global_collect_test.rb index dba8d6fc6bf..a167ca7caa0 100644 --- a/test/remote/gateways/remote_global_collect_test.rb +++ b/test/remote/gateways/remote_global_collect_test.rb @@ -21,6 +21,20 @@ def test_successful_purchase assert_equal 'Succeeded', response.message end + def test_successful_purchase_with_fraud_fields + options = @options.merge( + fraud_fields: + { + "website" => "www.example.com", + "giftMessage" => "Happy Day!" + } + ) + + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_equal 'Succeeded', response.message + end + def test_successful_purchase_with_more_options options = @options.merge( order_id: '1', diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb index c257f90d765..6ed57284bd5 100644 --- a/test/unit/gateways/global_collect_test.rb +++ b/test/unit/gateways/global_collect_test.rb @@ -65,6 +65,29 @@ def test_authorize_without_pre_authorization_flag assert_success response end + def test_successful_authorization_with_extra_options + options = @options.merge( + { + order_id: "123", + ip: "127.0.0.1", + fraud_fields: + { + "website" => "www.example.com", + "giftMessage" => "Happy Day!" + } + } + ) + + response = stub_comms do + @gateway.authorize(@accepted_amount, @credit_card, options) + end.check_request do |endpoint, data, headers| + assert_match %r("fraudFields":{"website":"www.example.com","giftMessage":"Happy Day!","customerIpAddress":"127.0.0.1"}), data + assert_match %r("merchantReference":"123"), data + end.respond_with(successful_authorize_response) + + assert_success response + end + def test_trucates_first_name_to_15_chars credit_card = credit_card('4567350000427977', { first_name: "thisisaverylongfirstname" }) From 00b81f49999a953bf1cf7bf3e222e3af45b2183f Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Mon, 26 Mar 2018 11:45:58 -0400 Subject: [PATCH 352/677] Paystation: Support verify action Supported via authorizing with a 0 amount. Negative cases for verify can't be properly tested since failures are provoked by sending specific amount values. Manual testing with a bad card number gave a Luhn check error but otherwise expected behavior. Closes #2793 Remote (2 unrelated failures) 11 tests, 47 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 81.8182% passed Unit: 9 tests, 50 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/paystation.rb | 5 ++++- test/remote/gateways/remote_paystation_test.rb | 5 +++++ test/unit/gateways/paystation_test.rb | 7 +++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7208ec320ca..6505bf11705 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -43,6 +43,7 @@ * PayU Latam: Support language parameter [dtykocki] #2787 * Payflow: Pass OrderDesc field [curiousepic] #2789 * Global Collect: Add arbitrary fraudField params [curiousepic] #2790 +* Paystation: Support verify action [curiousepic] #2793 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/paystation.rb b/lib/active_merchant/billing/gateways/paystation.rb index 332899934da..781952b0ac3 100644 --- a/lib/active_merchant/billing/gateways/paystation.rb +++ b/lib/active_merchant/billing/gateways/paystation.rb @@ -75,7 +75,6 @@ def store(credit_card, options = {}) commit(post) end - def refund(money, authorization, options={}) post = new_request add_amount(post, money, options) @@ -85,6 +84,10 @@ def refund(money, authorization, options={}) commit(post) end + def verify(credit_card, options={}) + authorize(0, credit_card, options) + end + private def new_request diff --git a/test/remote/gateways/remote_paystation_test.rb b/test/remote/gateways/remote_paystation_test.rb index ea773793dcc..691cf66ccd1 100644 --- a/test/remote/gateways/remote_paystation_test.rb +++ b/test/remote/gateways/remote_paystation_test.rb @@ -110,4 +110,9 @@ def test_failed_refund assert_equal "Error 11:", response.params["strong"] end + def test_successful_verify + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_match %r{Transaction successful}, response.message + end end diff --git a/test/unit/gateways/paystation_test.rb b/test/unit/gateways/paystation_test.rb index 4e4337b14d9..6fa03c4715b 100644 --- a/test/unit/gateways/paystation_test.rb +++ b/test/unit/gateways/paystation_test.rb @@ -106,6 +106,13 @@ def test_failed_refund assert_failure response end + def test_successful_verify + @gateway.expects(:ssl_post).returns(successful_authorization_response) + + assert response = @gateway.verify(@credit_card, @options) + assert_success response + end + private def successful_purchase_response From a97b0827ed1155c0faae9c2560e2704a0367fb3e Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Fri, 23 Mar 2018 15:02:17 -0400 Subject: [PATCH 353/677] Checkout V2: Return error codes in response Closes #2791 Remote: 25 tests, 60 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 20 tests, 84 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/checkout_v2.rb | 9 ++++++++- test/remote/gateways/remote_checkout_v2_test.rb | 8 ++++++++ test/unit/gateways/checkout_v2_test.rb | 17 ++++++++++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6505bf11705..fc8c663fc9a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -44,6 +44,7 @@ * Payflow: Pass OrderDesc field [curiousepic] #2789 * Global Collect: Add arbitrary fraudField params [curiousepic] #2790 * Paystation: Support verify action [curiousepic] #2793 +* Checkout V2: Return error codes in response [curiousepic] #2791 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb index eb08f36a1fc..6a09c8f5d78 100644 --- a/lib/active_merchant/billing/gateways/checkout_v2.rb +++ b/lib/active_merchant/billing/gateways/checkout_v2.rb @@ -212,7 +212,14 @@ def authorization_from(raw) end def error_code_from(succeeded, response) - succeeded ? nil : STANDARD_ERROR_CODE_MAPPING[response["responseCode"]] + return if succeeded + if response["errorCode"] && response["errorMessageCodes"] + "#{response["errorCode"]}: #{response["errorMessageCodes"].join(", ")}" + elsif response["errorCode"] + response["errorCode"] + else + STANDARD_ERROR_CODE_MAPPING[response["responseCode"]] + end end end end diff --git a/test/remote/gateways/remote_checkout_v2_test.rb b/test/remote/gateways/remote_checkout_v2_test.rb index 80288c2f405..1f9e2d8392b 100644 --- a/test/remote/gateways/remote_checkout_v2_test.rb +++ b/test/remote/gateways/remote_checkout_v2_test.rb @@ -6,6 +6,7 @@ def setup @amount = 200 @credit_card = credit_card('4242424242424242', verification_value: '100', month: '6', year: '2018') + @expired_card = credit_card('4242424242424242', verification_value: '100', month: '6', year: '2010') @declined_card = credit_card('4000300011112220') @options = { @@ -178,4 +179,11 @@ def test_failed_verify assert_match %r{Invalid Card Number}, response.message assert_equal Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code end + + def test_expired_card_returns_error_code + response = @gateway.purchase(@amount, @expired_card, @options) + assert_failure response + assert_equal 'Validation error: Expired Card', response.message + assert_equal '70000: 70077', response.error_code + end end diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb index 50c79e73bea..5379ac51277 100644 --- a/test/unit/gateways/checkout_v2_test.rb +++ b/test/unit/gateways/checkout_v2_test.rb @@ -186,6 +186,15 @@ def test_invalid_json assert_match %r{Invalid JSON response}, response.message end + def test_error_code_returned + response = stub_comms do + @gateway.purchase(@amount, @credit_card) + end.respond_with(error_code_response) + + assert_failure response + assert_match /70000: 70077/, response.error_code + 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 end @@ -440,5 +449,11 @@ def invalid_json_response ) end - + def error_code_response + %( + { + "eventId":"1b206f69-b4db-4259-9713-b72dfe0f19da","errorCode":"70000","message":"Validation error","errorMessageCodes":["70077"],"errors":["Expired Card"] + } + ) + end end From 47fb40c0db9967eed83a1ca9419d57221ab471fa Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Mon, 26 Mar 2018 12:49:54 -0400 Subject: [PATCH 354/677] CardStream: Change `refund` to use `REFUND_SALE` Per CardStream, specifying `REFUND` as the action performs a general / independent credit against the card which may result in chargebacks. Instead, the `REFUND_SALE` action can be used refund a `SALE` transaction that has settled. When a `SALE` transaction has not settled, a `CANCEL` request must be made that will refund the original `SALE`. Note: I initially found this behavior quite confusing but it turns out we perform this pattern in the Authorize.net, WorldPay, and BraintreeBlue adapters. These changes follow the same pattern. Closes #2795 Unit: 24 tests, 126 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 30 tests, 200 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/card_stream.rb | 11 ++- .../gateways/remote_card_stream_test.rb | 72 ++++++++++++++++--- test/unit/gateways/card_stream_test.rb | 26 ++++++- 4 files changed, 100 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fc8c663fc9a..69d95d562af 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -45,6 +45,7 @@ * Global Collect: Add arbitrary fraudField params [curiousepic] #2790 * Paystation: Support verify action [curiousepic] #2793 * Checkout V2: Return error codes in response [curiousepic] #2791 +* CardStream: Change refund to use REFUND_SALE [dtykocki] #2795 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb index 401efe6ec4d..fb4b5a0c3bc 100644 --- a/lib/active_merchant/billing/gateways/card_stream.rb +++ b/lib/active_merchant/billing/gateways/card_stream.rb @@ -184,7 +184,16 @@ def refund(money, authorization, options = {}) add_pair(post, :xref, authorization) add_amount(post, money, options) add_remote_address(post, options) - commit('REFUND', post) + response = commit('REFUND_SALE', post) + + return response if response.success? + return response unless options[:force_full_refund_if_unsettled] + + if response.params["responseCode"] == "65541" + void(authorization, options) + else + response + end end def void(authorization, options = {}) diff --git a/test/remote/gateways/remote_card_stream_test.rb b/test/remote/gateways/remote_card_stream_test.rb index 98790c6c374..7533036d161 100644 --- a/test/remote/gateways/remote_card_stream_test.rb +++ b/test/remote/gateways/remote_card_stream_test.rb @@ -144,18 +144,32 @@ def test_successful_visacreditcard_authorization_and_capture_no_billing_address assert responseCapture.test? end - def test_successful_visacreditcard_purchase_and_refund + def test_successful_visacreditcard_purchase_and_refund_with_force_refund assert responsePurchase = @gateway.purchase(284, @visacreditcard, @visacredit_options) assert_equal 'APPROVED', responsePurchase.message assert_success responsePurchase assert responsePurchase.test? assert !responsePurchase.authorization.blank? - assert responseRefund = @gateway.refund(142, responsePurchase.authorization, @visacredit_options) + + assert responseRefund = @gateway.refund(142, responsePurchase.authorization, @visacredit_options.merge(force_full_refund_if_unsettled: true)) assert_equal 'APPROVED', responseRefund.message assert_success responseRefund assert responseRefund.test? end + def test_failed_visacreditcard_purchase_and_refund + assert responsePurchase = @gateway.purchase(284, @visacreditcard, @visacredit_options) + assert_equal 'APPROVED', responsePurchase.message + assert_success responsePurchase + assert responsePurchase.test? + assert !responsePurchase.authorization.blank? + + assert responseRefund = @gateway.refund(142, responsePurchase.authorization, @visacredit_options) + assert_failure responseRefund + assert_equal 'Can not REFUND this SALE transaction', responseRefund.message + assert responseRefund.test? + end + def test_successful_visacreditcard_purchase_with_dynamic_descriptors assert responsePurchase = @gateway.purchase(284, @visacreditcard, @visacredit_descriptor_options) assert_equal 'APPROVED', responsePurchase.message @@ -188,18 +202,32 @@ def test_successful_visadebitcard_authorization_and_capture assert responseCapture.test? end - def test_successful_visadebitcard_purchase_and_refund + def test_successful_visadebitcard_purchase_and_refund_with_force_refund assert responsePurchase = @gateway.purchase(284, @visadebitcard, @visadebit_options) assert_equal 'APPROVED', responsePurchase.message assert_success responsePurchase assert responsePurchase.test? assert !responsePurchase.authorization.blank? - assert responseRefund = @gateway.refund(142, responsePurchase.authorization, @visadebit_options) + + assert responseRefund = @gateway.refund(142, responsePurchase.authorization, @visadebit_options.merge(force_full_refund_if_unsettled: true)) assert_equal 'APPROVED', responseRefund.message assert_success responseRefund assert responseRefund.test? end + def test_failed_visadebitcard_purchase_and_refund + assert responsePurchase = @gateway.purchase(284, @visadebitcard, @visadebit_options) + assert_equal 'APPROVED', responsePurchase.message + assert_success responsePurchase + assert responsePurchase.test? + assert !responsePurchase.authorization.blank? + + assert responseRefund = @gateway.refund(142, responsePurchase.authorization, @visadebit_options) + assert_equal 'Can not REFUND this SALE transaction', responseRefund.message + assert_failure responseRefund + assert responseRefund.test? + end + def test_successful_amex_authorization_and_capture assert responseAuthorization = @gateway.authorize(142, @amex, @amex_options) assert_equal 'APPROVED', responseAuthorization.message @@ -212,18 +240,32 @@ def test_successful_amex_authorization_and_capture assert responseCapture.test? end - def test_successful_amex_purchase_and_refund + def test_successful_amex_purchase_and_refund_with_force_refund assert responsePurchase = @gateway.purchase(284, @amex, @amex_options) assert_equal 'APPROVED', responsePurchase.message assert_success responsePurchase assert responsePurchase.test? assert !responsePurchase.authorization.blank? - assert responseRefund = @gateway.refund(142, responsePurchase.authorization, @amex_options) + + assert responseRefund = @gateway.refund(142, responsePurchase.authorization, @amex_options.merge(force_full_refund_if_unsettled: true)) assert_equal 'APPROVED', responseRefund.message assert_success responseRefund assert responseRefund.test? end + def test_failed_amex_purchase_and_refund + assert responsePurchase = @gateway.purchase(284, @amex, @amex_options) + assert_equal 'APPROVED', responsePurchase.message + assert_success responsePurchase + assert responsePurchase.test? + assert !responsePurchase.authorization.blank? + + assert responseRefund = @gateway.refund(142, responsePurchase.authorization, @amex_options) + assert_equal 'Can not REFUND this SALE transaction', responseRefund.message + assert_failure responseRefund + assert responseRefund.test? + end + def test_successful_mastercard_authorization_and_capture assert responseAuthorization = @gateway.authorize(142, @mastercard, @mastercard_options) assert_equal 'APPROVED', responseAuthorization.message @@ -236,18 +278,32 @@ def test_successful_mastercard_authorization_and_capture assert responseCapture.test? end - def test_successful_mastercard_purchase_and_refund + def test_successful_mastercard_purchase_and_refund_with_force_refund assert responsePurchase = @gateway.purchase(284, @mastercard, @mastercard_options) assert_equal 'APPROVED', responsePurchase.message assert_success responsePurchase assert responsePurchase.test? assert !responsePurchase.authorization.blank? - assert responseRefund = @gateway.refund(142, responsePurchase.authorization, @mastercard_options) + + assert responseRefund = @gateway.refund(142, responsePurchase.authorization, @mastercard_options.merge(force_full_refund_if_unsettled: true)) assert_equal 'APPROVED', responseRefund.message assert_success responseRefund assert responseRefund.test? end + def test_failed_mastercard_purchase_and_refund + assert responsePurchase = @gateway.purchase(284, @mastercard, @mastercard_options) + assert_equal 'APPROVED', responsePurchase.message + assert_success responsePurchase + assert responsePurchase.test? + assert !responsePurchase.authorization.blank? + + assert responseRefund = @gateway.refund(142, responsePurchase.authorization, @mastercard_options) + assert_equal 'Can not REFUND this SALE transaction', responseRefund.message + assert_failure responseRefund + assert responseRefund.test? + end + def test_successful_visacreditcard_purchase assert response = @gateway.purchase(142, @visacreditcard, @visacredit_options) assert_equal 'APPROVED', response.message diff --git a/test/unit/gateways/card_stream_test.rb b/test/unit/gateways/card_stream_test.rb index 65a7380dd3c..c92b6459075 100644 --- a/test/unit/gateways/card_stream_test.rb +++ b/test/unit/gateways/card_stream_test.rb @@ -80,7 +80,7 @@ def test_successful_visacreditcard_capture assert responseCapture.test? end - def test_successful_visacreditcard_refund + def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) assert responseRefund = @gateway.refund(142, "authorization", @visacredit_options) @@ -89,6 +89,26 @@ def test_successful_visacreditcard_refund assert responseRefund.test? end + def test_successful_refund_due_to_unsettled_payment_forces_void + refund = stub_comms do + @gateway.refund(142, 'authorization', @visacredit_options.merge(force_full_refund_if_unsettled: true)) + end.respond_with(failed_refund_for_unsettled_payment_response, successful_void_response) + + assert refund + assert_success refund + assert_equal 'APPROVED', refund.message + assert refund.test? + end + + def test_failed_refund_due_to_unsettled_payment + @gateway.expects(:ssl_post).returns(failed_refund_for_unsettled_payment_response) + + assert refund = @gateway.refund(142, "authorization", @visacredit_options) + assert_equal 'Can not REFUND this SALE transaction', refund.message + assert_failure refund + assert refund.test? + end + def test_successful_visacreditcard_void @gateway.expects(:ssl_post).returns(successful_void_response) @@ -280,6 +300,10 @@ def successful_refund_response "merchantID=0000000&threeDSEnabled=Y&merchantDescription=General+test+account+with+AVS%2FCV2+checking&xref=13021914NT06BM21GJ15VJH&amount=142&currencyCode=826&action=REFUND&type=1&countryCode=826&merchantAlias=0000992&remoteAddress=80.229.33.63&responseCode=0&responseMessage=REFUNDACCEPTED&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostCode=NN17+8YG+&transactionUnique=c7981d78d217cf3cfda6559921e31c4a&orderRef=AM+test+purchase&amountReceived=142&avscv2ResponseCode=222100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&cv2Check=matched&addressCheck=matched&postcodeCheck=matched&threeDSXID=00000000000004717488&threeDSEnrolled=U&threeDSErrorCode=-1&threeDSErrorDescription=Error+while+attempting+to+send+the+request+to%3A+https%3A%2F%2F3dstest.universalpaymentgateway.com%3A4343%2FAPI%0A%0DPlease+make+sure+that+ActiveMerchant+server+is+running+and+the+URL+is+valid.+ERROR_INTERNET_CANNOT_CONNECT%3A+The+attempt+to+connect+to+the+server+failed.&threeDSMerchantPref=PROCEED&threeDSVETimestamp=2013-02-19+14%3A05%3A58&cardTypeCode=VC&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A0821&threeDSRequired=N&transactionID=4717490&transactionPreviousID=4717488&timestamp=2013-02-19+14%3A06%3A21&cardType=Visa+Credit&currencyExponent=2&responseStatus=0&merchantName=CARDSTREAM+TEST&merchantID2=100001" end + def failed_refund_for_unsettled_payment_response + "responseCode=65541&responseMessage=Can+not+REFUND+this+SALE+transaction&responseStatus=2&xref=18032714RP14KM21FX11YHT&amount=142&currencyCode=826&remoteAddress=1.1.1.1&countryCode=GB&merchantID=103191&action=REFUND_SALE&requestID=5aba43ad1481e&state=finished&requestMerchantID=103191&processMerchantID=103191&transactionID=25814232&timestamp=2018-03-27+14%3A14%3A21&vcsResponseCode=0&vcsResponseMessage=Success+-+no+velocity+check+rules+applied&signature=b56640b215510a04ebfaa095b63705cda08cca318a7ccb2b2b48caec75adc187d9cae5082eb1dc71d258813ee9d879721e48af04966a489171f435bfa67b6d92" + end + def successful_void_response "merchantID=103191&threeDSEnabled=Y&avscv2CheckEnabled=N&eReceiptsEnabled=N&transactionID=11132605&xref=16050316NZ51LT53FP70BMZ&state=canceled&captureDelay=-1&remoteAddress=107.15.253.186&action=CANCEL%3ASALE&type=1&currencyCode=826&countryCode=826&amount=284&orderRef=AM+test+purchase&transactionUnique=2240526ccaa7d41af63a94aab843e683&cardTypeCode=VC&cardNumberMask=492942%2A%2A%2A%2A%2A%2A0821&cardExpiryDate=1214&cardExpiryMonth=12&cardExpiryYear=14&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostcode=NN17+8YG&eReceiptsStoreID=1&customerReceiptsRequired=N&cv2Check=matched&addressCheck=matched&postcodeCheck=matched&avscv2ResponseCode=222100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&addressCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&postcodeCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&threeDSRequired=N&threeDSCheckPref=authenticated&authorisationCode=084609&amountReceived=0&responseCode=0&responseMessage=Transaction+cancelled.&cardCVVMandatory=N&responseStatus=0&timestamp=2016-05-03+16%3A51%3A54&cardType=Visa+Credit&cardScheme=Visa+&cardSchemeCode=VC&cardIssuer=BARCLAYS+BANK+PLC&cardIssuerCountry=United+Kingdom&cardIssuerCountryCode=GBR&signature=73cf5ec5470f6a1b3abce4e2a4b64adc2da0cb7103e8d362b40ab101d2ff339961a593869f289f7660a286e8c92c22fd5dec4330cf7e7e0ca8651cd8c0a8d966" end From 1e30351d25249e54fe2fd3fb77eb377e56db5a2d Mon Sep 17 00:00:00 2001 From: Wilson Chiang <WilsonChiang@users.noreply.github.com> Date: Thu, 29 Mar 2018 10:14:31 -0400 Subject: [PATCH 355/677] Stripe: Add `exchange_rate` parameter (#2796) This adds support for the optional `exchange_rate` parameter during capture and purchase. This specifies an exchange rate to be used during a transaction, and if incorrect or stale, Stripe will return a 400 `invalid_request_error` with an `invalid_exchange_rate` code. The response also contains the updated rate in the event of a failure in the `new_rate` parameter. This is currently a preview feature. Ref: https://stripe.com/docs/api#capture_charge Unit: 126 tests, 667 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 64 tests, 291 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/stripe.rb | 6 ++++++ test/unit/gateways/stripe_test.rb | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 22fc636b43d..c5f76308336 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -128,6 +128,7 @@ def capture(money, authorization, options = {}) else add_application_fee(post, options) add_amount(post, money, options) + add_exchange_rate(post, options) commit(:post, "charges/#{CGI.escape(authorization)}/capture", post, options) end end @@ -320,6 +321,7 @@ def create_post_for_auth_or_purchase(money, payment, options) add_metadata(post, options) add_application_fee(post, options) + add_exchange_rate(post, options) add_destination(post, options) post end @@ -334,6 +336,10 @@ def add_application_fee(post, options) post[:application_fee] = options[:application_fee] if options[:application_fee] end + def add_exchange_rate(post, options) + post[:exchange_rate] = options[:exchange_rate] if options[:exchange_rate] + end + def add_destination(post, options) if options[:destination] post[:destination] = {} diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index ed5f1ba319e..6a8f4f62f87 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -853,6 +853,22 @@ def test_application_fee_is_submitted_for_capture end.respond_with(successful_capture_response) end + def test_exchange_rate_is_submitted_for_purchase + stub_comms(@gateway, :ssl_request) do + @gateway.purchase(@amount, @credit_card, @options.merge({:exchange_rate => 0.96251})) + end.check_request do |method, endpoint, data, headers| + assert_match(/exchange_rate=0.96251/, data) + end.respond_with(successful_purchase_response) + end + + def test_exchange_rate_is_submitted_for_capture + stub_comms(@gateway, :ssl_request) do + @gateway.capture(@amount, "ch_test_charge", @options.merge({:exchange_rate => 0.96251})) + end.check_request do |method, endpoint, data, headers| + assert_match(/exchange_rate=0.96251/, data) + end.respond_with(successful_capture_response) + end + def test_destination_is_submitted_for_purchase stub_comms(@gateway, :ssl_request) do @gateway.purchase(@amount, @credit_card, @options.merge({:destination => 'subaccountid'})) From ff0a7dbbd3eaadb5ce0efd37f8f3c13d86823e53 Mon Sep 17 00:00:00 2001 From: Abdullah Barrak <a@abarrak.com> Date: Sun, 11 Mar 2018 01:34:49 +0300 Subject: [PATCH 356/677] Spreedly: scrub sensitive transcript data Closes #2781 Unit Test: 21 tests, 120 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote Test: 27 tests, 117 assertions, 8 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 70.3704% passed --- CHANGELOG | 1 + .../billing/gateways/spreedly_core.rb | 13 +++- .../gateways/remote_spreedly_core_test.rb | 27 +++++++- test/unit/gateways/spreedly_core_test.rb | 62 +++++++++++++++++++ 4 files changed, 100 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 69d95d562af..f3a46338581 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -46,6 +46,7 @@ * Paystation: Support verify action [curiousepic] #2793 * Checkout V2: Return error codes in response [curiousepic] #2791 * CardStream: Change refund to use REFUND_SALE [dtykocki] #2795 +* Spreedly: Scrub sensitive transaction data [abarrak] #2781 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/gateways/spreedly_core.rb b/lib/active_merchant/billing/gateways/spreedly_core.rb index e4c43db48c0..7e93b523d0e 100644 --- a/lib/active_merchant/billing/gateways/spreedly_core.rb +++ b/lib/active_merchant/billing/gateways/spreedly_core.rb @@ -106,6 +106,18 @@ def unstore(authorization, options={}) commit("payment_methods/#{authorization}/redact.xml", '', :put) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). + gsub(%r((<number>).+(</number>)), '\1[FILTERED]\2'). + gsub(%r((<verification_value>).+(</verification_value>)), '\1[FILTERED]\2'). + gsub(%r((<payment_method_token>).+(</payment_method_token>)), '\1[FILTERED]\2') + end + private def save_card(retain, credit_card, options) @@ -244,4 +256,3 @@ def headers end end end - diff --git a/test/remote/gateways/remote_spreedly_core_test.rb b/test/remote/gateways/remote_spreedly_core_test.rb index 3a3bfb8e9a1..1059a932349 100644 --- a/test/remote/gateways/remote_spreedly_core_test.rb +++ b/test/remote/gateways/remote_spreedly_core_test.rb @@ -8,8 +8,8 @@ def setup @amount = 100 @credit_card = credit_card('5555555555554444') @declined_card = credit_card('4012888888881881') - @existing_payment_method = '9AjLflWs7SOKuqJLveOZya9bixa' - @declined_payment_method = 'n3JElNt9joT1mJ3CxvWjyEN39N' + @existing_payment_method = 'WQ9zJ1UOgak8BrNEi3g5RCianlY' + @declined_payment_method = 'AMc22hrKtQFpYHTvjNx0lGRWZVv' end def test_successful_purchase_with_token @@ -245,4 +245,27 @@ def test_invalid_login assert_failure response assert_match %r{Unable to authenticate}, response.message end + + def test_scrubbing_purchase + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:login], transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end + + def test_scrubbing_purchase_with_token + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @existing_payment_method) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@existing_payment_method, transcript) + assert_scrubbed(@gateway.options[:login], transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end end diff --git a/test/unit/gateways/spreedly_core_test.rb b/test/unit/gateways/spreedly_core_test.rb index 0ae7a5725d8..a0b74eaa339 100644 --- a/test/unit/gateways/spreedly_core_test.rb +++ b/test/unit/gateways/spreedly_core_test.rb @@ -241,8 +241,13 @@ def test_successful_unstore assert_equal "Succeeded!", response.message end + def test_scrubbing + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end private + def successful_purchase_response MockResponse.succeeded <<-XML <transaction> @@ -799,4 +804,61 @@ def successful_unstore_response XML end + def pre_scrubbed + <<-EOS + opening connection to core.spreedly.com:443... + opened + starting SSL for core.spreedly.com:443... + SSL established + <- "POST /v1/payment_methods.xml HTTP/1.1\r\nContent-Type: text/xml\r\nAuthorization: Basic NFk5YlZrT0NwWWVzUFFPZkRpN1RYUXlVdzUwOlkyaTdBamdVMDNTVWp3WTR4bk9QcXpkc3Y0ZE1iUERDUXpvckFrOEJjb3kwVThFSVZFNGlubkdqdW9NUXY3TU4=\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: core.spreedly.com\r\nContent-Length: 404\r\n\r\n" + <- "<?xml version=\"1.0\"?>\n<payment_method>\n <credit_card>\n <number>5555555555554444</number>\n <verification_value>123</verification_value>\n <first_name>Longbob</first_name>\n <last_name>Longsen</last_name>\n <month>9</month>\n <year>2019</year>\n <email/>\n <address1/>\n <address2/>\n <city/>\n <state/>\n <zip/>\n <country/>\n </credit_card>\n <data></data>\n</payment_method>\n" + -> "HTTP/1.1 201 Created\r\n" + -> "Date: Sat, 10 Mar 2018 22:04:06 GMT\r\n" + -> "Content-Type: application/xml; charset=utf-8\r\n" + -> "Content-Length: 1875\r\n" + -> "Connection: close\r\n" + -> "X-Frame-Options: SAMEORIGIN\r\n" + -> "X-XSS-Protection: 1; mode=block\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "ETag: W/\"c4ef6dfc389a5514d6b6ffd8bac8786c\"\r\n" + -> "Cache-Control: max-age=0, private, must-revalidate\r\n" + -> "X-Request-Id: b227ok4du2hrj7mrtt10.core_dcaa82760687b3ef\r\n" + -> "Server: nginx\r\n" + -> "Strict-Transport-Security: max-age=31536000; includeSubdomains;\r\n" + -> "\r\n" + reading 1875 bytes... + -> "<transaction>\n <token>NRBpydUCWn658GHV8h2kVlUzB0i</token>\n <created_at type=\"dateTime\">2018-03-10T22:04:06Z</created_at>\n <updated_at type=\"dateTime\">2018-03-10T22:04:06Z</updated_at>\n <succeeded type=\"boolean\">true</succeeded>\n <transaction_type>AddPaymentMethod</transaction_type>\n <retained type=\"boolean\">false</retained>\n <state>succeeded</state>\n <message key=\"messages.transaction_succeeded\">Succeeded!</message>\n <payment_method>\n <token>Wd25UIrH1uopTkZZ4UDdb5XmSDd</token>\n <created_at type=\"dateTime\">2018-03-10T22:04:06Z</created_at>\n <updated_at type=\"dateTime\">2018-03-10T22:04:06Z</updated_at>\n <email nil=\"true\"/>\n <data nil=\"true\"/>\n <storage_state>cached</storage_state>\n <test type=\"boolean\">true</test>\n <last_four_digits>4444</last_four_digits>\n <first_six_digits>555555</first_six_digits>\n <card_type>master</card_type>\n <first_name>Longbob</first_name>\n <last_name>Longsen</last_name>\n <month type=\"integer\">9</month>\n <year type=\"integer\">2019</year>\n <address1 nil=\"true\"/>\n <address2 nil=\"true\"/>\n <city nil=\"true\"/>\n <state nil=\"true\"/>\n <zip nil=\"true\"/>\n <country nil=\"true\"/>\n <phone_number nil=\"true\"/>\n <company nil=\"true\"/>\n <full_name>Longbob Longsen</full_name>\n <eligible_for_card_updater type=\"boolean\">true</eligible_for_card_updater>\n <shipping_address1 nil=\"true\"/>\n <shipping_address2 nil=\"true\"/>\n <shipping_city nil=\"true\"/>\n <shipping_state nil=\"true\"/>\n <shipping_zip nil=\"true\"/>\n <shipping_country nil=\"true\"/>\n <shipping_phone_number nil=\"true\"/>\n <payment_method_type>credit_card</payment_method_type>\n <errors>\n </errors>\n <verification_value>XXX</verification_value>\n <number>XXXX-XXXX-XXXX-4444</number>\n <fingerprint>125370bb396dff6fed4f581f85a91a9e5317</fingerprint>\n </payment_method>\n</transaction>\n" + read 1875 bytes + Conn close + EOS + end + + def post_scrubbed + <<-EOS + opening connection to core.spreedly.com:443... + opened + starting SSL for core.spreedly.com:443... + SSL established + <- "POST /v1/payment_methods.xml HTTP/1.1\r\nContent-Type: text/xml\r\nAuthorization: Basic [FILTERED]=\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: core.spreedly.com\r\nContent-Length: 404\r\n\r\n" + <- "<?xml version=\"1.0\"?>\n<payment_method>\n <credit_card>\n <number>[FILTERED]</number>\n <verification_value>[FILTERED]</verification_value>\n <first_name>Longbob</first_name>\n <last_name>Longsen</last_name>\n <month>9</month>\n <year>2019</year>\n <email/>\n <address1/>\n <address2/>\n <city/>\n <state/>\n <zip/>\n <country/>\n </credit_card>\n <data></data>\n</payment_method>\n" + -> "HTTP/1.1 201 Created\r\n" + -> "Date: Sat, 10 Mar 2018 22:04:06 GMT\r\n" + -> "Content-Type: application/xml; charset=utf-8\r\n" + -> "Content-Length: 1875\r\n" + -> "Connection: close\r\n" + -> "X-Frame-Options: SAMEORIGIN\r\n" + -> "X-XSS-Protection: 1; mode=block\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "ETag: W/\"c4ef6dfc389a5514d6b6ffd8bac8786c\"\r\n" + -> "Cache-Control: max-age=0, private, must-revalidate\r\n" + -> "X-Request-Id: b227ok4du2hrj7mrtt10.core_dcaa82760687b3ef\r\n" + -> "Server: nginx\r\n" + -> "Strict-Transport-Security: max-age=31536000; includeSubdomains;\r\n" + -> "\r\n" + reading 1875 bytes... + -> "<transaction>\n <token>NRBpydUCWn658GHV8h2kVlUzB0i</token>\n <created_at type=\"dateTime\">2018-03-10T22:04:06Z</created_at>\n <updated_at type=\"dateTime\">2018-03-10T22:04:06Z</updated_at>\n <succeeded type=\"boolean\">true</succeeded>\n <transaction_type>AddPaymentMethod</transaction_type>\n <retained type=\"boolean\">false</retained>\n <state>succeeded</state>\n <message key=\"messages.transaction_succeeded\">Succeeded!</message>\n <payment_method>\n <token>Wd25UIrH1uopTkZZ4UDdb5XmSDd</token>\n <created_at type=\"dateTime\">2018-03-10T22:04:06Z</created_at>\n <updated_at type=\"dateTime\">2018-03-10T22:04:06Z</updated_at>\n <email nil=\"true\"/>\n <data nil=\"true\"/>\n <storage_state>cached</storage_state>\n <test type=\"boolean\">true</test>\n <last_four_digits>4444</last_four_digits>\n <first_six_digits>555555</first_six_digits>\n <card_type>master</card_type>\n <first_name>Longbob</first_name>\n <last_name>Longsen</last_name>\n <month type=\"integer\">9</month>\n <year type=\"integer\">2019</year>\n <address1 nil=\"true\"/>\n <address2 nil=\"true\"/>\n <city nil=\"true\"/>\n <state nil=\"true\"/>\n <zip nil=\"true\"/>\n <country nil=\"true\"/>\n <phone_number nil=\"true\"/>\n <company nil=\"true\"/>\n <full_name>Longbob Longsen</full_name>\n <eligible_for_card_updater type=\"boolean\">true</eligible_for_card_updater>\n <shipping_address1 nil=\"true\"/>\n <shipping_address2 nil=\"true\"/>\n <shipping_city nil=\"true\"/>\n <shipping_state nil=\"true\"/>\n <shipping_zip nil=\"true\"/>\n <shipping_country nil=\"true\"/>\n <shipping_phone_number nil=\"true\"/>\n <payment_method_type>credit_card</payment_method_type>\n <errors>\n </errors>\n <verification_value>[FILTERED]</verification_value>\n <number>[FILTERED]</number>\n <fingerprint>125370bb396dff6fed4f581f85a91a9e5317</fingerprint>\n </payment_method>\n</transaction>\n" + read 1875 bytes + Conn close + EOS + end end From 528d77b3d6b4ac294ba19b3faeb56256e1e15c71 Mon Sep 17 00:00:00 2001 From: Bart de Water <bartdewater@gmail.com> Date: Thu, 29 Mar 2018 17:09:05 -0400 Subject: [PATCH 357/677] Add missing changelog for #2796 --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index f3a46338581..0992e935065 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -47,6 +47,7 @@ * Checkout V2: Return error codes in response [curiousepic] #2791 * CardStream: Change refund to use REFUND_SALE [dtykocki] #2795 * Spreedly: Scrub sensitive transaction data [abarrak] #2781 +* Stripe: Add `exchange_rate` parameter [WilsonChiang] #2796 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 From 2711a60d0f8895c0212fb186d27349e7dca98a94 Mon Sep 17 00:00:00 2001 From: Bart de Water <bartdewater@gmail.com> Date: Thu, 29 Mar 2018 17:10:34 -0400 Subject: [PATCH 358/677] Release v1.78.0 --- CHANGELOG | 2 ++ lib/active_merchant/version.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 0992e935065..f26ac4963b4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ = ActiveMerchant CHANGELOG == HEAD + +== Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 * Litle: Add Support for Echeck [nfarve] #2776 * Orbital: Correct level 2 tax handling [deedeelavinder] #2729 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index fcd84d92701..ce50e19a8a7 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.77.0" + VERSION = "1.78.0" end From 6fc35994bbf487502bef2dfeadec1cae8d32bdc5 Mon Sep 17 00:00:00 2001 From: Abdullah Barrak <a@abarrak.com> Date: Fri, 30 Mar 2018 13:58:36 +0300 Subject: [PATCH 359/677] Spreedly: Support verify and find operations Closes #2798 Unit Test: 25 tests, 136 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote Test: 33 tests, 153 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/spreedly_core.rb | 47 ++- .../gateways/remote_spreedly_core_test.rb | 58 +++- test/unit/gateways/spreedly_core_test.rb | 296 ++++++++++++++++++ 4 files changed, 388 insertions(+), 14 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f26ac4963b4..dededa97ef3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Spreedly: Support verify and find transactions [abarrak] #2798 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/spreedly_core.rb b/lib/active_merchant/billing/gateways/spreedly_core.rb index 7e93b523d0e..1aab6d811ce 100644 --- a/lib/active_merchant/billing/gateways/spreedly_core.rb +++ b/lib/active_merchant/billing/gateways/spreedly_core.rb @@ -44,7 +44,7 @@ def purchase(money, payment_method, options = {}) purchase_with_token(money, payment_method, options) else MultiResponse.run do |r| - r.process { save_card(false, payment_method, options) } + r.process { save_card(options[:store], payment_method, options) } r.process { purchase_with_token(money, r.authorization, options) } end end @@ -62,7 +62,7 @@ def authorize(money, payment_method, options = {}) authorize_with_token(money, payment_method, options) else MultiResponse.run do |r| - r.process { save_card(false, payment_method, options) } + r.process { save_card(options[:store], payment_method, options) } r.process { authorize_with_token(money, r.authorization, options) } end end @@ -88,6 +88,24 @@ def void(authorization, options={}) commit("transactions/#{authorization}/void.xml", '') end + + # Public: Determine whether a credit card is chargeable card and available for purchases. + # + # payment_method - The CreditCard or the Spreedly payment method token. + # options - A hash of options: + # :store - Retain the payment method if the verify + # succeeds. Defaults to false. (optional) + def verify(payment_method, options = {}) + if payment_method.is_a?(String) + verify_with_token(payment_method, options) + else + MultiResponse.run do |r| + r.process { save_card(options[:store], payment_method, options) } + r.process { verify_with_token(r.authorization, options) } + end + end + end + # Public: Store a credit card in the Spreedly vault and retain it. # # credit_card - The CreditCard to store @@ -106,6 +124,13 @@ def unstore(authorization, options={}) commit("payment_methods/#{authorization}/redact.xml", '', :put) end + # Public: Get the transaction with the given token. + def find(transaction_token) + commit("transactions/#{transaction_token}.xml", nil, :get) + end + + alias_method :status, :find + def supports_scrubbing? true end @@ -140,10 +165,20 @@ def authorize_with_token(money, payment_method_token, options) commit("gateways/#{@options[:gateway_token]}/authorize.xml", request) end + def verify_with_token(payment_method_token, options) + request = build_xml_request('transaction') do |doc| + add_invoice(doc, nil, options) + doc.payment_method_token(payment_method_token) + doc.retain_on_success(true) if options[:store] + add_extra_options(:gateway_specific_fields, doc, options) + end + + commit("gateways/#{@options[:gateway_token]}/verify.xml", request) + end + def auth_purchase_request(money, payment_method_token, options) build_xml_request('transaction') do |doc| add_invoice(doc, money, options) - doc.ip(options[:ip]) add_extra_options(:gateway_specific_fields, doc, options) doc.payment_method_token(payment_method_token) doc.retain_on_success(true) if options[:store] @@ -151,11 +186,11 @@ def auth_purchase_request(money, payment_method_token, options) end def add_invoice(doc, money, options) - doc.amount amount(money) + doc.amount amount(money) unless money.nil? doc.currency_code(options[:currency] || currency(money) || default_currency) doc.order_id(options[:order_id]) - doc.ip(options[:ip]) - doc.description(options[:description]) + doc.ip(options[:ip]) if options[:ip] + doc.description(options[:description]) if options[:description] end def add_credit_card(doc, credit_card, options) diff --git a/test/remote/gateways/remote_spreedly_core_test.rb b/test/remote/gateways/remote_spreedly_core_test.rb index 1059a932349..c9ea36a7d2c 100644 --- a/test/remote/gateways/remote_spreedly_core_test.rb +++ b/test/remote/gateways/remote_spreedly_core_test.rb @@ -8,8 +8,10 @@ def setup @amount = 100 @credit_card = credit_card('5555555555554444') @declined_card = credit_card('4012888888881881') - @existing_payment_method = 'WQ9zJ1UOgak8BrNEi3g5RCianlY' - @declined_payment_method = 'AMc22hrKtQFpYHTvjNx0lGRWZVv' + @existing_payment_method = '3rEkRlZur2hXKbwwRBidHJAIUTO' + @declined_payment_method = 'UPfh3J3JbekLeYC88BP741JWnS5' + @existing_transaction = 'PJ5ICgM6h7v9pBNxDCJjRHDDxBC' + @not_found_transaction = 'AdyQXaG0SVpSoMPdmFlvd3aA3uz' end def test_successful_purchase_with_token @@ -21,7 +23,7 @@ def test_successful_purchase_with_token def test_failed_purchase_with_token assert response = @gateway.purchase(@amount, @declined_payment_method) assert_failure response - assert_match %r(Unable to process the transaction), response.message + assert_match %r(Unable to process the purchase transaction), response.message end def test_successful_authorize_with_token_and_capture @@ -38,7 +40,7 @@ def test_successful_authorize_with_token_and_capture def test_failed_authorize_with_token assert response = @gateway.authorize(@amount, @declined_payment_method) assert_failure response - assert_match %r(Unable to process the transaction), response.message + assert_match %r(Unable to process the authorize transaction), response.message end def test_failed_capture @@ -55,7 +57,7 @@ def test_successful_purchase_with_credit_card assert_success response assert_equal 'Succeeded!', response.message assert_equal 'Purchase', response.params['transaction_type'] - assert_equal 'used', response.params['payment_method_storage_state'] + assert_equal 'cached', response.params['payment_method_storage_state'] end def test_successful_purchase_with_card_and_address @@ -69,7 +71,7 @@ def test_successful_purchase_with_card_and_address assert_equal 'Succeeded!', response.message assert_equal 'joebob@example.com', response.params['payment_method_email'] - assert_equal '1234 My Street', response.params['payment_method_address1'] + assert_equal '456 My Street', response.params['payment_method_address1'] assert_equal 'Apt 1', response.params['payment_method_address2'] assert_equal 'Ottawa', response.params['payment_method_city'] assert_equal 'ON', response.params['payment_method_state'] @@ -122,7 +124,7 @@ def test_successful_authorize_with_card_and_address assert_equal 'Authorization', response.params['transaction_type'] assert_equal 'joebob@example.com', response.params['payment_method_email'] - assert_equal '1234 My Street', response.params['payment_method_address1'] + assert_equal '456 My Street', response.params['payment_method_address1'] assert_equal 'Apt 1', response.params['payment_method_address2'] assert_equal 'Ottawa', response.params['payment_method_city'] assert_equal 'ON', response.params['payment_method_state'] @@ -188,7 +190,7 @@ def test_successful_store_with_address assert response = @gateway.store(@credit_card, options) assert_success response assert_equal 'joebob@example.com', response.params['payment_method_email'] - assert_equal '1234 My Street', response.params['payment_method_address1'] + assert_equal '456 My Street', response.params['payment_method_address1'] assert_equal 'Apt 1', response.params['payment_method_address2'] assert_equal 'Ottawa', response.params['payment_method_city'] assert_equal 'ON', response.params['payment_method_state'] @@ -238,6 +240,46 @@ def test_successful_void assert_equal 'Succeeded!', response.message end + def test_successful_verify_with_token + assert response = @gateway.verify(@existing_payment_method) + assert_success response + assert_equal 'Succeeded!', response.message + assert_equal 'Verification', response.params['transaction_type'] + assert_includes %w(cached retained), response.params['payment_method_storage_state'] + end + + def test_failed_verify_with_token + assert response = @gateway.verify(@declined_payment_method) + assert_failure response + end + + def test_successful_verify_with_credit_card + assert response = @gateway.verify(@credit_card) + assert_success response + assert_equal 'Succeeded!', response.message + assert_equal 'Verification', response.params['transaction_type'] + assert_includes %w(cached retained), response.params['payment_method_storage_state'] + end + + def test_failed_verify_with_declined_credit_card + assert response = @gateway.verify(@declined_card) + assert_failure response + assert_match %r(Unable to process the verify transaction), response.message + end + + def test_successful_find_transaction + assert response = @gateway.find(@existing_transaction) + assert_success response + assert_equal 'Succeeded!', response.message + assert_equal 'Purchase', response.params['transaction_type'] + end + + def test_failed_find_transaction + assert response = @gateway.find(@not_found_transaction) + assert_failure response + assert_match %r(Unable to find the transaction), response.message + end + def test_invalid_login gateway = SpreedlyCoreGateway.new(:login => 'Bogus', :password => 'MoreBogus', :gateway_token => 'EvenMoreBogus') diff --git a/test/unit/gateways/spreedly_core_test.rb b/test/unit/gateways/spreedly_core_test.rb index a0b74eaa339..251b1c4a119 100644 --- a/test/unit/gateways/spreedly_core_test.rb +++ b/test/unit/gateways/spreedly_core_test.rb @@ -8,6 +8,8 @@ def setup @credit_card = credit_card @amount = 103 + @existing_transaction = 'LKA3RchoqYO0njAfhHVw60ohjrC' + @not_found_transaction = 'AdyQXaG0SVpSoMPdmFlvd3aA3uz' end def test_successful_purchase_with_payment_method_token @@ -214,6 +216,24 @@ def test_failed_void assert_equal '10600', response.params['response_error_code'] end + def test_successful_verify + @gateway.expects(:raw_ssl_request).returns(successful_verify_response) + response = @gateway.verify(@payment_method_token) + assert_success response + + assert_equal "Succeeded!", response.message + assert_equal "Verification", response.params["transaction_type"] + end + + def test_failed_verify + @gateway.expects(:raw_ssl_request).returns(failed_verify_response) + response = @gateway.verify(@payment_method_token) + assert_failure response + + assert_equal "Unable to process the verify transaction.", response.message + assert_empty response.params['response_error_code'] + end + def test_successful_store @gateway.expects(:raw_ssl_request).returns(successful_store_response) response = @gateway.store(@credit_card) @@ -241,6 +261,24 @@ def test_successful_unstore assert_equal "Succeeded!", response.message end + def test_successful_find + @gateway.expects(:raw_ssl_request).returns(successful_find_response) + response = @gateway.find(@existing_transaction) + assert_success response + + assert_equal "Succeeded!", response.message + assert_equal "LKA3RchoqYO0njAfhHVw60ohjrC", response.authorization + end + + def test_failed_find + @gateway.expects(:raw_ssl_request).returns(failed_find_response) + response = @gateway.find(@not_found_transaction) + assert_failure response + + assert_match %r(Unable to find the transaction), response.message + assert_match %r(#{@not_found_transaction}), response.message + end + def test_scrubbing assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed @@ -861,4 +899,262 @@ def post_scrubbed Conn close EOS end + + def successful_verify_response + MockResponse.succeeded <<-XML + <transaction> + <on_test_gateway type="boolean">true</on_test_gateway> + <created_at type="dateTime">2018-02-24T00:47:56Z</created_at> + <updated_at type="dateTime">2018-02-24T00:47:56Z</updated_at> + <succeeded type="boolean">true</succeeded> + <state>succeeded</state> + <token>891hWyHKmfCggQQ7Q35sGVcEC01</token> + <transaction_type>Verification</transaction_type> + <order_id nil="true"/> + <ip nil="true"/> + <description nil="true"/> + <email nil="true"/> + <merchant_name_descriptor nil="true"/> + <merchant_location_descriptor nil="true"/> + <gateway_specific_fields nil="true"/> + <gateway_specific_response_fields> + </gateway_specific_response_fields> + <gateway_transaction_id>67</gateway_transaction_id> + <gateway_latency_ms type="integer">27</gateway_latency_ms> + <currency_code>USD</currency_code> + <retain_on_success type="boolean">false</retain_on_success> + <payment_method_added type="boolean">false</payment_method_added> + <message key="messages.transaction_succeeded">Succeeded!</message> + <gateway_token>3gLeg4726V5P0HK7cq7QzHsL0a6</gateway_token> + <gateway_type>test</gateway_type> + <shipping_address> + <name>Jim TesterDude</name> + <address1 nil="true"/> + <address2 nil="true"/> + <city nil="true"/> + <state nil="true"/> + <zip nil="true"/> + <country nil="true"/> + <phone_number nil="true"/> + </shipping_address> + <response> + <success type="boolean">true</success> + <message>Successful verify</message> + <avs_code nil="true"/> + <avs_message nil="true"/> + <cvv_code nil="true"/> + <cvv_message nil="true"/> + <pending type="boolean">false</pending> + <result_unknown type="boolean">false</result_unknown> + <error_code></error_code> + <error_detail nil="true"/> + <cancelled type="boolean">false</cancelled> + <fraud_review nil="true"/> + <created_at type="dateTime">2018-02-24T00:47:56Z</created_at> + <updated_at type="dateTime">2018-02-24T00:47:56Z</updated_at> + </response> + <payment_method> + <token>9AjLflWs7SOKuqJLveOZya9bixa</token> + <created_at type="dateTime">2012-12-07T19:08:15Z</created_at> + <updated_at type="dateTime">2018-02-24T00:35:45Z</updated_at> + <email nil="true"/> + <data> + <how_many>2</how_many> + </data> + <storage_state>retained</storage_state> + <test type="boolean">true</test> + <last_four_digits>4444</last_four_digits> + <first_six_digits>555555</first_six_digits> + <card_type>master</card_type> + <first_name>Jim</first_name> + <last_name>TesterDude</last_name> + <month type="integer">9</month> + <year type="integer">2022</year> + <address1 nil="true"/> + <address2 nil="true"/> + <city nil="true"/> + <state nil="true"/> + <zip nil="true"/> + <country nil="true"/> + <phone_number nil="true"/> + <company nil="true"/> + <full_name>Jim TesterDude</full_name> + <eligible_for_card_updater nil="true"/> + <shipping_address1 nil="true"/> + <shipping_address2 nil="true"/> + <shipping_city nil="true"/> + <shipping_state nil="true"/> + <shipping_zip nil="true"/> + <shipping_country nil="true"/> + <shipping_phone_number nil="true"/> + <payment_method_type>credit_card</payment_method_type> + <errors> + </errors> + <verification_value></verification_value> + <number>XXXX-XXXX-XXXX-4444</number> + <fingerprint>125370bb396dff6fed4f581f85a91a9e5317</fingerprint> + </payment_method> + </transaction> + XML + end + + def failed_verify_response + MockResponse.failed <<-XML + <transaction> + <on_test_gateway type="boolean">true</on_test_gateway> + <created_at type="dateTime">2018-02-24T00:53:58Z</created_at> + <updated_at type="dateTime">2018-02-24T00:53:58Z</updated_at> + <succeeded type="boolean">false</succeeded> + <state>gateway_processing_failed</state> + <token>RwmpyTCRmCpji1YtSD5f5fQDpkS</token> + <transaction_type>Verification</transaction_type> + <order_id nil="true"/> + <ip nil="true"/> + <description nil="true"/> + <email nil="true"/> + <merchant_name_descriptor nil="true"/> + <merchant_location_descriptor nil="true"/> + <gateway_specific_fields nil="true"/> + <gateway_specific_response_fields> + </gateway_specific_response_fields> + <gateway_transaction_id nil="true"/> + <gateway_latency_ms type="integer">24</gateway_latency_ms> + <currency_code>USD</currency_code> + <retain_on_success type="boolean">false</retain_on_success> + <payment_method_added type="boolean">false</payment_method_added> + <message>Unable to process the verify transaction.</message> + <gateway_token>3gLeg4726V5P0HK7cq7QzHsL0a6</gateway_token> + <gateway_type>test</gateway_type> + <shipping_address> + <name>Longbob Longsen</name> + <address1 nil="true"/> + <address2 nil="true"/> + <city nil="true"/> + <state nil="true"/> + <zip nil="true"/> + <country nil="true"/> + <phone_number nil="true"/> + </shipping_address> + <response> + <success type="boolean">false</success> + <message>Unable to process the verify transaction.</message> + <avs_code nil="true"/> + <avs_message nil="true"/> + <cvv_code nil="true"/> + <cvv_message nil="true"/> + <pending type="boolean">false</pending> + <result_unknown type="boolean">false</result_unknown> + <error_code></error_code> + <error_detail nil="true"/> + <cancelled type="boolean">false</cancelled> + <fraud_review nil="true"/> + <created_at type="dateTime">2018-02-24T00:53:58Z</created_at> + <updated_at type="dateTime">2018-02-24T00:53:58Z</updated_at> + </response> + <payment_method> + <token>UzUKWHwI7GtZe3gz1UU5FiZ6DxH</token> + <created_at type="dateTime">2018-02-24T00:53:56Z</created_at> + <updated_at type="dateTime">2018-02-24T00:53:56Z</updated_at> + <email nil="true"/> + <data nil="true"/> + <storage_state>cached</storage_state> + <test type="boolean">true</test> + <last_four_digits>1881</last_four_digits> + <first_six_digits>401288</first_six_digits> + <card_type>visa</card_type> + <first_name>Longbob</first_name> + <last_name>Longsen</last_name> + <month type="integer">9</month> + <year type="integer">2019</year> + <address1 nil="true"/> + <address2 nil="true"/> + <city nil="true"/> + <state nil="true"/> + <zip nil="true"/> + <country nil="true"/> + <phone_number nil="true"/> + <company nil="true"/> + <full_name>Longbob Longsen</full_name> + <eligible_for_card_updater nil="true"/> + <shipping_address1 nil="true"/> + <shipping_address2 nil="true"/> + <shipping_city nil="true"/> + <shipping_state nil="true"/> + <shipping_zip nil="true"/> + <shipping_country nil="true"/> + <shipping_phone_number nil="true"/> + <payment_method_type>credit_card</payment_method_type> + <errors> + </errors> + <verification_value>XXX</verification_value> + <number>XXXX-XXXX-XXXX-1881</number> + <fingerprint>db33a42fcf2908a3795bd4ea881de2e0f015</fingerprint> + </payment_method> + </transaction> + XML + end + + def successful_find_response + MockResponse.succeeded <<-XML + <transaction> + <token>LKA3RchoqYO0njAfhHVw60ohjrC</token> + <created_at type="dateTime">2012-12-07T19:03:50Z</created_at> + <updated_at type="dateTime">2012-12-07T19:03:50Z</updated_at> + <succeeded type="boolean">true</succeeded> + <transaction_type>AddPaymentMethod</transaction_type> + <retained type="boolean">false</retained> + <state>succeeded</state> + <message key="messages.transaction_succeeded">Succeeded!</message> + <payment_method> + <token>67KlSyyvBAt9VUMJg3lUeWbBaWX</token> + <created_at type="dateTime">2012-12-07T19:03:50Z</created_at> + <updated_at type="dateTime">2017-07-29T23:25:21Z</updated_at> + <email nil="true"/> + <data> + <how_many>2</how_many> + </data> + <storage_state>redacted</storage_state> + <test type="boolean">false</test> + <last_four_digits>4444</last_four_digits> + <first_six_digits nil="true"/> + <card_type>master</card_type> + <first_name>Jim</first_name> + <last_name>TesterDude</last_name> + <month type="integer">9</month> + <year type="integer">2022</year> + <address1 nil="true"/> + <address2 nil="true"/> + <city nil="true"/> + <state nil="true"/> + <zip nil="true"/> + <country nil="true"/> + <phone_number nil="true"/> + <company nil="true"/> + <full_name>Jim TesterDude</full_name> + <eligible_for_card_updater type="boolean">true</eligible_for_card_updater> + <shipping_address1 nil="true"/> + <shipping_address2 nil="true"/> + <shipping_city nil="true"/> + <shipping_state nil="true"/> + <shipping_zip nil="true"/> + <shipping_country nil="true"/> + <shipping_phone_number nil="true"/> + <payment_method_type>credit_card</payment_method_type> + <errors> + </errors> + <verification_value></verification_value> + <number></number> + <fingerprint nil="true"/> + </payment_method> + </transaction> + XML + end + + def failed_find_response + MockResponse.failed <<-XML + <errors> + <error key="errors.transaction_not_found">Unable to find the transaction AdyQXaG0SVpSoMPdmFlvd3aA3uz.</error> + </errors> + XML + end end From b9df1eb942375bb5e23d46131f79c065c6447fe8 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Tue, 30 Jan 2018 16:00:35 -0500 Subject: [PATCH 360/677] Mundipagg: New Gateway Implementation Adds new gateway Mundipagg. Adds two new vouchers as credit cards (Sodexo and VR). Allows `delete` requests to pass body parameters. Loaded suite test/unit/gateways/mundipagg_test ............... 15 tests, 66 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Loaded suite test/remote/gateways/remote_mundipagg_test Started .................... 20 tests, 50 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- CHANGELOG | 1 + .../billing/credit_card_methods.rb | 4 +- .../billing/gateways/mundipagg.rb | 289 +++++++ lib/active_merchant/connection.rb | 10 +- test/fixtures.yml | 4 + test/remote/gateways/remote_mundipagg_test.rb | 164 ++++ test/unit/connection_test.rb | 6 + test/unit/credit_card_methods_test.rb | 8 + test/unit/gateways/mundipagg_test.rb | 814 ++++++++++++++++++ 9 files changed, 1297 insertions(+), 3 deletions(-) create mode 100644 lib/active_merchant/billing/gateways/mundipagg.rb create mode 100644 test/remote/gateways/remote_mundipagg_test.rb create mode 100644 test/unit/gateways/mundipagg_test.rb diff --git a/CHANGELOG b/CHANGELOG index dededa97ef3..e041a99f7b1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -51,6 +51,7 @@ * CardStream: Change refund to use REFUND_SALE [dtykocki] #2795 * Spreedly: Scrub sensitive transaction data [abarrak] #2781 * Stripe: Add `exchange_rate` parameter [WilsonChiang] #2796 +* Mundipagg: New Gateway Implementation [nfarve] #2791 == Version 1.77.0 (January 31, 2018) * Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698 diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb index a76a148fadd..8dc47186c1b 100644 --- a/lib/active_merchant/billing/credit_card_methods.rb +++ b/lib/active_merchant/billing/credit_card_methods.rb @@ -14,7 +14,9 @@ module CreditCardMethods 'dankort' => /^5019\d{12}$/, 'maestro' => /^(5[06-8]|6\d)\d{10,17}$/, 'forbrugsforeningen' => /^600722\d{10}$/, - 'laser' => /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/ + 'laser' => /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/, + 'sodexo' => /^(606071|603389|606070|606069|606068|600818)\d{8}$/, + 'vr' => /^(627416|637036)\d{8}$/ } # http://www.barclaycard.co.uk/business/files/bin_rules.pdf diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb new file mode 100644 index 00000000000..1ec773acf8f --- /dev/null +++ b/lib/active_merchant/billing/gateways/mundipagg.rb @@ -0,0 +1,289 @@ +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class MundipaggGateway < Gateway + self.live_url = 'https://api.mundipagg.com/core/v1' + + self.supported_countries = ['US'] + self.default_currency = 'USD' + self.supported_cardtypes = [:visa, :master, :american_express, :discover] + + self.homepage_url = 'https://www.mundipagg.com/' + self.display_name = 'Mundipagg' + + STANDARD_ERROR_CODE_MAPPING = { + '400' => STANDARD_ERROR_CODE[:processing_error], + '401' => STANDARD_ERROR_CODE[:config_error], + '404' => STANDARD_ERROR_CODE[:processing_error], + '412' => STANDARD_ERROR_CODE[:processing_error], + '422' => STANDARD_ERROR_CODE[:processing_error], + '500' => STANDARD_ERROR_CODE[:processing_error] + } + + STANDARD_ERROR_MESSAGE_MAPPING = { + '400' => 'Invalid request;', + '401' => 'Invalid API key;', + '404' => 'The requested resource does not exist;', + '412' => 'Valid parameters but request failed;', + '422' => 'Invalid parameters;', + '500' => 'An internal error occurred;' + } + + def initialize(options={}) + requires!(options, :api_key) + super + end + + def purchase(money, payment, options={}) + post = {} + add_invoice(post, money, options) + add_customer_data(post, options) unless payment.is_a?(String) + add_shipping_address(post, options) + add_payment(post, payment, options) + + commit('sale', post) + end + + def authorize(money, payment, options={}) + post = {} + add_invoice(post, money, options) + add_customer_data(post, options) unless payment.is_a?(String) + add_shipping_address(post, options) + add_payment(post, payment, options) + add_capture_flag(post, payment) + commit('authonly', post) + end + + def capture(money, authorization, options={}) + post = {} + post[:code] = authorization + add_invoice(post, money, options) + commit('capture', post, authorization) + end + + def refund(money, authorization, options={}) + add_invoice(post={}, money, options) + commit('refund', post, authorization) + end + + def void(authorization, options={}) + commit('void', post=nil, authorization) + end + + def store(payment, options={}) + post = {} + options.update(name: payment.name) + options = add_customer(options) unless options[:customer_id] + add_payment(post, payment, options) + commit('store', post, options[:customer_id]) + end + + def verify(credit_card, options={}) + MultiResponse.run(:use_first_response) do |r| + r.process { authorize(100, credit_card, options) } + r.process(:ignore_result) { void(r.authorization, options) } + end + end + + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript + .gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]') + .gsub(%r(("cvv\\":\\")\d*), '\1[FILTERED]') + .gsub(%r((card\\":{\\"number\\":\\")\d*), '\1[FILTERED]') + end + + private + + def add_customer(options) + post = {} + post[:name] = options[:name] + customer = commit('customer', post) + options.update(customer_id: customer.authorization) + end + + def add_customer_data(post, options) + post[:customer] = {} + post[:customer][:email] = options[:email] + end + + def add_billing_address(options) + billing = {} + address = options[:billing_address] || options[:address] + billing[:street] = address[:address1].match(/\D+/)[0].strip if address[:address1] + billing[:number] = address[:address1].match(/\d+/)[0] if address[:address1] + billing[:compliment] = address[:address2] if address[:address2] + billing[:city] = address[:city] if address[:city] + billing[:state] = address[:state] if address[:state] + billing[:country] = address[:country] if address[:country] + billing[:zip_code] = address[:zip] if address[:zip] + billing[:neighborhood] = address[:neighborhood] + billing + end + + def add_shipping_address(post, options) + if address = options[:shipping_address] + post[:address] = {} + post[:address][:street] = address[:address1].match(/\D+/)[0].strip if address[:address1] + post[:address][:number] = address[:address1].match(/\d+/)[0] if address[:address1] + post[:address][:compliment] = address[:address2] if address[:address2] + post[:address][:city] = address[:city] if address[:city] + post[:address][:state] = address[:state] if address[:state] + post[:address][:country] = address[:country] if address[:country] + post[:address][:zip_code] = address[:zip] if address[:zip] + end + end + + def add_invoice(post, money, options) + post[:amount] = money + post[:currency] = (options[:currency] || currency(money)) + end + + def add_capture_flag(post, payment) + if voucher?(payment) + post[:payment][:voucher][:capture] = false + else + post[:payment][:credit_card][:capture] = false + end + end + + def add_payment(post, payment, options) + post[:customer][:name] = payment.name if post[:customer] + post[:customer_id] = parse_auth(payment)[0] if payment.is_a?(String) + post[:payment] = {} + post[:payment][:gateway_affiliation_id] = @options[:gateway_id] + post[:payment][:metadata] = { mundipagg_payment_method_code: '1' } if test? + if voucher?(payment) + add_voucher(post, payment, options) + else + add_credit_card(post, payment, options) + end + end + + def add_credit_card(post, payment, options) + post[:payment][:payment_method] = 'credit_card' + post[:payment][:credit_card] = {} + if payment.is_a?(String) + post[:payment][:credit_card][:card_id] = parse_auth(payment)[1] + else + post[:payment][:credit_card][:card] = {} + post[:payment][:credit_card][:card][:number] = payment.number + post[:payment][:credit_card][:card][:holder_name] = payment.name + post[:payment][:credit_card][:card][:exp_month] = payment.month + post[:payment][:credit_card][:card][:exp_year] = payment.year + post[:payment][:credit_card][:card][:cvv] = payment.verification_value + post[:payment][:credit_card][:card][:billing_address] = add_billing_address(options) + end + end + + def add_voucher(post, payment, options) + post[:currency] = 'BRL' + post[:payment][:payment_method] = 'voucher' + post[:payment][:voucher] = {} + post[:payment][:voucher][:card] = {} + post[:payment][:voucher][:card][:number] = payment.number + post[:payment][:voucher][:card][:holder_name] = payment.name + post[:payment][:voucher][:card][:holder_document] = options[:holder_document] + post[:payment][:voucher][:card][:exp_month] = payment.month + post[:payment][:voucher][:card][:exp_year] = payment.year + post[:payment][:voucher][:card][:cvv] = payment.verification_value + post[:payment][:voucher][:card][:billing_address] = add_billing_address(options) + end + + def voucher?(payment) + return false if payment.is_a?(String) + %w[sodexo vr].include? card_brand(payment) + end + + def headers + { + 'Authorization' => 'Basic ' + Base64.strict_encode64("#{@options[:api_key]}:"), + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + } + end + + def parse(body) + JSON.parse(body) + end + + def url_for(action, auth = nil) + url = live_url + case action + when 'store' + "#{url}/customers/#{auth}/cards/" + when 'customer' + "#{url}/customers/" + when 'refund', 'void' + "#{url}/charges/#{auth}/" + when 'capture' + "#{url}/charges/#{auth}/capture/" + else + "#{url}/charges/" + end + end + + def commit(action, parameters, auth = nil) + url = url_for(action, auth) + parameters.merge!(parameters[:payment][:credit_card].delete(:card)).delete(:payment) if action == 'store' + response = if %w[refund void].include? action + parse(ssl_request(:delete, url, post_data(parameters), headers)) + else + parse(ssl_post(url, post_data(parameters), headers)) + end + + Response.new( + success_from(response), + message_from(response), + response, + authorization: authorization_from(response, action), + avs_result: AVSResult.new(code: response['some_avs_response_key']), + cvv_result: CVVResult.new(response['some_cvv_response_key']), + test: test?, + error_code: error_code_from(response) + ) + rescue ResponseError => e + message = get_error_message(e) + return Response.new( + false, + "#{STANDARD_ERROR_MESSAGE_MAPPING[e.response.code]} #{message}", + parse(e.response.body), + test: test?, + error_code: STANDARD_ERROR_CODE_MAPPING[e.response.code], + ) + end + + def success_from(response) + %w[pending paid processing canceled active].include? response['status'] + end + + def get_error_message(error) + JSON.parse(error.response.body)['message'] + end + + def message_from(response) + return response['message'] if response['message'] + return response['last_transaction']['acquirer_message'] if response['last_transaction'] + end + + def authorization_from(response, action) + return "#{response['customer']['id']}|#{response['id']}" if action == 'store' + response['id'] + end + + def parse_auth(auth) + auth.split('|') + end + + def post_data(parameters = {}) + parameters.to_json + end + + def error_code_from(response) + STANDARD_ERROR_CODE[:processing_error] unless success_from(response) + end + end + end +end diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index b859cc1f76c..6be20a588ea 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -80,8 +80,14 @@ def request(method, body, headers = {}) # It's kind of ambiguous whether the RFC allows bodies # for DELETE requests. But Net::HTTP's delete method # very unambiguously does not. - raise ArgumentError, "DELETE requests do not support a request body" if body - http.delete(endpoint.request_uri, headers) + if body + debug body + req = Net::HTTP::Delete.new(endpoint.request_uri, headers) + req.body = body + http.request(req) + else + http.delete(endpoint.request_uri, headers) + end else raise ArgumentError, "Unsupported request method #{method.to_s.upcase}" end diff --git a/test/fixtures.yml b/test/fixtures.yml index c1eeed84be6..6118cc4f9af 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -531,6 +531,10 @@ money_movers: login: demo password: password +mundipagg: + api_key: api_key + gateway_id: gateway_id + # Working credentials, no need to replace nab_transact: login: ABC0001 diff --git a/test/remote/gateways/remote_mundipagg_test.rb b/test/remote/gateways/remote_mundipagg_test.rb new file mode 100644 index 00000000000..52391c42c63 --- /dev/null +++ b/test/remote/gateways/remote_mundipagg_test.rb @@ -0,0 +1,164 @@ +require 'test_helper' + +class RemoteMundipaggTest < Test::Unit::TestCase + def setup + @gateway = MundipaggGateway.new(fixtures(:mundipagg)) + + @amount = 100 + @credit_card = credit_card('4000100011112224') + @declined_card = credit_card('4000300011112220') + @voucher = credit_card('60607044957644', brand: 'sodexo') + @options = { + billing_address: address(options = { neighborhood: 'Sesame Street' }), + description: 'Store Purchase' + } + end + + def test_successful_purchase + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Simulator|Transação de simulação autorizada com sucesso', response.message + end + + def test_successful_purchase_with_more_options + options = @options.update({ + order_id: '1', + ip: '127.0.0.1', + email: 'joe@example.com', + shipping_address: address + }) + + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + end + + def test_successful_purchase_with_voucher + @options.update(holder_document: '93095135270') + response = @gateway.purchase(@amount, @voucher, @options) + assert_success response + assert_equal 'Simulator|Transação de simulação autorizada com sucesso', response.message + end + + def test_failed_purchase + response = @gateway.purchase(105200, @declined_card, @options) + assert_failure response + assert_equal 'Simulator|Transação de simulada negada por falta de crédito, utilizado para realizar simulação de autorização parcial.', response.message + end + + def test_successful_authorize_and_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + assert_equal 'Simulator|Transação de simulação capturada com sucesso', capture.message + end + + def test_failed_authorize + response = @gateway.authorize(105200, @declined_card, @options) + assert_failure response + assert_equal 'Simulator|Transação de simulada negada por falta de crédito, utilizado para realizar simulação de autorização parcial.', response.message + end + + def test_partial_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount-1, auth.authorization) + assert_success capture + end + + def test_failed_capture + response = @gateway.capture(@amount, 'abc') + assert_failure response + assert_equal 'The requested resource does not exist; Charge not found.', response.message + end + + def test_successful_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount, purchase.authorization) + assert_success refund + end + + def test_partial_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount - 1, purchase.authorization) + assert_success refund + end + + def test_failed_refund + response = @gateway.refund(@amount, 'abc') + assert_failure response + assert_equal 'The requested resource does not exist; Charge not found.', response.message + end + + def test_successful_void + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert void = @gateway.void(auth.authorization) + assert_success void + end + + def test_successful_void_with_voucher + @options.update(holder_document: '93095135270') + auth = @gateway.purchase(@amount, @voucher, @options) + assert_success auth + + assert void = @gateway.void(auth.authorization) + assert_success void + end + + def test_successful_refund_with_voucher + @options.update(holder_document: '93095135270') + auth = @gateway.purchase(@amount, @voucher, @options) + assert_success auth + + assert void = @gateway.refund(1, auth.authorization) + assert_success void + end + + def test_failed_void + response = @gateway.void('abc') + assert_failure response + assert_equal 'The requested resource does not exist; Charge not found.', response.message + end + + def test_successful_verify + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_match %r{Simulator|Transação de simulação autorizada com sucesso}, response.message + end + + def test_successful_store_and_purchase + store = @gateway.store(@credit_card, @options) + assert_success store + + assert purchase = @gateway.purchase(@amount, store.authorization, @options) + assert_success purchase + assert_equal 'Simulator|Transação de simulação autorizada com sucesso', purchase.message + end + + def test_invalid_login + gateway = MundipaggGateway.new(api_key: '') + + response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_match %r{Invalid API key; Authorization has been denied for this request.}, response.message + end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:api_key], transcript) + end +end diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index 6417270fe83..59c3d98a062 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -51,6 +51,12 @@ def test_successful_delete_request assert_equal 'success', response.body end + def test_successful_delete_with_body_request + Net::HTTP.any_instance.expects(:request).at_most(3).returns(@ok) + response = @connection.request(:delete, 'data', {}) + assert_equal 'success', response.body + end + def test_get_raises_argument_error_if_passed_data assert_raises(ArgumentError) do @connection.request(:get, 'data', {}) diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb index e910ddfecdd..2e99504a258 100644 --- a/test/unit/credit_card_methods_test.rb +++ b/test/unit/credit_card_methods_test.rb @@ -154,6 +154,14 @@ def test_should_detect_laser_card assert_equal 'laser', CreditCard.brand?('677117111234') end + def test_should_detect_sodexo_card + assert_equal 'sodexo', CreditCard.brand?('60606944957644') + end + + def test_should_detect_vr_card + assert_equal 'vr', CreditCard.brand?('63703644957644') + end + def test_should_detect_when_an_argument_brand_does_not_match_calculated_brand assert CreditCard.matching_brand?('4175001000000000', 'visa') assert_false CreditCard.matching_brand?('4175001000000000', 'master') diff --git a/test/unit/gateways/mundipagg_test.rb b/test/unit/gateways/mundipagg_test.rb new file mode 100644 index 00000000000..d610875abc4 --- /dev/null +++ b/test/unit/gateways/mundipagg_test.rb @@ -0,0 +1,814 @@ +require 'test_helper' + +class MundipaggTest < Test::Unit::TestCase + include CommStub + def setup + @gateway = MundipaggGateway.new(api_key: 'my_api_key') + @credit_card = credit_card + @amount = 100 + + @options = { + order_id: '1', + billing_address: address, + description: 'Store Purchase' + } + end + + def test_successful_purchase + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + + assert_equal 'ch_90Vjq8TrwfP74XJO', response.authorization + assert response.test? + end + + def test_failed_purchase + @gateway.expects(:ssl_post).returns(failed_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code + end + + def test_successful_authorize + @gateway.expects(:ssl_post).returns(successful_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + + assert_equal 'ch_gm5wrlGMI2Fb0x6K', response.authorization + assert response.test? + end + + def test_failed_authorize + @gateway.expects(:ssl_post).returns(failed_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code + end + + def test_successful_capture + @gateway.expects(:ssl_post).returns(successful_capture_response) + + response = @gateway.capture(@amount, @credit_card, @options) + assert_success response + + assert_equal 'ch_gm5wrlGMI2Fb0x6K', response.authorization + assert response.test? + end + + def test_failed_capture + @gateway.expects(:ssl_post).returns(failed_capture_response) + + response = @gateway.capture(@amount, @credit_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code + end + + def test_successful_refund + @gateway.expects(:ssl_request).returns(successful_refund_response) + + response = @gateway.refund(@amount, 'K1J5B1YFLE') + assert_success response + + assert_equal 'ch_RbPVPWMH2bcGA50z', response.authorization + assert response.test? + end + + def test_failed_refund + @gateway.expects(:ssl_request).returns(failed_refund_response) + + response = @gateway.refund(@amount, 'abc') + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code + end + + def test_successful_void + @gateway.expects(:ssl_request).returns(successful_void_response) + + response = @gateway.void('ch_RbPVPWMH2bcGA50z') + assert_success response + + assert_equal 'ch_RbPVPWMH2bcGA50z', response.authorization + assert response.test? + end + + def test_failed_void + @gateway.expects(:ssl_request).returns(failed_void_response) + + response = @gateway.void('abc') + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code + end + + def test_successful_verify + @gateway.expects(:ssl_post).returns(successful_verify_response) + + response = @gateway.verify(@credit_card, @options) + assert_success response + + assert_equal 'ch_G9rB74PI3uoDMxAo', response.authorization + assert response.test? + end + + def test_successful_verify_with_failed_void + response = stub_comms(@gateway, :ssl_request) do + @gateway.verify(@credit_card, @options) + end.respond_with(successful_authorize_response, failed_void_response) + assert_success response + assert_equal 'Simulator|Transação de simulação autorizada com sucesso', response.message + end + + def test_sucessful_store + @gateway.expects(:ssl_post).times(2).returns(successful_create_customer_response, successful_store_response) + + response = @gateway.store(@credit_card, @options) + assert_success response + + assert_equal 'cus_N70xAX6S65cMnokB|card_51ElNwYSVJFpRe0g', response.authorization + assert response.test? + end + + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + + private + + def pre_scrubbed + %q( + opening connection to api.mundipagg.com:443... + opened + starting SSL for api.mundipagg.com:443... + SSL established + <- "POST /core/v1/charges/ HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Basic c2tfdGVzdF9keE1WOE51QnZpajZKNVhuOg==\r\nAccept: application/json\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.mundipagg.com\r\nContent-Length: 424\r\n\r\n" + <- "{\"amount\":100,\"currency\":\"USD\",\"customer\":{\"email\":null,\"name\":\"Longbob Longsen\"},\"payment\":{\"payment_method\":\"credit_card\",\"credit_card\":{\"card\":{\"number\":\"4000100011112224\",\"holder_name\":\"Longbob Longsen\",\"exp_month\":9,\"exp_year\":2019,\"cvv\":\"123\",\"billing_address\":{\"street\":\"My Street\",\"number\":\"456\",\"compliment\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"country\":\"CA\",\"zip_code\":\"K1C2N6\",\"neighborhood\":\"Sesame Street\"}}}}}" + -> "HTTP/1.1 200 OK\r\n" + -> "Date: Thu, 01 Feb 2018 20:23:19 GMT\r\n" + -> "Content-Type: application/json; charset=utf-8\r\n" + -> "Content-Length: 801\r\n" + -> "Connection: close\r\n" + -> "Cache-Control: no-cache\r\n" + -> "Pragma: no-cache\r\n" + -> "Content-Encoding: gzip\r\n" + -> "Expires: -1\r\n" + -> "Set-Cookie: TS01e8e2cd=0118d560cc62281517c87bb3b52c62fba3f9d13acb485adc69cac121833699beb2a66ca4bfe3e2af65dfe2f67542ec36ff8e41db56; Path=/; Domain=.api.mundipagg.com\r\n" + -> "\r\n" + reading 801 bytes... + -> "\x1F\x8B\b\x00\x00\x00\x00\x00\x04\x00\x95T\xCDn\x9C0\x10\xBEW\xEA; \xCEA2,,lnmRU\xD5\xB6I\x9AM\xAA\xAA\x174k\x9B]\xB7`\x13c\xB2\xD9\xA4\xFB4=\xF4A\xF2b\xB5\xCD\xC2\x82H\x95\xE4\x84\x98\xEF\x9B\xF1\xCC7?\x0Fo\xDF8\x8E\xCB\x88{\xEC\xB8x\x9D\xBE\x17\xBF\xD0\x1C>_G??\xDD\x7F\xBF\xF9\x9A\xBBG\x16\xC7\x82P\xC3\xF8\x18$\x97'\xA7\xC1b6\xDF\x03+Pt\x03\xDB\xB4\t\x004\xC1\x81\x8F#\x8FNH\xE6\x85\x10\x11o\x19\xFB\xB1\x87&\xD3I\x12M!\x0E\t\xEC\x1D\xA1\x105W\xDA\xC9G\xA8\xB1\x94\xC0H:6W\nT]\x99\xE8\x86\xD0\xE6SKI9\xDE\x1A\xF3\xF5\xE2\xD4m#l\v\xCAUZP\xB5\x16ME\x92\x12\xA6R\f\x92\xB8\xFDW\xCC\vn\x80\xFC\xC4C\x81\x87\xFC\xAB\x00\x1D\a\x93c\x7F\xF6\xA3\x8D/\xA9.\xEC\xFF\xC4\xA4%\xD6%y\x19\x11\xD7\x95\x12\x05\x95\x9A\xF6`\f\a\xD1\xEB*\xF5O\xCF/6\xE8j\xB3Y\xD0\xF8\xC3\\$\x8D\x8F\xA6p(\xAC\xEE\x9F\x05_-\xC5\xD21\xDF\x8A\xF2\x0E\xA7\x05\xB0\xDC\x10:\v\xA19\xE375\xB5\"f\x90W\xB4E^Z\xD3+\xAA2z\xAE\x05\xA7\xA6=\x0F;c\xD95\xD5\xE6P\xA9TI\xE0\x15`\xC5\x04\x1FUm\xB0\xF4\xAE\xD8\xC2\xE6v\xC3\xC2\xB3\xEB \x96\xF3\xB2\v\xDA\xF3L\xD5\xB6\xA4O\xB6r4}q\xE0\x87\xD3 \x9Eya\x92\x10/DQ\xE6\xC1\x94\xF8\x1E\xC28\xCE\xA2)\xCEhD;\xD7\xD1\xA0\rF\rC\xA9j\xFD`G\xAFj\x8Cie0%\xEBNR\xC6\xB5K\x9E\x9B\xA13\x90\xDF\x05\xC775\x93T\xA6m\xFF*V\xD49(!\xDD\x11\x05\xB2\x8C\xE5\fl\xAD\xED\x9A\x8DY\xAA)1\fga\x18\x8Da^\xD5\x06\x9E\xA0d\x12=\x01C\xAD\xD6]\xF0Y\x10\xC5\xF1lL*t}\xB0\xB2\x94E\x9B\xEE\xEF+\xDB\x89\xC7\xBF\x8F\x7F\x84C\xA8\xD3\xD4\xD1\xFC\xEA\xA0B\xB2{ \xE0`Q8Z!\x1D@\x8C\xE3J\xAA\xA5<\xD4\x86:\x86(\xA9\x84A\x8Fm\x9E\xC0I\xBA\xD7\xBF\xA3\xDA\xAEw3t\xD8\x1DmN\xEF\xE4\xFC'\x8F.\xD4\xEA\x12\xF3\xFB`\x19\xB7N\x9A\x951\xA9\xE7\xB0bw)a+f{\xE4\x86\b!\x1F\xF5HvV3Q\xCB\x1E\b\x82\xB0GYj\x15\xEC\x83\xDFX\x05=\xFBZ\xE4\xA4\xD7\xE5\xFFl\xA9\xD9\xD3\xBB2-\x04WkM\x9B\r\xCD[\n\xE6\xE8%\xEB\x01\x87I4[pK{\xA1\x9E[\xE3\xD9\x8F\x1E\xF9\xB9E\x1E\x90\x97,\xD7\xB7c\x95\x02!\xB2\x99\xF5No\x9B\x92\xA4\xD4\x86\xF9\xB2u\x16\xCD\xCFQ\x0F\xE7u\xB1\xB4\xE7\xCD\r\xA3\xE9\x00\xB9ge\xD7\xFD\xB9\x7F\x12\x9C\raN\xD9j\xBD\x14r-\x9A\x9B\xBD\xA0\x95\xD6\xF3\xA9'0S\xF6\xE2\x9F+\x05\e\x18@F0\xFB\xC0\xF9\xD9\xD0\xC5l\xB9\xB4^'\xEF\x06\x88.\x95\xA6\xFE>\xDF#\xA7+\xEA\xC8\x19&\xD0\xBA\xEC\x0EB\rO\xD2\x9E\xB1\xEBf\xF5\xC5\rzE{\xBAS\xA7;S\n^\xD1\xC16\xB4\xEA\xEA\bm6\xF6\x18\xBF}\xB3\xFB\aD\t\x1C\xBA\xE0\a\x00\x00" + read 801 bytes + Conn close + ) + end + + def post_scrubbed + %q( + opening connection to api.mundipagg.com:443... + opened + starting SSL for api.mundipagg.com:443... + SSL established + <- "POST /core/v1/charges/ HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Basic [FILTERED]==\r\nAccept: application/json\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.mundipagg.com\r\nContent-Length: 424\r\n\r\n" + <- "{\"amount\":100,\"currency\":\"USD\",\"customer\":{\"email\":null,\"name\":\"Longbob Longsen\"},\"payment\":{\"payment_method\":\"credit_card\",\"credit_card\":{\"card\":{\"number\":\"[FILTERED]\",\"holder_name\":\"Longbob Longsen\",\"exp_month\":9,\"exp_year\":2019,\"cvv\":\"[FILTERED]\",\"billing_address\":{\"street\":\"My Street\",\"number\":\"456\",\"compliment\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"country\":\"CA\",\"zip_code\":\"K1C2N6\",\"neighborhood\":\"Sesame Street\"}}}}}" + -> "HTTP/1.1 200 OK\r\n" + -> "Date: Thu, 01 Feb 2018 20:23:19 GMT\r\n" + -> "Content-Type: application/json; charset=utf-8\r\n" + -> "Content-Length: 801\r\n" + -> "Connection: close\r\n" + -> "Cache-Control: no-cache\r\n" + -> "Pragma: no-cache\r\n" + -> "Content-Encoding: gzip\r\n" + -> "Expires: -1\r\n" + -> "Set-Cookie: TS01e8e2cd=0118d560cc62281517c87bb3b52c62fba3f9d13acb485adc69cac121833699beb2a66ca4bfe3e2af65dfe2f67542ec36ff8e41db56; Path=/; Domain=.api.mundipagg.com\r\n" + -> "\r\n" + reading 801 bytes... + -> "\x1F\x8B\b\x00\x00\x00\x00\x00\x04\x00\x95T\xCDn\x9C0\x10\xBEW\xEA; \xCEA2,,lnmRU\xD5\xB6I\x9AM\xAA\xAA\x174k\x9B]\xB7`\x13c\xB2\xD9\xA4\xFB4=\xF4A\xF2b\xB5\xCD\xC2\x82H\x95\xE4\x84\x98\xEF\x9B\xF1\xCC7?\x0Fo\xDF8\x8E\xCB\x88{\xEC\xB8x\x9D\xBE\x17\xBF\xD0\x1C>_G??\xDD\x7F\xBF\xF9\x9A\xBBG\x16\xC7\x82P\xC3\xF8\x18$\x97'\xA7\xC1b6\xDF\x03+Pt\x03\xDB\xB4\t\x004\xC1\x81\x8F#\x8FNH\xE6\x85\x10\x11o\x19\xFB\xB1\x87&\xD3I\x12M!\x0E\t\xEC\x1D\xA1\x105W\xDA\xC9G\xA8\xB1\x94\xC0H:6W\nT]\x99\xE8\x86\xD0\xE6SKI9\xDE\x1A\xF3\xF5\xE2\xD4m#l\v\xCAUZP\xB5\x16ME\x92\x12\xA6R\f\x92\xB8\xFDW\xCC\vn\x80\xFC\xC4C\x81\x87\xFC\xAB\x00\x1D\a\x93c\x7F\xF6\xA3\x8D/\xA9.\xEC\xFF\xC4\xA4%\xD6%y\x19\x11\xD7\x95\x12\x05\x95\x9A\xF6`\f\a\xD1\xEB*\xF5O\xCF/6\xE8j\xB3Y\xD0\xF8\xC3\\$\x8D\x8F\xA6p(\xAC\xEE\x9F\x05_-\xC5\xD21\xDF\x8A\xF2\x0E\xA7\x05\xB0\xDC\x10:\v\xA19\xE375\xB5\"f\x90W\xB4E^Z\xD3+\xAA2z\xAE\x05\xA7\xA6=\x0F;c\xD95\xD5\xE6P\xA9TI\xE0\x15`\xC5\x04\x1FUm\xB0\xF4\xAE\xD8\xC2\xE6v\xC3\xC2\xB3\xEB \x96\xF3\xB2\v\xDA\xF3L\xD5\xB6\xA4O\xB6r4}q\xE0\x87\xD3 \x9Eya\x92\x10/DQ\xE6\xC1\x94\xF8\x1E\xC28\xCE\xA2)\xCEhD;\xD7\xD1\xA0\rF\rC\xA9j\xFD`G\xAFj\x8Cie0%\xEBNR\xC6\xB5K\x9E\x9B\xA13\x90\xDF\x05\xC775\x93T\xA6m\xFF*V\xD49(!\xDD\x11\x05\xB2\x8C\xE5\fl\xAD\xED\x9A\x8DY\xAA)1\fga\x18\x8Da^\xD5\x06\x9E\xA0d\x12=\x01C\xAD\xD6]\xF0Y\x10\xC5\xF1lL*t}\xB0\xB2\x94E\x9B\xEE\xEF+\xDB\x89\xC7\xBF\x8F\x7F\x84C\xA8\xD3\xD4\xD1\xFC\xEA\xA0B\xB2{ \xE0`Q8Z!\x1D@\x8C\xE3J\xAA\xA5<\xD4\x86:\x86(\xA9\x84A\x8Fm\x9E\xC0I\xBA\xD7\xBF\xA3\xDA\xAEw3t\xD8\x1DmN\xEF\xE4\xFC'\x8F.\xD4\xEA\x12\xF3\xFB`\x19\xB7N\x9A\x951\xA9\xE7\xB0bw)a+f{\xE4\x86\b!\x1F\xF5HvV3Q\xCB\x1E\b\x82\xB0GYj\x15\xEC\x83\xDFX\x05=\xFBZ\xE4\xA4\xD7\xE5\xFFl\xA9\xD9\xD3\xBB2-\x04WkM\x9B\r\xCD[\n\xE6\xE8%\xEB\x01\x87I4[pK{\xA1\x9E[\xE3\xD9\x8F\x1E\xF9\xB9E\x1E\x90\x97,\xD7\xB7c\x95\x02!\xB2\x99\xF5No\x9B\x92\xA4\xD4\x86\xF9\xB2u\x16\xCD\xCFQ\x0F\xE7u\xB1\xB4\xE7\xCD\r\xA3\xE9\x00\xB9ge\xD7\xFD\xB9\x7F\x12\x9C\raN\xD9j\xBD\x14r-\x9A\x9B\xBD\xA0\x95\xD6\xF3\xA9'0S\xF6\xE2\x9F+\x05\e\x18@F0\xFB\xC0\xF9\xD9\xD0\xC5l\xB9\xB4^'\xEF\x06\x88.\x95\xA6\xFE>\xDF#\xA7+\xEA\xC8\x19&\xD0\xBA\xEC\x0EB\rO\xD2\x9E\xB1\xEBf\xF5\xC5\rzE{\xBAS\xA7;S\n^\xD1\xC16\xB4\xEA\xEA\bm6\xF6\x18\xBF}\xB3\xFB\aD\t\x1C\xBA\xE0\a\x00\x00" + read 801 bytes + Conn close + ) + end + + def successful_purchase_response + %( + { + "id": "ch_90Vjq8TrwfP74XJO", + "code": "ME0KIN4A0O", + "gateway_id": "162bead8-23a0-4708-b687-078a69a1aa7c", + "amount": 100, + "paid_amount": 100, + "status": "paid", + "currency": "USD", + "payment_method": "credit_card", + "paid_at": "2018-02-01T18:41:05Z", + "created_at": "2018-02-01T18:41:04Z", + "updated_at": "2018-02-01T18:41:04Z", + "customer": { + "id": "cus_VxJX2NmTqyUnXgL9", + "name": "Longbob Longsen", + "email": "", + "delinquent": false, + "created_at": "2018-02-01T18:41:04Z", + "updated_at": "2018-02-01T18:41:04Z", + "phones": {} + }, + "last_transaction": { + "id": "tran_JNzjzadcVZHlG8K2", + "transaction_type": "credit_card", + "gateway_id": "c579c8fa-53d7-41a8-b4cc-a03c712ebbb7", + "amount": 100, + "status": "captured", + "success": true, + "installments": 1, + "acquirer_name": "simulator", + "acquirer_affiliation_code": "", + "acquirer_tid": "198548", + "acquirer_nsu": "866277", + "acquirer_auth_code": "713736", + "acquirer_message": "Simulator|Transação de simulação autorizada com sucesso", + "acquirer_return_code": "0", + "operation_type": "auth_and_capture", + "card": { + "id": "card_pD02Q6WtOTB7a3kE", + "first_six_digits": "400010", + "last_four_digits": "2224", + "brand": "Visa", + "holder_name": "Longbob Longsen", + "exp_month": 9, + "exp_year": 2019, + "status": "active", + "created_at": "2018-02-01T18:41:04Z", + "updated_at": "2018-02-01T18:41:04Z", + "billing_address": { + "street": "My Street", + "number": "456", + "zip_code": "K1C2N6", + "neighborhood": "Sesame Street", + "city": "Ottawa", + "state": "ON", + "country": "CA", + "line_1": "456, My Street, Sesame Street" + }, + "type": "credit" + }, + "created_at": "2018-02-01T18:41:04Z", + "updated_at": "2018-02-01T18:41:04Z", + "gateway_response": { + "code": "201" + } + } + } + ) + end + + def failed_purchase_response + %( + { + "id": "ch_ykXLG3RfVfNE4dZe", + "code": "3W80HGVS0R", + "gateway_id": "79ae6732-1b60-4008-80f5-0d1be8ec41a7", + "amount": 105200, + "status": "failed", + "currency": "USD", + "payment_method": "credit_card", + "created_at": "2018-02-01T18:42:44Z", + "updated_at": "2018-02-01T18:42:45Z", + "customer": { + "id": "cus_0JnywlzI3hV6ZNe2", + "name": "Longbob Longsen", + "email": "", + "delinquent": false, + "created_at": "2018-02-01T18:42:44Z", + "updated_at": "2018-02-01T18:42:44Z", + "phones": {} + }, + "last_transaction": { + "id": "tran_nVx8730IjhOR8PD2", + "transaction_type": "credit_card", + "gateway_id": "f3993413-73a0-4e8d-a7bc-eb3ed198c770", + "amount": 105200, + "status": "not_authorized", + "success": false, + "installments": 1, + "acquirer_name": "simulator", + "acquirer_affiliation_code": "", + "acquirer_message": "Simulator|Transação de simulada negada por falta de crédito, utilizado para realizar simulação de autorização parcial.", + "acquirer_return_code": "92", + "operation_type": "auth_and_capture", + "card": { + "id": "card_VrxnWlrsOHOpzMj5", + "first_six_digits": "400030", + "last_four_digits": "2220", + "brand": "Visa", + "holder_name": "Longbob Longsen", + "exp_month": 9, + "exp_year": 2019, + "status": "active", + "created_at": "2018-02-01T18:42:44Z", + "updated_at": "2018-02-01T18:42:44Z", + "billing_address": { + "street": "My Street", + "number": "456", + "zip_code": "K1C2N6", + "neighborhood": "Sesame Street", + "city": "Ottawa", + "state": "ON", + "country": "CA", + "line_1": "456, My Street, Sesame Street" + }, + "type": "credit" + }, + "created_at": "2018-02-01T18:42:44Z", + "updated_at": "2018-02-01T18:42:44Z", + "gateway_response": { + "code": "201" + } + } + } + ) + end + + def successful_authorize_response + %( + { + "id": "ch_gm5wrlGMI2Fb0x6K", + "code": "K1J5B1YFLE", + "gateway_id": "3b6c0f72-c4b3-48b2-8eb7-2424321a6c93", + "amount": 100, + "status": "pending", + "currency": "USD", + "payment_method": "credit_card", + "created_at": "2018-02-01T16:43:30Z", + "updated_at": "2018-02-01T16:43:30Z", + "customer": { + "id": "cus_bVWYqeTmpu9VYLd9", + "name": "Longbob Longsen", + "email": "", + "delinquent": false, + "created_at": "2018-02-01T16:43:30Z", + "updated_at": "2018-02-01T16:43:30Z", + "phones": {} + }, + "last_transaction": { + "id": "tran_DWJlEApZI9UL2qR9", + "transaction_type": "credit_card", + "gateway_id": "6dae95a7-6b7f-4431-be33-cb3ecf21287a", + "amount": 100, + "status": "authorized_pending_capture", + "success": true, + "installments": 1, + "acquirer_name": "simulator", + "acquirer_affiliation_code": "", + "acquirer_tid": "25970", + "acquirer_nsu": "506128", + "acquirer_auth_code": "523448", + "acquirer_message": "Simulator|Transação de simulação autorizada com sucesso", + "acquirer_return_code": "0", + "operation_type": "auth_only", + "card": { + "id": "card_J26O3K2hvPc2vOQG", + "first_six_digits": "400010", + "last_four_digits": "2224", + "brand": "Visa", + "holder_name": "Longbob Longsen", + "exp_month": 9, + "exp_year": 2019, + "status": "active", + "created_at": "2018-02-01T16:43:30Z", + "updated_at": "2018-02-01T16:43:30Z", + "billing_address": { + "street": "My Street", + "number": "456", + "zip_code": "K1C2N6", + "neighborhood": "Sesame Street", + "city": "Ottawa", + "state": "ON", + "country": "CA", + "line_1": "456, My Street, Sesame Street" + }, + "type": "credit" + }, + "created_at": "2018-02-01T16:43:31Z", + "updated_at": "2018-02-01T16:43:31Z", + "gateway_response": { + "code": "201" + } + } + } + ) + end + + def failed_authorize_response + %( + { + "id": "ch_O4bW13ukwF5XpmLg", + "code": "2KW1C5VSZO", + "gateway_id": "9bf24ea7-e913-44bc-92ca-50491ffcd7a1", + "amount": 105200, + "status": "failed", + "currency": "USD", + "payment_method": "credit_card", + "created_at": "2018-02-01T18:46:06Z", + "updated_at": "2018-02-01T18:46:06Z", + "customer": { + "id": "cus_7VGAGxqI4OUwZ392", + "name": "Longbob Longsen", + "email": "", + "delinquent": false, + "created_at": "2018-02-01T18:46:06Z", + "updated_at": "2018-02-01T18:46:06Z", + "phones": {} + }, + "last_transaction": { + "id": "tran_g0JYdDXcDesqd36E", + "transaction_type": "credit_card", + "gateway_id": "c0896dd6-0d5c-4e8b-9d92-df5a70e3fb76", + "amount": 105200, + "status": "not_authorized", + "success": false, + "installments": 1, + "acquirer_name": "simulator", + "acquirer_affiliation_code": "", + "acquirer_message": "Simulator|Transação de simulada negada por falta de crédito, utilizado para realizar simulação de autorização parcial.", + "acquirer_return_code": "92", + "operation_type": "auth_only", + "card": { + "id": "card_LR0A1vcVbsmY3wzY", + "first_six_digits": "400030", + "last_four_digits": "2220", + "brand": "Visa", + "holder_name": "Longbob Longsen", + "exp_month": 9, + "exp_year": 2019, + "status": "active", + "created_at": "2018-02-01T18:46:06Z", + "updated_at": "2018-02-01T18:46:06Z", + "billing_address": { + "street": "My Street", + "number": "456", + "zip_code": "K1C2N6", + "neighborhood": "Sesame Street", + "city": "Ottawa", + "state": "ON", + "country": "CA", + "line_1": "456, My Street, Sesame Street" + }, + "type": "credit" + }, + "created_at": "2018-02-01T18:46:06Z", + "updated_at": "2018-02-01T18:46:06Z", + "gateway_response": { + "code": "201" + } + } + } + ) + end + + def successful_capture_response + %( + { + "id": "ch_gm5wrlGMI2Fb0x6K", + "code": "ch_gm5wrlGMI2Fb0x6K", + "gateway_id": "3b6c0f72-c4b3-48b2-8eb7-2424321a6c93", + "amount": 100, + "paid_amount": 100, + "status": "paid", + "currency": "USD", + "payment_method": "credit_card", + "paid_at": "2018-02-01T16:43:33Z", + "created_at": "2018-02-01T16:43:30Z", + "updated_at": "2018-02-01T16:43:33Z", + "customer": { + "id": "cus_bVWYqeTmpu9VYLd9", + "name": "Longbob Longsen", + "email": "", + "delinquent": false, + "created_at": "2018-02-01T16:43:30Z", + "updated_at": "2018-02-01T16:43:30Z", + "phones": {} + }, + "last_transaction": { + "id": "tran_wL9APd6cws19WNJ7", + "transaction_type": "credit_card", + "gateway_id": "6dae95a7-6b7f-4431-be33-cb3ecf21287a", + "amount": 100, + "status": "captured", + "success": true, + "installments": 1, + "acquirer_name": "simulator", + "acquirer_affiliation_code": "", + "acquirer_tid": "299257", + "acquirer_nsu": "894685", + "acquirer_auth_code": "523448", + "acquirer_message": "Simulator|Transação de simulação capturada com sucesso", + "acquirer_return_code": "0", + "operation_type": "capture", + "card": { + "id": "card_J26O3K2hvPc2vOQG", + "first_six_digits": "400010", + "last_four_digits": "2224", + "brand": "Visa", + "holder_name": "Longbob Longsen", + "exp_month": 9, + "exp_year": 2019, + "status": "active", + "created_at": "2018-02-01T16:43:30Z", + "updated_at": "2018-02-01T16:43:30Z", + "billing_address": { + "street": "My Street", + "number": "456", + "zip_code": "K1C2N6", + "neighborhood": "Sesame Street", + "city": "Ottawa", + "state": "ON", + "country": "CA", + "line_1": "456, My Street, Sesame Street" + }, + "type": "credit" + }, + "created_at": "2018-02-01T16:43:33Z", + "updated_at": "2018-02-01T16:43:33Z", + "gateway_response": { + "code": "200" + } + } + } + ) + end + + def failed_capture_response + '{"message": "Charge not found."}' + end + + def successful_refund_response + %( + { + "id": "ch_RbPVPWMH2bcGA50z", + "code": "O5L5A4VCRK", + "gateway_id": "d77c6a32-e1c8-42d4-bd1b-e92b36f054f9", + "amount": 100, + "canceled_amount": 100, + "status": "canceled", + "currency": "USD", + "payment_method": "credit_card", + "canceled_at": "2018-02-01T16:34:07Z", + "created_at": "2018-02-01T16:34:07Z", + "updated_at": "2018-02-01T16:34:07Z", + "customer": { + "id": "cus_odYDGxQirlcp693a", + "name": "Longbob Longsen", + "email": "", + "delinquent": false, + "created_at": "2018-02-01T16:34:07Z", + "updated_at": "2018-02-01T16:34:07Z", + "phones": {} + }, + "last_transaction": { + "id": "tran_m1prZBNTgUmZrGzZ", + "transaction_type": "credit_card", + "gateway_id": "23648dca-07dc-4f31-9b24-26aa702dc7e8", + "amount": 100, + "status": "voided", + "success": true, + "acquirer_name": "simulator", + "acquirer_affiliation_code": "", + "acquirer_tid": "489627", + "acquirer_nsu": "174061", + "acquirer_auth_code": "433589", + "acquirer_return_code": "0", + "operation_type": "cancel", + "card": { + "id": "card_8PaGBMOhXwi9Q24z", + "first_six_digits": "400010", + "last_four_digits": "2224", + "brand": "Visa", + "holder_name": "Longbob Longsen", + "exp_month": 9, + "exp_year": 2019, + "status": "active", + "created_at": "2018-02-01T16:34:07Z", + "updated_at": "2018-02-01T16:34:07Z", + "billing_address": { + "street": "My Street", + "number": "456", + "zip_code": "K1C2N6", + "neighborhood": "Sesame Street", + "city": "Ottawa", + "state": "ON", + "country": "CA", + "line_1": "456, My Street, Sesame Street" + }, + "type": "credit" + }, + "created_at": "2018-02-01T16:34:07Z", + "updated_at": "2018-02-01T16:34:07Z", + "gateway_response": { + "code": "200" + } + } + } + ) + end + + def failed_refund_response + '{"message": "Charge not found."}' + end + + def successful_void_response + %( + { + "id": "ch_RbPVPWMH2bcGA50z", + "code": "O5L5A4VCRK", + "gateway_id": "d77c6a32-e1c8-42d4-bd1b-e92b36f054f9", + "amount": 100, + "canceled_amount": 100, + "status": "canceled", + "currency": "USD", + "payment_method": "credit_card", + "canceled_at": "2018-02-01T16:34:07Z", + "created_at": "2018-02-01T16:34:07Z", + "updated_at": "2018-02-01T16:34:07Z", + "customer": { + "id": "cus_odYDGxQirlcp693a", + "name": "Longbob Longsen", + "email": "", + "delinquent": false, + "created_at": "2018-02-01T16:34:07Z", + "updated_at": "2018-02-01T16:34:07Z", + "phones": {} + }, + "last_transaction": { + "id": "tran_m1prZBNTgUmZrGzZ", + "transaction_type": "credit_card", + "gateway_id": "23648dca-07dc-4f31-9b24-26aa702dc7e8", + "amount": 100, + "status": "voided", + "success": true, + "acquirer_name": "simulator", + "acquirer_affiliation_code": "", + "acquirer_tid": "489627", + "acquirer_nsu": "174061", + "acquirer_auth_code": "433589", + "acquirer_return_code": "0", + "operation_type": "cancel", + "card": { + "id": "card_8PaGBMOhXwi9Q24z", + "first_six_digits": "400010", + "last_four_digits": "2224", + "brand": "Visa", + "holder_name": "Longbob Longsen", + "exp_month": 9, + "exp_year": 2019, + "status": "active", + "created_at": "2018-02-01T16:34:07Z", + "updated_at": "2018-02-01T16:34:07Z", + "billing_address": { + "street": "My Street", + "number": "456", + "zip_code": "K1C2N6", + "neighborhood": "Sesame Street", + "city": "Ottawa", + "state": "ON", + "country": "CA", + "line_1": "456, My Street, Sesame Street" + }, + "type": "credit" + }, + "created_at": "2018-02-01T16:34:07Z", + "updated_at": "2018-02-01T16:34:07Z", + "gateway_response": { + "code": "200" + } + } + } + ) + end + + def failed_void_response + '{"message": "Charge not found."}' + end + + def successful_verify_response + %( + { + "id": "ch_G9rB74PI3uoDMxAo", + "code": "8EXXFEBQDK", + "gateway_id": "4b228be6-6795-416a-9238-204020e7fdd1", + "amount": 100, + "canceled_amount": 100, + "status": "canceled", + "currency": "USD", + "payment_method": "credit_card", + "canceled_at": "2018-02-02T14:25:25Z", + "created_at": "2018-02-02T14:25:24Z", + "updated_at": "2018-02-02T14:25:25Z", + "customer": { + "id": "cus_V2GXxeOunSYpEvOD", + "name": "Longbob Longsen", + "email": "", + "delinquent": false, + "created_at": "2018-02-02T14:25:24Z", + "updated_at": "2018-02-02T14:25:24Z", + "phones": {} + }, + "last_transaction": { + "id": "tran_r50yVePSJbuA3dKb", + "transaction_type": "credit_card", + "gateway_id": "2d1c155a-e89d-4972-9ee1-a3b3f56d6ff8", + "amount": 100, + "status": "voided", + "success": true, + "acquirer_name": "simulator", + "acquirer_affiliation_code": "", + "acquirer_tid": "711106", + "acquirer_nsu": "553868", + "acquirer_auth_code": "271719", + "acquirer_return_code": "0", + "operation_type": "cancel", + "card": { + "id": "card_7WraOEps6FpRLQob", + "first_six_digits": "400010", + "last_four_digits": "2224", + "brand": "Visa", + "holder_name": "Longbob Longsen", + "exp_month": 9, + "exp_year": 2019, + "status": "active", + "created_at": "2018-02-02T14:25:24Z", + "updated_at": "2018-02-02T14:25:24Z", + "billing_address": { + "street": "My Street", + "number": "456", + "zip_code": "K1C2N6", + "neighborhood": "Sesame Street", + "city": "Ottawa", + "state": "ON", + "country": "CA", + "line_1": "456, My Street, Sesame Street" + }, + "type": "credit" + }, + "created_at": "2018-02-02T14:25:25Z", + "updated_at": "2018-02-02T14:25:25Z", + "gateway_response": { + "code": "200" + } + } + } + ) + end + + def successful_create_customer_response + %( + { + "id": "cus_NRL1bw3HpAHLbWPQ", + "name": "Sideshow Bob", + "email": "", + "delinquent": false, + "created_at": "2018-02-05T15:03:39Z", + "updated_at": "2018-02-05T15:03:39Z", + "phones": {} + } + ) + end + + def successful_store_response + %( + { + "id": "card_51ElNwYSVJFpRe0g", + "first_six_digits": "400010", + "last_four_digits": "2224", + "brand": "Visa", + "holder_name": "Longbob Longsen", + "exp_month": 9, + "exp_year": 2019, + "status": "active", + "created_at": "2018-02-05T15:45:01Z", + "updated_at": "2018-02-05T15:45:01Z", + "billing_address": { + "street": "My Street", + "number": "456", + "zip_code": "K1C2N6", + "neighborhood": "Sesame Street", + "city": "Ottawa", + "state": "ON", + "country": "CA", + "line_1": "456, My Street, Sesame Street" + }, + "customer": { + "id": "cus_N70xAX6S65cMnokB", + "name": "Bob Belcher", + "email": "", + "delinquent": false, + "created_at": "2018-02-05T15:45:01Z", + "updated_at": "2018-02-05T15:45:01Z", + "phones": {} + }, + "type": "credit" + } + ) + end +end From ee4c050d048a3a684c3f8eca34761dc6d3fa7aa5 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Fri, 30 Mar 2018 15:17:14 -0400 Subject: [PATCH 361/677] Adyen: Support merchant-specific subdomains Adds merchant-level subdomain specification via gateway-level option. Adyen's sandbox doesn't support testing of these subdomains, so the only way I found to test the functionality was by subverting the check for a test url in the adapter itself, and checking the request in a unit test, hence the 1 unit failure. Closes #2799 Remote: 32 tests, 81 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 19 tests, 89 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 94.7368% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 12 ++++++++++-- test/unit/gateways/adyen_test.rb | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e041a99f7b1..591f196eae3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * Spreedly: Support verify and find transactions [abarrak] #2798 +* Adyen: Support merchant-specific subdomains [curiousepic] #2799 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index e6a60ee63fd..744b68e9da0 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -202,8 +202,6 @@ def parse(body) end def commit(action, parameters) - url = (test? ? test_url : live_url) - begin raw_response = ssl_post("#{url}/#{action.to_s}", post_data(action, parameters), request_headers) response = parse(raw_response) @@ -224,6 +222,16 @@ def commit(action, parameters) end + def url + if test? + test_url + elsif @options[:subdomain] + "https://#{@options[:subdomain]}-pal-live.adyenpayments.com/pal/servlet/Payment/v18" + else + live_url + end + end + def basic_auth Base64.strict_encode64("#{@username}:#{@password}") end diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index 1411a477460..3fcf38c3fbe 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -28,6 +28,25 @@ def setup } end + # Subdomains are only valid for production gateways, so the test_url check must be manually bypassed for this test to pass. + # def test_subdomain_specification + # gateway = AdyenGateway.new( + # username: 'ws@adyenmerchant.com', + # password: 'password', + # merchant_account: 'merchantAccount', + # subdomain: '123-subdomain' + # ) + # + # response = stub_comms(gateway) do + # gateway.authorize(@amount, @credit_card, @options) + # end.check_request do |endpoint, data, headers| + # assert_match("https://123-subdomain-pal-live.adyenpayments.com/pal/servlet/Payment/v18/authorise", endpoint) + # end.respond_with(successful_authorize_response) + # + # assert response + # assert_success response + # end + def test_successful_authorize @gateway.expects(:ssl_post).returns(successful_authorize_response) From d5ca3fb61eb82bfb2c18ca6fd564513fe5627cc3 Mon Sep 17 00:00:00 2001 From: Brian Bergstrom <boilingbergstrom@gmail.com> Date: Wed, 4 Apr 2018 10:12:11 -0500 Subject: [PATCH 362/677] Fix ENV based configuration of Net::Http for proxies (#2800) Pass :ENV as default proxy address to Net::HTTP to retain normal behavior with http_proxy environment configuration. --- CHANGELOG | 1 + lib/active_merchant/connection.rb | 2 +- test/unit/connection_test.rb | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 591f196eae3..1d298b4acd4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * Spreedly: Support verify and find transactions [abarrak] #2798 * Adyen: Support merchant-specific subdomains [curiousepic] #2799 +* Fix ENV based configuration of Net::Http for proxies [bbergstrom] #2800 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index 6be20a588ea..3feaa0b7286 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -44,7 +44,7 @@ def initialize(endpoint) @max_retries = MAX_RETRIES @ignore_http_status = false @ssl_version = nil - @proxy_address = nil + @proxy_address = :ENV @proxy_port = nil end diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index 59c3d98a062..52379f9606f 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -26,6 +26,22 @@ def test_connection_endpoint_raises_uri_error end end + def test_connection_passes_env_proxy_by_default + spy = Net::HTTP.new('example.com', 443) + Net::HTTP.expects(:new).with('example.com', 443, :ENV, nil).returns(spy) + spy.expects(:get).with('/tx.php', {}).returns(@ok) + @connection.request(:get, nil, {}) + end + + def test_connection_does_pass_requested_proxy + @connection.proxy_address = "proxy.example.com" + @connection.proxy_port = 8080 + spy = Net::HTTP.new('example.com', 443) + Net::HTTP.expects(:new).with('example.com', 443, "proxy.example.com", 8080).returns(spy) + spy.expects(:get).with('/tx.php', {}).returns(@ok) + @connection.request(:get, nil, {}) + end + def test_successful_get_request @connection.logger.expects(:info).twice Net::HTTP.any_instance.expects(:get).with('/tx.php', {}).returns(@ok) From 4ab3eb852e1ba0a3f18e308b0ce54aac22b08ded Mon Sep 17 00:00:00 2001 From: Bart <bartdewater@gmail.com> Date: Thu, 5 Apr 2018 14:14:23 -0400 Subject: [PATCH 363/677] Update travis for Rails 5.2, Ruby 2.5 (#2788) * Drop support for Rails < 4.2 Rails 4.2 is still maintained for 'severe securtity issues' per http://guides.rubyonrails.org/maintenance_policy.html#security-issues * Add Rails 5.2 to the test matrix * Add Ruby 2.5 to CI and fix tests The OpenSSL require was needed to fix the lookup of the OpenSSL constant in NetworkConnectionRetries SkipJack: tildes are not escaped by https://github.com/ruby/ruby/commit/e1b432754553423008a14d39d0901eabc99e7ddb --- .travis.yml | 28 ++++++------------- CHANGELOG | 1 + Gemfile.rails40 | 11 -------- Gemfile.rails41 | 11 -------- Gemfile.rails32 => Gemfile.rails52 | 2 +- activemerchant.gemspec | 2 +- lib/active_merchant.rb | 6 +--- .../billing/gateways/clearhaus.rb | 2 -- lib/active_merchant/billing/gateways/migs.rb | 2 -- test/unit/gateways/migs_test.rb | 1 - test/unit/gateways/skip_jack_test.rb | 4 ++- 11 files changed, 16 insertions(+), 54 deletions(-) delete mode 100644 Gemfile.rails40 delete mode 100644 Gemfile.rails41 rename Gemfile.rails32 => Gemfile.rails52 (85%) diff --git a/.travis.yml b/.travis.yml index 94450c38b5e..22a294031eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,31 +4,21 @@ sudo: false cache: bundler rvm: -- 2.1 -- 2.2.7 -- 2.3.4 -- 2.4.1 +- 2.5 +- 2.4 +- 2.3 +- 2.2 gemfile: -- Gemfile.rails32 -- Gemfile.rails40 -- Gemfile.rails41 -- Gemfile.rails42 -- Gemfile.rails50 +- Gemfile.rails52 - Gemfile.rails51 +- Gemfile.rails50 +- Gemfile.rails42 matrix: - exclude: - - rvm: 2.1 - gemfile: Gemfile.rails50 + include: - rvm: 2.1 - gemfile: Gemfile.rails51 - - rvm: 2.4.1 - gemfile: Gemfile.rails32 - - rvm: 2.4.1 - gemfile: Gemfile.rails40 - - rvm: 2.4.1 - gemfile: Gemfile.rails41 + gemfile: Gemfile.rails42 notifications: email: diff --git a/CHANGELOG b/CHANGELOG index 1d298b4acd4..89191a9bcb8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Remove support for Rails < 4.2, add support for Rails 5.2 and Ruby 2.5 [bdewater] * Spreedly: Support verify and find transactions [abarrak] #2798 * Adyen: Support merchant-specific subdomains [curiousepic] #2799 * Fix ENV based configuration of Net::Http for proxies [bbergstrom] #2800 diff --git a/Gemfile.rails40 b/Gemfile.rails40 deleted file mode 100644 index 6842a77d1ff..00000000000 --- a/Gemfile.rails40 +++ /dev/null @@ -1,11 +0,0 @@ -source 'https://rubygems.org' -gemspec - -gem 'jruby-openssl', :platforms => :jruby - -group :test, :remote_test do - # gateway-specific dependencies, keeping these gems out of the gemspec - gem 'braintree', '>= 2.50.0' -end - -gem 'activesupport', '~> 4.0.0' diff --git a/Gemfile.rails41 b/Gemfile.rails41 deleted file mode 100644 index 150a0bfe06b..00000000000 --- a/Gemfile.rails41 +++ /dev/null @@ -1,11 +0,0 @@ -source 'https://rubygems.org' -gemspec - -gem 'jruby-openssl', :platforms => :jruby - -group :test, :remote_test do - # gateway-specific dependencies, keeping these gems out of the gemspec - gem 'braintree', '>= 2.50.0' -end - -gem 'activesupport', '~> 4.1.0' diff --git a/Gemfile.rails32 b/Gemfile.rails52 similarity index 85% rename from Gemfile.rails32 rename to Gemfile.rails52 index 188439ed3d5..aa056d4cad8 100644 --- a/Gemfile.rails32 +++ b/Gemfile.rails52 @@ -8,4 +8,4 @@ group :test, :remote_test do gem 'braintree', '>= 2.50.0' end -gem 'activesupport', '~> 3.2.0' +gem 'activesupport', '~> 5.2.0.rc1' diff --git a/activemerchant.gemspec b/activemerchant.gemspec index 23f420287b3..b273850c216 100644 --- a/activemerchant.gemspec +++ b/activemerchant.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.has_rdoc = true if Gem::VERSION < '1.7.0' - s.add_dependency('activesupport', '>= 3.2.14', '< 6.x') + s.add_dependency('activesupport', '>= 4.2', '< 6.x') s.add_dependency('i18n', '>= 0.6.9') s.add_dependency('builder', '>= 2.1.2', '< 4.0.0') s.add_dependency('nokogiri', "~> 1.4") diff --git a/lib/active_merchant.rb b/lib/active_merchant.rb index 66de1834685..b19a4725b37 100644 --- a/lib/active_merchant.rb +++ b/lib/active_merchant.rb @@ -28,11 +28,6 @@ require 'active_support/core_ext/object/conversions' require 'active_support/core_ext/class/attribute' require 'active_support/core_ext/enumerable' - -if(!defined?(ActiveSupport::VERSION) || (ActiveSupport::VERSION::STRING < "4.1")) - require 'active_support/core_ext/class/attribute_accessors' -end - require 'active_support/core_ext/module/attribute_accessors' require 'base64' @@ -42,6 +37,7 @@ require 'rexml/document' require 'timeout' require 'socket' +require 'openssl' require 'active_merchant/network_connection_retries' require 'active_merchant/connection' diff --git a/lib/active_merchant/billing/gateways/clearhaus.rb b/lib/active_merchant/billing/gateways/clearhaus.rb index ae11cbbdc6b..93ee3c041fa 100644 --- a/lib/active_merchant/billing/gateways/clearhaus.rb +++ b/lib/active_merchant/billing/gateways/clearhaus.rb @@ -1,5 +1,3 @@ -require 'openssl' - module ActiveMerchant #:nodoc: module Billing #:nodoc: class ClearhausGateway < Gateway diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb index 9a9a938fc90..7995805e1a5 100644 --- a/lib/active_merchant/billing/gateways/migs.rb +++ b/lib/active_merchant/billing/gateways/migs.rb @@ -1,7 +1,5 @@ require 'active_merchant/billing/gateways/migs/migs_codes' -require 'openssl' # Used in add_secure_hash - module ActiveMerchant #:nodoc: module Billing #:nodoc: class MigsGateway < Gateway diff --git a/test/unit/gateways/migs_test.rb b/test/unit/gateways/migs_test.rb index 869e1657a5d..f34b624c01c 100644 --- a/test/unit/gateways/migs_test.rb +++ b/test/unit/gateways/migs_test.rb @@ -1,5 +1,4 @@ require 'test_helper' -require 'openssl' class MigsTest < Test::Unit::TestCase def setup diff --git a/test/unit/gateways/skip_jack_test.rb b/test/unit/gateways/skip_jack_test.rb index 273508220ee..a79cf6eda5d 100644 --- a/test/unit/gateways/skip_jack_test.rb +++ b/test/unit/gateways/skip_jack_test.rb @@ -195,7 +195,9 @@ def test_paymentech_authorization_failure def test_serial_number_is_added_before_developer_serial_number_for_authorization - @gateway.expects(:ssl_post).with('https://developer.skipjackic.com/scripts/evolvcc.dll?AuthorizeAPI', "Year=#{Time.now.year + 1}&TransactionAmount=1.00&ShipToPhone=&SerialNumber=X&SJName=Longbob+Longsen&OrderString=1%7ENone%7E0.00%7E0%7EN%7E%7C%7C&OrderNumber=1&OrderDescription=&Month=9&InvoiceNumber=&Email=cody%40example.com&DeveloperSerialNumber=Y&CustomerCode=&CVV2=123&AccountNumber=4242424242424242").returns(successful_authorization_response) + expected ="Year=#{Time.now.year + 1}&TransactionAmount=1.00&ShipToPhone=&SerialNumber=X&SJName=Longbob+Longsen&OrderString=1~None~0.00~0~N~%7C%7C&OrderNumber=1&OrderDescription=&Month=9&InvoiceNumber=&Email=cody%40example.com&DeveloperSerialNumber=Y&CustomerCode=&CVV2=123&AccountNumber=4242424242424242" + expected = expected.gsub('~', '%7E') if RUBY_VERSION < '2.5.0' + @gateway.expects(:ssl_post).with('https://developer.skipjackic.com/scripts/evolvcc.dll?AuthorizeAPI', expected).returns(successful_authorization_response) @gateway.authorize(@amount, @credit_card, @options) end From c76e0d178a0bdf1df9a98b7210ac801de24c6ad1 Mon Sep 17 00:00:00 2001 From: Bart <bartdewater@gmail.com> Date: Fri, 6 Apr 2018 11:11:59 -0400 Subject: [PATCH 364/677] Fix Travis build for Ruby 2.5 https://github.com/travis-ci/travis-ci/issues/8978#issuecomment-354036443 --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 22a294031eb..3454346d6e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,10 @@ language: ruby script: "bundle exec rake test:units" sudo: false cache: bundler +before_install: + # https://github.com/travis-ci/travis-ci/issues/8978#issuecomment-354036443 + - gem update --system + - gem install bundler rvm: - 2.5 From b2423daee0b7d502d447f169204fd5b7bd57f2bf Mon Sep 17 00:00:00 2001 From: Bart de Water <bartdewater@gmail.com> Date: Fri, 6 Apr 2018 12:24:53 -0400 Subject: [PATCH 365/677] "ubygems" has been removed from Ruby 2.5 thus requiring it with the `-r` flag doesn't work --- Rakefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Rakefile b/Rakefile index 4852f416101..0fd21391e64 100644 --- a/Rakefile +++ b/Rakefile @@ -28,14 +28,12 @@ task :test => 'test:units' namespace :test do Rake::TestTask.new(:units) do |t| t.pattern = 'test/unit/**/*_test.rb' - t.ruby_opts << '-rubygems -w' t.libs << 'test' t.verbose = true end Rake::TestTask.new(:remote) do |t| t.pattern = 'test/remote/**/*_test.rb' - t.ruby_opts << '-rubygems -w' t.libs << 'test' t.verbose = true end From 168b46d6b33aec015ace784e492ed62b58585ca9 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 10 Apr 2018 15:30:16 -0400 Subject: [PATCH 366/677] ANET: Withhold cryptogram for credit Credits were failing for network tokenization credit cards, apparrently due to the cryptogram being present. This withholds the cryptogram from such credits. Closes #2804 Remote: 65 tests, 221 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 90 tests, 511 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/authorize_net.rb | 10 +++---- .../gateways/remote_authorize_net_test.rb | 28 +++++++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 89191a9bcb8..17141659dd7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Spreedly: Support verify and find transactions [abarrak] #2798 * Adyen: Support merchant-specific subdomains [curiousepic] #2799 * Fix ENV based configuration of Net::Http for proxies [bbergstrom] #2800 +* ANET: Withhold cryptogram for credit [curiousepic] #2804 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index cd5e8b69453..3cc43832175 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -167,7 +167,7 @@ def credit(amount, payment, options={}) xml.transactionType('refundTransaction') xml.amount(amount(amount)) - add_payment_source(xml, payment) + add_payment_source(xml, payment, :credit) xml.refTransId(transaction_id_from(options[:transaction_id])) if options[:transaction_id] add_invoice(xml, 'refundTransaction', options) add_customer_data(xml, payment, options) @@ -375,7 +375,7 @@ def normal_void(authorization, options) end end - def add_payment_source(xml, source) + def add_payment_source(xml, source, action = nil) return unless source if source.is_a?(String) add_token_payment_method(xml, source) @@ -384,7 +384,7 @@ def add_payment_source(xml, source) elsif card_brand(source) == 'apple_pay' add_apple_pay_payment_token(xml, source) else - add_credit_card(xml, source) + add_credit_card(xml, source, action) end end @@ -457,7 +457,7 @@ def add_user_fields(xml, amount, options) end end - def add_credit_card(xml, credit_card) + def add_credit_card(xml, credit_card, action) if credit_card.track_data add_swipe_data(xml, credit_card) else @@ -468,7 +468,7 @@ def add_credit_card(xml, credit_card) if credit_card.valid_card_verification_value?(credit_card.verification_value, credit_card.brand) xml.cardCode(credit_card.verification_value) end - if credit_card.is_a?(NetworkTokenizationCreditCard) + if credit_card.is_a?(NetworkTokenizationCreditCard) && action != :credit xml.cryptogram(credit_card.payment_cryptogram) end end diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb index ed443256b70..eb396551373 100644 --- a/test/remote/gateways/remote_authorize_net_test.rb +++ b/test/remote/gateways/remote_authorize_net_test.rb @@ -616,6 +616,34 @@ def test_successful_authorize_and_capture_with_network_tokenization assert_success capture end + def test_successful_refund_with_network_tokenization + credit_card = network_tokenization_credit_card('4000100011112224', + payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + verification_value: nil + ) + + purchase = @gateway.purchase(@amount, credit_card, @options) + assert_success purchase + + @options[:billing_address] = nil + + refund = @gateway.refund(@amount, purchase.authorization, @options.merge(first_name: 'Jim', last_name: 'Smith')) + assert_failure refund + assert_match %r{does not meet the criteria for issuing a credit}, refund.message, "Only allowed to refund transactions that have settled. This is the best we can do for now testing wise." + end + + def test_successful_credit_with_network_tokenization + credit_card = network_tokenization_credit_card('4000100011112224', + payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + verification_value: nil + ) + + response = @gateway.credit(@amount, credit_card, @options) + assert_success response + assert_equal 'This transaction has been approved', response.message + assert response.authorization + end + def test_network_tokenization_transcript_scrubbing credit_card = network_tokenization_credit_card('4111111111111111', :brand => 'visa', From e83f531ea882695e6b06e688dd9780880aae1c1b Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder <deedeelavinder@gmail.com> Date: Wed, 11 Apr 2018 13:38:26 -0400 Subject: [PATCH 367/677] Borgun: Remove batch from request parameters Batch is part of Borgun's response but is not needed for the request. This removes it from the `add_reference` method adding it to the request but maintains its place in the response. Closes #2805 Unit tests: 8 tests, 37 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote tests: 20 tests, 47 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/borgun.rb | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 17141659dd7..d3604f5142c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * Adyen: Support merchant-specific subdomains [curiousepic] #2799 * Fix ENV based configuration of Net::Http for proxies [bbergstrom] #2800 * ANET: Withhold cryptogram for credit [curiousepic] #2804 +* Borgun: Remove batch from request parameters [deedeelavinder] #2805 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb index a1e23d4c3f9..f3892b9f4f8 100644 --- a/lib/active_merchant/billing/gateways/borgun.rb +++ b/lib/active_merchant/billing/gateways/borgun.rb @@ -98,7 +98,6 @@ def add_payment_method(post, payment_method) def add_reference(post, authorization) dateandtime, batch, transaction, rrn, authcode, _, _, _ = split_authorization(authorization) post[:DateAndTime] = dateandtime - post[:Batch] = batch post[:Transaction] = transaction post[:RRN] = rrn post[:AuthCode] = authcode From 215024fe1ade930323d5658db6d840e43bf0d5ec Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Thu, 5 Apr 2018 15:43:14 -0400 Subject: [PATCH 368/677] Remove Inquiry requests in verify transactions Inquiries need at least 5 minutes after initial transaction in order to be reliable. This removes inquiries from verify requests. Errors are also caused by timeouts. Successful tests can be achieved by adding a sleep, but doesn not produce consistent results. Loaded suite test/unit/gateways/worldpay_test ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 37 tests, 210 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Loaded suite test/remote/gateways/remote_worldpay_test Finished in 231.664812 seconds. --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 23 tests, 71 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 78.2609% passed --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/worldpay.rb | 4 ++-- test/remote/gateways/remote_worldpay_test.rb | 6 ++++++ test/unit/gateways/worldpay_test.rb | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d3604f5142c..07cb149c765 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * Fix ENV based configuration of Net::Http for proxies [bbergstrom] #2800 * ANET: Withhold cryptogram for credit [curiousepic] #2804 * Borgun: Remove batch from request parameters [deedeelavinder] #2805 +* WorldPay: Remove Inquiry requests in verify transactions == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index bf0fbd8f61d..e6e608d94f3 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -55,7 +55,7 @@ def capture(money, authorization, options = {}) def void(authorization, options = {}) MultiResponse.run do |r| - r.process{inquire_request(authorization, options, "AUTHORISED")} + r.process{inquire_request(authorization, options, "AUTHORISED")} unless options[:authorization_validated] r.process{cancel_request(authorization, options)} end end @@ -83,7 +83,7 @@ def credit(money, payment_method, options = {}) def verify(credit_card, options={}) MultiResponse.run(:use_first_response) do |r| r.process { authorize(100, credit_card, options) } - r.process(:ignore_result) { void(r.authorization, options) } + r.process(:ignore_result) { void(r.authorization, options.merge(:authorization_validated => true)) } end end diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index d4473dbe40d..9c40d7d6609 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -43,6 +43,7 @@ def test_authorize_and_capture assert_success auth assert_equal 'SUCCESS', auth.message assert auth.authorization + sleep(40) assert capture = @gateway.capture(@amount, auth.authorization) assert_success capture end @@ -51,12 +52,14 @@ def test_authorize_and_capture_by_reference assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth assert_equal 'SUCCESS', auth.message + sleep(40) assert capture = @gateway.capture(@amount, auth.authorization) assert_success capture assert reference = auth.authorization @options[:order_id] = generate_unique_id assert auth = @gateway.authorize(@amount, reference, @options) + sleep(40) assert capture = @gateway.capture(@amount, auth.authorization) assert_success capture end @@ -65,6 +68,7 @@ def test_authorize_and_purchase_by_reference assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth assert_equal 'SUCCESS', auth.message + sleep(40) assert capture = @gateway.capture(@amount, auth.authorization) assert_success capture @@ -72,6 +76,7 @@ def test_authorize_and_purchase_by_reference @options[:order_id] = generate_unique_id assert auth = @gateway.authorize(@amount, reference, @options) @options[:order_id] = generate_unique_id + sleep(40) assert capture = @gateway.purchase(@amount, auth.authorization, @options) assert_success capture end @@ -100,6 +105,7 @@ def test_ip_address def test_void assert_success(response = @gateway.authorize(@amount, @credit_card, @options)) + sleep(40) assert_success (void = @gateway.void(response.authorization)) assert_equal "SUCCESS", void.message assert void.params["cancel_received_order_code"] diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index 560aebba69b..35d18b69a5e 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -442,7 +442,7 @@ def assert_tag_with_attributes(tag, attributes, string) end def test_successful_verify - @gateway.expects(:ssl_post).times(3).returns(successful_authorize_response, successful_void_response) + @gateway.expects(:ssl_post).times(2).returns(successful_authorize_response, successful_void_response) response = @gateway.verify(@credit_card, @options) assert_success response From c4800fe20fdc10c4a3b29d2d50ab44451fa24db7 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Thu, 12 Apr 2018 15:25:39 -0400 Subject: [PATCH 369/677] Update Changelog Adds author and PR to changelog entry --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 07cb149c765..ef906a2ca9b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,7 +7,7 @@ * Fix ENV based configuration of Net::Http for proxies [bbergstrom] #2800 * ANET: Withhold cryptogram for credit [curiousepic] #2804 * Borgun: Remove batch from request parameters [deedeelavinder] #2805 -* WorldPay: Remove Inquiry requests in verify transactions +* WorldPay: Remove Inquiry requests in verify transactions [nfarve] #2802 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 From e78391fa96b02ed02beb65a4b0a91bd30482a0c7 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Mon, 16 Apr 2018 14:54:11 -0400 Subject: [PATCH 370/677] Credorax: Update tests Closes #2809 Remote: 19 tests, 54 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 18 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + test/remote/gateways/remote_credorax_test.rb | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ef906a2ca9b..91618564c57 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * ANET: Withhold cryptogram for credit [curiousepic] #2804 * Borgun: Remove batch from request parameters [deedeelavinder] #2805 * WorldPay: Remove Inquiry requests in verify transactions [nfarve] #2802 +* Credorax: Update tests [curiousepic] #2809 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/test/remote/gateways/remote_credorax_test.rb b/test/remote/gateways/remote_credorax_test.rb index d33de554502..02937b313ac 100644 --- a/test/remote/gateways/remote_credorax_test.rb +++ b/test/remote/gateways/remote_credorax_test.rb @@ -5,8 +5,8 @@ def setup @gateway = CredoraxGateway.new(fixtures(:credorax)) @amount = 100 - @credit_card = credit_card('4176661000001015', verification_value: "281", month: "12", year: "2017") - @declined_card = credit_card('4176661000001015', verification_value: "000", month: "12", year: "2017") + @credit_card = credit_card('4176661000001015', verification_value: "281", month: "12", year: "2022") + @declined_card = credit_card('4176661000001111', verification_value: "681", month: "12", year: "2022") @options = { order_id: "1", currency: "EUR", @@ -29,7 +29,7 @@ def test_successful_purchase end def test_successful_purchase_with_extra_options - response = @gateway.purchase(@amount, @credit_card, @options.merge(transaction_type: '8')) + response = @gateway.purchase(@amount, @credit_card, @options.merge(transaction_type: '10')) assert_success response assert_equal "1", response.params["H9"] assert_equal "Succeeded", response.message @@ -38,7 +38,7 @@ def test_successful_purchase_with_extra_options def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "Do not Honour", response.message + assert_equal "Transaction not allowed for cardholder", response.message end def test_successful_authorize_and_capture @@ -55,7 +55,7 @@ def test_successful_authorize_and_capture def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal "Do not Honour", response.message + assert_equal "Transaction not allowed for cardholder", response.message end def test_failed_capture @@ -103,7 +103,7 @@ def test_successful_capture_and_void def test_failed_void response = @gateway.void("") assert_failure response - assert_equal "Internal server error. Please contact Credorax support.", response.message + assert_equal "Referred to transaction has not been found.", response.message end def test_successful_refund @@ -131,7 +131,7 @@ def test_successful_refund_and_void def test_failed_refund response = @gateway.refund(nil, "123;123;123") assert_failure response - assert_equal "Internal server error. Please contact Credorax support.", response.message + assert_equal "Referred to transaction has not been found.", response.message end def test_successful_credit @@ -155,7 +155,7 @@ def test_successful_verify def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "Do not Honour", response.message + assert_equal "Transaction not allowed for cardholder", response.message end def test_transcript_scrubbing From d14d31b5c42cd2ccd28457bc7aeea9e1b03048eb Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Wed, 11 Apr 2018 11:50:36 -0400 Subject: [PATCH 371/677] Braintree: Remove decimal for non-fractional currencies Adds list of non-fractional currencies and ulitizes them when adding the amount field to transactions. Loaded suite test/remote/gateways/remote_braintree_blue_test ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 60 tests, 349 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Loaded suite test/unit/gateways/braintree_blue_test 48 tests, 121 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Loaded suite test/unit/gateways/braintree_orange_test 17 tests, 65 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Loaded suite test/remote/gateways/remote_braintree_orange_test 20 tests, 88 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- CHANGELOG | 1 + .../billing/gateways/braintree/braintree_common.rb | 1 + lib/active_merchant/billing/gateways/braintree_blue.rb | 8 ++++---- lib/active_merchant/billing/gateways/smart_ps.rb | 2 +- test/unit/gateways/braintree_orange_test.rb | 10 ++++++++++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 91618564c57..b2e74f42200 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * Borgun: Remove batch from request parameters [deedeelavinder] #2805 * WorldPay: Remove Inquiry requests in verify transactions [nfarve] #2802 * Credorax: Update tests [curiousepic] #2809 +* Braintree: Remove decimal for non-fractional currencies [nfarve] #2806 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/braintree/braintree_common.rb b/lib/active_merchant/billing/gateways/braintree/braintree_common.rb index af47eae5a36..1d4fc3dec9b 100644 --- a/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +++ b/lib/active_merchant/billing/gateways/braintree/braintree_common.rb @@ -5,6 +5,7 @@ def self.included(base) base.homepage_url = 'http://www.braintreepaymentsolutions.com' base.display_name = 'Braintree' base.default_currency = 'USD' + base.currencies_without_fractions = %w(BIF CLP DJF GNF JPY KMF KRW LAK PYG RWF UGX VND VUV XAF XOF XPF) end def supports_scrubbing diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 68a46fa19cd..babef713b7f 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -78,7 +78,7 @@ def authorize(money, credit_card_or_vault_id, options = {}) def capture(money, authorization, options = {}) commit do - result = @braintree_gateway.transaction.submit_for_settlement(authorization, amount(money).to_s) + result = @braintree_gateway.transaction.submit_for_settlement(authorization, localized_amount(money, options[:currency] || default_currency).to_s) response_from_result(result) end end @@ -95,7 +95,7 @@ def refund(*args) # legacy signature: #refund(transaction_id, options = {}) # new signature: #refund(money, transaction_id, options = {}) money, transaction_id, options = extract_refund_args(args) - money = amount(money).to_s if money + money = localized_amount(money, options[:currency] || default_currency).to_s if money commit do response = response_from_result(@braintree_gateway.transaction.refund(transaction_id, money)) @@ -530,6 +530,7 @@ def transaction_hash(result) { "order_id" => transaction.order_id, + "amount" => transaction.amount.to_s, "status" => transaction.status, "credit_card_details" => credit_card_details, "customer_details" => customer_details, @@ -543,7 +544,7 @@ def transaction_hash(result) def create_transaction_parameters(money, credit_card_or_vault_id, options) parameters = { - :amount => amount(money).to_s, + :amount => localized_amount(money, options[:currency] || default_currency).to_s, :order_id => options[:order_id], :customer => { :id => options[:store] == true ? "" : options[:store], @@ -557,7 +558,6 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) :hold_in_escrow => options[:hold_in_escrow] } } - parameters[:custom_fields] = options[:custom_fields] parameters[:device_data] = options[:device_data] if options[:device_data] parameters[:service_fee_amount] = options[:service_fee_amount] if options[:service_fee_amount] diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb index 5c03505e725..64b59c3f6fe 100644 --- a/lib/active_merchant/billing/gateways/smart_ps.rb +++ b/lib/active_merchant/billing/gateways/smart_ps.rb @@ -229,7 +229,7 @@ def parse(body) end def commit(action, money, parameters) - parameters[:amount] = amount(money) if money + parameters[:amount] = localized_amount(money, parameters[:currency] || default_currency) if money response = parse( ssl_post(self.live_url, post_data(action,parameters)) ) Response.new(response["response"] == "1", message_from(response), response, :authorization => (response["transactionid"] || response["customer_vault_id"]), diff --git a/test/unit/gateways/braintree_orange_test.rb b/test/unit/gateways/braintree_orange_test.rb index 6607ad45d0a..6ed0d3481e5 100644 --- a/test/unit/gateways/braintree_orange_test.rb +++ b/test/unit/gateways/braintree_orange_test.rb @@ -24,6 +24,16 @@ def test_successful_purchase assert_equal '510695343', response.authorization end + def test_fractional_amounts + response = stub_comms do + @gateway.purchase(100, @credit_card, @options.merge(currency: 'JPY')) + end.check_request do |endpoint, data, headers| + refute_match(/amount=1.00/, data) + end.respond_with(successful_purchase_response) + + assert_success response + end + def test_successful_store @gateway.expects(:ssl_post).returns(successful_store_response) From d5f4b8fa8599899c22c3314f0f4d8d354e5018ad Mon Sep 17 00:00:00 2001 From: Bart de Water <bartdewater@gmail.com> Date: Mon, 5 Mar 2018 17:19:28 -0500 Subject: [PATCH 372/677] Allow setting min/max SSL version for a connection on Ruby 2.5 The configuration on the Net::HTTP object is passed through to OpenSSL::SSLContext --- CHANGELOG | 1 + lib/active_merchant/connection.rb | 12 ++++++++++++ .../network_connection_retries.rb | 2 ++ lib/active_merchant/posts_data.rb | 10 ++++++++++ test/unit/connection_test.rb | 16 ++++++++++++++++ 5 files changed, 41 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index b2e74f42200..9f43f3adc99 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Allow setting min/max SSL version for a connection on Ruby 2.5 [bdewater] #2775 * Remove support for Rails < 4.2, add support for Rails 5.2 and Ruby 2.5 [bdewater] * Spreedly: Support verify and find transactions [abarrak] #2798 * Adyen: Support merchant-specific subdomains [curiousepic] #2799 diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index 3feaa0b7286..6db1df3b29f 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -21,6 +21,10 @@ class Connection attr_accessor :read_timeout attr_accessor :verify_peer attr_accessor :ssl_version + if Net::HTTP.instance_methods.include?(:min_version=) + attr_accessor :min_version + attr_accessor :max_version + end attr_accessor :ca_file attr_accessor :ca_path attr_accessor :pem @@ -44,6 +48,10 @@ def initialize(endpoint) @max_retries = MAX_RETRIES @ignore_http_status = false @ssl_version = nil + if Net::HTTP.instance_methods.include?(:min_version=) + @min_version = nil + @max_version = nil + end @proxy_address = :ENV @proxy_port = nil end @@ -127,6 +135,10 @@ def configure_ssl(http) http.use_ssl = true http.ssl_version = ssl_version if ssl_version + if http.respond_to?(:min_version=) + http.min_version = min_version if min_version + http.max_version = max_version if max_version + end if verify_peer http.verify_mode = OpenSSL::SSL::VERIFY_PEER diff --git a/lib/active_merchant/network_connection_retries.rb b/lib/active_merchant/network_connection_retries.rb index 4248df7ce4b..fe2c0e29c61 100644 --- a/lib/active_merchant/network_connection_retries.rb +++ b/lib/active_merchant/network_connection_retries.rb @@ -1,3 +1,5 @@ +require 'openssl' + module ActiveMerchant module NetworkConnectionRetries DEFAULT_RETRIES = 3 diff --git a/lib/active_merchant/posts_data.rb b/lib/active_merchant/posts_data.rb index 666cadd4fc1..db81049df24 100644 --- a/lib/active_merchant/posts_data.rb +++ b/lib/active_merchant/posts_data.rb @@ -8,6 +8,12 @@ def self.included(base) base.class_attribute :ssl_version base.ssl_version = nil + base.class_attribute :min_version + base.min_version = nil + + base.class_attribute :max_version + base.min_version = nil + base.class_attribute :retry_safe base.retry_safe = false @@ -53,6 +59,10 @@ def raw_ssl_request(method, endpoint, data, headers = {}) connection.max_retries = max_retries connection.tag = self.class.name connection.wiredump_device = wiredump_device + if connection.respond_to?(:min_version=) + connection.min_version = min_version + connection.max_version = max_version + end connection.pem = @options[:pem] if @options connection.pem_password = @options[:pem_password] if @options diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index 52379f9606f..4e08eae8be5 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -97,6 +97,22 @@ def test_override_ssl_version assert_equal :SSLv3, @connection.ssl_version end + def test_override_min_version + omit_if Net::HTTP.instance_methods.exclude?(:min_version=) + + refute_equal :TLS1_1, @connection.min_version + @connection.min_version = :TLS1_1 + assert_equal :TLS1_1, @connection.min_version + end + + def test_override_max_version + omit_if Net::HTTP.instance_methods.exclude?(:min_version=) + + refute_equal :TLS1_2, @connection.max_version + @connection.max_version = :TLS1_2 + assert_equal :TLS1_2, @connection.max_version + end + def test_default_read_timeout assert_equal ActiveMerchant::Connection::READ_TIMEOUT, @connection.read_timeout end From f1838e6a582ec728848c1fd9bd0c72c62725579e Mon Sep 17 00:00:00 2001 From: Bart de Water <bartdewater@gmail.com> Date: Fri, 6 Apr 2018 10:53:23 -0400 Subject: [PATCH 373/677] Add `rake gateways:ssl:min_version` task to test TLS 1.1 minimum version requirement TLS 1.0 will not be allowed after 30 June: https://blog.pcisecuritystandards.org/are-you-ready-for-30-june-2018-sayin-goodbye-to-ssl-early-tls --- CHANGELOG | 1 + Rakefile | 14 ++++-- lib/support/ssl_version.rb | 87 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 lib/support/ssl_version.rb diff --git a/CHANGELOG b/CHANGELOG index 9f43f3adc99..340a2df2350 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * Allow setting min/max SSL version for a connection on Ruby 2.5 [bdewater] #2775 +* Add `gateways:ssl:min_version` rake task to test upcoming TLS 1.0 deprecation deadline [bdewater] #2775 * Remove support for Rails < 4.2, add support for Rails 5.2 and Ruby 2.5 [bdewater] * Spreedly: Support verify and find transactions [abarrak] #2798 * Adyen: Support merchant-specific subdomains [curiousepic] #2799 diff --git a/Rakefile b/Rakefile index 0fd21391e64..dea40508ff7 100644 --- a/Rakefile +++ b/Rakefile @@ -13,6 +13,7 @@ require 'rake' require 'rake/testtask' require 'support/gateway_support' require 'support/ssl_verify' +require 'support/ssl_version' require 'support/outbound_hosts' require 'bundler/gem_tasks' @@ -89,8 +90,15 @@ namespace :gateways do end end - desc 'Test that gateways allow SSL verify_peer' - task :ssl_verify do - SSLVerify.new.test_gateways + namespace :ssl do + desc 'Test that gateways allow SSL verify_peer' + task :verify do + SSLVerify.new.test_gateways + end + + desc 'Test gateways minimal SSL version connection' + task :min_version do + SSLVersion.new.test_gateways + end end end diff --git a/lib/support/ssl_version.rb b/lib/support/ssl_version.rb new file mode 100644 index 00000000000..e45738d7757 --- /dev/null +++ b/lib/support/ssl_version.rb @@ -0,0 +1,87 @@ +require "active_merchant" +require "support/gateway_support" + +class SSLVersion + attr_accessor :success, :failed, :missing, :errored + + def initialize + @gateways = GatewaySupport.new.gateways + @success, @failed, @missing, @errored = [], [], [], [] + end + + def test_gateways(min_version = :TLS1_1) + raise "Requires Ruby 2.5 or better" unless Net::HTTP.instance_methods.include?(:min_version=) + + puts "Verifying #{@gateways.count} gateways for SSL min_version=#{min_version}\n\n" + + @gateways.each do |g| + unless g.live_url + missing << g unless g.abstract_class + next + end + + uri = URI.parse(g.live_url) + result, message = test_min_version(uri, min_version) + + case result + when :success + print "." + success << g + when :fail + print "F" + failed << {:gateway => g, :message => message} + when :error + print "E" + errored << {:gateway => g, :message => message} + end + end + + print_summary + end + + def print_summary + puts "\n\nSucceeded gateways (#{success.length})" + + puts "\n\nFailed Gateways (#{failed.length}):" + failed.each do |f| + puts "#{f[:gateway].name} - #{f[:message]}" + end + + puts "\n\nError Gateways (#{errored.length}):" + errored.each do |e| + puts "#{e[:gateway].name} - #{e[:message]}" + end + + if missing.length > 0 + puts "\n\nGateways missing live_url (#{missing.length}):" + missing.each do |m| + puts m.name + end + end + end + + private + + def test_min_version(uri, min_version) + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = true + http.verify_mode = OpenSSL::SSL::VERIFY_NONE # don't care about certificate validity, just protocol version + http.min_version = min_version + http.open_timeout = 10 + http.read_timeout = 10 + + http.post("/", "") + + return :success + rescue Net::HTTPBadResponse + return :success # version negotiation succeeded + rescue OpenSSL::SSL::SSLError => ex + return :fail, ex.inspect + rescue Interrupt => ex + print_summary + raise ex + rescue StandardError => ex + return :error, ex.inspect + end + +end From dc14b5214fbcbdceb9727dcd62d197206d2d8dda Mon Sep 17 00:00:00 2001 From: a-salty-strudel <danae.macleod@gmail.com> Date: Wed, 18 Apr 2018 11:31:26 -0400 Subject: [PATCH 374/677] Add documented country support for US and CA Closes #2810 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/realex.rb | 2 +- test/unit/gateways/realex_test.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 340a2df2350..bd4afe32c26 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * WorldPay: Remove Inquiry requests in verify transactions [nfarve] #2802 * Credorax: Update tests [curiousepic] #2809 * Braintree: Remove decimal for non-fractional currencies [nfarve] #2806 +* Realex: Add documented country support for US and CA [a-salty-strudel] #2810 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index 65767cf8e27..fca748cea2b 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -35,7 +35,7 @@ class RealexGateway < Gateway self.money_format = :cents self.default_currency = 'EUR' self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ] - self.supported_countries = %w(IE GB FR BE NL LU IT) + self.supported_countries = %w(IE GB FR BE NL LU IT US CA) self.homepage_url = 'http://www.realexpayments.com/' self.display_name = 'Realex' diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb index 69ced65ae8d..67747a11313 100644 --- a/test/unit/gateways/realex_test.rb +++ b/test/unit/gateways/realex_test.rb @@ -95,7 +95,7 @@ def test_deprecated_credit end def test_supported_countries - assert_equal ['IE', 'GB', "FR", "BE", "NL", "LU", "IT"], RealexGateway.supported_countries + assert_equal ['IE', 'GB', "FR", "BE", "NL", "LU", "IT", "US", "CA"], RealexGateway.supported_countries end def test_supported_card_types From 36e3a34eaab82b9793d7374889f7c04226ef3438 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder <deedeelavinder@gmail.com> Date: Sat, 21 Apr 2018 21:38:09 -0400 Subject: [PATCH 375/677] Paymentez: Add tax_percentage optional parameter The 5 test failures are due to using credentials from Ecuador which does not permit `authorize` and does not recoginize the `declined_card` test number. Closes #2814 Remote Tests: 15 tests, 28 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 66.6667% passed Unit Tests: 15 tests, 44 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/paymentez.rb | 1 + test/remote/gateways/remote_paymentez_test.rb | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index bd4afe32c26..7470fdcea2a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * Credorax: Update tests [curiousepic] #2809 * Braintree: Remove decimal for non-fractional currencies [nfarve] #2806 * Realex: Add documented country support for US and CA [a-salty-strudel] #2810 +* Paymentez: Add `tax_percentage` optional parameter [deedeelavinder] #2814 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index 682ee743f4a..4ec8208e755 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -150,6 +150,7 @@ def add_invoice(post, money, options) post[:order][:installments] = options[:installments] if options[:installments] post[:order][:installments_type] = options[:installments_type] if options[:installments_type] post[:order][:taxable_amount] = options[:taxable_amount] if options[:taxable_amount] + post[:order][:tax_percentage] = options[:tax_percentage] if options[:tax_percentage] end def add_payment(post, payment) diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb index c22083655ea..94389b6be73 100644 --- a/test/remote/gateways/remote_paymentez_test.rb +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -25,7 +25,8 @@ def test_successful_purchase def test_successful_purchase_with_more_options options = { order_id: '1', - ip: '127.0.0.1' + ip: '127.0.0.1', + tax_percentage: 0.07 } response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) From f5f72e094e0dea699568162c110814d7f88d5888 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder <deedeelavinder@gmail.com> Date: Wed, 18 Apr 2018 14:49:56 -0400 Subject: [PATCH 376/677] Braintree: Add boolean for skip_advanced_fraud_checking Closes #2811 Remote tests: 61 tests, 353 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit tests: 48 tests, 121 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/braintree_blue.rb | 7 ++++++- test/remote/gateways/remote_braintree_blue_test.rb | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7470fdcea2a..8f83dae3268 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * Braintree: Remove decimal for non-fractional currencies [nfarve] #2806 * Realex: Add documented country support for US and CA [a-salty-strudel] #2810 * Paymentez: Add `tax_percentage` optional parameter [deedeelavinder] #2814 +* Braintree: Add `skip_advanced_fraud_checking` optional parameter [deedeelavinder] #2811 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index babef713b7f..2a791d05494 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -555,9 +555,14 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) :options => { :store_in_vault => options[:store] ? true : false, :submit_for_settlement => options[:submit_for_settlement], - :hold_in_escrow => options[:hold_in_escrow] + :hold_in_escrow => options[:hold_in_escrow], } } + + if options[:skip_advanced_fraud_checking] + parameters[:options].merge!({ :skip_advanced_fraud_checking => options[:skip_advanced_fraud_checking] }) + end + parameters[:custom_fields] = options[:custom_fields] parameters[:device_data] = options[:device_data] if options[:device_data] parameters[:service_fee_amount] = options[:service_fee_amount] if options[:service_fee_amount] diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index fc97f9ee6bc..0066bc496b2 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -279,6 +279,13 @@ def test_successful_purchase_with_phone_from_address assert_equal '(555)555-5555', transaction["customer_details"]["phone"] end + def test_successful_purchase_with_skip_advanced_fraud_checking_option + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(skip_advanced_fraud_checking: true)) + assert_success response + assert_equal '1000 Approved', response.message + assert_equal 'submitted_for_settlement', response.params["braintree_transaction"]["status"] + end + def test_purchase_with_store_using_random_customer_id assert response = @gateway.purchase( @amount, credit_card('5105105105105100'), @options.merge(:store => true) From 197c32d6035563c7b027bea0a9ef079930cfbccd Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Mon, 23 Apr 2018 15:31:24 -0400 Subject: [PATCH 377/677] SafeCharge: Additional gateway options Adds merchant descriptor options that may be used to display on a customer's credit card statement. Additionally, this adds support for the new `sg_StoredCredentialMode` field. When `stored_credential_mode` is true, this tells SafeCharge that the transaction was completed using a previously tokenized and stored card data. When `stored_credential_mode` is false (the default), this tells SafeCharge the card was entered for the first time and will be stored for future transactions. Closes #2816 Remote: 23 tests, 68 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 20 tests, 96 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/safe_charge.rb | 12 +++-- .../gateways/remote_safe_charge_test.rb | 48 +++++++++++++++++- test/unit/gateways/safe_charge_test.rb | 49 +++++++++++++++++++ 4 files changed, 104 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8f83dae3268..be00064249a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * Realex: Add documented country support for US and CA [a-salty-strudel] #2810 * Paymentez: Add `tax_percentage` optional parameter [deedeelavinder] #2814 * Braintree: Add `skip_advanced_fraud_checking` optional parameter [deedeelavinder] #2811 +* SafeCharge: Additional gateway options [dtykocki] #2816 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index 3c7119ae16f..dbbac0788e7 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -25,7 +25,7 @@ def purchase(money, payment, options={}) post[:sg_APIType] = 1 if options[:three_d_secure] trans_type = options[:three_d_secure] ? "Sale3D" : "Sale" add_transaction_data(trans_type, post, money, options) - add_payment(post, payment) + add_payment(post, payment, options) add_customer_details(post, payment, options) commit(post) @@ -34,7 +34,7 @@ def purchase(money, payment, options={}) def authorize(money, payment, options={}) post = {} add_transaction_data("Auth", post, money, options) - add_payment(post, payment) + add_payment(post, payment, options) add_customer_details(post, payment, options) commit(post) @@ -69,7 +69,7 @@ def refund(money, authorization, options={}) def credit(money, payment, options={}) post = {} - add_payment(post, payment) + add_payment(post, payment, options) add_transaction_data("Credit", post, money, options) post[:sg_CreditType] = 1 @@ -125,14 +125,18 @@ def add_transaction_data(trans_type, post, money, options) post[:sg_WebsiteID] = options[:website_id] if options[:website_id] post[:sg_IPAddress] = options[:ip] if options[:ip] post[:sg_VendorID] = options[:vendor_id] if options[:vendor_id] + post[:sg_Descriptor] = options[:merchant_descriptor] if options[:merchant_descriptor] + post[:sg_MerchantPhoneNumber] = options[:merchant_phone_number] if options[:merchant_phone_number] + post[:sg_MerchantName] = options[:merchant_name] if options[:merchant_name] end - def add_payment(post, payment) + def add_payment(post, payment, options={}) post[:sg_NameOnCard] = payment.name post[:sg_CardNumber] = payment.number post[:sg_ExpMonth] = format(payment.month, :two_digits) post[:sg_ExpYear] = format(payment.year, :two_digits) post[:sg_CVV2] = payment.verification_value + post[:sg_StoredCredentialMode] = (options[:stored_credential_mode] == true ? 1 : 0) end def add_customer_details(post, payment, options) diff --git a/test/remote/gateways/remote_safe_charge_test.rb b/test/remote/gateways/remote_safe_charge_test.rb index ca9e1778871..221f8ab13b7 100644 --- a/test/remote/gateways/remote_safe_charge_test.rb +++ b/test/remote/gateways/remote_safe_charge_test.rb @@ -5,7 +5,7 @@ def setup @gateway = SafeChargeGateway.new(fixtures(:safe_charge)) @amount = 100 - @credit_card = credit_card('4000100011112224') + @credit_card = credit_card('4000100011112224', verification_value: '912') @declined_card = credit_card('4000300011112220') @options = { order_id: generate_unique_id, @@ -63,7 +63,11 @@ def test_successful_purchase_with_more_options email: "joe@example.com", user_id: '123', auth_type: '2', - expected_fulfillment_count: '3' + expected_fulfillment_count: '3', + merchant_descriptor: 'Test Descriptor', + merchant_phone_number: '(555)555-5555', + merchant_name: 'Test Merchant', + stored_credential_mode: true } response = @gateway.purchase(@amount, @credit_card, options) @@ -86,6 +90,27 @@ def test_successful_authorize_and_capture assert_equal 'Success', capture.message end + def test_successful_authorize_and_capture_with_more_options + extra = { + order_id: '1', + ip: "127.0.0.1", + email: "joe@example.com", + user_id: '123', + auth_type: '2', + expected_fulfillment_count: '3', + merchant_descriptor: 'Test Descriptor', + merchant_phone_number: '(555)555-5555', + merchant_name: 'Test Merchant', + stored_credential_mode: true + } + auth = @gateway.authorize(@amount, @credit_card, extra) + assert_success auth + + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + assert_equal 'Success', capture.message + end + def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response @@ -135,6 +160,25 @@ def test_successful_credit assert_equal 'Success', response.message end + def test_successful_credit_with_extra_options + extra = { + order_id: '1', + ip: "127.0.0.1", + email: "joe@example.com", + user_id: '123', + auth_type: '2', + expected_fulfillment_count: '3', + merchant_descriptor: 'Test Descriptor', + merchant_phone_number: '(555)555-5555', + merchant_name: 'Test Merchant', + stored_credential_mode: true + } + + response = @gateway.credit(@amount, credit_card('4444436501403986'), extra) + assert_success response + assert_equal 'Success', response.message + end + def test_failed_credit response = @gateway.credit(@amount, @declined_card, @options) assert_failure response diff --git a/test/unit/gateways/safe_charge_test.rb b/test/unit/gateways/safe_charge_test.rb index a5ce762e70b..3cddc23e4e2 100644 --- a/test/unit/gateways/safe_charge_test.rb +++ b/test/unit/gateways/safe_charge_test.rb @@ -14,6 +14,11 @@ def setup billing_address: address, description: 'Store Purchase' } + @merchant_options = @options.merge( + merchant_descriptor: 'Test Descriptor', + merchant_phone_number: '(555)555-5555', + merchant_name: 'Test Merchant' + ) @three_ds_options = @options.merge(three_d_secure: true) end @@ -29,6 +34,50 @@ def test_successful_purchase assert response.test? end + def test_successful_purchase_with_merchant_options + purchase = stub_comms do + @gateway.purchase(@amount, @credit_card, @merchant_options) + end.check_request do |endpoint, data, headers| + assert_match(/sg_Descriptor/, data) + assert_match(/sg_MerchantPhoneNumber/, data) + assert_match(/sg_MerchantName/, data) + end.respond_with(successful_purchase_response) + + assert_success purchase + assert_equal '111951|101508189567|ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAd' \ + 'AAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAF' \ + "UAbQBYAFIAMwA=|%02d|%d|1.00|USD" % [@credit_card.month, @credit_card.year.to_s[-2..-1]], purchase.authorization + assert purchase.test? + end + + def test_successful_purchase_with_truthy_stored_credential_mode + purchase = stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential_mode: true)) + end.check_request do |endpoint, data, headers| + assert_match(/sg_StoredCredentialMode=1/, data) + end.respond_with(successful_purchase_response) + + assert_success purchase + assert_equal '111951|101508189567|ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAd' \ + 'AAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAF' \ + "UAbQBYAFIAMwA=|%02d|%d|1.00|USD" % [@credit_card.month, @credit_card.year.to_s[-2..-1]], purchase.authorization + assert purchase.test? + end + + def test_successful_purchase_with_falsey_stored_credential_mode + purchase = stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential_mode: false)) + end.check_request do |endpoint, data, headers| + assert_match(/sg_StoredCredentialMode=0/, data) + end.respond_with(successful_purchase_response) + + assert_success purchase + assert_equal '111951|101508189567|ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAd' \ + 'AAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAF' \ + "UAbQBYAFIAMwA=|%02d|%d|1.00|USD" % [@credit_card.month, @credit_card.year.to_s[-2..-1]], purchase.authorization + assert purchase.test? + end + def test_failed_purchase @gateway.expects(:ssl_post).returns(failed_purchase_response) From cb795aa2421c16b900e844fbc92ad543db3d3764 Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Thu, 26 Apr 2018 18:01:37 -0400 Subject: [PATCH 378/677] FirstPay: Handle missing billing addresses When a billing address or address is not specified, the adapter will raise an exception. This adds a guard around the address to prevent these exceptions from occurring. Closes #2822 Remote: 12 tests, 27 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 10 tests, 108 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/first_pay.rb | 19 ++++++++++--------- test/remote/gateways/remote_first_pay_test.rb | 8 ++++++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index be00064249a..f078c3d49d4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * Paymentez: Add `tax_percentage` optional parameter [deedeelavinder] #2814 * Braintree: Add `skip_advanced_fraud_checking` optional parameter [deedeelavinder] #2811 * SafeCharge: Additional gateway options [dtykocki] #2816 +* FirstPay: Handle missing billing addresses [dtykocki] #2822 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb index ad9a62c03d4..c46353164b3 100644 --- a/lib/active_merchant/billing/gateways/first_pay.rb +++ b/lib/active_merchant/billing/gateways/first_pay.rb @@ -70,15 +70,16 @@ def add_customer_data(post, options) end def add_address(post, creditcard, options) - address = options[:billing_address] || options[:address] - post[:owner_name] = address[:name] - post[:owner_street] = address[:address1] - post[:owner_street2] = address[:address2] if address[:address2] - post[:owner_city] = address[:city] - post[:owner_state] = address[:state] - post[:owner_zip] = address[:zip] - post[:owner_country] = address[:country] - post[:owner_phone] = address[:phone] if address[:phone] + if address = options[:billing_address] || options[:address] + post[:owner_name] = address[:name] + post[:owner_street] = address[:address1] + post[:owner_street2] = address[:address2] if address[:address2] + post[:owner_city] = address[:city] + post[:owner_state] = address[:state] + post[:owner_zip] = address[:zip] + post[:owner_country] = address[:country] + post[:owner_phone] = address[:phone] if address[:phone] + end end def add_invoice(post, money, options) diff --git a/test/remote/gateways/remote_first_pay_test.rb b/test/remote/gateways/remote_first_pay_test.rb index b64b05e578f..68607203107 100644 --- a/test/remote/gateways/remote_first_pay_test.rb +++ b/test/remote/gateways/remote_first_pay_test.rb @@ -27,6 +27,14 @@ def test_failed_purchase assert_equal 'Declined', response.message end + def test_failed_purchase_with_no_address + @options.delete(:billing_address) + response = @gateway.purchase(@amount, @credit_card, @options) + + assert_failure response + assert_equal 'Address is invalid (street, city, zip, state and or country fields)', response.message + end + def test_successful_authorize_and_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth From 4105f8ff1e3fb22c107d529233621ae71caa679e Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Tue, 24 Apr 2018 15:21:59 -0400 Subject: [PATCH 379/677] Realex: Add ApplePay Support Adds support for apple pay and updates card numbers as they are now publicly available. Loaded suite test/remote/gateways/remote_realex_test 20 tests, 106 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 95% passed Loaded suite test/unit/gateways/realex_test 21 tests, 439 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/realex.rb | 13 ++++++++ test/fixtures.yml | 25 +++++++++------ test/remote/gateways/remote_realex_test.rb | 31 +++++++++++++++++-- 4 files changed, 58 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f078c3d49d4..12108ad7da9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ * Braintree: Add `skip_advanced_fraud_checking` optional parameter [deedeelavinder] #2811 * SafeCharge: Additional gateway options [dtykocki] #2816 * FirstPay: Handle missing billing addresses [dtykocki] #2822 +* Realex: Add ApplePay Support [nfarve] #2820 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index fca748cea2b..ecc3150c992 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -140,6 +140,7 @@ def build_purchase_or_authorization_request(action, money, credit_card, options) add_card(xml, credit_card) xml.tag! 'autosettle', 'flag' => auto_settle_flag(action) add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), amount(money), (options[:currency] || currency(money)), credit_card.number) + add_network_tokenization_card(xml, credit_card) if credit_card.is_a?(NetworkTokenizationCreditCard) add_comments(xml, options) add_address_and_customer_info(xml, options) end @@ -251,6 +252,18 @@ def add_card(xml, credit_card) end end + def add_network_tokenization_card(xml, payment) + xml.tag! 'mpi' do + xml.tag! 'cavv', payment.payment_cryptogram + xml.tag! 'eci', payment.eci + end + xml.tag! 'supplementarydata' do + xml.tag! 'item', 'type' => 'mobile' do + xml.tag! 'field01', payment.source.to_s.gsub('_','-') + end + end + end + def format_address_code(address) code = [address[:zip].to_s, address[:address1].to_s + address[:address2].to_s] code.collect{|e| e.gsub(/\D/, "")}.reject{|e| e.empty?}.join("|") diff --git a/test/fixtures.yml b/test/fixtures.yml index 6118cc4f9af..d03708a73bb 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -978,64 +978,69 @@ realex: password: Y realex_mastercard: - number: + number: '5425230000004415' month: '6' year: '2020' verification_value: '123' + brand: 'master' realex_mastercard_coms_error: - number: + number: '5135020000005871' month: '6' year: '2020' verification_value: '123' + brand: 'master' realex_mastercard_declined: - number: + number: '5114610000004778' month: '6' year: '2020' verification_value: '123' + brand: 'master' realex_mastercard_referral_a: - number: + number: '5121220000006921' month: '6' year: '2020' verification_value: '123' + brand: 'master' realex_mastercard_referral_b: - number: + number: '5114630000009791' month: '6' year: '2020' verification_value: '123' + brand: 'master' # Realex doesn't provide public testing data # Fill in the card numbers with the Realex test # data. realex_visa: - number: + number: '4263970000005262' month: '6' year: '2020' verification_value: '123' realex_visa_coms_error: - number: + number: '4009830000001985' month: '6' year: '2020' verification_value: '123' realex_visa_declined: - number: + number: '4000120000001154' month: '6' year: '2020' verification_value: '123' realex_visa_referral_a: - number: + number: '4000160000004147' month: '6' year: '2020' verification_value: '123' realex_visa_referral_b: - number: + number: '4000130000001724' month: '6' year: '2020' verification_value: '123' diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb index 33c863f334f..f8b233cce7e 100644 --- a/test/remote/gateways/remote_realex_test.rb +++ b/test/remote/gateways/remote_realex_test.rb @@ -18,6 +18,19 @@ def setup @mastercard_referral_a = card_fixtures(:realex_mastercard_referral_a) @mastercard_coms_error = card_fixtures(:realex_mastercard_coms_error) + @apple_pay = credit_card = network_tokenization_credit_card('4242424242424242', + payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + verification_value: nil, + eci: '05', + source: :apple_pay + ) + + @declined_apple_pay = credit_card = network_tokenization_credit_card('4000120000001154', + payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + verification_value: nil, + eci: '05', + source: :apple_pay + ) @amount = 10000 end @@ -70,10 +83,17 @@ def test_realex_purchase_with_invalid_account assert_not_nil response assert_failure response - assert_equal '506', response.params['result'] + assert_equal '504', response.params['result'] assert_match %r{no such}i, response.message end + def test_realex_purchase_with_apple_pay + response = @gateway.purchase(1000, @apple_pay, :order_id => generate_unique_id, :description => 'Test Realex with ApplePay') + assert_success response + assert response.test? + assert_equal 'Successful', response.message + end + def test_realex_purchase_declined [ @visa_declined, @mastercard_declined ].each do |card| @@ -90,6 +110,14 @@ def test_realex_purchase_declined end + def test_realex_purchase_with_apple_pay_declined + response = @gateway.purchase(1101, @declined_apple_pay, :order_id => generate_unique_id, :description => 'Test Realex with ApplePay') + assert_failure response + assert response.test? + assert_equal '101', response.params['result'] + assert_match %r{DECLINED}i, response.message + end + def test_realex_purchase_referral_b [ @visa_referral_b, @mastercard_referral_b ].each do |card| @@ -282,7 +310,6 @@ def test_realex_purchase_then_refund assert_not_nil rebate_response assert_success rebate_response - assert rebate_response.test? assert rebate_response.authorization.length > 0 assert_equal 'Successful', rebate_response.message end From ae5190c6e00a7794a7d53666aefe34088877caba Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Thu, 26 Apr 2018 17:02:28 -0400 Subject: [PATCH 380/677] Checkout V2: Additional gateway options Adds the following options that are applied to both `purchase` and `authorize` in support of new Visa stored credential changes: - card_on_file: By default this option is not sent to the gateway. Specify `true` when making a call using card details stored on your server. - transaction_indictator: Default value of 1 (regular). Specify 2 for recurring or 3 for MOTO. - previous_charge_id: Used to reference either the previous transaction or the opening transaction of a payment plan. Closes #2821 Remote: 27 tests, 65 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 21 tests, 93 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/checkout_v2.rb | 7 ++++++ .../gateways/remote_checkout_v2_test.rb | 19 +++++++++++++++ test/unit/gateways/checkout_v2_test.rb | 24 +++++++++++++++++++ 4 files changed, 51 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 12108ad7da9..c12dd3848de 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * SafeCharge: Additional gateway options [dtykocki] #2816 * FirstPay: Handle missing billing addresses [dtykocki] #2822 * Realex: Add ApplePay Support [nfarve] #2820 +* Checkout V2: Additional gateway options [dtykocki] #2821 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb index 6a09c8f5d78..b81c2f32a4f 100644 --- a/lib/active_merchant/billing/gateways/checkout_v2.rb +++ b/lib/active_merchant/billing/gateways/checkout_v2.rb @@ -34,6 +34,7 @@ def authorize(amount, payment_method, options={}) add_invoice(post, amount, options) add_payment_method(post, payment_method) add_customer_data(post, options) + add_transaction_data(post, options) commit(:authorize, post) end @@ -113,6 +114,12 @@ def add_customer_data(post, options) end end + def add_transaction_data(post, options={}) + post[:cardOnFile] = true if options[:card_on_file] == true + post[:transactionIndicator] = options[:transaction_indicator] || 1 + post[:previousChargeId] = options[:previous_charge_id] if options[:previous_charge_id] + end + def commit(action, post, authorization = nil) begin raw_response = ssl_post(url(post, action, authorization), post.to_json, headers) diff --git a/test/remote/gateways/remote_checkout_v2_test.rb b/test/remote/gateways/remote_checkout_v2_test.rb index 1f9e2d8392b..c894bd951a1 100644 --- a/test/remote/gateways/remote_checkout_v2_test.rb +++ b/test/remote/gateways/remote_checkout_v2_test.rb @@ -15,6 +15,11 @@ def setup description: 'Purchase', email: "longbob.longsen@example.com" } + @additional_options = @options.merge( + card_on_file: true, + transaction_indicator: 2, + previous_charge_id: "charge_12312" + ) end def test_transcript_scrubbing @@ -34,6 +39,12 @@ def test_successful_purchase assert_equal 'Succeeded', response.message end + def test_successful_purchase_with_additional_options + response = @gateway.purchase(@amount, @credit_card, @additional_options) + assert_success response + assert_equal 'Succeeded', response.message + end + def test_successful_purchase_includes_avs_result response = @gateway.purchase(@amount, @credit_card, @options) assert_success response @@ -115,6 +126,14 @@ def test_successful_authorize_and_capture assert_success capture end + def test_successful_authorize_and_capture_with_additional_options + auth = @gateway.authorize(@amount, @credit_card, @additional_options) + assert_success auth + + assert capture = @gateway.capture(nil, auth.authorization) + assert_success capture + end + def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb index 5379ac51277..1724f172730 100644 --- a/test/unit/gateways/checkout_v2_test.rb +++ b/test/unit/gateways/checkout_v2_test.rb @@ -93,6 +93,30 @@ def test_successful_authorize_and_capture assert_success capture end + def test_successful_authorize_and_capture_with_additional_options + response = stub_comms do + options = { + card_on_file: true, + transaction_indicator: 2, + previous_charge_id: "charge_123" + } + @gateway.authorize(@amount, @credit_card, options) + end.check_request do |endpoint, data, headers| + assert_match(%r{"cardOnFile":true}, data) + assert_match(%r{"transactionIndicator":2}, data) + assert_match(%r{"previousChargeId":"charge_123"}, data) + end.respond_with(successful_authorize_response) + + assert_success response + assert_equal "charge_test_AF1A29AD350Q748C7EA8", response.authorization + + capture = stub_comms do + @gateway.capture(@amount, response.authorization) + end.respond_with(successful_capture_response) + + assert_success capture + end + def test_failed_authorize response = stub_comms do @gateway.authorize(@amount, @credit_card) From f2e5ae2a5f8887e52ab69650ff859e0c26558880 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 1 May 2018 10:51:44 -0400 Subject: [PATCH 381/677] CyberSource: Support 3ds validate request Closes #2823 Remote (3 unrelated failures): 40 tests, 181 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 92.5% passed Unit: 45 tests, 217 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/cyber_source.rb | 13 ++++++++++-- .../gateways/remote_cyber_source_test.rb | 19 ++++++++++++++--- test/unit/gateways/cyber_source_test.rb | 21 ++++++++++++++++++- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c12dd3848de..83c54e447ba 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * FirstPay: Handle missing billing addresses [dtykocki] #2822 * Realex: Add ApplePay Support [nfarve] #2820 * Checkout V2: Additional gateway options [dtykocki] #2821 +* CyberSource: Support 3ds validate request [curiousepic] #2823 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index c44e96fa677..6b1df15c71d 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -295,7 +295,7 @@ def build_purchase_request(money, payment_method_or_reference, options) add_check_service(xml) else add_purchase_service(xml, payment_method_or_reference, options) - xml.tag! 'payerAuthEnrollService', {'run' => 'true'} if options[:payer_auth_enroll_service] + add_threeds_services(xml, options) add_payment_network_token(xml) if network_tokenization?(payment_method_or_reference) add_business_rules_data(xml, payment_method_or_reference, options) unless options[:pinless_debit_card] end @@ -403,7 +403,7 @@ def build_validate_pinless_debit_request(creditcard,options) def add_business_rules_data(xml, payment_method, options) prioritized_options = [options, @options] - unless network_tokenization?(payment_method) + unless network_tokenization?(payment_method) || options[:payer_auth_validate_service] xml.tag! 'businessRules' do xml.tag!('ignoreAVSResult', 'true') if extract_option(prioritized_options, :ignore_avs) xml.tag!('ignoreCVResult', 'true') if extract_option(prioritized_options, :ignore_cvv) @@ -667,6 +667,15 @@ def add_validate_pinless_debit_service(xml) xml.tag!'pinlessDebitValidateService', {'run' => 'true'} end + def add_threeds_services(xml, options) + xml.tag! 'payerAuthEnrollService', {'run' => 'true'} if options[:payer_auth_enroll_service] + if options[:payer_auth_validate_service] + xml.tag! 'payerAuthValidateService', {'run' => 'true'} do + xml.tag! 'signedPARes', options[:pares] + end + end + end + def lookup_country_code(country_field) country_code = Country.find(country_field) rescue nil country_code.code(:alpha2) if country_code diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb index 598b87f785c..b690e25c5f1 100644 --- a/test/remote/gateways/remote_cyber_source_test.rb +++ b/test/remote/gateways/remote_cyber_source_test.rb @@ -369,16 +369,17 @@ def test_successful_retrieve_subscription assert response.test? end - def test_3ds_purchase_request + def test_3ds_enroll_request_via_purchase assert response = @gateway.purchase(1202, @three_ds_enrolled_card, @options.merge(payer_auth_enroll_service: true)) assert_equal "475", response.params["reasonCode"] assert !response.params["acsURL"].blank? assert !response.params["paReq"].blank? assert !response.params["xid"].blank? assert !response.success? + puts response.inspect end - def test_3ds_authorize_request + def test_3ds_enroll_request_via_authorize assert response = @gateway.authorize(1202, @three_ds_enrolled_card, @options.merge(payer_auth_enroll_service: true)) assert_equal "475", response.params["reasonCode"] assert !response.params["acsURL"].blank? @@ -387,7 +388,7 @@ def test_3ds_authorize_request assert !response.success? end - def test_3ds_transactions_with_unenrolled_card + def test_successful_3ds_requests_with_unenrolled_card assert response = @gateway.purchase(1202, @credit_card, @options.merge(payer_auth_enroll_service: true)) assert response.success? @@ -395,6 +396,18 @@ def test_3ds_transactions_with_unenrolled_card assert response.success? end + def test_3ds_validate_request + assert response = @gateway.purchase(1202, @three_ds_enrolled_card, @options.merge(payer_auth_validate_service: true, pares: pares)) + assert_equal "100", response.params["reasonCode"] + assert response.success? + end + + def pares + <<-PARES +eNqdmFuTqkgSgN+N8D90zD46M4B3J+yOKO6goNyFN25yEUHkUsiv31K7T/ec6dg9u75YlWRlZVVmflWw1uNrGNJa6DfX8G0thVXlRuFLErz+tgm67sRlbJr3ky4G9LWn8N/e1nughtVD4dFawFAodT8OqbBx4NLdj/o8y3JqKlavSLsNr1VS5G/En/if4zX20UUTXf3Yzeu3teuXpCC/TeerMTFfY+/d9Tm8CvRbEB7dJqvX2LO7xj7H7Zt7q0JOd0nwpo3VacjVvMc4pZcXfcjFpMqLc6UHr2vsrrEO3Dp8G+P4Ap+PZy/E9C+c+AtfrrGHfH25mwPnokG2CRxfY18Fa7Q71zD3b2/LKXr0o7cOu0uRh0gDre1He419+nZx8zf87z+kepeu9cPbuk7OX31a3X0iFmvsIV9XtVs31Zu9xt5ba99t2zcAAAksNjsr4N5MVctyGIaN2H6E1vpQWYd+8obPkFPo/zEKZFFxTer4fHf174I1dncFe4Tzba0lUY4mu4Yv3TnLURDjur78hWEQwj/h5M/iGmHIYRzDVxhSCKok+tdvz1FhIOTH4n8aRrl5kSe+myW9W6PEkMI6LoKXH759Z0ZX75YITGWoP5CpP3ximv9xl+ATYoZsYt8b/bKyX5nlZ2evlftHFbvEfYKfDL2t1fAY3jMifDFU4fW3f/1KZdBJFFb1/+PKhxtfLXzYM92sCd8qN5U5lrrNDZOFzkiecUIszvyCVJjXj3FPzTX2w/f3hT2j+GW3noobXm8xXJ3KK2aZztNbVdsLWbbOASZgzSY45eYqFNiK5ReRNLKbzvZSIDJj+zqBzIEkIx1L9ZTabYeDJa/MV51fF9A0dxDvxzf5CiPmttuVVBLHxmZSNp53lnBcJzh+IS3YpejKebycHjQlvMggwkvHdZjhYBHf8M1R4ikKjHxMGxlCfuCv+IqmxjTRk9GMnO2ynnXsWMvZSYdlk+Vmvpz1pVns4v05ugRWIGZNMhxUGLzoqs+VDe14Jtzli63TT06WBvpJg2+2UVLie+5mgGDlEVjip+7EmZhCvRdndtQHmKm0vaUDejhYTRgglbR5qysx6I1gf+vTyWJ3ahaXNOWBUrXRYnwasbKlbi3XsJLNuA3g6+uXrHqPzCa8PSNxmKElubX7bGmNl4Z+LbuIEJT8SrnXIMnd7IUOz8XLI4DX3192xucDQGlI8NmnijOiqR/+/rJ9lRCvCqSv6a+7OCl+f6FeDW2N/TzPY2IqvNbJEdUVwqUkCLTVo32vtAhAgQSRQAFNgLRii5vCEeLWl4HCsKQCoJMyWwmcOEAYDBlLlGlKHa2DLRnJ5nCAhkoksypca9nxKfDvUhIUEmvIsX9WL96ZrZTxqvYs82aPjQi1bz7NaBIJHhYpCEXplJ2GA8ea4a7lXCRVgUxk06ai0DSoDecg4wIvE3ZC0ooOQhbinUQzNyn1OzkFM5kWXSS7PWVKNxx8SCV+2VE9EJ8+2TrITF1ScEjBh3WBgere5bJWUpb3ld9lPAMd+e6JNxGQJS4F9vuKdObLigRGbj2LyPyznEmqAZmnxS0DO9o+iCfXmsUeRZIKIXW8Djy0Tw8rks4yX62omWctI2Oc5d7ZvKGokEIKZDI6lfEp4VYQJ+9RAGBHAWUJ7s+HAyraoB4DSmYSEIl4LuOMDMYCIZJ71pj7U99OwbapLHXFMLI66s7eKosO9qmWU56LwmJCul2tccin+XTKE4tV7EatfZaSNCQFH9bYXMNCetuoK2kl0SN6An3f3xmIMwGIT8KlZZS5pV/wpTIz8FzIF9fhIK6EhVLuzEDAg4MI+sybxjVzA/TGuEmsEHDZbZFBtjKxdKfgilSRZDLRoGjQmpWlzUEZGeJ+7CK6jCNPPgQe2ZInYsxH5YEWZoId7i5G2RJNax3USyCJo1OXS/jNLKdCtZiMSaCR4jKPaXvXqjl/6Et+OMBDRoth7MfSnLa3o7ItpxyV8CZcmjrVbJtyWykIypti158qotvx1VkJTm48GzeYBAUaKIAsJhUcDkL9mUO8KjEgBUCiIEdZFKcBjhsxAkpL5cjGxN7nzMYgZElgguweT/ugZg5F0s5BfGT2cGCPWdzRQfCwpkzRoa8YasSpRuIhBMUdRVxBGyn1FouIkytA/p5XKp4iAEO2AMZRSKQkIPDhgLC0ZSKTIV5IsXXC55ue+a566chmgKyLBwZfHlr7igWzo4Dn4m63WjXm3kMV3G7GNc3KJz9Ur5pt1AxBnafhdFf03bi2pnQlT8pZhWNWN7Mu+6RtWe/I6AbUz1wcFd6puR7FdrSYDwcYP5lcIsJ0ZNh7zOxcqcSFOjoUhaui645OzZ5qHGeazOnrqlxJ1+2eSJtTNOo7bBrgyvIanQyHuh9xP/PqO4BROI0Alp6/AOzbLYAh/asAo/t78d0L1ZdQ/mVerrZ+yoQSCZ+wiqCpjNmbw2WNbXW0NyZqFNzU0Uh0dHgTEUqqABnwhAENTjfNUu9WLs751LE60N8xINGsmvkTJTLOqzag/g624UDS72hjelmXP9GmKz9kEmf/R7DR4Ak2ZEmdQv7pz4YmzU84fQHYHWZ+DjomBcrTYiVRuig6KJ1R5Z5dhD5kiRQeewAg3Jqc2SOv+8ASIgVnYOQsf9558pl8OIIWJ4KCQ4u+QWKmIqgK7g5MOZ+0XJ4jemPuucVRUPf5rma5LL6U7RxuXQ4ax+NodrIvC4k53wRDanhGdkGrnhJRq2/UajccHM67ebQItvRyk3PEnFrl1y5dFuT0PEFYMqbn0dG2dlx+js/7Yt7HZFuSVXvsV5OYiTYHec4EG7kxo+GgKfvamoPtDhry3CPLjaJN7okBAJeGPTl7z5+AgQolAQC3wBZtwRGA7U2ViJFJcmnxxgo+jjHdwGGkjs0G5UYccOYJ7XDmP7IgS+9QkEj8YY2OFIsk1WUi3MTJQTed7U3A2YUW3Vh3OND14irp4PiAhSYxHA2siFSZKN1jhOVFme2MOa7LKcst80SEKId+OjqM+9GBjoxIIZfNxsBWkyVmbmYUa4iJghm7gzu+8jeiAxMvJwhiR80zcl4FSr2Q01jx442ebHWlimZHrNQymRgOto7dtFMgbPTdxmG4ayKWQJ+Lp3K0OcQ1rU2jtLyw+XKXOqWoLo7ulVFHgTebYaLWXho+Sr1OPy7AcHCGCar/njbEqWk2ib1Z6iWb3cbm1eTZ6PVXIdCmCAJJ+AEBEYh0tx8xmanGGwngHKWVnCZ4E/qRkgaQ+OgfpYOS+5vi+XoroMHnreA/3XIQBP7LPefzlvPj1oBuOd3zlsOKrYegcC+p4YCPfRmFv5NSZiLpNpR1cLPusvQhw3/IUnIqKRWknr5yDBRNo2dkCVSPmdGNAUBGH8cXr2f29z15gBBCTrfuBb66/SokhoP/gglTIqUPSEjvkNC88QpHo0kEguNHRIaDj5igJAWIBjKgKTJRNmSkUNPwevRaVWGow9Vezev9QtlZJaWDcZpjs3SywiKsxD0p8RVKHQ6u49ExWZz6zY28KaVz4ntbnC0nGDi0G9GFeM2id5cJkwbRKezMS2ZrYcnsZzuDlqaRqx0XJS9F5h6VycYt8nF7TfnOCimzY5NpNyWLIBPzY4ZhNZdu8FKm+3pxwqZyqLHWzSsT5f2mQACop8+THcXu42wXhB5bmeepaHFBHFcOzM7lZZr4DPOPs/073eHgQ5sGD22dBAZE4SSx/vtijxSQsEuSy0gWSqEshkxiw9xVEJhqg78mbmrU3nxGzJe1fLxwDDO59rxHzgrpzPiHrvK8WlDJpo33y3MdhU7GZ81W6fFSHfnjYpbBcDjo4CLNjoAvSxRlLaU2W76plphc5At/tEhKra8VXiLN0FuM59Ddt5zgHZitL1vFyttHamkZ44sToxvD5ubwK/BtsWOfr03Yj1epz5esx7ekx8eu+/ePrx/B/g0UAjN8 + PARES + end + def test_verify_credentials assert @gateway.verify_credentials diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index 955764361e1..e0a4351e4d2 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -446,7 +446,7 @@ def test_malformed_xml_handling assert response.test? end - def test_3ds_response + 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| @@ -459,6 +459,17 @@ def test_3ds_response assert_equal "https://0eafstag.cardinalcommerce.com/EAFService/jsp/v1/redirect", purchase.params["acsURL"] end + 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| + assert_match(/\<payerAuthValidateService run=\"true\"\>/, data) + assert_match(/\<signedPARes\>ABC123\<\/signedPARes\>/, data) + end.respond_with(successful_threedeesecure_validate_response) + + assert_success validation + end + def test_scrub assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed end @@ -713,6 +724,14 @@ def threedeesecure_purchase_response XML end + def successful_threedeesecure_validate_response + <<-XML +<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> +<soap:Header> +<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-635495097"><wsu:Created>2018-05-01T14:28:36.773Z</wsu:Created></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.121"><c:merchantReferenceCode>23751b5aeb076ea5940c5b656284bf6a</c:merchantReferenceCode><c:requestID>5251849164756591904009</c:requestID><c:decision>ACCEPT</c:decision><c:reasonCode>100</c:reasonCode><c:requestToken>Ahj//wSTHLQMXdtQnQUJGxDds0bNnDRoo0+VcdXMBUafKuOrnpAuWT9zDJpJlukB29J4YBpMctAxd21CdBQkwQ3g</c:requestToken><c:purchaseTotals><c:currency>USD</c:currency></c:purchaseTotals><c:ccAuthReply><c:reasonCode>100</c:reasonCode><c:amount>12.02</c:amount><c:authorizationCode>831000</c:authorizationCode><c:avsCode>Y</c:avsCode><c:avsCodeRaw>Y</c:avsCodeRaw><c:authorizedDateTime>2018-05-01T14:28:36Z</c:authorizedDateTime><c:processorResponse>00</c:processorResponse><c:reconciliationID>ZLIU5GM27GBP</c:reconciliationID><c:authRecord>0110322000000E10000200000000000000120205011428360272225A4C495535474D32374742503833313030303030000159004400103232415050524F56414C0022313457303136313530373033383032303934473036340006564943524120</c:authRecord></c:ccAuthReply><c:ccCaptureReply><c:reasonCode>100</c:reasonCode><c:requestDateTime>2018-05-01T14:28:36Z</c:requestDateTime><c:amount>12.02</c:amount><c:reconciliationID>76466844</c:reconciliationID></c:ccCaptureReply><c:payerAuthValidateReply><c:reasonCode>100</c:reasonCode><c:authenticationResult>0</c:authenticationResult><c:authenticationStatusMessage>Success</c:authenticationStatusMessage><c:cavv>AAABAWFlmQAAAABjRWWZEEFgFz+=</c:cavv><c:cavvAlgorithm>2</c:cavvAlgorithm><c:commerceIndicator>vbv</c:commerceIndicator><c:eci>05</c:eci><c:eciRaw>05</c:eciRaw><c:xid>S2R4eGtHbEZqbnozeGhBRHJ6QzA=</c:xid><c:paresStatus>Y</c:paresStatus></c:payerAuthValidateReply></c:replyMessage></soap:Body></soap:Envelope> + XML + end + def assert_xml_valid_to_xsd(data, root_element = '//s:Body/*') schema_file = File.open("#{File.dirname(__FILE__)}/../../schema/cyber_source/CyberSourceTransaction_#{CyberSourceGateway::XSD_VERSION}.xsd") doc = Nokogiri::XML(data) From 2da6e684eb08010b3b93d89bac6a71d3e66fc5c9 Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Tue, 1 May 2018 07:47:17 -0400 Subject: [PATCH 382/677] Paymentez: Remove card tokenization step from authorize It turns out that Paymentez does accept card data when performing an authorization. Previously, `authorize` would attempt to tokenize a card via store if not already tokenized. This removes the tokenization step while still allowing for authorizations to be performed with a tokenized card. Closes #2825 Unit: 15 tests, 44 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 15 tests, 37 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/paymentez.rb | 12 ++------ test/remote/gateways/remote_paymentez_test.rb | 6 ++-- test/unit/gateways/paymentez_test.rb | 30 +++++++++++++------ 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 83c54e447ba..f951581034b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ * Realex: Add ApplePay Support [nfarve] #2820 * Checkout V2: Additional gateway options [dtykocki] #2821 * CyberSource: Support 3ds validate request [curiousepic] #2823 +* Paymentez: Remove card tokenization step from authorize [dtykocki] #2825 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index 4ec8208e755..5b8983d8d2f 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -61,18 +61,10 @@ def authorize(money, payment, options = {}) post = {} add_invoice(post, money, options) + add_payment(post, payment) add_customer_data(post, options) - if payment.is_a?(String) - post[:card] = { token: payment } - commit_transaction('authorize', post) - else - MultiResponse.run do |r| - r.process { store(payment, options) } - post[:card] = { token: r.authorization } - r.process { commit_transaction('authorize', post) } - end - end + commit_transaction('authorize', post) end def capture(_money, authorization, _options = {}) diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb index 94389b6be73..63ba19b25b1 100644 --- a/test/remote/gateways/remote_paymentez_test.rb +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -67,7 +67,7 @@ def test_successful_authorize_and_capture assert_success auth assert capture = @gateway.capture(@amount, auth.authorization) assert_success capture - assert_equal 'Operation Successful', capture.message + assert_equal 'Response by mock', capture.message end def test_successful_authorize_and_capture_with_token @@ -78,13 +78,13 @@ def test_successful_authorize_and_capture_with_token assert_success auth assert capture = @gateway.capture(@amount, auth.authorization) assert_success capture - assert_equal 'Operation Successful', capture.message + assert_equal 'Response by mock', capture.message end def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal 'Not Authorized', response.message + assert_equal nil, response.message end def test_partial_capture diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb index 6473c7b7a3a..6c9d3f88c05 100644 --- a/test/unit/gateways/paymentez_test.rb +++ b/test/unit/gateways/paymentez_test.rb @@ -44,7 +44,7 @@ def test_failed_purchase end def test_successful_authorize - @gateway.stubs(:ssl_post).returns(successful_store_response, successful_authorize_response) + @gateway.stubs(:ssl_post).returns(successful_authorize_response) response = @gateway.authorize(@amount, @credit_card, @options) assert_success response @@ -62,7 +62,7 @@ def test_successful_authorize_with_token end def test_failed_authorize - @gateway.expects(:ssl_post).returns(failed_store_response) + @gateway.expects(:ssl_post).returns(failed_authorize_response) response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response @@ -272,17 +272,29 @@ def successful_authorize_response def failed_authorize_response %q( - { + { + "transaction": { + "status": "failure", + "payment_date": null, + "amount": 1.0, + "authorization_code": null, + "installments": 1, + "dev_reference": "Testing", + "message": null, + "carrier_code": "3", + "id": "CI-1223", + "status_detail": 9 + }, "card": { "bin": "424242", - "status": "rejected", - "token": "2026849624512750545", - "message": "Not Authorized", - "expiry_year": "2018", + "status": null, + "token": "6461587429110733892", + "expiry_year": "2019", "expiry_month": "9", - "transaction_reference": "CI-606", + "transaction_reference": "CI-1223", "type": "vi", - "number": "4242" + "number": "4242", + "origin": "Paymentez" } } ) From f45dea590ab178afab0d1dcb6e7c44769a659825 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Tue, 10 Apr 2018 11:40:04 -0400 Subject: [PATCH 383/677] WorldPay: Add 3DS Adds 3DS ability to Worldpay Errors are caused by authorize calls requiring time to be captured Loaded suite test/remote/gateways/remote_worldpay_test 24 tests, 75 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 79.1667% passed Loaded suite test/unit/gateways/worldpay_test 37 tests, 210 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/worldpay.rb | 53 +++++++++++++++---- test/remote/gateways/remote_worldpay_test.rb | 41 ++++++++++++++ 3 files changed, 84 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f951581034b..d852e266883 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,7 @@ * Checkout V2: Additional gateway options [dtykocki] #2821 * CyberSource: Support 3ds validate request [curiousepic] #2823 * Paymentez: Remove card tokenization step from authorize [dtykocki] #2825 +* WorldPay: Add 3DS [nfarve] #2819 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index e6e608d94f3..4f49f1b2915 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -101,27 +101,27 @@ def scrub(transcript) private def authorize_request(money, payment_method, options) - commit('authorize', build_authorization_request(money, payment_method, options), "AUTHORISED") + commit('authorize', build_authorization_request(money, payment_method, options), "AUTHORISED", options) end def capture_request(money, authorization, options) - commit('capture', build_capture_request(money, authorization, options), :ok) + commit('capture', build_capture_request(money, authorization, options), :ok, options) end def cancel_request(authorization, options) - commit('cancel', build_void_request(authorization, options), :ok) + commit('cancel', build_void_request(authorization, options), :ok, options) end def inquire_request(authorization, options, *success_criteria) - commit('inquiry', build_order_inquiry_request(authorization, options), *success_criteria) + commit('inquiry', build_order_inquiry_request(authorization, options), *success_criteria, options) end def refund_request(money, authorization, options) - commit('refund', build_refund_request(money, authorization, options), :ok) + commit('refund', build_refund_request(money, authorization, options), :ok, options) end def credit_request(money, payment_method, options) - commit('credit', build_authorization_request(money, payment_method, options), :ok) + commit('credit', build_authorization_request(money, payment_method, options), :ok, options) end def build_request @@ -252,9 +252,13 @@ def add_payment_method(xml, amount, payment_method, options) end def add_email(xml, options) - return unless options[:email] + return unless options[:execute_threed] || options[:email] xml.tag! 'shopper' do - xml.tag! 'shopperEmailAddress', options[:email] + xml.tag! 'shopperEmailAddress', options[:email] if options[:email] + xml.tag! 'browser' do + xml.tag! 'acceptHeader', options[:accept_header] + xml.tag! 'userAgentHeader', options[:user_agent] + end end end @@ -321,9 +325,24 @@ def parse_element(raw, node) raw end - def commit(action, request, *success_criteria) - xmr = ssl_post(url, request, 'Content-Type' => 'text/xml', 'Authorization' => encoded_credentials) - raw = parse(action, xmr) + def headers(options) + headers = { + 'Content-Type' => 'text/xml', + 'Authorization' => encoded_credentials + } + if options[:cookie] + headers.merge!('Set-Cookie' => options[:cookie]) if options[:cookie] + end + headers + end + + def commit(action, request, *success_criteria, options) + xml = ssl_post(url, request, headers(options)) + raw = parse(action, xml) + if options[:execute_threed] + raw[:cookie] = @cookie + raw[:session_id] = options[:session_id] + end success, message = success_and_message_from(raw, success_criteria) Response.new( @@ -346,6 +365,18 @@ def url test? ? self.test_url : self.live_url end + # Override the regular handle response so we can access the headers + # Set-Cookie value is needed for 3DS transactions + def handle_response(response) + case response.code.to_i + when 200...300 + @cookie = response.response['Set-Cookie'] + response.body + else + raise ResponseError.new(response) + end + end + # success_criteria can be: # - a string or an array of strings (if one of many responses) # - An array of strings if one of many responses could be considered a diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index 9c40d7d6609..5180f0b7fc6 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -9,6 +9,7 @@ def setup @amount = 100 @credit_card = credit_card('4111111111111111') @declined_card = credit_card('4111111111111111', :first_name => nil, :last_name => 'REFUSED') + @threeDS_card = credit_card('4111111111111111', :first_name => nil, :last_name => '3D') @options = {order_id: generate_unique_id, email: "wow@example.com"} end @@ -81,6 +82,46 @@ def test_authorize_and_purchase_by_reference assert_success capture end + def test_successful_authorize_with_3ds + session_id = generate_unique_id + order_id = @options[:order_id] + options = @options.merge( + { + execute_threed: true, + accept_header: 'text/html', + user_agent: 'Mozilla/5.0', + session_id: session_id, + ip: '127.0.0.1', + cookie: 'machine=32423423' + }) + assert first_message = @gateway.authorize(@amount, @threeDS_card, options) + assert_equal "A transaction status of 'AUTHORISED' is required.", first_message.message + assert first_message.test? + refute first_message.authorization.blank? + refute first_message.params['issuer_url'].blank? + refute first_message.params['pa_request'].blank? + refute first_message.params['cookie'].blank? + refute first_message.params['session_id'].blank? + end + + def test_failed_authorize_with_3ds + session_id = generate_unique_id + order_id = @options[:order_id] + options = @options.merge( + { + execute_threed: true, + accept_header: 'text/html', + session_id: session_id, + ip: '127.0.0.1', + cookie: 'machine=32423423' + }) + assert first_message = @gateway.authorize(@amount, @threeDS_card, options) + assert_match %r{missing info for 3D-secure transaction}i, first_message.message + assert first_message.test? + assert first_message.params['issuer_url'].blank? + assert first_message.params['pa_request'].blank? + end + def test_failed_capture assert response = @gateway.capture(@amount, 'bogus') assert_failure response From 6460dad9702a64e433c1db99308a8d8a0cb8b9aa Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Fri, 4 May 2018 11:26:18 -0400 Subject: [PATCH 384/677] EBANX: Interpolate authorization string The + operator was causing problems with error responses that did not contain the expected values. Closes #2830 Remote (4 unrelated failures for "declined" test card not declining): 21 tests, 54 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 80.9524% passed Unit: 16 tests, 54 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/ebanx.rb | 6 +++--- test/remote/gateways/remote_ebanx_test.rb | 2 +- test/unit/gateways/ebanx_test.rb | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d852e266883..b7e39102a1c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,6 +22,7 @@ * CyberSource: Support 3ds validate request [curiousepic] #2823 * Paymentez: Remove card tokenization step from authorize [dtykocki] #2825 * WorldPay: Add 3DS [nfarve] #2819 +* EBANX: Interpolate authorization string [curiousepic] #2830 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb index 2a334766823..353bfd9bacb 100644 --- a/lib/active_merchant/billing/gateways/ebanx.rb +++ b/lib/active_merchant/billing/gateways/ebanx.rb @@ -241,7 +241,7 @@ def message_from(response) def authorization_from(action, parameters, response) if action == :store - response.try(:[], "token") + "|" + CARD_BRAND[parameters[:payment_type_code].to_sym] + "#{response.try(:[], "token")}|#{CARD_BRAND[parameters[:payment_type_code].to_sym]}" else response.try(:[], "payment").try(:[], "hash") end @@ -254,8 +254,8 @@ def post_data(action, parameters = {}) end def url_for(hostname, action, parameters) - return hostname + URL_MAP[action] + "?#{convert_to_url_form_encoded(parameters)}" if requires_http_get(action) - hostname + URL_MAP[action] + return "#{hostname}#{URL_MAP[action]}?#{convert_to_url_form_encoded(parameters)}" if requires_http_get(action) + "#{hostname}#{URL_MAP[action]}" end def requires_http_get(action) diff --git a/test/remote/gateways/remote_ebanx_test.rb b/test/remote/gateways/remote_ebanx_test.rb index 2e50ced72b0..8c8232d24f5 100644 --- a/test/remote/gateways/remote_ebanx_test.rb +++ b/test/remote/gateways/remote_ebanx_test.rb @@ -71,7 +71,7 @@ def test_successful_purchase_as_colombian response = @gateway.purchase(500, @credit_card, options) assert_success response - assert_equal 'Accepted', response.message + assert_equal 'Sandbox - Test credit card, transaction captured', response.message end def test_failed_purchase diff --git a/test/unit/gateways/ebanx_test.rb b/test/unit/gateways/ebanx_test.rb index 76e565fe46f..7504e9c8138 100644 --- a/test/unit/gateways/ebanx_test.rb +++ b/test/unit/gateways/ebanx_test.rb @@ -140,6 +140,14 @@ def test_successful_store_and_purchase assert_success response end + def test_error_response_with_invalid_creds + @gateway.expects(:ssl_request).returns(invalid_cred_response) + + response = @gateway.store(@credit_card, @options) + assert_failure response + assert_equal "Invalid integration key", response.message + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed @@ -230,4 +238,10 @@ def successful_purchase_with_stored_card_response {"payment":{"hash":"59d3e2955021c5e2b180e1ea9670e2d9675c15453a2ab346","pin":"252076123","merchant_payment_code":"a942f8a68836e888fa8e8af1e8ca4bf2","order_number":null,"status":"CO","status_date":"2017-10-03 19:18:45","open_date":"2017-10-03 19:18:44","confirm_date":"2017-10-03 19:18:45","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-10-06","instalments":"1","payment_type_code":"visa","details":{"billing_descriptor":""},"transaction_status":{"acquirer":"EBANX","code":"OK","description":"Accepted"},"pre_approved":true,"capture_available":false,"customer":{"document":"85351346893","email":"unspecified@example.com","name":"NOT PROVIDED","birth_date":null}},"status":"SUCCESS"} ) end + + def invalid_cred_response + %( + {"status":"ERROR","status_code":"DA-1","status_message":"Invalid integration key"} + ) + end end From 61ac694e42d94a9917115b0a33d05f9ab33e9d3f Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Thu, 3 May 2018 11:19:58 -0400 Subject: [PATCH 385/677] CyberSource: Support 3DS validation for authorize Also allows businessRules fields to be passed for 3DS transactions and adds more 3DS tests. Closes #2832 Remote (3 unrelated failures for pinless debit cards): 43 tests, 192 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 93.0233% passed Unit: 45 tests, 217 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/cyber_source.rb | 4 +- .../gateways/remote_cyber_source_test.rb | 39 +++++++++++++++++-- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b7e39102a1c..434cb0a50d0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,7 @@ * Paymentez: Remove card tokenization step from authorize [dtykocki] #2825 * WorldPay: Add 3DS [nfarve] #2819 * EBANX: Interpolate authorization string [curiousepic] #2830 +* CyberSource: Support 3DS validation for authorize [curiousepic] #2832 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 6b1df15c71d..85a1c08a0a0 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -258,7 +258,7 @@ def build_auth_request(money, creditcard_or_reference, options) add_decision_manager_fields(xml, options) add_mdd_fields(xml, options) add_auth_service(xml, creditcard_or_reference, options) - xml.tag! 'payerAuthEnrollService', {'run' => 'true'} if options[:payer_auth_enroll_service] + add_threeds_services(xml, options) add_payment_network_token(xml) if network_tokenization?(creditcard_or_reference) add_business_rules_data(xml, creditcard_or_reference, options) xml.target! @@ -403,7 +403,7 @@ def build_validate_pinless_debit_request(creditcard,options) def add_business_rules_data(xml, payment_method, options) prioritized_options = [options, @options] - unless network_tokenization?(payment_method) || options[:payer_auth_validate_service] + unless network_tokenization?(payment_method) xml.tag! 'businessRules' do xml.tag!('ignoreAVSResult', 'true') if extract_option(prioritized_options, :ignore_avs) xml.tag!('ignoreCVResult', 'true') if extract_option(prioritized_options, :ignore_cvv) diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb index b690e25c5f1..3535e079938 100644 --- a/test/remote/gateways/remote_cyber_source_test.rb +++ b/test/remote/gateways/remote_cyber_source_test.rb @@ -9,12 +9,24 @@ def setup @credit_card = credit_card('4111111111111111', verification_value: '321') @declined_card = credit_card('801111111111111') @pinless_debit_card = credit_card('4002269999999999') + @three_ds_unenrolled_card = credit_card('4000000000000051', + verification_value: '321', + month: "12", + year: "#{Time.now.year + 2}", + brand: :visa + ) @three_ds_enrolled_card = credit_card('4000000000000002', verification_value: '321', month: "12", year: "#{Time.now.year + 2}", brand: :visa ) + @three_ds_invalid_card = credit_card('4000000000000010', + verification_value: '321', + month: "12", + year: "#{Time.now.year + 2}", + brand: :visa + ) @amount = 100 @@ -376,7 +388,6 @@ def test_3ds_enroll_request_via_purchase assert !response.params["paReq"].blank? assert !response.params["xid"].blank? assert !response.success? - puts response.inspect end def test_3ds_enroll_request_via_authorize @@ -389,19 +400,39 @@ def test_3ds_enroll_request_via_authorize end def test_successful_3ds_requests_with_unenrolled_card - assert response = @gateway.purchase(1202, @credit_card, @options.merge(payer_auth_enroll_service: true)) + assert response = @gateway.purchase(1202, @three_ds_unenrolled_card, @options.merge(payer_auth_enroll_service: true)) assert response.success? - assert response = @gateway.authorize(1202, @credit_card, @options.merge(payer_auth_enroll_service: true)) + assert response = @gateway.authorize(1202, @three_ds_unenrolled_card, @options.merge(payer_auth_enroll_service: true)) assert response.success? end - def test_3ds_validate_request + def test_successful_3ds_validate_purchase_request assert response = @gateway.purchase(1202, @three_ds_enrolled_card, @options.merge(payer_auth_validate_service: true, pares: pares)) assert_equal "100", response.params["reasonCode"] + assert_equal "0", response.params["authenticationResult"] assert response.success? end + def test_failed_3ds_validate_purchase_request + assert response = @gateway.purchase(1202, @three_ds_invalid_card, @options.merge(payer_auth_validate_service: true, pares: pares)) + assert_equal "476", response.params["reasonCode"] + assert !response.success? + end + + def test_successful_3ds_validate_authorize_request + assert response = @gateway.authorize(1202, @three_ds_enrolled_card, @options.merge(payer_auth_validate_service: true, pares: pares)) + assert_equal "100", response.params["reasonCode"] + assert_equal "0", response.params["authenticationResult"] + assert response.success? + end + + def test_failed_3ds_validate_authorize_request + assert response = @gateway.authorize(1202, @three_ds_invalid_card, @options.merge(payer_auth_validate_service: true, pares: pares)) + assert_equal "476", response.params["reasonCode"] + assert !response.success? + end + def pares <<-PARES eNqdmFuTqkgSgN+N8D90zD46M4B3J+yOKO6goNyFN25yEUHkUsiv31K7T/ec6dg9u75YlWRlZVVmflWw1uNrGNJa6DfX8G0thVXlRuFLErz+tgm67sRlbJr3ky4G9LWn8N/e1nughtVD4dFawFAodT8OqbBx4NLdj/o8y3JqKlavSLsNr1VS5G/En/if4zX20UUTXf3Yzeu3teuXpCC/TeerMTFfY+/d9Tm8CvRbEB7dJqvX2LO7xj7H7Zt7q0JOd0nwpo3VacjVvMc4pZcXfcjFpMqLc6UHr2vsrrEO3Dp8G+P4Ap+PZy/E9C+c+AtfrrGHfH25mwPnokG2CRxfY18Fa7Q71zD3b2/LKXr0o7cOu0uRh0gDre1He419+nZx8zf87z+kepeu9cPbuk7OX31a3X0iFmvsIV9XtVs31Zu9xt5ba99t2zcAAAksNjsr4N5MVctyGIaN2H6E1vpQWYd+8obPkFPo/zEKZFFxTer4fHf174I1dncFe4Tzba0lUY4mu4Yv3TnLURDjur78hWEQwj/h5M/iGmHIYRzDVxhSCKok+tdvz1FhIOTH4n8aRrl5kSe+myW9W6PEkMI6LoKXH759Z0ZX75YITGWoP5CpP3ximv9xl+ATYoZsYt8b/bKyX5nlZ2evlftHFbvEfYKfDL2t1fAY3jMifDFU4fW3f/1KZdBJFFb1/+PKhxtfLXzYM92sCd8qN5U5lrrNDZOFzkiecUIszvyCVJjXj3FPzTX2w/f3hT2j+GW3noobXm8xXJ3KK2aZztNbVdsLWbbOASZgzSY45eYqFNiK5ReRNLKbzvZSIDJj+zqBzIEkIx1L9ZTabYeDJa/MV51fF9A0dxDvxzf5CiPmttuVVBLHxmZSNp53lnBcJzh+IS3YpejKebycHjQlvMggwkvHdZjhYBHf8M1R4ikKjHxMGxlCfuCv+IqmxjTRk9GMnO2ynnXsWMvZSYdlk+Vmvpz1pVns4v05ugRWIGZNMhxUGLzoqs+VDe14Jtzli63TT06WBvpJg2+2UVLie+5mgGDlEVjip+7EmZhCvRdndtQHmKm0vaUDejhYTRgglbR5qysx6I1gf+vTyWJ3ahaXNOWBUrXRYnwasbKlbi3XsJLNuA3g6+uXrHqPzCa8PSNxmKElubX7bGmNl4Z+LbuIEJT8SrnXIMnd7IUOz8XLI4DX3192xucDQGlI8NmnijOiqR/+/rJ9lRCvCqSv6a+7OCl+f6FeDW2N/TzPY2IqvNbJEdUVwqUkCLTVo32vtAhAgQSRQAFNgLRii5vCEeLWl4HCsKQCoJMyWwmcOEAYDBlLlGlKHa2DLRnJ5nCAhkoksypca9nxKfDvUhIUEmvIsX9WL96ZrZTxqvYs82aPjQi1bz7NaBIJHhYpCEXplJ2GA8ea4a7lXCRVgUxk06ai0DSoDecg4wIvE3ZC0ooOQhbinUQzNyn1OzkFM5kWXSS7PWVKNxx8SCV+2VE9EJ8+2TrITF1ScEjBh3WBgere5bJWUpb3ld9lPAMd+e6JNxGQJS4F9vuKdObLigRGbj2LyPyznEmqAZmnxS0DO9o+iCfXmsUeRZIKIXW8Djy0Tw8rks4yX62omWctI2Oc5d7ZvKGokEIKZDI6lfEp4VYQJ+9RAGBHAWUJ7s+HAyraoB4DSmYSEIl4LuOMDMYCIZJ71pj7U99OwbapLHXFMLI66s7eKosO9qmWU56LwmJCul2tccin+XTKE4tV7EatfZaSNCQFH9bYXMNCetuoK2kl0SN6An3f3xmIMwGIT8KlZZS5pV/wpTIz8FzIF9fhIK6EhVLuzEDAg4MI+sybxjVzA/TGuEmsEHDZbZFBtjKxdKfgilSRZDLRoGjQmpWlzUEZGeJ+7CK6jCNPPgQe2ZInYsxH5YEWZoId7i5G2RJNax3USyCJo1OXS/jNLKdCtZiMSaCR4jKPaXvXqjl/6Et+OMBDRoth7MfSnLa3o7ItpxyV8CZcmjrVbJtyWykIypti158qotvx1VkJTm48GzeYBAUaKIAsJhUcDkL9mUO8KjEgBUCiIEdZFKcBjhsxAkpL5cjGxN7nzMYgZElgguweT/ugZg5F0s5BfGT2cGCPWdzRQfCwpkzRoa8YasSpRuIhBMUdRVxBGyn1FouIkytA/p5XKp4iAEO2AMZRSKQkIPDhgLC0ZSKTIV5IsXXC55ue+a566chmgKyLBwZfHlr7igWzo4Dn4m63WjXm3kMV3G7GNc3KJz9Ur5pt1AxBnafhdFf03bi2pnQlT8pZhWNWN7Mu+6RtWe/I6AbUz1wcFd6puR7FdrSYDwcYP5lcIsJ0ZNh7zOxcqcSFOjoUhaui645OzZ5qHGeazOnrqlxJ1+2eSJtTNOo7bBrgyvIanQyHuh9xP/PqO4BROI0Alp6/AOzbLYAh/asAo/t78d0L1ZdQ/mVerrZ+yoQSCZ+wiqCpjNmbw2WNbXW0NyZqFNzU0Uh0dHgTEUqqABnwhAENTjfNUu9WLs751LE60N8xINGsmvkTJTLOqzag/g624UDS72hjelmXP9GmKz9kEmf/R7DR4Ak2ZEmdQv7pz4YmzU84fQHYHWZ+DjomBcrTYiVRuig6KJ1R5Z5dhD5kiRQeewAg3Jqc2SOv+8ASIgVnYOQsf9558pl8OIIWJ4KCQ4u+QWKmIqgK7g5MOZ+0XJ4jemPuucVRUPf5rma5LL6U7RxuXQ4ax+NodrIvC4k53wRDanhGdkGrnhJRq2/UajccHM67ebQItvRyk3PEnFrl1y5dFuT0PEFYMqbn0dG2dlx+js/7Yt7HZFuSVXvsV5OYiTYHec4EG7kxo+GgKfvamoPtDhry3CPLjaJN7okBAJeGPTl7z5+AgQolAQC3wBZtwRGA7U2ViJFJcmnxxgo+jjHdwGGkjs0G5UYccOYJ7XDmP7IgS+9QkEj8YY2OFIsk1WUi3MTJQTed7U3A2YUW3Vh3OND14irp4PiAhSYxHA2siFSZKN1jhOVFme2MOa7LKcst80SEKId+OjqM+9GBjoxIIZfNxsBWkyVmbmYUa4iJghm7gzu+8jeiAxMvJwhiR80zcl4FSr2Q01jx442ebHWlimZHrNQymRgOto7dtFMgbPTdxmG4ayKWQJ+Lp3K0OcQ1rU2jtLyw+XKXOqWoLo7ulVFHgTebYaLWXho+Sr1OPy7AcHCGCar/njbEqWk2ib1Z6iWb3cbm1eTZ6PVXIdCmCAJJ+AEBEYh0tx8xmanGGwngHKWVnCZ4E/qRkgaQ+OgfpYOS+5vi+XoroMHnreA/3XIQBP7LPefzlvPj1oBuOd3zlsOKrYegcC+p4YCPfRmFv5NSZiLpNpR1cLPusvQhw3/IUnIqKRWknr5yDBRNo2dkCVSPmdGNAUBGH8cXr2f29z15gBBCTrfuBb66/SokhoP/gglTIqUPSEjvkNC88QpHo0kEguNHRIaDj5igJAWIBjKgKTJRNmSkUNPwevRaVWGow9Vezev9QtlZJaWDcZpjs3SywiKsxD0p8RVKHQ6u49ExWZz6zY28KaVz4ntbnC0nGDi0G9GFeM2id5cJkwbRKezMS2ZrYcnsZzuDlqaRqx0XJS9F5h6VycYt8nF7TfnOCimzY5NpNyWLIBPzY4ZhNZdu8FKm+3pxwqZyqLHWzSsT5f2mQACop8+THcXu42wXhB5bmeepaHFBHFcOzM7lZZr4DPOPs/073eHgQ5sGD22dBAZE4SSx/vtijxSQsEuSy0gWSqEshkxiw9xVEJhqg78mbmrU3nxGzJe1fLxwDDO59rxHzgrpzPiHrvK8WlDJpo33y3MdhU7GZ81W6fFSHfnjYpbBcDjo4CLNjoAvSxRlLaU2W76plphc5At/tEhKra8VXiLN0FuM59Ddt5zgHZitL1vFyttHamkZ44sToxvD5ubwK/BtsWOfr03Yj1epz5esx7ekx8eu+/ePrx/B/g0UAjN8 From 48440c1fb7979faf2a1129014dac3d14c2966b39 Mon Sep 17 00:00:00 2001 From: Filipe Costa <filipebarcos@users.noreply.github.com> Date: Tue, 8 May 2018 10:18:44 -0400 Subject: [PATCH 386/677] Adding 3D Secure pass thru capabilities to Braintree (#2834) This is simply adding support to `:three_d_secure_pass_thru` params for Braintree, documented here: https://developers.braintreepayments.com/reference/request/transaction/sale/ruby#three_d_secure_pass_thru --- .../billing/gateways/braintree_blue.rb | 10 +++++++++- test/remote/gateways/remote_braintree_blue_test.rb | 8 ++++++++ .../gateways/remote_braintree_orange_test.rb | 8 +++++++- test/unit/gateways/braintree_blue_test.rb | 14 ++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 2a791d05494..6651dcc6d52 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -558,7 +558,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) :hold_in_escrow => options[:hold_in_escrow], } } - + if options[:skip_advanced_fraud_checking] parameters[:options].merge!({ :skip_advanced_fraud_checking => options[:skip_advanced_fraud_checking] }) end @@ -634,6 +634,14 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) } end + if options[:three_d_secure] + parameters[:three_d_secure_pass_thru] = { + cavv: options[:three_d_secure][:cavv], + eci_flag: options[:three_d_secure][:eci], + xid: options[:three_d_secure][:xid], + } + end + parameters end end diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index 0066bc496b2..cf060f773d2 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -368,6 +368,14 @@ def test_successful_purchase_with_addresses assert_equal 'Mexico', transaction["shipping_details"]["country_name"] end + def test_successful_purchase_with_three_d_secure_pass_thru + three_d_secure_params = { eci: "05", cavv: "cavv", xid: "xid" } + assert response = @gateway.purchase(@amount, @credit_card, + three_d_secure: three_d_secure_params + ) + assert_success response + end + def test_unsuccessful_purchase_declined assert response = @gateway.purchase(@declined_amount, @credit_card, @options) assert_failure response diff --git a/test/remote/gateways/remote_braintree_orange_test.rb b/test/remote/gateways/remote_braintree_orange_test.rb index 8bde4c2f561..8468633afbf 100644 --- a/test/remote/gateways/remote_braintree_orange_test.rb +++ b/test/remote/gateways/remote_braintree_orange_test.rb @@ -142,6 +142,12 @@ def test_failed_capture assert response.message.match(/Invalid Transaction ID \/ Object ID specified:/) end + def test_authorize_with_three_d_secure_pass_thru + assert auth = @gateway.authorize(@amount, @credit_card, @options.merge(eci: "05", xid: "xid", cavv: "cavv")) + assert_success auth + assert_equal 'This transaction has been approved', auth.message + end + def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response @@ -170,7 +176,7 @@ def test_transcript_scrubbing @gateway.purchase(@declined_amount, @credit_card, @options) end clean_transcript = @gateway.scrub(transcript) - + assert_scrubbed(@credit_card.number, clean_transcript) assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript) end diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index bd9ad5d99f3..c022cfcec74 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -513,6 +513,20 @@ def test_cardholder_name_passing_with_card @gateway.purchase(100, credit_card("41111111111111111111"), :customer => {:first_name => "Longbob", :last_name => "Longsen"}) end + def test_three_d_secure_pass_thru_handling + Braintree::TransactionGateway. + any_instance. + expects(:sale). + with(has_entries(three_d_secure_pass_thru: { + cavv: "cavv", + eci_flag: "eci", + xid: "xid", + })). + returns(braintree_result) + + @gateway.purchase(100, credit_card("41111111111111111111"), three_d_secure: {cavv: "cavv", eci: "eci", xid: "xid"}) + end + def test_passes_recurring_flag @gateway = BraintreeBlueGateway.new( :merchant_id => 'test', From 4e1fe6aeecacccf4968ae428d27b090ac37628ee Mon Sep 17 00:00:00 2001 From: JoseLuis Vilar <Gjoseluisvilar@gmail.com> Date: Mon, 7 May 2018 09:46:40 +0200 Subject: [PATCH 387/677] Redsys: Fix ISO code for PLN wrong iso code for PLN Closes #2831 Remote (2 unrelated void failures): 18 tests, 51 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 88.8889% passed Unit: 32 tests, 95 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/redsys.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 434cb0a50d0..c7c0dc1c696 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,7 @@ * WorldPay: Add 3DS [nfarve] #2819 * EBANX: Interpolate authorization string [curiousepic] #2830 * CyberSource: Support 3DS validation for authorize [curiousepic] #2832 +* Redsys: Fix ISO code for PLN [chopenhauer] #2831 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb index 9ab1264a196..8611832637d 100644 --- a/lib/active_merchant/billing/gateways/redsys.rb +++ b/lib/active_merchant/billing/gateways/redsys.rb @@ -75,7 +75,7 @@ class RedsysGateway < Gateway "NOK" => '578', "NZD" => '554', "PEN" => '604', - "PLN" => '616', + "PLN" => '985', "RUB" => '643', "SAR" => '682', "SEK" => '752', From bd6efefccf60552865b052751c96307b6af53679 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 8 May 2018 16:15:36 -0400 Subject: [PATCH 388/677] Merchant E Solutions: Support transcript scrubbing Closes #2836 Remote: 18 tests, 77 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 94.4444% passed Unit: 20 tests, 99 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/merchant_e_solutions.rb | 11 +++++++++++ .../remote_merchant_e_solutions_test.rb | 12 ++++++++++++ .../gateways/merchant_e_solutions_test.rb | 19 +++++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index c7c0dc1c696..52bbf4280b6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -25,6 +25,7 @@ * EBANX: Interpolate authorization string [curiousepic] #2830 * CyberSource: Support 3DS validation for authorize [curiousepic] #2832 * Redsys: Fix ISO code for PLN [chopenhauer] #2831 +* Merchant E Solutions: Support transcript scrubbing [curiousepic] #2836 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb index f27adf3e306..8a855661cbe 100644 --- a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +++ b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb @@ -94,6 +94,17 @@ def void(transaction_id, options = {}) commit('V', nil, options.merge(post)) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((&?profile_key=)\w*(&?)), '\1[FILTERED]\2'). + gsub(%r((&?card_number=)\d*(&?)), '\1[FILTERED]\2'). + gsub(%r((&?cvv2=)\d*(&?)), '\1[FILTERED]\2') + end + private def add_address(post, options) diff --git a/test/remote/gateways/remote_merchant_e_solutions_test.rb b/test/remote/gateways/remote_merchant_e_solutions_test.rb index ca016efb882..8e60553c49a 100644 --- a/test/remote/gateways/remote_merchant_e_solutions_test.rb +++ b/test/remote/gateways/remote_merchant_e_solutions_test.rb @@ -198,4 +198,16 @@ def test_successful_purchase_with_3dsecure_params assert_success response assert_equal 'This transaction has been approved', response.message end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_match(%r{cvv2\=\[FILTERED\]}, transcript) + assert_no_match(%r{cvv2=#{@credit_card.verification_value}}, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end end diff --git a/test/unit/gateways/merchant_e_solutions_test.rb b/test/unit/gateways/merchant_e_solutions_test.rb index a213ffde63c..a2bfa44a318 100644 --- a/test/unit/gateways/merchant_e_solutions_test.rb +++ b/test/unit/gateways/merchant_e_solutions_test.rb @@ -167,6 +167,11 @@ def test_supported_card_types assert_equal [:visa, :master, :american_express, :discover, :jcb], MerchantESolutionsGateway.supported_cardtypes end + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + private def successful_purchase_response @@ -200,4 +205,18 @@ def successful_unstore_response def failed_purchase_response 'transaction_id=error&error_code=101&auth_response_text=Invalid%20I%20or%20Key%20Incomplete%20Request' end + + def pre_scrubbed + <<-TRANSCRIPT + "profile_id=94100010518900000029&profile_key=YvKeIpxLxpJoKRKkJjMOpqmGkwUCBBEO&transaction_type=D&invoice_number=123&card_number=4111111111111111&cvv2=123&card_exp_date=0919&cardholder_street_address=123%2BState%2BStreet&cardholder_zip=55555&transaction_amount=1.00" + "transaction_id=3dfdc828adf032d589111ff45a7087fc&error_code=000&auth_response_text=Exact Match&avs_result=Y&cvv2_result=M&auth_code=T4797H" + TRANSCRIPT + end + + def post_scrubbed + <<-TRANSCRIPT + "profile_id=94100010518900000029&profile_key=[FILTERED]&transaction_type=D&invoice_number=123&card_number=[FILTERED]&cvv2=[FILTERED]&card_exp_date=0919&cardholder_street_address=123%2BState%2BStreet&cardholder_zip=55555&transaction_amount=1.00" + "transaction_id=3dfdc828adf032d589111ff45a7087fc&error_code=000&auth_response_text=Exact Match&avs_result=Y&cvv2_result=M&auth_code=T4797H" + TRANSCRIPT + end end From a834bc4a682ea9b1bcdaf4f98fba8825c7d6143f Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 8 May 2018 16:28:45 -0400 Subject: [PATCH 389/677] Paystation: Support transcript scrubbing Closes #2837 Remote (2 unrelated failures): 12 tests, 49 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 83.3333% passed Unit: 10 tests, 52 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/paystation.rb | 10 ++++++++++ test/remote/gateways/remote_paystation_test.rb | 10 ++++++++++ test/unit/gateways/paystation_test.rb | 13 +++++++++++++ 4 files changed, 34 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 52bbf4280b6..5faf218b899 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,7 @@ * CyberSource: Support 3DS validation for authorize [curiousepic] #2832 * Redsys: Fix ISO code for PLN [chopenhauer] #2831 * Merchant E Solutions: Support transcript scrubbing [curiousepic] #2836 +* Paystation: Support transcript scrubbing [curiousepic] #2837 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/paystation.rb b/lib/active_merchant/billing/gateways/paystation.rb index 781952b0ac3..0eedd12f0fb 100644 --- a/lib/active_merchant/billing/gateways/paystation.rb +++ b/lib/active_merchant/billing/gateways/paystation.rb @@ -88,6 +88,16 @@ def verify(credit_card, options={}) authorize(0, credit_card, options) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((pstn_cn=)\d*), '\1[FILTERED]'). + gsub(%r((pstn_cc=)\d*), '\1[FILTERED]') + end + private def new_request diff --git a/test/remote/gateways/remote_paystation_test.rb b/test/remote/gateways/remote_paystation_test.rb index 691cf66ccd1..a66abd7e4ef 100644 --- a/test/remote/gateways/remote_paystation_test.rb +++ b/test/remote/gateways/remote_paystation_test.rb @@ -115,4 +115,14 @@ def test_successful_verify assert_success response assert_match %r{Transaction successful}, response.message end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + end end diff --git a/test/unit/gateways/paystation_test.rb b/test/unit/gateways/paystation_test.rb index 6fa03c4715b..c4550e4d37e 100644 --- a/test/unit/gateways/paystation_test.rb +++ b/test/unit/gateways/paystation_test.rb @@ -113,6 +113,11 @@ def test_successful_verify assert_success response end + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + private def successful_purchase_response @@ -415,4 +420,12 @@ def failed_refund_response <FONT FACE="Arial" SIZE="2"><strong>Error 11:</strong> Not enough input parameters.</FONT>) end + def pre_scrubbed + "pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=5123456789012346&pstn_ct=visa&pstn_ex=1305&pstn_cc=123&pstn_tm=T&paystation=_empty" + end + + def post_scrubbed + "pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=[FILTERED]&pstn_ct=visa&pstn_ex=1305&pstn_cc=[FILTERED]&pstn_tm=T&paystation=_empty" + end + end From dad403d11d6df41dde83018e3dabfc9e29ccbf87 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 8 May 2018 15:14:12 -0400 Subject: [PATCH 390/677] Psigate: Support transcript scrubbing Closes #2835 Remote: 7 tests, 23 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 12 tests, 30 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/psigate.rb | 11 +++++++++++ test/remote/gateways/remote_psigate_test.rb | 11 +++++++++++ test/unit/gateways/psigate_test.rb | 19 +++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 5faf218b899..6a03adc7de8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -27,6 +27,7 @@ * Redsys: Fix ISO code for PLN [chopenhauer] #2831 * Merchant E Solutions: Support transcript scrubbing [curiousepic] #2836 * Paystation: Support transcript scrubbing [curiousepic] #2837 +* Psigate: Support transcript scrubbing [curiousepic] #2835 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/psigate.rb b/lib/active_merchant/billing/gateways/psigate.rb index aa9a5fa53f1..4ec3039f78a 100644 --- a/lib/active_merchant/billing/gateways/psigate.rb +++ b/lib/active_merchant/billing/gateways/psigate.rb @@ -86,6 +86,17 @@ def void(authorization, options = {}) commit(nil, nil, options) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((<Passphrase>)[^<]*(</Passphrase>))i, '\1[FILTERED]\2'). + gsub(%r((<CardNumber>)[^<]*(</CardNumber>))i, '\1[FILTERED]\2'). + gsub(%r((<CardIDNumber>)[^<]*(</CardIDNumber>))i, '\1[FILTERED]\2') + end + private def commit(money, creditcard, options = {}) diff --git a/test/remote/gateways/remote_psigate_test.rb b/test/remote/gateways/remote_psigate_test.rb index ea414c797da..74d643794fe 100644 --- a/test/remote/gateways/remote_psigate_test.rb +++ b/test/remote/gateways/remote_psigate_test.rb @@ -56,4 +56,15 @@ def test_successful_void assert void = @gateway.void(authorization.authorization) assert_success void end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @creditcard, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@creditcard.number, transcript) + assert_scrubbed(@creditcard.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end end diff --git a/test/unit/gateways/psigate_test.rb b/test/unit/gateways/psigate_test.rb index 92e85e08ab2..b3c76703c65 100644 --- a/test/unit/gateways/psigate_test.rb +++ b/test/unit/gateways/psigate_test.rb @@ -87,6 +87,11 @@ def test_cvv_result assert_equal 'M', response.cvv_result['code'] end + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + private def successful_authorization_response @@ -186,4 +191,18 @@ def xml_purchase_fixture def xml_capture_fixture '<?xml version="1.0"?><Order><OrderID>1004</OrderID><CardAction>2</CardAction><StoreID>teststore</StoreID><PaymentType>CC</PaymentType><SubTotal>20.00</SubTotal><Passphrase>psigate1234</Passphrase></Order>' end + + def pre_scrubbed + <<-PRE_SCRUBBED + <?xml version='1.0'?><Order><StoreID>teststore</StoreID><Passphrase>psigate1234</Passphrase><OrderID>1b7b4b36bf61e972a9e6a6be8fff15d8</OrderID><Email>jack@example.com</Email><PaymentType>CC</PaymentType><CardAction>0</CardAction><SubTotal>24.00</SubTotal><CardNumber>4242424242424242</CardNumber><CardExpMonth>09</CardExpMonth><CardExpYear>14</CardExpYear><CardIDCode>1</CardIDCode><CardIDNumber>123</CardIDNumber><Bname>Jim Smith</Bname><Baddress1>1234 My Street</Baddress1><Baddress2>Apt 1</Baddress2><Bcity>Ottawa</Bcity><Bprovince>ON</Bprovince><Bpostalcode>K1C2N6</Bpostalcode><Bcountry>CA</Bcountry><Bcompany>Widgets Inc</Bcompany></Order> + <CardNumber>......4242</CardNumber> + PRE_SCRUBBED + end + + def post_scrubbed + <<-POST_SCRUBBED + <?xml version='1.0'?><Order><StoreID>teststore</StoreID><Passphrase>[FILTERED]</Passphrase><OrderID>1b7b4b36bf61e972a9e6a6be8fff15d8</OrderID><Email>jack@example.com</Email><PaymentType>CC</PaymentType><CardAction>0</CardAction><SubTotal>24.00</SubTotal><CardNumber>[FILTERED]</CardNumber><CardExpMonth>09</CardExpMonth><CardExpYear>14</CardExpYear><CardIDCode>1</CardIDCode><CardIDNumber>[FILTERED]</CardIDNumber><Bname>Jim Smith</Bname><Baddress1>1234 My Street</Baddress1><Baddress2>Apt 1</Baddress2><Bcity>Ottawa</Bcity><Bprovince>ON</Bprovince><Bpostalcode>K1C2N6</Bpostalcode><Bcountry>CA</Bcountry><Bcompany>Widgets Inc</Bcompany></Order> + <CardNumber>[FILTERED]</CardNumber> + POST_SCRUBBED + end end From 1ddb0a0bb673e69bdd776f74bd135827b98aa2a4 Mon Sep 17 00:00:00 2001 From: Filipe Costa <filipebarcos@users.noreply.github.com> Date: Fri, 11 May 2018 08:34:43 -0400 Subject: [PATCH 391/677] Authorize.net: Add flexibility for 3D Secure Parameters (#2844) * Authorize.net: Add flexibility for 3D Secure Parameters This adds flexibility for passing in 3D Secure Parameters. Current implementation already supports is but with very specific options, this will give some sort of standard for other gateways to follow. Braintree implementation already supports it per #2834 * Missing CHANGELOG entry for PR#2834 --- CHANGELOG | 2 ++ .../billing/gateways/authorize_net.rb | 7 ++-- test/unit/gateways/authorize_net_test.rb | 32 +++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6a03adc7de8..2bd59186fb4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -28,6 +28,8 @@ * Merchant E Solutions: Support transcript scrubbing [curiousepic] #2836 * Paystation: Support transcript scrubbing [curiousepic] #2837 * Psigate: Support transcript scrubbing [curiousepic] #2835 +* Braintree: Adding 3D Secure pass thru capabilities [filipebarcos] #2843 +* Authorize.net: Add flexibility for 3D Secure Parameters [filipebarcos] #2844 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index 3cc43832175..be4125c1c56 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -552,8 +552,11 @@ def add_customer_data(xml, payment_source, options) xml.customerIP(options[:ip]) unless empty?(options[:ip]) xml.cardholderAuthentication do - xml.authenticationIndicator(options[:authentication_indicator]) - xml.cardholderAuthenticationValue(options[:cardholder_authentication_value]) + three_d_secure = options.fetch(:three_d_secure, {}) + xml.authenticationIndicator( + options[:authentication_indicator] || three_d_secure[:eci]) + xml.cardholderAuthenticationValue( + options[:cardholder_authentication_value] || three_d_secure[:cavv]) end end diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 938ca3e7697..f5e521ef3b5 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -741,6 +741,38 @@ def test_add_cardholder_authentication_value end.respond_with(successful_purchase_response) end + def test_alternative_three_d_secure_options + three_d_secure_opts = { cavv: 'E0Mvq8AAABEiMwARIjNEVWZ3iJk=', eci: '2' } + stub_comms do + @gateway.purchase(@amount, @credit_card, three_d_secure: three_d_secure_opts) + end.check_request do |endpoint, data, headers| + parse(data) do |doc| + assert_equal "E0Mvq8AAABEiMwARIjNEVWZ3iJk=", doc.at_xpath("//cardholderAuthentication/cardholderAuthenticationValue").content + assert_equal "2", doc.at_xpath("//cardholderAuthentication/authenticationIndicator").content + assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + end + end.respond_with(successful_purchase_response) + end + + def test_prioritize_authentication_value_params + three_d_secure_opts = { cavv: 'fake', eci: 'fake' } + stub_comms do + @gateway.purchase( + @amount, + @credit_card, + cardholder_authentication_value: 'E0Mvq8AAABEiMwARIjNEVWZ3iJk=', + authentication_indicator: "2", + three_d_secure: three_d_secure_opts + ) + end.check_request do |endpoint, data, headers| + parse(data) do |doc| + assert_equal "E0Mvq8AAABEiMwARIjNEVWZ3iJk=", doc.at_xpath("//cardholderAuthentication/cardholderAuthenticationValue").content + assert_equal "2", doc.at_xpath("//cardholderAuthentication/authenticationIndicator").content + assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + end + end.respond_with(successful_purchase_response) + end + def test_capture_passing_extra_info response = stub_comms do @gateway.capture(50, '123456789', description: "Yo", order_id: "Sweetness") From 65c9a7a7090780b505ebe3eda1201f2681cd5e5a Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Wed, 9 May 2018 16:50:53 -0400 Subject: [PATCH 392/677] Elavon: Update Country List Updates the list of countries for Elavon to include Mexico. Loaded suite test/remote/gateways/remote_elavon_test ........................ 24 tests, 105 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/elavon_test ............................. 29 tests, 141 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/elavon.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 2bd59186fb4..6ce6741fc27 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -30,6 +30,7 @@ * Psigate: Support transcript scrubbing [curiousepic] #2835 * Braintree: Adding 3D Secure pass thru capabilities [filipebarcos] #2843 * Authorize.net: Add flexibility for 3D Secure Parameters [filipebarcos] #2844 +* Elavon: Update Country List [nfarve] #2840 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb index 2e160ed9343..ddf36f296d2 100644 --- a/lib/active_merchant/billing/gateways/elavon.rb +++ b/lib/active_merchant/billing/gateways/elavon.rb @@ -11,7 +11,7 @@ class ElavonGateway < Gateway self.live_url = 'https://api.convergepay.com/VirtualMerchant/process.do' self.display_name = 'Elavon MyVirtualMerchant' - self.supported_countries = %w(US CA PR DE IE NO PL LU BE NL) + self.supported_countries = %w(US CA PR DE IE NO PL LU BE NL MX) self.supported_cardtypes = [:visa, :master, :american_express, :discover] self.homepage_url = 'http://www.elavon.com/' From 48cdef287bf1a3c042295f41905c744d8b10f0c8 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Wed, 9 May 2018 17:03:25 -0400 Subject: [PATCH 393/677] WorldPay: Update Country List Updates the Country list for Worldpay Loaded suite test/unit/gateways/worldpay_test ..................................... 37 tests, 210 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_worldpay_test 25 tests, 84 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 84% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/worldpay.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 6ce6741fc27..5d35ada8976 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -31,6 +31,7 @@ * Braintree: Adding 3D Secure pass thru capabilities [filipebarcos] #2843 * Authorize.net: Add flexibility for 3D Secure Parameters [filipebarcos] #2844 * Elavon: Update Country List [nfarve] #2840 +* WorldPay: Update Country List [nfarve] #2841 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index 4f49f1b2915..f6864fb3752 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -6,7 +6,7 @@ class WorldpayGateway < Gateway self.default_currency = 'GBP' self.money_format = :cents - self.supported_countries = %w(HK GB AU AD BE CH CY CZ DE DK ES FI FR GI GR HU IE IT LI LU MC MT NL NO NZ PL PT SE SG SI SM TR UM VA) + self.supported_countries = %w(HK GB AU AD AR BE BR CA CH CN CO CR CY CZ DE DK ES FI FR GI GR HU IE IN IT JP LI LU MC MT MY MX NL NO NZ PA PE PL PT SE SG SI SM TR UM VA) self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :laser, :switch] self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW) self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND) From 0c4d3ae833592a342de389c6413b5a8858241c25 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Wed, 9 May 2018 16:04:44 -0400 Subject: [PATCH 394/677] Merchant Warrior: Support transcript scrubbing Most of the remote tests fail mostly due to test-account decay, but the scrubbing tests are good and should be sufficiently exercised even in this state. Closes #2845 Remote: 11 tests, 37 assertions, 7 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 36.3636% passed Unit: 10 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/merchant_warrior.rb | 12 +++++++++ .../gateways/remote_merchant_warrior_test.rb | 27 ++++++++++++++++++- test/unit/gateways/merchant_warrior_test.rb | 13 +++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 5d35ada8976..d4df45fca2e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -32,6 +32,7 @@ * Authorize.net: Add flexibility for 3D Secure Parameters [filipebarcos] #2844 * Elavon: Update Country List [nfarve] #2840 * WorldPay: Update Country List [nfarve] #2841 +* Merchant Warrior: Support transcript scrubbing [curiousepic] #2845 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/merchant_warrior.rb b/lib/active_merchant/billing/gateways/merchant_warrior.rb index 30e34e4edb3..52495836532 100644 --- a/lib/active_merchant/billing/gateways/merchant_warrior.rb +++ b/lib/active_merchant/billing/gateways/merchant_warrior.rb @@ -68,6 +68,18 @@ def store(creditcard, options = {}) commit('addCard', post) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((&?paymentCardNumber=)[^&]*)i, '\1[FILTERED]'). + gsub(%r((CardNumber=)[^&]*)i, '\1[FILTERED]'). + gsub(%r((&?paymentCardCSC=)[^&]*)i, '\1[FILTERED]'). + gsub(%r((&?apiKey=)[^&]*)i, '\1[FILTERED]') + end + private def add_transaction(post, identification) diff --git a/test/remote/gateways/remote_merchant_warrior_test.rb b/test/remote/gateways/remote_merchant_warrior_test.rb index 30abcc7684e..ade8d20e594 100644 --- a/test/remote/gateways/remote_merchant_warrior_test.rb +++ b/test/remote/gateways/remote_merchant_warrior_test.rb @@ -10,7 +10,7 @@ def setup @credit_card = credit_card( '5123456789012346', :month => 5, - :year => 17, + :year => Time.now.year + 2, :verification_value => '123', :brand => 'master' ) @@ -113,4 +113,29 @@ def test_successful_purchase_with_funky_names assert_equal 'Transaction approved', purchase.message assert_success purchase end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@success_amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_match(%r{paymentCardCSC\=\[FILTERED\]}, transcript) + assert_no_match(%r{paymentCardCSC=#{@credit_card.verification_value}}, transcript) + assert_scrubbed(@gateway.options[:api_passphrase], transcript) + assert_scrubbed(@gateway.options[:api_key], transcript) + end + + def test_transcript_scrubbing_store + transcript = capture_transcript(@gateway) do + @gateway.store(@credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:api_passphrase], transcript) + assert_scrubbed(@gateway.options[:api_key], transcript) + end end diff --git a/test/unit/gateways/merchant_warrior_test.rb b/test/unit/gateways/merchant_warrior_test.rb index 8b9da664447..613e8e52511 100644 --- a/test/unit/gateways/merchant_warrior_test.rb +++ b/test/unit/gateways/merchant_warrior_test.rb @@ -139,6 +139,11 @@ def test_orderid_truncated end.respond_with(successful_purchase_response) end + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + private def successful_purchase_response @@ -216,4 +221,12 @@ def successful_store_response </mwResponse> XML end + + def pre_scrubbed + %q(transactionAmount=1.00&transactionCurrency=AUD&hash=adb50f6ff360f861e6f525e8daae76b5&transactionProduct=98fc25d40a47f3d24da460c0ca307c&customerName=Longbob+Longsen&customerCountry=AU&customerState=Queensland&customerCity=Brisbane&customerAddress=123+test+st&customerPostCode=4000&customerIP=&customerPhone=&customerEmail=&paymentCardNumber=5123456789012346&paymentCardName=Longbob+Longsen&paymentCardExpiry=0520&paymentCardCSC=123&merchantUUID=51f7da294af8f&apiKey=nooudtd0&method=processCard) + end + + def post_scrubbed + %q(transactionAmount=1.00&transactionCurrency=AUD&hash=adb50f6ff360f861e6f525e8daae76b5&transactionProduct=98fc25d40a47f3d24da460c0ca307c&customerName=Longbob+Longsen&customerCountry=AU&customerState=Queensland&customerCity=Brisbane&customerAddress=123+test+st&customerPostCode=4000&customerIP=&customerPhone=&customerEmail=&paymentCardNumber=[FILTERED]&paymentCardName=Longbob+Longsen&paymentCardExpiry=0520&paymentCardCSC=[FILTERED]&merchantUUID=51f7da294af8f&apiKey=[FILTERED]&method=processCard) + end end From 117cd37d75b641d74fff84f2dc41fe3e0646205f Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Mon, 16 Apr 2018 16:21:33 -0400 Subject: [PATCH 395/677] NAB Transact: Pass nonfractional amounts correctly Also updates test url, but there are still remote test failures using the "Card Acceptor" (flag on the test account) and the "Periodic" endpoint (which is failing connection). But these are unrelated to the change. Closes #2843 Remote: 22 tests, 54 assertions, 4 failures, 6 errors, 0 pendings, 0 omissions, 0 notifications 54.5455% passed Unit: 18 tests, 75 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/nab_transact.rb | 8 ++++---- test/remote/gateways/remote_nab_transact_test.rb | 2 +- test/unit/gateways/nab_transact_test.rb | 8 ++++++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d4df45fca2e..14e7b9e3cd9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -33,6 +33,7 @@ * Elavon: Update Country List [nfarve] #2840 * WorldPay: Update Country List [nfarve] #2841 * Merchant Warrior: Support transcript scrubbing [curiousepic] #2845 +* NAB Transact: Pass nonfractional amounts correctly [curiousepic] #2843 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/nab_transact.rb b/lib/active_merchant/billing/gateways/nab_transact.rb index 4c5f5102ca7..446450f4322 100644 --- a/lib/active_merchant/billing/gateways/nab_transact.rb +++ b/lib/active_merchant/billing/gateways/nab_transact.rb @@ -10,7 +10,7 @@ class NabTransactGateway < Gateway class_attribute :test_periodic_url, :live_periodic_url - self.test_url = 'https://transact.nab.com.au/test/xmlapi/payment' + self.test_url = 'https://demo.transact.nab.com.au/xmlapi/payment' self.live_url = 'https://transact.nab.com.au/live/xmlapi/payment' self.test_periodic_url = 'https://transact.nab.com.au/xmlapidemo/periodic' self.live_periodic_url = 'https://transact.nab.com.au/xmlapi/periodic' @@ -104,7 +104,7 @@ def add_metadata(xml, options) def build_purchase_request(money, credit_card, options) xml = Builder::XmlMarkup.new - xml.tag! 'amount', amount(money) + xml.tag! 'amount', localized_amount(money, options[:currency] || currency(money)) xml.tag! 'currency', options[:currency] || currency(money) xml.tag! 'purchaseOrderNo', options[:order_id].to_s.gsub(/[ ']/, '') @@ -124,7 +124,7 @@ def build_reference_request(money, reference, options) transaction_id, order_id, preauth_id, original_amount = reference.split('*') - xml.tag! 'amount', (money ? amount(money) : original_amount) + xml.tag! 'amount', (money ? localized_amount(money, options[:currency] || currency(money)) : original_amount) xml.tag! 'currency', options[:currency] || currency(money) xml.tag! 'txnID', transaction_id xml.tag! 'purchaseOrderNo', order_id @@ -205,7 +205,7 @@ def build_purchase_using_stored_card_request(money, identification, options) xml.tag! 'crn', identification xml.tag! 'currency', options[:currency] || currency(money) - xml.tag! 'amount', amount(money) + xml.tag! 'amount', localized_amount(money, options[:currency] || currency(money)) xml.target! end diff --git a/test/remote/gateways/remote_nab_transact_test.rb b/test/remote/gateways/remote_nab_transact_test.rb index 5eb8eac4b33..4892a5a47de 100644 --- a/test/remote/gateways/remote_nab_transact_test.rb +++ b/test/remote/gateways/remote_nab_transact_test.rb @@ -177,7 +177,7 @@ def test_failed_refund authorization = response.authorization assert response = @gateway.refund(@amount+1, authorization) assert_failure response - assert_equal 'Only $2.0 available for refund', response.message + assert_equal 'Only 2.00 AUD available for refund', response.message end def test_invalid_login diff --git a/test/unit/gateways/nab_transact_test.rb b/test/unit/gateways/nab_transact_test.rb index a10e2a44ee6..e4c56bb818b 100644 --- a/test/unit/gateways/nab_transact_test.rb +++ b/test/unit/gateways/nab_transact_test.rb @@ -153,6 +153,14 @@ def test_override_request_timeout end.respond_with(successful_purchase_response) end + def test_nonfractional_currencies + stub_comms(@gateway, :ssl_request) do + @gateway.authorize(10000, @credit_card, @options.merge(currency: 'JPY')) + end.check_request do |method, endpoint, data, headers| + assert_match(/<amount>100<\/amount>/, data) + end.respond_with(successful_authorize_response) + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed From e29966b4a7b52a1a6d4d171361087c6a56fed7d1 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Wed, 9 May 2018 17:09:44 -0400 Subject: [PATCH 396/677] Realex: Update Country List Updates Country List for Realex to include Spain. Loaded suite test/unit/gateways/realex_test 21 tests, 439 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ------ Loaded suite test/remote/gateways/remote_realex_test 20 tests, 108 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/realex.rb | 2 +- test/unit/gateways/realex_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index ecc3150c992..64f3e3e2fbd 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -35,7 +35,7 @@ class RealexGateway < Gateway self.money_format = :cents self.default_currency = 'EUR' self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ] - self.supported_countries = %w(IE GB FR BE NL LU IT US CA) + self.supported_countries = %w(IE GB FR BE NL LU IT US CA ES) self.homepage_url = 'http://www.realexpayments.com/' self.display_name = 'Realex' diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb index 67747a11313..7a4deb75db2 100644 --- a/test/unit/gateways/realex_test.rb +++ b/test/unit/gateways/realex_test.rb @@ -95,7 +95,7 @@ def test_deprecated_credit end def test_supported_countries - assert_equal ['IE', 'GB', "FR", "BE", "NL", "LU", "IT", "US", "CA"], RealexGateway.supported_countries + assert_equal ['IE', 'GB', "FR", "BE", "NL", "LU", "IT", "US", "CA", "ES"], RealexGateway.supported_countries end def test_supported_card_types From 8186e176e1f61b68beecb41dbd95260257fc6d8a Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Mon, 14 May 2018 16:21:35 -0400 Subject: [PATCH 397/677] Update Changelog Updates changelog with latest PR merge. --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 14e7b9e3cd9..d5dbc5f82af 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -34,6 +34,7 @@ * WorldPay: Update Country List [nfarve] #2841 * Merchant Warrior: Support transcript scrubbing [curiousepic] #2845 * NAB Transact: Pass nonfractional amounts correctly [curiousepic] #2843 +* Realex: Update Country List [nfarve] #2842 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 From b543879a63fa91b9d25b49ad6233b462ae38be02 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Wed, 16 May 2018 10:40:04 -0400 Subject: [PATCH 398/677] QBMS: Support transcript scrubbing We do not have test credentials for QBMS and they claim their test sandbox is not currently working, so the remote tests cannot be run. The mock transcripts added here in the unit tests should be accurate; they come from an external scrub test that dates to the same time and API version for the gateway implementation here in Active Merchant. This scrub method is the same as what Spreedly calls manually on QBMS transactions made today, and we've confirmed that those transcripts are properly scrubbed. Closes #2849 Unit: 15 tests, 74 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/qbms.rb | 11 ++++ test/remote/gateways/remote_qbms_test.rb | 11 ++++ test/unit/gateways/qbms_test.rb | 67 ++++++++++++++++++++ 4 files changed, 90 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index d5dbc5f82af..1697cf2db29 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -35,6 +35,7 @@ * Merchant Warrior: Support transcript scrubbing [curiousepic] #2845 * NAB Transact: Pass nonfractional amounts correctly [curiousepic] #2843 * Realex: Update Country List [nfarve] #2842 +* QBMS: Support transcript scrubbing [curiousepic] #2849 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/qbms.rb b/lib/active_merchant/billing/gateways/qbms.rb index 2beedc826e4..4cf2a999f31 100644 --- a/lib/active_merchant/billing/gateways/qbms.rb +++ b/lib/active_merchant/billing/gateways/qbms.rb @@ -113,6 +113,17 @@ def query commit(:query, nil, {}) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((<ConnectionTicket>)[^<]*(</ConnectionTicket>))i, '\1[FILTERED]\2'). + gsub(%r((<CreditCardNumber>)[^<]*(</CreditCardNumber>))i, '\1[FILTERED]\2'). + gsub(%r((<CardSecurityCode>)[^<]*(</CardSecurityCode>))i, '\1[FILTERED]\2') + end + private def hosted? diff --git a/test/remote/gateways/remote_qbms_test.rb b/test/remote/gateways/remote_qbms_test.rb index d88553ec1c8..d97be9f3b2d 100644 --- a/test/remote/gateways/remote_qbms_test.rb +++ b/test/remote/gateways/remote_qbms_test.rb @@ -88,6 +88,17 @@ def test_decline assert_equal "The request to process this transaction has been declined.", response.message end + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:ticket], transcript) + end + private def error_card(config_id) diff --git a/test/unit/gateways/qbms_test.rb b/test/unit/gateways/qbms_test.rb index 1ea30acd0ad..ee8095368cf 100644 --- a/test/unit/gateways/qbms_test.rb +++ b/test/unit/gateways/qbms_test.rb @@ -155,6 +155,11 @@ def test_use_test_url_when_overwriting_with_test_option ActiveMerchant::Billing::Base.mode = :test end + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + # helper methods start here def query_response(opts = {}) @@ -254,4 +259,66 @@ def wrap(type, opts, xml) </QBMSXML> XML end + + def pre_scrubbed + <<-PRE_SCRUBBED + <?xml version="1.0" encoding="utf-8"?><?qbmsxml version="4.0"?><QBMSXML><SignonMsgsRq><SignonDesktopRq><ClientDateTime>2012-07-06T11:48:30-07:00</ClientDateTime><ApplicationLogin>subscriptions-test.spreedly.com</ApplicationLogin><ConnectionTicket>TGT-135-0exSkgC_I9tvKAxCwOE$Eg</ConnectionTicket></SignonDesktopRq></SignonMsgsRq><QBMSXMLMsgsRq><CustomerCreditCardChargeRq><TransRequestID>859e649c87f9ac698536</TransRequestID><CreditCardNumber>4111111111111111</CreditCardNumber><ExpirationMonth>9</ExpirationMonth><ExpirationYear>2013</ExpirationYear><IsECommerce>true</IsECommerce><Amount>1.00</Amount><NameOnCard>Longbob Longsen</NameOnCard><CreditCardAddress>1234 My Street</CreditCardAddress><CreditCardPostalCode>K1C2N6</CreditCardPostalCode><CardSecurityCode>123</CardSecurityCode></CustomerCreditCardChargeRq></QBMSXMLMsgsRq></QBMSXML> + <!DOCTYPE QBMSXML PUBLIC "-//INTUIT//DTD QBMSXML QBMS 4.0//EN" "http://webmerchantaccount.ptc.quickbooks.com/dtds/qbmsxml40.dtd"> + <QBMSXML> + <SignonMsgsRs> + <SignonDesktopRs statusCode="0" statusSeverity="INFO"> + <ServerDateTime>2012-07-06T18:48:31</ServerDateTime> + <SessionTicket>V1-110-Q31341600511142d1e4131:133159303</SessionTicket> + </SignonDesktopRs> + </SignonMsgsRs> + <QBMSXMLMsgsRs> + <CustomerCreditCardChargeRs statusCode="0" statusMessage="Status OK" statusSeverity="INFO"> + <CreditCardTransID>YY1002519111</CreditCardTransID> + <AuthorizationCode>135927</AuthorizationCode> + <AVSStreet>Pass</AVSStreet> + <AVSZip>Pass</AVSZip> + <CardSecurityCodeMatch>Pass</CardSecurityCodeMatch> + <MerchantAccountNumber>5247711053184054</MerchantAccountNumber> + <ReconBatchID>420120706 1Q11485247711053184054AUTO04</ReconBatchID> + <PaymentGroupingCode>5</PaymentGroupingCode> + <PaymentStatus>Completed</PaymentStatus> + <TxnAuthorizationTime>2012-07-06T18:48:31</TxnAuthorizationTime> + <TxnAuthorizationStamp>1341600511</TxnAuthorizationStamp> + <ClientTransID>q0b539f2</ClientTransID> + </CustomerCreditCardChargeRs> + </QBMSXMLMsgsRs> + </QBMSXML> + PRE_SCRUBBED + end + + def post_scrubbed + <<-POST_SCRUBBED + <?xml version="1.0" encoding="utf-8"?><?qbmsxml version="4.0"?><QBMSXML><SignonMsgsRq><SignonDesktopRq><ClientDateTime>2012-07-06T11:48:30-07:00</ClientDateTime><ApplicationLogin>subscriptions-test.spreedly.com</ApplicationLogin><ConnectionTicket>[FILTERED]</ConnectionTicket></SignonDesktopRq></SignonMsgsRq><QBMSXMLMsgsRq><CustomerCreditCardChargeRq><TransRequestID>859e649c87f9ac698536</TransRequestID><CreditCardNumber>[FILTERED]</CreditCardNumber><ExpirationMonth>9</ExpirationMonth><ExpirationYear>2013</ExpirationYear><IsECommerce>true</IsECommerce><Amount>1.00</Amount><NameOnCard>Longbob Longsen</NameOnCard><CreditCardAddress>1234 My Street</CreditCardAddress><CreditCardPostalCode>K1C2N6</CreditCardPostalCode><CardSecurityCode>[FILTERED]</CardSecurityCode></CustomerCreditCardChargeRq></QBMSXMLMsgsRq></QBMSXML> + <!DOCTYPE QBMSXML PUBLIC "-//INTUIT//DTD QBMSXML QBMS 4.0//EN" "http://webmerchantaccount.ptc.quickbooks.com/dtds/qbmsxml40.dtd"> + <QBMSXML> + <SignonMsgsRs> + <SignonDesktopRs statusCode="0" statusSeverity="INFO"> + <ServerDateTime>2012-07-06T18:48:31</ServerDateTime> + <SessionTicket>V1-110-Q31341600511142d1e4131:133159303</SessionTicket> + </SignonDesktopRs> + </SignonMsgsRs> + <QBMSXMLMsgsRs> + <CustomerCreditCardChargeRs statusCode="0" statusMessage="Status OK" statusSeverity="INFO"> + <CreditCardTransID>YY1002519111</CreditCardTransID> + <AuthorizationCode>135927</AuthorizationCode> + <AVSStreet>Pass</AVSStreet> + <AVSZip>Pass</AVSZip> + <CardSecurityCodeMatch>Pass</CardSecurityCodeMatch> + <MerchantAccountNumber>5247711053184054</MerchantAccountNumber> + <ReconBatchID>420120706 1Q11485247711053184054AUTO04</ReconBatchID> + <PaymentGroupingCode>5</PaymentGroupingCode> + <PaymentStatus>Completed</PaymentStatus> + <TxnAuthorizationTime>2012-07-06T18:48:31</TxnAuthorizationTime> + <TxnAuthorizationStamp>1341600511</TxnAuthorizationStamp> + <ClientTransID>q0b539f2</ClientTransID> + </CustomerCreditCardChargeRs> + </QBMSXMLMsgsRs> + </QBMSXML> + POST_SCRUBBED + end end From ec853c34d3c6b14dad8ceb68ee424003f1c5cca2 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Wed, 9 May 2018 16:44:42 -0400 Subject: [PATCH 399/677] Adyen: Add support for installments Adds the ability to spread a purchase over several installments. Loaded suite test/remote/gateways/remote_adyen_test 32 tests, 81 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed .................. Loaded suite test/unit/gateways/adyen_test 18 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 7 +++++++ test/remote/gateways/remote_adyen_test.rb | 3 ++- test/unit/gateways/adyen_test.rb | 11 ++++++++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1697cf2db29..21fcb154d1e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -36,6 +36,7 @@ * NAB Transact: Pass nonfractional amounts correctly [curiousepic] #2843 * Realex: Update Country List [nfarve] #2842 * QBMS: Support transcript scrubbing [curiousepic] #2849 +* Adyen: Add support for installments [nfarve] #2839 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index 744b68e9da0..bbdb047f549 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -47,6 +47,7 @@ def authorize(money, payment, options={}) add_extra_data(post, options) add_shopper_interaction(post, payment, options) add_address(post, options) + add_installments(post, options) if options[:installments] commit('authorise', post) end @@ -196,6 +197,12 @@ def add_recurring_contract(post, options = {}) post[:recurring] = recurring end + def add_installments(post, options) + post[:installments] = { + value: options[:installments] + } + end + def parse(body) return {} if body.blank? JSON.parse(body) diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb index 21232d33bed..8bd307765ce 100644 --- a/test/remote/gateways/remote_adyen_test.rb +++ b/test/remote/gateways/remote_adyen_test.rb @@ -23,7 +23,8 @@ def setup shopper_ip: "77.110.174.153", shopper_reference: "John Smith", billing_address: address(), - order_id: "123" + order_id: "123", + installments: 2 } end diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index 3fcf38c3fbe..d454266f687 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -24,7 +24,8 @@ def setup @options = { billing_address: address(), shopper_reference: "John Smith", - order_id: '345123' + order_id: '345123', + installments: 2 } end @@ -90,6 +91,14 @@ def test_successful_purchase assert response.test? end + def test_installments_sent + stub_comms do + @gateway.authorize(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_equal 2, JSON.parse(data)['installments']['value'] + end.respond_with(successful_authorize_response) + end + def test_failed_purchase @gateway.expects(:ssl_post).returns(failed_purchase_response) From e06b213d82f8e3eceb66e4f6b52f6f9ccdecfb5d Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Fri, 18 May 2018 09:36:11 -0400 Subject: [PATCH 400/677] Paymentez: Read messages on Failure with no error Extends parsing messages on failure. Messages can be returned that are not included in the error field. Loaded suite test/unit/gateways/paymentez_test ................ 16 tests, 48 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_paymentez_test ................ 16 tests, 39 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/paymentez.rb | 6 ++- test/unit/gateways/paymentez_test.rb | 37 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 21fcb154d1e..e0b40ac2a4b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -37,6 +37,7 @@ * Realex: Update Country List [nfarve] #2842 * QBMS: Support transcript scrubbing [curiousepic] #2849 * Adyen: Add support for installments [nfarve] #2839 +* Paymentez: Read messages on Failure with no error [nfarve] #2850 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index 5b8983d8d2f..220ab88199b 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -219,7 +219,11 @@ def message_from(response) if success_from(response) response['transaction'] && response['transaction']['message'] else - response['error'] && response['error']['type'] + if response['error'] + response['error'] && response['error']['type'] + else + response['transaction']['message'] + end end end diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb index 6c9d3f88c05..5e603b66fcf 100644 --- a/test/unit/gateways/paymentez_test.rb +++ b/test/unit/gateways/paymentez_test.rb @@ -43,6 +43,15 @@ def test_failed_purchase assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code end + def test_expired_card + @gateway.expects(:ssl_post).returns(expired_card_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code + assert_equal 'Expired card', response.message + end + def test_successful_authorize @gateway.stubs(:ssl_post).returns(successful_authorize_response) @@ -373,4 +382,32 @@ def failed_store_response } ) end + + def expired_card_response + %q( + { + "transaction":{ + "status":"failure", + "payment_date":null, + "amount":1.0, + "authorization_code":null, + "installments":1, + "dev_reference":"ci123", + "message":"Expired card", + "carrier_code":"54", + "id":"PR-25", + "status_detail":9 + }, + "card":{ + "bin":"528851", + "expiry_year":"2024", + "expiry_month":"4", + "transaction_reference":"PR-25", + "type":"mc", + "number":"9794", + "origin":"Paymentez" + } + } + ) + end end From 95d74af4e1e71240d4594199a83a34310669963a Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Mon, 21 May 2018 10:54:33 -0400 Subject: [PATCH 401/677] Paymentez: Fix response message conditional Previously, an exception was occurring if there was no transaction message. This catches instances where there is no transaction element using guard clauses. Closes #2851 Remote: 15 tests, 37 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 16 tests, 48 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/paymentez.rb | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e0b40ac2a4b..25d808c1a6d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -38,6 +38,7 @@ * QBMS: Support transcript scrubbing [curiousepic] #2849 * Adyen: Add support for installments [nfarve] #2839 * Paymentez: Read messages on Failure with no error [nfarve] #2850 +* Paymentez: Fix response message conditional [curiousepic] #2851 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index 220ab88199b..836ed968b4e 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -216,14 +216,10 @@ def card_success_from(response) end def message_from(response) - if success_from(response) - response['transaction'] && response['transaction']['message'] + if !success_from(response) && response['error'] + response['error'] && response['error']['type'] else - if response['error'] - response['error'] && response['error']['type'] - else - response['transaction']['message'] - end + response['transaction'] && response['transaction']['message'] end end From 00fbcfc736d1716d2184d089c369b8272dde9d81 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Mon, 21 May 2018 13:11:52 -0400 Subject: [PATCH 402/677] UsaEpay: Add ability to send email receipt Adds the ability to set a flag to return emailed receipts as well as the template to use when sending the receipt. Loaded suite test/unit/gateways/usa_epay_transaction_test Started ............................................. 45 tests, 263 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 100% passed Loaded suite test/remote/gateways/remote_usa_epay_transaction_test ......................... 25 tests, 98 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 100% passed --- CHANGELOG | 1 + .../billing/gateways/usa_epay_transaction.rb | 7 ++++++- .../gateways/remote_usa_epay_transaction_test.rb | 6 ++++++ test/unit/gateways/usa_epay_transaction_test.rb | 11 +++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 25d808c1a6d..d28f18485b4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -39,6 +39,7 @@ * Adyen: Add support for installments [nfarve] #2839 * Paymentez: Read messages on Failure with no error [nfarve] #2850 * Paymentez: Fix response message conditional [curiousepic] #2851 +* Add ability to send email receipt [nfarve] #2852 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb index 27acbf6c0c5..5fa792f6ce5 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb @@ -140,7 +140,12 @@ def add_customer_data(post, options) if options.has_key? :email post[:custemail] = options[:email] - post[:custreceipt] = 'No' + if options[:cust_receipt] + post[:custreceipt] = options[:cust_receipt] + post[:custreceiptname] = options[:cust_receipt_name] if options[:cust_receipt_name] + else + post[:custreceipt] = 'No' + end end if options.has_key? :customer diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb index c1e9a6469bc..3acc16cd62b 100644 --- a/test/remote/gateways/remote_usa_epay_transaction_test.rb +++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb @@ -55,6 +55,12 @@ def test_successful_purchase_with_extra_test_mode assert_success response end + def test_successful_purchase_with_email_receipt + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:email => 'hank@hill.com',:cust_receipt => 'Yes')) + assert_equal 'Success', response.message + assert_success response + end + def test_unsuccessful_purchase # For some reason this will fail with "You have tried this card too # many times, please contact merchant" unless a unique order id is diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb index b427560ad1a..5b8f12684cc 100644 --- a/test/unit/gateways/usa_epay_transaction_test.rb +++ b/test/unit/gateways/usa_epay_transaction_test.rb @@ -82,6 +82,17 @@ def test_successful_purchase_passing_extra_test_mode assert_success response end + def test_successful_purchase_email_receipt + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(:email => 'bobby@hill.com', :cust_receipt => 'Yes', :cust_receipt_name => "socool")) + end.check_request do |endpoint, data, headers| + assert_match(/UMcustreceipt=Yes/, data) + assert_match(/UMcustreceiptname=socool/, data) + assert_match(/UMtestmode=0/, data) + end.respond_with(successful_purchase_response) + assert_success response + end + def test_successful_purchase_split_payment response = stub_comms do @gateway.purchase(@amount, @credit_card, @options.merge( From 8766e81ec4e491767c2dcec372707cbb7c91ba32 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 22 May 2018 11:19:26 -0400 Subject: [PATCH 403/677] Barclaycard Smartpay: Pass shopper_interaction Closes #2853 Remote: 29 tests, 61 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 25 tests, 114 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/barclaycard_smartpay.rb | 1 + .../gateways/remote_barclaycard_smartpay_test.rb | 6 ++++++ test/unit/gateways/barclaycard_smartpay_test.rb | 10 ++++++++++ 4 files changed, 18 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index d28f18485b4..4e9adebba86 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -40,6 +40,7 @@ * Paymentez: Read messages on Failure with no error [nfarve] #2850 * Paymentez: Fix response message conditional [curiousepic] #2851 * Add ability to send email receipt [nfarve] #2852 +* Barclaycard Smartpay: Pass shopper_interaction [curiousepic] #2853 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index 513821bd95e..5f2f4c72333 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -305,6 +305,7 @@ def payment_request(money, options) hash[:shopperEmail] = options[:email] if options[:email] hash[:shopperIP] = options[:ip] if options[:ip] hash[:shopperReference] = options[:customer] if options[:customer] + hash[:shopperInteraction] = options[:shopper_interaction] if options[:shopper_interaction] hash.keep_if { |_, v| v } end diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index 96b6127f41f..3a4e9249b5b 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -153,6 +153,12 @@ def test_successful_purchase_with_no_address assert_equal '[capture-received]', response.message end + def test_successful_purchase_with_shopper_interaction + response = @gateway.purchase(@amount, @credit_card, @options.merge(shopper_interaction: 'ContAuth')) + assert_success response + assert_equal '[capture-received]', response.message + end + def test_successful_authorize_with_3ds assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @options.merge(execute_threed: true)) assert_equal 'RedirectShopper', response.message diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb index 23fc6d9238c..5f69651ea59 100644 --- a/test/unit/gateways/barclaycard_smartpay_test.rb +++ b/test/unit/gateways/barclaycard_smartpay_test.rb @@ -157,6 +157,16 @@ def test_successful_authorize_with_shipping_house_number_and_street assert_equal '7914002629995504', response.authorization end + def test_successful_authorize_with_extra_options + response = stub_comms do + @gateway.authorize(@amount, @credit_card, @options.merge(shopper_interaction: 'ContAuth')) + end.check_request do |endpoint, data, headers| + assert_match(/shopperInteraction=ContAuth/, data) + end.respond_with(successful_authorize_response) + + assert_success response + end + def test_successful_authorize @gateway.stubs(:ssl_post).returns(successful_authorize_response) From 544be0d1ef345c2b569aafe1930babc04ec49ba9 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 24 May 2018 10:27:40 -0400 Subject: [PATCH 404/677] Stripe: mark UGX as a zero-decimal currency Unit: 122 tests, 651 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 64 tests, 291 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2857 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/stripe.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 4e9adebba86..b2ddaac0859 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -41,6 +41,7 @@ * Paymentez: Fix response message conditional [curiousepic] #2851 * Add ability to send email receipt [nfarve] #2852 * Barclaycard Smartpay: Pass shopper_interaction [curiousepic] #2853 +* Stripe: Treat UGX as a zero-decimal currency [bpollack] #2857 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index c5f76308336..d9755082aa6 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -25,7 +25,7 @@ class StripeGateway < Gateway self.default_currency = 'USD' self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro] - self.currencies_without_fractions = %w(BIF CLP DJF GNF JPY KMF KRW MGA PYG RWF VND VUV XAF XOF XPF) + self.currencies_without_fractions = %w(BIF CLP DJF GNF JPY KMF KRW MGA PYG RWF VND VUV XAF XOF XPF UGX) self.homepage_url = 'https://stripe.com/' self.display_name = 'Stripe' From 7a297e8188ab4838e5c0b2ddc0eccddb2866f9a7 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Wed, 23 May 2018 10:51:46 -0400 Subject: [PATCH 405/677] Mundipagg: Remove Billing Address if no Address Sent Removes the `billing_address` object if no address is sent. Loaded suite test/unit/gateways/mundipagg_test ............... 15 tests, 65 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_mundipagg_test .................... 20 tests, 50 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/mundipagg.rb | 32 ++++++++++--------- test/remote/gateways/remote_mundipagg_test.rb | 7 ++++ test/unit/gateways/mundipagg_test.rb | 9 ++++++ 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b2ddaac0859..62383a761d3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -42,6 +42,7 @@ * Add ability to send email receipt [nfarve] #2852 * Barclaycard Smartpay: Pass shopper_interaction [curiousepic] #2853 * Stripe: Treat UGX as a zero-decimal currency [bpollack] #2857 +* Mundipagg: Remove Billing Address if no Address Sent [nfarve] #2855 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb index 1ec773acf8f..d9fd7d7ba46 100644 --- a/lib/active_merchant/billing/gateways/mundipagg.rb +++ b/lib/active_merchant/billing/gateways/mundipagg.rb @@ -109,18 +109,20 @@ def add_customer_data(post, options) post[:customer][:email] = options[:email] end - def add_billing_address(options) - billing = {} - address = options[:billing_address] || options[:address] - billing[:street] = address[:address1].match(/\D+/)[0].strip if address[:address1] - billing[:number] = address[:address1].match(/\d+/)[0] if address[:address1] - billing[:compliment] = address[:address2] if address[:address2] - billing[:city] = address[:city] if address[:city] - billing[:state] = address[:state] if address[:state] - billing[:country] = address[:country] if address[:country] - billing[:zip_code] = address[:zip] if address[:zip] - billing[:neighborhood] = address[:neighborhood] - billing + def add_billing_address(post, type, options) + if address = (options[:billing_address] || options[:address]) + billing = {} + address = options[:billing_address] || options[:address] + billing[:street] = address[:address1].match(/\D+/)[0].strip if address[:address1] + billing[:number] = address[:address1].match(/\d+/)[0] if address[:address1] + billing[:compliment] = address[:address2] if address[:address2] + billing[:city] = address[:city] if address[:city] + billing[:state] = address[:state] if address[:state] + billing[:country] = address[:country] if address[:country] + billing[:zip_code] = address[:zip] if address[:zip] + billing[:neighborhood] = address[:neighborhood] + post[:payment][type.to_sym][:card][:billing_address] = billing + end end def add_shipping_address(post, options) @@ -153,7 +155,7 @@ def add_payment(post, payment, options) post[:customer][:name] = payment.name if post[:customer] post[:customer_id] = parse_auth(payment)[0] if payment.is_a?(String) post[:payment] = {} - post[:payment][:gateway_affiliation_id] = @options[:gateway_id] + post[:payment][:gateway_affiliation_id] = @options[:gateway_id] if @options[:gateway_id] post[:payment][:metadata] = { mundipagg_payment_method_code: '1' } if test? if voucher?(payment) add_voucher(post, payment, options) @@ -174,7 +176,7 @@ def add_credit_card(post, payment, options) post[:payment][:credit_card][:card][:exp_month] = payment.month post[:payment][:credit_card][:card][:exp_year] = payment.year post[:payment][:credit_card][:card][:cvv] = payment.verification_value - post[:payment][:credit_card][:card][:billing_address] = add_billing_address(options) + add_billing_address(post,'credit_card', options) end end @@ -189,7 +191,7 @@ def add_voucher(post, payment, options) post[:payment][:voucher][:card][:exp_month] = payment.month post[:payment][:voucher][:card][:exp_year] = payment.year post[:payment][:voucher][:card][:cvv] = payment.verification_value - post[:payment][:voucher][:card][:billing_address] = add_billing_address(options) + add_billing_address(post, 'voucher', options) end def voucher?(payment) diff --git a/test/remote/gateways/remote_mundipagg_test.rb b/test/remote/gateways/remote_mundipagg_test.rb index 52391c42c63..417cc547102 100644 --- a/test/remote/gateways/remote_mundipagg_test.rb +++ b/test/remote/gateways/remote_mundipagg_test.rb @@ -20,6 +20,13 @@ def test_successful_purchase assert_equal 'Simulator|Transação de simulação autorizada com sucesso', response.message end + def test_successful_purchase_no_address + @options.delete(:billing_address) + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Simulator|Transação de simulação autorizada com sucesso', response.message + end + def test_successful_purchase_with_more_options options = @options.update({ order_id: '1', diff --git a/test/unit/gateways/mundipagg_test.rb b/test/unit/gateways/mundipagg_test.rb index d610875abc4..ad30dc9647a 100644 --- a/test/unit/gateways/mundipagg_test.rb +++ b/test/unit/gateways/mundipagg_test.rb @@ -24,6 +24,15 @@ def test_successful_purchase assert response.test? end + def test_billing_not_sent + @options.delete(:billing_address) + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + refute data["billing_address"] + end.respond_with(successful_purchase_response) + end + def test_failed_purchase @gateway.expects(:ssl_post).returns(failed_purchase_response) From f3e0beb635ee2668757576995eac42c5630f12f3 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Thu, 24 May 2018 16:35:54 -0400 Subject: [PATCH 406/677] Paypal: Support more robust scrubbing This moves the scrub method to paypal_common_api.rb so that it can be used on Paypal Express transactions, which contain Username and Password credentials, and adds a scrub for Signature. Closes #2858 Paypal Remote (transient failure re-run): 26 tests, 70 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 96.1538% passed 1 tests, 7 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Paypal Unit: 66 tests, 264 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Paypal Express Remote: 3 tests, 8 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Paypal Express Unit: 63 tests, 181 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Paypal Common Api Unit: 17 tests, 30 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/paypal.rb | 12 ----- .../gateways/paypal/paypal_common_api.rb | 14 +++++ .../gateways/remote_paypal_express_test.rb | 20 +++++-- test/remote/gateways/remote_paypal_test.rb | 1 + test/unit/gateways/paypal_express_test.rb | 52 +++++++++++++++++++ test/unit/gateways/paypal_test.rb | 2 +- 7 files changed, 84 insertions(+), 18 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 62383a761d3..3ced091e8a9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -43,6 +43,7 @@ * Barclaycard Smartpay: Pass shopper_interaction [curiousepic] #2853 * Stripe: Treat UGX as a zero-decimal currency [bpollack] #2857 * Mundipagg: Remove Billing Address if no Address Sent [nfarve] #2855 +* Paypal: Support more robust scrubbing [curiousepic] #2858 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/paypal.rb b/lib/active_merchant/billing/gateways/paypal.rb index 56f20ca4bea..3a2b84b45e0 100644 --- a/lib/active_merchant/billing/gateways/paypal.rb +++ b/lib/active_merchant/billing/gateways/paypal.rb @@ -38,18 +38,6 @@ def express @express ||= PaypalExpressGateway.new(@options) end - def supports_scrubbing? - true - end - - def scrub(transcript) - transcript. - gsub(%r((<n1:Password>).+(</n1:Password>)), '\1[FILTERED]\2'). - gsub(%r((<n1:Username>).+(</n1:Username>)), '\1[FILTERED]\2'). - gsub(%r((<n2:CreditCardNumber>).+(</n2:CreditCardNumber)), '\1[FILTERED]\2'). - gsub(%r((<n2:CVV2>)\d+(</n2:CVV2)), '\1[FILTERED]\2') - end - private def define_transaction_type(transaction_arg) diff --git a/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb b/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb index 86180619d54..fe3146eac55 100644 --- a/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +++ b/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb @@ -269,7 +269,21 @@ def manage_pending_transaction(transaction_id, action) commit 'ManagePendingTransactionStatus', build_manage_pending_transaction_status(transaction_id, action) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((<n1:Password>).+(</n1:Password>)), '\1[FILTERED]\2'). + gsub(%r((<n1:Username>).+(</n1:Username>)), '\1[FILTERED]\2'). + gsub(%r((<n1:Signature>).+(</n1:Signature>)), '\1[FILTERED]\2'). + gsub(%r((<n2:CreditCardNumber>).+(</n2:CreditCardNumber)), '\1[FILTERED]\2'). + gsub(%r((<n2:CVV2>)\d+(</n2:CVV2)), '\1[FILTERED]\2') + end + private + def build_request_wrapper(action, options = {}) xml = Builder::XmlMarkup.new :indent => 2 xml.tag! action + 'Req', 'xmlns' => PAYPAL_NAMESPACE do diff --git a/test/remote/gateways/remote_paypal_express_test.rb b/test/remote/gateways/remote_paypal_express_test.rb index 0563993f0da..938bd0f9c14 100644 --- a/test/remote/gateways/remote_paypal_express_test.rb +++ b/test/remote/gateways/remote_paypal_express_test.rb @@ -3,9 +3,9 @@ class PaypalExpressTest < Test::Unit::TestCase def setup Base.mode = :test - + @gateway = PaypalExpressGateway.new(fixtures(:paypal_certificate)) - + @options = { :order_id => '230000', :email => 'buyer@jadedpallet.com', @@ -22,7 +22,7 @@ def setup :cancel_return_url => 'http://example.com/cancel' } end - + def test_set_express_authorization @options.update( :return_url => 'http://example.com', @@ -34,7 +34,7 @@ def test_set_express_authorization assert response.test? assert !response.params['token'].blank? end - + def test_set_express_purchase @options.update( :return_url => 'http://example.com', @@ -46,4 +46,14 @@ def test_set_express_purchase assert response.test? assert !response.params['token'].blank? end -end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.setup_authorization(500, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@gateway.options[:login], transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end +end diff --git a/test/remote/gateways/remote_paypal_test.rb b/test/remote/gateways/remote_paypal_test.rb index 7027d394cf0..af3696d45ef 100644 --- a/test/remote/gateways/remote_paypal_test.rb +++ b/test/remote/gateways/remote_paypal_test.rb @@ -41,6 +41,7 @@ def test_transcript_scrubbing assert_scrubbed(@credit_card.verification_value, transcript) assert_scrubbed(@gateway.options[:login], transcript) assert_scrubbed(@gateway.options[:password], transcript) + assert_scrubbed(@gateway.options[:signature], transcript) end def test_successful_purchase diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb index bb75a181311..349debe7eb5 100644 --- a/test/unit/gateways/paypal_express_test.rb +++ b/test/unit/gateways/paypal_express_test.rb @@ -1141,4 +1141,56 @@ def failure_billing_agreement_details_response </PayerInfo></BAUpdateResponseDetails></BAUpdateResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> RESPONSE end + + def pre_scrubbed + <<-TRANSCRIPT +<?xml version=\"1.0\" encoding=\"UTF-8\"?><env:Envelope xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><env:Header><RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\" xmlns:n1=\"urn:ebay:apis:eBLBaseComponents\" env:mustUnderstand=\"0\"><n1:Credentials><n1:Username>activemerchant-cert-test_api1.example.com</n1:Username><n1:Password>ERDD3JRFU5H5DQXS</n1:Password><n1:Subject/></n1:Credentials></RequesterCredentials></env:Header><env:Body><SetExpressCheckoutReq xmlns=\"urn:ebay:api:PayPalAPI\"> + <SetExpressCheckoutRequest xmlns:n2=\"urn:ebay:apis:eBLBaseComponents\"> + <n2:Version>124</n2:Version> + <n2:SetExpressCheckoutRequestDetails> + <n2:ReturnURL>http://example.com/return</n2:ReturnURL> + <n2:CancelURL>http://example.com/cancel</n2:CancelURL> + <n2:ReqBillingAddress>0</n2:ReqBillingAddress> + <n2:NoShipping>0</n2:NoShipping> + <n2:AddressOverride>0</n2:AddressOverride> + <n2:BuyerEmail>buyer@jadedpallet.com</n2:BuyerEmail> + <n2:PaymentDetails> + <n2:OrderTotal currencyID=\"USD\">5.00</n2:OrderTotal> + <n2:OrderDescription>Stuff that you purchased, yo!</n2:OrderDescription> + <n2:InvoiceID>230000</n2:InvoiceID> + <n2:PaymentAction>Authorization</n2:PaymentAction> + </n2:PaymentDetails> + </n2:SetExpressCheckoutRequestDetails> + </SetExpressCheckoutRequest> +</SetExpressCheckoutReq> +</env:Body></env:Envelope> +<?xml version=\"1.0\" encoding=\"UTF-8\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:cc=\"urn:ebay:apis:CoreComponentTypes\" xmlns:wsu=\"http://schemas.xmlsoap.org/ws/2002/07/utility\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xmlns:ed=\"urn:ebay:apis:EnhancedDataTypes\" xmlns:ebl=\"urn:ebay:apis:eBLBaseComponents\" xmlns:ns=\"urn:ebay:api:PayPalAPI\"><SOAP-ENV:Header><Security xmlns=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xsi:type=\"wsse:SecurityType\"></Security><RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\" xsi:type=\"ebl:CustomSecurityHeaderType\"><Credentials xmlns=\"urn:ebay:apis:eBLBaseComponents\" xsi:type=\"ebl:UserIdPasswordType\"><Username xsi:type=\"xs:string\"></Username><Password xsi:type=\"xs:string\"></Password><Signature xsi:type=\"xs:string\"></Signature><Subject xsi:type=\"xs:string\"></Subject></Credentials></RequesterCredentials></SOAP-ENV:Header><SOAP-ENV:Body id=\"_0\"><SetExpressCheckoutResponse xmlns=\"urn:ebay:api:PayPalAPI\"><Timestamp xmlns=\"urn:ebay:apis:eBLBaseComponents\">2018-05-24T20:23:54Z</Timestamp><Ack xmlns=\"urn:ebay:apis:eBLBaseComponents\">Success</Ack><CorrelationID xmlns=\"urn:ebay:apis:eBLBaseComponents\">b6dd2a043921b</CorrelationID><Version xmlns=\"urn:ebay:apis:eBLBaseComponents\">124</Version><Build xmlns=\"urn:ebay:apis:eBLBaseComponents\">46549960</Build><Token xsi:type=\"ebl:ExpressCheckoutTokenType\">EC-7KR85820NC734104L</Token></SetExpressCheckoutResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> + TRANSCRIPT + end + + def post_scrubbed + <<-TRANSCRIPT +<?xml version=\"1.0\" encoding=\"UTF-8\"?><env:Envelope xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><env:Header><RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\" xmlns:n1=\"urn:ebay:apis:eBLBaseComponents\" env:mustUnderstand=\"0\"><n1:Credentials><n1:Username>[FILTERED]</n1:Username><n1:Password>[FILTERED]</n1:Password><n1:Subject/></n1:Credentials></RequesterCredentials></env:Header><env:Body><SetExpressCheckoutReq xmlns=\"urn:ebay:api:PayPalAPI\"> + <SetExpressCheckoutRequest xmlns:n2=\"urn:ebay:apis:eBLBaseComponents\"> + <n2:Version>124</n2:Version> + <n2:SetExpressCheckoutRequestDetails> + <n2:ReturnURL>http://example.com/return</n2:ReturnURL> + <n2:CancelURL>http://example.com/cancel</n2:CancelURL> + <n2:ReqBillingAddress>0</n2:ReqBillingAddress> + <n2:NoShipping>0</n2:NoShipping> + <n2:AddressOverride>0</n2:AddressOverride> + <n2:BuyerEmail>buyer@jadedpallet.com</n2:BuyerEmail> + <n2:PaymentDetails> + <n2:OrderTotal currencyID=\"USD\">5.00</n2:OrderTotal> + <n2:OrderDescription>Stuff that you purchased, yo!</n2:OrderDescription> + <n2:InvoiceID>230000</n2:InvoiceID> + <n2:PaymentAction>Authorization</n2:PaymentAction> + </n2:PaymentDetails> + </n2:SetExpressCheckoutRequestDetails> + </SetExpressCheckoutRequest> +</SetExpressCheckoutReq> +</env:Body></env:Envelope> +<?xml version=\"1.0\" encoding=\"UTF-8\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:cc=\"urn:ebay:apis:CoreComponentTypes\" xmlns:wsu=\"http://schemas.xmlsoap.org/ws/2002/07/utility\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xmlns:ed=\"urn:ebay:apis:EnhancedDataTypes\" xmlns:ebl=\"urn:ebay:apis:eBLBaseComponents\" xmlns:ns=\"urn:ebay:api:PayPalAPI\"><SOAP-ENV:Header><Security xmlns=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xsi:type=\"wsse:SecurityType\"></Security><RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\" xsi:type=\"ebl:CustomSecurityHeaderType\"><Credentials xmlns=\"urn:ebay:apis:eBLBaseComponents\" xsi:type=\"ebl:UserIdPasswordType\"><Username xsi:type=\"xs:string\"></Username><Password xsi:type=\"xs:string\"></Password><Signature xsi:type=\"xs:string\"></Signature><Subject xsi:type=\"xs:string\"></Subject></Credentials></RequesterCredentials></SOAP-ENV:Header><SOAP-ENV:Body id=\"_0\"><SetExpressCheckoutResponse xmlns=\"urn:ebay:api:PayPalAPI\"><Timestamp xmlns=\"urn:ebay:apis:eBLBaseComponents\">2018-05-24T20:23:54Z</Timestamp><Ack xmlns=\"urn:ebay:apis:eBLBaseComponents\">Success</Ack><CorrelationID xmlns=\"urn:ebay:apis:eBLBaseComponents\">b6dd2a043921b</CorrelationID><Version xmlns=\"urn:ebay:apis:eBLBaseComponents\">124</Version><Build xmlns=\"urn:ebay:apis:eBLBaseComponents\">46549960</Build><Token xsi:type=\"ebl:ExpressCheckoutTokenType\">EC-7KR85820NC734104L</Token></SetExpressCheckoutResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> + TRANSCRIPT + end end diff --git a/test/unit/gateways/paypal_test.rb b/test/unit/gateways/paypal_test.rb index 55aaf10d732..906b1c9b938 100644 --- a/test/unit/gateways/paypal_test.rb +++ b/test/unit/gateways/paypal_test.rb @@ -642,7 +642,7 @@ def post_scrubbed starting SSL for api-3t.sandbox.paypal.com:443... SSL established <- "POST /2.0/ 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: api-3t.sandbox.paypal.com\r\nContent-Length: 2229\r\n\r\n" - <- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><env:Envelope xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><env:Header><RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\" xmlns:n1=\"urn:ebay:apis:eBLBaseComponents\" env:mustUnderstand=\"0\"><n1:Credentials><n1:Username>[FILTERED]</n1:Username><n1:Password>[FILTERED]</n1:Password><n1:Subject/><n1:Signature>AFcWxV21C7fd0v3bYYYRCpSSRl31AC-11AKBL8FFO9tjImL311y8a0hx</n1:Signature></n1:Credentials></RequesterCredentials></env:Header><env:Body><DoDirectPaymentReq xmlns=\"urn:ebay:api:PayPalAPI\">\n <DoDirectPaymentRequest xmlns:n2=\"urn:ebay:apis:eBLBaseComponents\">\n <n2:Version>72</n2:Version>\n <n2:DoDirectPaymentRequestDetails>\n <n2:PaymentAction>Sale</n2:PaymentAction>\n <n2:PaymentDetails>\n <n2:OrderTotal currencyID=\"USD\">1.00</n2:OrderTotal>\n <n2:OrderDescription>Stuff that you purchased, yo!</n2:OrderDescription>\n <n2:InvoiceID>70e472b155c61d27fe19555a96d51127</n2:InvoiceID>\n <n2:ButtonSource>ActiveMerchant</n2:ButtonSource>\n </n2:PaymentDetails>\n <n2:CreditCard>\n <n2:CreditCardType>Visa</n2:CreditCardType>\n <n2:CreditCardNumber>[FILTERED]</n2:CreditCardNumber>\n <n2:ExpMonth>09</n2:ExpMonth>\n <n2:ExpYear>2015</n2:ExpYear>\n <n2:CVV2>[FILTERED]</n2:CVV2>\n <n2:CardOwner>\n <n2:PayerName>\n <n2:FirstName>Longbob</n2:FirstName>\n <n2:LastName>Longsen</n2:LastName>\n </n2:PayerName>\n <n2:Payer>buyer@jadedpallet.com</n2:Payer>\n <n2:Address>\n <n2:Name>Longbob Longsen</n2:Name>\n <n2:Street1>1234 Penny Lane</n2:Street1>\n <n2:Street2/>\n <n2:CityName>Jonsetown</n2:CityName>\n <n2:StateOrProvince>NC</n2:StateOrProvince>\n <n2:Country>US</n2:Country>\n <n2:PostalCode>23456</n2:PostalCode>\n </n2:Address>\n </n2:CardOwner>\n </n2:CreditCard>\n <n2:IPAddress>10.0.0.1</n2:IPAddress>\n </n2:DoDirectPaymentRequestDetails>\n </DoDirectPaymentRequest>\n</DoDirectPaymentReq>\n</env:Body></env:Envelope>" + <- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><env:Envelope xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><env:Header><RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\" xmlns:n1=\"urn:ebay:apis:eBLBaseComponents\" env:mustUnderstand=\"0\"><n1:Credentials><n1:Username>[FILTERED]</n1:Username><n1:Password>[FILTERED]</n1:Password><n1:Subject/><n1:Signature>[FILTERED]</n1:Signature></n1:Credentials></RequesterCredentials></env:Header><env:Body><DoDirectPaymentReq xmlns=\"urn:ebay:api:PayPalAPI\">\n <DoDirectPaymentRequest xmlns:n2=\"urn:ebay:apis:eBLBaseComponents\">\n <n2:Version>72</n2:Version>\n <n2:DoDirectPaymentRequestDetails>\n <n2:PaymentAction>Sale</n2:PaymentAction>\n <n2:PaymentDetails>\n <n2:OrderTotal currencyID=\"USD\">1.00</n2:OrderTotal>\n <n2:OrderDescription>Stuff that you purchased, yo!</n2:OrderDescription>\n <n2:InvoiceID>70e472b155c61d27fe19555a96d51127</n2:InvoiceID>\n <n2:ButtonSource>ActiveMerchant</n2:ButtonSource>\n </n2:PaymentDetails>\n <n2:CreditCard>\n <n2:CreditCardType>Visa</n2:CreditCardType>\n <n2:CreditCardNumber>[FILTERED]</n2:CreditCardNumber>\n <n2:ExpMonth>09</n2:ExpMonth>\n <n2:ExpYear>2015</n2:ExpYear>\n <n2:CVV2>[FILTERED]</n2:CVV2>\n <n2:CardOwner>\n <n2:PayerName>\n <n2:FirstName>Longbob</n2:FirstName>\n <n2:LastName>Longsen</n2:LastName>\n </n2:PayerName>\n <n2:Payer>buyer@jadedpallet.com</n2:Payer>\n <n2:Address>\n <n2:Name>Longbob Longsen</n2:Name>\n <n2:Street1>1234 Penny Lane</n2:Street1>\n <n2:Street2/>\n <n2:CityName>Jonsetown</n2:CityName>\n <n2:StateOrProvince>NC</n2:StateOrProvince>\n <n2:Country>US</n2:Country>\n <n2:PostalCode>23456</n2:PostalCode>\n </n2:Address>\n </n2:CardOwner>\n </n2:CreditCard>\n <n2:IPAddress>10.0.0.1</n2:IPAddress>\n </n2:DoDirectPaymentRequestDetails>\n </DoDirectPaymentRequest>\n</DoDirectPaymentReq>\n</env:Body></env:Envelope>" -> "HTTP/1.1 200 OK\r\n" -> "Date: Tue, 02 Dec 2014 18:44:21 GMT\r\n" -> "Server: Apache\r\n" From 877b70f57a7cbd5326c69fd25c6b0c8c3aed7875 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 25 May 2018 12:09:22 -0400 Subject: [PATCH 407/677] Stripe: Handle upstream processing errors Sometimes, Stripe can fail internally, in which case its status will be set to "failed" even though an error key may be absent. This commit handles that case and adds a regression test for it. Unit: 127 tests, 674 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 64 tests, 291 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2859 --- CHANGELOG | 1 + .../billing/gateways/stripe.rb | 16 +++- test/unit/gateways/stripe_test.rb | 94 +++++++++++++++++++ 3 files changed, 108 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3ced091e8a9..f3fccbc53a8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -44,6 +44,7 @@ * Stripe: Treat UGX as a zero-decimal currency [bpollack] #2857 * Mundipagg: Remove Billing Address if no Address Sent [nfarve] #2855 * Paypal: Support more robust scrubbing [curiousepic] #2858 +* Stripe: Report internal Stripe errors as failures [bpollack] #2859 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index d9755082aa6..2616d4e07b7 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -549,14 +549,14 @@ def commit(method, url, parameters = nil, options = {}) add_expand_parameters(parameters, options) if parameters response = api_request(method, url, parameters, options) - success = !response.key?("error") + success = success_from(response) card = card_from_response(response) avs_code = AVS_CODE_TRANSLATOR["line1: #{card["address_line1_check"]}, zip: #{card["address_zip_check"]}"] cvc_code = CVC_CODE_TRANSLATOR[card["cvc_check"]] Response.new(success, - success ? "Transaction approved" : response["error"]["message"], + message_from(success, response), response, :test => response_is_test?(response), :authorization => authorization_from(success, url, method, response), @@ -568,7 +568,7 @@ def commit(method, url, parameters = nil, options = {}) end def authorization_from(success, url, method, response) - return response["error"]["charge"] unless success + return response.fetch("error", {})["charge"] unless success if url == "customers" [response["id"], response["sources"]["data"].first["id"]].join("|") @@ -579,6 +579,14 @@ def authorization_from(success, url, method, response) end end + def message_from(success, response) + success ? "Transaction approved" : response.fetch("error", {"message" => "No error details"})["message"] + end + + def success_from(response) + !response.key?("error") && response["status"] != "failed" + end + def response_error(raw_response) begin parse(raw_response) @@ -626,6 +634,8 @@ def emv_authorization_from_response(response) end def error_code_from(response) + return STANDARD_ERROR_CODE_MAPPING['processing_error'] unless response['error'] + code = response['error']['code'] decline_code = response['error']['decline_code'] if code == 'card_declined' diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index 6a8f4f62f87..a310accd5b5 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -1365,6 +1365,16 @@ def test_verify_bad_credentials assert !@gateway.verify_credentials end + def test_stripe_internal_error_fails + @gateway.expects(:add_creditcard) + @gateway.expects(:ssl_request).returns(stripe_internal_error_response) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal response.message, "No error details" + assert response.test? + end + private # this mock is only useful with unit tests, as cryptograms generated by an EMV terminal @@ -2228,6 +2238,90 @@ def credentials_are_bogus_response MockResponse.new(401, body) end + def stripe_internal_error_response + <<-RESPONSE + { + "id": "ch_1CSa8KL6Z03PTOVWo9B3qYCI", + "object": "charge", + "amount": 900, + "amount_refunded": 0, + "application": null, + "application_fee": null, + "balance_transaction": null, + "captured": false, + "created": 1526517494, + "currency": "usd", + "customer": null, + "description": null, + "destination": null, + "dispute": null, + "failure_code": null, + "failure_message": null, + "fraud_details": {}, + "invoice": null, + "livemode": true, + "metadata": { + "product_name": "1 month", + "vendor_id": "12345", + "connect_agent": "Spreedly", + "email": "someone@example.com", + "order_id": "3193747-1568289" + }, + "on_behalf_of": null, + "order": null, + "outcome": { + "network_status": "approved_by_network", + "reason": null, + "seller_message": "Payment complete.", + "type": "authorized" + }, + "paid": false, + "receipt_email": null, + "receipt_number": null, + "refunded": false, + "refunds": { + "object": "list", + "data": [], + "has_more": false, + "total_count": 0, + "url": "/v1/charges/ch_1CSa8KL6Z03PTOVWo9B3qYCI/refunds" + }, + "review": null, + "shipping": null, + "source": { + "id": "card_1a2b3c4d5e6f7g8h9j", + "object": "card", + "address_city": null, + "address_country": null, + "address_line1": null, + "address_line1_check": null, + "address_line2": null, + "address_state": null, + "address_zip": null, + "address_zip_check": null, + "brand": "Visa", + "country": "MX", + "customer": null, + "cvc_check": null, + "dynamic_last4": null, + "exp_month": 11, + "exp_year": 2021, + "fingerprint": "ABCDEFGHIJKLMNO", + "funding": "credit", + "last4": "0123", + "metadata": {}, + "name": null, + "tokenization_method": null + }, + "source_transfer": null, + "statement_descriptor": "MAGIC*TEST*STUFF", + "status": "failed", + "transfer_group": null, + "livemode": false + } + RESPONSE + end + def token_params { "id" => "tok_14uq3k2gKyKnHxtYUAZZZlH3", From aa7a63f4a3b110783053f3f225ca1b94a32d7464 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Tue, 22 May 2018 16:00:04 -0400 Subject: [PATCH 408/677] Authorize.net: Add ability to pass `customer_payment_profile_id` Adds the ability to actively set the `customer_payment_profile_id` field. Loaded suite test/remote/gateways/remote_authorize_net_test .................................................................. 66 tests, 224 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/authorize_net_test ............................................................................................ 92 tests, 521 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/authorize_net.rb | 14 ++++++++------ test/remote/gateways/remote_authorize_net_test.rb | 13 +++++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f3fccbc53a8..18cd77cbf66 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -45,6 +45,7 @@ * Mundipagg: Remove Billing Address if no Address Sent [nfarve] #2855 * Paypal: Support more robust scrubbing [curiousepic] #2858 * Stripe: Report internal Stripe errors as failures [bpollack] #2859 +* Authorize.net: Add ability to pass `customer_payment_profile_id` [nfarve] #2854 == Version 1.78.0 (March 29, 2018) * Litle: Add store for echecks [nfarve] #2779 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index be4125c1c56..b6c9701d280 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -167,7 +167,7 @@ def credit(amount, payment, options={}) xml.transactionType('refundTransaction') xml.amount(amount(amount)) - add_payment_source(xml, payment, :credit) + add_payment_source(xml, payment, options, :credit) xml.refTransId(transaction_id_from(options[:transaction_id])) if options[:transaction_id] add_invoice(xml, 'refundTransaction', options) add_customer_data(xml, payment, options) @@ -246,7 +246,7 @@ def add_auth_purchase(xml, transaction_type, amount, payment, options) xml.transactionRequest do xml.transactionType(transaction_type) xml.amount(amount(amount)) - add_payment_source(xml, payment) + add_payment_source(xml, payment, options) add_invoice(xml, transaction_type, options) add_tax_fields(xml, options) add_duty_fields(xml, options) @@ -268,7 +268,7 @@ def add_cim_auth_purchase(xml, transaction_type, amount, payment, options) add_tax_fields(xml, options) add_shipping_fields(xml, options) add_duty_fields(xml, options) - add_payment_source(xml, payment) + add_payment_source(xml, payment, options) add_invoice(xml, transaction_type, options) add_tax_exempt_status(xml, options) end @@ -375,10 +375,10 @@ def normal_void(authorization, options) end end - def add_payment_source(xml, source, action = nil) + def add_payment_source(xml, source, options, action = nil) return unless source if source.is_a?(String) - add_token_payment_method(xml, source) + add_token_payment_method(xml, source, options) elsif card_brand(source) == 'check' add_check(xml, source) elsif card_brand(source) == 'apple_pay' @@ -489,8 +489,10 @@ def add_swipe_data(xml, credit_card) end end - def add_token_payment_method(xml, token) + def add_token_payment_method(xml, token, options) customer_profile_id, customer_payment_profile_id, _ = split_authorization(token) + customer_profile_id = options[:customer_profile_id] if options[:customer_profile_id] + customer_payment_profile_id = options[:customer_payment_profile_id] if options[:customer_payment_profile_id] xml.customerProfileId(customer_profile_id) xml.customerPaymentProfileId(customer_payment_profile_id) end diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb index eb396551373..8f2a26e07bd 100644 --- a/test/remote/gateways/remote_authorize_net_test.rb +++ b/test/remote/gateways/remote_authorize_net_test.rb @@ -392,6 +392,19 @@ def test_failed_authorize_using_stored_card assert_match %r{Address not verified}, response.avs_result["message"] end + def test_failed_authorize_using_wrong_token + response = @gateway.store(@declined_card) + assert_success response + + responseA = @gateway.authorize(@amount, response.authorization, @options.merge(customer_payment_profile_id: 12345)) + responseB = @gateway.authorize(@amount, response.authorization, @options.merge(customer_profile_id: 12345)) + assert_failure responseA + assert_failure responseB + + assert_equal 'Customer Profile ID or Customer Payment Profile ID not found', responseA.message + assert_equal 'Customer Profile ID or Customer Payment Profile ID not found', responseB.message + end + def test_failed_capture_using_stored_card store = @gateway.store(@credit_card, @options) assert_success store From b20ad8a287567868ffce067e453f94c40935c317 Mon Sep 17 00:00:00 2001 From: Bart de Water <bart.dewater@shopify.com> Date: Wed, 30 May 2018 11:33:52 -0400 Subject: [PATCH 409/677] Add logging of SSL connection details On June 30 the PCI DSS mandates TLS 1.1 or better for securely transmitting payment data. This refinement to Net::HTTP allows us to get the required details within the scope of the ActiveMerchant::Connection class, without monkey patching globally. Example output: ``` irb(main):004:0> gw.authorize(100, "test") I, [2018-05-30T11:22:44.565084 #44620] INFO -- : [ActiveMerchant::Billing::PayflowGateway] connection_http_method=POST connection_uri=https://payflowpro.paypal.com I, [2018-05-30T11:22:45.165265 #44620] INFO -- : [ActiveMerchant::Billing::PayflowGateway] connection_ssl_version=TLSv1.2 connection_ssl_cipher=ECDHE-RSA-AES128-GCM-SHA256 ``` --- CHANGELOG | 1 + lib/active_merchant.rb | 1 + lib/active_merchant/connection.rb | 23 ++++++++++++++----- .../net_http_ssl_connection.rb | 9 ++++++++ 4 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 lib/active_merchant/net_http_ssl_connection.rb diff --git a/CHANGELOG b/CHANGELOG index 18cd77cbf66..a7f17463a5a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * Allow setting min/max SSL version for a connection on Ruby 2.5 [bdewater] #2775 * Add `gateways:ssl:min_version` rake task to test upcoming TLS 1.0 deprecation deadline [bdewater] #2775 +* Log negotiated SSL version and cipher [bdewater + methodmissing] #2862 * Remove support for Rails < 4.2, add support for Rails 5.2 and Ruby 2.5 [bdewater] * Spreedly: Support verify and find transactions [abarrak] #2798 * Adyen: Support merchant-specific subdomains [curiousepic] #2799 diff --git a/lib/active_merchant.rb b/lib/active_merchant.rb index b19a4725b37..88e6216aa15 100644 --- a/lib/active_merchant.rb +++ b/lib/active_merchant.rb @@ -40,6 +40,7 @@ require 'openssl' require 'active_merchant/network_connection_retries' +require 'active_merchant/net_http_ssl_connection' require 'active_merchant/connection' require 'active_merchant/post_data' require 'active_merchant/posts_data' diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index 6db1df3b29f..d057face6fa 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -5,6 +5,7 @@ module ActiveMerchant class Connection + using NetHttpSslConnection include NetworkConnectionRetries MAX_RETRIES = 3 @@ -25,6 +26,7 @@ class Connection attr_accessor :min_version attr_accessor :max_version end + attr_reader :ssl_connection attr_accessor :ca_file attr_accessor :ca_path attr_accessor :pem @@ -52,6 +54,7 @@ def initialize(endpoint) @min_version = nil @max_version = nil end + @ssl_connection = {} @proxy_address = :ENV @proxy_port = nil end @@ -71,6 +74,10 @@ def request(method, body, headers = {}) result = nil realtime = Benchmark.realtime do + http.start unless http.started? + @ssl_connection = http.ssl_connection + info "connection_ssl_version=#{ssl_connection[:version]} connection_ssl_cipher=#{ssl_connection[:cipher]}", tag + result = case method when :get raise ArgumentError, "GET requests do not support a request body" if body @@ -109,16 +116,20 @@ def request(method, body, headers = {}) ensure info "connection_request_total_time=%.4fs" % [Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start], tag + http.finish if http.started? end private + def http - http = Net::HTTP.new(endpoint.host, endpoint.port, proxy_address, proxy_port) - configure_debugging(http) - configure_timeouts(http) - configure_ssl(http) - configure_cert(http) - http + @http ||= begin + http = Net::HTTP.new(endpoint.host, endpoint.port, proxy_address, proxy_port) + configure_debugging(http) + configure_timeouts(http) + configure_ssl(http) + configure_cert(http) + http + end end def configure_debugging(http) diff --git a/lib/active_merchant/net_http_ssl_connection.rb b/lib/active_merchant/net_http_ssl_connection.rb new file mode 100644 index 00000000000..ed359ae67e2 --- /dev/null +++ b/lib/active_merchant/net_http_ssl_connection.rb @@ -0,0 +1,9 @@ +require 'net/http' + +module NetHttpSslConnection + refine Net::HTTP do + def ssl_connection + { version: @socket.io.ssl_version, cipher: @socket.io.cipher[0] } + end + end +end From 7caeccdca5254d69bb7ca06b1a2e63aaa97f8b58 Mon Sep 17 00:00:00 2001 From: Bart de Water <bart.dewater@shopify.com> Date: Wed, 30 May 2018 23:24:41 -0400 Subject: [PATCH 410/677] Release v1.79.0 --- CHANGELOG | 2 ++ lib/active_merchant/version.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a7f17463a5a..b1855db4caf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ = ActiveMerchant CHANGELOG == HEAD + +== Version 1.79.0 (May 30, 2018) * Allow setting min/max SSL version for a connection on Ruby 2.5 [bdewater] #2775 * Add `gateways:ssl:min_version` rake task to test upcoming TLS 1.0 deprecation deadline [bdewater] #2775 * Log negotiated SSL version and cipher [bdewater + methodmissing] #2862 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index ce50e19a8a7..dda47f0fa5d 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.78.0" + VERSION = "1.79.0" end From 296edf5669548257b8e2bd5b372d0ac81f1f7d27 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 30 May 2018 16:58:07 -0400 Subject: [PATCH 411/677] Mundipagg: pass holder_document for CC purchases Unit: 16 tests, 70 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 20 tests, 50 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2864 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/mundipagg.rb | 1 + test/unit/gateways/mundipagg_test.rb | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index b1855db4caf..6663b68365d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Mundipagg: allow passing holder_document for credit card purchases [bpollack] #2864 == Version 1.79.0 (May 30, 2018) * Allow setting min/max SSL version for a connection on Ruby 2.5 [bdewater] #2775 diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb index d9fd7d7ba46..751b94db660 100644 --- a/lib/active_merchant/billing/gateways/mundipagg.rb +++ b/lib/active_merchant/billing/gateways/mundipagg.rb @@ -176,6 +176,7 @@ def add_credit_card(post, payment, options) post[:payment][:credit_card][:card][:exp_month] = payment.month post[:payment][:credit_card][:card][:exp_year] = payment.year post[:payment][:credit_card][:card][:cvv] = payment.verification_value + post[:payment][:credit_card][:card][:holder_document] = options[:holder_document] if options[:holder_document] add_billing_address(post,'credit_card', options) end end diff --git a/test/unit/gateways/mundipagg_test.rb b/test/unit/gateways/mundipagg_test.rb index ad30dc9647a..62b29474c24 100644 --- a/test/unit/gateways/mundipagg_test.rb +++ b/test/unit/gateways/mundipagg_test.rb @@ -24,6 +24,18 @@ def test_successful_purchase assert response.test? end + def test_successful_purchase_with_holder_document + @options.merge!(holder_document: "a1b2c3d4") + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match(/a1b2c3d4/, data) + end.respond_with(successful_purchase_response) + + assert_success response + assert response.test? + end + def test_billing_not_sent @options.delete(:billing_address) stub_comms do From 98b5dcad9851a835e1075d162c94a0c60d3e34f4 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 31 May 2018 11:11:08 -0400 Subject: [PATCH 412/677] Conekta: add support for monthly installments Unit: 12 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 15 tests, 57 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2866 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/conekta.rb | 1 + test/remote/gateways/remote_conekta_test.rb | 10 ++++++++-- test/unit/gateways/conekta_test.rb | 13 +++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6663b68365d..ac32c7c49fa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * Mundipagg: allow passing holder_document for credit card purchases [bpollack] #2864 +* Conekta: support monthly_installments [bpollack] #2866 == Version 1.79.0 (May 30, 2018) * Allow setting min/max SSL version for a connection on Ruby 2.5 [bdewater] #2775 diff --git a/lib/active_merchant/billing/gateways/conekta.rb b/lib/active_merchant/billing/gateways/conekta.rb index 669edc313c2..87378003093 100644 --- a/lib/active_merchant/billing/gateways/conekta.rb +++ b/lib/active_merchant/billing/gateways/conekta.rb @@ -77,6 +77,7 @@ def add_order(post, money, options) post[:description] = options[:description] || "Active Merchant Purchase" post[:reference_id] = options[:order_id] if options[:order_id] post[:currency] = (options[:currency] || currency(money)).downcase + post[:monthly_installments] = options[:monthly_installments] if options[:monthly_installments] post[:amount] = amount(money) end diff --git a/test/remote/gateways/remote_conekta_test.rb b/test/remote/gateways/remote_conekta_test.rb index 5e30e2582f6..ee0d9005d76 100644 --- a/test/remote/gateways/remote_conekta_test.rb +++ b/test/remote/gateways/remote_conekta_test.rb @@ -10,7 +10,7 @@ def setup number: "4242424242424242", verification_value: "183", month: "01", - year: "2018", + year: "2019", first_name: "Mario F.", last_name: "Moreno Reyes" ) @@ -19,7 +19,7 @@ def setup number: "4000000000000002", verification_value: "183", month: "01", - year: "2018", + year: "2019", first_name: "Mario F.", last_name: "Moreno Reyes" ) @@ -55,6 +55,12 @@ def test_successful_purchase assert_equal nil, response.message end + def test_successful_purchase_with_installments + assert response = @gateway.purchase(@amount * 300, @credit_card, @options.merge({monthly_installments: 3})) + assert_success response + assert_equal nil, response.message + end + def test_unsuccessful_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response diff --git a/test/unit/gateways/conekta_test.rb b/test/unit/gateways/conekta_test.rb index c959c214722..13bc272a7a5 100644 --- a/test/unit/gateways/conekta_test.rb +++ b/test/unit/gateways/conekta_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class ConektaTest < Test::Unit::TestCase + include CommStub + def setup @gateway = ConektaGateway.new(:key => "key_eYvWV7gSDkNYXsmr") @@ -65,6 +67,17 @@ def test_unsuccessful_purchase assert response.test? end + 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| + assert_match %r{monthly_installments=3}, data + end.respond_with(successful_purchase_response) + + assert_success response + assert response.test? + end + def test_unsuccessful_refund @gateway.expects(:ssl_request).returns(failed_refund_response) assert response = @gateway.refund(@amount, "1", @options) From de128f4135e5816a16d317ed3a79077653ae4042 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 31 May 2018 11:25:32 -0400 Subject: [PATCH 413/677] Authorize.net: pass email_customer if set Previously, we would only pass email_customer if it was set true, and omit the value otherwise. But this could result in emails being sent in some cases. Instead, if any value is provided, pass it along. Unit: 92 tests, 524 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 67 tests, 230 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2867 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/authorize_net.rb | 4 ++-- test/remote/gateways/remote_authorize_net_test.rb | 8 ++++++++ test/unit/gateways/authorize_net_test.rb | 7 +++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ac32c7c49fa..125b8139db6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * Mundipagg: allow passing holder_document for credit card purchases [bpollack] #2864 * Conekta: support monthly_installments [bpollack] #2866 +* Authorize.net: allow sending email_customer set to false [bpollack] #2867 == Version 1.79.0 (May 30, 2018) * Allow setting min/max SSL version for a connection on Ruby 2.5 [bdewater] #2775 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index b6c9701d280..490f9fd94ef 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -412,10 +412,10 @@ def add_settings(xml, source, options) ActiveMerchant.deprecated "Using the duplicate_window class_attribute is deprecated. Use the transaction options hash instead." set_duplicate_window(xml, self.class.duplicate_window) end - if options[:email_customer] + if options.key?(:email_customer) xml.setting do xml.settingName("emailCustomer") - xml.settingValue("true") + xml.settingValue(options[:email_customer] ? "true" : "false") end end if options[:header_email_receipt] diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb index 8f2a26e07bd..24e4e4a8769 100644 --- a/test/remote/gateways/remote_authorize_net_test.rb +++ b/test/remote/gateways/remote_authorize_net_test.rb @@ -62,6 +62,14 @@ def test_successful_purchase_with_email_customer assert response.authorization end + def test_successful_purchase_with_false_email_customer + response = @gateway.purchase(@amount, @credit_card, duplicate_window: 0, email_customer: false, email: 'anet@example.com', billing_address: address) + assert_success response + assert response.test? + assert_equal 'This transaction has been approved', response.message + assert response.authorization + end + def test_successful_purchase_with_header_email_receipt response = @gateway.purchase(@amount, @credit_card, duplicate_window: 0, header_email_receipt: "subject line", email: 'anet@example.com', billing_address: address) assert_success response diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index f5e521ef3b5..0ac15ef2b9d 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -307,6 +307,13 @@ def test_passes_email_customer assert_match(/<settingName>emailCustomer<\/settingName>/, data) assert_match(/<settingValue>true<\/settingValue>/, data) end.respond_with(successful_purchase_response) + + stub_comms do + @gateway.purchase(@amount, credit_card, email_customer: false) + end.check_request do |endpoint, data, headers| + assert_match(/<settingName>emailCustomer<\/settingName>/, data) + assert_match(/<settingValue>false<\/settingValue>/, data) + end.respond_with(successful_purchase_response) end def test_passes_header_email_receipt From 50606e0d473cec7c851ce51abf27ac3cbabe7d96 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 31 May 2018 14:33:16 -0400 Subject: [PATCH 414/677] Prevent keepalives by default With b20ad8a287567, the connection logic changed such that keepalives would suddenly be used, where previously, Connection: close would be sent. This patch reverts to the old behavior. Keepalives can still be manually requested by passing the relevant header. --- lib/active_merchant/connection.rb | 2 ++ test/unit/connection_test.rb | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index d057face6fa..57a6e15d56a 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -65,6 +65,8 @@ def wiredump_device=(device) end def request(method, body, headers = {}) + headers['connection'] ||= 'close' + request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC) retry_exceptions(:max_retries => max_retries, :logger => logger, :tag => tag) do diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index 4e08eae8be5..1327f2df401 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -29,7 +29,7 @@ def test_connection_endpoint_raises_uri_error def test_connection_passes_env_proxy_by_default spy = Net::HTTP.new('example.com', 443) Net::HTTP.expects(:new).with('example.com', 443, :ENV, nil).returns(spy) - spy.expects(:get).with('/tx.php', {}).returns(@ok) + spy.expects(:get).with('/tx.php', {'connection' => 'close'}).returns(@ok) @connection.request(:get, nil, {}) end @@ -38,31 +38,31 @@ def test_connection_does_pass_requested_proxy @connection.proxy_port = 8080 spy = Net::HTTP.new('example.com', 443) Net::HTTP.expects(:new).with('example.com', 443, "proxy.example.com", 8080).returns(spy) - spy.expects(:get).with('/tx.php', {}).returns(@ok) + spy.expects(:get).with('/tx.php', {'connection' => 'close'}).returns(@ok) @connection.request(:get, nil, {}) end def test_successful_get_request @connection.logger.expects(:info).twice - Net::HTTP.any_instance.expects(:get).with('/tx.php', {}).returns(@ok) + Net::HTTP.any_instance.expects(:get).with('/tx.php', {'connection' => 'close'}).returns(@ok) response = @connection.request(:get, nil, {}) assert_equal 'success', response.body end def test_successful_post_request - Net::HTTP.any_instance.expects(:post).with('/tx.php', 'data', ActiveMerchant::Connection::RUBY_184_POST_HEADERS).returns(@ok) + Net::HTTP.any_instance.expects(:post).with('/tx.php', 'data', ActiveMerchant::Connection::RUBY_184_POST_HEADERS.merge({'connection' => 'close'})).returns(@ok) response = @connection.request(:post, 'data', {}) assert_equal 'success', response.body end def test_successful_put_request - Net::HTTP.any_instance.expects(:put).with('/tx.php', 'data', {}).returns(@ok) + Net::HTTP.any_instance.expects(:put).with('/tx.php', 'data', {'connection' => 'close'}).returns(@ok) response = @connection.request(:put, 'data', {}) assert_equal 'success', response.body end def test_successful_delete_request - Net::HTTP.any_instance.expects(:delete).with('/tx.php', {}).returns(@ok) + Net::HTTP.any_instance.expects(:delete).with('/tx.php', {'connection' => 'close'}).returns(@ok) response = @connection.request(:delete, nil, {}) assert_equal 'success', response.body end From a0efb7d12211794c4a3ec813cac613952d122250 Mon Sep 17 00:00:00 2001 From: Bart de Water <bart.dewater@shopify.com> Date: Thu, 31 May 2018 15:50:27 -0400 Subject: [PATCH 415/677] Release 1.79.1 --- CHANGELOG | 3 +++ lib/active_merchant/version.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 125b8139db6..af42441a284 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ = ActiveMerchant CHANGELOG == HEAD + +== Version 1.79.1 (May 31, 2018) +* Fix Net::HTTP connections defaulting to connection: keep-alive instead of close since #2862 [bpollack] #2868 * Mundipagg: allow passing holder_document for credit card purchases [bpollack] #2864 * Conekta: support monthly_installments [bpollack] #2866 * Authorize.net: allow sending email_customer set to false [bpollack] #2867 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index dda47f0fa5d..5f684df061b 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.79.0" + VERSION = "1.79.1" end From df6690788bc55746f07627a427590cf472b6186a Mon Sep 17 00:00:00 2001 From: Bart de Water <bart.dewater@shopify.com> Date: Sat, 2 Jun 2018 19:53:17 -0400 Subject: [PATCH 416/677] Release 1.79.2 --- CHANGELOG | 3 +++ lib/active_merchant/posts_data.rb | 2 +- lib/active_merchant/version.rb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index af42441a284..e2fca3c6617 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,9 @@ == HEAD +== Version 1.79.2 (June 2, 2018) +* Fix Gateway#max_version= overwriting min_version [bdewater] + == Version 1.79.1 (May 31, 2018) * Fix Net::HTTP connections defaulting to connection: keep-alive instead of close since #2862 [bpollack] #2868 * Mundipagg: allow passing holder_document for credit card purchases [bpollack] #2864 diff --git a/lib/active_merchant/posts_data.rb b/lib/active_merchant/posts_data.rb index db81049df24..e7de9be2f99 100644 --- a/lib/active_merchant/posts_data.rb +++ b/lib/active_merchant/posts_data.rb @@ -12,7 +12,7 @@ def self.included(base) base.min_version = nil base.class_attribute :max_version - base.min_version = nil + base.max_version = nil base.class_attribute :retry_safe base.retry_safe = false diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 5f684df061b..199852f1e00 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.79.1" + VERSION = "1.79.2" end From 41d677acaceaed185a55282d23cdd3a8b3cb7bd8 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 4 Jun 2018 11:05:41 -0400 Subject: [PATCH 417/677] Paymentez: handle server internal errors For the last couple of weeks, Paymentez has been 500ing and sending down HTML pages, which crashes the JSON parser and results in less-than-helpful exception. This patch handles HTML responses without crashing. NB, the remote test failures are because not all Paymentez gateways support authorize, and the remote tests do hit them, but they otherwise are fine. Unit: 17 tests, 50 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 15 tests, 29 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 73.3333% passed Closes #2871 --- .../billing/gateways/paymentez.rb | 7 +++++- test/unit/gateways/paymentez_test.rb | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index 836ed968b4e..5a3a83c87a2 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -171,7 +171,12 @@ def commit_raw(object, action, parameters) rescue ResponseError => e raw_response = e.response.body end - parse(raw_response) + + begin + parse(raw_response) + rescue JSON::ParserError + {'status' => 'Internal server error'} + end end def commit_transaction(action, parameters) diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb index 5e603b66fcf..ef10ed75b74 100644 --- a/test/unit/gateways/paymentez_test.rb +++ b/test/unit/gateways/paymentez_test.rb @@ -141,6 +141,14 @@ def test_complex_store assert_success response end + def test_paymentez_crashes_fail + @gateway.stubs(:ssl_post).returns(crash_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed @@ -410,4 +418,18 @@ def expired_card_response } ) end + + def crash_response + %q( + <html> + <head> + <title>Internal Server Error</title> + </head> + <body> + <h1><p>Internal Server Error</p></h1> + + </body> + </html> + ) + end end From e4bc5366768cf092d29e8c6d708803a57919b7e8 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 4 Jun 2018 13:59:22 -0400 Subject: [PATCH 418/677] Add missing CHANGELOG entry for #2871 --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index e2fca3c6617..883dfed8a25 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Paymentez: return a Result object even when the upstream server 500s [bpollack] #2871 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] From 46a422f23275d1c7c0036472b9556bba9d138be5 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 30 May 2018 17:18:11 -0400 Subject: [PATCH 419/677] Require Ruby 2.3 or higher Rubies older than 2.3.6 are outside maintenance, so this honestly seems like the bare minimum for a payment gem. Closes #2863 --- .travis.yml | 3 +-- CHANGELOG | 1 + README.md | 4 ++++ activemerchant.gemspec | 2 +- circle.yml | 2 +- lib/active_merchant/billing/gateways/cc5.rb | 4 +--- lib/active_merchant/billing/gateways/garanti.rb | 4 +--- test/remote/gateways/remote_finansbank_test.rb | 5 ----- test/remote/gateways/remote_garanti_test.rb | 5 ----- test/unit/gateways/finansbank_test.rb | 4 ---- test/unit/gateways/garanti_test.rb | 9 +-------- test/unit/network_connection_retries_test.rb | 11 +++-------- 12 files changed, 14 insertions(+), 40 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3454346d6e2..903c2e0e197 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,6 @@ rvm: - 2.5 - 2.4 - 2.3 -- 2.2 gemfile: - Gemfile.rails52 @@ -21,7 +20,7 @@ gemfile: matrix: include: - - rvm: 2.1 + - rvm: 2.3 gemfile: Gemfile.rails42 notifications: diff --git a/CHANGELOG b/CHANGELOG index 883dfed8a25..6349f5ff6bf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * Paymentez: return a Result object even when the upstream server 500s [bpollack] #2871 +* Drop support for Ruby versions older than 2.3 [bpollack] #2863 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/README.md b/README.md index 02aa7b4e486..12a517c49f3 100644 --- a/README.md +++ b/README.md @@ -232,3 +232,7 @@ The [ActiveMerchant Wiki](http://github.com/activemerchant/active_merchant/wikis ## API stability policy Functionality or APIs that are deprecated will be marked as such. Deprecated functionality is removed on major version changes - for example, deprecations from 2.x are removed in 3.x. + +## Ruby and Rails compatibility policies + +Because Active Merchant is a payment library, it needs to take security seriously. For this reason, Active Merchant guarantees compatibility only with actively supported versions of Ruby and Rails. At the time of this writing, that means that Ruby 2.3+ and Rails 4.2+ are supported. diff --git a/activemerchant.gemspec b/activemerchant.gemspec index b273850c216..184547471e3 100644 --- a/activemerchant.gemspec +++ b/activemerchant.gemspec @@ -14,7 +14,7 @@ Gem::Specification.new do |s| s.homepage = 'http://activemerchant.org/' s.rubyforge_project = 'activemerchant' - s.required_ruby_version = '>= 2.1' + s.required_ruby_version = '>= 2.3' s.files = Dir['CHANGELOG', 'README.md', 'MIT-LICENSE', 'CONTRIBUTORS', 'lib/**/*', 'vendor/**/*'] s.require_path = 'lib' diff --git a/circle.yml b/circle.yml index b6aab8e1717..5d2a53e5abb 100644 --- a/circle.yml +++ b/circle.yml @@ -1,6 +1,6 @@ machine: ruby: - version: '2.1.0' + version: '2.3.0' dependencies: cache_directories: diff --git a/lib/active_merchant/billing/gateways/cc5.rb b/lib/active_merchant/billing/gateways/cc5.rb index 6efc099db15..8ae9fbaded0 100644 --- a/lib/active_merchant/billing/gateways/cc5.rb +++ b/lib/active_merchant/billing/gateways/cc5.rb @@ -190,10 +190,8 @@ def normalize(text) if ActiveSupport::Inflector.method(:transliterate).arity == -2 ActiveSupport::Inflector.transliterate(text,'') - elsif RUBY_VERSION >= '1.9' - text.gsub(/[^\x00-\x7F]+/, '') else - ActiveSupport::Inflector.transliterate(text).to_s + text.gsub(/[^\x00-\x7F]+/, '') end end end diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb index 34533bca4bb..31f9f55ee48 100644 --- a/lib/active_merchant/billing/gateways/garanti.rb +++ b/lib/active_merchant/billing/gateways/garanti.rb @@ -197,10 +197,8 @@ def normalize(text) if ActiveSupport::Inflector.method(:transliterate).arity == -2 ActiveSupport::Inflector.transliterate(text,'') - elsif RUBY_VERSION >= '1.9' - text.gsub(/[^\x00-\x7F]+/, '') else - ActiveSupport::Inflector.transliterate(text).to_s + text.gsub(/[^\x00-\x7F]+/, '') end end diff --git a/test/remote/gateways/remote_finansbank_test.rb b/test/remote/gateways/remote_finansbank_test.rb index c8887cf4ae4..9338e31fd10 100644 --- a/test/remote/gateways/remote_finansbank_test.rb +++ b/test/remote/gateways/remote_finansbank_test.rb @@ -3,11 +3,6 @@ class RemoteFinansbankTest < Test::Unit::TestCase def setup - if RUBY_VERSION < '1.9' && $KCODE == "NONE" - @original_kcode = $KCODE - $KCODE = 'u' - end - @gateway = FinansbankGateway.new(fixtures(:finansbank)) @amount = 100 diff --git a/test/remote/gateways/remote_garanti_test.rb b/test/remote/gateways/remote_garanti_test.rb index 706dd627031..97c0b616914 100644 --- a/test/remote/gateways/remote_garanti_test.rb +++ b/test/remote/gateways/remote_garanti_test.rb @@ -4,11 +4,6 @@ class RemoteGarantiTest < Test::Unit::TestCase def setup - if RUBY_VERSION < '1.9' && $KCODE == "NONE" - @original_kcode = $KCODE - $KCODE = 'u' - end - @gateway = GarantiGateway.new(fixtures(:garanti)) @amount = 100 # 1 cents = 0.01$ diff --git a/test/unit/gateways/finansbank_test.rb b/test/unit/gateways/finansbank_test.rb index efdd29845c4..4d4553366fd 100644 --- a/test/unit/gateways/finansbank_test.rb +++ b/test/unit/gateways/finansbank_test.rb @@ -4,10 +4,6 @@ class FinansbankTest < Test::Unit::TestCase def setup @original_kcode = nil - if RUBY_VERSION < '1.9' && $KCODE == "NONE" - @original_kcode = $KCODE - $KCODE = 'u' - end @gateway = FinansbankGateway.new( :login => 'login', diff --git a/test/unit/gateways/garanti_test.rb b/test/unit/gateways/garanti_test.rb index cd1ecf19482..5b8287bb018 100644 --- a/test/unit/gateways/garanti_test.rb +++ b/test/unit/gateways/garanti_test.rb @@ -5,10 +5,6 @@ class GarantiTest < Test::Unit::TestCase def setup @original_kcode = nil - if RUBY_VERSION < '1.9' && $KCODE == "NONE" - @original_kcode = $KCODE - $KCODE = 'u' - end Base.mode = :test @gateway = GarantiGateway.new(:login => 'a', :password => 'b', :terminal_id => 'c', :merchant_id => 'd') @@ -51,12 +47,9 @@ def test_character_normalization if ActiveSupport::Inflector.method(:transliterate).arity == -2 assert_equal 'ABCCDEFGGHIIJKLMNOOPRSSTUUVYZ', @gateway.send(:normalize, 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ') assert_equal 'abccdefgghiijklmnooprsstuuvyz', @gateway.send(:normalize, 'abcçdefgğhıijklmnoöprsştuüvyz') - elsif RUBY_VERSION >= '1.9' + else assert_equal 'ABCDEFGHIJKLMNOPRSTUVYZ', @gateway.send(:normalize, 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ') assert_equal 'abcdefghijklmnoprstuvyz', @gateway.send(:normalize, 'abcçdefgğhıijklmnoöprsştuüvyz') - else - assert_equal 'ABCCDEFGGHIIJKLMNOOPRSSTUUVYZ', @gateway.send(:normalize, 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ') - assert_equal 'abccdefgghijklmnooprsstuuvyz', @gateway.send(:normalize, 'abcçdefgğhıijklmnoöprsştuüvyz') end end diff --git a/test/unit/network_connection_retries_test.rb b/test/unit/network_connection_retries_test.rb index 44afcf0fb2d..aff10190667 100644 --- a/test/unit/network_connection_retries_test.rb +++ b/test/unit/network_connection_retries_test.rb @@ -32,10 +32,7 @@ def test_econnreset_raises_correctly end def test_timeout_errors_raise_correctly - exceptions = [Timeout::Error, Errno::ETIMEDOUT] - if RUBY_VERSION >= '2.0.0' - exceptions += [Net::ReadTimeout, Net::OpenTimeout] - end + exceptions = [Timeout::Error, Errno::ETIMEDOUT, Net::ReadTimeout, Net::OpenTimeout] exceptions.each do |exception| raised = assert_raises(ActiveMerchant::ConnectionError) do @@ -57,10 +54,8 @@ def test_socket_error_raises_correctly end def test_ssl_errors_raise_correctly - exceptions = [OpenSSL::SSL::SSLError] - if RUBY_VERSION >= '2.1.0' - exceptions += [OpenSSL::SSL::SSLErrorWaitWritable, OpenSSL::SSL::SSLErrorWaitReadable] - end + exceptions = [OpenSSL::SSL::SSLError, OpenSSL::SSL::SSLErrorWaitWritable, + OpenSSL::SSL::SSLErrorWaitReadable] exceptions.each do |exception| raised = assert_raises(ActiveMerchant::ConnectionError) do From e48a6a81e8deb47460710c3aae8fd841ec63adda Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 4 Jun 2018 14:16:54 -0400 Subject: [PATCH 420/677] Bridge Pay: don't throw when account_type omitted One remote test fails (for echecks, no less), but it does so both with and without this patch, and the error appears internal (it fails with a .NET XSD validation error for an element we're not sending and isn't documented). Unit: 14 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 17 tests, 38 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 94.1176% passed Closes #2873 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/bridge_pay.rb | 2 +- test/unit/gateways/bridge_pay_test.rb | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 6349f5ff6bf..f56d4422933 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * Paymentez: return a Result object even when the upstream server 500s [bpollack] #2871 * Drop support for Ruby versions older than 2.3 [bpollack] #2863 +* Bridge Pay: don't throw an exception when bank account type is omitted [bpollack] #2873 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/bridge_pay.rb b/lib/active_merchant/billing/gateways/bridge_pay.rb index 2754a20428b..90b7cc6c5d8 100644 --- a/lib/active_merchant/billing/gateways/bridge_pay.rb +++ b/lib/active_merchant/billing/gateways/bridge_pay.rb @@ -114,7 +114,7 @@ def add_payment_method(post, payment_method) post[:TransitNum] = payment_method.routing_number post[:AccountNum] = payment_method.account_number post[:NameOnCheck] = payment_method.name - post[:ExtData] = "<AccountType>#{payment_method.account_type.capitalize}</AccountType>" + post[:ExtData] = "<AccountType>#{payment_method.account_type[0].capitalize}</AccountType>" if payment_method.account_type end end diff --git a/test/unit/gateways/bridge_pay_test.rb b/test/unit/gateways/bridge_pay_test.rb index 85b9579b9fd..5a0e640a08b 100644 --- a/test/unit/gateways/bridge_pay_test.rb +++ b/test/unit/gateways/bridge_pay_test.rb @@ -45,6 +45,14 @@ def test_successful_purchase_with_echeck assert response.test? end + def test_failed_purchase_with_bad_echeck + @gateway.expects(:ssl_post).returns(failed_purchase_response) + + @check.account_type = nil + response = @gateway.purchase(@amount, @check) + assert_failure response + end + def test_authorize_and_capture response = stub_comms do @gateway.authorize(@amount, @credit_card) From 79c46f7ae1e33c24998f2d021888b64c22ef4e4e Mon Sep 17 00:00:00 2001 From: Tom Scott <tscott@weblinc.com> Date: Mon, 4 Jun 2018 14:35:05 -0400 Subject: [PATCH 421/677] Fix WebMock regression in 1.79.2 Since Webmock [overrides the Net::HTTP#start method](https://github.com/bblimke/webmock/blob/master/lib/webmock/http_lib_adapters/net_http.rb#L144) to simulate HTTP requests, unsafe usage of `@socket` in ActiveMerchant's `Net::HTTP#ssl_connection` refinement caused cryptic errors in tests that used VCR along with ActiveMerchant: ``` MyProject::TotallyFabulousIntegrationTest#test_fabulosity: NoMethodError: undefined method `io' for nil:NilClass test/test_helper.rb:44:in `use_cassette' .../gems/activemerchant-1.79.0/lib/active_merchant/net_http_ssl_connection.rb:6:in `ssl_connection' .../gems/activemerchant-1.79.0/lib/active_merchant/connection.rb:78:in `block (2 levels) in request' ... ``` --- lib/active_merchant/net_http_ssl_connection.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/active_merchant/net_http_ssl_connection.rb b/lib/active_merchant/net_http_ssl_connection.rb index ed359ae67e2..d0764cbc615 100644 --- a/lib/active_merchant/net_http_ssl_connection.rb +++ b/lib/active_merchant/net_http_ssl_connection.rb @@ -3,6 +3,7 @@ module NetHttpSslConnection refine Net::HTTP do def ssl_connection + return {} unless @socket.present? { version: @socket.io.ssl_version, cipher: @socket.io.cipher[0] } end end From f75f57e55c4cab9d2673a564243a15f810bdcb9e Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 4 Jun 2018 16:43:01 -0400 Subject: [PATCH 422/677] Do not make remote connections in unit tests Blue Snap and Mundipagg unit tests made remote connections. Now they don't. Blue Snap units: 18 tests, 68 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Mundipagg units: 16 tests, 71 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2875 --- CHANGELOG | 1 + test/unit/gateways/blue_snap_test.rb | 4 ++-- test/unit/gateways/mundipagg_test.rb | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f56d4422933..6c6f5696612 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * Paymentez: return a Result object even when the upstream server 500s [bpollack] #2871 * Drop support for Ruby versions older than 2.3 [bpollack] #2863 * Bridge Pay: don't throw an exception when bank account type is omitted [bpollack] #2873 +* Avoid making actual connections in Blue Snap and Mundipagg unit tests [bpollack] #2875 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb index 19689062d91..2355fc81389 100644 --- a/test/unit/gateways/blue_snap_test.rb +++ b/test/unit/gateways/blue_snap_test.rb @@ -123,9 +123,9 @@ def test_failed_store end def test_currency_added_correctly - stub_comms do + stub_comms(@gateway, :raw_ssl_request) do @gateway.purchase(@amount, @credit_card, @options.merge(currency: 'CAD')) - end.check_request do |endpoint, data, headers| + end.check_request do |method, url, data| assert_match(/<currency>CAD<\/currency>/, data) end.respond_with(successful_purchase_response) end diff --git a/test/unit/gateways/mundipagg_test.rb b/test/unit/gateways/mundipagg_test.rb index 62b29474c24..745add67c59 100644 --- a/test/unit/gateways/mundipagg_test.rb +++ b/test/unit/gateways/mundipagg_test.rb @@ -126,6 +126,7 @@ def test_failed_void end def test_successful_verify + @gateway.expects(:ssl_request).returns(successful_authorize_response) @gateway.expects(:ssl_post).returns(successful_verify_response) response = @gateway.verify(@credit_card, @options) From 3efa5c901aa327445056eff0496a398bf93237ba Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 5 Jun 2018 09:10:44 -0400 Subject: [PATCH 423/677] More aggressivley don't make connections The changes introduced for SSL logging cause our stubs in the connection test to fail, resulting in actual connections being made. This patch restores the stubs, and unit tests can no run with no connectivity whatsoever. 3855 tests, 67872 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed Closes #2876 --- CHANGELOG | 1 + test/unit/connection_test.rb | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6c6f5696612..830cf51dc0e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Drop support for Ruby versions older than 2.3 [bpollack] #2863 * Bridge Pay: don't throw an exception when bank account type is omitted [bpollack] #2873 * Avoid making actual connections in Blue Snap and Mundipagg unit tests [bpollack] #2875 +* Avoid making actual connections in the connection unit tests [bpollack] #2876 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index 1327f2df401..cf0c42d5f72 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -29,6 +29,7 @@ def test_connection_endpoint_raises_uri_error def test_connection_passes_env_proxy_by_default spy = Net::HTTP.new('example.com', 443) Net::HTTP.expects(:new).with('example.com', 443, :ENV, nil).returns(spy) + spy.expects(:start).returns(true) spy.expects(:get).with('/tx.php', {'connection' => 'close'}).returns(@ok) @connection.request(:get, nil, {}) end @@ -38,6 +39,7 @@ def test_connection_does_pass_requested_proxy @connection.proxy_port = 8080 spy = Net::HTTP.new('example.com', 443) Net::HTTP.expects(:new).with('example.com', 443, "proxy.example.com", 8080).returns(spy) + spy.expects(:start).returns(true) spy.expects(:get).with('/tx.php', {'connection' => 'close'}).returns(@ok) @connection.request(:get, nil, {}) end @@ -45,42 +47,49 @@ def test_connection_does_pass_requested_proxy def test_successful_get_request @connection.logger.expects(:info).twice Net::HTTP.any_instance.expects(:get).with('/tx.php', {'connection' => 'close'}).returns(@ok) + Net::HTTP.any_instance.expects(:start).returns(true) response = @connection.request(:get, nil, {}) assert_equal 'success', response.body end def test_successful_post_request Net::HTTP.any_instance.expects(:post).with('/tx.php', 'data', ActiveMerchant::Connection::RUBY_184_POST_HEADERS.merge({'connection' => 'close'})).returns(@ok) + Net::HTTP.any_instance.expects(:start).returns(true) response = @connection.request(:post, 'data', {}) assert_equal 'success', response.body end def test_successful_put_request Net::HTTP.any_instance.expects(:put).with('/tx.php', 'data', {'connection' => 'close'}).returns(@ok) + Net::HTTP.any_instance.expects(:start).returns(true) response = @connection.request(:put, 'data', {}) assert_equal 'success', response.body end def test_successful_delete_request Net::HTTP.any_instance.expects(:delete).with('/tx.php', {'connection' => 'close'}).returns(@ok) + Net::HTTP.any_instance.expects(:start).returns(true) response = @connection.request(:delete, nil, {}) assert_equal 'success', response.body end def test_successful_delete_with_body_request Net::HTTP.any_instance.expects(:request).at_most(3).returns(@ok) + Net::HTTP.any_instance.expects(:start).returns(true) response = @connection.request(:delete, 'data', {}) assert_equal 'success', response.body end def test_get_raises_argument_error_if_passed_data assert_raises(ArgumentError) do + Net::HTTP.any_instance.expects(:start).returns(true) @connection.request(:get, 'data', {}) end end def test_request_raises_when_request_method_not_supported assert_raises(ArgumentError) do + Net::HTTP.any_instance.expects(:start).returns(true) @connection.request(:head, nil, {}) end end @@ -164,7 +173,7 @@ def test_override_ca_path def test_unrecoverable_exception @connection.logger.expects(:info).once - Net::HTTP.any_instance.expects(:post).raises(EOFError) + Net::HTTP.any_instance.expects(:start).raises(EOFError) assert_raises(ActiveMerchant::ConnectionError) do @connection.request(:post, '') @@ -173,14 +182,15 @@ def test_unrecoverable_exception def test_failure_then_success_with_recoverable_exception @connection.logger.expects(:info).never - Net::HTTP.any_instance.expects(:post).times(2).raises(Errno::ECONNREFUSED).then.returns(@ok) + Net::HTTP.any_instance.expects(:start).times(2).raises(Errno::ECONNREFUSED).then.returns(true) + Net::HTTP.any_instance.expects(:post).returns(@ok) @connection.request(:post, '') end def test_failure_limit_reached @connection.logger.expects(:info).once - Net::HTTP.any_instance.expects(:post).times(ActiveMerchant::Connection::MAX_RETRIES).raises(Errno::ECONNREFUSED) + Net::HTTP.any_instance.expects(:start).times(ActiveMerchant::Connection::MAX_RETRIES).raises(Errno::ECONNREFUSED) assert_raises(ActiveMerchant::ConnectionError) do @connection.request(:post, '') @@ -188,7 +198,8 @@ def test_failure_limit_reached end def test_failure_then_success_with_retry_safe_enabled - Net::HTTP.any_instance.expects(:post).times(2).raises(EOFError).then.returns(@ok) + Net::HTTP.any_instance.expects(:start).times(2).raises(EOFError).then.returns(@ok) + Net::HTTP.any_instance.expects(:post).returns(@ok) @connection.retry_safe = true @@ -196,9 +207,9 @@ def test_failure_then_success_with_retry_safe_enabled end def test_mixture_of_failures_with_retry_safe_enabled - Net::HTTP.any_instance.expects(:post).times(3).raises(Errno::ECONNRESET). - raises(Errno::ECONNREFUSED). - raises(EOFError) + Net::HTTP.any_instance.expects(:start).times(3).raises(Errno::ECONNRESET). + raises(Errno::ECONNREFUSED). + raises(EOFError) @connection.retry_safe = true @@ -209,7 +220,7 @@ def test_mixture_of_failures_with_retry_safe_enabled def test_failure_with_ssl_certificate @connection.logger.expects(:error).once - Net::HTTP.any_instance.expects(:post).raises(OpenSSL::X509::CertificateError) + Net::HTTP.any_instance.expects(:start).raises(OpenSSL::X509::CertificateError) assert_raises(ActiveMerchant::ClientCertificateError) do @connection.request(:post, '') From 9190252c9dc78ec5a45cf0f4228153e16067a0dc Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 31 May 2018 09:30:15 -0400 Subject: [PATCH 424/677] Openpay: support payment installments One remote test fails with a 3DS-related error, but it does prior to this commit also. Unit: 20 tests, 102 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 24 tests, 80 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 95.8333% passed Closes #2865 --- lib/active_merchant/billing/gateways/openpay.rb | 2 ++ test/remote/gateways/remote_openpay_test.rb | 11 ++++++++--- test/unit/gateways/openpay_test.rb | 11 +++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/active_merchant/billing/gateways/openpay.rb b/lib/active_merchant/billing/gateways/openpay.rb index 811656cb075..4ad00ec4999 100644 --- a/lib/active_merchant/billing/gateways/openpay.rb +++ b/lib/active_merchant/billing/gateways/openpay.rb @@ -38,6 +38,7 @@ def authorize(money, creditcard, options = {}) def capture(money, authorization, options = {}) post = {} post[:amount] = amount(money) if money + post[:payments] = options[:payments] if options[:payments] commit(:post, "charges/#{CGI.escape(authorization)}/capture", post, options) end @@ -114,6 +115,7 @@ def create_post_for_auth_or_purchase(money, creditcard, options) post[:device_session_id] = options[:device_session_id] post[:currency] = (options[:currency] || currency(money)).upcase post[:use_card_points] = options[:use_card_points] if options[:use_card_points] + post[:payment_plan] = {payments: options[:payments]} if options[:payments] add_creditcard(post, creditcard, options) post end diff --git a/test/remote/gateways/remote_openpay_test.rb b/test/remote/gateways/remote_openpay_test.rb index 01cc9fab432..279531ef37b 100644 --- a/test/remote/gateways/remote_openpay_test.rb +++ b/test/remote/gateways/remote_openpay_test.rb @@ -31,7 +31,7 @@ def test_successful_purchase_with_email def test_unsuccessful_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal 'The card is not supported on online transactions', response.message + assert_equal 'The card was declined', response.message end def test_successful_refund @@ -69,7 +69,7 @@ def test_successful_authorize_with_email def test_unsuccessful_authorize assert response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal 'The card is not supported on online transactions', response.message + assert_equal 'The card was declined', response.message end def test_successful_capture @@ -131,6 +131,11 @@ def test_failed_purchase_with_card_points assert_match %r{cardNumber not allowed for Card points}, response.message end + def test_successful_purchase_with_installments + assert response = @gateway.purchase(@amount * 300, @store_card, @options.merge(payments: '3')) + assert_success response + end + def test_successful_store new_email_address = '%d@example.org' % Time.now assert response = @gateway.store(@credit_card, name: 'Test User', email: new_email_address) @@ -160,7 +165,7 @@ def test_successful_verify def test_unsuccessful_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_match /The card is not supported/, response.message + assert_match /The card was declined/, response.message end def test_invalid_login diff --git a/test/unit/gateways/openpay_test.rb b/test/unit/gateways/openpay_test.rb index e3d55229688..7355647e382 100644 --- a/test/unit/gateways/openpay_test.rb +++ b/test/unit/gateways/openpay_test.rb @@ -178,6 +178,17 @@ def test_passing_device_session_id assert_success response end + def test_passing_payment_installments + response = stub_comms(@gateway, :ssl_request) do + @gateway.purchase(@amount, @credit_card, payments: '6') + end.check_request do |method, endpoint, data, headers| + assert_match(%r{"payments":"6"}, data) + assert_match(%r{"payment_plan":}, data) + end.respond_with(successful_purchase_response) + + assert_success response + end + def test_transcript_scrubbing assert_equal scrubbed_transcript, @gateway.scrub(transcript) end From 984cdebe02032b7e42c9b526d42d8e4f8a1929dd Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 6 Jun 2018 12:30:35 -0400 Subject: [PATCH 425/677] Openpay: add missing CHANGELOG entry --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 830cf51dc0e..32f61e2aa0f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * Bridge Pay: don't throw an exception when bank account type is omitted [bpollack] #2873 * Avoid making actual connections in Blue Snap and Mundipagg unit tests [bpollack] #2875 * Avoid making actual connections in the connection unit tests [bpollack] #2876 +* Openpay: support payment installments [bpollack] #2865 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] From 53eaca1c8d6e88c0bd915645794a42a9f5dcb40e Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 6 Jun 2018 14:38:44 -0400 Subject: [PATCH 426/677] First Pay: add support for recurring payments Unit: 11 tests, 115 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 13 tests, 29 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2877 --- CHANGELOG | 1 + .../billing/gateways/first_pay.rb | 9 ++++++--- test/remote/gateways/remote_first_pay_test.rb | 7 +++++++ test/unit/gateways/first_pay_test.rb | 16 ++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 32f61e2aa0f..bd74083a880 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * Avoid making actual connections in Blue Snap and Mundipagg unit tests [bpollack] #2875 * Avoid making actual connections in the connection unit tests [bpollack] #2876 * Openpay: support payment installments [bpollack] #2865 +* First Pay: support recurring charges [bpollack] #2877 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb index c46353164b3..88f40b5513e 100644 --- a/lib/active_merchant/billing/gateways/first_pay.rb +++ b/lib/active_merchant/billing/gateways/first_pay.rb @@ -21,7 +21,7 @@ def initialize(options={}) def purchase(money, payment, options={}) post = {} add_invoice(post, money, options) - add_payment(post, payment) + add_payment(post, payment, options) add_address(post, payment, options) add_customer_data(post, options) @@ -31,7 +31,7 @@ def purchase(money, payment, options={}) def authorize(money, payment, options={}) post = {} add_invoice(post, money, options) - add_payment(post, payment) + add_payment(post, payment, options) add_address(post, payment, options) add_customer_data(post, options) @@ -87,11 +87,14 @@ def add_invoice(post, money, options) post[:total] = amount(money) end - def add_payment(post, payment) + def add_payment(post, payment, options) post[:card_name] = payment.brand # Unclear if need to map to known names or open text field?? post[:card_number] = payment.number post[:card_exp] = expdate(payment) post[:cvv2] = payment.verification_value + post[:recurring] = options[:recurring] if options[:recurring] + post[:recurringStartDate] = options[:recurring_start_date] if options[:recurring_start_date] + post[:recurringEndDate] = options[:recurring_end_date] if options[:recurring_end_date] end def add_reference(post, action, money, authorization) diff --git a/test/remote/gateways/remote_first_pay_test.rb b/test/remote/gateways/remote_first_pay_test.rb index 68607203107..923667078b3 100644 --- a/test/remote/gateways/remote_first_pay_test.rb +++ b/test/remote/gateways/remote_first_pay_test.rb @@ -109,4 +109,11 @@ def test_invalid_login response = gateway.purchase(@amount, @credit_card, @options) assert_failure response end + + def test_recurring_payment + @options.merge!({recurring: 'none', recurring_start_date: DateTime.now, recurring_end_date: DateTime.now}) + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Approved', response.message + end end diff --git a/test/unit/gateways/first_pay_test.rb b/test/unit/gateways/first_pay_test.rb index 5aa676f9faa..0b3de0f9c25 100644 --- a/test/unit/gateways/first_pay_test.rb +++ b/test/unit/gateways/first_pay_test.rb @@ -181,6 +181,22 @@ def test_failed_void assert response.message.include?('Void failed') end + def test_recurring_payments + @options[:recurring] = 'none' + @options[:recurring_start_date] = '01/01/1900' + @options[:recurring_end_date] = '02/02/1901' + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match(%r{<FIELD KEY="recurring">none</FIELD>}, data) + assert_match(%r{<FIELD KEY="recurringStartDate">01/01/1900</FIELD>}, data) + assert_match(%r{<FIELD KEY="recurringEndDate">02/02/1901</FIELD>}, data) + end.respond_with(successful_purchase_response) + + assert response + assert_success response + end + private def successful_purchase_response From d7ce1dcd2ffbb529d038c5c094d987a99e954595 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 6 Jun 2018 18:43:55 -0400 Subject: [PATCH 427/677] Bridge Pay: restore some aspects of check handling While the Bridge Pay docs seem to indicate that account_type should be `C` or `S`, practice indicates that's incorrect. Restore the old functionality. This is in response to https://github.com/activemerchant/active_merchant/commit/e48a6a81e8deb47460710c3aae8fd841ec63adda#commitcomment-29273916 Unit: 15 tests, 70 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 17 tests, 38 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 94.1176% passed Closes #2878 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/bridge_pay.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index bd74083a880..9fa3a381e41 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * Avoid making actual connections in the connection unit tests [bpollack] #2876 * Openpay: support payment installments [bpollack] #2865 * First Pay: support recurring charges [bpollack] #2877 +* Bridge Pay: pass full name of account type for echeck transactions [bpollack] #2878 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/bridge_pay.rb b/lib/active_merchant/billing/gateways/bridge_pay.rb index 90b7cc6c5d8..5c57828f51c 100644 --- a/lib/active_merchant/billing/gateways/bridge_pay.rb +++ b/lib/active_merchant/billing/gateways/bridge_pay.rb @@ -114,7 +114,7 @@ def add_payment_method(post, payment_method) post[:TransitNum] = payment_method.routing_number post[:AccountNum] = payment_method.account_number post[:NameOnCheck] = payment_method.name - post[:ExtData] = "<AccountType>#{payment_method.account_type[0].capitalize}</AccountType>" if payment_method.account_type + post[:ExtData] = "<AccountType>#{payment_method.account_type.capitalize}</AccountType>" if payment_method.account_type end end From f0a3cf1ec0412b5e054f2293caf5024cedf5d206 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 13 Jun 2018 16:38:26 -0400 Subject: [PATCH 428/677] Kuski: do not send extraTaxes if no value provided The failing remote test is a refund, which fails with a note that refunds for the test card aren't supported (I think; my Spanish isn't great). Unit: 8 tests, 45 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 9 tests, 27 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 88.8889% passed Closes #2886 --- CHANGELOG | 1 + .../billing/gateways/kushki.rb | 12 +-- test/unit/gateways/kushki_test.rb | 102 ++++++++++++++++++ 3 files changed, 106 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9fa3a381e41..3ca2b52afa0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * Openpay: support payment installments [bpollack] #2865 * First Pay: support recurring charges [bpollack] #2877 * Bridge Pay: pass full name of account type for echeck transactions [bpollack] #2878 +* Kushki: do not send 0 for tax values if tax values are not provided [bpollack] #2886 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/kushki.rb b/lib/active_merchant/billing/gateways/kushki.rb index ba0148b353f..0265235cd11 100644 --- a/lib/active_merchant/billing/gateways/kushki.rb +++ b/lib/active_merchant/billing/gateways/kushki.rb @@ -94,14 +94,7 @@ def add_amount_defaults(sum, money, options) sum[:iva] = 0 sum[:subtotalIva0] = 0 - if sum[:currency] == "COP" - extra_taxes = {} - extra_taxes[:propina] = 0 - extra_taxes[:tasaAeroportuaria] = 0 - extra_taxes[:agenciaDeViaje] = 0 - extra_taxes[:iac] = 0 - sum[:extraTaxes] = extra_taxes - else + if sum[:currency] != "COP" sum[:ice] = 0 end end @@ -112,7 +105,8 @@ def add_amount_by_country(sum, options) sum[:iva] = amount[:iva].to_f if amount[:iva] sum[:subtotalIva0] = amount[:subtotal_iva_0].to_f if amount[:subtotal_iva_0] sum[:ice] = amount[:ice].to_f if amount[:ice] - if extra_taxes = amount[:extra_taxes] && sum[:currency] == "COP" + if (extra_taxes = amount[:extra_taxes]) && sum[:currency] == "COP" + sum[:extraTaxes] ||= Hash.new sum[:extraTaxes][:propina] = extra_taxes[:propina].to_f if extra_taxes[:propina] sum[:extraTaxes][:tasaAeroportuaria] = extra_taxes[:tasa_aeroportuaria].to_f if extra_taxes[:tasa_aeroportuaria] sum[:extraTaxes][:agenciaDeViaje] = extra_taxes[:agencia_de_viaje].to_f if extra_taxes[:agencia_de_viaje] diff --git a/test/unit/gateways/kushki_test.rb b/test/unit/gateways/kushki_test.rb index 5aeb1a8af9c..c1fb7ded9c0 100644 --- a/test/unit/gateways/kushki_test.rb +++ b/test/unit/gateways/kushki_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class KushkiTest < Test::Unit::TestCase + include CommStub + def setup @gateway = KushkiGateway.new(public_merchant_id: '_', private_merchant_id: '_') @amount = 100 @@ -46,6 +48,106 @@ def test_successful_purchase_with_options assert response.test? end + def test_taxes_are_excluded_when_not_provided + options = { + currency: "COP", + amount: { + subtotal_iva_0: "4.95", + subtotal_iva: "10", + iva: "1.54", + ice: "3.50" + } + } + + amount = 100 * ( + options[:amount][:subtotal_iva_0].to_f + + options[:amount][:subtotal_iva].to_f + + options[:amount][:iva].to_f + + options[:amount][:ice].to_f + ) + + response = stub_comms do + @gateway.purchase(amount, @credit_card, options) + end.check_request do |endpoint, data, headers| + if /charges/ =~ endpoint + assert_no_match %r{extraTaxes}, data + end + end.respond_with(successful_charge_response, successful_token_response) + + assert_success response + end + + def test_partial_taxes_do_not_error + options = { + currency: "COP", + amount: { + subtotal_iva_0: "4.95", + subtotal_iva: "10", + iva: "1.54", + ice: "3.50", + extra_taxes: { + tasa_aeroportuaria: 0.2, + iac: 0.4 + } + } + } + + amount = 100 * ( + options[:amount][:subtotal_iva_0].to_f + + options[:amount][:subtotal_iva].to_f + + options[:amount][:iva].to_f + + options[:amount][:ice].to_f + ) + + response = stub_comms do + @gateway.purchase(amount, @credit_card, options) + end.check_request do |endpoint, data, headers| + if /charges/ =~ endpoint + assert_match %r{extraTaxes}, data + assert_no_match %r{propina}, data + assert_match %r{iac}, data + end + end.respond_with(successful_charge_response, successful_token_response) + + assert_success response + end + + def test_taxes_are_included_when_provided + options = { + currency: "COP", + amount: { + subtotal_iva_0: "4.95", + subtotal_iva: "10", + iva: "1.54", + ice: "3.50", + extra_taxes: { + propina: 0.1, + tasa_aeroportuaria: 0.2, + agencia_de_viaje: 0.3, + iac: 0.4 + } + } + } + + amount = 100 * ( + options[:amount][:subtotal_iva_0].to_f + + options[:amount][:subtotal_iva].to_f + + options[:amount][:iva].to_f + + options[:amount][:ice].to_f + ) + + response = stub_comms do + @gateway.purchase(amount, @credit_card, options) + end.check_request do |endpoint, data, headers| + if /charges/ =~ endpoint + assert_match %r{extraTaxes}, data + assert_match %r{propina}, data + end + end.respond_with(successful_charge_response, successful_token_response) + + assert_success response + end + def test_failed_purchase options = { amount: { From 067a653bf1d13bece632d0f23eb8d23061cb251c Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Wed, 13 Jun 2018 12:18:46 -0400 Subject: [PATCH 429/677] Payflow: Update ACH tests Remote tests were erroring due to the previous account number having reached it's "return limit" (despite this being in sandbox). The new number succeeds. Closes #2887 Remote: (All failures are due to the test account not being flagged for recurring profiles or unreferenced credits) 30 tests, 119 assertions, 9 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 70% passed Unit: 46 tests, 208 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + test/remote/gateways/remote_payflow_test.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 3ca2b52afa0..249a747bffa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * First Pay: support recurring charges [bpollack] #2877 * Bridge Pay: pass full name of account type for echeck transactions [bpollack] #2878 * Kushki: do not send 0 for tax values if tax values are not provided [bpollack] #2886 +* Payflow: Update ACH tests [curiousepic] #2887 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/test/remote/gateways/remote_payflow_test.rb b/test/remote/gateways/remote_payflow_test.rb index d9384f08854..021ec914a54 100644 --- a/test/remote/gateways/remote_payflow_test.rb +++ b/test/remote/gateways/remote_payflow_test.rb @@ -27,7 +27,7 @@ def setup @check = check( :routing_number => '111111118', - :account_number => '1234567801' + :account_number => '1111111111' ) end @@ -89,6 +89,16 @@ def test_successful_ach_purchase assert_not_nil response.authorization end + def test_ach_purchase_and_refund + assert response = @gateway.purchase(50, @check) + assert_success response + assert_equal 'Approved', response.message + assert !response.authorization.blank? + + assert credit = @gateway.refund(50, response.authorization) + assert_success credit + end + def test_successful_authorization assert response = @gateway.authorize(100, @credit_card, @options) assert_equal "Approved", response.message From 6a701dd05b699155745f1ecac1f9334111f693ac Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 14 Jun 2018 16:02:49 -0400 Subject: [PATCH 430/677] Credorax: support billing description field Pretty much all remote tests fail, saying the card has been declined, with no additional information. I'm tracking that down, but I'm disinclined to hold based on that. Unit: 19 tests, 89 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 19 tests, 27 assertions, 10 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 47.3684% passed Closes #2889 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/credorax.rb | 1 + test/unit/gateways/credorax_test.rb | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 249a747bffa..1d49cc14bd0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Bridge Pay: pass full name of account type for echeck transactions [bpollack] #2878 * Kushki: do not send 0 for tax values if tax values are not provided [bpollack] #2886 * Payflow: Update ACH tests [curiousepic] #2887 +* Credorax: support passing billing description [bpollack] #2889 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb index 0a57a4b0e21..9cb25e45f14 100644 --- a/lib/active_merchant/billing/gateways/credorax.rb +++ b/lib/active_merchant/billing/gateways/credorax.rb @@ -215,6 +215,7 @@ def add_invoice(post, money, options) post[:a1] = generate_unique_id post[:a5] = currency post[:h9] = options[:order_id] + post[:i2] = options[:billing_descriptor] if options[:billing_descriptor] end CARD_TYPES = { diff --git a/test/unit/gateways/credorax_test.rb b/test/unit/gateways/credorax_test.rb index 6a404ded066..c204f9664b0 100644 --- a/test/unit/gateways/credorax_test.rb +++ b/test/unit/gateways/credorax_test.rb @@ -214,6 +214,15 @@ def test_adds_a9_field end.respond_with(successful_purchase_response) end + def test_supports_billing_descriptor + @options.merge!({ billing_descriptor: "abcdefghijkl"}) + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match /i2=abcdefghijkl/, data + end.respond_with(successful_purchase_response) + end + private def successful_purchase_response From fea3cc1af7890395242c019e9a863b4bb1246f1e Mon Sep 17 00:00:00 2001 From: Abdullah Barrak <a@abarrak.com> Date: Thu, 1 Mar 2018 23:42:41 +0300 Subject: [PATCH 431/677] MiGS: scrub sensitive 3DS fields Scrub the 3DS `xid` and `cavv` from the transcript. Unit Test: 5 tests, 17 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote Test (1 unrelated error: due old `offsite_purchase` test setup): 13 tests, 39 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications 92.3077% passed Closes #2771 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/migs.rb | 4 +++- test/remote/gateways/remote_migs_test.rb | 25 +++++++++++++++++++- test/unit/gateways/migs_test.rb | 8 +++---- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1d49cc14bd0..619f0403aeb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * Kushki: do not send 0 for tax values if tax values are not provided [bpollack] #2886 * Payflow: Update ACH tests [curiousepic] #2887 * Credorax: support passing billing description [bpollack] #2889 +* MiGS: scrub 3DS fields [abarrak] #2771 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb index 7995805e1a5..39b3d9f2cd3 100644 --- a/lib/active_merchant/billing/gateways/migs.rb +++ b/lib/active_merchant/billing/gateways/migs.rb @@ -213,7 +213,9 @@ def scrub(transcript) gsub(%r((&?CardNum=)\d*(&?)), '\1[FILTERED]\2'). gsub(%r((&?CardSecurityCode=)\d*(&?)), '\1[FILTERED]\2'). gsub(%r((&?AccessCode=)[^&]*(&?)), '\1[FILTERED]\2'). - gsub(%r((&?Password=)[^&]*(&?)), '\1[FILTERED]\2') + gsub(%r((&?Password=)[^&]*(&?)), '\1[FILTERED]\2'). + gsub(%r((&?3DSXID=)[^&]*(&?)), '\1[FILTERED]\2'). + gsub(%r((&?VerToken=)[^&]*(&?)), '\1[FILTERED]\2') end private diff --git a/test/remote/gateways/remote_migs_test.rb b/test/remote/gateways/remote_migs_test.rb index c6b83c56195..3e6f3ae43f6 100644 --- a/test/remote/gateways/remote_migs_test.rb +++ b/test/remote/gateways/remote_migs_test.rb @@ -20,6 +20,15 @@ def setup :order_id => '1', :currency => 'SAR' } + + @three_ds_options = { + :VerType => '3DS', + :VerToken => 'AAACAFBEUBgoAhEAIURQAAAAAAA=', + '3DSXID' => 'NWJlZDJmYzkyMTU1NGEwNzk1YjA=', + '3DSECI' => '02', + '3DSenrolled' => 'Y', + '3DSstatus' => 'A' + } end def test_server_purchase_url @@ -36,7 +45,7 @@ def test_server_purchase_url responses = { 'visa' => /You have chosen .*VISA.*/, - 'master' => /You have chosen .*MasterCard.*/, + 'master' => /You have chosen .*MasterCard.*/ } responses.each_pair do |card_type, response_text| @@ -134,6 +143,20 @@ def test_transcript_scrubbing_of_advanced_password assert_scrubbed(@gateway.options[:advanced_password], transcript) end + def test_transcript_scrubbing_of_3ds_cavv_and_xid_values + opts = @options.merge(@three_ds_options) + + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, opts) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(opts[:VerToken], transcript) + assert_scrubbed(opts['3DSXID'], transcript) + end + private def assert_response_match(regexp, url) diff --git a/test/unit/gateways/migs_test.rb b/test/unit/gateways/migs_test.rb index f34b624c01c..4a0bd12a5b1 100644 --- a/test/unit/gateways/migs_test.rb +++ b/test/unit/gateways/migs_test.rb @@ -103,7 +103,7 @@ def pre_scrubbed starting SSL for migs.mastercard.com.au:443... SSL established <- "POST /vpcdps 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: migs.mastercard.com.au\r\nContent-Length: 354\r\n\r\n" -<- "vpc_Amount=100&vpc_Currency=SAR&vpc_OrderInfo=1&vpc_CardNum=4987654321098769&vpc_CardSecurityCode=123&vpc_CardExp=2105&vpc_Version=1&vpc_Merchant=TESTH-STATION&vpc_AccessCode=F1CE6F32&vpc_Command=pay&vpc_MerchTxnRef=84c1f31ded35dea26ac297fd7ba092da&vpc_SecureHash=CD1B2B8BC325C6C8FC1A041AD6AC90821984277113DF708B16B37809E7B0EC33&vpc_SecureHashType=SHA256" +<- "vpc_Amount=100&vpc_Currency=SAR&vpc_OrderInfo=1&vpc_CardNum=4987654321098769&vpc_CardSecurityCode=123&vpc_CardExp=2105&vpc_Version=1&vpc_Merchant=TESTH-STATION&vpc_AccessCode=F1CE6F32&vpc_Command=pay&vpc_MerchTxnRef=84c1f31ded35dea26ac297fd7ba092da&vpc_SecureHash=CD1B2B8BC325C6C8FC1A041AD6AC90821984277113DF708B16B37809E7B0EC33&vpc_SecureHashType=SHA256&vpc_VerType=3DS&vpc_3DSXID=YzRjZWRjODY4MmY2NGQ3ZTgzNDQ&vpc_VerToken=AAACAgeVABgnAggAQ5UAAAAAAAA&vpc_3DSenrolled=Y&vpc_3DSECI=05&3DSstatus=Y" -> "HTTP/1.1 200 OK\r\n" -> "Date: Tue, 13 Feb 2018 19:02:18 GMT\r\n" -> "Expires: Sun, 15 Jul 1990 00:00:00 GMT\r\n" @@ -116,7 +116,7 @@ def pre_scrubbed -> "Set-Cookie: TS01c4b9ca=01fb8d8de2ba6ffaf7439497dd78d9b3348c82bcf24d4619e65a406161e57276b6b293e77732a293be63bf750213e588797bc86f05; Path=/; Secure; HTTPOnly\r\n" -> "\r\n" reading 595 bytes... --> "vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=100&vpc_AuthorizeId=239491&vpc_BatchNo=20180214&vpc_CSCResultCode=Unsupported&vpc_Card=VC&vpc_Command=pay&vpc_Currency=SAR&vpc_Locale=en_SA&vpc_MerchTxnRef=84c1f31ded35dea26ac297fd7ba092da&vpc_Merchant=TESTH-STATION&vpc_Message=Approved&vpc_OrderInfo=1&vpc_ReceiptNo=804506239491&vpc_RiskOverallResult=ACC&vpc_SecureHash=99993E000461810D9F71B1A4FC5EA2D68DF6BA1F7EBA6A9FC544DA035627C03C&vpc_SecureHashType=SHA256&vpc_TransactionNo=372&vpc_TxnResponseCode=0&vpc_Version=1" +-> "vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=100&vpc_AuthorizeId=239491&vpc_BatchNo=20180214&vpc_CSCResultCode=Unsupported&vpc_Card=VC&vpc_Command=pay&vpc_Currency=SAR&vpc_Locale=en_SA&vpc_MerchTxnRef=84c1f31ded35dea26ac297fd7ba092da&vpc_Merchant=TESTH-STATION&vpc_Message=Approved&vpc_OrderInfo=1&vpc_ReceiptNo=804506239491&vpc_RiskOverallResult=ACC&vpc_SecureHash=99993E000461810D9F71B1A4FC5EA2D68DF6BA1F7EBA6A9FC544DA035627C03C&vpc_SecureHashType=SHA256&vpc_TransactionNo=372&vpc_TxnResponseCode=0&vpc_Version=1&vpc_VerType=3DS&vpc_3DSXID=YzRjZWRjODY4MmY2NGQ3ZTgzNDQ&vpc_VerToken=AAACAgeVABgnAggAQ5UAAAAAAAA&vpc_3DSenrolled=Y&vpc_3DSECI=05&3DSstatus=Y" read 595 bytes Conn close EOS @@ -129,7 +129,7 @@ def post_scrubbed starting SSL for migs.mastercard.com.au:443... SSL established <- "POST /vpcdps 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: migs.mastercard.com.au\r\nContent-Length: 354\r\n\r\n" -<- "vpc_Amount=100&vpc_Currency=SAR&vpc_OrderInfo=1&vpc_CardNum=[FILTERED]&vpc_CardSecurityCode=[FILTERED]&vpc_CardExp=2105&vpc_Version=1&vpc_Merchant=TESTH-STATION&vpc_AccessCode=[FILTERED]&vpc_Command=pay&vpc_MerchTxnRef=84c1f31ded35dea26ac297fd7ba092da&vpc_SecureHash=CD1B2B8BC325C6C8FC1A041AD6AC90821984277113DF708B16B37809E7B0EC33&vpc_SecureHashType=SHA256" +<- "vpc_Amount=100&vpc_Currency=SAR&vpc_OrderInfo=1&vpc_CardNum=[FILTERED]&vpc_CardSecurityCode=[FILTERED]&vpc_CardExp=2105&vpc_Version=1&vpc_Merchant=TESTH-STATION&vpc_AccessCode=[FILTERED]&vpc_Command=pay&vpc_MerchTxnRef=84c1f31ded35dea26ac297fd7ba092da&vpc_SecureHash=CD1B2B8BC325C6C8FC1A041AD6AC90821984277113DF708B16B37809E7B0EC33&vpc_SecureHashType=SHA256&vpc_VerType=3DS&vpc_3DSXID=[FILTERED]&vpc_VerToken=[FILTERED]&vpc_3DSenrolled=Y&vpc_3DSECI=05&3DSstatus=Y" -> "HTTP/1.1 200 OK\r\n" -> "Date: Tue, 13 Feb 2018 19:02:18 GMT\r\n" -> "Expires: Sun, 15 Jul 1990 00:00:00 GMT\r\n" @@ -142,7 +142,7 @@ def post_scrubbed -> "Set-Cookie: TS01c4b9ca=01fb8d8de2ba6ffaf7439497dd78d9b3348c82bcf24d4619e65a406161e57276b6b293e77732a293be63bf750213e588797bc86f05; Path=/; Secure; HTTPOnly\r\n" -> "\r\n" reading 595 bytes... --> "vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=100&vpc_AuthorizeId=239491&vpc_BatchNo=20180214&vpc_CSCResultCode=Unsupported&vpc_Card=VC&vpc_Command=pay&vpc_Currency=SAR&vpc_Locale=en_SA&vpc_MerchTxnRef=84c1f31ded35dea26ac297fd7ba092da&vpc_Merchant=TESTH-STATION&vpc_Message=Approved&vpc_OrderInfo=1&vpc_ReceiptNo=804506239491&vpc_RiskOverallResult=ACC&vpc_SecureHash=99993E000461810D9F71B1A4FC5EA2D68DF6BA1F7EBA6A9FC544DA035627C03C&vpc_SecureHashType=SHA256&vpc_TransactionNo=372&vpc_TxnResponseCode=0&vpc_Version=1" +-> "vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=100&vpc_AuthorizeId=239491&vpc_BatchNo=20180214&vpc_CSCResultCode=Unsupported&vpc_Card=VC&vpc_Command=pay&vpc_Currency=SAR&vpc_Locale=en_SA&vpc_MerchTxnRef=84c1f31ded35dea26ac297fd7ba092da&vpc_Merchant=TESTH-STATION&vpc_Message=Approved&vpc_OrderInfo=1&vpc_ReceiptNo=804506239491&vpc_RiskOverallResult=ACC&vpc_SecureHash=99993E000461810D9F71B1A4FC5EA2D68DF6BA1F7EBA6A9FC544DA035627C03C&vpc_SecureHashType=SHA256&vpc_TransactionNo=372&vpc_TxnResponseCode=0&vpc_Version=1&vpc_VerType=3DS&vpc_3DSXID=[FILTERED]&vpc_VerToken=[FILTERED]&vpc_3DSenrolled=Y&vpc_3DSECI=05&3DSstatus=Y" read 595 bytes Conn close EOS From b37f6d5a20b204ea5e2112b50d8b6ff3115d988b Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 15 Jun 2018 09:29:04 -0400 Subject: [PATCH 432/677] Forte: strip location_id and account_id for URLs This strictly speaking should not be necessary, but we're seeing enough of this happening that it seems worth doing (and is otherwise harmless). Unit: 18 tests, 61 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 18 tests, 45 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2890 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/forte.rb | 2 +- test/unit/gateways/forte_test.rb | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 619f0403aeb..e8a7d0a4a3f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * Payflow: Update ACH tests [curiousepic] #2887 * Credorax: support passing billing description [bpollack] #2889 * MiGS: scrub 3DS fields [abarrak] #2771 +* Forte: avoid crashing when location_id or account_id have spaces [bpollack] #2890 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/forte.rb b/lib/active_merchant/billing/gateways/forte.rb index fd50c83a3cc..3ffb3602fb0 100644 --- a/lib/active_merchant/billing/gateways/forte.rb +++ b/lib/active_merchant/billing/gateways/forte.rb @@ -214,7 +214,7 @@ def authorization_from(response) end def endpoint - "/accounts/act_#{@options[:account_id]}/locations/loc_#{@options[:location_id]}/transactions/" + "/accounts/act_#{@options[:account_id].strip}/locations/loc_#{@options[:location_id].strip}/transactions/" end def headers diff --git a/test/unit/gateways/forte_test.rb b/test/unit/gateways/forte_test.rb index de88de9ab31..e40d650140b 100644 --- a/test/unit/gateways/forte_test.rb +++ b/test/unit/gateways/forte_test.rb @@ -139,6 +139,16 @@ def test_failed_verify assert_failure response end + def test_handles_improper_padding + @gateway = ForteGateway.new(location_id: ' improperly-padded ', account_id: ' account_id ', api_key: 'api_key', secret: 'secret') + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |type, url, parameters, headers| + URI.parse(url) + end.respond_with(MockedResponse.new(successful_purchase_response)) + assert_success response + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed From a6d2b21a973f5aea0991c97da34a5c9454c6134f Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Fri, 18 May 2018 15:32:03 -0400 Subject: [PATCH 433/677] Adyen: Support Network Tokenization Cards via mpiData fields Closes #2891 Remote: 34 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 21 tests, 97 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 28 ++++-- test/remote/gateways/remote_adyen_test.rb | 30 +++++- test/unit/gateways/adyen_test.rb | 91 +++++++++++++++++++ 4 files changed, 141 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e8a7d0a4a3f..21ae2293ca0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * Credorax: support passing billing description [bpollack] #2889 * MiGS: scrub 3DS fields [abarrak] #2771 * Forte: avoid crashing when location_id or account_id have spaces [bpollack] #2890 +* Adyen: Support Network Tokenization Cards via mpiData fields [curiousepic] #2891 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index bbdb047f549..05ba5769400 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -44,7 +44,7 @@ def authorize(money, payment, options={}) post = init_post(options) add_invoice(post, money, options) add_payment(post, payment) - add_extra_data(post, options) + add_extra_data(post, payment, options) add_shopper_interaction(post, payment, options) add_address(post, options) add_installments(post, options) if options[:installments] @@ -76,7 +76,7 @@ def store(credit_card, options={}) post = init_post(options) add_invoice(post, 0, options) add_payment(post, credit_card) - add_extra_data(post, options) + add_extra_data(post, credit_card, options) add_recurring_contract(post, options) add_address(post, options) commit('authorise', post) @@ -97,23 +97,30 @@ def scrub(transcript) transcript. gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). gsub(%r(("number\\?":\\?")[^"]*)i, '\1[FILTERED]'). - gsub(%r(("cvc\\?":\\?")[^"]*)i, '\1[FILTERED]') + gsub(%r(("cvc\\?":\\?")[^"]*)i, '\1[FILTERED]'). + gsub(%r(("cavv\\?":\\?")[^"]*)i, '\1[FILTERED]') end private - def add_extra_data(post, options) + NETWORK_TOKENIZATION_CARD_SOURCE = { + "apple_pay" => "applepay", + "android_pay" => "androidpay", + "google_pay" => "paywithgoogle" + } + + def add_extra_data(post, payment, options) post[:shopperEmail] = options[:shopper_email] if options[:shopper_email] post[:shopperIP] = options[:shopper_ip] if options[:shopper_ip] post[:shopperReference] = options[:shopper_reference] if options[:shopper_reference] post[:fraudOffset] = options[:fraud_offset] if options[:fraud_offset] - post[:selectedBrand] = options[:selected_brand] if options[:selected_brand] + post[:selectedBrand] = options[:selected_brand] || NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard) post[:deliveryDate] = options[:delivery_date] if options[:delivery_date] post[:merchantOrderReference] = options[:merchant_order_reference] if options[:merchant_order_reference] end def add_shopper_interaction(post, payment, options={}) - if payment.respond_to?(:verification_value) && payment.verification_value + if (payment.respond_to?(:verification_value) && payment.verification_value) || payment.is_a?(NetworkTokenizationCreditCard) shopper_interaction = "Ecommerce" else shopper_interaction = "ContAuth" @@ -157,6 +164,7 @@ def add_payment(post, payment) post[:selectedRecurringDetailReference] = recurring_detail_reference add_recurring_contract(post, options) else + add_mpi_data_for_network_tokenization_card(post, payment) if payment.is_a?(NetworkTokenizationCreditCard) add_card(post, payment) end end @@ -185,6 +193,14 @@ def add_original_reference(post, authorization, options = {}) post[:originalReference] = single_reference(authorization) || original_psp_reference end + def add_mpi_data_for_network_tokenization_card(post, payment) + post[:mpiData] = {} + post[:mpiData][:authenticationResponse] = "Y" + post[:mpiData][:cavv] = payment.payment_cryptogram + post[:mpiData][:directoryResponse] = "Y" + post[:mpiData][:eci] = payment.eci || "07" + end + def single_reference(authorization) authorization if !authorization.include?("#") end diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb index 8bd307765ce..5c23d919776 100644 --- a/test/remote/gateways/remote_adyen_test.rb +++ b/test/remote/gateways/remote_adyen_test.rb @@ -17,14 +17,21 @@ def setup @declined_card = credit_card('4000300011112220') + @apple_pay_card = network_tokenization_credit_card('4111111111111111', + :payment_cryptogram => "YwAAAAAABaYcCMX/OhNRQAAAAAA=", + :month => "08", + :year => "2018", + :source => :apple_pay, + :verification_value => nil + ) + @options = { reference: '345123', shopper_email: "john.smith@test.com", shopper_ip: "77.110.174.153", shopper_reference: "John Smith", billing_address: address(), - order_id: "123", - installments: 2 + order_id: "123" } end @@ -55,12 +62,18 @@ def test_successful_purchase_no_cvv end def test_successful_purchase_with_more_options - options = @options.merge!(fraudOffset: '1') + options = @options.merge!(fraudOffset: '1', installments: 2) response = @gateway.purchase(@amount, @credit_card, options) assert_success response assert_equal '[capture-received]', response.message end + def test_successful_purchase_with_apple_pay + response = @gateway.purchase(@amount, @apple_pay_card, @options) + assert_success response + assert_equal '[capture-received]', response.message + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response @@ -191,6 +204,17 @@ def test_transcript_scrubbing assert_scrubbed(@gateway.options[:password], transcript) end + def test_transcript_scrubbing_network_tokenization_card + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @apple_pay_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@apple_pay_card.number, transcript) + assert_scrubbed(@apple_pay_card.payment_cryptogram, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + end + def test_incorrect_number_for_purchase card = credit_card('4242424242424241') assert response = @gateway.purchase(@amount, card, @options) diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index d454266f687..958d063e729 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -19,6 +19,14 @@ def setup :brand => 'visa' ) + @apple_pay_card = network_tokenization_credit_card('4111111111111111', + :payment_cryptogram => "YwAAAAAABaYcCMX/OhNRQAAAAAA=", + :month => "08", + :year => "2018", + :source => :apple_pay, + :verification_value => nil + ) + @amount = 100 @options = { @@ -194,6 +202,11 @@ def test_scrub assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed end + def test_scrub_network_tokenization_card + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + def test_add_address post = {:card => {:billingAddress => {}}} @options[:billing_address].delete(:address1) @@ -207,6 +220,16 @@ def test_add_address assert_equal @options[:billing_address][:country], post[:card][:billingAddress][:country] end + def test_authorize_with_network_tokenization_credit_card + response = stub_comms do + @gateway.authorize(@amount, @apple_pay_card, @options) + end.check_request do |endpoint, data, headers| + assert_equal "YwAAAAAABaYcCMX/OhNRQAAAAAA=", JSON.parse(data)['mpiData']['cavv'] + assert_equal "07", JSON.parse(data)['mpiData']['eci'] + end.respond_with(successful_authorize_response) + assert_success response + end + private def pre_scrubbed @@ -273,6 +296,74 @@ def post_scrubbed POST_SCRUBBED end + def pre_scrubbed_network_tokenization_card + <<-PRE_SCRUBBED + opening connection to pal-test.adyen.com:443... + opened + starting SSL for pal-test.adyen.com:443... + SSL established + I, [2018-06-18T11:53:47.394267 #25363] INFO -- : [ActiveMerchant::Billing::AdyenGateway] connection_ssl_version=TLSv1.2 connection_ssl_cipher=ECDHE-RSA-AES128-GCM-SHA256 + D, [2018-06-18T11:53:47.394346 #25363] DEBUG -- : {"merchantAccount":"SpreedlyCOM294","reference":"123","amount":{"value":"100","currency":"USD"},"mpiData":{"authenticationResponse":"Y","cavv":"YwAAAAAABaYcCMX/OhNRQAAAAAA=","directoryResponse":"Y","eci":"07"},"card":{"expiryMonth":8,"expiryYear":2018,"holderName":"Longbob Longsen","number":"4111111111111111","billingAddress":{"street":"456 My Street","houseNumberOrName":"Apt 1","postalCode":"K1C2N6","city":"Ottawa","stateOrProvince":"ON","country":"CA"}},"shopperEmail":"john.smith@test.com","shopperIP":"77.110.174.153","shopperReference":"John Smith","selectedBrand":"applepay","shopperInteraction":"Ecommerce"} + <- "POST /pal/servlet/Payment/v18/authorise HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Basic d3NAQ29tcGFueS5TcHJlZWRseTQ3MTo3c3d6U0p2R1VWViUvP3Q0Uy9bOVtoc0hF\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: pal-test.adyen.com\r\nContent-Length: 618\r\n\r\n" + <- "{\"merchantAccount\":\"SpreedlyCOM294\",\"reference\":\"123\",\"amount\":{\"value\":\"100\",\"currency\":\"USD\"},\"mpiData\":{\"authenticationResponse\":\"Y\",\"cavv\":\"YwAAAAAABaYcCMX/OhNRQAAAAAA=\",\"directoryResponse\":\"Y\",\"eci\":\"07\"},\"card\":{\"expiryMonth\":8,\"expiryYear\":2018,\"holderName\":\"Longbob Longsen\",\"number\":\"4111111111111111\",\"billingAddress\":{\"street\":\"456 My Street\",\"houseNumberOrName\":\"Apt 1\",\"postalCode\":\"K1C2N6\",\"city\":\"Ottawa\",\"stateOrProvince\":\"ON\",\"country\":\"CA\"}},\"shopperEmail\":\"john.smith@test.com\",\"shopperIP\":\"77.110.174.153\",\"shopperReference\":\"John Smith\",\"selectedBrand\":\"applepay\",\"shopperInteraction\":\"Ecommerce\"}" + -> "HTTP/1.1 200 OK\r\n" + -> "Date: Mon, 18 Jun 2018 15:53:47 GMT\r\n" + -> "Server: Apache\r\n" + -> "Set-Cookie: JSESSIONID=06EE78291B761A33ED9E21E46BA54649.test104e; Path=/pal; Secure; HttpOnly\r\n" + -> "pspReference: 8835293372276408\r\n" + -> "Connection: close\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Content-Type: application/json;charset=utf-8\r\n" + -> "\r\n" + -> "50\r\n" + reading 80 bytes... + -> "" + -> "{\"pspReference\":\"8835293372276408\",\"resultCode\":\"Authorised\",\"authCode\":\"26056\"}" + read 80 bytes + reading 2 bytes... + -> "" + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + PRE_SCRUBBED + end + + def post_scrubbed_network_tokenization_card + <<-POST_SCRUBBED + opening connection to pal-test.adyen.com:443... + opened + starting SSL for pal-test.adyen.com:443... + SSL established + I, [2018-06-18T11:53:47.394267 #25363] INFO -- : [ActiveMerchant::Billing::AdyenGateway] connection_ssl_version=TLSv1.2 connection_ssl_cipher=ECDHE-RSA-AES128-GCM-SHA256 + D, [2018-06-18T11:53:47.394346 #25363] DEBUG -- : {"merchantAccount":"SpreedlyCOM294","reference":"123","amount":{"value":"100","currency":"USD"},"mpiData":{"authenticationResponse":"Y","cavv":"[FILTERED]","directoryResponse":"Y","eci":"07"},"card":{"expiryMonth":8,"expiryYear":2018,"holderName":"Longbob Longsen","number":"[FILTERED]","billingAddress":{"street":"456 My Street","houseNumberOrName":"Apt 1","postalCode":"K1C2N6","city":"Ottawa","stateOrProvince":"ON","country":"CA"}},"shopperEmail":"john.smith@test.com","shopperIP":"77.110.174.153","shopperReference":"John Smith","selectedBrand":"applepay","shopperInteraction":"Ecommerce"} + <- "POST /pal/servlet/Payment/v18/authorise HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Basic [FILTERED]\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: pal-test.adyen.com\r\nContent-Length: 618\r\n\r\n" + <- "{\"merchantAccount\":\"SpreedlyCOM294\",\"reference\":\"123\",\"amount\":{\"value\":\"100\",\"currency\":\"USD\"},\"mpiData\":{\"authenticationResponse\":\"Y\",\"cavv\":\"[FILTERED]\",\"directoryResponse\":\"Y\",\"eci\":\"07\"},\"card\":{\"expiryMonth\":8,\"expiryYear\":2018,\"holderName\":\"Longbob Longsen\",\"number\":\"[FILTERED]\",\"billingAddress\":{\"street\":\"456 My Street\",\"houseNumberOrName\":\"Apt 1\",\"postalCode\":\"K1C2N6\",\"city\":\"Ottawa\",\"stateOrProvince\":\"ON\",\"country\":\"CA\"}},\"shopperEmail\":\"john.smith@test.com\",\"shopperIP\":\"77.110.174.153\",\"shopperReference\":\"John Smith\",\"selectedBrand\":\"applepay\",\"shopperInteraction\":\"Ecommerce\"}" + -> "HTTP/1.1 200 OK\r\n" + -> "Date: Mon, 18 Jun 2018 15:53:47 GMT\r\n" + -> "Server: Apache\r\n" + -> "Set-Cookie: JSESSIONID=06EE78291B761A33ED9E21E46BA54649.test104e; Path=/pal; Secure; HttpOnly\r\n" + -> "pspReference: 8835293372276408\r\n" + -> "Connection: close\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Content-Type: application/json;charset=utf-8\r\n" + -> "\r\n" + -> "50\r\n" + reading 80 bytes... + -> "" + -> "{\"pspReference\":\"8835293372276408\",\"resultCode\":\"Authorised\",\"authCode\":\"26056\"}" + read 80 bytes + reading 2 bytes... + -> "" + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + POST_SCRUBBED + end + def failed_purchase_response <<-RESPONSE { From 4630df302d02edcb359927542e11f7398be0b923 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Tue, 12 Jun 2018 09:26:44 -0400 Subject: [PATCH 434/677] Moneris US: Add ACH Adds ACH capabilities to Moneris US Gateway One failing test for CVV verification that are unrelated to these changes. Loaded suite test/remote/gateways/remote_moneris_us_test Failure: test_cvv_no_match_when_enabled(MonerisUsRemoteTest) 30 tests, 118 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 96.6667% passed Loaded suite test/unit/gateways/moneris_us_test 33 tests, 164 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2888 --- CHANGELOG | 1 + .../billing/gateways/moneris_us.rb | 68 +++++++++++++++---- .../remote/gateways/remote_moneris_us_test.rb | 44 ++++++++++++ test/unit/gateways/moneris_us_test.rb | 42 ++++++++++++ 4 files changed, 143 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 21ae2293ca0..d10e7f637e2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * MiGS: scrub 3DS fields [abarrak] #2771 * Forte: avoid crashing when location_id or account_id have spaces [bpollack] #2890 * Adyen: Support Network Tokenization Cards via mpiData fields [curiousepic] #2891 +* Moneris US: Add ACH [nfarve] #2888 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb index 2986746cfe6..b4101be56b6 100644 --- a/lib/active_merchant/billing/gateways/moneris_us.rb +++ b/lib/active_merchant/billing/gateways/moneris_us.rb @@ -72,9 +72,15 @@ def purchase(money, creditcard_or_datakey, options = {}) add_payment_source(post, creditcard_or_datakey, options) post[:amount] = amount(money) post[:order_id] = options[:order_id] - post[:address] = options[:billing_address] || options[:address] + add_address(post, creditcard_or_datakey, options) post[:crypt_type] = options[:crypt_type] || @options[:crypt_type] - action = (post[:data_key].blank?) ? 'us_purchase' : 'us_res_purchase_cc' + action = if creditcard_or_datakey.is_a?(String) + 'us_res_purchase_cc' + elsif card_brand(creditcard_or_datakey) == 'check' + 'us_ach_debit' + elsif post[:data_key].blank? + 'us_purchase' + end commit(action, post) end @@ -114,12 +120,11 @@ def refund(money, authorization, options = {}) commit 'us_refund', crediting_params(authorization, :amount => amount(money)) end - def store(credit_card, options = {}) + def store(payment_source, options = {}) post = {} - post[:pan] = credit_card.number - post[:expdate] = expdate(credit_card) + add_payment_source(post, payment_source, options) post[:crypt_type] = options[:crypt_type] || @options[:crypt_type] - commit('us_res_add_cc', post) + card_brand(payment_source) == 'check' ? commit('us_res_add_ach', post) : commit('us_res_add_cc', post) end def unstore(data_key, options = {}) @@ -128,13 +133,11 @@ def unstore(data_key, options = {}) commit('us_res_delete', post) end - def update(data_key, credit_card, options = {}) + def update(data_key, payment_source, options = {}) post = {} - post[:pan] = credit_card.number - post[:expdate] = expdate(credit_card) + add_payment_source(post, payment_source, options) post[:data_key] = data_key - post[:crypt_type] = options[:crypt_type] || @options[:crypt_type] - commit('us_res_update_cc', post) + card_brand(payment_source) == 'check' ? commit('us_res_update_ach', post) : commit('us_res_update_cc', post) end def supports_scrubbing? @@ -154,14 +157,41 @@ def expdate(creditcard) sprintf("%.4i", creditcard.year)[-2..-1] + sprintf("%.2i", creditcard.month) end + def add_address(post, payment_method, options) + if !payment_method.is_a?(String) && card_brand(payment_method) == 'check' + post[:ach_info][:cust_first_name] = payment_method.first_name if payment_method.first_name + post[:ach_info][:cust_last_name] = payment_method.last_name if payment_method.last_name + if address = options[:billing_address] || options[:address] + post[:ach_info][:cust_address1] = address[:address1] if address[:address1] + post[:ach_info][:cust_address2] = address[:address2] if address[:address2] + post[:ach_info][:city] = address[:city] if address[:city] + post[:ach_info][:state] = address[:state] if address[:state] + post[:ach_info][:zip] = address[:zip] if address[:zip] + end + else + post[:address] = options[:billing_address] || options[:address] + end + end + def add_payment_source(post, source, options) if source.is_a?(String) post[:data_key] = source post[:cust_id] = options[:customer] + elsif card_brand(source) == 'check' + ach_info = {} + ach_info[:sec] = 'web' + ach_info[:routing_num] = source.routing_number + ach_info[:account_num] = source.account_number + ach_info[:account_type] = source.account_type + ach_info[:check_num] = source.number if source.number + post[:ach_info] = ach_info else post[:pan] = source.number post[:expdate] = expdate(source) post[:cvd_value] = source.verification_value if source.verification_value? + if crypt_type = options[:crypt_type] || @options[:crypt_type] + post[:crypt_type] = crypt_type + end post[:cust_id] = options[:customer] || source.name end end @@ -247,6 +277,8 @@ def transaction_element(action, parameters) transaction.add_element(avs_element(parameters[:address])) if @avs_enabled && parameters[:address] when :cvd_info transaction.add_element(cvd_element(parameters[:cvd_value])) if @cvv_enabled + when :ach_info + transaction.add_element(ach_element(parameters[:ach_info])) else transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank? end @@ -277,6 +309,14 @@ def cvd_element(cvd_value) element end + def ach_element(ach_info) + element = REXML::Element.new('ach_info') + actions['ach_info'].each do |key| + element.add_element(key.to_s).text = ach_info[key] unless ach_info[key].blank? + end + element + end + def message_from(message) return 'Unspecified error' if message.blank? message.gsub(/[^\w]/, ' ').split.join(" ").capitalize @@ -301,7 +341,11 @@ def actions "us_res_delete" => [:data_key], "us_res_update_cc" => [:data_key, :pan, :expdate, :crypt_type], "us_res_purchase_cc" => [:data_key, :order_id, :cust_id, :amount, :crypt_type], - "us_res_preauth_cc" => [:data_key, :order_id, :cust_id, :amount, :crypt_type] + "us_res_preauth_cc" => [:data_key, :order_id, :cust_id, :amount, :crypt_type], + "us_ach_debit" => [:order_id, :cust_id, :amount, :ach_info], + "us_res_add_ach" => [:order_id, :cust_id, :amount, :ach_info], + "us_res_update_ach" => [:order_id, :data_key, :cust_id, :amount, :ach_info], + "ach_info" => [:sec, :cust_first_name, :cust_last_name, :cust_address1, :cust_address2, :cust_city, :cust_state, :cust_zip, :routing_num, :account_num, :check_num, :account_type] } end end diff --git a/test/remote/gateways/remote_moneris_us_test.rb b/test/remote/gateways/remote_moneris_us_test.rb index 602d56f5d5e..0692e831db8 100644 --- a/test/remote/gateways/remote_moneris_us_test.rb +++ b/test/remote/gateways/remote_moneris_us_test.rb @@ -12,6 +12,11 @@ def setup :billing_address => address, :description => 'Store Purchase' } + @check = check({ + routing_number: '011000015', + account_number: '1234455', + number: 123 + }) end def test_successful_purchase @@ -21,6 +26,21 @@ def test_successful_purchase assert_false response.authorization.blank? end + def test_successful_echeck_purchase + response = @gateway.purchase(@amount, @check, @options) + assert_success response + assert response.test? + assert_equal 'Registered', response.message + assert response.authorization + end + + def test_failed_echeck_purchase + response = @gateway.purchase(105, check(routing_number: 5), @options) + assert_failure response + assert response.test? + assert_equal 'Unspecified error', response.message + end + def test_successful_authorization response = @gateway.authorize(@amount, @credit_card, @options) assert_success response @@ -103,6 +123,14 @@ def test_successful_store @data_key = response.params["data_key"] end + def test_successful_echeck_store + assert response = @gateway.store(@check) + assert_success response + assert_equal "Successfully registered ach details", response.message + assert response.params["data_key"].present? + @data_key_echeck = response.params["data_key"] + end + def test_successful_unstore test_successful_store assert response = @gateway.unstore(@data_key) @@ -111,6 +139,14 @@ def test_successful_unstore assert response.params["data_key"].present? end + def test_successful_echeck_unstore + test_successful_echeck_store + assert response = @gateway.unstore(@data_key_echeck) + assert_success response + assert_equal "Successfully deleted ach details", response.message + assert response.params["data_key"].present? + end + def test_update test_successful_store assert response = @gateway.update(@data_key, @credit_card) @@ -119,6 +155,14 @@ def test_update assert response.params["data_key"].present? end + def test_echeck_update + test_successful_echeck_store + assert response = @gateway.update(@data_key_echeck, @check) + assert_success response + assert_equal "Successfully updated ach details", response.message + assert response.params["data_key"].present? + end + def test_successful_purchase_with_vault test_successful_store assert response = @gateway.purchase(@amount, @data_key, @options) diff --git a/test/unit/gateways/moneris_us_test.rb b/test/unit/gateways/moneris_us_test.rb index daac3648e0c..3a0834adbb8 100644 --- a/test/unit/gateways/moneris_us_test.rb +++ b/test/unit/gateways/moneris_us_test.rb @@ -13,6 +13,11 @@ def setup @amount = 100 @credit_card = credit_card('4242424242424242') + @check = check({ + routing_number: '011000015', + account_number: '1234455', + number: 123 + }) @options = { :order_id => '1', :billing_address => address } end @@ -37,6 +42,14 @@ def test_failed_purchase assert_failure response end + def test_successful_echeck_purchase + @gateway.expects(:ssl_post).returns(successful_echeck_purchase_response) + + assert response = @gateway.authorize(100, @check, @options) + assert_success response + assert_equal '1522-0_25;cb80f38f44af2168fd9033cdf2d0d4c0', response.authorization + end + def test_deprecated_credit @gateway.expects(:ssl_post).with(anything, regexp_matches(/txn_number>123<\//), anything).returns("") @gateway.expects(:parse).returns({}) @@ -551,6 +564,35 @@ def successful_update_response RESPONSE end + def successful_echeck_purchase_response + <<-RESPONSE + <?xml version="1.0"?> + <response> + <receipt> + <ReceiptId>cb80f38f44af2168fd9033cdf2d0d4c0</ReceiptId> + <ReferenceNum>001000040010015220</ReferenceNum> + <ResponseCode>005</ResponseCode> + <ISO>01</ISO> + <AuthCode></AuthCode> + <TransTime>08:23:37</TransTime> + <TransDate>2018-06-18</TransDate> + <TransType>00</TransType> + <Complete>true</Complete> + <Message>REGISTERED * =</Message> + <TransAmount>1.0</TransAmount> + <CardType>CQ</CardType> + <TransID>1522-0_25</TransID> + <TimedOut>false</TimedOut> + <BankTotals>null</BankTotals> + <Ticket>null</Ticket> + <CorporateCard>false</CorporateCard> + <MessageId>null</MessageId> + <RecurSuccess>true</RecurSuccess> + </receipt> + </response> + RESPONSE + end + def xml_purchase_fixture '<request><store_id>monusqa002</store_id><api_token>qatoken</api_token><us_purchase><amount>1.01</amount><pan>4242424242424242</pan><expdate>0303</expdate><crypt_type>7</crypt_type><order_id>order1</order_id></us_purchase></request>' end From 242d220e67d5562092a6d6ee1306adda1b228e7b Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Thu, 21 Jun 2018 15:51:36 -0400 Subject: [PATCH 435/677] Realex: Pass amount for captures Closes #2895 Remote (7 failures unrelated to changes verified on master): 21 tests, 103 assertions, 7 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 66.6667% passed Unit: 21 tests, 445 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/realex.rb | 7 +++--- test/remote/gateways/remote_realex_test.rb | 22 +++++++++++++++++++ test/unit/gateways/realex_test.rb | 5 +++-- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d10e7f637e2..4a1f5bbdf86 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * Forte: avoid crashing when location_id or account_id have spaces [bpollack] #2890 * Adyen: Support Network Tokenization Cards via mpiData fields [curiousepic] #2891 * Moneris US: Add ACH [nfarve] #2888 +* Realex: Pass amount for captures [curiousepic] #2895 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index 64f3e3e2fbd..ce68055a1e4 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -64,7 +64,7 @@ def authorize(money, creditcard, options = {}) end def capture(money, authorization, options = {}) - request = build_capture_request(authorization, options) + request = build_capture_request(money, authorization, options) commit(request) end @@ -147,14 +147,15 @@ def build_purchase_or_authorization_request(action, money, credit_card, options) xml.target! end - def build_capture_request(authorization, options) + def build_capture_request(money, authorization, options) timestamp = new_timestamp xml = Builder::XmlMarkup.new :indent => 2 xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'settle' do add_merchant_details(xml, options) + add_amount(xml, money, options) add_transaction_identifiers(xml, authorization, options) add_comments(xml, options) - add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), nil, nil, nil) + add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), amount(money), (options[:currency] || currency(money)), nil) end xml.target! end diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb index f8b233cce7e..3efc19866f5 100644 --- a/test/remote/gateways/remote_realex_test.rb +++ b/test/remote/gateways/remote_realex_test.rb @@ -261,6 +261,28 @@ def test_realex_authorize_then_capture ) assert auth_response.test? + capture_response = @gateway.capture(nil, auth_response.authorization) + + assert_not_nil capture_response + assert_success capture_response + assert capture_response.authorization.length > 0 + assert_equal 'Successful', capture_response.message + assert_match(/Settled Successfully/, capture_response.params['message']) + end + + def test_realex_authorize_then_capture_with_extra_amount + order_id = generate_unique_id + + auth_response = @gateway.authorize(@amount*115, @visa, + :order_id => order_id, + :description => 'Test Realex Purchase', + :billing_address => { + :zip => '90210', + :country => 'US' + } + ) + assert auth_response.test? + capture_response = @gateway.capture(@amount, auth_response.authorization) assert_not_nil capture_response diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb index 7a4deb75db2..ad4f0ce32f1 100644 --- a/test/unit/gateways/realex_test.rb +++ b/test/unit/gateways/realex_test.rb @@ -133,14 +133,15 @@ def test_capture_xml <request timestamp="20090824160201" type="settle"> <merchantid>your_merchant_id</merchantid> <account>your_account</account> + <amount>100</amount> <orderid>1</orderid> <pasref>4321</pasref> <authcode>1234</authcode> - <sha1hash>4132600f1dc70333b943fc292bd0ca7d8e722f6e</sha1hash> + <sha1hash>ef0a6c485452f3f94aff336fa90c6c62993056ca</sha1hash> </request> SRC - assert_xml_equal valid_capture_xml, @gateway.build_capture_request('1;4321;1234', {}) + assert_xml_equal valid_capture_xml, @gateway.build_capture_request(@amount, '1;4321;1234', {}) end def test_purchase_xml From a0afaad742da0e5773d6c03fe003688748e6b3f7 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 21 Jun 2018 16:29:46 -0400 Subject: [PATCH 436/677] CardConnect: add store and unstore Unit: 21 tests, 89 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 23 tests, 54 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2896 --- CHANGELOG | 1 + .../billing/gateways/card_connect.rb | 51 ++++++++++++++----- .../gateways/remote_card_connect_test.rb | 27 ++++++++++ test/unit/gateways/card_connect_test.rb | 46 +++++++++++++++++ 4 files changed, 112 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4a1f5bbdf86..c7cde0764fb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ * Adyen: Support Network Tokenization Cards via mpiData fields [curiousepic] #2891 * Moneris US: Add ACH [nfarve] #2888 * Realex: Pass amount for captures [curiousepic] #2895 +* Card Connect: support storing cards [bpollack] #2896 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/card_connect.rb b/lib/active_merchant/billing/gateways/card_connect.rb index 7fc67262623..1363f97d250 100644 --- a/lib/active_merchant/billing/gateways/card_connect.rb +++ b/lib/active_merchant/billing/gateways/card_connect.rb @@ -130,6 +130,21 @@ def verify(credit_card, options = {}) authorize(0, credit_card, options) end + def store(payment, options = {}) + post = {} + add_payment(post, payment) + add_address(post, options) + add_customer_data(post, options) + commit('profile', post) + end + + def unstore(authorization, options = {}) + account_id, profile_id = authorization.split('|') + commit('profile', {}, + verb: :delete, + path: "/#{profile_id}/#{account_id}/#{@options[:merchant_id]}") + end + def supports_scrubbing? true end @@ -175,13 +190,19 @@ def add_invoice(post, options) end def add_payment(post, payment) - post[:name] = payment.name - if card_brand(payment) == 'check' - add_echeck(post, payment) + if payment.is_a?(String) + account_id, profile_id = payment.split('|') + post[:profile] = profile_id + post[:acctid] = account_id else - post[:account] = payment.number - post[:expiry] = expdate(payment) - post[:cvv2] = payment.verification_value + post[:name] = payment.name + if card_brand(payment) == 'check' + add_echeck(post, payment) + else + post[:account] = payment.number + post[:expiry] = expdate(payment) + post[:cvv2] = payment.verification_value + end end end @@ -237,18 +258,18 @@ def parse(body) JSON.parse(body) end - def url(action) + def url(action, path) if test? - test_url + action + test_url + action + path else - (@options[:domain] ? @options[:domain] : live_url) + action + (@options[:domain] ? @options[:domain] : live_url) + action + path end end - def commit(action, parameters) + def commit(action, parameters, verb: :put, path: '') parameters[:merchid] = @options[:merchant_id] - url = url(action) - response = parse(ssl_request(:put, url, post_data(parameters), headers)) + url = url(action, path) + response = parse(ssl_request(verb, url, post_data(parameters), headers)) Response.new( success_from(response), @@ -271,7 +292,11 @@ def message_from(response) end def authorization_from(response) - response['retref'] + if response['profileid'] + "#{response['acctid']}|#{response['profileid']}" + else + response['retref'] + end end def post_data(parameters = {}) diff --git a/test/remote/gateways/remote_card_connect_test.rb b/test/remote/gateways/remote_card_connect_test.rb index 87d1ae47ff9..a607308976f 100644 --- a/test/remote/gateways/remote_card_connect_test.rb +++ b/test/remote/gateways/remote_card_connect_test.rb @@ -76,6 +76,13 @@ def test_successful_purchase_3DS assert_equal 'Approval', response.message end + def test_successful_purchase_with_profile + store_response = @gateway.store(@credit_card, @options) + assert_success store_response + purchase_response = @gateway.purchase(@amount, store_response.authorization, @options) + assert_success purchase_response + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response @@ -172,6 +179,26 @@ def test_failed_verify assert_match %r{Insufficient funds}, response.message end + def test_successful_store + response = @gateway.store(@credit_card, @options) + + assert_success response + assert_equal 'Profile Saved', response.message + end + + def test_successful_unstore + store_response = @gateway.store(@credit_card, @options) + assert_success store_response + + unstore_response = @gateway.unstore(store_response.authorization, @options) + assert_success unstore_response + end + + def test_failed_unstore + response = @gateway.unstore('0|abcdefghijklmnopq', @options) + assert_failure response + end + def test_invalid_login gateway = CardConnectGateway.new(username: '', password: '', merchant_id: '') assert_raises(ActiveMerchant::ResponseError) do diff --git a/test/unit/gateways/card_connect_test.rb b/test/unit/gateways/card_connect_test.rb index 078f6f9256b..ab735f986b5 100644 --- a/test/unit/gateways/card_connect_test.rb +++ b/test/unit/gateways/card_connect_test.rb @@ -166,6 +166,35 @@ def test_failed_verify assert_equal "Insufficient funds", response.message end + def test_successful_store + @gateway.expects(:ssl_request).returns(successful_store_response) + response = @gateway.store(@credit_card, @options) + + assert_success response + assert_equal 'Profile Saved', response.message + assert_equal '1|16700875781344019340', response.authorization + end + + def test_failed_store + @gateway.expects(:ssl_request).returns(failed_store_response) + response = @gateway.store(@credit_card, @options) + + assert_failure response + end + + def test_successful_unstore + response = stub_comms(@gateway, :ssl_request) do + @gateway.unstore('1|16700875781344019340') + end.check_request do |verb, url, data, headers| + assert_equal :delete, verb + assert_match %r{16700875781344019340/1}, url + end.respond_with(successful_unstore_response) + end + + def test_failed_unstore + + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed @@ -276,4 +305,21 @@ def successful_verify_response def failed_verify_response "{\"respproc\":\"FNOR\",\"amount\":\"0.00\",\"resptext\":\"Insufficient funds\",\"cardproc\":\"FNOR\",\"commcard\":\" C \",\"retref\":\"005101240599\",\"respstat\":\"C\",\"respcode\":\"NU\",\"account\":\"9435885049491053\",\"merchid\":\"496160873888\",\"token\":\"9435885049491053\"}" end + + def successful_store_response + "{\"country\":\"CA\",\"gsacard\":\"N\",\"address\":\"456 My Street Apt 1\",\"resptext\":\"Profile Saved\",\"city\":\"Ottawa\",\"acctid\":\"1\",\"respcode\":\"09\",\"defaultacct\":\"Y\",\"accttype\":\"VISA\",\"token\":\"9477709629051443\",\"respproc\":\"PPS\",\"phone\":\"(555)555-555\",\"profileid\":\"16700875781344019340\",\"name\":\"Longbob Longsen\",\"auoptout\":\"N\",\"postal\":\"K1C2N6\",\"expiry\":\"0919\",\"region\":\"ON\",\"respstat\":\"A\"}" + end + + def successful_unstore_response + "{\"respproc\":\"PPS\",\"resptext\":\"Profile Deleted\",\"respstat\":\"A\",\"respcode\":\"08\"}" + end + + def failed_store_response + # Best-guess based on documentation + "{\"country\":\"CA\",\"gsacard\":\"N\",\"address\":\"456 My Street Apt 1\",\"resptext\":\"Profile Saved\",\"city\":\"Ottawa\",\"acctid\":\"1\",\"respcode\":\"09\",\"defaultacct\":\"Y\",\"accttype\":\"VISA\",\"token\":\"9477709629051443\",\"respproc\":\"PPS\",\"phone\":\"(555)555-555\",\"profileid\":\"16700875781344019340\",\"name\":\"Longbob Longsen\",\"auoptout\":\"N\",\"postal\":\"K1C2N6\",\"expiry\":\"0919\",\"region\":\"ON\",\"respstat\":\"C\"}" + end + + def failed_unstore_response + "{\"respproc\":\"PPS\",\"resptext\":\"Profile not found\",\"respstat\":\"C\",\"respcode\":\"96\"}" + end end From b5a7a35418007a9dc49fd1d84a17b670909e01ea Mon Sep 17 00:00:00 2001 From: Jonathan Girard Viau <am00620@ens.etsmtl.ca> Date: Fri, 22 Jun 2018 14:25:56 -0400 Subject: [PATCH 437/677] Add Street2 to payflow fields for avs (#2897) --- .../billing/gateways/payflow/payflow_common_api.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb index 225f746eaea..82820e6dcd4 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb @@ -137,6 +137,7 @@ def add_address(xml, tag, address, options) xml.tag! 'Address' do xml.tag! 'Street', address[:address1] unless address[:address1].blank? + xml.tag! 'Street2', address[:address2] unless address[:address2].blank? xml.tag! 'City', address[:city] unless address[:city].blank? xml.tag! 'State', address[:state].blank? ? "N/A" : address[:state] xml.tag! 'Country', address[:country] unless address[:country].blank? From ff50df9798441936c4db56d774fc93926ee32f19 Mon Sep 17 00:00:00 2001 From: Grant Bourque <grant@anedot.com> Date: Fri, 15 Jun 2018 17:09:58 -0500 Subject: [PATCH 438/677] Set connection request start time at method start - Move the recording of the request start time to the beginning of `Connection#request`. This ensures that everything is instrumented and assigns the variable used in the `ensure` block as soon as possible before any possible exceptions. --- lib/active_merchant/connection.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index 57a6e15d56a..7978f5dcc27 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -65,10 +65,10 @@ def wiredump_device=(device) end def request(method, body, headers = {}) - headers['connection'] ||= 'close' - request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + headers['connection'] ||= 'close' + retry_exceptions(:max_retries => max_retries, :logger => logger, :tag => tag) do begin info "connection_http_method=#{method.to_s.upcase} connection_uri=#{endpoint}", tag From 262b65c45bf9538e9df57cd4f9ab39d6b4591cd7 Mon Sep 17 00:00:00 2001 From: Grant Bourque <grant@anedot.com> Date: Fri, 15 Jun 2018 17:37:20 -0500 Subject: [PATCH 439/677] Prevent mutation of headers argument - Copy the headers argument object in `Connection#request` to prevent mutation of an object that could be frozen. - Add a test for `PostsData#raw_ssl_request` asserting against headers argument mutation to protect against mutation happening unknowingly at that level. Closes #2892 --- CHANGELOG | 1 + lib/active_merchant/connection.rb | 1 + test/unit/connection_test.rb | 6 ++++++ test/unit/posts_data_test.rb | 8 ++++++++ 4 files changed, 16 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index c7cde0764fb..3d4c329a2b3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * Moneris US: Add ACH [nfarve] #2888 * Realex: Pass amount for captures [curiousepic] #2895 * Card Connect: support storing cards [bpollack] #2896 +* Avoid mutating headers passed in for Active Merchant connections [grantbdev] #2892 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index 7978f5dcc27..6509e68fff8 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -67,6 +67,7 @@ def wiredump_device=(device) def request(method, body, headers = {}) request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + headers = headers.dup headers['connection'] ||= 'close' retry_exceptions(:max_retries => max_retries, :logger => logger, :tag => tag) do diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index cf0c42d5f72..58f4b411b89 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -44,6 +44,12 @@ def test_connection_does_pass_requested_proxy @connection.request(:get, nil, {}) end + def test_connection_does_not_mutate_headers_argument + headers = { "Content-Type" => "text/xml" }.freeze + @connection.request(:get, nil, headers) + assert_equal({ "Content-Type" => "text/xml" }, headers) + end + def test_successful_get_request @connection.logger.expects(:info).twice Net::HTTP.any_instance.expects(:get).with('/tx.php', {'connection' => 'close'}).returns(@ok) diff --git a/test/unit/posts_data_test.rb b/test/unit/posts_data_test.rb index d41aecf4d85..962cf2e5ae5 100644 --- a/test/unit/posts_data_test.rb +++ b/test/unit/posts_data_test.rb @@ -42,6 +42,14 @@ def test_successful_raw_request assert_equal @ok, @gateway.raw_ssl_request(:post, @url, '') end + def test_raw_ssl_request_does_not_mutate_headers_argument + ActiveMerchant::Connection.any_instance.expects(:request).returns(@ok) + + headers = { "Content-Type" => "text/xml" }.freeze + @gateway.raw_ssl_request(:post, @url, '', headers) + assert_equal({ "Content-Type" => "text/xml" }, headers) + end + def test_setting_ssl_strict_outside_class_definition assert_equal SimpleTestGateway.ssl_strict, SubclassGateway.ssl_strict SimpleTestGateway.ssl_strict = !SimpleTestGateway.ssl_strict From a1ed8ede2d4b8b5e4f917782417711665c2f8943 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 22 Jun 2018 13:54:50 -0400 Subject: [PATCH 440/677] Forte: enable refunds Unit: 20 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 20 tests, 52 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2898 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/forte.rb | 10 +++ test/remote/gateways/remote_forte_test.rb | 18 ++++++ test/unit/gateways/forte_test.rb | 64 +++++++++++++++++++ 4 files changed, 93 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 3d4c329a2b3..0cb4ede8107 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * Realex: Pass amount for captures [curiousepic] #2895 * Card Connect: support storing cards [bpollack] #2896 * Avoid mutating headers passed in for Active Merchant connections [grantbdev] #2892 +* Forte: add support for refunds [bpollack] #2898 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/forte.rb b/lib/active_merchant/billing/gateways/forte.rb index 3ffb3602fb0..f7075cdf5f9 100644 --- a/lib/active_merchant/billing/gateways/forte.rb +++ b/lib/active_merchant/billing/gateways/forte.rb @@ -64,6 +64,16 @@ def credit(money, payment_method, options={}) commit(:post, post) end + def refund(money, authorization, options={}) + post = {} + add_amount(post, money, options) + post[:original_transaction_id] = transaction_id_from(authorization) + post[:authorization_code] = authorization_code_from(authorization) + post[:action] = 'reverse' + + commit(:post, post) + end + def void(authorization, options={}) post = {} post[:transaction_id] = transaction_id_from(authorization) diff --git a/test/remote/gateways/remote_forte_test.rb b/test/remote/gateways/remote_forte_test.rb index f54bb27f623..9a73d11e081 100644 --- a/test/remote/gateways/remote_forte_test.rb +++ b/test/remote/gateways/remote_forte_test.rb @@ -145,6 +145,24 @@ def test_failed_void assert_match 'field transaction_id', response.message end + def test_successful_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + wait_for_authorization_to_clear + + assert refund = @gateway.refund(@amount, purchase.authorization, @options) + assert_success refund + assert_equal 'TEST APPROVAL', refund.message + end + + def test_failed_refund + response = @gateway.refund(@amount, '', @options) + assert_failure response + assert_match 'field authorization_code', response.message + assert_match 'field original_transaction_id', response.message + end + def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response diff --git a/test/unit/gateways/forte_test.rb b/test/unit/gateways/forte_test.rb index e40d650140b..053e0c7636f 100644 --- a/test/unit/gateways/forte_test.rb +++ b/test/unit/gateways/forte_test.rb @@ -139,6 +139,20 @@ def test_failed_verify assert_failure response end + def test_successful_refund + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.refund(@amount, "authcode") + end.respond_with(MockedResponse.new(successful_refund_response)) + assert_success response + end + + def test_failed_refund + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.refund(@amount, "authcode") + end.respond_with(MockedResponse.new(failed_refund_response)) + assert_failure response + end + def test_handles_improper_padding @gateway = ForteGateway.new(location_id: ' improperly-padded ', account_id: ' account_id ', api_key: 'api_key', secret: 'secret') response = stub_comms(@gateway, :raw_ssl_request) do @@ -549,4 +563,54 @@ def failed_void_response } ) end + + def successful_refund_response + <<-SUCCESS + { + "transaction_id": "trn_6ad08872-a8c9-44a9-baca-670c31de98a1", + "location_id": "loc_176008", + "original_transaction_id": "trn_cf645bab-72cc-41d5-a9d2-376845333008", + "order_number": "1", + "action": "disburse", + "authorization_amount": 1, + "authorization_code": "123456", + "entered_by": "f087a90f00f0ae57050c937ed3815c9f", + "billing_address": { + "first_name": "Jim", + "last_name": "Smith", + "physical_address": { + "street_line1": "456 My Street", + "street_line2": "Apt 1", + "locality": "Ottawa", + "region": "ON", + "postal_code": "K1C2N6" + } + }, + "response": { + "environment": "sandbox", + "response_type": "A", + "response_code": "A01", + "response_desc": "TEST APPROVAL", + "authorization_code": "123456", + "avs_result": "Y", + "cvv_code": "M" + } + } + SUCCESS + end + + def failed_refund_response + <<-FAILED + { + "location_id": "loc_176008", + "action": "reverse", + "authorization_amount": 1, + "entered_by": "f087a90f00f0ae57050c937ed3815c9f", + "response": { + "environment": "sandbox", + "response_desc": "Error[1]: The field authorization_code is required when performing a reverse action. Error[2]: The field original_transaction_id is required when performing a reverse action." + } + } + FAILED + end end From b09fad47275c5f2b11b7d29afc0fa7d68f98c9f4 Mon Sep 17 00:00:00 2001 From: David Whitby <whitby3001@gmail.com> Date: Thu, 30 Mar 2017 13:13:43 +0100 Subject: [PATCH 441/677] Forte: syntax fix Closes #2381 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/forte.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0cb4ede8107..ca7d4c6c6d4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ * Card Connect: support storing cards [bpollack] #2896 * Avoid mutating headers passed in for Active Merchant connections [grantbdev] #2892 * Forte: add support for refunds [bpollack] #2898 +* Forte: fix a bug in logic for selecting billing names [whitby3001] #2381 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/forte.rb b/lib/active_merchant/billing/gateways/forte.rb index f7075cdf5f9..b13ec679b03 100644 --- a/lib/active_merchant/billing/gateways/forte.rb +++ b/lib/active_merchant/billing/gateways/forte.rb @@ -130,11 +130,11 @@ def add_billing_address(post, payment, options) post[:billing_address][:physical_address][:locality] = address[:city] if address[:city] end - if empty?(post[:billing_address][:first_name] && payment.first_name) + if empty?(post[:billing_address][:first_name]) && payment.first_name post[:billing_address][:first_name] = payment.first_name end - if empty?(post[:billing_address][:last_name] && payment.last_name) + if empty?(post[:billing_address][:last_name]) && payment.last_name post[:billing_address][:last_name] = payment.last_name end end From dfc8ae6015bc63de7a44291d8363b564411789bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Prod=27homme?= <prodhomme.clement@hotmail.fr> Date: Sun, 11 Jun 2017 17:08:24 +0200 Subject: [PATCH 442/677] Properly demarcate code in README.md Closes #2458 --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 12a517c49f3..5fbec7885ae 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,15 @@ You can check out the latest source from git: Installation from RubyGems: - gem install activemerchant +```console +gem install activemerchant +``` Or, if you're using Bundler, just add the following to your Gemfile: - gem 'activemerchant' +```ruby +gem 'activemerchant' +``` ## Usage From 84d758583c3a55afa6478fd8c9bea33a78fef2b8 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 22 Jun 2018 15:52:33 -0400 Subject: [PATCH 443/677] Paymentez: support captures with different amounts Previously, Paymentez only supported capturing the original amount. It now supports capturing any amount the processor is okay with--by default, 100% or more of the amount specified. As part of this commit, I've repaired all remote tests, plus altered the partial cpature test, since it's now explicitly documented that the test, as written, should fail (which it does). Unit: 16 tests, 48 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 16 tests, 41 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2900 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/paymentez.rb | 7 +++++-- test/remote/gateways/remote_paymentez_test.rb | 14 +++++++++++--- test/unit/gateways/paymentez_test.rb | 11 ++++++++++- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ca7d4c6c6d4..5fa7bebf7cb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,7 @@ * Avoid mutating headers passed in for Active Merchant connections [grantbdev] #2892 * Forte: add support for refunds [bpollack] #2898 * Forte: fix a bug in logic for selecting billing names [whitby3001] #2381 +* Paymentez: allow capture amount to exceed authorization amount [bpollack] #2900 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index 5a3a83c87a2..49b628834d7 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -67,8 +67,11 @@ def authorize(money, payment, options = {}) commit_transaction('authorize', post) end - def capture(_money, authorization, _options = {}) - post = { transaction: { id: authorization } } + def capture(money, authorization, _options = {}) + post = { + transaction: { id: authorization } + } + post[:order] = {amount: amount(money).to_f} if money commit_transaction('capture', post) end diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb index 63ba19b25b1..6164e7e2e9b 100644 --- a/test/remote/gateways/remote_paymentez_test.rb +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -81,23 +81,31 @@ def test_successful_authorize_and_capture_with_token assert_equal 'Response by mock', capture.message end + def test_successful_authorize_and_capture_with_different_amount + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + assert capture = @gateway.capture(@amount + 100, auth.authorization) + assert_success capture + assert_equal 'Response by mock', capture.message + end + def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal nil, response.message + assert_equal 'Response by mock', response.message end def test_partial_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth assert capture = @gateway.capture(@amount - 1, auth.authorization) - assert_success capture + assert_failure capture # Paymentez explicitly does not support partial capture; only GREATER than auth capture end def test_failed_capture response = @gateway.capture(@amount, '') assert_failure response - assert_equal 'The capture method is not supported by carrier', response.message + assert_equal 'The modification of the amount is not supported by carrier', response.message end def test_store diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb index ef10ed75b74..b5605fc63bd 100644 --- a/test/unit/gateways/paymentez_test.rb +++ b/test/unit/gateways/paymentez_test.rb @@ -81,7 +81,16 @@ def test_failed_authorize def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - response = @gateway.capture(@amount, '1234', @options) + response = @gateway.capture(nil, '1234', @options) + assert_success response + assert_equal 'CI-635', response.authorization + assert response.test? + end + + def test_successful_capture_with_amount + @gateway.expects(:ssl_post).returns(successful_capture_response) + + response = @gateway.capture(@amount + 1, '1234', @options) assert_success response assert_equal 'CI-635', response.authorization assert response.test? From eeda082afc1819aef752f4e5723709172e0eb99f Mon Sep 17 00:00:00 2001 From: Andrew Reynhout <reynhout@quesera.com> Date: Tue, 13 Feb 2018 22:29:13 +0000 Subject: [PATCH 444/677] JetPay: fix garbled action code messages Closes #2749 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/jetpay.rb | 2 +- lib/active_merchant/billing/gateways/jetpay_v2.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5fa7bebf7cb..1084174a009 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,6 +22,7 @@ * Forte: add support for refunds [bpollack] #2898 * Forte: fix a bug in logic for selecting billing names [whitby3001] #2381 * Paymentez: allow capture amount to exceed authorization amount [bpollack] #2900 +* JetPay: fix typo in error messages [reynhout] #2749 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/jetpay.rb b/lib/active_merchant/billing/gateways/jetpay.rb index 9dfdefe2b2a..7a32ae1a1fb 100644 --- a/lib/active_merchant/billing/gateways/jetpay.rb +++ b/lib/active_merchant/billing/gateways/jetpay.rb @@ -49,7 +49,7 @@ class JetpayGateway < Gateway "043" => "Pick up card (stolen card).", "051" => "Insufficient funds.", "052" => "No checking account.", - "053" => "Mp savomgs accpimt.", + "053" => "No savings account.", "054" => "Expired Card.", "055" => "Incorrect PIN.", "057" => "Transaction not permitted to cardholder.", diff --git a/lib/active_merchant/billing/gateways/jetpay_v2.rb b/lib/active_merchant/billing/gateways/jetpay_v2.rb index 9ca46601a2f..31d92e00960 100644 --- a/lib/active_merchant/billing/gateways/jetpay_v2.rb +++ b/lib/active_merchant/billing/gateways/jetpay_v2.rb @@ -41,7 +41,7 @@ class JetpayV2Gateway < Gateway "043" => "Pick up card (stolen card).", "051" => "Insufficient funds.", "052" => "No checking account.", - "053" => "Mp savomgs accpimt.", + "053" => "No savings account.", "054" => "Expired Card.", "055" => "Incorrect PIN.", "057" => "Transaction not permitted to cardholder.", From 644163752dd1c4d09d38c4864556bb832581fe86 Mon Sep 17 00:00:00 2001 From: Matthew Heath <matthewheath@users.noreply.github.com> Date: Mon, 4 Sep 2017 19:34:36 +0100 Subject: [PATCH 445/677] Braintree: add Maestro as supported card type Unit: 6 tests, 6 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2571 Closes #2217 --- CHANGELOG | 1 + .../billing/gateways/braintree/braintree_common.rb | 2 +- test/unit/gateways/braintree_test.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1084174a009..d8aa4f3fab0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,7 @@ * Forte: fix a bug in logic for selecting billing names [whitby3001] #2381 * Paymentez: allow capture amount to exceed authorization amount [bpollack] #2900 * JetPay: fix typo in error messages [reynhout] #2749 +* Braintree: add support for Maestro cards [matthewheath] #2571 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/braintree/braintree_common.rb b/lib/active_merchant/billing/gateways/braintree/braintree_common.rb index 1d4fc3dec9b..b16b18e5f7b 100644 --- a/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +++ b/lib/active_merchant/billing/gateways/braintree/braintree_common.rb @@ -1,7 +1,7 @@ module BraintreeCommon def self.included(base) base.supported_countries = %w(US CA AD AT BE BG HR CY CZ DK EE FI FR GI DE GR GG HU IS IM IE IT JE LV LI LT LU MT MC NL NO PL PT RO SM SK SI ES SE CH TR GB SG HK MY AU NZ) - base.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club] + base.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro] base.homepage_url = 'http://www.braintreepaymentsolutions.com' base.display_name = 'Braintree' base.default_currency = 'USD' diff --git a/test/unit/gateways/braintree_test.rb b/test/unit/gateways/braintree_test.rb index ba1b24e76a2..07b8922305b 100644 --- a/test/unit/gateways/braintree_test.rb +++ b/test/unit/gateways/braintree_test.rb @@ -28,7 +28,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], BraintreeGateway.supported_cardtypes + assert_equal [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro], BraintreeGateway.supported_cardtypes end def test_should_have_default_currency From 0de48acaaf23b5be8ea3142875e4cf6304a31738 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@bitquabit.com> Date: Sun, 24 Jun 2018 11:41:58 -0400 Subject: [PATCH 446/677] Remove redundant lines from .travis.yml Several additional settings were introduced to work around Travis bug 8978, but that has since been resolved. Additionally, also remove a fully redundant `script` line. --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 903c2e0e197..726411a1e7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,6 @@ language: ruby -script: "bundle exec rake test:units" sudo: false cache: bundler -before_install: - # https://github.com/travis-ci/travis-ci/issues/8978#issuecomment-354036443 - - gem update --system - - gem install bundler rvm: - 2.5 From 974aa50b642fd45b92f36af846b9cea3d870fc5f Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 19 Jun 2018 11:23:39 -0400 Subject: [PATCH 447/677] Add RuboCop support This introduces RuboCop to Active Merchant, defaulting to the normal Ruby community guidelines. To grandfather in our existing code, I've pre-generated a `.rubocop_todo.yml` file, which will allow gradual migration. To run RuboCop, you can run `rake rubocop`, but I've also introduced a test:local Rake target that runs both the unit tests and RuboCop checks. I've made this be the default Rake task as well, which means Travis will (if this PR lands) require RuboCop passing for test approval. As a proof-of-concept, I went ahead and fixed WhenThen and YodaConditional style violations, which had sufficiently few violations to work for demo purposes. All PayPal-related code is excluded because it crashes RuboCop. Unit: 3864 tests, 67919 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- .rubocop.yml | 17 + .rubocop_todo.yml | 1793 +++++++++++++++++ Gemfile | 1 + Rakefile | 8 +- .../billing/credit_card_formatting.rb | 4 +- .../billing/gateways/cashnet.rb | 2 +- .../billing/gateways/cecabank.rb | 2 +- lib/active_merchant/billing/gateways/culqi.rb | 10 +- test/unit/gateways/braintree_blue_test.rb | 4 +- test/unit/gateways/stripe_test.rb | 2 +- 10 files changed, 1830 insertions(+), 13 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000000..27475582a79 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,17 @@ +inherit_from: .rubocop_todo.yml + +# Please keep AllCops, Bundler, Layout, Style, Metrics groups and then order cops +# alphabetically +# +# References: +# * https://github.com/bbatsov/ruby-style-guide +# * https://rubocop.readthedocs.io/ +AllCops: + DisplayCopNames: true + DisplayStyleGuide: true + Exclude: + - "generators/**/*" + - "lib/active_merchant/billing/gateways/paypal/**/*" + - "lib/active_merchant/billing/gateways/paypal_express.rb" + ExtraDetails: false + TargetRubyVersion: 2.3 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000000..9001653df45 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,1793 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2018-06-26 10:12:34 -0400 using RuboCop version 0.57.2. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: Include, TreatCommentsAsGroupSeparators. +# Include: **/*.gemspec +Gemspec/OrderedDependencies: + Exclude: + - 'activemerchant.gemspec' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: outdent, indent +Layout/AccessModifierIndentation: + Exclude: + - 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb' + - 'test/unit/gateways/allied_wallet_test.rb' + - 'test/unit/gateways/usa_epay_transaction_test.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Layout/AlignArray: + Exclude: + - 'lib/active_merchant/billing/gateways/plugnpay.rb' + - 'lib/active_merchant/billing/gateways/verifi.rb' + - 'test/unit/gateways/trexle_test.rb' + +# Offense count: 139 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/AlignHash: + Enabled: false + +# Offense count: 275 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_parameter, with_fixed_indentation +Layout/AlignParameters: + Enabled: false + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith. +# SupportedStylesAlignWith: either, start_of_block, start_of_line +Layout/BlockAlignment: + Exclude: + - 'lib/active_merchant/billing/gateways/elavon.rb' + - 'lib/active_merchant/billing/gateways/garanti.rb' + - 'lib/active_merchant/billing/gateways/opp.rb' + - 'lib/active_merchant/billing/gateways/payflow_express.rb' + - 'lib/active_merchant/billing/gateways/paymill.rb' + - 'lib/active_merchant/billing/gateways/viaklix.rb' + - 'lib/active_merchant/billing/gateways/wirecard.rb' + - 'test/unit/gateways/authorize_net_test.rb' + +# Offense count: 113 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. +# SupportedStyles: case, end +Layout/CaseIndentation: + Enabled: false + +# Offense count: 426 +# Cop supports --auto-correct. +Layout/ClosingHeredocIndentation: + Enabled: false + +# Offense count: 35 +# Cop supports --auto-correct. +Layout/ClosingParenthesisIndentation: + Enabled: false + +# Offense count: 20 +# Cop supports --auto-correct. +Layout/CommentIndentation: + Exclude: + - 'lib/active_merchant/billing/gateways/firstdata_e4.rb' + - 'lib/active_merchant/billing/gateways/ogone.rb' + - 'lib/active_merchant/billing/gateways/opp.rb' + - 'lib/active_merchant/billing/gateways/payflow_express.rb' + - 'test/remote/gateways/remote_itransact_test.rb' + - 'test/remote/gateways/remote_opp_test.rb' + - 'test/remote/gateways/remote_paypal_test.rb' + - 'test/remote/gateways/remote_world_net_test.rb' + - 'test/unit/gateways/eway_managed_test.rb' + - 'test/unit/gateways/opp_test.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. +# SupportedStylesAlignWith: start_of_line, def +Layout/DefEndAlignment: + Exclude: + - 'test/remote/gateways/remote_moneris_test.rb' + - 'test/remote/gateways/remote_pay_conex_test.rb' + - 'test/remote/gateways/remote_payflow_uk_test.rb' + - 'test/unit/gateways/optimal_payment_test.rb' + +# Offense count: 513 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: leading, trailing +Layout/DotPosition: + Enabled: false + +# Offense count: 24 +# Cop supports --auto-correct. +Layout/ElseAlignment: + Exclude: + - 'lib/active_merchant/billing/gateway.rb' + - 'lib/active_merchant/billing/gateways/authorize_net.rb' + - 'lib/active_merchant/billing/gateways/balanced.rb' + - 'lib/active_merchant/billing/gateways/braintree_blue.rb' + - 'lib/active_merchant/billing/gateways/card_stream.rb' + - 'lib/active_merchant/billing/gateways/clearhaus.rb' + - 'lib/active_merchant/billing/gateways/firstdata_e4.rb' + - 'lib/active_merchant/billing/gateways/moneris.rb' + - 'lib/active_merchant/billing/gateways/moneris_us.rb' + - 'lib/active_merchant/billing/gateways/pac_net_raven.rb' + - 'lib/active_merchant/billing/gateways/payflow.rb' + - 'lib/active_merchant/billing/gateways/trust_commerce.rb' + - 'lib/active_merchant/billing/response.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +Layout/EmptyLineAfterMagicComment: + Exclude: + - 'lib/active_merchant/billing/gateways/ogone.rb' + - 'lib/active_merchant/billing/gateways/redsys.rb' + - 'test/remote/gateways/remote_banwire_test.rb' + - 'test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb' + - 'test/remote/gateways/remote_finansbank_test.rb' + - 'test/remote/gateways/remote_ogone_test.rb' + - 'test/remote/gateways/remote_webpay_test.rb' + - 'test/remote/gateways/remote_wirecard_test.rb' + - 'test/unit/gateways/finansbank_test.rb' + - 'test/unit/gateways/usa_epay_advanced_test.rb' + - 'test/unit/gateways/wirecard_test.rb' + +# Offense count: 66 +# Cop supports --auto-correct. +# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Enabled: false + +# Offense count: 97 +# Cop supports --auto-correct. +Layout/EmptyLines: + Enabled: false + +# Offense count: 49 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundAccessModifier: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundArguments: + Exclude: + - 'test/unit/gateways/cardknox_test.rb' + - 'test/unit/gateways/usa_epay_transaction_test.rb' + +# Offense count: 15 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Exclude: + - 'lib/active_merchant/billing/gateways/cc5.rb' + - 'lib/active_merchant/billing/gateways/data_cash.rb' + - 'lib/active_merchant/billing/gateways/efsnet.rb' + - 'lib/active_merchant/billing/gateways/payflow_express.rb' + - 'lib/active_merchant/billing/gateways/telr.rb' + - 'test/remote/gateways/remote_paystation_test.rb' + - 'test/remote/gateways/remote_realex_test.rb' + - 'test/unit/gateways/cardknox_test.rb' + - 'test/unit/gateways/usa_epay_transaction_test.rb' + +# Offense count: 165 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only +Layout/EmptyLinesAroundClassBody: + Enabled: false + +# Offense count: 10 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundExceptionHandlingKeywords: + Exclude: + - 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb' + - 'lib/active_merchant/billing/gateways/cecabank.rb' + - 'lib/active_merchant/billing/gateways/exact.rb' + - 'lib/active_merchant/billing/gateways/pay_conex.rb' + - 'lib/active_merchant/billing/gateways/pin.rb' + - 'lib/active_merchant/billing/gateways/wepay.rb' + - 'lib/active_merchant/billing/gateways/worldpay.rb' + - 'lib/active_merchant/billing/gateways/worldpay_online_payments.rb' + - 'lib/active_merchant/connection.rb' + - 'test/unit/gateways/worldpay_test.rb' + +# Offense count: 64 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundMethodBody: + Enabled: false + +# Offense count: 18 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: + Exclude: + - 'lib/active_merchant/billing/credit_card_formatting.rb' + - 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb' + - 'lib/active_merchant/billing/gateways/efsnet.rb' + - 'lib/active_merchant/billing/gateways/ezic.rb' + - 'lib/active_merchant/billing/gateways/linkpoint.rb' + - 'lib/active_merchant/billing/gateways/mastercard.rb' + - 'lib/active_merchant/billing/gateways/moneris.rb' + - 'lib/active_merchant/billing/gateways/moneris_us.rb' + - 'lib/active_merchant/billing/gateways/payment_express.rb' + - 'lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb' + - 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb' + - 'lib/active_merchant/billing/gateways/sage_pay.rb' + - 'lib/active_merchant/billing/gateways/trans_first.rb' + - 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb' + - 'lib/active_merchant/posts_data.rb' + +# Offense count: 40 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. +# SupportedStylesAlignWith: keyword, variable, start_of_line +Layout/EndAlignment: + Enabled: false + +# Offense count: 191 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Enabled: false + +# Offense count: 122 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses +Layout/FirstParameterIndentation: + Enabled: false + +# Offense count: 13 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets +Layout/IndentArray: + Exclude: + - 'lib/active_merchant/billing/gateways/firstdata_e4.rb' + - 'test/remote/gateways/remote_linkpoint_test.rb' + - 'test/remote/gateways/remote_payflow_express_test.rb' + - 'test/unit/gateways/cyber_source_test.rb' + - 'test/unit/gateways/paypal_express_test.rb' + +# Offense count: 253 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/IndentHash: + Enabled: false + +# Offense count: 387 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent +Layout/IndentHeredoc: + Enabled: false + +# Offense count: 135 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, rails +Layout/IndentationConsistency: + Enabled: false + +# Offense count: 244 +# Cop supports --auto-correct. +# Configuration parameters: Width, IgnoredPatterns. +Layout/IndentationWidth: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/LeadingBlankLines: + Exclude: + - 'lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb' + - 'test/unit/gateways/quickpay_test.rb' + +# Offense count: 68 +# Cop supports --auto-correct. +Layout/LeadingCommentSpace: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineArrayBraceLayout: + Exclude: + - 'lib/active_merchant/billing/gateways/optimal_payment.rb' + - 'test/remote/gateways/remote_linkpoint_test.rb' + - 'test/remote/gateways/remote_orbital_test.rb' + - 'test/remote/gateways/remote_payflow_express_test.rb' + +# Offense count: 42 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineHashBraceLayout: + Enabled: false + +# Offense count: 234 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineMethodCallBraceLayout: + Enabled: false + +# Offense count: 34 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented, indented_relative_to_receiver +Layout/MultilineMethodCallIndentation: + Exclude: + - 'lib/active_merchant/billing/gateways/balanced.rb' + - 'lib/active_merchant/billing/gateways/ogone.rb' + - 'lib/active_merchant/billing/gateways/realex.rb' + - 'lib/active_merchant/billing/gateways/sage.rb' + - 'lib/active_merchant/billing/gateways/telr.rb' + - 'test/unit/connection_test.rb' + - 'test/unit/gateways/braintree_blue_test.rb' + - 'test/unit/gateways/jetpay_v2_test.rb' + - 'test/unit/gateways/wirecard_test.rb' + - 'test/unit/network_connection_retries_test.rb' + +# Offense count: 35 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented +Layout/MultilineOperationIndentation: + Exclude: + - 'lib/active_merchant/billing/credit_card_methods.rb' + - 'lib/active_merchant/billing/gateways/commercegate.rb' + - 'lib/active_merchant/billing/gateways/iridium.rb' + - 'lib/active_merchant/billing/gateways/moneris.rb' + - 'lib/active_merchant/billing/gateways/moneris_us.rb' + - 'lib/active_merchant/billing/gateways/orbital.rb' + - 'lib/active_merchant/billing/gateways/redsys.rb' + - 'test/unit/gateways/barclays_epdq_extra_plus_test.rb' + - 'test/unit/gateways/braintree_blue_test.rb' + - 'test/unit/gateways/ogone_test.rb' + - 'test/unit/gateways/skip_jack_test.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/RescueEnsureAlignment: + Exclude: + - 'lib/active_merchant/billing/gateways/checkout_v2.rb' + - 'lib/active_merchant/billing/gateways/mundipagg.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/SpaceAfterColon: + Exclude: + - 'test/remote/gateways/remote_micropayment_test.rb' + - 'test/remote/gateways/remote_payu_latam_test.rb' + +# Offense count: 315 +# Cop supports --auto-correct. +Layout/SpaceAfterComma: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleInsidePipes. +# SupportedStylesInsidePipes: space, no_space +Layout/SpaceAroundBlockParameters: + Exclude: + - 'lib/active_merchant/billing/gateways/payscout.rb' + - 'test/unit/country_test.rb' + +# Offense count: 638 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: false + +# Offense count: 105 +# Cop supports --auto-correct. +Layout/SpaceAroundKeyword: + Enabled: false + +# Offense count: 802 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Layout/SpaceAroundOperators: + Enabled: false + +# Offense count: 182 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceBeforeBlockBraces: + Enabled: false + +# Offense count: 39 +# Cop supports --auto-correct. +Layout/SpaceBeforeComma: + Exclude: + - 'lib/active_merchant/billing/gateways/cyber_source.rb' + - 'lib/active_merchant/billing/gateways/ideal/ideal_base.rb' + - 'lib/active_merchant/billing/gateways/instapay.rb' + - 'lib/active_merchant/billing/gateways/net_registry.rb' + - 'lib/active_merchant/billing/gateways/optimal_payment.rb' + - 'lib/active_merchant/billing/gateways/psigate.rb' + - 'lib/active_merchant/billing/gateways/sage_pay.rb' + - 'test/remote/gateways/remote_eway_test.rb' + - 'test/remote/gateways/remote_payflow_express_test.rb' + - 'test/remote/gateways/remote_paypal_express_test.rb' + - 'test/remote/gateways/remote_paypal_test.rb' + - 'test/unit/gateways/checkout_test.rb' + - 'test/unit/gateways/paypal_express_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/SpaceBeforeComment: + Exclude: + - 'test/remote/gateways/remote_usa_epay_advanced_test.rb' + +# Offense count: 16 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Layout/SpaceBeforeFirstArg: + Exclude: + - 'lib/active_merchant/billing/gateways/checkout.rb' + - 'lib/active_merchant/billing/gateways/cyber_source.rb' + - 'lib/active_merchant/billing/gateways/s5.rb' + - 'test/remote/gateways/remote_braintree_orange_test.rb' + - 'test/remote/gateways/remote_payflow_test.rb' + - 'test/unit/gateways/bogus_test.rb' + - 'test/unit/gateways/instapay_test.rb' + - 'test/unit/gateways/quickpay_v10_test.rb' + - 'test/unit/gateways/quickpay_v4to7_test.rb' + +# Offense count: 122 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: false + +# Offense count: 12 +# Cop supports --auto-correct. +Layout/SpaceInsideArrayPercentLiteral: + Exclude: + - 'lib/active_merchant/billing/gateways/migs/migs_codes.rb' + +# Offense count: 345 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Enabled: false + +# Offense count: 1186 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Enabled: false + +# Offense count: 116 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceInsideParens: + Enabled: false + +# Offense count: 115 +# Cop supports --auto-correct. +Layout/SpaceInsidePercentLiteralDelimiters: + Enabled: false + +# Offense count: 35 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideReferenceBrackets: + Exclude: + - 'lib/active_merchant/billing/gateways/blue_pay.rb' + - 'lib/active_merchant/billing/gateways/cams.rb' + - 'lib/active_merchant/billing/gateways/ideal/ideal_base.rb' + - 'lib/active_merchant/billing/gateways/metrics_global.rb' + - 'lib/active_merchant/billing/gateways/sage_pay.rb' + - 'lib/active_merchant/billing/gateways/secure_pay.rb' + - 'lib/active_merchant/billing/gateways/transact_pro.rb' + - 'test/remote/gateways/remote_ideal_rabobank_test.rb' + - 'test/remote/gateways/remote_wirecard_test.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceInsideStringInterpolation: + Exclude: + - 'lib/active_merchant/billing/gateways/garanti.rb' + - 'lib/active_merchant/billing/gateways/trust_commerce.rb' + - 'test/unit/gateways/worldpay_test.rb' + +# Offense count: 27 +# Cop supports --auto-correct. +# Configuration parameters: IndentationWidth. +Layout/Tab: + Exclude: + - 'lib/active_merchant/billing/gateways/braintree_blue.rb' + - 'lib/active_merchant/billing/gateways/efsnet.rb' + - 'lib/active_merchant/billing/gateways/pagarme.rb' + - 'lib/active_merchant/billing/gateways/trust_commerce.rb' + - 'test/remote/gateways/remote_orbital_test.rb' + +# Offense count: 57 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingBlankLines: + Enabled: false + +# Offense count: 357 +# Cop supports --auto-correct. +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Enabled: false + +# Offense count: 4 +Lint/AmbiguousBlockAssociation: + Exclude: + - 'test/test_helper.rb' + - 'test/unit/gateways/gateway_test.rb' + - 'test/unit/gateways/worldpay_test.rb' + +# Offense count: 31 +Lint/AmbiguousRegexpLiteral: + Enabled: false + +# Offense count: 148 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Enabled: false + +# Offense count: 8 +Lint/DuplicateMethods: + Exclude: + - 'test/remote/gateways/remote_litle_certification_test.rb' + - 'test/remote/gateways/remote_mercury_certification_test.rb' + - 'test/remote/gateways/remote_modern_payments_test.rb' + - 'test/remote/gateways/remote_netaxept_test.rb' + - 'test/remote/gateways/remote_verifi_test.rb' + +# Offense count: 1 +Lint/EmptyWhen: + Exclude: + - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' + +# Offense count: 3 +Lint/FormatParameterMismatch: + Exclude: + - 'test/unit/credit_card_formatting_test.rb' + +# Offense count: 2 +Lint/HandleExceptions: + Exclude: + - 'lib/active_merchant/billing/gateways/mastercard.rb' + - 'lib/active_merchant/billing/gateways/trust_commerce.rb' + +# Offense count: 1 +Lint/IneffectiveAccessModifier: + Exclude: + - 'lib/active_merchant/network_connection_retries.rb' + +# Offense count: 1 +Lint/NestedMethodDefinition: + Exclude: + - 'test/unit/gateways/blue_pay_test.rb' + +# Offense count: 4 +Lint/ParenthesesAsGroupedExpression: + Exclude: + - 'lib/active_merchant/billing/gateways/trans_first_transaction_express.rb' + - 'test/remote/gateways/remote_payment_express_test.rb' + - 'test/remote/gateways/remote_worldpay_test.rb' + +# Offense count: 1 +Lint/RescueException: + Exclude: + - 'lib/active_merchant/billing/gateways/quantum.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Lint/ScriptPermission: + Exclude: + - 'lib/active_merchant/billing/avs_result.rb' + - 'lib/active_merchant/billing/gateways/skip_jack.rb' + - 'test/test_helper.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +Lint/StringConversionInInterpolation: + Exclude: + - 'lib/active_merchant/billing/gateways/adyen.rb' + - 'lib/active_merchant/billing/gateways/dibs.rb' + - 'lib/active_merchant/billing/gateways/pay_junction.rb' + - 'lib/active_merchant/billing/gateways/skip_jack.rb' + - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' + - 'test/remote/gateways/remote_authorize_net_cim_test.rb' + +# Offense count: 1 +Lint/UnderscorePrefixedVariableName: + Exclude: + - 'lib/active_merchant/billing/gateways/ogone.rb' + +# Offense count: 1453 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Enabled: false + +# Offense count: 283 +# Cop supports --auto-correct. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. +Lint/UnusedMethodArgument: + Enabled: false + +# Offense count: 1 +# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. +Lint/UselessAccessModifier: + Exclude: + - 'lib/active_merchant/network_connection_retries.rb' + +# Offense count: 68 +Lint/UselessAssignment: + Enabled: false + +# Offense count: 1409 +Metrics/AbcSize: + Max: 192 + +# Offense count: 26 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/BlockLength: + Max: 54 + +# Offense count: 12 +# Configuration parameters: CountBlocks. +Metrics/BlockNesting: + Max: 6 + +# Offense count: 489 +# Configuration parameters: CountComments. +Metrics/ClassLength: + Max: 2135 + +# Offense count: 175 +Metrics/CyclomaticComplexity: + Max: 36 + +# Offense count: 1741 +# Configuration parameters: CountComments. +Metrics/MethodLength: + Max: 163 + +# Offense count: 5 +# Configuration parameters: CountComments. +Metrics/ModuleLength: + Max: 383 + +# Offense count: 2 +# Configuration parameters: CountKeywordArgs. +Metrics/ParameterLists: + Max: 6 + +# Offense count: 126 +Metrics/PerceivedComplexity: + Max: 32 + +# Offense count: 6 +Naming/AccessorMethodName: + Exclude: + - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' + - 'test/remote/gateways/remote_authorize_net_cim_test.rb' + - 'test/unit/gateways/authorize_net_cim_test.rb' + +# Offense count: 1 +Naming/ConstantName: + Exclude: + - 'test/test_helper.rb' + +# Offense count: 45 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: lowercase, uppercase +Naming/HeredocDelimiterCase: + Exclude: + - 'test/unit/gateways/authorize_net_test.rb' + - 'test/unit/gateways/card_stream_test.rb' + - 'test/unit/gateways/hps_test.rb' + - 'test/unit/gateways/litle_test.rb' + - 'test/unit/gateways/moneris_test.rb' + +# Offense count: 85 +# Configuration parameters: Blacklist. +# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) +Naming/HeredocDelimiterNaming: + Enabled: false + +# Offense count: 1 +Naming/MemoizedInstanceVariableName: + Exclude: + - 'lib/active_merchant/billing/compatibility.rb' + +# Offense count: 15 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: snake_case, camelCase +Naming/MethodName: + Exclude: + - 'lib/active_merchant/billing/gateways/card_connect.rb' + - 'lib/active_merchant/billing/gateways/latitude19.rb' + - 'lib/active_merchant/billing/gateways/qbms.rb' + - 'test/remote/gateways/remote_card_connect_test.rb' + - 'test/remote/gateways/remote_card_stream_test.rb' + - 'test/remote/gateways/remote_fat_zebra_test.rb' + - 'test/remote/gateways/remote_sage_pay_test.rb' + - 'test/unit/gateways/sage_pay_test.rb' + +# Offense count: 5 +# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros. +# NamePrefix: is_, has_, have_ +# NamePrefixBlacklist: is_, has_, have_ +# NameWhitelist: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicateName: + Exclude: + - 'spec/**/*' + - 'lib/active_merchant/billing/gateways/authorize_net.rb' + - 'lib/active_merchant/billing/gateways/payeezy.rb' + - 'lib/active_merchant/billing/gateways/paymill.rb' + - 'lib/active_merchant/billing/gateways/redsys.rb' + - 'lib/active_merchant/billing/gateways/sage_pay.rb' + +# Offense count: 14 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: io, id, to, by, on, in, at +Naming/UncommunicativeMethodParamName: + Exclude: + - 'lib/active_merchant/billing/gateways/blue_snap.rb' + - 'lib/active_merchant/billing/gateways/cyber_source.rb' + - 'lib/active_merchant/billing/gateways/iridium.rb' + - 'lib/active_merchant/billing/gateways/latitude19.rb' + - 'lib/active_merchant/billing/gateways/merchant_ware.rb' + - 'lib/active_merchant/billing/gateways/quantum.rb' + - 'lib/active_merchant/billing/gateways/worldpay_online_payments.rb' + - 'test/unit/gateways/paypal/paypal_common_api_test.rb' + - 'test/unit/gateways/realex_test.rb' + +# Offense count: 51 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: snake_case, camelCase +Naming/VariableName: + Exclude: + - 'lib/active_merchant/billing/gateways/cyber_source.rb' + - 'lib/active_merchant/billing/gateways/ideal/ideal_base.rb' + - 'lib/active_merchant/billing/gateways/iridium.rb' + - 'lib/active_merchant/billing/gateways/latitude19.rb' + - 'lib/active_merchant/billing/gateways/optimal_payment.rb' + - 'lib/active_merchant/billing/gateways/quantum.rb' + - 'lib/active_merchant/billing/gateways/worldpay_online_payments.rb' + - 'test/remote/gateways/remote_authorize_net_test.rb' + - 'test/remote/gateways/remote_card_stream_test.rb' + - 'test/remote/gateways/remote_worldpay_test.rb' + - 'test/unit/gateways/card_stream_test.rb' + - 'test/unit/gateways/worldpay_online_payments_test.rb' + +# Offense count: 11 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: snake_case, normalcase, non_integer +Naming/VariableNumber: + Exclude: + - 'lib/active_merchant/billing/gateways/merchant_partners.rb' + - 'lib/active_merchant/billing/gateways/mercury.rb' + - 'lib/active_merchant/billing/gateways/orbital.rb' + - 'test/remote/gateways/remote_paypal_test.rb' + - 'test/unit/gateways/merchant_ware_test.rb' + - 'test/unit/gateways/merchant_ware_version_four_test.rb' + - 'test/unit/gateways/orbital_test.rb' + - 'test/unit/gateways/paypal/paypal_common_api_test.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +Performance/Casecmp: + Exclude: + - 'lib/active_merchant/billing/gateways/ebanx.rb' + - 'lib/active_merchant/billing/gateways/eway_managed.rb' + - 'lib/active_merchant/billing/gateways/itransact.rb' + - 'lib/active_merchant/billing/gateways/paystation.rb' + - 'lib/active_merchant/billing/gateways/redsys.rb' + - 'lib/active_merchant/country.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Performance/CompareWithBlock: + Exclude: + - 'lib/active_merchant/billing/gateways/skip_jack.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +Performance/InefficientHashSearch: + Exclude: + - 'lib/active_merchant/billing/credit_card.rb' + - 'lib/active_merchant/billing/gateways/inspire.rb' + - 'lib/active_merchant/billing/gateways/smart_ps.rb' + - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' + - 'test/unit/gateways/payscout_test.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +Performance/RangeInclude: + Exclude: + - 'lib/active_merchant/billing/check.rb' + - 'lib/active_merchant/billing/credit_card_methods.rb' + - 'lib/active_merchant/billing/gateways/blue_pay.rb' + - 'lib/active_merchant/billing/gateways/blue_snap.rb' + - 'lib/active_merchant/billing/gateways/cashnet.rb' + - 'lib/active_merchant/billing/gateways/moneris.rb' + - 'lib/active_merchant/billing/gateways/moneris_us.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Performance/RedundantBlockCall: + Exclude: + - 'test/unit/gateways/nab_transact_test.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Performance/RedundantMatch: + Exclude: + - 'lib/active_merchant/billing/gateways/opp.rb' + - 'test/unit/gateways/payu_latam_test.rb' + +# Offense count: 59 +# Cop supports --auto-correct. +# Configuration parameters: MaxKeyValuePairs. +Performance/RedundantMerge: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Performance/ReverseEach: + Exclude: + - 'lib/active_merchant/billing/gateways/trust_commerce.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +Performance/StringReplacement: + Exclude: + - 'lib/active_merchant/billing/compatibility.rb' + - 'lib/active_merchant/billing/gateways/card_connect.rb' + - 'lib/active_merchant/billing/gateways/firstdata_e4.rb' + - 'lib/active_merchant/billing/gateways/ideal/ideal_base.rb' + - 'lib/active_merchant/billing/gateways/merchant_ware.rb' + - 'lib/active_merchant/billing/gateways/merchant_ware_version_four.rb' + - 'lib/active_merchant/billing/gateways/orbital.rb' + - 'lib/active_merchant/billing/gateways/quickbooks.rb' + - 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb' + - 'lib/active_merchant/billing/gateways/realex.rb' + - 'test/unit/gateways/nab_transact_test.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +Security/YAMLLoad: + Exclude: + - 'test/test_helper.rb' + - 'test/unit/fixtures_test.rb' + - 'test/unit/gateways/firstdata_e4_test.rb' + - 'test/unit/gateways/payeezy_test.rb' + +# Offense count: 2 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: inline, group +Style/AccessModifierDeclarations: + Exclude: + - 'test/unit/gateways/metrics_global_test.rb' + - 'test/unit/gateways/optimal_payment_test.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: prefer_alias, prefer_alias_method +Style/Alias: + Exclude: + - 'lib/active_merchant/billing/gateways/beanstream.rb' + - 'lib/active_merchant/billing/gateways/braintree_blue.rb' + - 'lib/active_merchant/billing/gateways/inspire.rb' + - 'lib/active_merchant/billing/gateways/migs.rb' + - 'lib/active_merchant/billing/gateways/smart_ps.rb' + - 'lib/active_merchant/billing/gateways/spreedly_core.rb' + - 'lib/active_merchant/post_data.rb' + - 'test/unit/gateways/bpoint_test.rb' + - 'test/unit/gateways/paymentez_test.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, conditionals +Style/AndOr: + Exclude: + - 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb' + - 'lib/active_merchant/billing/gateways/eway.rb' + - 'lib/active_merchant/billing/gateways/iridium.rb' + - 'lib/active_merchant/billing/gateways/pac_net_raven.rb' + - 'lib/active_merchant/billing/gateways/smart_ps.rb' + - 'lib/active_merchant/billing/gateways/stripe.rb' + - 'lib/active_merchant/billing/gateways/webpay.rb' + +# Offense count: 47 +# Configuration parameters: AllowedChars. +Style/AsciiComments: + Exclude: + - 'lib/active_merchant/billing/gateways/authorize_net_arb.rb' + - 'lib/active_merchant/billing/gateways/authorize_net_cim.rb' + - 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb' + - 'lib/active_merchant/billing/gateways/eway_rapid.rb' + - 'lib/active_merchant/billing/gateways/netbanx.rb' + - 'lib/active_merchant/billing/gateways/ogone.rb' + - 'lib/active_merchant/billing/gateways/orbital.rb' + - 'lib/active_merchant/billing/gateways/payflow_express.rb' + - 'lib/active_merchant/billing/gateways/paystation.rb' + - 'lib/active_merchant/billing/gateways/psl_card.rb' + - 'lib/active_merchant/billing/gateways/sage.rb' + - 'test/remote/gateways/remote_data_cash_test.rb' + - 'test/remote/gateways/remote_nab_transact_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/Attr: + Exclude: + - 'test/unit/gateways/forte_test.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: percent_q, bare_percent +Style/BarePercentLiterals: + Exclude: + - 'test/unit/gateways/clearhaus_test.rb' + - 'test/unit/gateways/eway_rapid_test.rb' + - 'test/unit/gateways/orbital_test.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/BlockComments: + Exclude: + - 'test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb' + - 'test/remote/gateways/remote_netpay_test.rb' + - 'test/remote/gateways/remote_payu_in_test.rb' + +# Offense count: 75 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# IgnoredMethods: lambda, proc, it +Style/BlockDelimiters: + Enabled: false + +# Offense count: 443 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: braces, no_braces, context_dependent +Style/BracesAroundHashParameters: + Enabled: false + +# Offense count: 2 +Style/CaseEquality: + Exclude: + - 'lib/active_merchant/billing/gateways/braintree_blue.rb' + - 'test/test_helper.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Exclude: + - 'test/unit/gateways/optimal_payment_test.rb' + - 'test/unit/gateways/realex_test.rb' + +# Offense count: 35 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: is_a?, kind_of? +Style/ClassCheck: + Enabled: false + +# Offense count: 8 +Style/ClassVars: + Exclude: + - 'lib/active_merchant/billing/base.rb' + - 'lib/active_merchant/billing/gateway.rb' + - 'lib/active_merchant/billing/gateways/balanced.rb' + - 'lib/active_merchant/billing/gateways/cyber_source.rb' + - 'test/remote/gateways/remote_cams_test.rb' + - 'test/test_helper.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +Style/ColonMethodCall: + Exclude: + - 'lib/active_merchant/billing/gateways/blue_pay.rb' + - 'lib/active_merchant/billing/gateways/cashnet.rb' + - 'lib/active_merchant/billing/gateways/credorax.rb' + - 'lib/active_merchant/billing/gateways/epay.rb' + - 'lib/active_merchant/billing/gateways/evo_ca.rb' + - 'lib/active_merchant/billing/gateways/ezic.rb' + - 'lib/active_merchant/billing/gateways/migs.rb' + - 'lib/active_merchant/billing/gateways/nmi.rb' + - 'test/unit/gateways/quickpay_v4to7_test.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: Keywords. +# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW +Style/CommentAnnotation: + Exclude: + - 'lib/active_merchant/billing/gateways/authorize_net_cim.rb' + - 'test/remote/gateways/remote_usa_epay_advanced_test.rb' + - 'test/unit/gateways/authorize_net_cim_test.rb' + - 'test/unit/gateways/usa_epay_advanced_test.rb' + +# Offense count: 8 +Style/CommentedKeyword: + Exclude: + - 'lib/active_merchant/billing/gateways/blue_pay.rb' + - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' + - 'lib/active_merchant/errors.rb' + - 'test/remote/gateways/remote_cardknox_test.rb' + - 'test/unit/gateways/cardknox_test.rb' + +# Offense count: 23 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. +# SupportedStyles: assign_to_condition, assign_inside_condition +Style/ConditionalAssignment: + Enabled: false + +# Offense count: 7 +Style/DateTime: + Exclude: + - 'test/remote/gateways/remote_first_pay_test.rb' + - 'test/remote/gateways/remote_pin_test.rb' + - 'test/remote/gateways/remote_trexle_test.rb' + - 'test/unit/gateways/orbital_test.rb' + - 'test/unit/gateways/paypal/paypal_common_api_test.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/DefWithParentheses: + Exclude: + - 'lib/active_merchant/billing/gateways/latitude19.rb' + - 'lib/active_merchant/billing/gateways/pagarme.rb' + +# Offense count: 210 +Style/Documentation: + Enabled: false + +# Offense count: 3 +Style/DoubleNegation: + Exclude: + - 'lib/active_merchant/billing/gateways/balanced.rb' + - 'lib/active_merchant/billing/gateways/netbilling.rb' + - 'lib/active_merchant/billing/gateways/pay_secure.rb' + +# Offense count: 18 +# Cop supports --auto-correct. +Style/EachWithObject: + Exclude: + - 'lib/active_merchant/billing/avs_result.rb' + - 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb' + - 'lib/active_merchant/billing/gateways/cams.rb' + - 'lib/active_merchant/billing/gateways/ezic.rb' + - 'lib/active_merchant/billing/gateways/federated_canada.rb' + - 'lib/active_merchant/billing/gateways/merchant_one.rb' + - 'lib/active_merchant/billing/gateways/micropayment.rb' + - 'lib/active_merchant/billing/gateways/money_movers.rb' + - 'lib/active_merchant/billing/gateways/orbital.rb' + - 'lib/active_merchant/billing/gateways/payu_in.rb' + - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' + - 'lib/active_merchant/billing/model.rb' + - 'test/test_helper.rb' + - 'test/unit/gateways/authorize_net_test.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +Style/EmptyCaseCondition: + Exclude: + - 'lib/active_merchant/billing/gateways/inspire.rb' + - 'lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb' + - 'lib/active_merchant/billing/gateways/smart_ps.rb' + - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty, nil, both +Style/EmptyElse: + Exclude: + - 'lib/active_merchant/billing/gateways/fat_zebra.rb' + - 'lib/active_merchant/billing/gateways/mercado_pago.rb' + - 'lib/active_merchant/billing/gateways/payeezy.rb' + - 'lib/active_merchant/billing/gateways/payment_express.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Style/EmptyLiteral: + Exclude: + - 'lib/active_merchant/billing/gateways/element.rb' + - 'lib/active_merchant/billing/gateways/itransact.rb' + - 'lib/active_merchant/billing/gateways/kushki.rb' + - 'lib/active_merchant/billing/gateways/transact_pro.rb' + - 'test/unit/gateways/paypal_digital_goods_test.rb' + +# Offense count: 14 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: compact, expanded +Style/EmptyMethod: + Exclude: + - 'lib/active_merchant/billing/gateways/qbms.rb' + - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' + - 'test/remote/gateways/remote_ncr_secure_pay_test.rb' + - 'test/unit/gateways/card_connect_test.rb' + - 'test/unit/gateways/cardknox_test.rb' + - 'test/unit/gateways/latitude19_test.rb' + - 'test/unit/gateways/world_net_test.rb' + - 'test/unit/gateways/worldpay_online_payments_test.rb' + +# Offense count: 24 +# Cop supports --auto-correct. +Style/Encoding: + Enabled: false + +# Offense count: 2 +Style/EvalWithLocation: + Exclude: + - 'lib/active_merchant/billing/credit_card.rb' + - 'lib/active_merchant/billing/response.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Style/ExpandPathArguments: + Exclude: + - 'Rakefile' + - 'activemerchant.gemspec' + - 'script/generate' + - 'test/test_helper.rb' + +# Offense count: 11 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: each, for +Style/For: + Exclude: + - 'lib/active_merchant/billing/gateways/cardknox.rb' + - 'lib/active_merchant/billing/gateways/linkpoint.rb' + - 'lib/active_merchant/billing/gateways/merchant_one.rb' + - 'lib/active_merchant/billing/gateways/psl_card.rb' + - 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb' + - 'test/remote/gateways/remote_orbital_test.rb' + +# Offense count: 96 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: format, sprintf, percent +Style/FormatString: + Enabled: false + +# Offense count: 22 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: annotated, template, unannotated +Style/FormatStringToken: + Exclude: + - 'lib/active_merchant/billing/gateways/redsys.rb' + - 'lib/active_merchant/connection.rb' + - 'lib/active_merchant/network_connection_retries.rb' + - 'test/remote/gateways/remote_balanced_test.rb' + - 'test/remote/gateways/remote_openpay_test.rb' + - 'test/unit/gateways/balanced_test.rb' + - 'test/unit/gateways/elavon_test.rb' + - 'test/unit/gateways/exact_test.rb' + - 'test/unit/gateways/firstdata_e4_test.rb' + - 'test/unit/gateways/safe_charge_test.rb' + +# Offense count: 677 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: when_needed, always, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 5 +# Configuration parameters: AllowedVariables. +Style/GlobalVars: + Exclude: + - 'test/remote/gateways/remote_finansbank_test.rb' + - 'test/remote/gateways/remote_garanti_test.rb' + - 'test/remote/gateways/remote_secure_pay_tech_test.rb' + - 'test/unit/gateways/finansbank_test.rb' + - 'test/unit/gateways/garanti_test.rb' + +# Offense count: 192 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Enabled: false + +# Offense count: 7424 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +Style/HashSyntax: + Enabled: false + +# Offense count: 6 +Style/IdenticalConditionalBranches: + Exclude: + - 'lib/active_merchant/billing/gateways/elavon.rb' + - 'lib/active_merchant/billing/gateways/litle.rb' + - 'lib/active_merchant/billing/gateways/payu_latam.rb' + +# Offense count: 15 +Style/IfInsideElse: + Exclude: + - 'lib/active_merchant/billing/credit_card.rb' + - 'lib/active_merchant/billing/gateways/authorize_net.rb' + - 'lib/active_merchant/billing/gateways/cecabank.rb' + - 'lib/active_merchant/billing/gateways/element.rb' + - 'lib/active_merchant/billing/gateways/eway_managed.rb' + - 'lib/active_merchant/billing/gateways/global_collect.rb' + - 'lib/active_merchant/billing/gateways/iridium.rb' + - 'lib/active_merchant/billing/gateways/quantum.rb' + - 'lib/active_merchant/billing/gateways/skip_jack.rb' + - 'lib/active_merchant/billing/gateways/worldpay_online_payments.rb' + +# Offense count: 128 +# Cop supports --auto-correct. +Style/IfUnlessModifier: + Enabled: false + +# Offense count: 3 +Style/IfUnlessModifierOfIfUnless: + Exclude: + - 'lib/active_merchant/billing/gateways/merchant_e_solutions.rb' + - 'lib/active_merchant/posts_data.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: InverseMethods, InverseBlocks. +Style/InverseMethods: + Exclude: + - 'lib/active_merchant/billing/gateways/ogone.rb' + - 'lib/active_merchant/billing/gateways/worldpay.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: line_count_dependent, lambda, literal +Style/Lambda: + Exclude: + - 'lib/active_merchant/billing/gateways/orbital.rb' + +# Offense count: 15 +# Cop supports --auto-correct. +Style/LineEndConcatenation: + Exclude: + - 'lib/active_merchant/billing/gateways/commercegate.rb' + - 'lib/active_merchant/billing/gateways/pay_hub.rb' + - 'lib/active_merchant/billing/gateways/swipe_checkout.rb' + - 'test/unit/gateways/barclays_epdq_extra_plus_test.rb' + - 'test/unit/gateways/ogone_test.rb' + +# Offense count: 31 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +Style/MethodCallWithoutArgsParentheses: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline +Style/MethodDefParentheses: + Exclude: + - 'lib/active_merchant/billing/gateways/cyber_source.rb' + - 'test/unit/gateways/ideal_rabobank_test.rb' + - 'test/unit/gateways/quickpay_v10_test.rb' + +# Offense count: 626 +Style/MultilineBlockChain: + Enabled: false + +# Offense count: 20 +# Cop supports --auto-correct. +Style/MultilineIfModifier: + Enabled: false + +# Offense count: 7 +# Cop supports --auto-correct. +Style/MultilineIfThen: + Exclude: + - 'lib/active_merchant/billing/gateways/eway_managed.rb' + - 'lib/active_merchant/connection.rb' + +# Offense count: 4 +Style/MultilineTernaryOperator: + Exclude: + - 'lib/active_merchant/billing/gateways/merchant_partners.rb' + - 'lib/active_merchant/billing/gateways/ogone.rb' + - 'lib/active_merchant/billing/gateways/swipe_checkout.rb' + - 'lib/active_merchant/billing/gateways/transact_pro.rb' + +# Offense count: 1 +Style/MultipleComparison: + Exclude: + - 'lib/active_merchant/billing/gateways/worldpay_online_payments.rb' + +# Offense count: 516 +# Cop supports --auto-correct. +Style/MutableConstant: + Enabled: false + +# Offense count: 21 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: both, prefix, postfix +Style/NegatedIf: + Exclude: + - 'lib/active_merchant/billing/credit_card.rb' + - 'lib/active_merchant/billing/gateways/adyen.rb' + - 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb' + - 'lib/active_merchant/billing/gateways/itransact.rb' + - 'lib/active_merchant/billing/gateways/iveri.rb' + - 'lib/active_merchant/billing/gateways/ogone.rb' + - 'lib/active_merchant/billing/gateways/orbital.rb' + - 'lib/active_merchant/billing/gateways/qbms.rb' + - 'lib/active_merchant/billing/gateways/worldpay.rb' + - 'lib/support/ssl_verify.rb' + - 'test/remote/gateways/remote_paypal_test.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/NestedModifier: + Exclude: + - 'lib/active_merchant/billing/gateways/merchant_e_solutions.rb' + - 'lib/active_merchant/posts_data.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: Whitelist. +# Whitelist: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with +Style/NestedParenthesizedCalls: + Exclude: + - 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinBodyLength. +# SupportedStyles: skip_modifier_ifs, always +Style/Next: + Exclude: + - 'lib/active_merchant/billing/gateways/authorize_net.rb' + - 'lib/support/outbound_hosts.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +Style/NilComparison: + Exclude: + - 'lib/active_merchant/billing/gateways/card_stream.rb' + - 'lib/active_merchant/billing/gateways/litle.rb' + - 'lib/active_merchant/billing/gateways/telr.rb' + - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' + - 'test/unit/gateways/braintree_blue_test.rb' + - 'test/unit/gateways/stripe_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IncludeSemanticChanges. +Style/NonNilCheck: + Exclude: + - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Style/Not: + Exclude: + - 'test/remote/gateways/remote_paypal_test.rb' + - 'test/test_helper.rb' + - 'test/unit/gateways/braintree_blue_test.rb' + +# Offense count: 20 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedOctalStyle. +# SupportedOctalStyles: zero_with_o, zero_only +Style/NumericLiteralPrefix: + Exclude: + - 'lib/active_merchant/billing/gateways/psl_card.rb' + - 'test/remote/gateways/remote_axcessms_test.rb' + - 'test/remote/gateways/remote_cecabank_test.rb' + - 'test/remote/gateways/remote_cenpos_test.rb' + - 'test/remote/gateways/remote_culqi_test.rb' + - 'test/remote/gateways/remote_litle_certification_test.rb' + - 'test/remote/gateways/remote_opp_test.rb' + - 'test/remote/gateways/remote_pay_junction_v2_test.rb' + - 'test/remote/gateways/remote_tns_test.rb' + - 'test/unit/credit_card_formatting_test.rb' + - 'test/unit/gateways/axcessms_test.rb' + - 'test/unit/gateways/opp_test.rb' + - 'test/unit/gateways/pay_junction_v2_test.rb' + +# Offense count: 446 +# Cop supports --auto-correct. +# Configuration parameters: Strict. +Style/NumericLiterals: + MinDigits: 17 + +# Offense count: 40 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/OrAssignment: + Exclude: + - 'lib/active_merchant/billing/gateways/net_registry.rb' + +# Offense count: 24 +# Cop supports --auto-correct. +Style/ParallelAssignment: + Enabled: false + +# Offense count: 29 +# Cop supports --auto-correct. +# Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. +Style/ParenthesesAroundCondition: + Enabled: false + +# Offense count: 877 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +Style/PerlBackrefs: + Exclude: + - 'lib/active_merchant/billing/gateways/qvalent.rb' + - 'lib/active_merchant/billing/gateways/sage_pay.rb' + - 'lib/support/outbound_hosts.rb' + - 'test/unit/gateways/payu_in_test.rb' + +# Offense count: 94 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: short, verbose +Style/PreferredHashMethods: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/Proc: + Exclude: + - 'test/unit/credit_card_methods_test.rb' + - 'test/unit/gateways/nab_transact_test.rb' + +# Offense count: 33 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: compact, exploded +Style/RaiseArgs: + Enabled: false + +# Offense count: 12 +# Cop supports --auto-correct. +Style/RandomWithOffset: + Exclude: + - 'lib/active_merchant/billing/gateways/borgun.rb' + - 'test/remote/gateways/remote_beanstream_test.rb' + - 'test/remote/gateways/remote_braintree_orange_test.rb' + - 'test/remote/gateways/remote_inspire_test.rb' + - 'test/remote/gateways/remote_merchant_ware_test.rb' + - 'test/remote/gateways/remote_merchant_ware_version_four_test.rb' + - 'test/remote/gateways/remote_pay_junction_test.rb' + - 'test/unit/gateways/beanstream_test.rb' + +# Offense count: 21 +# Cop supports --auto-correct. +Style/RedundantBegin: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +Style/RedundantConditional: + Exclude: + - 'lib/active_merchant/billing/gateways/pin.rb' + - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' + - 'lib/active_merchant/billing/gateways/worldpay_online_payments.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantException: + Exclude: + - 'lib/active_merchant/billing/gateway.rb' + +# Offense count: 27 +# Cop supports --auto-correct. +Style/RedundantParentheses: + Enabled: false + +# Offense count: 87 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Enabled: false + +# Offense count: 173 +# Cop supports --auto-correct. +Style/RedundantSelf: + Enabled: false + +# Offense count: 1178 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed +Style/RegexpLiteral: + Enabled: false + +# Offense count: 15 +# Cop supports --auto-correct. +Style/RescueModifier: + Exclude: + - 'lib/active_merchant/billing/gateways/clearhaus.rb' + - 'lib/active_merchant/billing/gateways/cyber_source.rb' + - 'lib/active_merchant/billing/gateways/jetpay.rb' + - 'lib/active_merchant/billing/gateways/jetpay_v2.rb' + - 'lib/active_merchant/billing/gateways/optimal_payment.rb' + - 'lib/active_merchant/billing/gateways/payflow/payflow_response.rb' + - 'lib/active_merchant/billing/gateways/sage.rb' + - 'lib/active_merchant/billing/gateways/secure_pay.rb' + - 'lib/active_merchant/billing/gateways/telr.rb' + - 'test/remote/gateways/remote_secure_pay_au_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Exclude: + - 'lib/active_merchant/billing/base.rb' + +# Offense count: 33 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist. +# Whitelist: present?, blank?, presence, try, try! +Style/SafeNavigation: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/SelfAssignment: + Exclude: + - 'lib/active_merchant/billing/credit_card.rb' + - 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: AllowAsExpressionSeparator. +Style/Semicolon: + Exclude: + - 'lib/active_merchant/billing/gateways/ezic.rb' + - 'lib/active_merchant/billing/gateways/merchant_one.rb' + - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' + - 'test/remote/gateways/remote_orbital_test.rb' + - 'test/unit/gateways/cardknox_test.rb' + - 'test/unit/gateways/omise_test.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowIfMethodIsEmpty. +Style/SingleLineMethods: + Exclude: + - 'test/unit/gateways/paypal/paypal_common_api_test.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: . +# SupportedStyles: use_perl_names, use_english_names +Style/SpecialGlobalVars: + EnforcedStyle: use_perl_names + +# Offense count: 14578 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Enabled: false + +# Offense count: 31 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiteralsInInterpolation: + Enabled: false + +# Offense count: 307 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinSize. +# SupportedStyles: percent, brackets +Style/SymbolArray: + Enabled: false + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: respond_to, define_method +Style/SymbolProc: + Exclude: + - 'lib/active_merchant/billing/compatibility.rb' + - 'lib/active_merchant/billing/gateways/braintree_blue.rb' + - 'lib/active_merchant/billing/gateways/cenpos.rb' + - 'lib/active_merchant/billing/gateways/checkout_v2.rb' + - 'lib/active_merchant/billing/gateways/creditcall.rb' + - 'lib/active_merchant/billing/gateways/mercury.rb' + - 'lib/active_merchant/billing/gateways/payflow/payflow_response.rb' + - 'lib/active_merchant/billing/gateways/psl_card.rb' + - 'lib/active_merchant/billing/gateways/realex.rb' + +# Offense count: 15 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowSafeAssignment. +# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex +Style/TernaryParentheses: + Exclude: + - 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb' + - 'lib/active_merchant/billing/gateways/blue_snap.rb' + - 'lib/active_merchant/billing/gateways/borgun.rb' + - 'lib/active_merchant/billing/gateways/braintree_blue.rb' + - 'lib/active_merchant/billing/gateways/card_stream.rb' + - 'lib/active_merchant/billing/gateways/litle.rb' + - 'lib/active_merchant/billing/gateways/moneris_us.rb' + - 'lib/active_merchant/billing/gateways/ogone.rb' + - 'lib/active_merchant/billing/gateways/orbital.rb' + - 'lib/active_merchant/billing/gateways/payeezy.rb' + - 'lib/active_merchant/billing/gateways/visanet_peru.rb' + +# Offense count: 27 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArguments: + Enabled: false + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Exclude: + - 'lib/active_merchant/billing/credit_card_methods.rb' + - 'test/remote/gateways/remote_payflow_express_test.rb' + - 'test/unit/gateways/netaxept_test.rb' + - 'test/unit/gateways/usa_epay_transaction_test.rb' + +# Offense count: 155 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Enabled: false + +# Offense count: 36 +# Cop supports --auto-correct. +# Configuration parameters: AllowNamedUnderscoreVariables. +Style/TrailingUnderscoreVariable: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist. +# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym +Style/TrivialAccessors: + Exclude: + - 'test/unit/gateways/opp_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/UnlessElse: + Exclude: + - 'lib/active_merchant/billing/gateways/usa_epay.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +Style/UnneededCondition: + Exclude: + - 'lib/active_merchant/billing/gateways/blue_pay.rb' + - 'lib/active_merchant/billing/gateways/card_connect.rb' + - 'lib/active_merchant/billing/gateways/creditcall.rb' + - 'lib/active_merchant/billing/gateways/micropayment.rb' + - 'lib/active_merchant/billing/gateways/omise.rb' + - 'lib/active_merchant/billing/gateways/pay_gate_xml.rb' + - 'lib/active_merchant/billing/gateways/qvalent.rb' + - 'lib/active_merchant/billing/gateways/verifi.rb' + - 'test/test_helper.rb' + +# Offense count: 26 +# Cop supports --auto-correct. +Style/UnneededInterpolation: + Exclude: + - 'lib/active_merchant/billing/base.rb' + - 'lib/active_merchant/billing/compatibility.rb' + - 'lib/active_merchant/billing/gateways/banwire.rb' + - 'lib/active_merchant/billing/gateways/cardknox.rb' + - 'lib/active_merchant/billing/gateways/conekta.rb' + - 'lib/active_merchant/billing/gateways/digitzs.rb' + - 'lib/active_merchant/billing/gateways/eway_managed.rb' + - 'lib/active_merchant/billing/gateways/first_giving.rb' + - 'lib/active_merchant/billing/gateways/merchant_one.rb' + - 'lib/active_merchant/billing/gateways/openpay.rb' + - 'lib/active_merchant/billing/gateways/pay_junction_v2.rb' + - 'lib/active_merchant/billing/gateways/safe_charge.rb' + - 'lib/active_merchant/billing/gateways/telr.rb' + - 'lib/support/gateway_support.rb' + - 'test/remote/gateways/remote_cyber_source_test.rb' + +# Offense count: 54 +# Cop supports --auto-correct. +Style/UnneededPercentQ: + Exclude: + - 'test/unit/gateways/clearhaus_test.rb' + - 'test/unit/gateways/forte_test.rb' + - 'test/unit/gateways/merchant_warrior_test.rb' + - 'test/unit/gateways/nmi_test.rb' + - 'test/unit/gateways/orbital_test.rb' + - 'test/unit/gateways/payex_test.rb' + - 'test/unit/gateways/paymentez_test.rb' + - 'test/unit/gateways/world_net_test.rb' + +# Offense count: 117 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinSize, WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + Enabled: false + +# Offense count: 33 +# Cop supports --auto-correct. +Style/ZeroLengthPredicate: + Enabled: false + +# Offense count: 9192 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 2484 diff --git a/Gemfile b/Gemfile index 81f68d6a75e..2c314a40873 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source 'https://rubygems.org' gemspec gem 'jruby-openssl', :platforms => :jruby +gem 'rubocop', '~> 0.57.2' group :test, :remote_test do # gateway-specific dependencies, keeping these gems out of the gemspec diff --git a/Rakefile b/Rakefile index dea40508ff7..441b85a4447 100644 --- a/Rakefile +++ b/Rakefile @@ -11,6 +11,7 @@ end require 'rake' require 'rake/testtask' +require 'rubocop/rake_task' require 'support/gateway_support' require 'support/ssl_verify' require 'support/ssl_version' @@ -23,9 +24,11 @@ task :tag_release do end desc "Run the unit test suite" -task :default => 'test:units' +task :default => 'test:local' task :test => 'test:units' +RuboCop::RakeTask.new + namespace :test do Rake::TestTask.new(:units) do |t| t.pattern = 'test/unit/**/*_test.rb' @@ -33,6 +36,9 @@ namespace :test do t.verbose = true end + desc 'Run all tests that do not require network access' + task :local => ['test:units', 'rubocop'] + Rake::TestTask.new(:remote) do |t| t.pattern = 'test/remote/**/*_test.rb' t.libs << 'test' diff --git a/lib/active_merchant/billing/credit_card_formatting.rb b/lib/active_merchant/billing/credit_card_formatting.rb index 63ce2a93b2e..b0725506cd2 100644 --- a/lib/active_merchant/billing/credit_card_formatting.rb +++ b/lib/active_merchant/billing/credit_card_formatting.rb @@ -14,8 +14,8 @@ def format(number, option) return '' if number.blank? case option - when :two_digits ; sprintf("%.2i", number.to_i)[-2..-1] - when :four_digits ; sprintf("%.4i", number.to_i)[-4..-1] + when :two_digits then sprintf("%.2i", number.to_i)[-2..-1] + when :four_digits then sprintf("%.4i", number.to_i)[-4..-1] else number end end diff --git a/lib/active_merchant/billing/gateways/cashnet.rb b/lib/active_merchant/billing/gateways/cashnet.rb index 463d83e66cc..a883bf34b30 100644 --- a/lib/active_merchant/billing/gateways/cashnet.rb +++ b/lib/active_merchant/billing/gateways/cashnet.rb @@ -142,7 +142,7 @@ def parse(body) def handle_response(response) if (200...300).include?(response.code.to_i) return response.body - elsif 302 == response.code.to_i + elsif response.code.to_i == 302 return ssl_get(URI.parse(response['location'])) end raise ResponseError.new(response) diff --git a/lib/active_merchant/billing/gateways/cecabank.rb b/lib/active_merchant/billing/gateways/cecabank.rb index 3eb62be1526..48982bd230c 100644 --- a/lib/active_merchant/billing/gateways/cecabank.rb +++ b/lib/active_merchant/billing/gateways/cecabank.rb @@ -142,7 +142,7 @@ def parse(body) response[:error_code] = root.elements['ERROR/codigo'].text response[:error_message] = root.elements['ERROR/descripcion'].text else - if("000" == root.elements['OPERACION'].attributes['numeroOperacion']) + if root.elements['OPERACION'].attributes['numeroOperacion'] == "000" if(root.elements['OPERACION/numeroAutorizacion']) response[:authorization] = root.elements['OPERACION/numeroAutorizacion'].text end diff --git a/lib/active_merchant/billing/gateways/culqi.rb b/lib/active_merchant/billing/gateways/culqi.rb index 1b3f0e8f3a2..964df74d8cf 100644 --- a/lib/active_merchant/billing/gateways/culqi.rb +++ b/lib/active_merchant/billing/gateways/culqi.rb @@ -181,11 +181,11 @@ def add_customer_data(post, options) def add_checksum(action, post) checksum_elements = case action - when :capture; [post[:toid], post[:trackingid], post[:captureamount], @options[:secret_key]] - when :void; [post[:toid], post[:description], post[:trackingid], @options[:secret_key]] - when :refund; [post[:toid], post[:trackingid], post[:refundamount], @options[:secret_key]] - when :tokenize; [post[:partnerid], post[:cardnumber], post[:cvv], @options[:secret_key]] - when :invalidate; [post[:partnerid], post[:token], @options[:secret_key]] + when :capture then [post[:toid], post[:trackingid], post[:captureamount], @options[:secret_key]] + when :void then [post[:toid], post[:description], post[:trackingid], @options[:secret_key]] + when :refund then [post[:toid], post[:trackingid], post[:refundamount], @options[:secret_key]] + when :tokenize then [post[:partnerid], post[:cardnumber], post[:cvv], @options[:secret_key]] + when :invalidate then [post[:partnerid], post[:token], @options[:secret_key]] else [post[:toid], post[:totype], post[:amount], post[:description], post[:redirecturl], post[:cardnumber] || post[:token], @options[:secret_key]] end diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index c022cfcec74..8b9f7dcdedd 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -170,7 +170,7 @@ def test_verification_merchant_account_id_exists_when_verify_card_and_merchant_a result = Braintree::SuccessfulResult.new(:customer => customer) Braintree::CustomerGateway.any_instance.expects(:create).with do |params| - 'merchant_account_id' == params[:credit_card][:options][:verification_merchant_account_id] + params[:credit_card][:options][:verification_merchant_account_id] == 'merchant_account_id' end.returns(result) gateway.store(credit_card('41111111111111111111'), :verify_card => true) @@ -193,7 +193,7 @@ def test_merchant_account_id_can_be_set_by_options customer.stubs(:id).returns('123') result = Braintree::SuccessfulResult.new(:customer => customer) Braintree::CustomerGateway.any_instance.expects(:create).with do |params| - 'value_from_options' == params[:credit_card][:options][:verification_merchant_account_id] + 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') diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index a310accd5b5..b62f017a61e 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -432,7 +432,7 @@ def test_successful_purchase_with_apple_pay_token_exchange def test_amount_localization @gateway.expects(:ssl_request).returns(successful_purchase_response(true)) @gateway.expects(:post_data).with do |params| - '4' == params[:amount] + params[:amount] == '4' end @options[:currency] = 'JPY' From 9cef76ab43086614770dabcd4a08e4b11dd2bf25 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 26 Jun 2018 10:24:48 -0400 Subject: [PATCH 448/677] Rubocop: patch all Gemfiles --- Gemfile.rails42 | 1 + Gemfile.rails50 | 1 + Gemfile.rails51 | 1 + Gemfile.rails52 | 1 + 4 files changed, 4 insertions(+) diff --git a/Gemfile.rails42 b/Gemfile.rails42 index fc4470341d5..98b0dd0c7a4 100644 --- a/Gemfile.rails42 +++ b/Gemfile.rails42 @@ -2,6 +2,7 @@ source 'https://rubygems.org' gemspec gem 'jruby-openssl', :platforms => :jruby +gem 'rubocop', '~> 0.57.2' group :test, :remote_test do # gateway-specific dependencies, keeping these gems out of the gemspec diff --git a/Gemfile.rails50 b/Gemfile.rails50 index 39f1278ff9f..cfe7103ac08 100644 --- a/Gemfile.rails50 +++ b/Gemfile.rails50 @@ -2,6 +2,7 @@ source 'https://rubygems.org' gemspec gem 'jruby-openssl', :platforms => :jruby +gem 'rubocop', '~> 0.57.2' group :test, :remote_test do # gateway-specific dependencies, keeping these gems out of the gemspec diff --git a/Gemfile.rails51 b/Gemfile.rails51 index 100dfb1ff95..4bbed6e8884 100644 --- a/Gemfile.rails51 +++ b/Gemfile.rails51 @@ -2,6 +2,7 @@ source 'https://rubygems.org' gemspec gem 'jruby-openssl', :platforms => :jruby +gem 'rubocop', '~> 0.57.2' group :test, :remote_test do # gateway-specific dependencies, keeping these gems out of the gemspec diff --git a/Gemfile.rails52 b/Gemfile.rails52 index aa056d4cad8..e76569231cf 100644 --- a/Gemfile.rails52 +++ b/Gemfile.rails52 @@ -2,6 +2,7 @@ source 'https://rubygems.org' gemspec gem 'jruby-openssl', :platforms => :jruby +gem 'rubocop', '~> 0.57.2' group :test, :remote_test do # gateway-specific dependencies, keeping these gems out of the gemspec From cda5d1fc95ec1917ff17ad73f95b3855ba81d8eb Mon Sep 17 00:00:00 2001 From: Jonathan Girard Viau <am00620@ens.etsmtl.ca> Date: Tue, 26 Jun 2018 10:26:34 -0400 Subject: [PATCH 449/677] Update Psigate endpoint url (#2899) --- .../billing/gateways/psigate.rb | 4 +- lib/certs/cacert.pem | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/lib/active_merchant/billing/gateways/psigate.rb b/lib/active_merchant/billing/gateways/psigate.rb index 4ec3039f78a..39737289639 100644 --- a/lib/active_merchant/billing/gateways/psigate.rb +++ b/lib/active_merchant/billing/gateways/psigate.rb @@ -35,8 +35,8 @@ module Billing #:nodoc: # :email => 'jack@yahoo.com' # ) class PsigateGateway < Gateway - self.test_url = 'https://staging.psigate.com:17989/Messenger/XMLMessenger' - self.live_url = 'https://secure.psigate.com:17934/Messenger/XMLMessenger' + self.test_url = 'https://realtimestaging.psigate.com/xml' + self.live_url = 'https://realtime.psigate.com/xml' self.supported_cardtypes = [:visa, :master, :american_express] self.supported_countries = ['CA'] diff --git a/lib/certs/cacert.pem b/lib/certs/cacert.pem index e353e84e1c0..72bbb947fe5 100644 --- a/lib/certs/cacert.pem +++ b/lib/certs/cacert.pem @@ -3949,3 +3949,40 @@ TZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pcmaHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a9 61qn8FYiqTxlVMYVqL2Gns2Dlmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G 3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed -----END CERTIFICATE----- + +COMODO RSA Certification Authority +================================== +-----BEGIN CERTIFICATE----- +MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCB +hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G +A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV +BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMTE5 +MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgT +EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR +Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR +6FSS0gpWsawNJN3Fz0RndJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8X +pz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZFGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC +9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+5eNu/Nio5JIk2kNrYrhV +/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pGx8cgoLEf +Zd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z ++pUX2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7w +qP/0uK3pN/u6uPQLOvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZah +SL0896+1DSJMwBGB7FY79tOi4lu3sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVIC +u9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+CGCe01a60y1Dma/RMhnEw6abf +Fobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5WdYgGq/yapiq +crxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E +FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB +/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvl +wFTPoCWOAvn9sKIN9SCYPBMtrFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM +4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+nq6PK7o9mfjYcwlYRm6mnPTXJ9OV +2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSgtZx8jb8uk2Intzna +FxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwWsRqZ +CuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiK +boHGhfKppC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmcke +jkk9u+UJueBPSZI9FoJAzMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yL +S0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHqZJx64SIDqZxubw5lT2yHh17zbqD5daWb +QOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk527RH89elWsn2/x20Kk4yl +0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7ILaZRfyHB +NVOFBkpdn627G190 +-----END CERTIFICATE----- From 0db9eaeb15ba145103463a8f2add810e0547d98c Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 26 Jun 2018 10:35:50 -0400 Subject: [PATCH 450/677] Rubocop: ignore vendor This isn't necessary locally, but breaks Travis --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index 27475582a79..80efd64708b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -13,5 +13,6 @@ AllCops: - "generators/**/*" - "lib/active_merchant/billing/gateways/paypal/**/*" - "lib/active_merchant/billing/gateways/paypal_express.rb" + - "vendor/**/*" ExtraDetails: false TargetRubyVersion: 2.3 From ed030727d5daf7c68325684b75797993b3d57d30 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 26 Jun 2018 11:19:53 -0400 Subject: [PATCH 451/677] Clean up various RuboCop violations The following style rules are no longer exempted: - Layout/AccessModifierIndentation - Layout/AlignArray - Layout/BlockAlignment - Style/TrivialAccessors - Style/UnlessElse - Style/UnneededConditional These all had only a few violations each, so I've folded them all into a single commit. I also regenerated .rubocop_todo.yml to reflect the new error counts, since some of these fixes had meaningfully positive impacts on other violations. Unit: 3874 tests, 67956 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- .rubocop_todo.yml | 73 +- .../billing/gateways/blue_pay.rb | 4 +- .../billing/gateways/card_connect.rb | 2 +- .../billing/gateways/creditcall.rb | 2 +- .../billing/gateways/elavon.rb | 6 +- .../billing/gateways/garanti.rb | 4 +- .../billing/gateways/micropayment.rb | 2 +- lib/active_merchant/billing/gateways/omise.rb | 2 +- lib/active_merchant/billing/gateways/opp.rb | 2 +- .../billing/gateways/pay_gate_xml.rb | 2 +- .../billing/gateways/payflow_express.rb | 2 +- .../billing/gateways/paymill.rb | 6 +- .../billing/gateways/plugnpay.rb | 4 +- .../billing/gateways/qvalent.rb | 2 +- .../billing/gateways/usa_epay.rb | 6 +- .../billing/gateways/usa_epay_transaction.rb | 2 +- .../billing/gateways/verifi.rb | 6 +- .../billing/gateways/viaklix.rb | 6 +- .../billing/gateways/wirecard.rb | 12 +- test/test_helper.rb | 2 +- test/unit/gateways/allied_wallet_test.rb | 700 +++++++++--------- test/unit/gateways/authorize_net_test.rb | 8 +- test/unit/gateways/opp_test.rb | 18 +- test/unit/gateways/trexle_test.rb | 6 +- .../gateways/usa_epay_transaction_test.rb | 2 +- 25 files changed, 407 insertions(+), 474 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9001653df45..32915191306 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-06-26 10:12:34 -0400 using RuboCop version 0.57.2. +# on 2018-06-26 11:27:33 -0400 using RuboCop version 0.57.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -14,24 +14,6 @@ Gemspec/OrderedDependencies: Exclude: - 'activemerchant.gemspec' -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: outdent, indent -Layout/AccessModifierIndentation: - Exclude: - - 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb' - - 'test/unit/gateways/allied_wallet_test.rb' - - 'test/unit/gateways/usa_epay_transaction_test.rb' - -# Offense count: 5 -# Cop supports --auto-correct. -Layout/AlignArray: - Exclude: - - 'lib/active_merchant/billing/gateways/plugnpay.rb' - - 'lib/active_merchant/billing/gateways/verifi.rb' - - 'test/unit/gateways/trexle_test.rb' - # Offense count: 139 # Cop supports --auto-correct. # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. @@ -48,21 +30,6 @@ Layout/AlignHash: Layout/AlignParameters: Enabled: false -# Offense count: 12 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleAlignWith. -# SupportedStylesAlignWith: either, start_of_block, start_of_line -Layout/BlockAlignment: - Exclude: - - 'lib/active_merchant/billing/gateways/elavon.rb' - - 'lib/active_merchant/billing/gateways/garanti.rb' - - 'lib/active_merchant/billing/gateways/opp.rb' - - 'lib/active_merchant/billing/gateways/payflow_express.rb' - - 'lib/active_merchant/billing/gateways/paymill.rb' - - 'lib/active_merchant/billing/gateways/viaklix.rb' - - 'lib/active_merchant/billing/gateways/wirecard.rb' - - 'test/unit/gateways/authorize_net_test.rb' - # Offense count: 113 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. @@ -281,14 +248,14 @@ Layout/IndentHash: Layout/IndentHeredoc: Enabled: false -# Offense count: 135 +# Offense count: 97 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: normal, rails Layout/IndentationConsistency: Enabled: false -# Offense count: 244 +# Offense count: 197 # Cop supports --auto-correct. # Configuration parameters: Width, IgnoredPatterns. Layout/IndentationWidth: @@ -459,7 +426,7 @@ Layout/SpaceBeforeFirstArg: - 'test/unit/gateways/quickpay_v10_test.rb' - 'test/unit/gateways/quickpay_v4to7_test.rb' -# Offense count: 122 +# Offense count: 118 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. # SupportedStyles: space, no_space, compact @@ -1627,7 +1594,7 @@ Style/SingleLineMethods: Style/SpecialGlobalVars: EnforcedStyle: use_perl_names -# Offense count: 14578 +# Offense count: 14577 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -1713,34 +1680,6 @@ Style/TrailingCommaInHashLiteral: Style/TrailingUnderscoreVariable: Enabled: false -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist. -# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym -Style/TrivialAccessors: - Exclude: - - 'test/unit/gateways/opp_test.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Style/UnlessElse: - Exclude: - - 'lib/active_merchant/billing/gateways/usa_epay.rb' - -# Offense count: 10 -# Cop supports --auto-correct. -Style/UnneededCondition: - Exclude: - - 'lib/active_merchant/billing/gateways/blue_pay.rb' - - 'lib/active_merchant/billing/gateways/card_connect.rb' - - 'lib/active_merchant/billing/gateways/creditcall.rb' - - 'lib/active_merchant/billing/gateways/micropayment.rb' - - 'lib/active_merchant/billing/gateways/omise.rb' - - 'lib/active_merchant/billing/gateways/pay_gate_xml.rb' - - 'lib/active_merchant/billing/gateways/qvalent.rb' - - 'lib/active_merchant/billing/gateways/verifi.rb' - - 'test/test_helper.rb' - # Offense count: 26 # Cop supports --auto-correct. Style/UnneededInterpolation: @@ -1786,7 +1725,7 @@ Style/WordArray: Style/ZeroLengthPredicate: Enabled: false -# Offense count: 9192 +# Offense count: 9190 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: diff --git a/lib/active_merchant/billing/gateways/blue_pay.rb b/lib/active_merchant/billing/gateways/blue_pay.rb index 25966133876..17f29dfe067 100644 --- a/lib/active_merchant/billing/gateways/blue_pay.rb +++ b/lib/active_merchant/billing/gateways/blue_pay.rb @@ -163,7 +163,7 @@ def refund(money, identification, options = {}) post[:PAYMENT_ACCOUNT] = '' post[:MASTER_ID] = identification post[:TRANS_TYPE] = 'REFUND' - post[:NAME1] = (options[:first_name] ? options[:first_name] : "") + post[:NAME1] = options[:first_name] || "" post[:NAME2] = options[:last_name] if options[:last_name] post[:ZIP] = options[:zip] if options[:zip] add_invoice(post, options) @@ -183,7 +183,7 @@ def credit(money, payment_object, options = {}) add_payment_method(post, payment_object) post[:TRANS_TYPE] = 'CREDIT' - post[:NAME1] = (options[:first_name] ? options[:first_name] : "") + post[:NAME1] = options[:first_name] || "" post[:NAME2] = options[:last_name] if options[:last_name] post[:ZIP] = options[:zip] if options[:zip] add_invoice(post, options) diff --git a/lib/active_merchant/billing/gateways/card_connect.rb b/lib/active_merchant/billing/gateways/card_connect.rb index 1363f97d250..40444cade8c 100644 --- a/lib/active_merchant/billing/gateways/card_connect.rb +++ b/lib/active_merchant/billing/gateways/card_connect.rb @@ -262,7 +262,7 @@ def url(action, path) if test? test_url + action + path else - (@options[:domain] ? @options[:domain] : live_url) + action + path + (@options[:domain] || live_url) + action + path end end diff --git a/lib/active_merchant/billing/gateways/creditcall.rb b/lib/active_merchant/billing/gateways/creditcall.rb index c961f999d85..fbedf5855b1 100644 --- a/lib/active_merchant/billing/gateways/creditcall.rb +++ b/lib/active_merchant/billing/gateways/creditcall.rb @@ -265,7 +265,7 @@ def authorization_from(response) end def manual_type(options) - options[:manual_type] ? options[:manual_type] : "ecommerce" + options[:manual_type] || "ecommerce" end end end diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb index ddf36f296d2..5ac0eaacabf 100644 --- a/lib/active_merchant/billing/gateways/elavon.rb +++ b/lib/active_merchant/billing/gateways/elavon.rb @@ -302,9 +302,9 @@ def preamble def parse(msg) resp = {} msg.split(self.delimiter).collect{|li| - key, value = li.split("=") - resp[key.to_s.strip.gsub(/^ssl_/, '')] = value.to_s.strip - } + key, value = li.split("=") + resp[key.to_s.strip.gsub(/^ssl_/, '')] = value.to_s.strip + } resp end diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb index 31f9f55ee48..c4b2c802b19 100644 --- a/lib/active_merchant/billing/gateways/garanti.rb +++ b/lib/active_merchant/billing/gateways/garanti.rb @@ -103,7 +103,7 @@ def build_sale_request(money, credit_card, options) end def build_authorize_request(money, credit_card, options) - build_xml_request(money, credit_card, options) do |xml| + build_xml_request(money, credit_card, options) do |xml| add_customer_data(xml, options) add_order_data(xml, options) do add_addresses(xml, options) @@ -117,7 +117,7 @@ def build_authorize_request(money, credit_card, options) def build_capture_request(money, ref_id, options) options = options.merge(:order_id => ref_id) - build_xml_request(money, ref_id, options) do |xml| + build_xml_request(money, ref_id, options) do |xml| add_customer_data(xml, options) add_order_data(xml, options) add_transaction_data(xml, money, options) diff --git a/lib/active_merchant/billing/gateways/micropayment.rb b/lib/active_merchant/billing/gateways/micropayment.rb index b1f7f07d36f..226bb9c469b 100644 --- a/lib/active_merchant/billing/gateways/micropayment.rb +++ b/lib/active_merchant/billing/gateways/micropayment.rb @@ -177,7 +177,7 @@ def split_authorization(authorization) end def authorization_from(response, request_params) - session_id = response["sessionId"] ? response["sessionId"] : request_params[:sessionId] + session_id = response["sessionId"] || request_params[:sessionId] "#{session_id}|#{response["transactionId"]}" end end diff --git a/lib/active_merchant/billing/gateways/omise.rb b/lib/active_merchant/billing/gateways/omise.rb index a3c21bf2c10..31acde05a16 100644 --- a/lib/active_merchant/billing/gateways/omise.rb +++ b/lib/active_merchant/billing/gateways/omise.rb @@ -263,7 +263,7 @@ def message_from(response) if successful?(response) 'Success' else - (response['message'] ? response['message'] : response['failure_message']) + response['message'] || response['failure_message'] end end diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb index 2640ad7f925..60ef5774116 100644 --- a/lib/active_merchant/billing/gateways/opp.rb +++ b/lib/active_merchant/billing/gateways/opp.rb @@ -365,7 +365,7 @@ def flatten_hash(hash) else h[k] = v end - end + end end end end diff --git a/lib/active_merchant/billing/gateways/pay_gate_xml.rb b/lib/active_merchant/billing/gateways/pay_gate_xml.rb index 86947816811..86b2d5d8f30 100644 --- a/lib/active_merchant/billing/gateways/pay_gate_xml.rb +++ b/lib/active_merchant/billing/gateways/pay_gate_xml.rb @@ -265,7 +265,7 @@ def commit(action, request, authorization = nil) response = parse(action, ssl_post(self.live_url, request)) Response.new(successful?(response), message_from(response), response, :test => test?, - :authorization => authorization ? authorization : response[:tid] + :authorization => authorization || response[:tid] ) end diff --git a/lib/active_merchant/billing/gateways/payflow_express.rb b/lib/active_merchant/billing/gateways/payflow_express.rb index 1f8b10ea182..25f31b19787 100644 --- a/lib/active_merchant/billing/gateways/payflow_express.rb +++ b/lib/active_merchant/billing/gateways/payflow_express.rb @@ -192,7 +192,7 @@ def add_pay_data(xml, money, options) end def add_paypal_details(xml, options) - xml.tag! 'PayPal' do + xml.tag! 'PayPal' do xml.tag! 'EMail', options[:email] unless options[:email].blank? xml.tag! 'ReturnURL', options[:return_url] unless options[:return_url].blank? xml.tag! 'CancelURL', options[:cancel_return_url] unless options[:cancel_return_url].blank? diff --git a/lib/active_merchant/billing/gateways/paymill.rb b/lib/active_merchant/billing/gateways/paymill.rb index 63bb466bb71..58a39f24572 100644 --- a/lib/active_merchant/billing/gateways/paymill.rb +++ b/lib/active_merchant/billing/gateways/paymill.rb @@ -132,9 +132,9 @@ def action_with_token(action, money, payment_method, options) self.send("#{action}_with_token", money, payment_method, options) else MultiResponse.run do |r| - r.process { save_card(payment_method, options) } - r.process { self.send("#{action}_with_token", money, r.authorization, options) } - end + r.process { save_card(payment_method, options) } + r.process { self.send("#{action}_with_token", money, r.authorization, options) } + end end end diff --git a/lib/active_merchant/billing/gateways/plugnpay.rb b/lib/active_merchant/billing/gateways/plugnpay.rb index bb48c0f228e..e7820d5b382 100644 --- a/lib/active_merchant/billing/gateways/plugnpay.rb +++ b/lib/active_merchant/billing/gateways/plugnpay.rb @@ -3,8 +3,8 @@ module Billing class PlugnpayGateway < Gateway class PlugnpayPostData < PostData # Fields that will be sent even if they are blank - self.required_fields = [ :publisher_name, :publisher_password, - :card_amount, :card_name, :card_number, :card_exp, :orderID ] + self.required_fields = [:publisher_name, :publisher_password, + :card_amount, :card_name, :card_number, :card_exp, :orderID] end self.live_url = self.test_url = 'https://pay1.plugnpay.com/payment/pnpremote.cgi' diff --git a/lib/active_merchant/billing/gateways/qvalent.rb b/lib/active_merchant/billing/gateways/qvalent.rb index 43e3ec9c09f..e78523c2fe5 100644 --- a/lib/active_merchant/billing/gateways/qvalent.rb +++ b/lib/active_merchant/billing/gateways/qvalent.rb @@ -120,7 +120,7 @@ def add_soft_descriptors(post, options) def add_invoice(post, money, options) post["order.amount"] = amount(money) post["card.currency"] = CURRENCY_CODES[options[:currency] || currency(money)] - post["order.ECI"] = options[:eci] ? options[:eci] : "SSL" + post["order.ECI"] = options[:eci] || "SSL" end def add_payment_method(post, payment_method) diff --git a/lib/active_merchant/billing/gateways/usa_epay.rb b/lib/active_merchant/billing/gateways/usa_epay.rb index 2ca57cdd0cf..b43e355f61c 100644 --- a/lib/active_merchant/billing/gateways/usa_epay.rb +++ b/lib/active_merchant/billing/gateways/usa_epay.rb @@ -14,10 +14,10 @@ class UsaEpayGateway < Gateway # create an instance of UsaEpayAdvancedGateway. # def self.new(options={}) - unless options.has_key?(:software_id) || options.has_key?(:live_url) - UsaEpayTransactionGateway.new(options) - else + if options.has_key?(:software_id) || options.has_key?(:live_url) UsaEpayAdvancedGateway.new(options) + else + UsaEpayTransactionGateway.new(options) end end end diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb index 5fa792f6ce5..c36e54f43fa 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb @@ -120,7 +120,7 @@ def scrub(transcript) gsub(%r((&?UMkey=)[^&]*)i, '\1[FILTERED]') end - private + private def add_amount(post, money) post[:amount] = amount(money) diff --git a/lib/active_merchant/billing/gateways/verifi.rb b/lib/active_merchant/billing/gateways/verifi.rb index 26e7d414905..2459edf5eb3 100644 --- a/lib/active_merchant/billing/gateways/verifi.rb +++ b/lib/active_merchant/billing/gateways/verifi.rb @@ -5,8 +5,8 @@ module Billing #:nodoc: class VerifiGateway < Gateway class VerifiPostData < PostData # Fields that will be sent even if they are blank - self.required_fields = [ :amount, :type, :ccnumber, :ccexp, :firstname, :lastname, - :company, :address1, :address2, :city, :state, :zip, :country, :phone ] + self.required_fields = [:amount, :type, :ccnumber, :ccexp, :firstname, :lastname, + :company, :address1, :address2, :city, :state, :zip, :country, :phone] end self.live_url = self.test_url = 'https://secure.verifi.com/gw/api/transact.php' @@ -203,7 +203,7 @@ def commit(trx_type, money, post) end def message_from(response) - response[:response_code_message] ? response[:response_code_message] : "" + response[:response_code_message] || "" end def parse(body) diff --git a/lib/active_merchant/billing/gateways/viaklix.rb b/lib/active_merchant/billing/gateways/viaklix.rb index 3229e05406d..3c9a1c18118 100644 --- a/lib/active_merchant/billing/gateways/viaklix.rb +++ b/lib/active_merchant/billing/gateways/viaklix.rb @@ -165,9 +165,9 @@ def post_data(parameters) def parse(msg) resp = {} msg.split(self.delimiter).collect{|li| - key, value = li.split("=") - resp[key.strip.gsub(/^ssl_/, '')] = value.to_s.strip - } + key, value = li.split("=") + resp[key.strip.gsub(/^ssl_/, '')] = value.to_s.strip + } resp end end diff --git a/lib/active_merchant/billing/gateways/wirecard.rb b/lib/active_merchant/billing/gateways/wirecard.rb index 46a94f942d3..4093149f03f 100644 --- a/lib/active_merchant/billing/gateways/wirecard.rb +++ b/lib/active_merchant/billing/gateways/wirecard.rb @@ -200,12 +200,12 @@ def build_request(action, money, options) xml.instruct! xml.tag! 'WIRECARD_BXML' do xml.tag! 'W_REQUEST' do - xml.tag! 'W_JOB' do - xml.tag! 'JobID', '' - # UserID for this transaction - xml.tag! 'BusinessCaseSignature', options[:signature] || options[:login] - # Create the whole rest of the message - add_transaction_data(xml, money, options) + xml.tag! 'W_JOB' do + xml.tag! 'JobID', '' + # UserID for this transaction + xml.tag! 'BusinessCaseSignature', options[:signature] || options[:login] + # Create the whole rest of the message + add_transaction_data(xml, money, options) end end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 929e5d8df59..4dec213f209 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -103,7 +103,7 @@ def assert_not_valid(model) end def assert_deprecation_warning(message=nil) - ActiveMerchant.expects(:deprecated).with(message ? message : anything) + ActiveMerchant.expects(:deprecated).with(message || anything) yield end diff --git a/test/unit/gateways/allied_wallet_test.rb b/test/unit/gateways/allied_wallet_test.rb index ec45ec0f918..687322093ca 100644 --- a/test/unit/gateways/allied_wallet_test.rb +++ b/test/unit/gateways/allied_wallet_test.rb @@ -3,354 +3,354 @@ class AlliedWalletTest < Test::Unit::TestCase include CommStub - def setup - @gateway = AlliedWalletGateway.new( - site_id: "1234", - merchant_id: "1234", - token: "token" - ) - - @credit_card = credit_card - @amount = 100 - end - - def test_successful_purchase - response = stub_comms do - @gateway.purchase(@amount, @credit_card) - end.respond_with(successful_purchase_response) - - assert_success response - - assert_equal "123456", response.authorization - assert response.test? - end - - def test_failed_purchase - response = stub_comms do - @gateway.purchase(@amount, @credit_card) - end.respond_with(failed_purchase_response) - - assert_failure response - assert_equal "Declined", response.message - assert response.test? - end - - def test_successful_authorize_and_capture - response = stub_comms do - @gateway.authorize(@amount, @credit_card) - end.respond_with(successful_authorize_response) - - assert_success response - assert_equal "123456", response.authorization - - capture = stub_comms do - @gateway.capture(@amount, response.authorization) - end.respond_with(successful_capture_response) - - assert_success capture - end - - def test_failed_authorize - response = stub_comms do - @gateway.authorize(@amount, @credit_card) - end.respond_with(failed_authorize_response) - - assert_failure response - assert_equal "Declined", response.message - assert response.test? - end - - def test_failed_capture - response = stub_comms do - @gateway.capture(100, "") - end.respond_with(failed_capture_response) - - assert_failure response - end - - def test_successful_void - response = stub_comms do - @gateway.purchase(@amount, @credit_card) - end.respond_with(successful_authorize_response) - - assert_success response - assert_equal "123456", response.authorization - - void = stub_comms do - @gateway.void(response.authorization) - end.check_request do |endpoint, data, headers| - assert_match(/123456/, data) - end.respond_with(successful_void_response) - - assert_success void - end - - def test_failed_void - response = stub_comms do - @gateway.void("5d53a33d960c46d00f5dc061947d998c") - end.check_request do |endpoint, data, headers| - assert_match(/5d53a33d960c46d00f5dc061947d998c/, data) - end.respond_with(failed_void_response) - - assert_failure response - end - - def test_successful_refund - response = stub_comms do - @gateway.purchase(@amount, @credit_card) - end.respond_with(successful_purchase_response) - - assert_success response - assert_equal "123456", response.authorization - - refund = stub_comms do - @gateway.refund(@amount, response.authorization) - end.check_request do |endpoint, data, headers| - assert_match(/123456/, data) - end.respond_with(successful_refund_response) - - assert_success refund - end - - def test_failed_refund - response = stub_comms do - @gateway.refund(nil, "") - end.respond_with(failed_refund_response) - - assert_failure response - end - - def test_successful_verify - response = stub_comms do - @gateway.verify(@credit_card) - end.respond_with(successful_authorize_response, failed_void_response) - assert_success response - assert_equal "Succeeded", response.message - end - - def test_failed_verify - response = stub_comms do - @gateway.verify(@credit_card) - end.respond_with(failed_authorize_response, successful_void_response) - assert_failure response - assert_equal "Declined", response.message - end - - def test_empty_response_fails - response = stub_comms do - @gateway.purchase(@amount, @credit_card) - end.respond_with(empty_purchase_response) - - assert_failure response - assert_equal "Error", response.message - end - - def test_invalid_json - response = stub_comms do - @gateway.purchase(@amount, @credit_card) - end.respond_with(invalid_json_response) - - assert_failure response - assert_match %r{Unparsable response}, response.message - end - - def test_transcript_scrubbing - assert_equal scrubbed_transcript, @gateway.scrub(transcript) - end - - def test_nil_cvv_transcript_scrubbing - assert_equal nil_cvv_scrubbed_transcript, @gateway.scrub(nil_cvv_transcript) - end - - def test_empty_string_cvv_transcript_scrubbing - assert_equal empty_string_cvv_scrubbed_transcript, @gateway.scrub(empty_string_cvv_transcript) - end - - private - - def successful_purchase_response - %( - { - "id": "123456", - "message": "Success", - "state": "Sale", - "status": "Successful" - } - ) - end - - def failed_purchase_response - %( - { - "id": "123456", - "message": "Declined", - "state": "Sale", - "status": "Declined" - } - ) - end - - def successful_authorize_response - %( - { - "id": "123456", - "message": "Success", - "state": "Authorize", - "status": "Successful" - } - ) - end - - def failed_authorize_response - %( - { - "id": "123456", - "message": "Declined", - "state": "Authorize", - "status": "Declined" - } - ) - end - - def successful_capture_response - %( - { - "id": "123456", - "message": "Successful", - "state": "Capture", - "status": "Successful" - } - ) - end - - def failed_capture_response - %( - { - "id": "123456", - "message": "Declined", - "state": "Capture", - "status": "Declined" - } - ) - end - - def successful_void_response - %( - { - "id": "123456", - "message": "Success", - "state": "Void", - "status": "Successful" - } - ) - end - - def failed_void_response - %( - { - "id": "123456", - "message": "Error", - "state": "Void", - "status": "Error" - } - ) - end - - def successful_refund_response - %( - { - "id": "123456", - "message": "Success", - "state": "Refund", - "status": "Successful" - } - ) - end - - def failed_refund_response - %( - { - "id": "123456", - "message": "Error", - "state": "Refund", - "status": "Error" - } - ) - end - - - def empty_purchase_response - %( - { - "id": "123456", - "message": "Error", - "state": "Purchase", - "status": "Error" - } - ) - end - - def invalid_json_response - %( - { - "id": "123456", - ) - end - - - def transcript - %( - <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer AAEAAHwXaLTYs2APKJW_4TpTDwCw_h9oDx9rA58FR78AFuYCX82Izes1nz9qGBXELGUN_EukKcP5T78Th5guDz4Rw5dQ4Gf0suKw7pz9vWrqa1NpZhrD9Lj9T-SFtOJgfodiwVaBBeSgbJLKA7MOzC9q2dv91HBNP69DygL1oX2L2mtt8fWlKSWhQmtG040E1I43jTueX3L3L9YA7iO6pIwO7CGybE5LnjkQ65KB2K4oYKfXRZosF77hgMJIh-KprFy9cYY3EjfupHeLon9im1BGafrda2N5wj_A_LvdMzfLAD1l1dgj82KlvM_gAzNJ4S19gAicRo9zIbsq36Apt-8jFjS0AQAAAAEAAA9Zr_lVLKMmmtKSo6T_9ulzMCRbYs798EpFD2wMlkb1NCQtA65VrNcM20Ka2FjNQfwOcSMWqDl9zFQhPyFl-npsG1Ww2oyyavA6HSe1HLRLtE_1hNBAlTBPQnLJ6hBf8eR_NTiVa-aQdV2l92-eSwCS59CzrOYGGCY1pLdNMDr_r66kg9l-l94154kRoMBRQSCqZV9iM9M-f3adLJqG6Q79zz1oJpGrH-Zv1kuv8eLaJJNOEFYARb0JbnAC5G1l9-aqxGvBrNkd4sAJIe23XrRx2XJCBIABxuGSQ1xJBTINVlXBXq1mvvd8B1uiYiDNia3c_vIGuSGIjZE0VbUN3oJppfCt1joGdePeUaC2Pyb2vuUN00EBEOaD9RF8IBWMLVJaF9cW2OewDOfBQg94MuOKLdXB_IisRx1ed25VQDVyv0f0CxmkAidvoDN0vvRIJZJr-bgBuL5FZM7gETAeYeiGlh7-Mf2Hzgy7236YNxcC9OnWFEcKEU50nlqog1bJnk8wJgoJWNqG0NUEK4DUzYqknmZ98qQv6rYrg5V-Hey-jAQp_KNf3h-vFHVZdP26Yg\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" - <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"4242424242424242\",\"cVVCode\":\"123\",\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" - ) - end - - def scrubbed_transcript - %( - <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer [FILTERED]\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" - <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"[FILTERED]\",\"cVVCode\":\"[FILTERED]\",\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" - ) - end - - def nil_cvv_transcript - %( - <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer AAEAAHwXaLTYs2APKJW_4TpTDwCw_h9oDx9rA58FR78AFuYCX82Izes1nz9qGBXELGUN_EukKcP5T78Th5guDz4Rw5dQ4Gf0suKw7pz9vWrqa1NpZhrD9Lj9T-SFtOJgfodiwVaBBeSgbJLKA7MOzC9q2dv91HBNP69DygL1oX2L2mtt8fWlKSWhQmtG040E1I43jTueX3L3L9YA7iO6pIwO7CGybE5LnjkQ65KB2K4oYKfXRZosF77hgMJIh-KprFy9cYY3EjfupHeLon9im1BGafrda2N5wj_A_LvdMzfLAD1l1dgj82KlvM_gAzNJ4S19gAicRo9zIbsq36Apt-8jFjS0AQAAAAEAAA9Zr_lVLKMmmtKSo6T_9ulzMCRbYs798EpFD2wMlkb1NCQtA65VrNcM20Ka2FjNQfwOcSMWqDl9zFQhPyFl-npsG1Ww2oyyavA6HSe1HLRLtE_1hNBAlTBPQnLJ6hBf8eR_NTiVa-aQdV2l92-eSwCS59CzrOYGGCY1pLdNMDr_r66kg9l-l94154kRoMBRQSCqZV9iM9M-f3adLJqG6Q79zz1oJpGrH-Zv1kuv8eLaJJNOEFYARb0JbnAC5G1l9-aqxGvBrNkd4sAJIe23XrRx2XJCBIABxuGSQ1xJBTINVlXBXq1mvvd8B1uiYiDNia3c_vIGuSGIjZE0VbUN3oJppfCt1joGdePeUaC2Pyb2vuUN00EBEOaD9RF8IBWMLVJaF9cW2OewDOfBQg94MuOKLdXB_IisRx1ed25VQDVyv0f0CxmkAidvoDN0vvRIJZJr-bgBuL5FZM7gETAeYeiGlh7-Mf2Hzgy7236YNxcC9OnWFEcKEU50nlqog1bJnk8wJgoJWNqG0NUEK4DUzYqknmZ98qQv6rYrg5V-Hey-jAQp_KNf3h-vFHVZdP26Yg\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" - <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"4242424242424242\",\"cVVCode\":null,\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" - ) - end - - def nil_cvv_scrubbed_transcript - %( - <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer [FILTERED]\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" - <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"[FILTERED]\",\"cVVCode\":[BLANK],\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" - ) - end - - def empty_string_cvv_transcript - %( - <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer AAEAAHwXaLTYs2APKJW_4TpTDwCw_h9oDx9rA58FR78AFuYCX82Izes1nz9qGBXELGUN_EukKcP5T78Th5guDz4Rw5dQ4Gf0suKw7pz9vWrqa1NpZhrD9Lj9T-SFtOJgfodiwVaBBeSgbJLKA7MOzC9q2dv91HBNP69DygL1oX2L2mtt8fWlKSWhQmtG040E1I43jTueX3L3L9YA7iO6pIwO7CGybE5LnjkQ65KB2K4oYKfXRZosF77hgMJIh-KprFy9cYY3EjfupHeLon9im1BGafrda2N5wj_A_LvdMzfLAD1l1dgj82KlvM_gAzNJ4S19gAicRo9zIbsq36Apt-8jFjS0AQAAAAEAAA9Zr_lVLKMmmtKSo6T_9ulzMCRbYs798EpFD2wMlkb1NCQtA65VrNcM20Ka2FjNQfwOcSMWqDl9zFQhPyFl-npsG1Ww2oyyavA6HSe1HLRLtE_1hNBAlTBPQnLJ6hBf8eR_NTiVa-aQdV2l92-eSwCS59CzrOYGGCY1pLdNMDr_r66kg9l-l94154kRoMBRQSCqZV9iM9M-f3adLJqG6Q79zz1oJpGrH-Zv1kuv8eLaJJNOEFYARb0JbnAC5G1l9-aqxGvBrNkd4sAJIe23XrRx2XJCBIABxuGSQ1xJBTINVlXBXq1mvvd8B1uiYiDNia3c_vIGuSGIjZE0VbUN3oJppfCt1joGdePeUaC2Pyb2vuUN00EBEOaD9RF8IBWMLVJaF9cW2OewDOfBQg94MuOKLdXB_IisRx1ed25VQDVyv0f0CxmkAidvoDN0vvRIJZJr-bgBuL5FZM7gETAeYeiGlh7-Mf2Hzgy7236YNxcC9OnWFEcKEU50nlqog1bJnk8wJgoJWNqG0NUEK4DUzYqknmZ98qQv6rYrg5V-Hey-jAQp_KNf3h-vFHVZdP26Yg\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" - <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"4242424242424242\",\"cVVCode\":\"\",\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" - ) - end - - def empty_string_cvv_scrubbed_transcript - %( - <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer [FILTERED]\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" - <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"[FILTERED]\",\"cVVCode\":\"[BLANK]\",\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" - ) - end - - def whitespace_string_cvv_transcript - %( - <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer AAEAAHwXaLTYs2APKJW_4TpTDwCw_h9oDx9rA58FR78AFuYCX82Izes1nz9qGBXELGUN_EukKcP5T78Th5guDz4Rw5dQ4Gf0suKw7pz9vWrqa1NpZhrD9Lj9T-SFtOJgfodiwVaBBeSgbJLKA7MOzC9q2dv91HBNP69DygL1oX2L2mtt8fWlKSWhQmtG040E1I43jTueX3L3L9YA7iO6pIwO7CGybE5LnjkQ65KB2K4oYKfXRZosF77hgMJIh-KprFy9cYY3EjfupHeLon9im1BGafrda2N5wj_A_LvdMzfLAD1l1dgj82KlvM_gAzNJ4S19gAicRo9zIbsq36Apt-8jFjS0AQAAAAEAAA9Zr_lVLKMmmtKSo6T_9ulzMCRbYs798EpFD2wMlkb1NCQtA65VrNcM20Ka2FjNQfwOcSMWqDl9zFQhPyFl-npsG1Ww2oyyavA6HSe1HLRLtE_1hNBAlTBPQnLJ6hBf8eR_NTiVa-aQdV2l92-eSwCS59CzrOYGGCY1pLdNMDr_r66kg9l-l94154kRoMBRQSCqZV9iM9M-f3adLJqG6Q79zz1oJpGrH-Zv1kuv8eLaJJNOEFYARb0JbnAC5G1l9-aqxGvBrNkd4sAJIe23XrRx2XJCBIABxuGSQ1xJBTINVlXBXq1mvvd8B1uiYiDNia3c_vIGuSGIjZE0VbUN3oJppfCt1joGdePeUaC2Pyb2vuUN00EBEOaD9RF8IBWMLVJaF9cW2OewDOfBQg94MuOKLdXB_IisRx1ed25VQDVyv0f0CxmkAidvoDN0vvRIJZJr-bgBuL5FZM7gETAeYeiGlh7-Mf2Hzgy7236YNxcC9OnWFEcKEU50nlqog1bJnk8wJgoJWNqG0NUEK4DUzYqknmZ98qQv6rYrg5V-Hey-jAQp_KNf3h-vFHVZdP26Yg\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" - <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"4242424242424242\",\"cVVCode\":\" \",\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" - ) - end - - def whitespace_string_cvv_scrubbed_transcript - %( - <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer [FILTERED]\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" - <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"[FILTERED]\",\"cVVCode\":\"[BLANK]\",\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" - ) - end + def setup + @gateway = AlliedWalletGateway.new( + site_id: "1234", + merchant_id: "1234", + token: "token" + ) + + @credit_card = credit_card + @amount = 100 + end + + def test_successful_purchase + response = stub_comms do + @gateway.purchase(@amount, @credit_card) + end.respond_with(successful_purchase_response) + + assert_success response + + assert_equal "123456", response.authorization + assert response.test? + end + + def test_failed_purchase + response = stub_comms do + @gateway.purchase(@amount, @credit_card) + end.respond_with(failed_purchase_response) + + assert_failure response + assert_equal "Declined", response.message + assert response.test? + end + + def test_successful_authorize_and_capture + response = stub_comms do + @gateway.authorize(@amount, @credit_card) + end.respond_with(successful_authorize_response) + + assert_success response + assert_equal "123456", response.authorization + + capture = stub_comms do + @gateway.capture(@amount, response.authorization) + end.respond_with(successful_capture_response) + + assert_success capture + end + + def test_failed_authorize + response = stub_comms do + @gateway.authorize(@amount, @credit_card) + end.respond_with(failed_authorize_response) + + assert_failure response + assert_equal "Declined", response.message + assert response.test? + end + + def test_failed_capture + response = stub_comms do + @gateway.capture(100, "") + end.respond_with(failed_capture_response) + + assert_failure response + end + + def test_successful_void + response = stub_comms do + @gateway.purchase(@amount, @credit_card) + end.respond_with(successful_authorize_response) + + assert_success response + assert_equal "123456", response.authorization + + void = stub_comms do + @gateway.void(response.authorization) + end.check_request do |endpoint, data, headers| + assert_match(/123456/, data) + end.respond_with(successful_void_response) + + assert_success void + end + + def test_failed_void + response = stub_comms do + @gateway.void("5d53a33d960c46d00f5dc061947d998c") + end.check_request do |endpoint, data, headers| + assert_match(/5d53a33d960c46d00f5dc061947d998c/, data) + end.respond_with(failed_void_response) + + assert_failure response + end + + def test_successful_refund + response = stub_comms do + @gateway.purchase(@amount, @credit_card) + end.respond_with(successful_purchase_response) + + assert_success response + assert_equal "123456", response.authorization + + refund = stub_comms do + @gateway.refund(@amount, response.authorization) + end.check_request do |endpoint, data, headers| + assert_match(/123456/, data) + end.respond_with(successful_refund_response) + + assert_success refund + end + + def test_failed_refund + response = stub_comms do + @gateway.refund(nil, "") + end.respond_with(failed_refund_response) + + assert_failure response + end + + def test_successful_verify + response = stub_comms do + @gateway.verify(@credit_card) + end.respond_with(successful_authorize_response, failed_void_response) + assert_success response + assert_equal "Succeeded", response.message + end + + def test_failed_verify + response = stub_comms do + @gateway.verify(@credit_card) + end.respond_with(failed_authorize_response, successful_void_response) + assert_failure response + assert_equal "Declined", response.message + end + + def test_empty_response_fails + response = stub_comms do + @gateway.purchase(@amount, @credit_card) + end.respond_with(empty_purchase_response) + + assert_failure response + assert_equal "Error", response.message + end + + def test_invalid_json + response = stub_comms do + @gateway.purchase(@amount, @credit_card) + end.respond_with(invalid_json_response) + + assert_failure response + assert_match %r{Unparsable response}, response.message + end + + def test_transcript_scrubbing + assert_equal scrubbed_transcript, @gateway.scrub(transcript) + end + + def test_nil_cvv_transcript_scrubbing + assert_equal nil_cvv_scrubbed_transcript, @gateway.scrub(nil_cvv_transcript) + end + + def test_empty_string_cvv_transcript_scrubbing + assert_equal empty_string_cvv_scrubbed_transcript, @gateway.scrub(empty_string_cvv_transcript) + end + + private + + def successful_purchase_response + %( + { + "id": "123456", + "message": "Success", + "state": "Sale", + "status": "Successful" + } + ) + end + + def failed_purchase_response + %( + { + "id": "123456", + "message": "Declined", + "state": "Sale", + "status": "Declined" + } + ) + end + + def successful_authorize_response + %( + { + "id": "123456", + "message": "Success", + "state": "Authorize", + "status": "Successful" + } + ) + end + + def failed_authorize_response + %( + { + "id": "123456", + "message": "Declined", + "state": "Authorize", + "status": "Declined" + } + ) + end + + def successful_capture_response + %( + { + "id": "123456", + "message": "Successful", + "state": "Capture", + "status": "Successful" + } + ) + end + + def failed_capture_response + %( + { + "id": "123456", + "message": "Declined", + "state": "Capture", + "status": "Declined" + } + ) + end + + def successful_void_response + %( + { + "id": "123456", + "message": "Success", + "state": "Void", + "status": "Successful" + } + ) + end + + def failed_void_response + %( + { + "id": "123456", + "message": "Error", + "state": "Void", + "status": "Error" + } + ) + end + + def successful_refund_response + %( + { + "id": "123456", + "message": "Success", + "state": "Refund", + "status": "Successful" + } + ) + end + + def failed_refund_response + %( + { + "id": "123456", + "message": "Error", + "state": "Refund", + "status": "Error" + } + ) + end + + + def empty_purchase_response + %( + { + "id": "123456", + "message": "Error", + "state": "Purchase", + "status": "Error" + } + ) + end + + def invalid_json_response + %( + { + "id": "123456", + ) + end + + + def transcript + %( + <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer AAEAAHwXaLTYs2APKJW_4TpTDwCw_h9oDx9rA58FR78AFuYCX82Izes1nz9qGBXELGUN_EukKcP5T78Th5guDz4Rw5dQ4Gf0suKw7pz9vWrqa1NpZhrD9Lj9T-SFtOJgfodiwVaBBeSgbJLKA7MOzC9q2dv91HBNP69DygL1oX2L2mtt8fWlKSWhQmtG040E1I43jTueX3L3L9YA7iO6pIwO7CGybE5LnjkQ65KB2K4oYKfXRZosF77hgMJIh-KprFy9cYY3EjfupHeLon9im1BGafrda2N5wj_A_LvdMzfLAD1l1dgj82KlvM_gAzNJ4S19gAicRo9zIbsq36Apt-8jFjS0AQAAAAEAAA9Zr_lVLKMmmtKSo6T_9ulzMCRbYs798EpFD2wMlkb1NCQtA65VrNcM20Ka2FjNQfwOcSMWqDl9zFQhPyFl-npsG1Ww2oyyavA6HSe1HLRLtE_1hNBAlTBPQnLJ6hBf8eR_NTiVa-aQdV2l92-eSwCS59CzrOYGGCY1pLdNMDr_r66kg9l-l94154kRoMBRQSCqZV9iM9M-f3adLJqG6Q79zz1oJpGrH-Zv1kuv8eLaJJNOEFYARb0JbnAC5G1l9-aqxGvBrNkd4sAJIe23XrRx2XJCBIABxuGSQ1xJBTINVlXBXq1mvvd8B1uiYiDNia3c_vIGuSGIjZE0VbUN3oJppfCt1joGdePeUaC2Pyb2vuUN00EBEOaD9RF8IBWMLVJaF9cW2OewDOfBQg94MuOKLdXB_IisRx1ed25VQDVyv0f0CxmkAidvoDN0vvRIJZJr-bgBuL5FZM7gETAeYeiGlh7-Mf2Hzgy7236YNxcC9OnWFEcKEU50nlqog1bJnk8wJgoJWNqG0NUEK4DUzYqknmZ98qQv6rYrg5V-Hey-jAQp_KNf3h-vFHVZdP26Yg\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" + <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"4242424242424242\",\"cVVCode\":\"123\",\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" + ) + end + + def scrubbed_transcript + %( + <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer [FILTERED]\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" + <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"[FILTERED]\",\"cVVCode\":\"[FILTERED]\",\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" + ) + end + + def nil_cvv_transcript + %( + <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer AAEAAHwXaLTYs2APKJW_4TpTDwCw_h9oDx9rA58FR78AFuYCX82Izes1nz9qGBXELGUN_EukKcP5T78Th5guDz4Rw5dQ4Gf0suKw7pz9vWrqa1NpZhrD9Lj9T-SFtOJgfodiwVaBBeSgbJLKA7MOzC9q2dv91HBNP69DygL1oX2L2mtt8fWlKSWhQmtG040E1I43jTueX3L3L9YA7iO6pIwO7CGybE5LnjkQ65KB2K4oYKfXRZosF77hgMJIh-KprFy9cYY3EjfupHeLon9im1BGafrda2N5wj_A_LvdMzfLAD1l1dgj82KlvM_gAzNJ4S19gAicRo9zIbsq36Apt-8jFjS0AQAAAAEAAA9Zr_lVLKMmmtKSo6T_9ulzMCRbYs798EpFD2wMlkb1NCQtA65VrNcM20Ka2FjNQfwOcSMWqDl9zFQhPyFl-npsG1Ww2oyyavA6HSe1HLRLtE_1hNBAlTBPQnLJ6hBf8eR_NTiVa-aQdV2l92-eSwCS59CzrOYGGCY1pLdNMDr_r66kg9l-l94154kRoMBRQSCqZV9iM9M-f3adLJqG6Q79zz1oJpGrH-Zv1kuv8eLaJJNOEFYARb0JbnAC5G1l9-aqxGvBrNkd4sAJIe23XrRx2XJCBIABxuGSQ1xJBTINVlXBXq1mvvd8B1uiYiDNia3c_vIGuSGIjZE0VbUN3oJppfCt1joGdePeUaC2Pyb2vuUN00EBEOaD9RF8IBWMLVJaF9cW2OewDOfBQg94MuOKLdXB_IisRx1ed25VQDVyv0f0CxmkAidvoDN0vvRIJZJr-bgBuL5FZM7gETAeYeiGlh7-Mf2Hzgy7236YNxcC9OnWFEcKEU50nlqog1bJnk8wJgoJWNqG0NUEK4DUzYqknmZ98qQv6rYrg5V-Hey-jAQp_KNf3h-vFHVZdP26Yg\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" + <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"4242424242424242\",\"cVVCode\":null,\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" + ) + end + + def nil_cvv_scrubbed_transcript + %( + <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer [FILTERED]\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" + <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"[FILTERED]\",\"cVVCode\":[BLANK],\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" + ) + end + + def empty_string_cvv_transcript + %( + <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer AAEAAHwXaLTYs2APKJW_4TpTDwCw_h9oDx9rA58FR78AFuYCX82Izes1nz9qGBXELGUN_EukKcP5T78Th5guDz4Rw5dQ4Gf0suKw7pz9vWrqa1NpZhrD9Lj9T-SFtOJgfodiwVaBBeSgbJLKA7MOzC9q2dv91HBNP69DygL1oX2L2mtt8fWlKSWhQmtG040E1I43jTueX3L3L9YA7iO6pIwO7CGybE5LnjkQ65KB2K4oYKfXRZosF77hgMJIh-KprFy9cYY3EjfupHeLon9im1BGafrda2N5wj_A_LvdMzfLAD1l1dgj82KlvM_gAzNJ4S19gAicRo9zIbsq36Apt-8jFjS0AQAAAAEAAA9Zr_lVLKMmmtKSo6T_9ulzMCRbYs798EpFD2wMlkb1NCQtA65VrNcM20Ka2FjNQfwOcSMWqDl9zFQhPyFl-npsG1Ww2oyyavA6HSe1HLRLtE_1hNBAlTBPQnLJ6hBf8eR_NTiVa-aQdV2l92-eSwCS59CzrOYGGCY1pLdNMDr_r66kg9l-l94154kRoMBRQSCqZV9iM9M-f3adLJqG6Q79zz1oJpGrH-Zv1kuv8eLaJJNOEFYARb0JbnAC5G1l9-aqxGvBrNkd4sAJIe23XrRx2XJCBIABxuGSQ1xJBTINVlXBXq1mvvd8B1uiYiDNia3c_vIGuSGIjZE0VbUN3oJppfCt1joGdePeUaC2Pyb2vuUN00EBEOaD9RF8IBWMLVJaF9cW2OewDOfBQg94MuOKLdXB_IisRx1ed25VQDVyv0f0CxmkAidvoDN0vvRIJZJr-bgBuL5FZM7gETAeYeiGlh7-Mf2Hzgy7236YNxcC9OnWFEcKEU50nlqog1bJnk8wJgoJWNqG0NUEK4DUzYqknmZ98qQv6rYrg5V-Hey-jAQp_KNf3h-vFHVZdP26Yg\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" + <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"4242424242424242\",\"cVVCode\":\"\",\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" + ) + end + + def empty_string_cvv_scrubbed_transcript + %( + <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer [FILTERED]\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" + <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"[FILTERED]\",\"cVVCode\":\"[BLANK]\",\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" + ) + end + + def whitespace_string_cvv_transcript + %( + <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer AAEAAHwXaLTYs2APKJW_4TpTDwCw_h9oDx9rA58FR78AFuYCX82Izes1nz9qGBXELGUN_EukKcP5T78Th5guDz4Rw5dQ4Gf0suKw7pz9vWrqa1NpZhrD9Lj9T-SFtOJgfodiwVaBBeSgbJLKA7MOzC9q2dv91HBNP69DygL1oX2L2mtt8fWlKSWhQmtG040E1I43jTueX3L3L9YA7iO6pIwO7CGybE5LnjkQ65KB2K4oYKfXRZosF77hgMJIh-KprFy9cYY3EjfupHeLon9im1BGafrda2N5wj_A_LvdMzfLAD1l1dgj82KlvM_gAzNJ4S19gAicRo9zIbsq36Apt-8jFjS0AQAAAAEAAA9Zr_lVLKMmmtKSo6T_9ulzMCRbYs798EpFD2wMlkb1NCQtA65VrNcM20Ka2FjNQfwOcSMWqDl9zFQhPyFl-npsG1Ww2oyyavA6HSe1HLRLtE_1hNBAlTBPQnLJ6hBf8eR_NTiVa-aQdV2l92-eSwCS59CzrOYGGCY1pLdNMDr_r66kg9l-l94154kRoMBRQSCqZV9iM9M-f3adLJqG6Q79zz1oJpGrH-Zv1kuv8eLaJJNOEFYARb0JbnAC5G1l9-aqxGvBrNkd4sAJIe23XrRx2XJCBIABxuGSQ1xJBTINVlXBXq1mvvd8B1uiYiDNia3c_vIGuSGIjZE0VbUN3oJppfCt1joGdePeUaC2Pyb2vuUN00EBEOaD9RF8IBWMLVJaF9cW2OewDOfBQg94MuOKLdXB_IisRx1ed25VQDVyv0f0CxmkAidvoDN0vvRIJZJr-bgBuL5FZM7gETAeYeiGlh7-Mf2Hzgy7236YNxcC9OnWFEcKEU50nlqog1bJnk8wJgoJWNqG0NUEK4DUzYqknmZ98qQv6rYrg5V-Hey-jAQp_KNf3h-vFHVZdP26Yg\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" + <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"4242424242424242\",\"cVVCode\":\" \",\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" + ) + end + + def whitespace_string_cvv_scrubbed_transcript + %( + <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer [FILTERED]\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" + <- "{\"siteId\":\"10118\",\"amount\":\"1.00\",\"trackingId\":\"82b5f6217fa19daa426e226a231d330a\",\"currency\":\"USD\",\"nameOnCard\":\"Longbob Longsen\",\"cardNumber\":\"[FILTERED]\",\"cVVCode\":\"[BLANK]\",\"expirationYear\":\"2016\",\"expirationMonth\":\"09\",\"email\":\"jim_smith@example.com\",\"iPAddress\":\"127.0.0.1\",\"firstName\":\"Jim\",\"lastName\":\"Smith\",\"addressLine1\":\"456 My Street\",\"addressLine2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryId\":\"CA\",\"postalCode\":\"K1C2N6\",\"phone\":\"(555)555-5555\"}" + ) + end end diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 0ac15ef2b9d..ac9e793554f 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -936,7 +936,7 @@ def assert_no_has_customer_id(data) end def test_include_cust_id_for_numeric_values - stub_comms do + stub_comms do @gateway.purchase(@amount, @credit_card, customer: "123") end.check_request do |endpoint, data, headers| parse(data) do |doc| @@ -948,7 +948,7 @@ def test_include_cust_id_for_numeric_values end def test_include_cust_id_for_word_character_values - stub_comms do + stub_comms do @gateway.purchase(@amount, @credit_card, customer: "4840_TT") end.check_request do |endpoint, data, headers| parse(data) do |doc| @@ -960,7 +960,7 @@ def test_include_cust_id_for_word_character_values end def test_dont_include_cust_id_for_email_addresses - stub_comms do + stub_comms do @gateway.purchase(@amount, @credit_card, customer: "bob@test.com") end.check_request do |endpoint, data, headers| doc = parse(data) @@ -970,7 +970,7 @@ def test_dont_include_cust_id_for_email_addresses end def test_dont_include_cust_id_for_phone_numbers - stub_comms do + stub_comms do @gateway.purchase(@amount, @credit_card, customer: "111-123-1231") end.check_request do |endpoint, data, headers| doc = parse(data) diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb index 783d34e887c..e3306dfe71e 100644 --- a/test/unit/gateways/opp_test.rb +++ b/test/unit/gateways/opp_test.rb @@ -204,18 +204,12 @@ def failed_response(type, id, code='100.100.101') end class OppMockResponse - def initialize(code, body) - @code = code - @body = body - end - - def code - @code - end - - def body - @body - end + attr_reader :code, :body + + def initialize(code, body) + @code = code + @body = body + end end end diff --git a/test/unit/gateways/trexle_test.rb b/test/unit/gateways/trexle_test.rb index b07bbc55393..7bbd31db900 100644 --- a/test/unit/gateways/trexle_test.rb +++ b/test/unit/gateways/trexle_test.rb @@ -39,9 +39,9 @@ def test_live_url def test_supported_countries expected_supported_countries = %w(AD AE AT AU BD BE BG BN CA CH CY CZ DE DK EE EG ES FI FR GB - GI GR HK HU ID IE IL IM IN IS IT JO KW LB LI LK LT LU LV MC - MT MU MV MX MY NL NO NZ OM PH PL PT QA RO SA SE SG SI SK SM - TR TT UM US VA VN ZA) + GI GR HK HU ID IE IL IM IN IS IT JO KW LB LI LK LT LU LV MC + MT MU MV MX MY NL NO NZ OM PH PL PT QA RO SA SE SG SI SK SM + TR TT UM US VA VN ZA) assert_equal expected_supported_countries, TrexleGateway.supported_countries end diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb index 5b8f12684cc..a4e632ae278 100644 --- a/test/unit/gateways/usa_epay_transaction_test.rb +++ b/test/unit/gateways/usa_epay_transaction_test.rb @@ -420,7 +420,7 @@ def test_scrub assert_equal @gateway.scrub(pre_scrubbed_echeck), post_scrubbed_echeck end -private + private def assert_address(type, post, expected_first_name = nil, expected_last_name = nil) prefix = key_prefix(type) From 1af7b826abccf08885c69cd7539ab628753d9e1c Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Fri, 16 Mar 2018 11:28:25 -0400 Subject: [PATCH 452/677] Visanet Peru: Refund on unsettled transactions When transactions are not yet settled a refundSingleTransaction needs to be called. This tries to use this method if a cancelDeposit fails. If both calls are made the messages from both transactions are captured. . Loaded suite test/unit/gateways/visanet_peru_test ............. 13 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_visanet_peru_test ................. 17 tests, 56 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/visanet_peru.rb | 66 +++++--- test/fixtures.yml | 7 +- .../gateways/remote_visanet_peru_test.rb | 13 +- test/unit/gateways/visanet_peru_test.rb | 152 ++++++++++++++---- 5 files changed, 187 insertions(+), 52 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d8aa4f3fab0..5f9aef015ce 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,7 @@ * Paymentez: allow capture amount to exceed authorization amount [bpollack] #2900 * JetPay: fix typo in error messages [reynhout] #2749 * Braintree: add support for Maestro cards [matthewheath] #2571 +* Visanet Peru: Refund on unsettled transactions [nfarve] #2772 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb index 724057994ba..f2c3e60acd1 100644 --- a/lib/active_merchant/billing/gateways/visanet_peru.rb +++ b/lib/active_merchant/billing/gateways/visanet_peru.rb @@ -34,25 +34,32 @@ def authorize(amount, payment_method, options={}) params[:email] = options[:email] || 'unknown@email.com' params[:createAlias] = false - commit("authorize", params) + commit("authorize", params, options) end def capture(authorization, options={}) params = {} + options[:id_unico] = split_authorization(authorization)[1] add_auth_order_id(params, authorization, options) - commit("deposit", params) + commit("deposit", params, options) end def void(authorization, options={}) params = {} add_auth_order_id(params, authorization, options) - commit("void", params) + commit("void", params, options) end def refund(amount, authorization, options={}) params = {} + params[:amount] = amount(amount) if amount add_auth_order_id(params, authorization, options) - commit("cancelDeposit", params) + response = commit("cancelDeposit", params, options) + return response if response.success? || split_authorization(authorization).length == 1 || !options[:force_full_refund_if_unsettled] + + # Attempt RefundSingleTransaction if unsettled + prepare_refund_data(params, authorization, options) + commit('refund', params, options) end def verify(credit_card, options={}) @@ -88,7 +95,8 @@ def add_invoice(params, money, options) end def add_auth_order_id(params, authorization, options) - params[:purchaseNumber] = authorization + purchase_number, _ = split_authorization(authorization) + params[:purchaseNumber] = purchase_number params[:externalTransactionId] = options[:order_id] end @@ -118,22 +126,35 @@ def add_antifraud_data(params, options) params[:antifraud] = antifraud end - def commit(action, params) + def prepare_refund_data(params, authorization, options) + params.delete(:purchaseNumber) + params[:externalReferenceId] = params.delete(:externalTransactionId) + _, transaction_id = split_authorization(authorization) + + options.update(transaction_id: transaction_id) + params[:ruc] = options[:ruc] + end + + def split_authorization(authorization) + authorization.split('|') + end + + def commit(action, params, options={}) begin - raw_response = ssl_request(method(action), url(action, params), params.to_json, headers) + raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers) response = parse(raw_response) rescue ResponseError => e raw_response = e.response.body - response_error(raw_response) + response_error(raw_response, options, action) rescue JSON::ParserError unparsable_response(raw_response) else Response.new( success_from(response), - message_from(response), + message_from(response, options, action), response, :test => test?, - :authorization => authorization_from(params), + :authorization => authorization_from(params, response, options), :error_code => response["errorCode"] ) end @@ -146,20 +167,23 @@ def headers } end - def url(action, params) + def url(action, params, options={}) if (action == "authorize") "#{base_url}/#{@options[:merchant_id]}" + elsif (action == 'refund') + "#{base_url}/#{@options[:merchant_id]}/#{action}/#{options[:transaction_id]}" else "#{base_url}/#{@options[:merchant_id]}/#{action}/#{params[:purchaseNumber]}" end end def method(action) - (action == "authorize") ? :post : :put + (%w(authorize refund).include? action) ? :post : :put end - def authorization_from(params) - params[:purchaseNumber] + def authorization_from(params, response, options) + id_unico = response['data']['ID_UNICO'] || options[:id_unico] + "#{params[:purchaseNumber]}|#{id_unico}" end def base_url @@ -174,15 +198,19 @@ def success_from(response) response["errorCode"] == 0 end - def message_from(response) + def message_from(response, options, action) if empty?(response["errorMessage"]) || response["errorMessage"] == "[ ]" - response["data"]["DSC_COD_ACCION"] + action == 'refund' ? "#{response["data"]["DSC_COD_ACCION"]}, #{options[:error_message]}" : response['data']['DSC_COD_ACCION'] + elsif action == 'refund' + message = "#{response["errorMessage"]}, #{options[:error_message]}" + options[:error_message] = response["errorMessage"] + message else - response["errorMessage"] + response['errorMessage'] end end - def response_error(raw_response) + def response_error(raw_response, options, action) begin response = parse(raw_response) rescue JSON::ParserError @@ -190,7 +218,7 @@ def response_error(raw_response) else return Response.new( false, - message_from(response), + message_from(response, options, action), response, :test => test?, :authorization => response["transactionUUID"], diff --git a/test/fixtures.yml b/test/fixtures.yml index d03708a73bb..bbbf30d5631 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -1216,9 +1216,10 @@ viaklix: # test credentails visanet_peru: - access_key_id: "AKIAJPOQZ7BAXJZ5K35A" - secret_access_key: "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" - merchant_id: "101266802" + access_key_id: "AKIAJLJTVQYHO4P76YYA" + secret_access_key: "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" + merchant_id: "543025501" + ruc: '20341198217' webpay: login: "test_secret_eHn4TTgsGguBcW764a2KA8Yd" diff --git a/test/remote/gateways/remote_visanet_peru_test.rb b/test/remote/gateways/remote_visanet_peru_test.rb index 9eb37e3e71d..b5402d4dad9 100644 --- a/test/remote/gateways/remote_visanet_peru_test.rb +++ b/test/remote/gateways/remote_visanet_peru_test.rb @@ -83,7 +83,7 @@ def test_failed_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response assert_equal 400, response.error_code - assert_equal "El pedido ha sido rechazado por Decision Manager", response.message + assert_equal "REJECT", response.message end def test_failed_capture @@ -102,6 +102,17 @@ def test_successful_refund assert_equal "OK", refund.message end + def test_successful_refund_unsettled + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + + new_auth = "_|#{response.authorization.split('|')[1]}" + refund = @gateway.refund(@amount, new_auth, @options.merge(force_full_refund_if_unsettled: true, ruc: '20341198217')) + # this test will fail currently because there is no E2E test working for visanet + # assert_success refund + # assert_equal "OK", refund.message + end + def test_failed_refund response = @gateway.refund(@amount, "900000044" ) assert_failure response diff --git a/test/unit/gateways/visanet_peru_test.rb b/test/unit/gateways/visanet_peru_test.rb index 08fe953fa59..49aab0a9bc7 100644 --- a/test/unit/gateways/visanet_peru_test.rb +++ b/test/unit/gateways/visanet_peru_test.rb @@ -23,7 +23,7 @@ def test_successful_purchase assert_success response assert_equal "OK", response.message - assert_match %r([0-9]{9}$), response.authorization + assert_match %r([0-9]{9}|$), response.authorization assert_equal @options[:order_id], response.params["externalTransactionId"] assert response.test? end @@ -42,7 +42,7 @@ def test_successful_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_success response assert_equal "OK", response.message - assert_match %r(^[0-9]{9}$), response.authorization + assert_match %r(^[0-9]{9}|$), response.authorization assert_equal @options[:order_id], response.params["externalTransactionId"] assert_equal "1.00", response.params["data"]["IMP_AUTORIZADO"] assert response.test? @@ -60,7 +60,7 @@ def test_failed_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response assert_equal 400, response.error_code - assert_equal "El pedido ha sido rechazado por Decision Manager", response.message + assert_equal "REJECT", response.message end def test_successful_capture @@ -70,17 +70,17 @@ def test_successful_capture capture = @gateway.capture(response.authorization, @options) assert_success capture assert_equal "OK", capture.message - assert_match %r(^[0-9]{9}$), capture.authorization + assert_match %r(^[0-9]{9}|$), capture.authorization assert_equal @options[:order_id], capture.params["externalTransactionId"] assert capture.test? end def test_failed_capture @gateway.expects(:ssl_request).returns(failed_capture_response) - invalid_purchase_number = "122333444" - response = @gateway.capture("authorize" + "|" + invalid_purchase_number) + invalid_purchase_number = "900000044" + response = @gateway.capture(invalid_purchase_number) assert_failure response - assert_equal "[ 'NUMORDEN 12233344 no se encuentra registrado', 'No se realizo el deposito' ]", response.message + assert_equal '[ "NUMORDEN 900000044 no se encuentra registrado", "No se realizo el deposito" ]', response.message assert_equal 400, response.error_code end @@ -256,32 +256,58 @@ def failed_authorize_response_bad_card end def failed_authorize_response_bad_email - <<-RESPONSE - { - "errorCode": 400, - "errorMessage": "El pedido ha sido rechazado por Decision Manager" - } - RESPONSE + %q( + { + "errorCode": 400, + "errorMessage": "REJECT", + "millis": 513, + "transactionUUID": "e2f0f73d-2f44-4f05-9e13-dad3bf378c57", + "transactionDate": 1519932476254, + "data": { + "FECHAYHORA_TX": "01\/03\/2018 21:26", + "RES_CVV2": null, + "CSIMENSAJE": null, + "ID_UNICO": null, + "ETICKET": null, + "DECISIONCS": "REJECT", + "CSIPORCENTAJEDESCUENTO": null, + "NROCUOTA": null, + "CSIIMPORTECOMERCIO": null, + "CSICODIGOPROGRAMA": null, + "DSC_ECI": null, + "ECI": "00", + "DSC_COD_ACCION": "Operacion denegada", + "NOM_EMISOR": null, + "IMPCUOTAAPROX": null, + "CSITIPOCOBRO": null, + "NUMREFERENCIA": null, + "RESPUESTA": "2", + "NUMORDEN": "376876217", + "CODACCION": "670", + "IMP_AUTORIZADO": "0.00", + "COD_AUTORIZA": null, + "CODTIENDA": "vndp", + "PAN": null, + "reviewTransaction": "false", + "ORI_TARJETA": null + }, + "transactionLog": { + + } + } + ) end def successful_capture_response - <<-RESPONSE - { - "errorCode": 0, - "errorMessage": "OK", - "externalTransactionId": "#{@options[:order_id]}", - "merchantId": "101266802" - } - RESPONSE + '{"errorCode":0,"errorMessage":"OK","transactionUUID":"8517cf68-4820-4224-959b-01c8117385e0","externalTransactionId":"de9dc65c094fb4f1defddc562731af81","transactionDateTime":1519937673906,"transactionDuration":0,"merchantId":"543025501","userTokenId":null,"aliasName":null,"data":{"FECHAYHORA_TX":null,"DSC_ECI":null,"DSC_COD_ACCION":null,"NOM_EMISOR":null,"ESTADO":"Depositado","RESPUESTA":"1","ID_UNICO":null,"NUMORDEN":null,"CODACCION":null,"ETICKET":null,"IMP_AUTORIZADO":null,"DECISIONCS":null,"COD_AUTORIZA":null,"CODTIENDA":"543025501","PAN":null,"ORI_TARJETA":null}}' end def failed_capture_response - <<-RESPONSE + %q( { - "errorCode": 400, - "errorMessage": "[ 'NUMORDEN 12233344 no se encuentra registrado', 'No se realizo el deposito' ]" + "errorCode":400,"errorMessage":"[ \"NUMORDEN 900000044 no se encuentra registrado\", \"No se realizo el deposito\" ]","millis":513,"transactionUUID":"e2f0f73d-2f44-4f05-9e13-dad3bf378c57","transactionDate":1519932476254,"data":{"FECHAYHORA_TX":null,"DSC_ECI":null,"DSC_COD_ACCION":null,"NOM_EMISOR":null,"ESTADO":"","RESPUESTA":"2","ID_UNICO":null,"NUMORDEN":null,"CODACCION":null,"ETICKET":null,"IMP_AUTORIZADO":null,"DECISIONCS":null,"COD_AUTORIZA":null,"CODTIENDA":"543025501","PAN":null,"ORI_TARJETA":null},"transactionLog":{} } - RESPONSE + ) end def successful_verify_response @@ -290,7 +316,27 @@ def successful_verify_response "errorCode": 0, "errorMessage": "OK", "externalTransactionId": "#{@options[:order_id]}", - "merchantId": "101266802" + "merchantId": "101266802", + "userTokenId": null, + "aliasName": null, + "data": { + "FECHAYHORA_TX": null, + "DSC_ECI": null, + "DSC_COD_ACCION": null, + "NOM_EMISOR": null, + "ESTADO": "Anulado", + "RESPUESTA": "1", + "ID_UNICO": null, + "NUMORDEN": null, + "CODACCION": null, + "ETICKET": null, + "IMP_AUTORIZADO": null, + "DECISIONCS": null, + "COD_AUTORIZA": null, + "CODTIENDA": "543025501", + "PAN": null, + "ORI_TARJETA": null + } } RESPONSE end @@ -313,7 +359,27 @@ def successful_void_response "errorCode": 0, "errorMessage": "OK", "externalTransactionId": "987654321", - "merchantId": "101266802" + "merchantId": "101266802", + "userTokenId": null, + "aliasName": null, + "data": { + "FECHAYHORA_TX": null, + "DSC_ECI": null, + "DSC_COD_ACCION": null, + "NOM_EMISOR": null, + "ESTADO": "Anulado", + "RESPUESTA": "1", + "ID_UNICO": null, + "NUMORDEN": null, + "CODACCION": null, + "ETICKET": null, + "IMP_AUTORIZADO": null, + "DECISIONCS": null, + "COD_AUTORIZA": null, + "CODTIENDA": "543025501", + "PAN": null, + "ORI_TARJETA": null + } } RESPONSE end @@ -322,7 +388,28 @@ def failed_void_response <<-RESPONSE { "errorCode": 400, - "errorMessage": "[ 'NUMORDEN no se encuentra registrado.', 'No se ha realizado la anulacion del pedido' ]" + "errorMessage": "[ 'NUMORDEN no se encuentra registrado.', 'No se ha realizado la anulacion del pedido' ]", + "data": { + "FECHAYHORA_TX": null, + "DSC_ECI": null, + "DSC_COD_ACCION": null, + "NOM_EMISOR": null, + "ESTADO": " ", + "RESPUESTA": "2", + "ID_UNICO": null, + "NUMORDEN": null, + "CODACCION": null, + "ETICKET": null, + "IMP_AUTORIZADO": null, + "DECISIONCS": null, + "COD_AUTORIZA": null, + "CODTIENDA": "543025501", + "PAN": null, + "ORI_TARJETA": null + }, + "transactionLog": { + + } } RESPONSE end @@ -348,7 +435,14 @@ def failed_refund_response <<-RESPONSE { "errorCode": 400, - "errorMessage": "[ 'NUMORDEN 122333444 no se encuentra registrado', 'No se realizo la anulacion del deposito' ]" + "errorMessage": "[ 'NUMORDEN 122333444 no se encuentra registrado', 'No se realizo la anulacion del deposito' ]", + "data": { + "ESTADO": "", + "RESPUESTA": "2" + }, + "transactionLog": { + + } } RESPONSE end From 49e36faf109212215c9ce2bf2c2e5f398ed0827c Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 26 Jun 2018 13:42:01 -0400 Subject: [PATCH 453/677] Fix code issues flagged in unit tests None of these resulted in build or test failure, but all are flagged directly on a test:unit run. The specific issues flagged were: active_merchant/lib/active_merchant/billing/gateways/mundipagg.rb:69: warning: assigned but unused variable - post active_merchant/lib/active_merchant/billing/gateways/litle.rb:81: warning: assigned but unused variable - kind active_merchant/lib/active_merchant/billing/gateways/litle.rb:195: warning: assigned but unused variable - transaction_id active_merchant/lib/active_merchant/billing/gateways/borgun.rb:99: warning: assigned but unused variable - batch active_merchant/test/unit/gateways/card_connect_test.rb:186: warning: assigned but unused variable - response active_merchant/test/unit/gateways/checkout_v2_test.rb:219: warning: ambiguous first argument; put parentheses or a space even after `/' operator active_merchant/test/unit/gateways/credorax_test.rb:222: warning: ambiguous first argument; put parentheses or a space even after `/' operator active_merchant/test/unit/gateways/optimal_payment_test.rb:445: warning: mismatched indentations at 'end' with 'def' at 441 None of these are related to RuboCop. 3874 tests, 67956 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/borgun.rb | 2 +- lib/active_merchant/billing/gateways/litle.rb | 4 ++-- .../billing/gateways/mundipagg.rb | 2 +- test/unit/gateways/card_connect_test.rb | 2 +- test/unit/gateways/checkout_v2_test.rb | 2 +- test/unit/gateways/credorax_test.rb | 2 +- test/unit/gateways/optimal_payment_test.rb | 18 +++++++++--------- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb index f3892b9f4f8..adb7788bd35 100644 --- a/lib/active_merchant/billing/gateways/borgun.rb +++ b/lib/active_merchant/billing/gateways/borgun.rb @@ -96,7 +96,7 @@ def add_payment_method(post, payment_method) end def add_reference(post, authorization) - dateandtime, batch, transaction, rrn, authcode, _, _, _ = split_authorization(authorization) + dateandtime, _batch, transaction, rrn, authcode, _, _, _ = split_authorization(authorization) post[:DateAndTime] = dateandtime post[:Transaction] = transaction post[:RRN] = rrn diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index 14b3658b0d5..a4dfdd8dc03 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -78,7 +78,7 @@ def refund(money, payment, options={}) add_descriptor(doc, options) doc.send(refund_type(payment), transaction_attributes(options)) do if payment.is_a?(String) - transaction_id, kind, _ = split_authorization(payment) + transaction_id, _, _ = split_authorization(payment) doc.litleTxnId(transaction_id) doc.amount(money) if money elsif check?(payment) @@ -192,7 +192,7 @@ def void_type(kind) end def refund_type(payment) - transaction_id, kind, _ = split_authorization(payment) + _, kind, _ = split_authorization(payment) if check?(payment) || kind == 'echeckSales' :echeckCredit else diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb index 751b94db660..7aefce004e4 100644 --- a/lib/active_merchant/billing/gateways/mundipagg.rb +++ b/lib/active_merchant/billing/gateways/mundipagg.rb @@ -66,7 +66,7 @@ def refund(money, authorization, options={}) end def void(authorization, options={}) - commit('void', post=nil, authorization) + commit('void', nil, authorization) end def store(payment, options={}) diff --git a/test/unit/gateways/card_connect_test.rb b/test/unit/gateways/card_connect_test.rb index ab735f986b5..2bc560d4e1d 100644 --- a/test/unit/gateways/card_connect_test.rb +++ b/test/unit/gateways/card_connect_test.rb @@ -183,7 +183,7 @@ def test_failed_store end def test_successful_unstore - response = stub_comms(@gateway, :ssl_request) do + stub_comms(@gateway, :ssl_request) do @gateway.unstore('1|16700875781344019340') end.check_request do |verb, url, data, headers| assert_equal :delete, verb diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb index 1724f172730..8505d2936ea 100644 --- a/test/unit/gateways/checkout_v2_test.rb +++ b/test/unit/gateways/checkout_v2_test.rb @@ -216,7 +216,7 @@ def test_error_code_returned end.respond_with(error_code_response) assert_failure response - assert_match /70000: 70077/, response.error_code + assert_match(/70000: 70077/, response.error_code) end def test_supported_countries diff --git a/test/unit/gateways/credorax_test.rb b/test/unit/gateways/credorax_test.rb index c204f9664b0..a5e2f009913 100644 --- a/test/unit/gateways/credorax_test.rb +++ b/test/unit/gateways/credorax_test.rb @@ -219,7 +219,7 @@ def test_supports_billing_descriptor stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| - assert_match /i2=abcdefghijkl/, data + assert_match(/i2=abcdefghijkl/, data) end.respond_with(successful_purchase_response) end diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb index d37bc29d476..8b4dabe78c2 100644 --- a/test/unit/gateways/optimal_payment_test.rb +++ b/test/unit/gateways/optimal_payment_test.rb @@ -439,14 +439,14 @@ def post_scrubbed end def pre_scrubbed_double_escaped - <<-PRE_SCRUBBED -txnMode=ccPurchase&txnRequest=%3CccAuthRequestV1+xmlns%3D%22http%3A%2F%2Fwww.optimalpayments.com%2Fcreditcard%2Fxmlschema%2Fv1%22+xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22+xsi%3AschemaLocation%3D%22http%3A%2F%2Fwww.optimalpayments.com%2Fcreditcard%2Fxmlschema%2Fv1%22%3E%0A++%3CmerchantAccount%3E%0A++++%3CaccountNum%3E89986098%3C%2FaccountNum%3E%0A++++%3CstoreID%3Etest%3C%2FstoreID%3E%0A++++%3CstorePwd%3Etest%3C%2FstorePwd%3E%0A++%3C%2FmerchantAccount%3E%0A++%3CmerchantRefNum%3E1%3C%2FmerchantRefNum%3E%0A++%3Camount%3E1.0%3C%2Famount%3E%0A++%3Ccard%3E%0A++++%3CcardNum%3E4387751111011%3C%2FcardNum%3E%0A++++%3CcardExpiry%3E%0A++++++%3Cmonth%3E9%3C%2Fmonth%3E%0A++++++%3Cyear%3E2015%3C%2Fyear%3E%0A++++%3C%2FcardExpiry%3E%0A++++%3CcardType%3EVI%3C%2FcardType%3E%0A++++%3CcvdIndicator%3E1%3C%2FcvdIndicator%3E%0A++++%3Ccvd%3E123%3C%2Fcvd%3E%0A++%3C%2Fcard%3E%0A++%3CbillingDetails%3E%0A++++%3CcardPayMethod%3EWEB%3C%2FcardPayMethod%3E%0A++++%3CfirstName%3EJim%3C%2FfirstName%3E%0A++++%3ClastName%3ESmith%3C%2FlastName%3E%0A++++%3Cstreet%3E1234+My+Street%3C%2Fstreet%3E%0A++++%3Cstreet2%3EApt+1%3C%2Fstreet2%3E%0A++++%3Ccity%3EOttawa%3C%2Fcity%3E%0A++++%3Cstate%3EON%3C%2Fstate%3E%0A++++%3Ccountry%3ECA%3C%2Fcountry%3E%0A++++%3Czip%3EK1C2N6%3C%2Fzip%3E%0A++++%3Cphone%3E%28555%29555-5555%3C%2Fphone%3E%0A++++%3Cemail%3Eemail%40example.com%3C%2Femail%3E%0A++%3C%2FbillingDetails%3E%0A++%3CcustomerIP%3E1.2.3.4%3C%2FcustomerIP%3E%0A%3C%2FccAuthRequestV1%3E%0A - PRE_SCRUBBED -end + <<-PRE_SCRUBBED + txnMode=ccPurchase&txnRequest=%3CccAuthRequestV1+xmlns%3D%22http%3A%2F%2Fwww.optimalpayments.com%2Fcreditcard%2Fxmlschema%2Fv1%22+xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22+xsi%3AschemaLocation%3D%22http%3A%2F%2Fwww.optimalpayments.com%2Fcreditcard%2Fxmlschema%2Fv1%22%3E%0A++%3CmerchantAccount%3E%0A++++%3CaccountNum%3E89986098%3C%2FaccountNum%3E%0A++++%3CstoreID%3Etest%3C%2FstoreID%3E%0A++++%3CstorePwd%3Etest%3C%2FstorePwd%3E%0A++%3C%2FmerchantAccount%3E%0A++%3CmerchantRefNum%3E1%3C%2FmerchantRefNum%3E%0A++%3Camount%3E1.0%3C%2Famount%3E%0A++%3Ccard%3E%0A++++%3CcardNum%3E4387751111011%3C%2FcardNum%3E%0A++++%3CcardExpiry%3E%0A++++++%3Cmonth%3E9%3C%2Fmonth%3E%0A++++++%3Cyear%3E2015%3C%2Fyear%3E%0A++++%3C%2FcardExpiry%3E%0A++++%3CcardType%3EVI%3C%2FcardType%3E%0A++++%3CcvdIndicator%3E1%3C%2FcvdIndicator%3E%0A++++%3Ccvd%3E123%3C%2Fcvd%3E%0A++%3C%2Fcard%3E%0A++%3CbillingDetails%3E%0A++++%3CcardPayMethod%3EWEB%3C%2FcardPayMethod%3E%0A++++%3CfirstName%3EJim%3C%2FfirstName%3E%0A++++%3ClastName%3ESmith%3C%2FlastName%3E%0A++++%3Cstreet%3E1234+My+Street%3C%2Fstreet%3E%0A++++%3Cstreet2%3EApt+1%3C%2Fstreet2%3E%0A++++%3Ccity%3EOttawa%3C%2Fcity%3E%0A++++%3Cstate%3EON%3C%2Fstate%3E%0A++++%3Ccountry%3ECA%3C%2Fcountry%3E%0A++++%3Czip%3EK1C2N6%3C%2Fzip%3E%0A++++%3Cphone%3E%28555%29555-5555%3C%2Fphone%3E%0A++++%3Cemail%3Eemail%40example.com%3C%2Femail%3E%0A++%3C%2FbillingDetails%3E%0A++%3CcustomerIP%3E1.2.3.4%3C%2FcustomerIP%3E%0A%3C%2FccAuthRequestV1%3E%0A + PRE_SCRUBBED + end -def post_scrubbed_double_escaped - <<-POST_SCRUBBED -txnMode=ccPurchase&txnRequest=%3CccAuthRequestV1+xmlns%3D%22http%3A%2F%2Fwww.optimalpayments.com%2Fcreditcard%2Fxmlschema%2Fv1%22+xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22+xsi%3AschemaLocation%3D%22http%3A%2F%2Fwww.optimalpayments.com%2Fcreditcard%2Fxmlschema%2Fv1%22%3E%0A++%3CmerchantAccount%3E%0A++++%3CaccountNum%3E89986098%3C%2FaccountNum%3E%0A++++%3CstoreID%3Etest%3C%2FstoreID%3E%0A++++%3CstorePwd%3E[FILTERED]%3C%2FstorePwd%3E%0A++%3C%2FmerchantAccount%3E%0A++%3CmerchantRefNum%3E1%3C%2FmerchantRefNum%3E%0A++%3Camount%3E1.0%3C%2Famount%3E%0A++%3Ccard%3E%0A++++%3CcardNum%3E[FILTERED]%3C%2FcardNum%3E%0A++++%3CcardExpiry%3E%0A++++++%3Cmonth%3E9%3C%2Fmonth%3E%0A++++++%3Cyear%3E2015%3C%2Fyear%3E%0A++++%3C%2FcardExpiry%3E%0A++++%3CcardType%3EVI%3C%2FcardType%3E%0A++++%3CcvdIndicator%3E1%3C%2FcvdIndicator%3E%0A++++%3Ccvd%3E[FILTERED]%3C%2Fcvd%3E%0A++%3C%2Fcard%3E%0A++%3CbillingDetails%3E%0A++++%3CcardPayMethod%3EWEB%3C%2FcardPayMethod%3E%0A++++%3CfirstName%3EJim%3C%2FfirstName%3E%0A++++%3ClastName%3ESmith%3C%2FlastName%3E%0A++++%3Cstreet%3E1234+My+Street%3C%2Fstreet%3E%0A++++%3Cstreet2%3EApt+1%3C%2Fstreet2%3E%0A++++%3Ccity%3EOttawa%3C%2Fcity%3E%0A++++%3Cstate%3EON%3C%2Fstate%3E%0A++++%3Ccountry%3ECA%3C%2Fcountry%3E%0A++++%3Czip%3EK1C2N6%3C%2Fzip%3E%0A++++%3Cphone%3E%28555%29555-5555%3C%2Fphone%3E%0A++++%3Cemail%3Eemail%40example.com%3C%2Femail%3E%0A++%3C%2FbillingDetails%3E%0A++%3CcustomerIP%3E1.2.3.4%3C%2FcustomerIP%3E%0A%3C%2FccAuthRequestV1%3E%0A - POST_SCRUBBED -end + def post_scrubbed_double_escaped + <<-POST_SCRUBBED + txnMode=ccPurchase&txnRequest=%3CccAuthRequestV1+xmlns%3D%22http%3A%2F%2Fwww.optimalpayments.com%2Fcreditcard%2Fxmlschema%2Fv1%22+xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22+xsi%3AschemaLocation%3D%22http%3A%2F%2Fwww.optimalpayments.com%2Fcreditcard%2Fxmlschema%2Fv1%22%3E%0A++%3CmerchantAccount%3E%0A++++%3CaccountNum%3E89986098%3C%2FaccountNum%3E%0A++++%3CstoreID%3Etest%3C%2FstoreID%3E%0A++++%3CstorePwd%3E[FILTERED]%3C%2FstorePwd%3E%0A++%3C%2FmerchantAccount%3E%0A++%3CmerchantRefNum%3E1%3C%2FmerchantRefNum%3E%0A++%3Camount%3E1.0%3C%2Famount%3E%0A++%3Ccard%3E%0A++++%3CcardNum%3E[FILTERED]%3C%2FcardNum%3E%0A++++%3CcardExpiry%3E%0A++++++%3Cmonth%3E9%3C%2Fmonth%3E%0A++++++%3Cyear%3E2015%3C%2Fyear%3E%0A++++%3C%2FcardExpiry%3E%0A++++%3CcardType%3EVI%3C%2FcardType%3E%0A++++%3CcvdIndicator%3E1%3C%2FcvdIndicator%3E%0A++++%3Ccvd%3E[FILTERED]%3C%2Fcvd%3E%0A++%3C%2Fcard%3E%0A++%3CbillingDetails%3E%0A++++%3CcardPayMethod%3EWEB%3C%2FcardPayMethod%3E%0A++++%3CfirstName%3EJim%3C%2FfirstName%3E%0A++++%3ClastName%3ESmith%3C%2FlastName%3E%0A++++%3Cstreet%3E1234+My+Street%3C%2Fstreet%3E%0A++++%3Cstreet2%3EApt+1%3C%2Fstreet2%3E%0A++++%3Ccity%3EOttawa%3C%2Fcity%3E%0A++++%3Cstate%3EON%3C%2Fstate%3E%0A++++%3Ccountry%3ECA%3C%2Fcountry%3E%0A++++%3Czip%3EK1C2N6%3C%2Fzip%3E%0A++++%3Cphone%3E%28555%29555-5555%3C%2Fphone%3E%0A++++%3Cemail%3Eemail%40example.com%3C%2Femail%3E%0A++%3C%2FbillingDetails%3E%0A++%3CcustomerIP%3E1.2.3.4%3C%2FcustomerIP%3E%0A%3C%2FccAuthRequestV1%3E%0A + POST_SCRUBBED + end end From e1bba0b4cf17dcb5202242987e9256695094088e Mon Sep 17 00:00:00 2001 From: Bart de Water <bartdewater@gmail.com> Date: Thu, 12 Apr 2018 15:08:31 -0400 Subject: [PATCH 454/677] Remove iDeal references iDeal is a Dutch offsite payment method and belongs in https://github.com/activemerchant/offsite_payments --- CHANGELOG | 1 + .../billing/gateways/ideal/ideal_base.rb | 246 -------------- .../billing/gateways/ideal/ideal_rabobank.pem | 13 - .../billing/gateways/ideal/ideal_response.rb | 29 -- .../billing/gateways/ideal_rabobank.rb | 66 ---- test/fixtures.yml | 12 - .../gateways/remote_ideal_rabobank_test.rb | 121 ------- test/unit/gateways/ideal_rabobank_test.rb | 320 ------------------ 8 files changed, 1 insertion(+), 807 deletions(-) delete mode 100644 lib/active_merchant/billing/gateways/ideal/ideal_base.rb delete mode 100644 lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem delete mode 100644 lib/active_merchant/billing/gateways/ideal/ideal_response.rb delete mode 100644 lib/active_merchant/billing/gateways/ideal_rabobank.rb delete mode 100644 test/remote/gateways/remote_ideal_rabobank_test.rb delete mode 100644 test/unit/gateways/ideal_rabobank_test.rb diff --git a/CHANGELOG b/CHANGELOG index 5f9aef015ce..919f98a9bfa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -25,6 +25,7 @@ * JetPay: fix typo in error messages [reynhout] #2749 * Braintree: add support for Maestro cards [matthewheath] #2571 * Visanet Peru: Refund on unsettled transactions [nfarve] #2772 +* Remove iDeal offsite gateway references [bdewater] #2807 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/ideal/ideal_base.rb b/lib/active_merchant/billing/gateways/ideal/ideal_base.rb deleted file mode 100644 index 2ee6d04eb01..00000000000 --- a/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +++ /dev/null @@ -1,246 +0,0 @@ -require 'active_merchant/billing/gateways/ideal/ideal_response' - -module ActiveMerchant #:nodoc: - module Billing #:nodoc: - # Implementation contains some simplifications - # - does not support multiple subID per merchant - # - language is fixed to 'nl' - class IdealBaseGateway < Gateway - class_attribute :server_pem, :pem_password, :default_expiration_period - self.default_expiration_period = 'PT10M' - self.default_currency = 'EUR' - self.pem_password = true - - self.abstract_class = true - - # These constants will never change for most users - AUTHENTICATION_TYPE = 'SHA1_RSA' - LANGUAGE = 'nl' - SUB_ID = '0' - API_VERSION = '1.1.0' - - def initialize(options = {}) - requires!(options, :login, :password, :pem) - - options[:pem_password] = options[:password] - super - end - - # Setup transaction. Get redirect_url from response.service_url - def setup_purchase(money, options = {}) - requires!(options, :issuer_id, :return_url, :order_id, :currency, :description, :entrance_code) - - commit(build_transaction_request(money, options)) - end - - # Check status of transaction and confirm payment - # transaction_id must be a valid transaction_id from a prior setup. - def capture(transaction, options = {}) - options[:transaction_id] = transaction - commit(build_status_request(options)) - end - - # Get list of issuers from response.issuer_list - def issuers - commit(build_directory_request) - end - - private - - def url - (test? ? test_url : live_url) - end - - def token - @token ||= create_fingerprint(@options[:pem]) - end - - # <?xml version="1.0" encoding="UTF-8"?> - # <AcquirerTrxReq xmlns="http://www.idealdesk.com/Message" version="1.1.0"> - # <createDateTimeStamp>2001-12-17T09:30:47.0Z</createDateTimeStamp> - # <Issuer> - # <issuerID>1003</issuerID> - # </Issuer> - # <Merchant> - # <merchantID>000123456</merchantID> - # <subID>0</subID> - # <authentication>passkey</authentication> - # <token>1</token> - # <tokenCode>3823ad872eff23</tokenCode> - # <merchantReturnURL>https://www.mijnwinkel.nl/betaalafhandeling - # </merchantReturnURL> - # </Merchant> - # <Transaction> - # <purchaseID>iDEAL-aankoop 21</purchaseID> - # <amount>5999</amount> - # <currency>EUR</currency> - # <expirationPeriod>PT3M30S</expirationPeriod> - # <language>nl</language> - # <description>Documentensuite</description> - # <entranceCode>D67tyx6rw9IhY71</entranceCode> - # </Transaction> - # </AcquirerTrxReq> - def build_transaction_request(money, options) - date_time_stamp = create_time_stamp - message = date_time_stamp + - options[:issuer_id] + - @options[:login] + - SUB_ID + - options[:return_url] + - options[:order_id] + - money.to_s + - (options[:currency] || currency(money)) + - LANGUAGE + - options[:description] + - options[:entrance_code] - token_code = sign_message(@options[:pem], @options[:password], message) - - xml = Builder::XmlMarkup.new(:indent => 2) - xml.instruct! - xml.tag! 'AcquirerTrxReq', 'xmlns' => 'http://www.idealdesk.com/Message', 'version' => API_VERSION do - xml.tag! 'createDateTimeStamp', date_time_stamp - xml.tag! 'Issuer' do - xml.tag! 'issuerID', options[:issuer_id] - end - xml.tag! 'Merchant' do - xml.tag! 'merchantID', @options[:login] - xml.tag! 'subID', SUB_ID - xml.tag! 'authentication', AUTHENTICATION_TYPE - xml.tag! 'token', token - xml.tag! 'tokenCode', token_code - xml.tag! 'merchantReturnURL', options[:return_url] - end - xml.tag! 'Transaction' do - xml.tag! 'purchaseID', options[:order_id] - xml.tag! 'amount', money - xml.tag! 'currency', options[:currency] - xml.tag! 'expirationPeriod', options[:expiration_period] || default_expiration_period - xml.tag! 'language', LANGUAGE - xml.tag! 'description', options[:description] - xml.tag! 'entranceCode', options[:entrance_code] - end - xml.target! - end - end - - # <?xml version="1.0" encoding="UTF-8"?> - # <AcquirerStatusReq xmlns="http://www.idealdesk.com/Message" version="1.1.0"> - # <createDateTimeStamp>2001-12-17T09:30:47.0Z</createDateTimeStamp> - # <Merchant> - # <merchantID>000123456</merchantID> - # <subID>0</subID> - # <authentication>keyed hash</authentication> - # <token>1</token> - # <tokenCode>3823ad872eff23</tokenCode> - # </Merchant> - # <Transaction> - # <transactionID>0001023456789112</transactionID> - # </Transaction> - # </AcquirerStatusReq> - def build_status_request(options) - datetimestamp = create_time_stamp - message = datetimestamp + @options[:login] + SUB_ID + options[:transaction_id] - tokenCode = sign_message(@options[:pem], @options[:password], message) - - xml = Builder::XmlMarkup.new(:indent => 2) - xml.instruct! - xml.tag! 'AcquirerStatusReq', 'xmlns' => 'http://www.idealdesk.com/Message', 'version' => API_VERSION do - xml.tag! 'createDateTimeStamp', datetimestamp - xml.tag! 'Merchant' do - xml.tag! 'merchantID', @options[:login] - xml.tag! 'subID', SUB_ID - xml.tag! 'authentication' , AUTHENTICATION_TYPE - xml.tag! 'token', token - xml.tag! 'tokenCode', tokenCode - end - xml.tag! 'Transaction' do - xml.tag! 'transactionID', options[:transaction_id] - end - end - xml.target! - end - - # <?xml version="1.0" encoding="UTF-8"?> - # <DirectoryReq xmlns="http://www.idealdesk.com/Message" version="1.1.0"> - # <createDateTimeStamp>2001-12-17T09:30:47.0Z</createDateTimeStamp> - # <Merchant> - # <merchantID>000000001</merchantID> - # <subID>0</subID> - # <authentication>1</authentication> - # <token>hashkey</token> - # <tokenCode>WajqV1a3nDen0be2r196g9FGFF=</tokenCode> - # </Merchant> - # </DirectoryReq> - def build_directory_request - datetimestamp = create_time_stamp - message = datetimestamp + @options[:login] + SUB_ID - tokenCode = sign_message(@options[:pem], @options[:password], message) - - xml = Builder::XmlMarkup.new(:indent => 2) - xml.instruct! - xml.tag! 'DirectoryReq', 'xmlns' => 'http://www.idealdesk.com/Message', 'version' => API_VERSION do - xml.tag! 'createDateTimeStamp', datetimestamp - xml.tag! 'Merchant' do - xml.tag! 'merchantID', @options[:login] - xml.tag! 'subID', SUB_ID - xml.tag! 'authentication', AUTHENTICATION_TYPE - xml.tag! 'token', token - xml.tag! 'tokenCode', tokenCode - end - end - xml.target! - end - - def commit(request) - raw_response = ssl_post(url, request) - response = Hash.from_xml(raw_response.to_s) - response_type = response.keys[0] - - case response_type - when 'AcquirerTrxRes', 'DirectoryRes' - success = true - when 'ErrorRes' - success = false - when 'AcquirerStatusRes' - raise SecurityError, "Message verification failed.", caller unless status_response_verified?(response) - success = (response['AcquirerStatusRes']['Transaction']['status'] == 'Success') - else - raise ArgumentError, "Unknown response type.", caller - end - - return IdealResponse.new(success, response.keys[0], response, :test => test?) - end - - def create_fingerprint(cert_file) - cert_data = OpenSSL::X509::Certificate.new(cert_file).to_s - cert_data = cert_data.sub(/-----BEGIN CERTIFICATE-----/, '') - cert_data = cert_data.sub(/-----END CERTIFICATE-----/, '') - fingerprint = Base64.decode64(cert_data) - fingerprint = Digest::SHA1.hexdigest(fingerprint) - return fingerprint.upcase - end - - def sign_message(private_key_data, password, data) - private_key = OpenSSL::PKey::RSA.new(private_key_data, password) - signature = private_key.sign(OpenSSL::Digest::SHA1.new, data.gsub('\s', '')) - return Base64.encode64(signature).gsub(/\n/, '') - end - - def verify_message(cert_file, data, signature) - public_key = OpenSSL::X509::Certificate.new(cert_file).public_key - return public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(signature), data) - end - - def status_response_verified?(response) - transaction = response['AcquirerStatusRes']['Transaction'] - message = response['AcquirerStatusRes']['createDateTimeStamp'] + transaction['transactionID' ] + transaction['status'] - message << transaction['consumerAccountNumber'].to_s - verify_message(server_pem, message, response['AcquirerStatusRes']['Signature']['signatureValue']) - end - - def create_time_stamp - Time.now.gmtime.strftime('%Y-%m-%dT%H:%M:%S.000Z') - end - end - end -end diff --git a/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem b/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem deleted file mode 100644 index 3259cfa330a..00000000000 --- a/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +++ /dev/null @@ -1,13 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICQDCCAakCBELvbPYwDQYJKoZIhvcNAQEEBQAwZzELMAkGA1UEBhMCREUxDzANBgNVBAgTBkhl -c3NlbjESMBAGA1UEBxMJRnJhbmtmdXJ0MQ4wDAYDVQQKEwVpREVBTDEOMAwGA1UECxMFaURFQUwx -EzARBgNVBAMTCmlERUFMIFJhYm8wHhcNMDUwODAyMTI1NDE0WhcNMTUwNzMxMTI1NDE0WjBnMQsw -CQYDVQQGEwJERTEPMA0GA1UECBMGSGVzc2VuMRIwEAYDVQQHEwlGcmFua2Z1cnQxDjAMBgNVBAoT -BWlERUFMMQ4wDAYDVQQLEwVpREVBTDETMBEGA1UEAxMKaURFQUwgUmFibzCBnzANBgkqhkiG9w0B -AQEFAAOBjQAwgYkCgYEA486iIKVhr8RNjxH+PZ3yTWx/8k2fqDFm8XU8I1Z5esRmPFnXmlgA8cG7 -e9AaBPaLoP7Dc8dRQoUO66KMakzGI/WAVdHIJiiKrz8xOcioIgrzPSqec7aqse3J28UraEHkGESJ -7dAW7Pw/shrmpmkzKsunLt6AkXss4W3JUndZUN0CAwEAATANBgkqhkiG9w0BAQQFAAOBgQCGy/FK -Lotp2ZOTtuLMgvDy74eicq/Znv4bLfpglzAPHycRHcHsXuer/lNHyvpKf2gdYe+IFalUW3OJZWIM -jpm4UniJ16RPdgwWVRJEdPr/P7JXMIqD2IEOgujuuTQ7x0VgCf9XrsPsP9ZR5DIPcDDhbrpSE0yF -Do77nwG61xMaGA== ------END CERTIFICATE----- diff --git a/lib/active_merchant/billing/gateways/ideal/ideal_response.rb b/lib/active_merchant/billing/gateways/ideal/ideal_response.rb deleted file mode 100644 index e050964ae40..00000000000 --- a/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +++ /dev/null @@ -1,29 +0,0 @@ -module ActiveMerchant #:nodoc: - module Billing #:nodoc: - class IdealResponse < Response - - def issuer_list - list = @params.values[0]['Directory']['Issuer'] - case list - when Hash - return [list] - when Array - return list - end - end - - def service_url - @params.values[0]['Issuer']['issuerAuthenticationURL'] - end - - def transaction - @params.values[0]['Transaction'] - end - - def error - @params.values[0]['Error'] - end - - end - end -end \ No newline at end of file diff --git a/lib/active_merchant/billing/gateways/ideal_rabobank.rb b/lib/active_merchant/billing/gateways/ideal_rabobank.rb deleted file mode 100644 index bc2707adb04..00000000000 --- a/lib/active_merchant/billing/gateways/ideal_rabobank.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'active_merchant/billing/gateways/ideal/ideal_base' - -module ActiveMerchant #:nodoc: - module Billing #:nodoc: - # First, make sure you have everything setup correctly and all of your dependencies in place with: - # - # require 'rubygems' - # require 'active_merchant' - # - # ActiveMerchant expects the amounts to be given as an Integer in cents. In this case, 10 EUR becomes 1000. - # - # Create certificates for authentication: - # - # The PEM file expected should contain both the certificate and the generated PEM file. - # Some sample shell commands to generate the certificates: - # - # openssl genrsa -aes128 -out priv.pem -passout pass:[YOUR PASSWORD] 1024 - # openssl req -x509 -new -key priv.pem -passin pass:[YOUR PASSWORD] -days 3000 -out cert.cer - # cat cert.cer priv.pem > ideal.pem - # - # Following the steps above, upload cert.cer to the ideal web interface and pass the path of ideal.pem to the :pem option. - # - # Configure the gateway using your iDEAL bank account info and security settings: - # - # Create gateway: - # gateway = ActiveMerchant::Billing::IdealRabobankGateway.new( - # :login => '123456789', # 9 digit merchant number - # :pem => File.read(Rails.root + 'config/ideal.pem'), - # :password => 'password' # password for the PEM key - # ) - # - # Get list of issuers to fill selection list on your payment form: - # response = gateway.issuers - # list = response.issuer_list - # - # Request transaction: - # - # options = { - # :issuer_id => '0001', - # :expiration_period => 'PT10M', - # :return_url => 'http://www.return.url', - # :order_id => '1234567890123456', - # :currency => 'EUR', - # :description => 'Een omschrijving', - # :entrance_code => '1234' - # } - # - # response = gateway.setup_purchase(amount, options) - # transaction_id = response.transaction['transactionID'] - # redirect_url = response.service_url - # - # Mandatory status request will confirm transaction: - # response = gateway.capture(transaction_id) - # - # Implementation contains some simplifications - # - does not support multiple subID per merchant - # - language is fixed to 'nl' - class IdealRabobankGateway < IdealBaseGateway - class_attribute :test_url, :live_url - - self.test_url = 'https://idealtest.rabobank.nl/ideal/iDeal' - self.live_url = 'https://ideal.rabobank.nl/ideal/iDeal' - self.server_pem = File.read(File.dirname(__FILE__) + '/ideal/ideal_rabobank.pem') - end - end -end diff --git a/test/fixtures.yml b/test/fixtures.yml index bbbf30d5631..c14a40480aa 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -376,15 +376,6 @@ iats_payments: password: TEST88 region: na -# login: merchant number -# password: password for the PEM secret key -# pem: public certificate and PEM secret key -ideal_rabobank: - login: LOGIN - password: PASSWORD - pem: | - PASTE YOUR PEM FILE HERE - inspire: login: demo password: password @@ -508,9 +499,6 @@ modern_payments: login: login password: password -mollie_ideal: - api_key: 'test_8isBjQoJXJoiXRSzjhwKPO1Bo9AkVA' - # Working credentials, no need to replace monei: sender_id: 8a829417488d34c401489a5cd1350977 diff --git a/test/remote/gateways/remote_ideal_rabobank_test.rb b/test/remote/gateways/remote_ideal_rabobank_test.rb deleted file mode 100644 index c2ecf00231c..00000000000 --- a/test/remote/gateways/remote_ideal_rabobank_test.rb +++ /dev/null @@ -1,121 +0,0 @@ -require 'test_helper' - -class RemoteIdealRabobankTest < Test::Unit::TestCase - def setup - Base.mode = :test - - @gateway = IdealRabobankGateway.new(fixtures(:ideal_rabobank)) - - @options = { - :issuer_id => '0151', - :return_url => 'http://www.return.url', - :order_id => '1234567890123456', - :currency => 'EUR', - :description => 'A description', - :entrance_code => '1234' - } - end - - def test_issuers - response = @gateway.issuers - list = response.issuer_list - - assert_equal 3, list.length - assert_equal 'Test Issuer', list[0]['issuerName'] - assert_equal '0121', list[0]['issuerID'] - assert_equal 'Short', list[0]['issuerList'] - end - - - def test_set_purchase - response = @gateway.setup_purchase(550, @options) - - assert_success response - assert response.test? - assert_nil response.error, "Response should not have an error" - end - - def test_return_errors - response = @gateway.setup_purchase(0.5, @options) - assert_failure response - assert_equal 'BR1210', response.error[ 'errorCode'] - assert_not_nil response.error['errorMessage'], "Response should contain an Error message" - assert_not_nil response.error['errorDetail'], "Response should contain an Error Detail message" - assert_not_nil response.error['consumerMessage'],"Response should contain an Consumer Error message" - end - - # default payment should succeed - def test_purchase_successful - response = @gateway.setup_purchase(100, @options) - - assert_success response - - assert_equal '1234567890123456', response.transaction['purchaseID'] - assert_equal '0020', response.params['AcquirerTrxRes']['Acquirer']['acquirerID'] - assert_not_nil response.service_url, "Response should contain a service url for payment" - - # now authorize the payment, issuer simulator has completed the payment - response = @gateway.capture(response.transaction['transactionID']) - - assert_success response - assert_equal 'Success', response.transaction['status'] - assert_equal 'DEN HAAG', response.transaction['consumerCity'] - assert_equal "Hr J A T Verf\303\274rth en/of Mw T V Chet", response.transaction['consumerName'] - end - - # payment of 200 should cancel - def test_purchase_cancel - response = @gateway.setup_purchase(200, @options) - - assert_success response - # now try to authorize the payment, issuer simulator has cancelled the payment - response = @gateway.capture(response.transaction['transactionID']) - - assert_failure response - assert_equal 'Cancelled', response.transaction['status'], 'Transaction should cancel' - end - - # payment of 300 should expire - def test_transaction_expired - response = @gateway.setup_purchase(300, @options) - - # now try to authorize the payment, issuer simulator let the payment expire - response = @gateway.capture(response.transaction['transactionID']) - - assert_failure response - assert_equal 'Expired', response.transaction['status'], 'Transaction should expire' - end - - # payment of 400 should remain open - def test_transaction_opened - response = @gateway.setup_purchase(400, @options) - - # now try to authorize the payment, issuer simulator keeps the payment open - response = @gateway.capture(response.transaction['transactionID']) - - assert_failure response - assert_equal 'Open', response.transaction['status'], 'Transaction should remain open' - end - - # payment of 500 should fail at issuer - def test_transaction_failed - response = @gateway.setup_purchase(500, @options) - - # now try to authorize the payment, issuer simulator lets the payment fail - response = @gateway.capture(response.transaction['transactionID']) - assert_failure response - assert_equal 'Failure', response.transaction['status'], 'Transaction should fail' - end - - # payment of 700 should be unknown at issuer - def test_transaction_unknown - response = @gateway.setup_purchase(700, @options) - - # now try to authorize the payment, issuer simulator lets the payment fail - response = @gateway.capture(response.transaction['transactionID']) - - assert_failure response - assert_equal 'SO1000', response.error[ 'errorCode'], 'ErrorCode should be correct' - end - -end diff --git a/test/unit/gateways/ideal_rabobank_test.rb b/test/unit/gateways/ideal_rabobank_test.rb deleted file mode 100644 index fe777decea0..00000000000 --- a/test/unit/gateways/ideal_rabobank_test.rb +++ /dev/null @@ -1,320 +0,0 @@ -# coding: UTF-8 - -require 'test_helper' - -class IdealRabobankTest < Test::Unit::TestCase - - DEFAULT_IDEAL_OPTIONS = { - :login => '123456789', - :pem => 'PEM', - :password => 'PASSWORD' - } - - def setup - @gateway = IdealRabobankGateway.new(DEFAULT_IDEAL_OPTIONS) - - # stub security methods, so we can run tests without PEM files - @stubbed_time_stamp = '2007-07-02T10:03:18.000Z' - @gateway.stubs(:create_fingerprint).returns('TOKEN') - @gateway.stubs(:sign_message).returns('TOKEN_CODE') - @gateway.stubs(:create_time_stamp).returns(@stubbed_time_stamp) - - @transaction_options = { - :issuer_id => '0001', - :expiration_period => 'PT10M', - :return_url => 'http://www.return.url', - :order_id => '1234567890123456', - :currency => 'EUR', - :description => 'A description', - :entrance_code => '1234' - } - end - - def test_build_transaction_request - request = @gateway.send(:build_transaction_request, 100, @transaction_options) - - xml_request = REXML::Document.new(request) - - assert_ideal_message xml_request, 'AcquirerTrxReq' - assert_merchant_elements xml_request - - assert_equal @transaction_options[:issuer_id], xml_request.root.elements['Issuer/issuerID'].text, 'Should map to an issuerID element.' - assert_equal @transaction_options[:return_url], xml_request.root.elements['Merchant/merchantReturnURL'].text, 'Should map to a merchantReturnURL element.' - assert_equal @transaction_options[:order_id], xml_request.root.elements['Transaction/purchaseID'].text, 'Should map to a purchaseID element.' - assert_equal '100', xml_request.root.elements['Transaction/amount'].text, 'Should map to an amount element.' - assert_equal @transaction_options[:currency], xml_request.root.elements['Transaction/currency'].text, 'Should map to a currency element.' - assert_equal @transaction_options[:expiration_period], xml_request.root.elements['Transaction/expirationPeriod'].text, 'Should map to an expirationPeriod element.' - assert_equal 'nl', xml_request.root.elements['Transaction/language'].text, 'Should map to a language element.' - assert_equal @transaction_options[:description], xml_request.root.elements['Transaction/description'].text, 'Should map to a description element.' - assert_equal @transaction_options[:entrance_code], xml_request.root.elements['Transaction/entranceCode'].text, 'Should map to an entranceCode element.' - end - - def test_build_status_request - request = @gateway.send(:build_status_request, :transaction_id => '1234') - xml_request = REXML::Document.new(request) - - assert_ideal_message xml_request, 'AcquirerStatusReq' - assert_merchant_elements xml_request - - assert_equal '1234', xml_request.root.elements['Transaction/transactionID'].text, 'Should map to a transactionID element.' - end - - def test_build_directory_request - request = @gateway.send(:build_directory_request) - xml_request = REXML::Document.new(request) - - assert_ideal_message xml_request, 'DirectoryReq' - assert_merchant_elements xml_request - end - - def assert_ideal_message xml_request, message_name - assert_equal '1.0', xml_request.version, "Should be version 1.0 of the xml specification" - assert_equal 'UTF-8', xml_request.encoding, "Should be UTF-8 encoding" - assert_equal 'http://www.idealdesk.com/Message', xml_request.root.namespace, "Should have a valid namespace" - assert_equal message_name, xml_request.root.name, "Root should match messagename" - assert_equal '1.1.0', xml_request.root.attribute('version', nil).value, "Should have a ideal version number" - assert_equal @stubbed_time_stamp, xml_request.root.elements['createDateTimeStamp'].text, 'Should have a time stamp.' - end - - def assert_merchant_elements xml_request - assert_equal DEFAULT_IDEAL_OPTIONS[:login], xml_request.root.elements['Merchant/merchantID'].text, 'Should map to an merchantID element.' - assert_equal '0', xml_request.root.elements['Merchant/subID'].text, 'Should map to an subID element.' - assert_equal 'SHA1_RSA', xml_request.root.elements['Merchant/authentication'].text, 'Should map to an authentication element.' - assert_equal 'TOKEN', xml_request.root.elements['Merchant/token'].text, 'Should map to a token element.' - assert_equal 'TOKEN_CODE', xml_request.root.elements['Merchant/tokenCode'].text, 'Should map to a tokenCode element.' - end - - # test incoming messages - - def test_setup_purchase_successful - @gateway.expects(:ssl_post).returns(successful_transaction_response) - response = @gateway.setup_purchase(100, @transaction_options) - assert_success response - transaction = response.transaction - assert_equal '0050000002797923', transaction['transactionID'], 'Should map to transaction_id' - assert_equal '9459897270157938', transaction['purchaseID'], 'Should map to purchase_id' - assert_equal '0050', response.params['AcquirerTrxRes']['Acquirer']['acquirerID'], 'Should map to acquirer_id' - assert_equal 'https://issuer.url/action?trxid=0050000002797923', response.service_url, "Response should have an issuer url" - end - - def test_error_response - @gateway.expects(:ssl_post).returns(failed_transaction_response) - response = @gateway.setup_purchase(100, @transaction_options) - assert_failure response - assert_equal 'ErrorRes', response.message, 'Should return error response' - error = response.error - assert_equal "BR1210", error['errorCode'], "Should return an error code" - assert_equal "Field generating error: Parameter \'25.99\' is not a natural(or \'-\') format", error['errorDetail'], "Should return an error detail" - assert_equal "Value contains non-permitted character", error['errorMessage'], "Should return an error message" - assert_equal "Betalen met iDEAL is nu niet mogelijk. Probeer het later nogmaals of betaal op een andere manier.", error['consumerMessage'], "Should return consumer message" - end - - def test_capture - @gateway.expects(:ssl_post).returns(successful_status_response) - @gateway.expects(:verify_message).returns(true) - - response = @gateway.capture('0050000002807474') - assert_success response - transaction = response.transaction - assert_equal '0050000002807474', transaction['transactionID'], 'Should map to transaction_id' - assert_equal 'C M Bröcker-Meijer en M Bröcker', transaction['consumerName'] - assert_equal 'P001234567', transaction['consumerAccountNumber'] - assert_equal 'DEN HAAG', transaction['consumerCity'] - assert_equal 'Success', transaction['status'], 'Should map to status' - end - - # make sure the gateway does not crash if issuer 'forgets' consumerAcountNumber - def test_capture_with_missing_account_number - @gateway.expects(:ssl_post).returns(successful_status_response_with_missing_fields) - @gateway.expects(:verify_message).returns(true) - - response = @gateway.capture('0050000002807474') - assert_success response - transaction = response.transaction - assert_equal '0050000002807474', transaction['transactionID'], 'Should map to transaction_id' - assert_nil transaction['consumerAccountNumber'] - assert_equal 'Success', transaction['status'], 'Should map to status' - end - - def test_payment_cancelled - @gateway.expects(:ssl_post).returns(cancelled_status_response) - @gateway.expects(:verify_message).returns(true) - - response = @gateway.capture('0050000002807474') - assert_failure response - transaction = response.transaction - assert_equal '0050000002807474', transaction['transactionID'], 'Should map to transaction_id' - assert_equal 'Cancelled', transaction['status'], 'Should map to status' - end - - def test_issuers_multiple - @gateway.expects(:ssl_post).returns(directory_request_response) - response = @gateway.issuers - assert_success response - list = response.issuer_list - assert_equal 4, list.size, "Should return multiple issuers" - assert_equal '0031', list[0]['issuerID'], "Should return an issuerID" - end - - def test_issuers_one_issuer - @gateway.expects(:ssl_post).returns(directory_request_response_one_issuer) - response = @gateway.issuers - assert_success response - list = response.issuer_list - assert_equal 1, list.size, "Should return one issuer" - assert_equal '0031', list[0]['issuerID'], "Should return an issuerID" - end - - def successful_transaction_response - <<-RESPONSE -<?xml version='1.0' encoding='UTF-8'?> -<AcquirerTrxRes version='1.1.0' xmlns='http://www.idealdesk.com/Message'> - <createDateTimeStamp>2007-07-02T10:03:18.000Z</createDateTimeStamp> - <Acquirer> - <acquirerID>0050</acquirerID> - </Acquirer> - <Issuer> - <issuerAuthenticationURL>https://issuer.url/action?trxid=0050000002797923</issuerAuthenticationURL> - </Issuer> - <Transaction> - <transactionID>0050000002797923</transactionID> - <purchaseID>9459897270157938</purchaseID> - </Transaction> -</AcquirerTrxRes> - RESPONSE - end - - def failed_transaction_response - <<-RESPONSE -<?xml version='1.0' encoding='UTF-8'?> - <ErrorRes version='1.1.0' xmlns='http://www.idealdesk.com/Message'> - <createDateTimeStamp>2007-07-02T10:03:18.000Z</createDateTimeStamp> - <Error> - <errorCode>BR1210</errorCode> - <errorMessage>Value contains non-permitted character</errorMessage> - <errorDetail>Field generating error: Parameter &apos;25.99&apos; is not a natural(or &apos;-&apos;) format</errorDetail> - <consumerMessage>Betalen met iDEAL is nu niet mogelijk. Probeer het later nogmaals of betaal op een andere manier.</consumerMessage> - </Error> -</ErrorRes> - RESPONSE - end - - def successful_status_response - <<-RESPONSE -?xml version='1.0' encoding='UTF-8'?> -<AcquirerStatusRes version='1.1.0' xmlns='http://www.idealdesk.com/Message'> - <createDateTimeStamp>2007-07-02T10:03:18.000Z</createDateTimeStamp> -<Acquirer> - <acquirerID>0050</acquirerID> -</Acquirer> -<Transaction> - <transactionID>0050000002807474</transactionID> - <status>Success</status> - <consumerName>C M Bröcker-Meijer en M Bröcker</consumerName> - <consumerAccountNumber>P001234567</consumerAccountNumber> - <consumerCity>DEN HAAG</consumerCity> -</Transaction> -<Signature> - <signatureValue>LONGSTRING</signatureValue> - <fingerprint>FINGERPRINT</fingerprint> -</Signature> -</AcquirerStatusRes> - RESPONSE - end - - def successful_status_response_with_missing_fields - <<-RESPONSE -?xml version='1.0' encoding='UTF-8'?> -<AcquirerStatusRes version='1.1.0' xmlns='http://www.idealdesk.com/Message'> - <createDateTimeStamp>2007-07-02T10:03:18.000Z</createDateTimeStamp> -<Acquirer> - <acquirerID>0050</acquirerID> -</Acquirer> -<Transaction> - <transactionID>0050000002807474</transactionID> - <status>Success</status> -</Transaction> -<Signature> - <signatureValue>LONGSTRING</signatureValue> - <fingerprint>FINGERPRINT</fingerprint> -</Signature> -</AcquirerStatusRes> - RESPONSE - end - - def cancelled_status_response - <<-RESPONSE -<?xml version='1.0' encoding='UTF-8'?> -<AcquirerStatusRes version='1.1.0' xmlns='http://www.idealdesk.com/Message'> - <createDateTimeStamp>2007-07-02T10:03:18.000Z</createDateTimeStamp> -<Acquirer> - <acquirerID>0050</acquirerID> -</Acquirer> -<Transaction> - <transactionID>0050000002807474</transactionID> - <status>Cancelled</status> -</Transaction> -<Signature> - <signatureValue>LONGSTRING</signatureValue> - <fingerprint>FINGERPRINT</fingerprint> -</Signature> -</AcquirerStatusRes> - RESPONSE - end - - def directory_request_response - <<-RESPONSE -<?xml version='1.0' encoding='UTF-8'?> -<DirectoryRes version='1.1.0' xmlns='http://www.idealdesk.com/Message'> -<createDateTimeStamp>2007-07-02T10:03:18.000Z</createDateTimeStamp> -<Acquirer> - <acquirerID>0050</acquirerID> -</Acquirer> -<Directory> - <directoryDateTimeStamp>2007-07-02T10:03:18.000Z</directoryDateTimeStamp> - <Issuer> - <issuerID>0031</issuerID> - <issuerName>ABN Amro Bank</issuerName> - <issuerList>Short</issuerList> - </Issuer> - <Issuer> - <issuerID>0721</issuerID> - <issuerName>Postbank</issuerName> - <issuerList>Short</issuerList> - </Issuer> - <Issuer> - <issuerID>0021</issuerID> - <issuerName>Rabobank</issuerName> - <issuerList>Short</issuerList> - </Issuer> - <Issuer> - <issuerID>0751</issuerID> - <issuerName>SNS Bank</issuerName> - <issuerList>Short</issuerList> - </Issuer> -</Directory> -</DirectoryRes> - RESPONSE - end - - def directory_request_response_one_issuer - <<-RESPONSE -<?xml version='1.0' encoding='UTF-8'?> -<DirectoryRes version='1.1.0' xmlns='http://www.idealdesk.com/Message'> -<createDateTimeStamp>2007-07-02T10:03:18.000Z</createDateTimeStamp> -<Acquirer> - <acquirerID>0050</acquirerID> -</Acquirer> -<Directory> - <directoryDateTimeStamp>2007-07-02T10:03:18.000Z</directoryDateTimeStamp> - <Issuer> - <issuerID>0031</issuerID> - <issuerName>ABN Amro Bank</issuerName> - <issuerList>Short</issuerList> - </Issuer> -</Directory> -</DirectoryRes> - RESPONSE - end - -end From 7da1ff6dd2642b62ade84b3feac04e93c0261308 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 26 Jun 2018 13:32:10 -0400 Subject: [PATCH 455/677] Fix Style/StringLiteral violations Yes, I cheated and used rubocop to help with this, but I also did actually audit the result, and it's pretty clean to read through with a good diff tool since no spacing, etc. was changed. My recommendation for review would be to look for and notice the absence of `#{}` in any of the changed strings, meaning that the `"` to `'` conversion is safe. Unit: 3874 tests, 67956 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- .rubocop_todo.yml | 7 - Rakefile | 6 +- activemerchant.gemspec | 6 +- lib/active_merchant.rb | 2 +- lib/active_merchant/billing/check.rb | 8 +- lib/active_merchant/billing/compatibility.rb | 2 +- lib/active_merchant/billing/credit_card.rb | 42 +- .../billing/credit_card_formatting.rb | 4 +- .../billing/credit_card_methods.rb | 4 +- lib/active_merchant/billing/gateway.rb | 26 +- lib/active_merchant/billing/gateways/adyen.rb | 30 +- .../billing/gateways/allied_wallet.rb | 44 +- .../billing/gateways/authorize_net.rb | 144 +++--- .../billing/gateways/authorize_net_arb.rb | 6 +- .../billing/gateways/authorize_net_cim.rb | 6 +- .../billing/gateways/axcessms.rb | 102 ++-- .../billing/gateways/balanced.rb | 58 +-- .../billing/gateways/bank_frick.rb | 6 +- .../billing/gateways/banwire.rb | 16 +- .../billing/gateways/barclaycard_smartpay.rb | 10 +- .../gateways/barclays_epdq_extra_plus.rb | 12 +- .../billing/gateways/be2bill.rb | 4 +- .../billing/gateways/beanstream.rb | 2 +- .../gateways/beanstream/beanstream_core.rb | 138 +++--- .../billing/gateways/blue_pay.rb | 38 +- .../billing/gateways/blue_snap.rb | 84 ++-- lib/active_merchant/billing/gateways/bogus.rb | 18 +- .../billing/gateways/borgun.rb | 18 +- .../billing/gateways/bpoint.rb | 2 +- .../gateways/braintree/braintree_common.rb | 2 +- .../billing/gateways/braintree_blue.rb | 188 ++++---- .../billing/gateways/braintree_orange.rb | 2 +- .../billing/gateways/bridge_pay.rb | 76 +-- lib/active_merchant/billing/gateways/cams.rb | 24 +- .../billing/gateways/card_stream.rb | 232 ++++----- .../billing/gateways/cardknox.rb | 14 +- .../billing/gateways/cardprocess.rb | 2 +- .../billing/gateways/cashnet.rb | 18 +- lib/active_merchant/billing/gateways/cc5.rb | 4 +- .../billing/gateways/cecabank.rb | 12 +- .../billing/gateways/cenpos.rb | 72 +-- .../billing/gateways/checkout.rb | 10 +- .../billing/gateways/checkout_v2.rb | 62 +-- .../billing/gateways/clearhaus.rb | 10 +- .../billing/gateways/commercegate.rb | 12 +- .../billing/gateways/conekta.rb | 26 +- .../billing/gateways/creditcall.rb | 82 ++-- .../billing/gateways/credorax.rb | 206 ++++---- lib/active_merchant/billing/gateways/culqi.rb | 40 +- .../billing/gateways/cyber_source.rb | 130 ++--- .../billing/gateways/data_cash.rb | 8 +- lib/active_merchant/billing/gateways/dibs.rb | 48 +- .../billing/gateways/digitzs.rb | 70 +-- lib/active_merchant/billing/gateways/ebanx.rb | 52 +- .../billing/gateways/efsnet.rb | 20 +- .../billing/gateways/elavon.rb | 6 +- .../billing/gateways/element.rb | 70 +-- lib/active_merchant/billing/gateways/epay.rb | 8 +- .../billing/gateways/evo_ca.rb | 2 +- lib/active_merchant/billing/gateways/eway.rb | 130 ++--- .../billing/gateways/eway_managed.rb | 22 +- .../billing/gateways/eway_rapid.rb | 62 +-- lib/active_merchant/billing/gateways/exact.rb | 24 +- lib/active_merchant/billing/gateways/ezic.rb | 26 +- .../billing/gateways/fat_zebra.rb | 48 +- .../billing/gateways/federated_canada.rb | 6 +- .../billing/gateways/first_giving.rb | 32 +- .../billing/gateways/first_pay.rb | 2 +- .../billing/gateways/firstdata_e4.rb | 142 +++--- .../billing/gateways/flo2cash.rb | 24 +- .../billing/gateways/flo2cash_simple.rb | 2 +- lib/active_merchant/billing/gateways/forte.rb | 26 +- .../billing/gateways/garanti.rb | 14 +- .../billing/gateways/global_collect.rb | 176 +++---- .../billing/gateways/global_transport.rb | 8 +- lib/active_merchant/billing/gateways/hdfc.rb | 66 +-- lib/active_merchant/billing/gateways/hps.rb | 56 +-- .../billing/gateways/iats_payments.rb | 52 +- .../billing/gateways/inspire.rb | 30 +- .../billing/gateways/instapay.rb | 8 +- lib/active_merchant/billing/gateways/ipp.rb | 34 +- .../billing/gateways/iridium.rb | 414 ++++++++-------- lib/active_merchant/billing/gateways/iveri.rb | 16 +- .../billing/gateways/jetpay.rb | 268 +++++------ .../billing/gateways/jetpay_v2.rb | 282 +++++------ .../billing/gateways/komoju.rb | 30 +- .../billing/gateways/kushki.rb | 60 +-- .../billing/gateways/latitude19.rb | 128 ++--- .../billing/gateways/linkpoint.rb | 44 +- lib/active_merchant/billing/gateways/litle.rb | 4 +- .../billing/gateways/mastercard.rb | 6 +- .../billing/gateways/maxipago.rb | 4 +- .../billing/gateways/mercado_pago.rb | 56 +-- .../billing/gateways/merchant_e_solutions.rb | 18 +- .../billing/gateways/merchant_one.rb | 12 +- .../billing/gateways/merchant_partners.rb | 48 +- .../billing/gateways/merchant_ware.rb | 98 ++-- .../gateways/merchant_ware_version_four.rb | 72 +-- .../billing/gateways/merchant_warrior.rb | 8 +- .../billing/gateways/mercury.rb | 56 +-- .../billing/gateways/metrics_global.rb | 14 +- .../billing/gateways/micropayment.rb | 62 +-- lib/active_merchant/billing/gateways/migs.rb | 16 +- .../billing/gateways/modern_payments.rb | 2 +- .../billing/gateways/modern_payments_cim.rb | 32 +- lib/active_merchant/billing/gateways/monei.rb | 10 +- .../billing/gateways/moneris.rb | 52 +- .../billing/gateways/moneris_us.rb | 60 +-- .../billing/gateways/money_movers.rb | 6 +- .../billing/gateways/nab_transact.rb | 12 +- .../billing/gateways/ncr_secure_pay.rb | 6 +- .../billing/gateways/netaxept.rb | 30 +- .../billing/gateways/netbanx.rb | 4 +- .../billing/gateways/netbilling.rb | 2 +- .../billing/gateways/netpay.rb | 10 +- lib/active_merchant/billing/gateways/nmi.rb | 36 +- lib/active_merchant/billing/gateways/ogone.rb | 44 +- lib/active_merchant/billing/gateways/omise.rb | 4 +- .../billing/gateways/openpay.rb | 8 +- lib/active_merchant/billing/gateways/opp.rb | 6 +- .../billing/gateways/optimal_payment.rb | 4 +- .../billing/gateways/orbital.rb | 122 ++--- .../orbital/orbital_soft_descriptors.rb | 8 +- .../billing/gateways/pac_net_raven.rb | 10 +- .../billing/gateways/pagarme.rb | 54 +-- .../billing/gateways/pago_facil.rb | 16 +- .../billing/gateways/pay_conex.rb | 50 +- .../billing/gateways/pay_gate_xml.rb | 62 +-- .../billing/gateways/pay_hub.rb | 58 +-- .../billing/gateways/pay_junction.rb | 14 +- .../billing/gateways/pay_junction_v2.rb | 60 +-- .../billing/gateways/pay_secure.rb | 8 +- .../billing/gateways/paybox_direct.rb | 30 +- .../billing/gateways/payeezy.rb | 10 +- lib/active_merchant/billing/gateways/payex.rb | 8 +- .../billing/gateways/payflow.rb | 14 +- .../gateways/payflow/payflow_common_api.rb | 44 +- .../billing/gateways/payflow_express.rb | 2 +- .../billing/gateways/payment_express.rb | 70 +-- .../billing/gateways/paymill.rb | 224 ++++----- .../billing/gateways/paypal.rb | 2 +- .../billing/gateways/paypal_digital_goods.rb | 2 +- .../billing/gateways/payscout.rb | 2 +- .../billing/gateways/paystation.rb | 28 +- .../billing/gateways/payu_in.rb | 86 ++-- .../billing/gateways/payu_latam.rb | 82 ++-- .../billing/gateways/payway.rb | 12 +- lib/active_merchant/billing/gateways/pin.rb | 14 +- .../billing/gateways/plugnpay.rb | 120 ++--- .../billing/gateways/pro_pay.rb | 246 +++++----- .../billing/gateways/psigate.rb | 28 +- .../billing/gateways/psl_card.rb | 26 +- lib/active_merchant/billing/gateways/qbms.rb | 104 ++-- .../billing/gateways/quantum.rb | 10 +- .../billing/gateways/quickbooks.rb | 20 +- .../billing/gateways/quickpay.rb | 2 +- .../billing/gateways/quickpay/quickpay_v10.rb | 22 +- .../gateways/quickpay/quickpay_v4to7.rb | 6 +- .../billing/gateways/qvalent.rb | 110 ++--- .../billing/gateways/realex.rb | 24 +- .../billing/gateways/redsys.rb | 238 +++++----- lib/active_merchant/billing/gateways/s5.rb | 10 +- .../billing/gateways/safe_charge.rb | 32 +- lib/active_merchant/billing/gateways/sage.rb | 40 +- .../billing/gateways/sage_pay.rb | 64 +-- .../billing/gateways/sallie_mae.rb | 22 +- .../billing/gateways/secure_net.rb | 38 +- .../billing/gateways/secure_pay.rb | 10 +- .../billing/gateways/secure_pay_au.rb | 14 +- .../billing/gateways/secure_pay_tech.rb | 18 +- .../billing/gateways/securion_pay.rb | 24 +- .../billing/gateways/skip_jack.rb | 56 +-- .../billing/gateways/smart_ps.rb | 62 +-- .../billing/gateways/so_easy_pay.rb | 6 +- .../billing/gateways/spreedly_core.rb | 2 +- .../billing/gateways/stripe.rb | 126 ++--- .../billing/gateways/swipe_checkout.rb | 10 +- lib/active_merchant/billing/gateways/telr.rb | 52 +- .../billing/gateways/trans_first.rb | 56 +-- .../trans_first_transaction_express.rb | 448 +++++++++--------- .../billing/gateways/transact_pro.rb | 14 +- .../billing/gateways/transnational.rb | 2 +- .../billing/gateways/trexle.rb | 10 +- .../billing/gateways/trust_commerce.rb | 76 +-- .../billing/gateways/usa_epay_advanced.rb | 74 +-- .../billing/gateways/usa_epay_transaction.rb | 4 +- lib/active_merchant/billing/gateways/vanco.rb | 50 +- .../billing/gateways/verifi.rb | 76 +-- .../billing/gateways/viaklix.rb | 6 +- .../billing/gateways/visanet_peru.rb | 48 +- .../billing/gateways/webpay.rb | 16 +- lib/active_merchant/billing/gateways/wepay.rb | 50 +- .../billing/gateways/wirecard.rb | 40 +- .../billing/gateways/worldpay.rb | 30 +- .../gateways/worldpay_online_payments.rb | 84 ++-- .../billing/gateways/worldpay_us.rb | 34 +- lib/active_merchant/billing/model.rb | 4 +- .../network_tokenization_credit_card.rb | 2 +- lib/active_merchant/billing/rails.rb | 2 +- lib/active_merchant/connection.rb | 10 +- lib/active_merchant/country.rb | 2 +- .../network_connection_retries.rb | 24 +- lib/active_merchant/post_data.rb | 2 +- lib/active_merchant/version.rb | 2 +- lib/support/gateway_support.rb | 4 +- lib/support/ssl_verify.rb | 10 +- lib/support/ssl_version.rb | 14 +- script/generate | 10 +- test/remote/gateways/remote_adyen_test.rb | 16 +- .../gateways/remote_allied_wallet_test.rb | 34 +- .../remote_authorize_net_apple_pay_test.rb | 6 +- .../gateways/remote_authorize_net_cim_test.rb | 52 +- .../gateways/remote_authorize_net_test.rb | 146 +++--- test/remote/gateways/remote_axcessms_test.rb | 56 +-- test/remote/gateways/remote_balanced_test.rb | 14 +- test/remote/gateways/remote_banwire_test.rb | 2 +- .../remote_barclaycard_smartpay_test.rb | 8 +- .../remote_barclays_epdq_extra_plus_test.rb | 12 +- .../remote_beanstream_interac_test.rb | 4 +- .../remote/gateways/remote_beanstream_test.rb | 54 +-- test/remote/gateways/remote_blue_pay_test.rb | 8 +- test/remote/gateways/remote_blue_snap_test.rb | 42 +- test/remote/gateways/remote_borgun_test.rb | 6 +- test/remote/gateways/remote_bpoint_test.rb | 4 +- .../gateways/remote_braintree_blue_test.rb | 308 ++++++------ .../gateways/remote_braintree_orange_test.rb | 16 +- .../remote/gateways/remote_bridge_pay_test.rb | 6 +- .../gateways/remote_card_connect_test.rb | 4 +- .../gateways/remote_card_stream_test.rb | 52 +- test/remote/gateways/remote_cardknox_test.rb | 4 +- test/remote/gateways/remote_cashnet_test.rb | 10 +- test/remote/gateways/remote_cecabank_test.rb | 2 +- test/remote/gateways/remote_cenpos_test.rb | 64 +-- test/remote/gateways/remote_checkout_test.rb | 32 +- .../gateways/remote_checkout_v2_test.rb | 20 +- .../remote/gateways/remote_citrus_pay_test.rb | 34 +- test/remote/gateways/remote_clearhaus_test.rb | 14 +- .../gateways/remote_commercegate_test.rb | 12 +- test/remote/gateways/remote_conekta_test.rb | 110 ++--- .../remote/gateways/remote_creditcall_test.rb | 8 +- test/remote/gateways/remote_credorax_test.rb | 60 +-- test/remote/gateways/remote_culqi_test.rb | 18 +- .../gateways/remote_cyber_source_test.rb | 62 +-- test/remote/gateways/remote_dibs_test.rb | 38 +- test/remote/gateways/remote_digitzs_test.rb | 8 +- test/remote/gateways/remote_ebanx_test.rb | 26 +- test/remote/gateways/remote_elavon_test.rb | 14 +- test/remote/gateways/remote_element_test.rb | 6 +- .../gateways/remote_eway_managed_test.rb | 8 +- .../remote/gateways/remote_eway_rapid_test.rb | 140 +++--- test/remote/gateways/remote_eway_test.rb | 8 +- test/remote/gateways/remote_exact_test.rb | 4 +- test/remote/gateways/remote_ezic_test.rb | 20 +- test/remote/gateways/remote_fat_zebra_test.rb | 2 +- .../gateways/remote_federated_canada_test.rb | 22 +- .../remote/gateways/remote_finansbank_test.rb | 4 +- .../gateways/remote_first_giving_test.rb | 26 +- .../gateways/remote_firstdata_e4_test.rb | 46 +- .../gateways/remote_flo2cash_simple_test.rb | 4 +- test/remote/gateways/remote_flo2cash_test.rb | 6 +- test/remote/gateways/remote_forte_test.rb | 10 +- test/remote/gateways/remote_garanti_test.rb | 2 +- .../gateways/remote_global_collect_test.rb | 10 +- .../gateways/remote_global_transport_test.rb | 22 +- test/remote/gateways/remote_hdfc_test.rb | 28 +- test/remote/gateways/remote_hps_test.rb | 4 +- .../gateways/remote_iats_payments_test.rb | 10 +- test/remote/gateways/remote_inspire_test.rb | 8 +- test/remote/gateways/remote_instapay_test.rb | 2 +- test/remote/gateways/remote_ipp_test.rb | 2 +- test/remote/gateways/remote_iridium_test.rb | 26 +- test/remote/gateways/remote_iveri_test.rb | 6 +- test/remote/gateways/remote_jetpay_test.rb | 50 +- .../remote_jetpay_v2_certification_test.rb | 144 +++--- test/remote/gateways/remote_jetpay_v2_test.rb | 44 +- test/remote/gateways/remote_komoju_test.rb | 12 +- test/remote/gateways/remote_kushki_test.rb | 16 +- .../remote/gateways/remote_latitude19_test.rb | 42 +- test/remote/gateways/remote_linkpoint_test.rb | 22 +- .../remote_litle_certification_test.rb | 106 ++--- test/remote/gateways/remote_litle_test.rb | 54 +-- test/remote/gateways/remote_maxipago_test.rb | 20 +- .../gateways/remote_mercado_pago_test.rb | 4 +- .../remote_merchant_e_solutions_test.rb | 2 +- .../gateways/remote_merchant_partners_test.rb | 58 +-- .../gateways/remote_merchant_ware_test.rb | 4 +- .../remote_merchant_ware_version_four_test.rb | 4 +- .../gateways/remote_merchant_warrior_test.rb | 20 +- .../remote_mercury_certification_test.rb | 86 ++-- test/remote/gateways/remote_mercury_test.rb | 58 +-- .../gateways/remote_metrics_global_test.rb | 24 +- .../gateways/remote_micropayment_test.rb | 64 +-- .../remote_modern_payments_cim_test.rb | 8 +- .../gateways/remote_modern_payments_test.rb | 4 +- test/remote/gateways/remote_moneris_test.rb | 24 +- .../remote/gateways/remote_moneris_us_test.rb | 32 +- .../gateways/remote_money_movers_test.rb | 22 +- .../gateways/remote_nab_transact_test.rb | 4 +- test/remote/gateways/remote_netaxept_test.rb | 12 +- test/remote/gateways/remote_netbanx_test.rb | 22 +- .../gateways/remote_network_merchants_test.rb | 14 +- test/remote/gateways/remote_nmi_test.rb | 48 +- test/remote/gateways/remote_ogone_test.rb | 20 +- test/remote/gateways/remote_openpay_test.rb | 4 +- test/remote/gateways/remote_opp_test.rb | 30 +- .../gateways/remote_optimal_payment_test.rb | 4 +- test/remote/gateways/remote_orbital_test.rb | 36 +- .../gateways/remote_pac_net_raven_test.rb | 16 +- test/remote/gateways/remote_pagarme_test.rb | 16 +- .../remote/gateways/remote_pago_facil_test.rb | 2 +- test/remote/gateways/remote_pay_conex_test.rb | 56 +-- .../gateways/remote_pay_gate_xml_test.rb | 2 +- test/remote/gateways/remote_pay_hub_test.rb | 10 +- .../gateways/remote_pay_junction_test.rb | 30 +- .../gateways/remote_pay_junction_v2_test.rb | 14 +- .../gateways/remote_paybox_direct_test.rb | 6 +- test/remote/gateways/remote_payeezy_test.rb | 32 +- test/remote/gateways/remote_payex_test.rb | 4 +- .../gateways/remote_payflow_express_test.rb | 120 ++--- test/remote/gateways/remote_payflow_test.rb | 62 +-- .../remote/gateways/remote_payflow_uk_test.rb | 28 +- .../gateways/remote_payment_express_test.rb | 20 +- test/remote/gateways/remote_paymill_test.rb | 4 +- test/remote/gateways/remote_paypal_test.rb | 12 +- test/remote/gateways/remote_payscout_test.rb | 16 +- .../remote/gateways/remote_paystation_test.rb | 22 +- test/remote/gateways/remote_payu_in_test.rb | 42 +- .../remote/gateways/remote_payu_latam_test.rb | 220 ++++----- test/remote/gateways/remote_payway_test.rb | 28 +- test/remote/gateways/remote_pin_test.rb | 20 +- test/remote/gateways/remote_plugnpay_test.rb | 6 +- test/remote/gateways/remote_pro_pay_test.rb | 10 +- test/remote/gateways/remote_psl_card_test.rb | 2 +- test/remote/gateways/remote_qbms_test.rb | 10 +- .../remote/gateways/remote_quickbooks_test.rb | 6 +- test/remote/gateways/remote_quickpay_test.rb | 6 +- .../gateways/remote_quickpay_v10_test.rb | 6 +- .../gateways/remote_quickpay_v4_test.rb | 10 +- .../gateways/remote_quickpay_v5_test.rb | 10 +- .../gateways/remote_quickpay_v6_test.rb | 10 +- .../gateways/remote_quickpay_v7_test.rb | 18 +- test/remote/gateways/remote_qvalent_test.rb | 76 +-- test/remote/gateways/remote_realex_test.rb | 18 +- .../gateways/remote_redsys_sha256_test.rb | 48 +- test/remote/gateways/remote_redsys_test.rb | 48 +- test/remote/gateways/remote_s5_test.rb | 6 +- .../gateways/remote_safe_charge_test.rb | 36 +- test/remote/gateways/remote_sage_pay_test.rb | 26 +- test/remote/gateways/remote_sage_test.rb | 24 +- .../remote/gateways/remote_secure_net_test.rb | 6 +- .../gateways/remote_secure_pay_au_test.rb | 2 +- .../gateways/remote_securion_pay_test.rb | 58 +-- test/remote/gateways/remote_skipjack_test.rb | 2 +- .../remote_stripe_android_pay_test.rb | 22 +- .../gateways/remote_stripe_apple_pay_test.rb | 100 ++-- .../gateways/remote_stripe_connect_test.rb | 12 +- .../remote/gateways/remote_stripe_emv_test.rb | 60 +-- test/remote/gateways/remote_stripe_test.rb | 268 +++++------ test/remote/gateways/remote_telr_test.rb | 56 +-- test/remote/gateways/remote_tns_test.rb | 34 +- .../gateways/remote_trans_first_test.rb | 2 +- ...te_trans_first_transaction_express_test.rb | 128 ++--- .../gateways/remote_transact_pro_test.rb | 2 +- test/remote/gateways/remote_transax_test.rb | 24 +- test/remote/gateways/remote_trexle_test.rb | 22 +- .../gateways/remote_trust_commerce_test.rb | 12 +- .../gateways/remote_usa_epay_advanced_test.rb | 36 +- .../remote_usa_epay_transaction_test.rb | 16 +- test/remote/gateways/remote_vanco_test.rb | 24 +- test/remote/gateways/remote_verifi_test.rb | 2 +- test/remote/gateways/remote_viaklix_test.rb | 2 +- .../gateways/remote_visanet_peru_test.rb | 58 +-- test/remote/gateways/remote_webpay_test.rb | 48 +- test/remote/gateways/remote_wepay_test.rb | 12 +- test/remote/gateways/remote_wirecard_test.rb | 32 +- test/remote/gateways/remote_world_net_test.rb | 4 +- .../remote_worldpay_online_payments_test.rb | 4 +- test/remote/gateways/remote_worldpay_test.rb | 40 +- .../gateways/remote_worldpay_us_test.rb | 18 +- test/support/mercury_helper.rb | 42 +- test/test_helper.rb | 24 +- test/unit/check_test.rb | 8 +- test/unit/connection_test.rb | 22 +- test/unit/credit_card_methods_test.rb | 8 +- test/unit/credit_card_test.rb | 98 ++-- test/unit/expiry_date_test.rb | 2 +- test/unit/gateways/adyen_test.rb | 14 +- test/unit/gateways/allied_wallet_test.rb | 30 +- test/unit/gateways/authorize_net_arb_test.rb | 8 +- test/unit/gateways/authorize_net_cim_test.rb | 20 +- test/unit/gateways/authorize_net_test.rb | 402 ++++++++-------- test/unit/gateways/axcessms_test.rb | 60 +-- test/unit/gateways/balanced_test.rb | 36 +- test/unit/gateways/banwire_test.rb | 4 +- .../gateways/barclaycard_smartpay_test.rb | 6 +- .../gateways/barclays_epdq_extra_plus_test.rb | 60 +-- test/unit/gateways/be2bill_test.rb | 4 +- test/unit/gateways/beanstream_interac_test.rb | 16 +- test/unit/gateways/beanstream_test.rb | 58 +-- test/unit/gateways/blue_pay_test.rb | 46 +- test/unit/gateways/blue_snap_test.rb | 40 +- test/unit/gateways/bogus_test.rb | 28 +- test/unit/gateways/borgun_test.rb | 8 +- test/unit/gateways/bpoint_test.rb | 2 +- test/unit/gateways/braintree_blue_test.rb | 232 ++++----- test/unit/gateways/braintree_orange_test.rb | 34 +- test/unit/gateways/braintree_test.rb | 6 +- test/unit/gateways/bridge_pay_test.rb | 16 +- test/unit/gateways/cams_test.rb | 6 +- test/unit/gateways/card_connect_test.rb | 38 +- test/unit/gateways/card_save_test.rb | 2 +- test/unit/gateways/card_stream_test.rb | 72 +-- test/unit/gateways/cardknox_test.rb | 44 +- test/unit/gateways/cardprocess_test.rb | 10 +- test/unit/gateways/cashnet_test.rb | 20 +- test/unit/gateways/cecabank_test.rb | 8 +- test/unit/gateways/cenpos_test.rb | 52 +- test/unit/gateways/checkout_test.rb | 14 +- test/unit/gateways/checkout_v2_test.rb | 44 +- test/unit/gateways/citrus_pay_test.rb | 10 +- test/unit/gateways/clearhaus_test.rb | 114 ++--- test/unit/gateways/commercegate_test.rb | 24 +- test/unit/gateways/conekta_test.rb | 56 +-- test/unit/gateways/creditcall_test.rb | 14 +- test/unit/gateways/credorax_test.rb | 62 +-- test/unit/gateways/culqi_test.rb | 8 +- test/unit/gateways/cyber_source_test.rb | 44 +- test/unit/gateways/data_cash_test.rb | 6 +- test/unit/gateways/dibs_test.rb | 36 +- test/unit/gateways/digitzs_test.rb | 12 +- test/unit/gateways/ebanx_test.rb | 26 +- test/unit/gateways/efsnet_test.rb | 28 +- test/unit/gateways/elavon_test.rb | 16 +- test/unit/gateways/element_test.rb | 18 +- test/unit/gateways/eway_managed_test.rb | 14 +- test/unit/gateways/eway_rapid_test.rb | 150 +++--- test/unit/gateways/exact_test.rb | 10 +- test/unit/gateways/ezic_test.rb | 44 +- test/unit/gateways/fat_zebra_test.rb | 88 ++-- test/unit/gateways/federated_canada_test.rb | 20 +- test/unit/gateways/first_giving_test.rb | 16 +- test/unit/gateways/firstdata_e4_test.rb | 94 ++-- test/unit/gateways/flo2cash_simple_test.rb | 10 +- test/unit/gateways/flo2cash_test.rb | 14 +- test/unit/gateways/forte_test.rb | 18 +- test/unit/gateways/gateway_test.rb | 22 +- test/unit/gateways/global_collect_test.rb | 42 +- test/unit/gateways/global_transport_test.rb | 28 +- test/unit/gateways/hdfc_test.rb | 26 +- test/unit/gateways/hps_test.rb | 4 +- test/unit/gateways/iats_payments_test.rb | 6 +- test/unit/gateways/inspire_test.rb | 16 +- test/unit/gateways/instapay_test.rb | 10 +- test/unit/gateways/ipp_test.rb | 12 +- test/unit/gateways/iridium_test.rb | 4 +- test/unit/gateways/iveri_test.rb | 12 +- test/unit/gateways/jetpay_test.rb | 10 +- test/unit/gateways/jetpay_v2_test.rb | 10 +- test/unit/gateways/komoju_test.rb | 120 ++--- test/unit/gateways/kushki_test.rb | 44 +- test/unit/gateways/latitude19_test.rb | 34 +- test/unit/gateways/linkpoint_test.rb | 18 +- test/unit/gateways/litle_test.rb | 96 ++-- test/unit/gateways/maxipago_test.rb | 18 +- test/unit/gateways/mercado_pago_test.rb | 46 +- .../gateways/merchant_e_solutions_test.rb | 36 +- test/unit/gateways/merchant_one_test.rb | 6 +- test/unit/gateways/merchant_partners_test.rb | 162 +++---- test/unit/gateways/merchant_ware_test.rb | 38 +- .../merchant_ware_version_four_test.rb | 36 +- test/unit/gateways/merchant_warrior_test.rb | 20 +- test/unit/gateways/mercury_test.rb | 14 +- test/unit/gateways/metrics_global_test.rb | 18 +- test/unit/gateways/micropayment_test.rb | 20 +- test/unit/gateways/migs_test.rb | 6 +- .../unit/gateways/modern_payments_cim_test.rb | 32 +- test/unit/gateways/moneris_test.rb | 86 ++-- test/unit/gateways/moneris_us_test.rb | 82 ++-- test/unit/gateways/money_movers_test.rb | 18 +- test/unit/gateways/mundipagg_test.rb | 4 +- test/unit/gateways/nab_transact_test.rb | 10 +- test/unit/gateways/netaxept_test.rb | 14 +- test/unit/gateways/netbilling_test.rb | 16 +- test/unit/gateways/netpay_test.rb | 36 +- test/unit/gateways/network_merchants_test.rb | 52 +- test/unit/gateways/nmi_test.rb | 48 +- test/unit/gateways/ogone_test.rb | 64 +-- test/unit/gateways/omise_test.rb | 8 +- test/unit/gateways/opp_test.rb | 44 +- test/unit/gateways/optimal_payment_test.rb | 20 +- test/unit/gateways/orbital_test.rb | 38 +- test/unit/gateways/pac_net_raven_test.rb | 34 +- test/unit/gateways/pagarme_test.rb | 84 ++-- test/unit/gateways/pago_facil_test.rb | 300 ++++++------ test/unit/gateways/pay_conex_test.rb | 66 +-- test/unit/gateways/pay_hub_test.rb | 22 +- test/unit/gateways/pay_junction_test.rb | 20 +- test/unit/gateways/pay_junction_v2_test.rb | 10 +- test/unit/gateways/paybox_direct_test.rb | 20 +- test/unit/gateways/payeezy_test.rb | 12 +- test/unit/gateways/payex_test.rb | 4 +- test/unit/gateways/payflow_express_test.rb | 4 +- test/unit/gateways/payflow_test.rb | 72 +-- test/unit/gateways/payment_express_test.rb | 38 +- test/unit/gateways/paymentez_test.rb | 2 +- test/unit/gateways/paymill_test.rb | 46 +- .../gateways/paypal_digital_goods_test.rb | 60 +-- test/unit/gateways/paypal_express_test.rb | 94 ++-- test/unit/gateways/paypal_test.rb | 56 +-- test/unit/gateways/payscout_test.rb | 28 +- test/unit/gateways/paystation_test.rb | 20 +- test/unit/gateways/payu_in_test.rb | 352 +++++++------- test/unit/gateways/payu_latam_test.rb | 188 ++++---- test/unit/gateways/payway_test.rb | 16 +- test/unit/gateways/pin_test.rb | 14 +- test/unit/gateways/plugnpay_test.rb | 14 +- test/unit/gateways/pro_pay_test.rb | 6 +- test/unit/gateways/psigate_test.rb | 14 +- test/unit/gateways/psl_card_test.rb | 4 +- test/unit/gateways/qbms_test.rb | 50 +- test/unit/gateways/quickbooks_test.rb | 4 +- test/unit/gateways/quickpay_v10_test.rb | 156 +++--- test/unit/gateways/quickpay_v4to7_test.rb | 54 +-- test/unit/gateways/qvalent_test.rb | 48 +- test/unit/gateways/realex_test.rb | 2 +- test/unit/gateways/redsys_sha256_test.rb | 74 +-- test/unit/gateways/redsys_test.rb | 60 +-- test/unit/gateways/safe_charge_test.rb | 34 +- test/unit/gateways/sage_pay_test.rb | 18 +- test/unit/gateways/sage_test.rb | 190 ++++---- test/unit/gateways/sallie_mae_test.rb | 6 +- test/unit/gateways/secure_net_test.rb | 2 +- test/unit/gateways/secure_pay_au_test.rb | 36 +- test/unit/gateways/securion_pay_test.rb | 50 +- test/unit/gateways/skip_jack_test.rb | 20 +- test/unit/gateways/so_easy_pay_test.rb | 4 +- test/unit/gateways/spreedly_core_test.rb | 86 ++-- test/unit/gateways/stripe_test.rb | 218 ++++----- test/unit/gateways/telr_test.rb | 26 +- test/unit/gateways/tns_test.rb | 10 +- test/unit/gateways/trans_first_test.rb | 10 +- .../trans_first_transaction_express_test.rb | 56 +-- test/unit/gateways/transact_pro_test.rb | 22 +- test/unit/gateways/trexle_test.rb | 12 +- test/unit/gateways/usa_epay_advanced_test.rb | 20 +- .../gateways/usa_epay_transaction_test.rb | 34 +- test/unit/gateways/vanco_test.rb | 26 +- test/unit/gateways/verifi_test.rb | 18 +- test/unit/gateways/viaklix_test.rb | 2 +- test/unit/gateways/visanet_peru_test.rb | 44 +- test/unit/gateways/webpay_test.rb | 16 +- test/unit/gateways/wepay_test.rb | 36 +- test/unit/gateways/wirecard_test.rb | 44 +- .../gateways/worldpay_online_payments_test.rb | 12 +- test/unit/gateways/worldpay_test.rb | 66 +-- test/unit/gateways/worldpay_us_test.rb | 14 +- test/unit/multi_response_test.rb | 112 ++--- test/unit/network_connection_retries_test.rb | 12 +- .../network_tokenization_credit_card_test.rb | 8 +- test/unit/posts_data_test.rb | 4 +- test/unit/rails_compatibility_test.rb | 8 +- 561 files changed, 10919 insertions(+), 10926 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 32915191306..f00fcb20eb8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1594,13 +1594,6 @@ Style/SingleLineMethods: Style/SpecialGlobalVars: EnforcedStyle: use_perl_names -# Offense count: 14577 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiterals: - Enabled: false - # Offense count: 31 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/Rakefile b/Rakefile index 441b85a4447..1aa5657c126 100644 --- a/Rakefile +++ b/Rakefile @@ -20,10 +20,10 @@ require 'bundler/gem_tasks' task :tag_release do system "git tag 'v#{ActiveMerchant::VERSION}'" - system "git push --tags" + system 'git push --tags' end -desc "Run the unit test suite" +desc 'Run the unit test suite' task :default => 'test:local' task :test => 'test:units' @@ -89,7 +89,7 @@ namespace :gateways do unless invalid_lines.empty? puts - puts "Unable to parse:" + puts 'Unable to parse:' invalid_lines.each do |line| puts line end diff --git a/activemerchant.gemspec b/activemerchant.gemspec index 184547471e3..031b34b2576 100644 --- a/activemerchant.gemspec +++ b/activemerchant.gemspec @@ -1,4 +1,4 @@ -$:.push File.expand_path("../lib", __FILE__) +$:.push File.expand_path('../lib', __FILE__) require 'active_merchant/version' Gem::Specification.new do |s| @@ -7,7 +7,7 @@ Gem::Specification.new do |s| s.version = ActiveMerchant::VERSION s.summary = 'Framework and tools for dealing with credit card transactions.' s.description = 'Active Merchant is a simple payment abstraction library used in and sponsored by Shopify. It is written by Tobias Luetke, Cody Fauser, and contributors. The aim of the project is to feel natural to Ruby users and to abstract as many parts as possible away from the user to offer a consistent interface across all supported gateways.' - s.license = "MIT" + s.license = 'MIT' s.author = 'Tobias Luetke' s.email = 'tobi@leetsoft.com' @@ -24,7 +24,7 @@ Gem::Specification.new do |s| s.add_dependency('activesupport', '>= 4.2', '< 6.x') s.add_dependency('i18n', '>= 0.6.9') s.add_dependency('builder', '>= 2.1.2', '< 4.0.0') - s.add_dependency('nokogiri', "~> 1.4") + s.add_dependency('nokogiri', '~> 1.4') s.add_development_dependency('rake') s.add_development_dependency('test-unit', '~> 3') diff --git a/lib/active_merchant.rb b/lib/active_merchant.rb index 88e6216aa15..06ab2f0d19d 100644 --- a/lib/active_merchant.rb +++ b/lib/active_merchant.rb @@ -51,7 +51,7 @@ module ActiveMerchant def self.deprecated(message, caller=Kernel.caller[1]) - warning = caller + ": " + message + warning = caller + ': ' + message if(respond_to?(:logger) && logger.present?) logger.warn(warning) else diff --git a/lib/active_merchant/billing/check.rb b/lib/active_merchant/billing/check.rb index b630f73ffce..561f7b54615 100644 --- a/lib/active_merchant/billing/check.rb +++ b/lib/active_merchant/billing/check.rb @@ -30,17 +30,17 @@ def validate errors = [] [:name, :routing_number, :account_number].each do |attr| - errors << [attr, "cannot be empty"] if empty?(self.send(attr)) + errors << [attr, 'cannot be empty'] if empty?(self.send(attr)) end - errors << [:routing_number, "is invalid"] unless valid_routing_number? + errors << [:routing_number, 'is invalid'] unless valid_routing_number? if(!empty?(account_holder_type) && !%w[business personal].include?(account_holder_type.to_s)) - errors << [:account_holder_type, "must be personal or business"] + errors << [:account_holder_type, 'must be personal or business'] end if(!empty?(account_type) && !%w[checking savings].include?(account_type.to_s)) - errors << [:account_type, "must be checking or savings"] + errors << [:account_type, 'must be checking or savings'] end errors_hash(errors) diff --git a/lib/active_merchant/billing/compatibility.rb b/lib/active_merchant/billing/compatibility.rb index 09dcfbf569d..b32cb6ca4f4 100644 --- a/lib/active_merchant/billing/compatibility.rb +++ b/lib/active_merchant/billing/compatibility.rb @@ -27,7 +27,7 @@ def self.deprecated def self.humanize(lower_case_and_underscored_word) result = lower_case_and_underscored_word.to_s.dup - result.gsub!(/_id$/, "") + result.gsub!(/_id$/, '') result.gsub!(/_/, ' ') result.gsub(/([a-z\d]*)/i) { |match| match.downcase diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb index 91b211bc6fd..5a808b6b5b5 100644 --- a/lib/active_merchant/billing/credit_card.rb +++ b/lib/active_merchant/billing/credit_card.rb @@ -1,6 +1,6 @@ require 'time' require 'date' -require "active_merchant/billing/model" +require 'active_merchant/billing/model' module ActiveMerchant #:nodoc: module Billing #:nodoc: @@ -65,7 +65,7 @@ class << self attr_reader :number def number=(value) - @number = (empty?(value) ? value : value.to_s.gsub(/[^\d]/, "")) + @number = (empty?(value) ? value : value.to_s.gsub(/[^\d]/, '')) end # Returns or sets the expiry month for the card. @@ -202,12 +202,12 @@ def requires_verification_value? attr_accessor :encrypted_pin_ksn def type - ActiveMerchant.deprecated "CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead." + ActiveMerchant.deprecated 'CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead.' brand end def type=(value) - ActiveMerchant.deprecated "CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead." + ActiveMerchant.deprecated 'CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead.' self.brand = value end @@ -250,7 +250,7 @@ def name def name=(full_name) names = full_name.split self.last_name = names.pop - self.first_name = names.join(" ") + self.first_name = names.join(' ') end %w(month year start_month start_year).each do |m| @@ -326,20 +326,20 @@ def validate_essential_attributes #:nodoc: errors = [] if self.class.requires_name? - errors << [:first_name, "cannot be empty"] if first_name.blank? - errors << [:last_name, "cannot be empty"] if last_name.blank? + errors << [:first_name, 'cannot be empty'] if first_name.blank? + errors << [:last_name, 'cannot be empty'] if last_name.blank? end if(empty?(month) || empty?(year)) - errors << [:month, "is required"] if empty?(month) - errors << [:year, "is required"] if empty?(year) + errors << [:month, 'is required'] if empty?(month) + errors << [:year, 'is required'] if empty?(year) else - errors << [:month, "is not a valid month"] if !valid_month?(month) + errors << [:month, 'is not a valid month'] if !valid_month?(month) if expired? - errors << [:year, "expired"] + errors << [:year, 'expired'] else - errors << [:year, "is not a valid year"] if !valid_expiry_year?(year) + errors << [:year, 'is not a valid year'] if !valid_expiry_year?(year) end end @@ -350,17 +350,17 @@ def validate_card_brand_and_number #:nodoc: errors = [] if !empty?(brand) - errors << [:brand, "is invalid"] if !CreditCard.card_companies.keys.include?(brand) + errors << [:brand, 'is invalid'] if !CreditCard.card_companies.keys.include?(brand) end if empty?(number) - errors << [:number, "is required"] + errors << [:number, 'is required'] elsif !CreditCard.valid_number?(number) - errors << [:number, "is not a valid credit card number"] + errors << [:number, 'is not a valid credit card number'] end if errors.empty? - errors << [:brand, "does not match the card number"] if !CreditCard.matching_brand?(number, brand) + errors << [:brand, 'does not match the card number'] if !CreditCard.matching_brand?(number, brand) end errors @@ -374,7 +374,7 @@ def validate_verification_value #:nodoc: errors << [:verification_value, "should be #{card_verification_value_length(brand)} digits"] end elsif requires_verification_value? - errors << [:verification_value, "is required"] + errors << [:verification_value, 'is required'] end errors end @@ -388,11 +388,11 @@ def validate_switch_or_solo_attributes #:nodoc: if((!valid_start_month || !valid_start_year) && !valid_issue_number?(issue_number)) if empty?(issue_number) - errors << [:issue_number, "cannot be empty"] - errors << [:start_month, "is invalid"] if !valid_start_month - errors << [:start_year, "is invalid"] if !valid_start_year + errors << [:issue_number, 'cannot be empty'] + errors << [:start_month, 'is invalid'] if !valid_start_month + errors << [:start_year, 'is invalid'] if !valid_start_year else - errors << [:issue_number, "is invalid"] if !valid_issue_number?(issue_number) + errors << [:issue_number, 'is invalid'] if !valid_issue_number?(issue_number) end end end diff --git a/lib/active_merchant/billing/credit_card_formatting.rb b/lib/active_merchant/billing/credit_card_formatting.rb index b0725506cd2..65078d04e6f 100644 --- a/lib/active_merchant/billing/credit_card_formatting.rb +++ b/lib/active_merchant/billing/credit_card_formatting.rb @@ -14,8 +14,8 @@ def format(number, option) return '' if number.blank? case option - when :two_digits then sprintf("%.2i", number.to_i)[-2..-1] - when :four_digits then sprintf("%.4i", number.to_i)[-4..-1] + when :two_digits then sprintf('%.2i', number.to_i)[-2..-1] + when :four_digits then sprintf('%.4i', number.to_i)[-4..-1] else number end end diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb index 8dc47186c1b..e61ee859070 100644 --- a/lib/active_merchant/billing/credit_card_methods.rb +++ b/lib/active_merchant/billing/credit_card_methods.rb @@ -149,7 +149,7 @@ def electron?(number) end def type?(number) - ActiveMerchant.deprecated "CreditCard#type? is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand? instead." + ActiveMerchant.deprecated 'CreditCard#type? is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand? instead.' brand?(number) end @@ -171,7 +171,7 @@ def matching_brand?(number, brand) end def matching_type?(number, brand) - ActiveMerchant.deprecated "CreditCard#matching_type? is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#matching_brand? instead." + ActiveMerchant.deprecated 'CreditCard#matching_type? is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#matching_brand? instead.' matching_brand?(number, brand) end diff --git a/lib/active_merchant/billing/gateway.rb b/lib/active_merchant/billing/gateway.rb index 6a150f9f9bd..d6596a810e9 100644 --- a/lib/active_merchant/billing/gateway.rb +++ b/lib/active_merchant/billing/gateway.rb @@ -58,8 +58,8 @@ class Gateway DEBIT_CARDS = [ :switch, :solo ] - CREDIT_DEPRECATION_MESSAGE = "Support for using credit to refund existing transactions is deprecated and will be removed from a future release of ActiveMerchant. Please use the refund method instead." - RECURRING_DEPRECATION_MESSAGE = "Recurring functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it." + CREDIT_DEPRECATION_MESSAGE = 'Support for using credit to refund existing transactions is deprecated and will be removed from a future release of ActiveMerchant. Please use the refund method instead.' + RECURRING_DEPRECATION_MESSAGE = 'Recurring functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it.' # == Standardized Error Codes # @@ -195,7 +195,7 @@ def supports_scrubbing? end def scrub(transcript) - raise RuntimeError.new("This gateway does not support scrubbing.") + raise RuntimeError.new('This gateway does not support scrubbing.') end def supports_network_tokenization? @@ -206,10 +206,10 @@ def supports_network_tokenization? def normalize(field) case field - when "true" then true - when "false" then false - when "" then nil - when "null" then nil + when 'true' then true + when 'false' then false + when '' then nil + when 'null' then nil else field end end @@ -243,7 +243,7 @@ def name def amount(money) return nil if money.nil? cents = if money.respond_to?(:cents) - ActiveMerchant.deprecated "Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents" + ActiveMerchant.deprecated 'Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents' money.cents else money @@ -256,7 +256,7 @@ def amount(money) if self.money_format == :cents cents.to_s else - sprintf("%.2f", cents.to_f / 100) + sprintf('%.2f', cents.to_f / 100) end end @@ -274,7 +274,7 @@ def localized_amount(money, currency) return amount unless non_fractional_currency?(currency) || three_decimal_currency?(currency) if non_fractional_currency?(currency) if self.money_format == :cents - sprintf("%.0f", amount.to_f / 100) + sprintf('%.0f', amount.to_f / 100) else amount.split('.').first end @@ -282,7 +282,7 @@ def localized_amount(money, currency) if self.money_format == :cents amount.to_s else - sprintf("%.3f", (amount.to_f / 10)) + sprintf('%.3f', (amount.to_f / 10)) end end end @@ -297,11 +297,11 @@ def truncate(value, max_size) end def split_names(full_name) - names = (full_name || "").split + names = (full_name || '').split return [nil, nil] if names.size == 0 last_name = names.pop - first_name = names.join(" ") + first_name = names.join(' ') [first_name, last_name] end diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index 05ba5769400..afea91c45ee 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -104,9 +104,9 @@ def scrub(transcript) private NETWORK_TOKENIZATION_CARD_SOURCE = { - "apple_pay" => "applepay", - "android_pay" => "androidpay", - "google_pay" => "paywithgoogle" + 'apple_pay' => 'applepay', + 'android_pay' => 'androidpay', + 'google_pay' => 'paywithgoogle' } def add_extra_data(post, payment, options) @@ -121,9 +121,9 @@ def add_extra_data(post, payment, options) def add_shopper_interaction(post, payment, options={}) if (payment.respond_to?(:verification_value) && payment.verification_value) || payment.is_a?(NetworkTokenizationCreditCard) - shopper_interaction = "Ecommerce" + shopper_interaction = 'Ecommerce' else - shopper_interaction = "ContAuth" + shopper_interaction = 'ContAuth' end post[:shopperInteraction] = options[:shopper_interaction] || shopper_interaction @@ -160,7 +160,7 @@ def add_invoice_for_modification(post, money, options) def add_payment(post, payment) if payment.is_a?(String) - _, _, recurring_detail_reference = payment.split("#") + _, _, recurring_detail_reference = payment.split('#') post[:selectedRecurringDetailReference] = recurring_detail_reference add_recurring_contract(post, options) else @@ -184,30 +184,30 @@ def add_card(post, credit_card) end def add_reference(post, authorization, options = {}) - _, psp_reference, _ = authorization.split("#") + _, psp_reference, _ = authorization.split('#') post[:originalReference] = single_reference(authorization) || psp_reference end def add_original_reference(post, authorization, options = {}) - original_psp_reference, _, _ = authorization.split("#") + original_psp_reference, _, _ = authorization.split('#') post[:originalReference] = single_reference(authorization) || original_psp_reference end def add_mpi_data_for_network_tokenization_card(post, payment) post[:mpiData] = {} - post[:mpiData][:authenticationResponse] = "Y" + post[:mpiData][:authenticationResponse] = 'Y' post[:mpiData][:cavv] = payment.payment_cryptogram - post[:mpiData][:directoryResponse] = "Y" - post[:mpiData][:eci] = payment.eci || "07" + post[:mpiData][:directoryResponse] = 'Y' + post[:mpiData][:eci] = payment.eci || '07' end def single_reference(authorization) - authorization if !authorization.include?("#") + authorization if !authorization.include?('#') end def add_recurring_contract(post, options = {}) recurring = { - contract: "RECURRING" + contract: 'RECURRING' } post[:recurring] = recurring @@ -261,8 +261,8 @@ def basic_auth def request_headers { - "Content-Type" => "application/json", - "Authorization" => "Basic #{basic_auth}" + 'Content-Type' => 'application/json', + 'Authorization' => "Basic #{basic_auth}" } end diff --git a/lib/active_merchant/billing/gateways/allied_wallet.rb b/lib/active_merchant/billing/gateways/allied_wallet.rb index fb4ecd7f12a..a7f359849c1 100644 --- a/lib/active_merchant/billing/gateways/allied_wallet.rb +++ b/lib/active_merchant/billing/gateways/allied_wallet.rb @@ -1,13 +1,13 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class AlliedWalletGateway < Gateway - self.display_name = "Allied Wallet" - self.homepage_url = "https://www.alliedwallet.com" + self.display_name = 'Allied Wallet' + self.homepage_url = 'https://www.alliedwallet.com' - self.live_url = "https://api.alliedwallet.com/merchants/" + self.live_url = 'https://api.alliedwallet.com/merchants/' - self.supported_countries = ["US"] - self.default_currency = "USD" + self.supported_countries = ['US'] + self.default_currency = 'USD' self.money_format = :dollars self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro] @@ -104,7 +104,7 @@ def add_payment_method(post, payment_method) end def add_customer_data(post, options) - post[:email] = options[:email] || "unspecified@example.com" + post[:email] = options[:email] || 'unspecified@example.com' post[:iPAddress] = options[:ip] if (billing_address = options[:billing_address]) post[:firstName], post[:lastName] = split_names(billing_address[:name]) @@ -130,11 +130,11 @@ def add_reference(post, authorization, action) ACTIONS = { - purchase: "SALE", - authorize: "AUTHORIZE", - capture: "CAPTURE", - void: "VOID", - refund: "REFUND" + purchase: 'SALE', + authorize: 'AUTHORIZE', + capture: 'CAPTURE', + void: 'VOID', + refund: 'REFUND' } def commit(action, post) @@ -146,14 +146,14 @@ def commit(action, post) response = parse(e.response.body) end - succeeded = success_from(response["status"]) + succeeded = success_from(response['status']) Response.new( succeeded, message_from(succeeded, response), response, - authorization: response["id"], - :avs_result => AVSResult.new(code: response["avs_response"]), - :cvv_result => CVVResult.new(response["cvv2_response"]), + authorization: response['id'], + :avs_result => AVSResult.new(code: response['avs_response']), + :cvv_result => CVVResult.new(response['cvv2_response']), test: test? ) rescue JSON::ParserError @@ -161,20 +161,20 @@ def commit(action, post) end def unparsable_response(raw_response) - message = "Unparsable response received from Allied Wallet. Please contact Allied Wallet if you continue to receive this message." + message = 'Unparsable response received from Allied Wallet. Please contact Allied Wallet if you continue to receive this message.' message += " (The raw response returned by the API was #{raw_response.inspect})" return Response.new(false, message) end def headers { - "Content-type" => "application/json", - "Authorization" => "Bearer " + @options[:token] + 'Content-type' => 'application/json', + 'Authorization' => 'Bearer ' + @options[:token] } end def url(action) - live_url + CGI.escape(@options[:merchant_id]) + "/" + ACTIONS[action] + "transactions" + live_url + CGI.escape(@options[:merchant_id]) + '/' + ACTIONS[action] + 'transactions' end def parse(body) @@ -190,14 +190,14 @@ def parse_element(response, node) end def success_from(response) - response == "Successful" + response == 'Successful' end def message_from(succeeded, response) if succeeded - "Succeeded" + 'Succeeded' else - response["message"] || "Unable to read error message" + response['message'] || 'Unable to read error message' end end diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index 490f9fd94ef..5db6708cb7e 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -89,10 +89,10 @@ class AuthorizeNetGateway < Gateway 2 => /\A;(?<pan>[\d]{1,19}+)=(?<expiration>[\d]{0,4}|=)(?<service_code>[\d]{0,3}|=)(?<discretionary_data>.*)\?\Z/ }.freeze - APPLE_PAY_DATA_DESCRIPTOR = "COMMON.APPLE.INAPP.PAYMENT" + APPLE_PAY_DATA_DESCRIPTOR = 'COMMON.APPLE.INAPP.PAYMENT' - PAYMENT_METHOD_NOT_SUPPORTED_ERROR = "155" - INELIGIBLE_FOR_ISSUING_CREDIT_ERROR = "54" + PAYMENT_METHOD_NOT_SUPPORTED_ERROR = '155' + INELIGIBLE_FOR_ISSUING_CREDIT_ERROR = '54' def initialize(options={}) requires!(options, :login, :password) @@ -102,11 +102,11 @@ def initialize(options={}) def purchase(amount, payment, options = {}) if payment.is_a?(String) commit(:cim_purchase) do |xml| - add_cim_auth_purchase(xml, "profileTransAuthCapture", amount, payment, options) + add_cim_auth_purchase(xml, 'profileTransAuthCapture', amount, payment, options) end else commit(:purchase) do |xml| - add_auth_purchase(xml, "authCaptureTransaction", amount, payment, options) + add_auth_purchase(xml, 'authCaptureTransaction', amount, payment, options) end end end @@ -114,11 +114,11 @@ def purchase(amount, payment, options = {}) def authorize(amount, payment, options={}) if payment.is_a?(String) commit(:cim_authorize) do |xml| - add_cim_auth_purchase(xml, "profileTransAuthOnly", amount, payment, options) + add_cim_auth_purchase(xml, 'profileTransAuthOnly', amount, payment, options) end else commit(:authorize) do |xml| - add_auth_purchase(xml, "authOnlyTransaction", amount, payment, options) + add_auth_purchase(xml, 'authOnlyTransaction', amount, payment, options) end end end @@ -141,7 +141,7 @@ def refund(amount, authorization, options={}) return response if response.success? return response unless options[:force_full_refund_if_unsettled] - if response.params["response_reason_code"] == INELIGIBLE_FOR_ISSUING_CREDIT_ERROR + if response.params['response_reason_code'] == INELIGIBLE_FOR_ISSUING_CREDIT_ERROR void(authorization, options) else response @@ -158,7 +158,7 @@ def void(authorization, options={}) def credit(amount, payment, options={}) if payment.is_a?(String) - raise ArgumentError, "Reference credits are not supported. Please supply the original credit card or use the #refund method." + raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card or use the #refund method.' end commit(:credit) do |xml| @@ -222,7 +222,7 @@ def scrub(transcript) def supports_network_tokenization? card = Billing::NetworkTokenizationCreditCard.new({ - :number => "4111111111111111", + :number => '4111111111111111', :month => 12, :year => 20, :first_name => 'John', @@ -232,7 +232,7 @@ def supports_network_tokenization? }) request = post_data(:authorize) do |xml| - add_auth_purchase(xml, "authOnlyTransaction", 1, card, {}) + add_auth_purchase(xml, 'authOnlyTransaction', 1, card, {}) end raw_response = ssl_post(url, request, headers) response = parse(:authorize, raw_response) @@ -302,7 +302,7 @@ def normal_capture(amount, authorization, options) add_tax_exempt_status(xml, options) add_po_number(xml, options) xml.refTransId(transaction_id_from(authorization)) - add_invoice(xml, "capture", options) + add_invoice(xml, 'capture', options) add_user_fields(xml, amount, options) end end @@ -320,7 +320,7 @@ def cim_refund(amount, authorization, options) add_shipping_fields(xml, options) add_duty_fields(xml, options) xml.creditCardNumberMasked(card_number) - add_invoice(xml, "profileTransRefund", options) + add_invoice(xml, 'profileTransRefund', options) xml.transId(transaction_id) end end @@ -396,38 +396,38 @@ def add_settings(xml, source, options) xml.transactionSettings do if options[:recurring] xml.setting do - xml.settingName("recurringBilling") - xml.settingValue("true") + xml.settingName('recurringBilling') + xml.settingValue('true') end end if options[:disable_partial_auth] xml.setting do - xml.settingName("allowPartialAuth") - xml.settingValue("false") + xml.settingName('allowPartialAuth') + xml.settingValue('false') end end if options[:duplicate_window] set_duplicate_window(xml, options[:duplicate_window]) elsif self.class.duplicate_window - ActiveMerchant.deprecated "Using the duplicate_window class_attribute is deprecated. Use the transaction options hash instead." + ActiveMerchant.deprecated 'Using the duplicate_window class_attribute is deprecated. Use the transaction options hash instead.' set_duplicate_window(xml, self.class.duplicate_window) end if options.key?(:email_customer) xml.setting do - xml.settingName("emailCustomer") - xml.settingValue(options[:email_customer] ? "true" : "false") + xml.settingName('emailCustomer') + xml.settingValue(options[:email_customer] ? 'true' : 'false') end end if options[:header_email_receipt] xml.setting do - xml.settingName("headerEmailReceipt") + xml.settingName('headerEmailReceipt') xml.settingValue(options[:header_email_receipt]) end end if options[:test_request] xml.setting do - xml.settingName("testRequest") - xml.settingValue("1") + xml.settingName('testRequest') + xml.settingValue('1') end end end @@ -435,7 +435,7 @@ def add_settings(xml, source, options) def set_duplicate_window(xml, value) xml.setting do - xml.settingName("duplicateWindow") + xml.settingName('duplicateWindow') xml.settingValue(value) end end @@ -444,13 +444,13 @@ def add_user_fields(xml, amount, options) xml.userFields do if currency = (options[:currency] || currency(amount)) xml.userField do - xml.name("x_currency_code") + xml.name('x_currency_code') xml.value(currency) end end if application_id.present? xml.userField do - xml.name("x_solution_id") + xml.name('x_solution_id') xml.value(application_id) end end @@ -583,7 +583,7 @@ def add_billing_address(xml, payment_source, options) end end - def add_shipping_address(xml, options, root_node="shipTo") + def add_shipping_address(xml, options, root_node='shipTo') address = options[:shipping_address] || options[:address] return unless address @@ -615,7 +615,7 @@ def add_invoice(xml, transaction_type, options) xml.order do xml.invoiceNumber(truncate(options[:order_id], 20)) xml.description(truncate(options[:description], 255)) - xml.purchaseOrderNumber(options[:po_number]) if options[:po_number] && transaction_type.start_with?("profileTrans") + xml.purchaseOrderNumber(options[:po_number]) if options[:po_number] && transaction_type.start_with?('profileTrans') end # Authorize.net API requires lineItems to be placed directly after order tag @@ -697,9 +697,9 @@ def create_customer_profile(credit_card, options) xml.email(options[:email]) unless empty?(options[:email]) xml.paymentProfiles do - xml.customerType("individual") + xml.customerType('individual') add_billing_address(xml, credit_card, options) - add_shipping_address(xml, options, "shipToList") + add_shipping_address(xml, options, 'shipToList') xml.payment do xml.creditCard do xml.cardNumber(truncate(credit_card.number, 16)) @@ -728,7 +728,7 @@ def names_from(payment_source, address, options) end def state_from(address, options) - if ["US", "CA"].include?(address[:country]) + if ['US', 'CA'].include?(address[:country]) address[:state] || 'NC' else address[:state] || 'n/a' @@ -759,7 +759,7 @@ def commit(action, &payload) avs_result = AVSResult.new(code: STANDARD_AVS_CODE_MAPPING[avs_result_code]) cvv_result = CVVResult.new(response[:card_code]) if using_live_gateway_in_test_mode?(response) - Response.new(false, "Using a live Authorize.net account in Test Mode is not permitted.") + Response.new(false, 'Using a live Authorize.net account in Test Mode is not permitted.') else Response.new( success_from(action, response), @@ -776,7 +776,7 @@ def commit(action, &payload) end def is_cim_action?(action) - action.to_s.start_with?("cim") + action.to_s.start_with?('cim') end def post_data(action) @@ -790,17 +790,17 @@ def post_data(action) def root_for(action) if action == :cim_store - "createCustomerProfileRequest" + 'createCustomerProfileRequest' elsif action == :cim_store_update - "createCustomerPaymentProfileRequest" + 'createCustomerPaymentProfileRequest' elsif action == :cim_store_delete_customer - "deleteCustomerProfileRequest" + 'deleteCustomerProfileRequest' elsif action == :verify_credentials - "authenticateTestRequest" + 'authenticateTestRequest' elsif is_cim_action?(action) - "createCustomerProfileTransactionRequest" + 'createCustomerProfileTransactionRequest' else - "createTransactionRequest" + 'createTransactionRequest' end end @@ -817,49 +817,49 @@ def parse_normal(action, body) response = {action: action} - response[:response_code] = if(element = doc.at_xpath("//transactionResponse/responseCode")) + response[:response_code] = if(element = doc.at_xpath('//transactionResponse/responseCode')) (empty?(element.content) ? nil : element.content.to_i) end - if(element = doc.at_xpath("//errors/error")) - response[:response_reason_code] = element.at_xpath("errorCode").content[/0*(\d+)$/, 1] - response[:response_reason_text] = element.at_xpath("errorText").content.chomp('.') - elsif(element = doc.at_xpath("//transactionResponse/messages/message")) - response[:response_reason_code] = element.at_xpath("code").content[/0*(\d+)$/, 1] - response[:response_reason_text] = element.at_xpath("description").content.chomp('.') - elsif(element = doc.at_xpath("//messages/message")) - response[:response_reason_code] = element.at_xpath("code").content[/0*(\d+)$/, 1] - response[:response_reason_text] = element.at_xpath("text").content.chomp('.') + if(element = doc.at_xpath('//errors/error')) + response[:response_reason_code] = element.at_xpath('errorCode').content[/0*(\d+)$/, 1] + response[:response_reason_text] = element.at_xpath('errorText').content.chomp('.') + elsif(element = doc.at_xpath('//transactionResponse/messages/message')) + response[:response_reason_code] = element.at_xpath('code').content[/0*(\d+)$/, 1] + response[:response_reason_text] = element.at_xpath('description').content.chomp('.') + elsif(element = doc.at_xpath('//messages/message')) + response[:response_reason_code] = element.at_xpath('code').content[/0*(\d+)$/, 1] + response[:response_reason_text] = element.at_xpath('text').content.chomp('.') else response[:response_reason_code] = nil - response[:response_reason_text] = "" + response[:response_reason_text] = '' end - response[:avs_result_code] = if(element = doc.at_xpath("//avsResultCode")) + response[:avs_result_code] = if(element = doc.at_xpath('//avsResultCode')) (empty?(element.content) ? nil : element.content) end - response[:transaction_id] = if(element = doc.at_xpath("//transId")) + response[:transaction_id] = if(element = doc.at_xpath('//transId')) (empty?(element.content) ? nil : element.content) end - response[:card_code] = if(element = doc.at_xpath("//cvvResultCode")) + response[:card_code] = if(element = doc.at_xpath('//cvvResultCode')) (empty?(element.content) ? nil : element.content) end - response[:authorization_code] = if(element = doc.at_xpath("//authCode")) + response[:authorization_code] = if(element = doc.at_xpath('//authCode')) (empty?(element.content) ? nil : element.content) end - response[:cardholder_authentication_code] = if(element = doc.at_xpath("//cavvResultCode")) + response[:cardholder_authentication_code] = if(element = doc.at_xpath('//cavvResultCode')) (empty?(element.content) ? nil : element.content) end - response[:account_number] = if(element = doc.at_xpath("//accountNumber")) + response[:account_number] = if(element = doc.at_xpath('//accountNumber')) (empty?(element.content) ? nil : element.content[-4..-1]) end - response[:test_request] = if(element = doc.at_xpath("//testRequest")) + response[:test_request] = if(element = doc.at_xpath('//testRequest')) (empty?(element.content) ? nil : element.content) end @@ -871,33 +871,33 @@ def parse_cim(body) doc = Nokogiri::XML(body).remove_namespaces! - if (element = doc.at_xpath("//messages/message")) - response[:message_code] = element.at_xpath("code").content[/0*(\d+)$/, 1] - response[:message_text] = element.at_xpath("text").content.chomp('.') + if (element = doc.at_xpath('//messages/message')) + response[:message_code] = element.at_xpath('code').content[/0*(\d+)$/, 1] + response[:message_text] = element.at_xpath('text').content.chomp('.') end - response[:result_code] = if(element = doc.at_xpath("//messages/resultCode")) + response[:result_code] = if(element = doc.at_xpath('//messages/resultCode')) (empty?(element.content) ? nil : element.content) end - response[:test_request] = if(element = doc.at_xpath("//testRequest")) + response[:test_request] = if(element = doc.at_xpath('//testRequest')) (empty?(element.content) ? nil : element.content) end - response[:customer_profile_id] = if(element = doc.at_xpath("//customerProfileId")) + response[:customer_profile_id] = if(element = doc.at_xpath('//customerProfileId')) (empty?(element.content) ? nil : element.content) end - response[:customer_payment_profile_id] = if(element = doc.at_xpath("//customerPaymentProfileIdList/numericString")) + response[:customer_payment_profile_id] = if(element = doc.at_xpath('//customerPaymentProfileIdList/numericString')) (empty?(element.content) ? nil : element.content) end - response[:customer_payment_profile_id] = if(element = doc.at_xpath("//customerPaymentProfileIdList/numericString") || - doc.at_xpath("//customerPaymentProfileId")) + response[:customer_payment_profile_id] = if(element = doc.at_xpath('//customerPaymentProfileIdList/numericString') || + doc.at_xpath('//customerPaymentProfileId')) (empty?(element.content) ? nil : element.content) end - response[:direct_response] = if(element = doc.at_xpath("//directResponse")) + response[:direct_response] = if(element = doc.at_xpath('//directResponse')) (empty?(element.content) ? nil : element.content) end @@ -908,7 +908,7 @@ def parse_cim(body) def success_from(action, response) if cim?(action) || (action == :verify_credentials) - response[:result_code] == "Ok" + response[:result_code] == 'Ok' else [APPROVED, FRAUD_REVIEW].include?(response[:response_code]) && TRANSACTION_ALREADY_ACTIONED.exclude?(response[:response_reason_code]) end @@ -928,14 +928,14 @@ def message_from(action, response, avs_result, cvv_result) def authorization_from(action, response) if cim?(action) - [response[:customer_profile_id], response[:customer_payment_profile_id], action].join("#") + [response[:customer_profile_id], response[:customer_payment_profile_id], action].join('#') else - [response[:transaction_id], response[:account_number], action].join("#") + [response[:transaction_id], response[:account_number], action].join('#') end end def split_authorization(authorization) - authorization.split("#") + authorization.split('#') end def cim?(action) @@ -952,7 +952,7 @@ def fraud_review?(response) end def using_live_gateway_in_test_mode?(response) - !test? && response[:test_request] == "1" + !test? && response[:test_request] == '1' end def map_error_code(response_code, response_reason_code) diff --git a/lib/active_merchant/billing/gateways/authorize_net_arb.rb b/lib/active_merchant/billing/gateways/authorize_net_arb.rb index ee19b1e1e3a..8781f60ea66 100644 --- a/lib/active_merchant/billing/gateways/authorize_net_arb.rb +++ b/lib/active_merchant/billing/gateways/authorize_net_arb.rb @@ -57,7 +57,7 @@ class AuthorizeNetArbGateway < Gateway # * <tt>:test</tt> -- +true+ or +false+. If true, perform transactions against the test server. # Otherwise, perform transactions against the production server. def initialize(options = {}) - ActiveMerchant.deprecated "ARB functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it." + ActiveMerchant.deprecated 'ARB functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it.' requires!(options, :login, :password) super end @@ -377,7 +377,7 @@ def expdate(credit_card) def recurring_commit(action, request) url = test? ? test_url : live_url - xml = ssl_post(url, request, "Content-Type" => "text/xml") + xml = ssl_post(url, request, 'Content-Type' => 'text/xml') response = recurring_parse(action, xml) @@ -395,7 +395,7 @@ def recurring_parse(action, xml) response = {} xml = REXML::Document.new(xml) root = REXML::XPath.first(xml, "//#{RECURRING_ACTIONS[action]}Response") || - REXML::XPath.first(xml, "//ErrorResponse") + REXML::XPath.first(xml, '//ErrorResponse') if root root.elements.to_a.each do |node| recurring_parse_element(response, node) diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb index c89f482a089..bfde6385998 100644 --- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb +++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb @@ -854,11 +854,11 @@ def add_drivers_license(xml, drivers_license) def commit(action, request) url = test? ? test_url : live_url - xml = ssl_post(url, request, "Content-Type" => "text/xml") + xml = ssl_post(url, request, 'Content-Type' => 'text/xml') response_params = parse(action, xml) - message_element= response_params["messages"]["message"] + message_element= response_params['messages']['message'] first_error = message_element.is_a?(Array) ? message_element.first : message_element message = first_error['text'] test_mode = @options[:test_requests] || message =~ /Test Mode/ @@ -942,7 +942,7 @@ def parse_direct_response(params) def parse(action, xml) xml = REXML::Document.new(xml) root = REXML::XPath.first(xml, "//#{CIM_ACTIONS[action]}Response") || - REXML::XPath.first(xml, "//ErrorResponse") + REXML::XPath.first(xml, '//ErrorResponse') if root response = parse_element(root) end diff --git a/lib/active_merchant/billing/gateways/axcessms.rb b/lib/active_merchant/billing/gateways/axcessms.rb index 30203788ad4..d45dde62713 100644 --- a/lib/active_merchant/billing/gateways/axcessms.rb +++ b/lib/active_merchant/billing/gateways/axcessms.rb @@ -1,8 +1,8 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class AxcessmsGateway < Gateway - self.test_url = "https://test.ctpe.io/payment/ctpe" - self.live_url = "https://ctpe.io/payment/ctpe" + self.test_url = 'https://test.ctpe.io/payment/ctpe' + self.live_url = 'https://ctpe.io/payment/ctpe' self.supported_countries = %w(AD AT BE BG BR CA CH CY CZ DE DK EE ES FI FO FR GB GI GR HR HU IE IL IM IS IT LI LT LU LV MC MT MX NL @@ -10,18 +10,18 @@ class AxcessmsGateway < Gateway self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :solo] - self.homepage_url = "http://www.axcessms.com/" - self.display_name = "Axcess MS" + self.homepage_url = 'http://www.axcessms.com/' + self.display_name = 'Axcess MS' self.money_format = :dollars - self.default_currency = "GBP" + self.default_currency = 'GBP' - API_VERSION = "1.0" - PAYMENT_CODE_PREAUTHORIZATION = "CC.PA" - PAYMENT_CODE_DEBIT = "CC.DB" - PAYMENT_CODE_CAPTURE = "CC.CP" - PAYMENT_CODE_REVERSAL = "CC.RV" - PAYMENT_CODE_REFUND = "CC.RF" - PAYMENT_CODE_REBILL = "CC.RB" + API_VERSION = '1.0' + PAYMENT_CODE_PREAUTHORIZATION = 'CC.PA' + PAYMENT_CODE_DEBIT = 'CC.DB' + PAYMENT_CODE_CAPTURE = 'CC.CP' + PAYMENT_CODE_REVERSAL = 'CC.RV' + PAYMENT_CODE_REFUND = 'CC.RF' + PAYMENT_CODE_REBILL = 'CC.RB' def initialize(options={}) requires!(options, :sender, :login, :password, :channel) @@ -59,21 +59,21 @@ def verify(credit_card, options={}) private def commit(paymentcode, money, payment, options) - options[:mode] ||= (test? ? "INTEGRATOR_TEST" : "LIVE") + options[:mode] ||= (test? ? 'INTEGRATOR_TEST' : 'LIVE') request = build_request(paymentcode, money, payment, options) headers = { - "Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8" + 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8' } response = parse(ssl_post((test? ? test_url : live_url), "load=#{CGI.escape(request)}", headers)) - success = (response[:result] == "ACK") + success = (response[:result] == 'ACK') message = "#{response[:reason]} - #{response[:return]}" authorization = response[:unique_id] Response.new(success, message, response, :authorization => authorization, - :test => (response[:mode] != "LIVE") + :test => (response[:mode] != 'LIVE') ) end @@ -87,7 +87,7 @@ def parse(body) parse_element(response, node) end - response[:mode] = REXML::XPath.first(xml, "//Transaction").attributes["mode"] + response[:mode] = REXML::XPath.first(xml, '//Transaction').attributes['mode'] response end @@ -107,30 +107,30 @@ def parse_element(response, node) def build_request(payment_code, money, payment, options) xml = Builder::XmlMarkup.new :indent => 2 xml.instruct! - xml.tag! "Request", "version" => API_VERSION do - xml.tag! "Header" do - xml.tag! "Security", "sender" => @options[:sender] + xml.tag! 'Request', 'version' => API_VERSION do + xml.tag! 'Header' do + xml.tag! 'Security', 'sender' => @options[:sender] end - xml.tag! "Transaction", "mode" => options[:mode], "channel" => @options[:channel], "response" => "SYNC" do - xml.tag! "User", "login" => @options[:login], "pwd" => @options[:password] - xml.tag! "Identification" do - xml.tag! "TransactionID", options[:order_id] || generate_unique_id - xml.tag! "ReferenceID", payment unless payment.respond_to?(:number) + xml.tag! 'Transaction', 'mode' => options[:mode], 'channel' => @options[:channel], 'response' => 'SYNC' do + xml.tag! 'User', 'login' => @options[:login], 'pwd' => @options[:password] + xml.tag! 'Identification' do + xml.tag! 'TransactionID', options[:order_id] || generate_unique_id + xml.tag! 'ReferenceID', payment unless payment.respond_to?(:number) end - xml.tag! "Payment", "code" => payment_code do - xml.tag! "Memo", options[:memo] unless options[:memo].blank? - xml.tag! "Presentation" do - xml.tag! "Amount", amount(money) - xml.tag! "Currency", (options[:currency] || currency(money)) - xml.tag! "Usage", options[:description] + xml.tag! 'Payment', 'code' => payment_code do + xml.tag! 'Memo', options[:memo] unless options[:memo].blank? + xml.tag! 'Presentation' do + xml.tag! 'Amount', amount(money) + xml.tag! 'Currency', (options[:currency] || currency(money)) + xml.tag! 'Usage', options[:description] end end if payment.respond_to?(:number) add_payment(xml, payment) - xml.tag! "Customer" do + xml.tag! 'Customer' do add_customer_name(xml, payment) add_address(xml, options[:billing_address] || options[:address]) add_contact(xml, options) @@ -143,37 +143,37 @@ def build_request(payment_code, money, payment, options) end def add_contact(xml, options) - xml.tag! "Contact" do - xml.tag! "Email", (options[:email] || "unknown@example.com") - xml.tag! "Ip", (options[:ip] || "127.0.0.1") + xml.tag! 'Contact' do + xml.tag! 'Email', (options[:email] || 'unknown@example.com') + xml.tag! 'Ip', (options[:ip] || '127.0.0.1') end end def add_customer_name(xml, payment) - xml.tag! "Name" do - xml.tag! "Given", payment.first_name - xml.tag! "Family", payment.last_name + xml.tag! 'Name' do + xml.tag! 'Given', payment.first_name + xml.tag! 'Family', payment.last_name end end def add_payment(xml, payment) - xml.tag! "Account" do - xml.tag! "Number", payment.number - xml.tag! "Holder", payment.name - xml.tag! "Brand", payment.brand - xml.tag! "Expiry", "month" => payment.month, "year" => payment.year - xml.tag! "Verification", payment.verification_value + xml.tag! 'Account' do + xml.tag! 'Number', payment.number + xml.tag! 'Holder', payment.name + xml.tag! 'Brand', payment.brand + xml.tag! 'Expiry', 'month' => payment.month, 'year' => payment.year + xml.tag! 'Verification', payment.verification_value end end def add_address(xml, address) - raise ArgumentError.new("Address is required") unless address - xml.tag! "Address" do - xml.tag! "Street", "#{address[:address1]} #{address[:address2]}".strip - xml.tag! "City", address[:city] - xml.tag! "State", address[:state] - xml.tag! "Zip", address[:zip] - xml.tag! "Country", address[:country] + raise ArgumentError.new('Address is required') unless address + xml.tag! 'Address' do + xml.tag! 'Street', "#{address[:address1]} #{address[:address2]}".strip + xml.tag! 'City', address[:city] + xml.tag! 'State', address[:state] + xml.tag! 'Zip', address[:zip] + xml.tag! 'Country', address[:country] end end end diff --git a/lib/active_merchant/billing/gateways/balanced.rb b/lib/active_merchant/billing/gateways/balanced.rb index 153c1a1369c..50a3dfcd2c0 100644 --- a/lib/active_merchant/billing/gateways/balanced.rb +++ b/lib/active_merchant/billing/gateways/balanced.rb @@ -17,7 +17,7 @@ module Billing #:nodoc: # live" button on the Balanced dashboard and fill in your marketplace # details. class BalancedGateway < Gateway - VERSION = "2.0.0" + VERSION = '2.0.0' self.live_url = 'https://api.balancedpayments.com' @@ -50,7 +50,7 @@ def purchase(money, payment_method, options = {}) else payment_method end - r.process{commit("debits", "cards/#{card_identifier_from(identifier)}/debits", post)} + r.process{commit('debits', "cards/#{card_identifier_from(identifier)}/debits", post)} end end @@ -67,7 +67,7 @@ def authorize(money, payment_method, options = {}) else payment_method end - r.process{commit("card_holds", "cards/#{card_identifier_from(identifier)}/card_holds", post)} + r.process{commit('card_holds', "cards/#{card_identifier_from(identifier)}/card_holds", post)} end end @@ -77,7 +77,7 @@ def capture(money, identifier, options = {}) post[:description] = options[:description] if options[:description] add_common_params(post, options) - commit("debits", "card_holds/#{reference_identifier_from(identifier)}/debits", post) + commit('debits', "card_holds/#{reference_identifier_from(identifier)}/debits", post) end def void(identifier, options = {}) @@ -85,7 +85,7 @@ def void(identifier, options = {}) post[:is_void] = true add_common_params(post, options) - commit("card_holds", "card_holds/#{reference_identifier_from(identifier)}", post, :put) + commit('card_holds', "card_holds/#{reference_identifier_from(identifier)}", post, :put) end def refund(money, identifier, options = {}) @@ -94,7 +94,7 @@ def refund(money, identifier, options = {}) post[:description] = options[:description] add_common_params(post, options) - commit("refunds", "debits/#{reference_identifier_from(identifier)}/refunds", post) + commit('refunds', "debits/#{reference_identifier_from(identifier)}/refunds", post) end def store(credit_card, options={}) @@ -108,7 +108,7 @@ def store(credit_card, options={}) add_address(post, options) - commit("cards", "cards", post) + commit('cards', 'cards', post) end private @@ -117,18 +117,18 @@ def reference_identifier_from(identifier) case identifier when %r{\|} uri = identifier. - split("|"). + split('|'). detect{|part| part.size > 0} - uri.split("/")[2] + uri.split('/')[2] when %r{\/} - identifier.split("/")[5] + identifier.split('/')[5] else identifier end end def card_identifier_from(identifier) - identifier.split("/").last + identifier.split('/').last end def add_amount(post, money) @@ -180,29 +180,29 @@ def success_from(entity_name, raw_response) entity = (raw_response[entity_name] || []).first if(!entity) false - elsif((entity_name == "refunds") && entity.include?("status")) - %w(succeeded pending).include?(entity["status"]) - elsif(entity.include?("status")) - (entity["status"] == "succeeded") - elsif(entity_name == "cards") - !!entity["id"] + elsif((entity_name == 'refunds') && entity.include?('status')) + %w(succeeded pending).include?(entity['status']) + elsif(entity.include?('status')) + (entity['status'] == 'succeeded') + elsif(entity_name == 'cards') + !!entity['id'] else false end end def message_from(raw_response) - if(raw_response["errors"]) - error = raw_response["errors"].first - (error["additional"] || error["message"] || error["description"]) + if(raw_response['errors']) + error = raw_response['errors'].first + (error['additional'] || error['message'] || error['description']) else - "Success" + 'Success' end end def authorization_from(entity_name, raw_response) entity = (raw_response[entity_name] || []).first - (entity && entity["id"]) + (entity && entity['id']) end def parse(body) @@ -211,8 +211,8 @@ def parse(body) message = 'Invalid response received from the Balanced API. Please contact support@balancedpayments.com if you continue to receive this message.' message += " (The raw response returned by the API was #{raw_response.inspect})" { - "errors" => [{ - "message" => message + 'errors' => [{ + 'message' => message }] } end @@ -231,7 +231,7 @@ def post_data(params) else "#{key}=#{CGI.escape(value.to_s)}" end - end.compact.join("&") + end.compact.join('&') end def headers @@ -245,10 +245,10 @@ def headers ) { - "Authorization" => "Basic " + Base64.encode64(@options[:login].to_s + ":").strip, - "User-Agent" => "Balanced/v1.1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}", - "Accept" => "application/vnd.api+json;revision=1.1", - "X-Balanced-User-Agent" => @@ua, + 'Authorization' => 'Basic ' + Base64.encode64(@options[:login].to_s + ':').strip, + 'User-Agent' => "Balanced/v1.1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}", + 'Accept' => 'application/vnd.api+json;revision=1.1', + 'X-Balanced-User-Agent' => @@ua, } end end diff --git a/lib/active_merchant/billing/gateways/bank_frick.rb b/lib/active_merchant/billing/gateways/bank_frick.rb index 2f5185d395d..fdfdfcff642 100644 --- a/lib/active_merchant/billing/gateways/bank_frick.rb +++ b/lib/active_merchant/billing/gateways/bank_frick.rb @@ -93,7 +93,7 @@ def add_address(post, creditcard, options) if address = options[:billing_address] || options[:address] post[:address] = address[:address1].to_s post[:company] = address[:company].to_s - post[:phone] = address[:phone].to_s.gsub(/[^0-9]/, '') || "0000000" + post[:phone] = address[:phone].to_s.gsub(/[^0-9]/, '') || '0000000' post[:zip] = address[:zip].to_s post[:city] = address[:city].to_s post[:country] = address[:country].to_s @@ -121,11 +121,11 @@ def add_payment(post, payment) def parse(body) results = {} xml = Nokogiri::XML(body) - resp = xml.xpath("//Response/Transaction/Identification") + resp = xml.xpath('//Response/Transaction/Identification') resp.children.each do |element| results[element.name.downcase.to_sym] = element.text end - resp = xml.xpath("//Response/Transaction/Processing") + resp = xml.xpath('//Response/Transaction/Processing') resp.children.each do |element| results[element.name.downcase.to_sym] = element.text end diff --git a/lib/active_merchant/billing/gateways/banwire.rb b/lib/active_merchant/billing/gateways/banwire.rb index 09082f50318..09aeb583fe2 100644 --- a/lib/active_merchant/billing/gateways/banwire.rb +++ b/lib/active_merchant/billing/gateways/banwire.rb @@ -40,13 +40,13 @@ def scrub(transcript) private def add_response_type(post) - post[:response_format] = "JSON" + post[:response_format] = 'JSON' end def add_customer_data(post, options) post[:user] = @options[:login] post[:phone] = options[:billing_address][:phone] - post[:mail] = options[:email] || "unspecified@email.com" + post[:mail] = options[:email] || 'unspecified@email.com' end def add_order_data(post, options) @@ -74,7 +74,7 @@ def add_amount(post, money, options) def card_brand(card) brand = super - ({"master" => "mastercard", "american_express" => "amex"}[brand] || brand) + ({'master' => 'mastercard', 'american_express' => 'amex'}[brand] || brand) end def parse(body) @@ -90,25 +90,25 @@ def commit(money, parameters) end Response.new(success?(response), - response["message"], + response['message'], response, :test => test?, - :authorization => response["code_auth"]) + :authorization => response['code_auth']) end def success?(response) - (response["response"] == "ok") + (response['response'] == 'ok') end def post_data(parameters = {}) - parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def json_error(raw_response) msg = 'Invalid response received from the Banwire API. Please contact Banwire support if you continue to receive this message.' msg += " (The raw response returned by the API was #{raw_response.inspect})" { - "message" => msg + 'message' => msg } end end diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index 5f2f4c72333..56fe408d503 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -160,11 +160,11 @@ def authorization_from(parameters, response) authorization = [parameters[:originalReference], response['pspReference']].compact return nil if authorization.empty? - return authorization.join("#") + return authorization.join('#') end def parse_avs_code(response) - AVS_MAPPING[response["avsResult"][0..1].strip] if response["avsResult"] + AVS_MAPPING[response['avsResult'][0..1].strip] if response['avsResult'] end def flatten_hash(hash, prefix = nil) @@ -249,13 +249,13 @@ def shipping_address_hash(options) def parse_street(address) address_to_parse = "#{address[:address1]} #{address[:address2]}" street = address[:street] || address_to_parse.split(/\s+/).keep_if { |x| x !~ /\d/ }.join(' ') - street.empty? ? "Not Provided" : street + street.empty? ? 'Not Provided' : street end def parse_house_number(address) address_to_parse = "#{address[:address1]} #{address[:address2]}" house = address[:houseNumberOrName] || address_to_parse.split(/\s+/).keep_if { |x| x =~ /\d/ }.join(' ') - house.empty? ? "Not Provided" : house + house.empty? ? 'Not Provided' : house end def create_address_hash(address, house, street) @@ -295,7 +295,7 @@ def modification_request(reference, options) end def psp_reference_from(authorization) - authorization.nil? ? nil : authorization.split("#").first + authorization.nil? ? nil : authorization.split('#').first end def payment_request(money, options) diff --git a/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb b/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb index 933d27f7f63..6f020860b2a 100644 --- a/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +++ b/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb @@ -1,15 +1,15 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class BarclaysEpdqExtraPlusGateway < OgoneGateway - self.test_url = "https://mdepayments.epdq.co.uk/ncol/test/" - self.live_url = "https://payments.epdq.co.uk/ncol/prod/" + self.test_url = 'https://mdepayments.epdq.co.uk/ncol/test/' + self.live_url = 'https://payments.epdq.co.uk/ncol/prod/' - self.display_name = "Barclays ePDQ Extra Plus" - self.homepage_url = "http://www.barclaycard.co.uk/business/accepting-payments/epdq-ecomm/" + self.display_name = 'Barclays ePDQ Extra Plus' + self.homepage_url = 'http://www.barclaycard.co.uk/business/accepting-payments/epdq-ecomm/' - self.supported_countries = ["GB"] + self.supported_countries = ['GB'] self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro] - self.default_currency = "GBP" + self.default_currency = 'GBP' end end end diff --git a/lib/active_merchant/billing/gateways/be2bill.rb b/lib/active_merchant/billing/gateways/be2bill.rb index 8c46902e9cc..f309272466f 100644 --- a/lib/active_merchant/billing/gateways/be2bill.rb +++ b/lib/active_merchant/billing/gateways/be2bill.rb @@ -1,4 +1,4 @@ -require "digest/sha2" +require 'digest/sha2' module ActiveMerchant #:nodoc: module Billing #:nodoc: @@ -72,7 +72,7 @@ def add_invoice(post, options) def add_creditcard(post, creditcard) post[:CARDFULLNAME] = creditcard ? creditcard.name : '' post[:CARDCODE] = creditcard ? creditcard.number : '' - post[:CARDVALIDITYDATE] = creditcard ? "%02d-%02s" % [creditcard.month, creditcard.year.to_s[-2..-1]] : '' + post[:CARDVALIDITYDATE] = creditcard ? '%02d-%02s' % [creditcard.month, creditcard.year.to_s[-2..-1]] : '' post[:CARDCVV] = creditcard ? creditcard.verification_value : '' end diff --git a/lib/active_merchant/billing/gateways/beanstream.rb b/lib/active_merchant/billing/gateways/beanstream.rb index d60d8a5d7ed..e86e21d60a5 100644 --- a/lib/active_merchant/billing/gateways/beanstream.rb +++ b/lib/active_merchant/billing/gateways/beanstream.rb @@ -170,7 +170,7 @@ def store(payment_method, options = {}) #can't actually delete a secure profile with the supplicated API. This function sets the status of the profile to closed (C). #Closed profiles will have to removed manually. def delete(vault_id) - update(vault_id, false, {:status => "C"}) + update(vault_id, false, {:status => 'C'}) end alias_method :unstore, :delete diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index e60e9bd2646..f6d8ba851d3 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -62,69 +62,69 @@ module BeanstreamCore } STATES = { - "ALBERTA" => "AB", - "BRITISH COLUMBIA" => "BC", - "MANITOBA" => "MB", - "NEW BRUNSWICK" => "NB", - "NEWFOUNDLAND AND LABRADOR" => "NL", - "NOVA SCOTIA" => "NS", - "ONTARIO" => "ON", - "PRINCE EDWARD ISLAND" => "PE", - "QUEBEC" => "QC", - "SASKATCHEWAN" => "SK", - "NORTHWEST TERRITORIES" => "NT", - "NUNAVUT" => "NU", - "YUKON" => "YT", - "ALABAMA" => "AL", - "ALASKA" => "AK", - "ARIZONA" => "AZ", - "ARKANSAS" => "AR", - "CALIFORNIA" => "CA", - "COLORADO" => "CO", - "CONNECTICUT" => "CT", - "DELAWARE" => "DE", - "FLORIDA" => "FL", - "GEORGIA" => "GA", - "HAWAII" => "HI", - "IDAHO" => "ID", - "ILLINOIS" => "IL", - "INDIANA" => "IN", - "IOWA" => "IA", - "KANSAS" => "KS", - "KENTUCKY" => "KY", - "LOUISIANA" => "LA", - "MAINE" => "ME", - "MARYLAND" => "MD", - "MASSACHUSETTS" => "MA", - "MICHIGAN" => "MI", - "MINNESOTA" => "MN", - "MISSISSIPPI" => "MS", - "MISSOURI" => "MO", - "MONTANA" => "MT", - "NEBRASKA" => "NE", - "NEVADA" => "NV", - "NEW HAMPSHIRE" => "NH", - "NEW JERSEY" => "NJ", - "NEW MEXICO" => "NM", - "NEW YORK" => "NY", - "NORTH CAROLINA" => "NC", - "NORTH DAKOTA" => "ND", - "OHIO" => "OH", - "OKLAHOMA" => "OK", - "OREGON" => "OR", - "PENNSYLVANIA" => "PA", - "RHODE ISLAND" => "RI", - "SOUTH CAROLINA" => "SC", - "SOUTH DAKOTA" => "SD", - "TENNESSEE" => "TN", - "TEXAS" => "TX", - "UTAH" => "UT", - "VERMONT" => "VT", - "VIRGINIA" => "VA", - "WASHINGTON" => "WA", - "WEST VIRGINIA" => "WV", - "WISCONSIN" => "WI", - "WYOMING" => "WY" + 'ALBERTA' => 'AB', + 'BRITISH COLUMBIA' => 'BC', + 'MANITOBA' => 'MB', + 'NEW BRUNSWICK' => 'NB', + 'NEWFOUNDLAND AND LABRADOR' => 'NL', + 'NOVA SCOTIA' => 'NS', + 'ONTARIO' => 'ON', + 'PRINCE EDWARD ISLAND' => 'PE', + 'QUEBEC' => 'QC', + 'SASKATCHEWAN' => 'SK', + 'NORTHWEST TERRITORIES' => 'NT', + 'NUNAVUT' => 'NU', + 'YUKON' => 'YT', + 'ALABAMA' => 'AL', + 'ALASKA' => 'AK', + 'ARIZONA' => 'AZ', + 'ARKANSAS' => 'AR', + 'CALIFORNIA' => 'CA', + 'COLORADO' => 'CO', + 'CONNECTICUT' => 'CT', + 'DELAWARE' => 'DE', + 'FLORIDA' => 'FL', + 'GEORGIA' => 'GA', + 'HAWAII' => 'HI', + 'IDAHO' => 'ID', + 'ILLINOIS' => 'IL', + 'INDIANA' => 'IN', + 'IOWA' => 'IA', + 'KANSAS' => 'KS', + 'KENTUCKY' => 'KY', + 'LOUISIANA' => 'LA', + 'MAINE' => 'ME', + 'MARYLAND' => 'MD', + 'MASSACHUSETTS' => 'MA', + 'MICHIGAN' => 'MI', + 'MINNESOTA' => 'MN', + 'MISSISSIPPI' => 'MS', + 'MISSOURI' => 'MO', + 'MONTANA' => 'MT', + 'NEBRASKA' => 'NE', + 'NEVADA' => 'NV', + 'NEW HAMPSHIRE' => 'NH', + 'NEW JERSEY' => 'NJ', + 'NEW MEXICO' => 'NM', + 'NEW YORK' => 'NY', + 'NORTH CAROLINA' => 'NC', + 'NORTH DAKOTA' => 'ND', + 'OHIO' => 'OH', + 'OKLAHOMA' => 'OK', + 'OREGON' => 'OR', + 'PENNSYLVANIA' => 'PA', + 'RHODE ISLAND' => 'RI', + 'SOUTH CAROLINA' => 'SC', + 'SOUTH DAKOTA' => 'SD', + 'TENNESSEE' => 'TN', + 'TEXAS' => 'TX', + 'UTAH' => 'UT', + 'VERMONT' => 'VT', + 'VIRGINIA' => 'VA', + 'WASHINGTON' => 'WA', + 'WEST VIRGINIA' => 'WV', + 'WISCONSIN' => 'WI', + 'WYOMING' => 'WY' } def self.included(base) @@ -206,7 +206,7 @@ def secure_profile_action(type) end def split_auth(string) - string.split(";") + string.split(';') end def add_amount(post, money) @@ -386,8 +386,8 @@ def parse(body) # Clean up the message text if there is any if results[:messageText] - results[:messageText].gsub!(/<LI>/, "") - results[:messageText].gsub!(/(\.)?<br>/, ". ") + results[:messageText].gsub!(/<LI>/, '') + results[:messageText].gsub!(/(\.)?<br>/, '. ') results[:messageText].strip! end @@ -413,7 +413,7 @@ def post(data, use_profile_api=nil) response = parse(ssl_post((use_profile_api ? SECURE_PROFILE_URL : self.live_url), data)) response[:customer_vault_id] = response[:customerCode] if response[:customerCode] build_response(success?(response), message_from(response), response, - :test => test? || response[:authCode] == "TEST", + :test => test? || response[:authCode] == 'TEST', :authorization => authorization_from(response), :cvv_result => CVD_CODES[response[:cvdId]], :avs_result => { :code => (AVS_CODES.include? response[:avsId]) ? AVS_CODES[response[:avsId]] : response[:avsId] } @@ -445,7 +445,7 @@ def add_source(post, source) if source.is_a?(String) or source.is_a?(Integer) post[:customerCode] = source else - card_brand(source) == "check" ? add_check(post, source) : add_credit_card(post, source) + card_brand(source) == 'check' ? add_check(post, source) : add_credit_card(post, source) end end @@ -466,7 +466,7 @@ def post_data(params, use_profile_api) params[:vbvEnabled] = '0' params[:scEnabled] = '0' - params.reject{|k, v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + params.reject{|k, v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end end diff --git a/lib/active_merchant/billing/gateways/blue_pay.rb b/lib/active_merchant/billing/gateways/blue_pay.rb index 17f29dfe067..5e708624538 100644 --- a/lib/active_merchant/billing/gateways/blue_pay.rb +++ b/lib/active_merchant/billing/gateways/blue_pay.rb @@ -155,7 +155,7 @@ def void(identification, options = {}) # * <tt>options</tt> -- A hash of parameters. def refund(money, identification, options = {}) if(identification && !identification.kind_of?(String)) - ActiveMerchant.deprecated "refund should only be used to refund a referenced transaction" + ActiveMerchant.deprecated 'refund should only be used to refund a referenced transaction' return credit(money, identification, options) end @@ -163,7 +163,7 @@ def refund(money, identification, options = {}) post[:PAYMENT_ACCOUNT] = '' post[:MASTER_ID] = identification post[:TRANS_TYPE] = 'REFUND' - post[:NAME1] = options[:first_name] || "" + post[:NAME1] = options[:first_name] || '' post[:NAME2] = options[:last_name] if options[:last_name] post[:ZIP] = options[:zip] if options[:zip] add_invoice(post, options) @@ -174,7 +174,7 @@ def refund(money, identification, options = {}) def credit(money, payment_object, options = {}) if(payment_object && payment_object.kind_of?(String)) - ActiveMerchant.deprecated "credit should only be used to credit a payment method" + ActiveMerchant.deprecated 'credit should only be used to credit a payment method' return refund(money, payment_object, options) end @@ -183,7 +183,7 @@ def credit(money, payment_object, options = {}) add_payment_method(post, payment_object) post[:TRANS_TYPE] = 'CREDIT' - post[:NAME1] = options[:first_name] || "" + post[:NAME1] = options[:first_name] || '' post[:NAME2] = options[:last_name] if options[:last_name] post[:ZIP] = options[:zip] if options[:zip] add_invoice(post, options) @@ -347,7 +347,7 @@ def parse(body) # The bp20api has max one value per form field. response_fields = Hash[CGI::parse(body).map{|k,v| [k.upcase,v.first]}] - if response_fields.include? "REBILL_ID" + if response_fields.include? 'REBILL_ID' return parse_recurring(response_fields) end @@ -378,12 +378,12 @@ def message_from(parsed) else message = message.chomp('.') end - elsif message == "Missing ACCOUNT_ID" - message = "The merchant login ID or password is invalid" + elsif message == 'Missing ACCOUNT_ID' + message = 'The merchant login ID or password is invalid' elsif message =~ /Approved/ - message = "This transaction has been approved" + message = 'This transaction has been approved' elsif message =~ /Expired/ - message = "The credit card has expired" + message = 'The credit card has expired' end message end @@ -418,13 +418,13 @@ def add_creditcard(post, creditcard) end CHECK_ACCOUNT_TYPES = { - "checking" => "C", - "savings" => "S" + 'checking' => 'C', + 'savings' => 'S' } def add_check(post, check) post[:PAYMENT_TYPE] = 'ACH' - post[:PAYMENT_ACCOUNT] = [CHECK_ACCOUNT_TYPES[check.account_type], check.routing_number, check.account_number].join(":") + post[:PAYMENT_ACCOUNT] = [CHECK_ACCOUNT_TYPES[check.account_type], check.routing_number, check.account_number].join(':') post[:NAME1] = check.first_name post[:NAME2] = check.last_name end @@ -465,15 +465,15 @@ def post_data(action, parameters = {}) post[:version] = '1' post[:login] = '' post[:tran_key] = '' - post[:relay_response] = "FALSE" + post[:relay_response] = 'FALSE' post[:type] = action - post[:delim_data] = "TRUE" - post[:delim_char] = "," - post[:encap_char] = "$" + post[:delim_data] = 'TRUE' + post[:delim_char] = ',' + post[:encap_char] = '$' post[:card_num] = '4111111111111111' post[:exp_date] = '1212' post[:solution_ID] = application_id if application_id - post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def expdate(creditcard) @@ -494,7 +494,7 @@ def calc_tps(amount, post) post[:MASTER_ID], post[:NAME1], post[:PAYMENT_ACCOUNT] - ].join("") + ].join('') ) end @@ -505,7 +505,7 @@ def calc_rebill_tps(post) @options[:login], post[:TRANS_TYPE], post[:REBILL_ID] - ].join("") + ].join('') ) end diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb index c2ee9385990..e736fe14152 100644 --- a/lib/active_merchant/billing/gateways/blue_snap.rb +++ b/lib/active_merchant/billing/gateways/blue_snap.rb @@ -3,8 +3,8 @@ module ActiveMerchant module Billing class BlueSnapGateway < Gateway - self.test_url = "https://sandbox.bluesnap.com/services/2" - self.live_url = "https://ws.bluesnap.com/services/2" + self.test_url = 'https://sandbox.bluesnap.com/services/2' + self.live_url = 'https://ws.bluesnap.com/services/2' self.supported_countries = %w(US CA GB AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE) self.default_currency = 'USD' @@ -14,11 +14,11 @@ class BlueSnapGateway < Gateway self.display_name = 'BlueSnap' TRANSACTIONS = { - purchase: "AUTH_CAPTURE", - authorize: "AUTH_ONLY", - capture: "CAPTURE", - void: "AUTH_REVERSAL", - refund: "REFUND" + purchase: 'AUTH_CAPTURE', + authorize: 'AUTH_ONLY', + capture: 'CAPTURE', + void: 'AUTH_REVERSAL', + refund: 'REFUND' } CVC_CODE_TRANSLATOR = { @@ -105,8 +105,8 @@ def verify(payment_method, options={}) def store(credit_card, options = {}) commit(:store) do |doc| add_personal_info(doc, credit_card, options) - doc.send("payment-sources") do - doc.send("credit-card-info") do + doc.send('payment-sources') do + doc.send('credit-card-info') do add_credit_card(doc, credit_card) end end @@ -138,17 +138,17 @@ def scrub(transcript) private def add_auth_purchase(doc, money, payment_method, options) - doc.send("recurring-transaction", options[:recurring] ? "RECURRING" : "ECOMMERCE") + doc.send('recurring-transaction', options[:recurring] ? 'RECURRING' : 'ECOMMERCE') add_order(doc, options) add_amount(doc, money, options) - doc.send("transaction-fraud-info") do - doc.send("shopper-ip-address", options[:ip]) if options[:ip] + doc.send('transaction-fraud-info') do + doc.send('shopper-ip-address', options[:ip]) if options[:ip] end if payment_method.is_a?(String) - doc.send("vaulted-shopper-id", payment_method) + doc.send('vaulted-shopper-id', payment_method) else - doc.send("card-holder-info") do + doc.send('card-holder-info') do add_personal_info(doc, payment_method, options) end add_credit_card(doc, payment_method) @@ -161,34 +161,34 @@ def add_amount(doc, money, options) end def add_personal_info(doc, credit_card, options) - doc.send("first-name", credit_card.first_name) - doc.send("last-name", credit_card.last_name) + doc.send('first-name', credit_card.first_name) + doc.send('last-name', credit_card.last_name) doc.email(options[:email]) if options[:email] add_address(doc, options) end def add_credit_card(doc, card) - doc.send("credit-card") do - doc.send("card-number", card.number) - doc.send("security-code", card.verification_value) - doc.send("expiration-month", card.month) - doc.send("expiration-year", card.year) + doc.send('credit-card') do + doc.send('card-number', card.number) + doc.send('security-code', card.verification_value) + doc.send('expiration-month', card.month) + doc.send('expiration-year', card.year) end end def add_description(doc, description) - doc.send("transaction-meta-data") do - doc.send("meta-data") do - doc.send("meta-key", "description") - doc.send("meta-value", truncate(description, 500)) - doc.send("meta-description", "Description") + doc.send('transaction-meta-data') do + doc.send('meta-data') do + doc.send('meta-key', 'description') + doc.send('meta-value', truncate(description, 500)) + doc.send('meta-description', 'Description') end end end def add_order(doc, options) - doc.send("merchant-transaction-id", truncate(options[:order_id], 50)) if options[:order_id] - doc.send("soft-descriptor", options[:soft_descriptor]) if options[:soft_descriptor] + doc.send('merchant-transaction-id', truncate(options[:order_id], 50)) if options[:order_id] + doc.send('soft-descriptor', options[:soft_descriptor]) if options[:soft_descriptor] add_description(doc, options[:description]) if options[:description] end @@ -204,7 +204,7 @@ def add_address(doc, options) end def add_authorization(doc, authorization) - doc.send("transaction-id", authorization) + doc.send('transaction-id', authorization) end def parse(response) @@ -222,7 +222,7 @@ def parse(response) end end - parsed["content-location-header"] = response['content-location'] + parsed['content-location-header'] = response['content-location'] parsed end @@ -262,12 +262,12 @@ def commit(action, verb = :post) def url(action = nil) base = test? ? test_url : live_url - resource = (action == :store) ? "vaulted-shoppers" : "transactions" + resource = (action == :store) ? 'vaulted-shoppers' : 'transactions' "#{base}/#{resource}" end def cvv_result(parsed) - CVVResult.new(CVC_CODE_TRANSLATOR[parsed["cvv-response-code"]]) + CVVResult.new(CVC_CODE_TRANSLATOR[parsed['cvv-response-code']]) end def avs_result(parsed) @@ -283,31 +283,31 @@ def success_from(action, response) end def message_from(succeeded, parsed_response) - return "Success" if succeeded - parsed_response["description"] + return 'Success' if succeeded + parsed_response['description'] end def authorization_from(action, parsed_response) - (action == :store) ? vaulted_shopper_id(parsed_response) : parsed_response["transaction-id"] + (action == :store) ? vaulted_shopper_id(parsed_response) : parsed_response['transaction-id'] end def vaulted_shopper_id(parsed_response) - return nil unless parsed_response["content-location-header"] - parsed_response["content-location-header"].split("/").last + return nil unless parsed_response['content-location-header'] + parsed_response['content-location-header'].split('/').last end def error_code_from(parsed_response) - parsed_response["code"] + parsed_response['code'] end def root_attributes { - xmlns: "http://ws.plimus.com" + xmlns: 'http://ws.plimus.com' } end def root_element(action) - (action == :store) ? "vaulted-shopper" : "card-transaction" + (action == :store) ? 'vaulted-shopper' : 'card-transaction' end def headers @@ -320,7 +320,7 @@ def headers def build_xml_request(action) builder = Nokogiri::XML::Builder.new builder.__send__(root_element(action), root_attributes) do |doc| - doc.send("card-transaction-type", TRANSACTIONS[action]) if TRANSACTIONS[action] + doc.send('card-transaction-type', TRANSACTIONS[action]) if TRANSACTIONS[action] yield(doc) end builder.doc.root.to_xml @@ -336,7 +336,7 @@ def handle_response(response) end def bad_authentication_response - { "description" => "Unable to authenticate. Please check your credentials." } + { 'description' => 'Unable to authenticate. Please check your credentials.' } end end end diff --git a/lib/active_merchant/billing/gateways/bogus.rb b/lib/active_merchant/billing/gateways/bogus.rb index 2f5407c069d..f6662fca7f2 100644 --- a/lib/active_merchant/billing/gateways/bogus.rb +++ b/lib/active_merchant/billing/gateways/bogus.rb @@ -7,15 +7,15 @@ class BogusGateway < Gateway AUTHORIZATION_EMV_SUCCESS = '8A023030' AUTHORIZATION_EMV_DECLINE = '8A023035' - SUCCESS_MESSAGE = "Bogus Gateway: Forced success" - FAILURE_MESSAGE = "Bogus Gateway: Forced failure" - NUMBER_ERROR_MESSAGE = "Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error" - AMOUNT_ERROR_MESSAGE = "Bogus Gateway: Use amount ending in 00 for success, 05 for failure and anything else for exception" - UNSTORE_ERROR_MESSAGE = "Bogus Gateway: Use trans_id ending in 1 for success, 2 for exception and anything else for error" - CAPTURE_ERROR_MESSAGE = "Bogus Gateway: Use authorization number ending in 1 for exception, 2 for error and anything else for success" - VOID_ERROR_MESSAGE = "Bogus Gateway: Use authorization number ending in 1 for exception, 2 for error and anything else for success" - REFUND_ERROR_MESSAGE = "Bogus Gateway: Use trans_id number ending in 1 for exception, 2 for error and anything else for success" - CHECK_ERROR_MESSAGE = "Bogus Gateway: Use bank account number ending in 1 for success, 2 for exception and anything else for error" + SUCCESS_MESSAGE = 'Bogus Gateway: Forced success' + FAILURE_MESSAGE = 'Bogus Gateway: Forced failure' + NUMBER_ERROR_MESSAGE = 'Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error' + AMOUNT_ERROR_MESSAGE = 'Bogus Gateway: Use amount ending in 00 for success, 05 for failure and anything else for exception' + UNSTORE_ERROR_MESSAGE = 'Bogus Gateway: Use trans_id ending in 1 for success, 2 for exception and anything else for error' + CAPTURE_ERROR_MESSAGE = 'Bogus Gateway: Use authorization number ending in 1 for exception, 2 for error and anything else for success' + VOID_ERROR_MESSAGE = 'Bogus Gateway: Use authorization number ending in 1 for exception, 2 for error and anything else for success' + REFUND_ERROR_MESSAGE = 'Bogus Gateway: Use trans_id number ending in 1 for exception, 2 for error and anything else for success' + CHECK_ERROR_MESSAGE = 'Bogus Gateway: Use bank account number ending in 1 for success, 2 for exception and anything else for error' self.supported_countries = [] self.supported_cardtypes = [:bogus] diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb index adb7788bd35..c6bf5612262 100644 --- a/lib/active_merchant/billing/gateways/borgun.rb +++ b/lib/active_merchant/billing/gateways/borgun.rb @@ -1,9 +1,9 @@ -require "nokogiri" +require 'nokogiri' module ActiveMerchant #:nodoc: module Billing #:nodoc: class BorgunGateway < Gateway - self.display_name = "Borgun" + self.display_name = 'Borgun' self.homepage_url = 'http://www.borgun.com' self.test_url = 'https://gatewaytest.borgun.is/ws/Heimir.pub.ws:Authorization' @@ -77,9 +77,9 @@ def scrub(transcript) private CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")} - CURRENCY_CODES["ISK"] = "352" - CURRENCY_CODES["EUR"] = "978" - CURRENCY_CODES["USD"] = "840" + CURRENCY_CODES['ISK'] = '352' + CURRENCY_CODES['EUR'] = '978' + CURRENCY_CODES['USD'] = '840' def add_invoice(post, money, options) post[:TrAmount] = amount(money) @@ -91,7 +91,7 @@ def add_payment_method(post, payment_method) post[:PAN] = payment_method.number post[:ExpDate] = format(payment_method.year, :two_digits) + format(payment_method.month, :two_digits) post[:CVC2] = payment_method.verification_value - post[:DateAndTime] = Time.now.strftime("%y%m%d%H%M%S") + post[:DateAndTime] = Time.now.strftime('%y%m%d%H%M%S') post[:RRN] = 'AMRCNT' + six_random_digits end @@ -151,7 +151,7 @@ def success_from(response) def message_from(succeeded, response) if succeeded - "Succeeded" + 'Succeeded' else response[:message] || "Error with ActionCode=#{response[:actioncode]}" end @@ -167,11 +167,11 @@ def authorization_from(response) response[:transtype], response[:tramount], response[:trcurrency] - ].join("|") + ].join('|') end def split_authorization(authorization) - dateandtime, batch, transaction, rrn, authcode, transtype, tramount, currency = authorization.split("|") + dateandtime, batch, transaction, rrn, authcode, transtype, tramount, currency = authorization.split('|') [dateandtime, batch, transaction, rrn, authcode, transtype, tramount, currency] end diff --git a/lib/active_merchant/billing/gateways/bpoint.rb b/lib/active_merchant/billing/gateways/bpoint.rb index 41ed27d6266..dc48ffa47a1 100644 --- a/lib/active_merchant/billing/gateways/bpoint.rb +++ b/lib/active_merchant/billing/gateways/bpoint.rb @@ -185,7 +185,7 @@ def commit(request_body) end def request_headers - { "Content-Type" => "application/soap+xml; charset=utf-8" } + { 'Content-Type' => 'application/soap+xml; charset=utf-8' } end def parse(body) diff --git a/lib/active_merchant/billing/gateways/braintree/braintree_common.rb b/lib/active_merchant/billing/gateways/braintree/braintree_common.rb index b16b18e5f7b..7343584f7aa 100644 --- a/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +++ b/lib/active_merchant/billing/gateways/braintree/braintree_common.rb @@ -13,7 +13,7 @@ def supports_scrubbing end def scrub(transcript) - return "" if transcript.blank? + return '' if transcript.blank? transcript. gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). gsub(%r((&?ccnumber=)\d*(&?)), '\1[FILTERED]\2'). diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 6651dcc6d52..96bdbdae5b8 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -1,9 +1,9 @@ require 'active_merchant/billing/gateways/braintree/braintree_common' begin - require "braintree" + require 'braintree' rescue LoadError - raise "Could not load the braintree gem. Use `gem install braintree` to install it." + raise 'Could not load the braintree gem. Use `gem install braintree` to install it.' end unless Braintree::Version::Major == 2 && Braintree::Version::Minor >= 78 @@ -125,7 +125,7 @@ def store(creditcard, options = {}) customer_exists_response = nil r.process{customer_exists_response = check_customer_exists(options[:customer])} r.process do - if customer_exists_response.params["exists"] + if customer_exists_response.params['exists'] add_credit_card_to_customer(creditcard, options) else add_customer_with_credit_card(creditcard, options) @@ -149,7 +149,7 @@ def update(vault_id, creditcard, options = {}) :cardholder_name => creditcard.name, :number => creditcard.number, :cvv => creditcard.verification_value, - :expiration_month => creditcard.month.to_s.rjust(2, "0"), + :expiration_month => creditcard.month.to_s.rjust(2, '0'), :expiration_year => creditcard.year.to_s } }, options)[:credit_card] @@ -176,7 +176,7 @@ def unstore(customer_vault_id, options = {}) else @braintree_gateway.customer.delete(customer_vault_id) end - Response.new(true, "OK") + Response.new(true, 'OK') end end alias_method :delete, :unstore @@ -187,7 +187,7 @@ def supports_network_tokenization? def verify_credentials begin - @braintree_gateway.transaction.find("non_existent_token") + @braintree_gateway.transaction.find('non_existent_token') rescue Braintree::AuthenticationError return false rescue Braintree::NotFoundError @@ -203,9 +203,9 @@ def check_customer_exists(customer_vault_id) commit do begin @braintree_gateway.customer.find(customer_vault_id) - ActiveMerchant::Billing::Response.new(true, "Customer found", {exists: true}, authorization: customer_vault_id) + ActiveMerchant::Billing::Response.new(true, 'Customer found', {exists: true}, authorization: customer_vault_id) rescue Braintree::NotFoundError - ActiveMerchant::Billing::Response.new(true, "Customer not found", {exists: false}) + ActiveMerchant::Billing::Response.new(true, 'Customer not found', {exists: false}) end end end @@ -220,7 +220,7 @@ def add_customer_with_credit_card(creditcard, options) :cardholder_name => creditcard.name, :number => creditcard.number, :cvv => creditcard.verification_value, - :expiration_month => creditcard.month.to_s.rjust(2, "0"), + :expiration_month => creditcard.month.to_s.rjust(2, '0'), :expiration_year => creditcard.year.to_s, :token => options[:credit_card_token] } @@ -254,7 +254,7 @@ def add_credit_card_to_customer(credit_card, options) cardholder_name: credit_card.name, number: credit_card.number, cvv: credit_card.verification_value, - expiration_month: credit_card.month.to_s.rjust(2, "0"), + expiration_month: credit_card.month.to_s.rjust(2, '0'), expiration_year: credit_card.year.to_s, } parameters[:billing_address] = map_address(options[:billing_address]) if options[:billing_address] @@ -336,9 +336,9 @@ def commit(&block) def message_from_result(result) if result.success? - "OK" + 'OK' elsif result.errors.any? - result.errors.map { |e| "#{e.message} (#{e.code})" }.join(" ") + result.errors.map { |e| "#{e.message} (#{e.code})" }.join(' ') elsif result.credit_card_verification "Processor declined: #{result.credit_card_verification.processor_response_text} (#{result.credit_card_verification.processor_response_code})" else @@ -377,41 +377,41 @@ def avs_code_from(transaction) def avs_mapping { - "street: M, zip: M" => "M", - "street: M, zip: N" => "A", - "street: M, zip: U" => "B", - "street: M, zip: I" => "B", - "street: M, zip: A" => "B", - - "street: N, zip: M" => "Z", - "street: N, zip: N" => "C", - "street: N, zip: U" => "C", - "street: N, zip: I" => "C", - "street: N, zip: A" => "C", - - "street: U, zip: M" => "P", - "street: U, zip: N" => "N", - "street: U, zip: U" => "I", - "street: U, zip: I" => "I", - "street: U, zip: A" => "I", - - "street: I, zip: M" => "P", - "street: I, zip: N" => "C", - "street: I, zip: U" => "I", - "street: I, zip: I" => "I", - "street: I, zip: A" => "I", - - "street: A, zip: M" => "P", - "street: A, zip: N" => "C", - "street: A, zip: U" => "I", - "street: A, zip: I" => "I", - "street: A, zip: A" => "I" + 'street: M, zip: M' => 'M', + 'street: M, zip: N' => 'A', + 'street: M, zip: U' => 'B', + 'street: M, zip: I' => 'B', + 'street: M, zip: A' => 'B', + + 'street: N, zip: M' => 'Z', + 'street: N, zip: N' => 'C', + 'street: N, zip: U' => 'C', + 'street: N, zip: I' => 'C', + 'street: N, zip: A' => 'C', + + 'street: U, zip: M' => 'P', + 'street: U, zip: N' => 'N', + 'street: U, zip: U' => 'I', + 'street: U, zip: I' => 'I', + 'street: U, zip: A' => 'I', + + 'street: I, zip: M' => 'P', + 'street: I, zip: N' => 'C', + 'street: I, zip: U' => 'I', + 'street: I, zip: I' => 'I', + 'street: I, zip: A' => 'I', + + 'street: A, zip: M' => 'P', + 'street: A, zip: N' => 'C', + 'street: A, zip: U' => 'I', + 'street: A, zip: I' => 'I', + 'street: A, zip: A' => 'I' } end def message_from_transaction_result(result) - if result.transaction && result.transaction.status == "gateway_rejected" - "Transaction declined - gateway rejected" + if result.transaction && result.transaction.status == 'gateway_rejected' + 'Transaction declined - gateway rejected' elsif result.transaction "#{result.transaction.processor_response_code} #{result.transaction.processor_response_text}" else @@ -454,22 +454,22 @@ def extract_refund_args(args) def customer_hash(customer, include_credit_cards=false) hash = { - "email" => customer.email, - "phone" => customer.phone, - "first_name" => customer.first_name, - "last_name" => customer.last_name, - "id" => customer.id + 'email' => customer.email, + 'phone' => customer.phone, + 'first_name' => customer.first_name, + 'last_name' => customer.last_name, + 'id' => customer.id } if include_credit_cards - hash["credit_cards"] = customer.credit_cards.map do |cc| + hash['credit_cards'] = customer.credit_cards.map do |cc| { - "bin" => cc.bin, - "expiration_date" => cc.expiration_date, - "token" => cc.token, - "last_4" => cc.last_4, - "card_type" => cc.card_type, - "masked_number" => cc.masked_number + 'bin' => cc.bin, + 'expiration_date' => cc.expiration_date, + 'token' => cc.token, + 'last_4' => cc.last_4, + 'card_type' => cc.card_type, + 'masked_number' => cc.masked_number } end end @@ -479,16 +479,16 @@ def customer_hash(customer, include_credit_cards=false) def transaction_hash(result) unless result.success? - return { "processor_response_code" => response_code_from_result(result) } + return { 'processor_response_code' => response_code_from_result(result) } end transaction = result.transaction if transaction.vault_customer vault_customer = { } - vault_customer["credit_cards"] = transaction.vault_customer.credit_cards.map do |cc| + vault_customer['credit_cards'] = transaction.vault_customer.credit_cards.map do |cc| { - "bin" => cc.bin + 'bin' => cc.bin } end else @@ -496,49 +496,49 @@ def transaction_hash(result) end customer_details = { - "id" => transaction.customer_details.id, - "email" => transaction.customer_details.email, - "phone" => transaction.customer_details.phone, + 'id' => transaction.customer_details.id, + 'email' => transaction.customer_details.email, + 'phone' => transaction.customer_details.phone, } billing_details = { - "street_address" => transaction.billing_details.street_address, - "extended_address" => transaction.billing_details.extended_address, - "company" => transaction.billing_details.company, - "locality" => transaction.billing_details.locality, - "region" => transaction.billing_details.region, - "postal_code" => transaction.billing_details.postal_code, - "country_name" => transaction.billing_details.country_name, + 'street_address' => transaction.billing_details.street_address, + 'extended_address' => transaction.billing_details.extended_address, + 'company' => transaction.billing_details.company, + 'locality' => transaction.billing_details.locality, + 'region' => transaction.billing_details.region, + 'postal_code' => transaction.billing_details.postal_code, + 'country_name' => transaction.billing_details.country_name, } shipping_details = { - "street_address" => transaction.shipping_details.street_address, - "extended_address" => transaction.shipping_details.extended_address, - "company" => transaction.shipping_details.company, - "locality" => transaction.shipping_details.locality, - "region" => transaction.shipping_details.region, - "postal_code" => transaction.shipping_details.postal_code, - "country_name" => transaction.shipping_details.country_name, + 'street_address' => transaction.shipping_details.street_address, + 'extended_address' => transaction.shipping_details.extended_address, + 'company' => transaction.shipping_details.company, + 'locality' => transaction.shipping_details.locality, + 'region' => transaction.shipping_details.region, + 'postal_code' => transaction.shipping_details.postal_code, + 'country_name' => transaction.shipping_details.country_name, } credit_card_details = { - "masked_number" => transaction.credit_card_details.masked_number, - "bin" => transaction.credit_card_details.bin, - "last_4" => transaction.credit_card_details.last_4, - "card_type" => transaction.credit_card_details.card_type, - "token" => transaction.credit_card_details.token + 'masked_number' => transaction.credit_card_details.masked_number, + 'bin' => transaction.credit_card_details.bin, + 'last_4' => transaction.credit_card_details.last_4, + 'card_type' => transaction.credit_card_details.card_type, + 'token' => transaction.credit_card_details.token } { - "order_id" => transaction.order_id, - "amount" => transaction.amount.to_s, - "status" => transaction.status, - "credit_card_details" => credit_card_details, - "customer_details" => customer_details, - "billing_details" => billing_details, - "shipping_details" => shipping_details, - "vault_customer" => vault_customer, - "merchant_account_id" => transaction.merchant_account_id, - "processor_response_code" => response_code_from_result(result) + 'order_id' => transaction.order_id, + 'amount' => transaction.amount.to_s, + 'status' => transaction.status, + 'credit_card_details' => credit_card_details, + 'customer_details' => customer_details, + 'billing_details' => billing_details, + 'shipping_details' => shipping_details, + 'vault_customer' => vault_customer, + 'merchant_account_id' => transaction.merchant_account_id, + 'processor_response_code' => response_code_from_result(result) } end @@ -547,7 +547,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) :amount => localized_amount(money, options[:currency] || default_currency).to_s, :order_id => options[:order_id], :customer => { - :id => options[:store] == true ? "" : options[:store], + :id => options[:store] == true ? '' : options[:store], :email => scrub_email(options[:email]), :phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] && options[:billing_address][:phone]) @@ -592,7 +592,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) if credit_card_or_vault_id.source == :apple_pay parameters[:apple_pay_card] = { :number => credit_card_or_vault_id.number, - :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, "0"), + :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, '0'), :expiration_year => credit_card_or_vault_id.year.to_s, :cardholder_name => credit_card_or_vault_id.name, :cryptogram => credit_card_or_vault_id.payment_cryptogram, @@ -602,7 +602,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) parameters[:android_pay_card] = { :number => credit_card_or_vault_id.number, :cryptogram => credit_card_or_vault_id.payment_cryptogram, - :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, "0"), + :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, '0'), :expiration_year => credit_card_or_vault_id.year.to_s, :google_transaction_id => credit_card_or_vault_id.transaction_id, :source_card_type => credit_card_or_vault_id.brand, @@ -614,7 +614,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) parameters[:credit_card] = { :number => credit_card_or_vault_id.number, :cvv => credit_card_or_vault_id.verification_value, - :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, "0"), + :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, '0'), :expiration_year => credit_card_or_vault_id.year.to_s, :cardholder_name => credit_card_or_vault_id.name } diff --git a/lib/active_merchant/billing/gateways/braintree_orange.rb b/lib/active_merchant/billing/gateways/braintree_orange.rb index a8b76b3d8b2..f56502eb7a0 100644 --- a/lib/active_merchant/billing/gateways/braintree_orange.rb +++ b/lib/active_merchant/billing/gateways/braintree_orange.rb @@ -7,7 +7,7 @@ class BraintreeOrangeGateway < SmartPs include BraintreeCommon self.display_name = 'Braintree (Orange Platform)' - self.supported_countries = ["US"] + self.supported_countries = ['US'] self.live_url = self.test_url = 'https://secure.braintreepaymentgateway.com/api/transact.php' diff --git a/lib/active_merchant/billing/gateways/bridge_pay.rb b/lib/active_merchant/billing/gateways/bridge_pay.rb index 5c57828f51c..091d8ac1a65 100644 --- a/lib/active_merchant/billing/gateways/bridge_pay.rb +++ b/lib/active_merchant/billing/gateways/bridge_pay.rb @@ -1,16 +1,16 @@ -require "nokogiri" +require 'nokogiri' module ActiveMerchant #:nodoc: module Billing #:nodoc: class BridgePayGateway < Gateway - self.display_name = "BridgePay" - self.homepage_url = "http://www.bridgepaynetwork.com/" + self.display_name = 'BridgePay' + self.homepage_url = 'http://www.bridgepaynetwork.com/' - self.test_url = "https://gatewaystage.itstgate.com/SmartPayments/transact3.asmx" - self.live_url = "https://gateway.itstgate.com/SmartPayments/transact3.asmx" + self.test_url = 'https://gatewaystage.itstgate.com/SmartPayments/transact3.asmx' + self.live_url = 'https://gateway.itstgate.com/SmartPayments/transact3.asmx' - self.supported_countries = ["CA", "US"] - self.default_currency = "USD" + self.supported_countries = ['CA', 'US'] + self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb] @@ -20,10 +20,10 @@ def initialize(options={}) end def purchase(amount, payment_method, options={}) - post = initialize_required_fields("Sale") + post = initialize_required_fields('Sale') # Allow the same amount in multiple transactions. - post[:ExtData] = "<Force>T</Force>" + post[:ExtData] = '<Force>T</Force>' add_invoice(post, amount, options) add_payment_method(post, payment_method) add_customer_data(post, options) @@ -32,7 +32,7 @@ def purchase(amount, payment_method, options={}) end def authorize(amount, payment_method, options={}) - post = initialize_required_fields("Auth") + post = initialize_required_fields('Auth') add_invoice(post, amount, options) add_payment_method(post, payment_method) @@ -42,7 +42,7 @@ def authorize(amount, payment_method, options={}) end def capture(amount, authorization, options={}) - post = initialize_required_fields("Force") + post = initialize_required_fields('Force') add_invoice(post, amount, options) add_reference(post, authorization) @@ -52,7 +52,7 @@ def capture(amount, authorization, options={}) end def refund(amount, authorization, options={}) - post = initialize_required_fields("Return") + post = initialize_required_fields('Return') add_invoice(post, amount, options) add_reference(post, authorization) @@ -61,7 +61,7 @@ def refund(amount, authorization, options={}) end def void(authorization, options={}) - post = initialize_required_fields("Void") + post = initialize_required_fields('Void') add_reference(post, authorization) @@ -119,31 +119,31 @@ def add_payment_method(post, payment_method) end def add_token(post, payment_method) - payment_method = payment_method.split("|") + payment_method = payment_method.split('|') post[:ExtData] = "<Force>T</Force><CardVault><Transaction>Read</Transaction><CustomerPaymentInfoKey>#{payment_method[1]}</CustomerPaymentInfoKey><Token>#{payment_method[0]}</Token><ExpDate>#{payment_method[2]}</ExpDate></CardVault>" end def initialize_required_fields(transaction_type) post = {} post[:TransType] = transaction_type - post[:Amount] = "" - post[:PNRef] = "" - post[:InvNum] = "" - post[:CardNum] = "" - post[:ExpDate] = "" - post[:MagData] = "" - post[:NameOnCard] = "" - post[:Zip] = "" - post[:Street] = "" - post[:CVNum] = "" - post[:MagData] = "" - post[:ExtData] = "" - post[:MICR] = "" - post[:DL] = "" - post[:SS] = "" - post[:DOB] = "" - post[:StateCode] = "" - post[:CheckType] = "" + post[:Amount] = '' + post[:PNRef] = '' + post[:InvNum] = '' + post[:CardNum] = '' + post[:ExpDate] = '' + post[:MagData] = '' + post[:NameOnCard] = '' + post[:Zip] = '' + post[:Street] = '' + post[:CVNum] = '' + post[:MagData] = '' + post[:ExtData] = '' + post[:MICR] = '' + post[:DL] = '' + post[:SS] = '' + post[:DOB] = '' + post[:StateCode] = '' + post[:CheckType] = '' post end @@ -167,7 +167,7 @@ def parse(xml) response = {} doc = Nokogiri::XML(xml) - doc.root.xpath("*").each do |node| + doc.root.xpath('*').each do |node| if (node.elements.size == 0) response[node.name.downcase.to_sym] = node.text else @@ -208,7 +208,7 @@ def base_url end def success_from(response) - response[:result] == "0" + response[:result] == '0' end def message_from(response) @@ -217,14 +217,14 @@ def message_from(response) def authorization_from(response) if response[:token] - [response[:token], response[:customerpaymentinfokey], response[:expdate]].join("|") + [response[:token], response[:customerpaymentinfokey], response[:expdate]].join('|') else - [response[:authcode], response[:pnref]].join("|") + [response[:authcode], response[:pnref]].join('|') end end def split_authorization(authorization) - authcode, pnref = authorization.split("|") + authcode, pnref = authorization.split('|') [authcode, pnref] end @@ -238,7 +238,7 @@ def post_data(post) { :UserName => @options[:user_name], :Password => @options[:password] - }.merge(post).collect{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join("&") + }.merge(post).collect{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/cams.rb b/lib/active_merchant/billing/gateways/cams.rb index 93d9297dc47..c053f77ecbc 100644 --- a/lib/active_merchant/billing/gateways/cams.rb +++ b/lib/active_merchant/billing/gateways/cams.rb @@ -1,7 +1,7 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class CamsGateway < Gateway - self.live_url = "https://secure.centralams.com/gw/api/transact.php" + self.live_url = 'https://secure.centralams.com/gw/api/transact.php' self.supported_countries = ['US'] self.default_currency = 'USD' @@ -83,7 +83,7 @@ def purchase(money, payment, options={}) post[:transactionid] = split_authorization(payment)[0] end - commit("sale", post) + commit('sale', post) end def authorize(money, payment, options={}) @@ -156,8 +156,8 @@ def add_address(post, creditcard, options={}) def add_reference(post, authorization) transaction_id, authcode = split_authorization(authorization) - post["transactionid"] = transaction_id - post["authcode"] = authcode + post['transactionid'] = transaction_id + post['authcode'] = authcode end def add_invoice(post, money, options) @@ -172,10 +172,10 @@ def add_payment(post, payment) end def parse(body) - kvs = body.split("&") + kvs = body.split('&') kvs.inject({}) { |h, kv| - k,v = kv.split("=") + k,v = kv.split('=') h[k] = v h } @@ -199,19 +199,19 @@ def commit(action, parameters) end def success_from(response) - response["response_code"] == "100" + response['response_code'] == '100' end def message_from(response) - response["responsetext"] + response['responsetext'] end def authorization_from(response) - [response["transactionid"], response["authcode"]].join("#") + [response['transactionid'], response['authcode']].join('#') end def split_authorization(authorization) - transaction_id, authcode = authorization.split("#") + transaction_id, authcode = authorization.split('#') [transaction_id, authcode] end @@ -219,11 +219,11 @@ def post_data(parameters = {}) parameters[:password] = @options[:password] parameters[:username] = @options[:username] - parameters.collect{|k,v| "#{k}=#{v}" }.join("&") + parameters.collect{|k,v| "#{k}=#{v}" }.join('&') end def error_code_from(response) - STANDARD_ERROR_CODE_MAPPING[response["response_code"]] + STANDARD_ERROR_CODE_MAPPING[response['response_code']] end end end diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb index fb4b5a0c3bc..dd929a56d2e 100644 --- a/lib/active_merchant/billing/gateways/card_stream.rb +++ b/lib/active_merchant/billing/gateways/card_stream.rb @@ -2,7 +2,7 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class CardStreamGateway < Gateway - THREEDSECURE_REQUIRED_DEPRECATION_MESSAGE = "Specifying the :threeDSRequired initialization option is deprecated. Please use the `:threeds_required => true` *transaction* option instead." + THREEDSECURE_REQUIRED_DEPRECATION_MESSAGE = 'Specifying the :threeDSRequired initialization option is deprecated. Please use the `:threeds_required => true` *transaction* option instead.' self.test_url = self.live_url = 'https://gateway.cardstream.com/direct/' self.money_format = :cents @@ -13,96 +13,96 @@ class CardStreamGateway < Gateway self.display_name = 'CardStream' CURRENCY_CODES = { - "AED" => "784", - "ALL" => "008", - "AMD" => "051", - "ANG" => "532", - "ARS" => "032", - "AUD" => "036", - "AWG" => "533", - "BAM" => "977", - "BBD" => "052", - "BGN" => "975", - "BMD" => "060", - "BOB" => "068", - "BRL" => "986", - "BSD" => "044", - "BWP" => "072", - "BZD" => "084", - "CAD" => "124", - "CHF" => "756", - "CLP" => "152", - "CNY" => "156", - "COP" => "170", - "CRC" => "188", - "CZK" => "203", - "DKK" => "208", - "DOP" => "214", - "EGP" => "818", - "EUR" => "978", - "GBP" => "826", - "GEL" => "981", - "GIP" => "292", - "GTQ" => "320", - "GYD" => "328", - "HKD" => "344", - "HNL" => "340", - "HRK" => "191", - "HUF" => "348", - "ISK" => "352", - "IDR" => "360", - "ILS" => "376", - "INR" => "356", - "JPY" => "392", - "JMD" => "388", - "KES" => "404", - "KRW" => "410", - "KYD" => "136", - "LBP" => "422", - "LKR" => "144", - "MAD" => "504", - "MVR" => "462", - "MWK" => "454", - "MXN" => "484", - "MYR" => "458", - "NAD" => "516", - "NGN" => "566", - "NIO" => "558", - "NOK" => "578", - "NPR" => "524", - "NZD" => "554", - "PAB" => "590", - "PEN" => "604", - "PGK" => "598", - "PHP" => "608", - "PKR" => "586", - "PLN" => "985", - "PYG" => "600", - "QAR" => "634", - "RON" => "946", - "RSD" => "941", - "RUB" => "643", - "RWF" => "646", - "SAR" => "682", - "SEK" => "752", - "SGD" => "702", - "SRD" => "968", - "THB" => "764", - "TND" => "788", - "TRY" => "949", - "TTD" => "780", - "TWD" => "901", - "TZS" => "834", - "UAH" => "980", - "UGX" => "800", - "USD" => "840", - "UYU" => "858", - "VND" => "704", - "WST" => "882", - "XAF" => "950", - "XCD" => "951", - "XOF" => "952", - "ZAR" => "710" + 'AED' => '784', + 'ALL' => '008', + 'AMD' => '051', + 'ANG' => '532', + 'ARS' => '032', + 'AUD' => '036', + 'AWG' => '533', + 'BAM' => '977', + 'BBD' => '052', + 'BGN' => '975', + 'BMD' => '060', + 'BOB' => '068', + 'BRL' => '986', + 'BSD' => '044', + 'BWP' => '072', + 'BZD' => '084', + 'CAD' => '124', + 'CHF' => '756', + 'CLP' => '152', + 'CNY' => '156', + 'COP' => '170', + 'CRC' => '188', + 'CZK' => '203', + 'DKK' => '208', + 'DOP' => '214', + 'EGP' => '818', + 'EUR' => '978', + 'GBP' => '826', + 'GEL' => '981', + 'GIP' => '292', + 'GTQ' => '320', + 'GYD' => '328', + 'HKD' => '344', + 'HNL' => '340', + 'HRK' => '191', + 'HUF' => '348', + 'ISK' => '352', + 'IDR' => '360', + 'ILS' => '376', + 'INR' => '356', + 'JPY' => '392', + 'JMD' => '388', + 'KES' => '404', + 'KRW' => '410', + 'KYD' => '136', + 'LBP' => '422', + 'LKR' => '144', + 'MAD' => '504', + 'MVR' => '462', + 'MWK' => '454', + 'MXN' => '484', + 'MYR' => '458', + 'NAD' => '516', + 'NGN' => '566', + 'NIO' => '558', + 'NOK' => '578', + 'NPR' => '524', + 'NZD' => '554', + 'PAB' => '590', + 'PEN' => '604', + 'PGK' => '598', + 'PHP' => '608', + 'PKR' => '586', + 'PLN' => '985', + 'PYG' => '600', + 'QAR' => '634', + 'RON' => '946', + 'RSD' => '941', + 'RUB' => '643', + 'RWF' => '646', + 'SAR' => '682', + 'SEK' => '752', + 'SGD' => '702', + 'SRD' => '968', + 'THB' => '764', + 'TND' => '788', + 'TRY' => '949', + 'TTD' => '780', + 'TWD' => '901', + 'TZS' => '834', + 'UAH' => '980', + 'UGX' => '800', + 'USD' => '840', + 'UYU' => '858', + 'VND' => '704', + 'WST' => '882', + 'XAF' => '950', + 'XCD' => '951', + 'XOF' => '952', + 'ZAR' => '710' } CVV_CODE = { @@ -118,11 +118,11 @@ class CardStreamGateway < Gateway # 4 - Postcode not matched. # 8 - Postcode partially matched. AVS_POSTAL_MATCH = { - "0" => nil, - "1" => nil, - "2" => "Y", - "4" => "N", - "8" => "N" + '0' => nil, + '1' => nil, + '2' => 'Y', + '4' => 'N', + '8' => 'N' } # 0 - No additional information available. @@ -131,11 +131,11 @@ class CardStreamGateway < Gateway # 4 - Address numeric not matched. # 8 - Address numeric partially matched. AVS_STREET_MATCH = { - "0" => nil, - "1" => nil, - "2" => "Y", - "4" => "N", - "8" => "N" + '0' => nil, + '1' => nil, + '2' => 'Y', + '4' => 'N', + '8' => 'N' } def initialize(options = {}) @@ -189,7 +189,7 @@ def refund(money, authorization, options = {}) return response if response.success? return response unless options[:force_full_refund_if_unsettled] - if response.params["responseCode"] == "65541" + if response.params['responseCode'] == '65541' void(authorization, options) else response @@ -295,11 +295,11 @@ def add_remote_address(post, options={}) end def normalize_line_endings(str) - str.gsub(/%0D%0A|%0A%0D|%0D/, "%0A") + str.gsub(/%0D%0A|%0A%0D|%0D/, '%0A') end def add_hmac(post) - result = post.sort.collect { |key, value| "#{key}=#{normalize_line_endings(CGI.escape(value.to_s))}" }.join("&") + result = post.sort.collect { |key, value| "#{key}=#{normalize_line_endings(CGI.escape(value.to_s))}" }.join('&') result = Digest::SHA512.hexdigest("#{result}#{@options[:shared_secret]}") add_pair(post, :signature, result) @@ -307,9 +307,9 @@ def add_hmac(post) def parse(body) result = {} - pairs = body.split("&") + pairs = body.split('&') pairs.each do |pair| - a = pair.split("=") + a = pair.split('=') # because some value pairs don't have a value result[a[0].to_sym] = a[1] == nil ? '' : CGI.unescape(a[1]) end @@ -327,8 +327,8 @@ def commit(action, parameters) response = parse(ssl_post(self.live_url, post_data(action, parameters))) - Response.new(response[:responseCode] == "0", - response[:responseCode] == "0" ? "APPROVED" : response[:responseMessage], + Response.new(response[:responseCode] == '0', + response[:responseCode] == '0' ? 'APPROVED' : response[:responseMessage], response, :test => test?, :authorization => response[:xref], @@ -341,14 +341,14 @@ def avs_from(response) postal_match = AVS_POSTAL_MATCH[response[:avscv2ResponseCode].to_s[1, 1]] street_match = AVS_STREET_MATCH[response[:avscv2ResponseCode].to_s[2, 1]] - code = if postal_match == "Y" && street_match == "Y" - "M" - elsif postal_match == "Y" - "P" - elsif street_match == "Y" - "A" + code = if postal_match == 'Y' && street_match == 'Y' + 'M' + elsif postal_match == 'Y' + 'P' + elsif street_match == 'Y' + 'A' else - "I" + 'I' end AVSResult.new({ @@ -364,7 +364,7 @@ def currency_code(currency) end def post_data(action, parameters = {}) - parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def add_pair(post, key, value, options = {}) diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb index 664626ab8fa..afafc938d9e 100644 --- a/lib/active_merchant/billing/gateways/cardknox.rb +++ b/lib/active_merchant/billing/gateways/cardknox.rb @@ -112,7 +112,7 @@ def scrub(transcript) private def split_authorization(authorization) - authorization.split(";") + authorization.split(';') end def add_reference(post, reference) @@ -134,7 +134,7 @@ def source_type(source) def source_type_from(authorization) _, _, source_type = split_authorization(authorization) - (source_type || "credit_card").to_sym + (source_type || 'credit_card').to_sym end def add_source(post, source) @@ -294,10 +294,10 @@ def commit(action, source_type, parameters) end def message_from(response) - if response[:status] == "Approved" - "Success" + if response[:status] == 'Approved' + 'Success' elsif response[:error].blank? - "Unspecified error" + 'Unspecified error' else response[:error] end @@ -310,7 +310,7 @@ def authorization_from(response, source_type) def post_data(command, parameters = {}) initial_parameters = { Key: @options[:api_key], - Version: "4.5.4", + Version: '4.5.4', SoftwareName: 'Active Merchant', SoftwareVersion: "#{ActiveMerchant::VERSION}", Command: command, @@ -321,7 +321,7 @@ def post_data(command, parameters = {}) initial_parameters[:Hash] = "s/#{seed}/#{hash}/n" unless @options[:pin].blank? parameters = initial_parameters.merge(parameters) - parameters.reject{|k, v| v.blank?}.collect{ |key, value| "x#{key}=#{CGI.escape(value.to_s)}" }.join("&") + parameters.reject{|k, v| v.blank?}.collect{ |key, value| "x#{key}=#{CGI.escape(value.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/cardprocess.rb b/lib/active_merchant/billing/gateways/cardprocess.rb index 059ad175298..020a39ec17f 100644 --- a/lib/active_merchant/billing/gateways/cardprocess.rb +++ b/lib/active_merchant/billing/gateways/cardprocess.rb @@ -189,7 +189,7 @@ def post_data(action, parameters = {}) post[:authentication][:password] = @options[:password] post[:authentication][:entityId] = @options[:entity_id] post[:paymentType] = action - dot_flatten_hash(post).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&") + dot_flatten_hash(post).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') end def error_code_from(response) diff --git a/lib/active_merchant/billing/gateways/cashnet.rb b/lib/active_merchant/billing/gateways/cashnet.rb index a883bf34b30..f3ae7dc87f5 100644 --- a/lib/active_merchant/billing/gateways/cashnet.rb +++ b/lib/active_merchant/billing/gateways/cashnet.rb @@ -3,13 +3,13 @@ module Billing #:nodoc: class CashnetGateway < Gateway include Empty - self.live_url = "https://commerce.cashnet.com/" - self.test_url = "https://train.cashnet.com/" + self.live_url = 'https://commerce.cashnet.com/' + self.test_url = 'https://train.cashnet.com/' - self.supported_countries = ["US"] + self.supported_countries = ['US'] self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb] - self.homepage_url = "http://www.higherone.com/" - self.display_name = "Cashnet" + self.homepage_url = 'http://www.higherone.com/' + self.display_name = 'Cashnet' self.money_format = :dollars self.max_retries = 0 @@ -34,7 +34,7 @@ def initialize(options = {}) :password, :merchant_gateway_name ) - options[:default_item_code] ||= "FEE" + options[:default_item_code] ||= 'FEE' super end @@ -92,9 +92,9 @@ def post_data(action, parameters = {}) post[:merchant] = @options[:merchant] post[:operator] = @options[:operator] post[:password] = @options[:password] - post[:station] = (@options[:station] || "WEB") + post[:station] = (@options[:station] || 'WEB') post[:custcode] = (@options[:custcode] || "ActiveMerchant/#{ActiveMerchant::VERSION}") - post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def add_creditcard(post, creditcard) @@ -149,7 +149,7 @@ def handle_response(response) end def unparsable_response(raw_response) - message = "Unparsable response received from Cashnet. Please contact Cashnet if you continue to receive this message." + message = 'Unparsable response received from Cashnet. Please contact Cashnet if you continue to receive this message.' message += " (The raw response returned by the API was #{raw_response.inspect})" return Response.new(false, message) end diff --git a/lib/active_merchant/billing/gateways/cc5.rb b/lib/active_merchant/billing/gateways/cc5.rb index 8ae9fbaded0..869296dcfb9 100644 --- a/lib/active_merchant/billing/gateways/cc5.rb +++ b/lib/active_merchant/billing/gateways/cc5.rb @@ -148,7 +148,7 @@ def currency_code(currency) end def commit(request) - raw_response = ssl_post((test? ? self.test_url : self.live_url), "DATA=" + request) + raw_response = ssl_post((test? ? self.test_url : self.live_url), 'DATA=' + request) response = parse(raw_response) @@ -182,7 +182,7 @@ def parse_element(response, node) end def success?(response) - (response[:response] == "Approved") + (response[:response] == 'Approved') end def normalize(text) diff --git a/lib/active_merchant/billing/gateways/cecabank.rb b/lib/active_merchant/billing/gateways/cecabank.rb index 48982bd230c..8bb644aa847 100644 --- a/lib/active_merchant/billing/gateways/cecabank.rb +++ b/lib/active_merchant/billing/gateways/cecabank.rb @@ -123,7 +123,7 @@ def parse(body) root = REXML::Document.new(body).root - response[:success] = (root.attributes['valor'] == "OK") + response[:success] = (root.attributes['valor'] == 'OK') response[:date] = root.attributes['fecha'] response[:operation_number] = root.attributes['numeroOperacion'] response[:message] = root.attributes['valor'] @@ -142,7 +142,7 @@ def parse(body) response[:error_code] = root.elements['ERROR/codigo'].text response[:error_message] = root.elements['ERROR/descripcion'].text else - if root.elements['OPERACION'].attributes['numeroOperacion'] == "000" + if root.elements['OPERACION'].attributes['numeroOperacion'] == '000' if(root.elements['OPERACION/numeroAutorizacion']) response[:authorization] = root.elements['OPERACION/numeroAutorizacion'].text end @@ -155,7 +155,7 @@ def parse(body) rescue REXML::ParseException => e response[:success] = false - response[:message] = "Unable to parse the response." + response[:message] = 'Unable to parse the response.' response[:error_message] = e.message response end @@ -195,15 +195,15 @@ def post_data(params) else "#{key}=#{CGI.escape(value.to_s)}" end - end.compact.join("&") + end.compact.join('&') end def build_authorization(response) - [response[:reference], response[:authorization]].join("|") + [response[:reference], response[:authorization]].join('|') end def split_authorization(authorization) - authorization.split("|") + authorization.split('|') end def generate_signature(action, parameters) diff --git a/lib/active_merchant/billing/gateways/cenpos.rb b/lib/active_merchant/billing/gateways/cenpos.rb index e019001d464..f6030e64f5c 100644 --- a/lib/active_merchant/billing/gateways/cenpos.rb +++ b/lib/active_merchant/billing/gateways/cenpos.rb @@ -1,15 +1,15 @@ -require "nokogiri" +require 'nokogiri' module ActiveMerchant #:nodoc: module Billing #:nodoc: class CenposGateway < Gateway - self.display_name = "CenPOS" - self.homepage_url = "https://www.cenpos.com/" + self.display_name = 'CenPOS' + self.homepage_url = 'https://www.cenpos.com/' - self.live_url = "https://ww3.cenpos.net/6/transact.asmx" + self.live_url = 'https://ww3.cenpos.net/6/transact.asmx' self.supported_countries = %w(AD AI AG AR AU AT BS BB BE BZ BM BR BN BG CA HR CY CZ DK DM EE FI FR DE GR GD GY HK HU IS IN IL IT JP LV LI LT LU MY MT MX MC MS NL PA PL PT KN LC MF VC SM SG SK SI ZA ES SR SE CH TR GB US UY) - self.default_currency = "USD" + self.default_currency = 'USD' self.money_format = :dollars self.supported_cardtypes = [:visa, :master, :american_express, :discover] @@ -24,7 +24,7 @@ def purchase(amount, payment_method, options={}) add_payment_method(post, payment_method) add_customer_data(post, options) - commit("Sale", post) + commit('Sale', post) end def authorize(amount, payment_method, options={}) @@ -33,7 +33,7 @@ def authorize(amount, payment_method, options={}) add_payment_method(post, payment_method) add_customer_data(post, options) - commit("Auth", post) + commit('Auth', post) end def capture(amount, authorization, options={}) @@ -42,7 +42,7 @@ def capture(amount, authorization, options={}) add_reference(post, authorization) add_customer_data(post, options) - commit("SpecialForce", post) + commit('SpecialForce', post) end def void(authorization, options={}) @@ -53,7 +53,7 @@ def void(authorization, options={}) add_tax(post, options) add_order_id(post, options) - commit("Void", post) + commit('Void', post) end def refund(amount, authorization, options={}) @@ -62,7 +62,7 @@ def refund(amount, authorization, options={}) add_reference(post, authorization) add_customer_data(post, options) - commit("SpecialReturn", post) + commit('SpecialReturn', post) end def credit(amount, payment_method, options={}) @@ -70,7 +70,7 @@ def credit(amount, payment_method, options={}) add_invoice(post, amount, options) add_payment_method(post, payment_method) - commit("Credit", post) + commit('Credit', post) end def verify(credit_card, options={}) @@ -156,9 +156,9 @@ def commit(action, post) xml = ssl_post(self.live_url, data, headers) raw = parse(xml) rescue ActiveMerchant::ResponseError => e - if(e.response.code == "500" && e.response.body.start_with?("<s:Envelope")) + if(e.response.code == '500' && e.response.body.start_with?('<s:Envelope')) raw = { - message: "See transcript for detailed error description." + message: 'See transcript for detailed error description.' } else raise @@ -180,17 +180,17 @@ def commit(action, post) def headers { - "Accept-Encoding" => "identity", - "Content-Type" => "text/xml;charset=UTF-8", - "SOAPAction" => "http://tempuri.org/Transactional/ProcessCreditCard" + 'Accept-Encoding' => 'identity', + 'Content-Type' => 'text/xml;charset=UTF-8', + 'SOAPAction' => 'http://tempuri.org/Transactional/ProcessCreditCard' } end def build_request(post) xml = Builder::XmlMarkup.new :indent => 8 - xml.tag!("acr:MerchantId", post.delete(:MerchantId)) - xml.tag!("acr:Password", post.delete(:Password)) - xml.tag!("acr:UserId", post.delete(:UserId)) + xml.tag!('acr:MerchantId', post.delete(:MerchantId)) + xml.tag!('acr:Password', post.delete(:Password)) + xml.tag!('acr:UserId', post.delete(:UserId)) post.sort.each do |field, value| xml.tag!("acr1:#{field}", value) end @@ -217,7 +217,7 @@ def parse(xml) doc = Nokogiri::XML(xml) doc.remove_namespaces! - body = doc.xpath("//ProcessCreditCardResult") + body = doc.xpath('//ProcessCreditCardResult') body.children.each do |node| if (node.elements.size == 0) response[node.name.underscore.to_sym] = node.text @@ -233,32 +233,32 @@ def parse(xml) end def success_from(response) - response == "0" + response == '0' end def message_from(succeeded, response) if succeeded - "Succeeded" + 'Succeeded' else - response[:message] || "Unable to read error message" + response[:message] || 'Unable to read error message' end end STANDARD_ERROR_CODE_MAPPING = { - "211" => STANDARD_ERROR_CODE[:invalid_number], - "252" => STANDARD_ERROR_CODE[:invalid_expiry_date], - "257" => STANDARD_ERROR_CODE[:invalid_cvc], - "333" => STANDARD_ERROR_CODE[:expired_card], - "1" => STANDARD_ERROR_CODE[:card_declined], - "99" => STANDARD_ERROR_CODE[:processing_error], + '211' => STANDARD_ERROR_CODE[:invalid_number], + '252' => STANDARD_ERROR_CODE[:invalid_expiry_date], + '257' => STANDARD_ERROR_CODE[:invalid_cvc], + '333' => STANDARD_ERROR_CODE[:expired_card], + '1' => STANDARD_ERROR_CODE[:card_declined], + '99' => STANDARD_ERROR_CODE[:processing_error], } def authorization_from(request, response) - [ response[:reference_number], request[:CardLastFourDigits], request[:Amount] ].join("|") + [ response[:reference_number], request[:CardLastFourDigits], request[:Amount] ].join('|') end def split_authorization(authorization) - reference_number, last_four_digits, original_amount = authorization.split("|") + reference_number, last_four_digits, original_amount = authorization.split('|') [reference_number, last_four_digits, original_amount] end @@ -275,14 +275,14 @@ def avs_result_from_xml(xml) end def cvv_result_code(xml) - cvv = validation_result_element(xml, "CVV") + cvv = validation_result_element(xml, 'CVV') return nil unless cvv validation_result_matches?(*validation_result_element_text(cvv.parent)) ? 'M' : 'N' end def avs_result_code(xml) - billing_address_elem = validation_result_element(xml, "Billing Address") - zip_code_elem = validation_result_element(xml, "Zip Code") + billing_address_elem = validation_result_element(xml, 'Billing Address') + zip_code_elem = validation_result_element(xml, 'Zip Code') return nil unless billing_address_elem && zip_code_elem @@ -312,10 +312,10 @@ def validation_result_element(xml, name) def validation_result_element_text(element) result_text = element.elements.detect { |elem| - elem.name == "Result" + elem.name == 'Result' }.children.detect { |elem| elem.text }.text - result_text.split(";").collect(&:strip) + result_text.split(';').collect(&:strip) end def validation_result_matches?(present, match) diff --git a/lib/active_merchant/billing/gateways/checkout.rb b/lib/active_merchant/billing/gateways/checkout.rb index c0ad0cb2ef6..51cf3919292 100644 --- a/lib/active_merchant/billing/gateways/checkout.rb +++ b/lib/active_merchant/billing/gateways/checkout.rb @@ -164,8 +164,8 @@ def add_track_id(xml, trackid) def commit(action, amount=nil, options={}, &builder) response = parse_xml(ssl_post(live_url, build_xml(action, &builder))) Response.new( - (response[:responsecode] == "0"), - (response[:result] || response[:error_text] || "Unknown Response"), + (response[:responsecode] == '0'), + (response[:result] || response[:error_text] || 'Unknown Response'), response, authorization: authorization_from(response, action, amount, options), test: test? @@ -184,7 +184,7 @@ def build_xml(action) def parse_xml(xml) response = {} - Nokogiri::XML(CGI.unescapeHTML(xml)).xpath("//response").children.each do |node| + Nokogiri::XML(CGI.unescapeHTML(xml)).xpath('//response').children.each do |node| if node.text? next elsif (node.elements.size == 0) @@ -202,11 +202,11 @@ def parse_xml(xml) def authorization_from(response, action, amount, options) currency = options[:currency] || currency(amount) - [response[:tranid], response[:trackid], action, amount, currency].join("|") + [response[:tranid], response[:trackid], action, amount, currency].join('|') end def split_authorization(authorization) - transid, trackid, action, amount, currency = authorization.split("|") + transid, trackid, action, amount, currency = authorization.split('|') [transid, trackid, action, amount, currency] end end diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb index b81c2f32a4f..7d1f688f971 100644 --- a/lib/active_merchant/billing/gateways/checkout_v2.rb +++ b/lib/active_merchant/billing/gateways/checkout_v2.rb @@ -1,13 +1,13 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class CheckoutV2Gateway < Gateway - self.display_name = "Checkout.com V2 Gateway" - self.homepage_url = "https://www.checkout.com/" - self.live_url = "https://api2.checkout.com/v2" - self.test_url = "https://sandbox.checkout.com/api2/v2" + self.display_name = 'Checkout.com V2 Gateway' + self.homepage_url = 'https://www.checkout.com/' + self.live_url = 'https://api2.checkout.com/v2' + self.test_url = 'https://sandbox.checkout.com/api2/v2' self.supported_countries = ['AD', 'AE', 'AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GI', 'GL', 'GR', 'HR', 'HU', 'IE', 'IS', 'IL', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SM', 'SK', 'SJ', 'TR', 'VA'] - self.default_currency = "USD" + self.default_currency = 'USD' self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express, :diners_club] @@ -30,7 +30,7 @@ def purchase(amount, payment_method, options={}) def authorize(amount, payment_method, options={}) post = {} - post[:autoCapture] = "n" + post[:autoCapture] = 'n' add_invoice(post, amount, options) add_payment_method(post, payment_method) add_customer_data(post, options) @@ -99,7 +99,7 @@ def add_payment_method(post, payment_method) end def add_customer_data(post, options) - post[:email] = options[:email] || "unspecified@example.com" + post[:email] = options[:email] || 'unspecified@example.com' post[:customerIp] = options[:ip] if options[:ip] address = options[:billing_address] if(address && post[:card]) @@ -153,8 +153,8 @@ def response(action, succeeded, response) def headers { - "Authorization" => @options[:secret_key], - "Content-Type" => "application/json;charset=UTF-8" + 'Authorization' => @options[:secret_key], + 'Content-Type' => 'application/json;charset=UTF-8' } end @@ -182,50 +182,50 @@ def parse(body) JSON.parse(body) rescue JSON::ParserError { - "message" => "Invalid JSON response received from CheckoutV2Gateway. Please contact CheckoutV2Gateway if you continue to receive this message.", - "raw_response" => scrub(body) + 'message' => 'Invalid JSON response received from CheckoutV2Gateway. Please contact CheckoutV2Gateway if you continue to receive this message.', + 'raw_response' => scrub(body) } end def success_from(response) - (response["responseCode"] == "10000" && !response["responseMessage"].start_with?("40")) || response["responseCode"] == "10100" + (response['responseCode'] == '10000' && !response['responseMessage'].start_with?('40')) || response['responseCode'] == '10100' end def message_from(succeeded, response) if succeeded - "Succeeded" - elsif response["errors"] - response["message"] + ": " + response["errors"].first + 'Succeeded' + elsif response['errors'] + response['message'] + ': ' + response['errors'].first else - response["responseMessage"] || response["message"] || "Unable to read error message" + response['responseMessage'] || response['message'] || 'Unable to read error message' end end STANDARD_ERROR_CODE_MAPPING = { - "20014" => STANDARD_ERROR_CODE[:invalid_number], - "20100" => STANDARD_ERROR_CODE[:invalid_expiry_date], - "20054" => STANDARD_ERROR_CODE[:expired_card], - "40104" => STANDARD_ERROR_CODE[:incorrect_cvc], - "40108" => STANDARD_ERROR_CODE[:incorrect_zip], - "40111" => STANDARD_ERROR_CODE[:incorrect_address], - "20005" => STANDARD_ERROR_CODE[:card_declined], - "20088" => STANDARD_ERROR_CODE[:processing_error], - "20001" => STANDARD_ERROR_CODE[:call_issuer], - "30004" => STANDARD_ERROR_CODE[:pickup_card] + '20014' => STANDARD_ERROR_CODE[:invalid_number], + '20100' => STANDARD_ERROR_CODE[:invalid_expiry_date], + '20054' => STANDARD_ERROR_CODE[:expired_card], + '40104' => STANDARD_ERROR_CODE[:incorrect_cvc], + '40108' => STANDARD_ERROR_CODE[:incorrect_zip], + '40111' => STANDARD_ERROR_CODE[:incorrect_address], + '20005' => STANDARD_ERROR_CODE[:card_declined], + '20088' => STANDARD_ERROR_CODE[:processing_error], + '20001' => STANDARD_ERROR_CODE[:call_issuer], + '30004' => STANDARD_ERROR_CODE[:pickup_card] } def authorization_from(raw) - raw["id"] + raw['id'] end def error_code_from(succeeded, response) return if succeeded - if response["errorCode"] && response["errorMessageCodes"] + if response['errorCode'] && response['errorMessageCodes'] "#{response["errorCode"]}: #{response["errorMessageCodes"].join(", ")}" - elsif response["errorCode"] - response["errorCode"] + elsif response['errorCode'] + response['errorCode'] else - STANDARD_ERROR_CODE_MAPPING[response["responseCode"]] + STANDARD_ERROR_CODE_MAPPING[response['responseCode']] end end end diff --git a/lib/active_merchant/billing/gateways/clearhaus.rb b/lib/active_merchant/billing/gateways/clearhaus.rb index 93ee3c041fa..43b68fb56c4 100644 --- a/lib/active_merchant/billing/gateways/clearhaus.rb +++ b/lib/active_merchant/billing/gateways/clearhaus.rb @@ -55,7 +55,7 @@ def authorize(amount, payment, options={}) action = if payment.respond_to?(:number) add_payment(post, payment) - "/authorizations" + '/authorizations' elsif payment.kind_of?(String) "/cards/#{payment}/authorizations" else @@ -97,7 +97,7 @@ def store(credit_card, options={}) post = {} add_payment(post, credit_card) - commit("/cards", post) + commit('/cards', post) end def supports_scrubbing? @@ -139,8 +139,8 @@ def add_payment(post, payment) def headers(api_key) { - "Authorization" => "Basic " + Base64.strict_encode64("#{api_key}:"), - "User-Agent" => "Clearhaus ActiveMerchantBindings/#{ActiveMerchant::VERSION}" + 'Authorization' => 'Basic ' + Base64.strict_encode64("#{api_key}:"), + 'User-Agent' => "Clearhaus ActiveMerchantBindings/#{ActiveMerchant::VERSION}" } end @@ -155,7 +155,7 @@ def commit(action, parameters) if @options[:signing_key] && @options[:private_key] begin - headers["Signature"] = generate_signature(body) + headers['Signature'] = generate_signature(body) rescue OpenSSL::PKey::RSAError => e return Response.new(false, e.message) end diff --git a/lib/active_merchant/billing/gateways/commercegate.rb b/lib/active_merchant/billing/gateways/commercegate.rb index d70a11aa153..77aede1e9de 100644 --- a/lib/active_merchant/billing/gateways/commercegate.rb +++ b/lib/active_merchant/billing/gateways/commercegate.rb @@ -65,15 +65,15 @@ def add_address(post, address) post[:state] = address[:state] post[:postalCode] = address[:zip] end - post[:countryCode] = ((address && address[:country]) || "US") + post[:countryCode] = ((address && address[:country]) || 'US') end def add_auth_purchase_options(post, money, options) add_address(post, options[:address]) - post[:customerIP] = options[:ip] || "127.0.0.1" + post[:customerIP] = options[:ip] || '127.0.0.1' post[:amount] = amount(money) - post[:email] = options[:email] || "unknown@example.com" + post[:email] = options[:email] || 'unknown@example.com' post[:currencyCode]= options[:currency] || currency(money) post[:merchAcct] = options[:merchant] @@ -127,8 +127,8 @@ def message_from(response) if response['returnText'].present? response['returnText'] else - "Invalid response received from the CommerceGate API. " + - "Please contact CommerceGate support if you continue to receive this message. " + + 'Invalid response received from the CommerceGate API. ' + + 'Please contact CommerceGate support if you continue to receive this message. ' + "(The raw response returned by the API was #{response.inspect})" end end @@ -136,7 +136,7 @@ def message_from(response) def post_data(parameters) parameters.collect do |key, value| "#{key}=#{CGI.escape(value.to_s)}" - end.join("&") + end.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/conekta.rb b/lib/active_merchant/billing/gateways/conekta.rb index 87378003093..d0857a0b917 100644 --- a/lib/active_merchant/billing/gateways/conekta.rb +++ b/lib/active_merchant/billing/gateways/conekta.rb @@ -34,7 +34,7 @@ def authorize(money, payment_source, options = {}) add_details_data(post, options) post[:capture] = false - commit(:post, "charges", post) + commit(:post, 'charges', post) end def capture(money, identifier, options = {}) @@ -74,7 +74,7 @@ def scrub(transcript) private def add_order(post, money, options) - post[:description] = options[:description] || "Active Merchant Purchase" + post[:description] = options[:description] || 'Active Merchant Purchase' post[:reference_id] = options[:order_id] if options[:order_id] post[:currency] = (options[:currency] || currency(money)).downcase post[:monthly_installments] = options[:monthly_installments] if options[:monthly_installments] @@ -175,13 +175,13 @@ def parse(body) def headers(meta) { - "Accept" => "application/vnd.conekta-v#{options[:version]}+json", - "Accept-Language" => "es", - "Authorization" => "Basic " + Base64.encode64("#{options[:key]}:"), - "RaiseHtmlError" => "false", - "Conekta-Client-User-Agent" => {"agent"=>"Conekta ActiveMerchantBindings/#{ActiveMerchant::VERSION}"}.to_json, - "X-Conekta-Client-User-Agent" => user_agent, - "X-Conekta-Client-User-Metadata" => meta.to_json + 'Accept' => "application/vnd.conekta-v#{options[:version]}+json", + 'Accept-Language' => 'es', + 'Authorization' => 'Basic ' + Base64.encode64("#{options[:key]}:"), + 'RaiseHtmlError' => 'false', + 'Conekta-Client-User-Agent' => {'agent'=>"Conekta ActiveMerchantBindings/#{ActiveMerchant::VERSION}"}.to_json, + 'X-Conekta-Client-User-Agent' => user_agent, + 'X-Conekta-Client-User-Metadata' => meta.to_json } end @@ -189,7 +189,7 @@ def commit(method, url, parameters, options = {}) success = false begin raw_response = parse(ssl_request(method, live_url + url, (parameters ? parameters.to_query : nil), headers(options[:meta]))) - success = (raw_response.key?("object") && (raw_response["object"] != "error")) + success = (raw_response.key?('object') && (raw_response['object'] != 'error')) rescue ResponseError => e raw_response = response_error(e.response.body) rescue JSON::ParserError @@ -198,10 +198,10 @@ def commit(method, url, parameters, options = {}) Response.new( success, - raw_response["message_to_purchaser"], + raw_response['message_to_purchaser'], raw_response, test: test?, - authorization: raw_response["id"] + authorization: raw_response['id'] ) end @@ -217,7 +217,7 @@ def json_error(raw_response) msg = 'Invalid response received from the Conekta API.' msg += " (The raw response returned by the API was #{raw_response.inspect})" { - "message" => msg + 'message' => msg } end end diff --git a/lib/active_merchant/billing/gateways/creditcall.rb b/lib/active_merchant/billing/gateways/creditcall.rb index fbedf5855b1..f55c4960812 100644 --- a/lib/active_merchant/billing/gateways/creditcall.rb +++ b/lib/active_merchant/billing/gateways/creditcall.rb @@ -16,29 +16,29 @@ class CreditcallGateway < Gateway self.display_name = 'Creditcall' CVV_CODE = { - "matched" => "M", - "notmatched" => "N", - "notchecked" => "P", - "partialmatch" => "N" + 'matched' => 'M', + 'notmatched' => 'N', + 'notchecked' => 'P', + 'partialmatch' => 'N' } AVS_CODE = { - "matched;matched" => "D", - "matched;notchecked" =>"B", - "matched;notmatched" => "A", - "matched;partialmatch" => "A", - "notchecked;matched" => "P", - "notchecked;notchecked" =>"I", - "notchecked;notmatched" => "I", - "notchecked;partialmatch" => "I", - "notmatched;matched" => "W", - "notmatched;notchecked" =>"C", - "notmatched;notmatched" => "C", - "notmatched;partialmatch" => "C", - "partialmatched;matched" => "W", - "partialmatched;notchecked" =>"C", - "partialmatched;notmatched" => "C", - "partialmatched;partialmatch" => "C" + 'matched;matched' => 'D', + 'matched;notchecked' =>'B', + 'matched;notmatched' => 'A', + 'matched;partialmatch' => 'A', + 'notchecked;matched' => 'P', + 'notchecked;notchecked' =>'I', + 'notchecked;notmatched' => 'I', + 'notchecked;partialmatch' => 'I', + 'notmatched;matched' => 'W', + 'notmatched;notchecked' =>'C', + 'notmatched;notmatched' => 'C', + 'notmatched;partialmatch' => 'C', + 'partialmatched;matched' => 'W', + 'partialmatched;notchecked' =>'C', + 'partialmatched;notmatched' => 'C', + 'partialmatched;partialmatch' => 'C' } def initialize(options={}) @@ -68,7 +68,7 @@ def purchase(money, payment_method, options={}) def authorize(money, payment_method, options={}) request = build_xml_request do |xml| - add_transaction_details(xml, money, nil, "Auth", options) + add_transaction_details(xml, money, nil, 'Auth', options) add_terminal_details(xml, options) add_card_details(xml, payment_method, options) end @@ -78,7 +78,7 @@ def authorize(money, payment_method, options={}) def capture(money, authorization, options={}) request = build_xml_request do |xml| - add_transaction_details(xml, money, authorization, "Conf", options) + add_transaction_details(xml, money, authorization, 'Conf', options) add_terminal_details(xml, options) end @@ -87,7 +87,7 @@ def capture(money, authorization, options={}) def refund(money, authorization, options={}) request = build_xml_request do |xml| - add_transaction_details(xml, money, authorization, "Refund", options) + add_transaction_details(xml, money, authorization, 'Refund', options) add_terminal_details(xml, options) end @@ -96,7 +96,7 @@ def refund(money, authorization, options={}) def void(authorization, options={}) request = build_xml_request do |xml| - add_transaction_details(xml, nil, authorization, "Void", options) + add_transaction_details(xml, nil, authorization, 'Void', options) add_terminal_details(xml, options) end @@ -128,16 +128,16 @@ def avs_result_code_from(params) end def cvv_result_code_from(params) - CVV_CODE[params["CSC"]] + CVV_CODE[params['CSC']] end def error_result_code_from(params) - params["ErrorCode"] + params['ErrorCode'] end def build_xml_request builder = Nokogiri::XML::Builder.new do |xml| - xml.Request(type: "CardEaseXML", version: "1.0.0") do + xml.Request(type: 'CardEaseXML', version: '1.0.0') do yield(xml) end end @@ -147,9 +147,9 @@ def build_xml_request def add_transaction_details(xml, amount, authorization, type, options={}) xml.TransactionDetails do xml.MessageType type - xml.Amount(unit: "Minor"){ xml.text(amount) } if amount + xml.Amount(unit: 'Minor'){ xml.text(amount) } if amount xml.CardEaseReference authorization if authorization - xml.VoidReason "01" if type == "Void" + xml.VoidReason '01' if type == 'Void' end end @@ -157,7 +157,7 @@ def add_terminal_details(xml, options={}) xml.TerminalDetails do xml.TerminalID @options[:terminal_id] xml.TransactionKey @options[:transaction_key] - xml.Software(version: "SoftwareVersion"){ xml.text("SoftwareName") } + xml.Software(version: 'SoftwareVersion'){ xml.text('SoftwareName') } end end @@ -191,12 +191,12 @@ def parse(body) response = {} xml = Nokogiri::XML(body) - node = xml.xpath("//Response/TransactionDetails") + node = xml.xpath('//Response/TransactionDetails') node.children.each do |childnode| response[childnode.name] = childnode.text end - node = xml.xpath("//Response/Result") + node = xml.xpath('//Response/Result') node.children.each do |childnode| if childnode.elements.empty? response[childnode.name] = childnode.text @@ -205,7 +205,7 @@ def parse(body) end end - node = xml.xpath("//Response/CardDetails") + node = xml.xpath('//Response/CardDetails') node.children.each do |childnode| if childnode.elements.empty? response[childnode.name] = childnode.text @@ -220,9 +220,9 @@ def parse(body) def childnode_to_response(response, childnode) childnode.elements.each do |element| - if element.name == "Error" - response["ErrorCode"] = element.attr("code") - response["ErrorMessage"] = element.text + if element.name == 'Error' + response['ErrorCode'] = element.attr('code') + response['ErrorMessage'] = element.text else response[element.name] = element.text end @@ -249,23 +249,23 @@ def url end def success_from(response) - response["LocalResult"] == "0" || response["LocalResult"] == "00" + response['LocalResult'] == '0' || response['LocalResult'] == '00' end def message_from(response) if success_from(response) - "Succeeded" + 'Succeeded' else - response["ErrorMessage"] + response['ErrorMessage'] end end def authorization_from(response) - response["CardEaseReference"] + response['CardEaseReference'] end def manual_type(options) - options[:manual_type] || "ecommerce" + options[:manual_type] || 'ecommerce' end end end diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb index 9cb25e45f14..96f45bc5c81 100644 --- a/lib/active_merchant/billing/gateways/credorax.rb +++ b/lib/active_merchant/billing/gateways/credorax.rb @@ -3,10 +3,10 @@ module Billing #:nodoc: class CredoraxGateway < Gateway class_attribute :test_url, :live_na_url, :live_eu_url - self.display_name = "Credorax Gateway" - self.homepage_url = "https://www.credorax.com/" + self.display_name = 'Credorax Gateway' + self.homepage_url = 'https://www.credorax.com/' - self.test_url = "https://intconsole.credorax.com/intenv/service/gateway" + self.test_url = 'https://intconsole.credorax.com/intenv/service/gateway' # The live URL is assigned on a per merchant basis once certification has passed # See the Credorax remote tests for the full certification test suite @@ -16,7 +16,7 @@ class CredoraxGateway < Gateway self.live_url = 'https://assigned-subdomain.credorax.net/crax_gate/service/gateway' self.supported_countries = %w(DE GB FR IT ES PL NL BE GR CZ PT SE HU RS AT CH BG DK FI SK NO IE HR BA AL LT MK SI LV EE ME LU MT IS AD MC LI SM) - self.default_currency = "EUR" + self.default_currency = 'EUR' self.currencies_without_fractions = %w(CLP JPY KRW PYG VND) self.currencies_with_three_decimal_places = %w(BHD JOD KWD OMR RSD TND) @@ -24,96 +24,96 @@ class CredoraxGateway < Gateway self.supported_cardtypes = [:visa, :master, :maestro] RESPONSE_MESSAGES = { - "00" => "Approved or completed successfully", - "01" => "Refer to card issuer", - "02" => "Refer to card issuer special condition", - "03" => "Invalid merchant", - "04" => "Pick up card", - "05" => "Do not Honour", - "06" => "Error", - "07" => "Pick up card special condition", - "08" => "Honour with identification", - "09" => "Request in progress", - "10" => "Approved for partial amount", - "11" => "Approved (VIP)", - "12" => "Invalid transaction", - "13" => "Invalid amount", - "14" => "Invalid card number", - "15" => "No such issuer", - "16" => "Approved, update track 3", - "17" => "Customer cancellation", - "18" => "Customer dispute", - "19" => "Re-enter transaction", - "20" => "Invalid response", - "21" => "No action taken", - "22" => "Suspected malfunction", - "23" => "Unacceptable transaction fee", - "24" => "File update not supported by receiver", - "25" => "No such record", - "26" => "Duplicate record update, old record replaced", - "27" => "File update field edit error", - "28" => "File locked out while update", - "29" => "File update error, contact acquirer", - "30" => "Format error", - "31" => "Issuer signed-off", - "32" => "Completed partially", - "33" => "Pick-up, expired card", - "34" => "Suspect Fraud", - "35" => "Pick-up, card acceptor contact acquirer", - "36" => "Pick up, card restricted", - "37" => "Pick up, call acquirer security", - "38" => "Pick up, Allowable PIN tries exceeded", - "39" => "Transaction Not Allowed", - "40" => "Requested function not supported", - "41" => "Lost Card, Pickup", - "42" => "No universal account", - "43" => "Pick up, stolen card", - "44" => "No investment account", - "50" => "Do not renew", - "51" => "Not sufficient funds", - "52" => "No checking Account", - "53" => "No savings account", - "54" => "Expired card", - "55" => "Pin incorrect", - "56" => "No card record", - "57" => "Transaction not allowed for cardholder", - "58" => "Transaction not allowed for merchant", - "59" => "Suspected Fraud", - "60" => "Card acceptor contact acquirer", - "61" => "Exceeds withdrawal amount limit", - "62" => "Restricted card", - "63" => "Security violation", - "64" => "Wrong original amount", - "65" => "Activity count limit exceeded", - "66" => "Call acquirers security department", - "67" => "Card to be picked up at ATM", - "68" => "Response received too late.", - "70" => "Invalid transaction; contact card issuer", - "71" => "Decline PIN not changed", - "75" => "Pin tries exceeded", - "76" => "Wrong PIN, number of PIN tries exceeded", - "77" => "Wrong Reference No.", - "78" => "Record Not Found", - "79" => "Already reversed", - "80" => "Network error", - "81" => "Foreign network error / PIN cryptographic error", - "82" => "Time out at issuer system", - "83" => "Transaction failed", - "84" => "Pre-authorization timed out", - "85" => "No reason to decline", - "86" => "Cannot verify pin", - "87" => "Purchase amount only, no cashback allowed", - "88" => "MAC sync Error", - "89" => "Authentication failure", - "91" => "Issuer not available", - "92" => "Unable to route at acquirer Module", - "93" => "Cannot be completed, violation of law", - "94" => "Duplicate Transmission", - "95" => "Reconcile error / Auth Not found", - "96" => "System malfunction", - "R0" => "Stop Payment Order", - "R1" => "Revocation of Authorisation Order", - "R3" => "Revocation of all Authorisations Order" + '00' => 'Approved or completed successfully', + '01' => 'Refer to card issuer', + '02' => 'Refer to card issuer special condition', + '03' => 'Invalid merchant', + '04' => 'Pick up card', + '05' => 'Do not Honour', + '06' => 'Error', + '07' => 'Pick up card special condition', + '08' => 'Honour with identification', + '09' => 'Request in progress', + '10' => 'Approved for partial amount', + '11' => 'Approved (VIP)', + '12' => 'Invalid transaction', + '13' => 'Invalid amount', + '14' => 'Invalid card number', + '15' => 'No such issuer', + '16' => 'Approved, update track 3', + '17' => 'Customer cancellation', + '18' => 'Customer dispute', + '19' => 'Re-enter transaction', + '20' => 'Invalid response', + '21' => 'No action taken', + '22' => 'Suspected malfunction', + '23' => 'Unacceptable transaction fee', + '24' => 'File update not supported by receiver', + '25' => 'No such record', + '26' => 'Duplicate record update, old record replaced', + '27' => 'File update field edit error', + '28' => 'File locked out while update', + '29' => 'File update error, contact acquirer', + '30' => 'Format error', + '31' => 'Issuer signed-off', + '32' => 'Completed partially', + '33' => 'Pick-up, expired card', + '34' => 'Suspect Fraud', + '35' => 'Pick-up, card acceptor contact acquirer', + '36' => 'Pick up, card restricted', + '37' => 'Pick up, call acquirer security', + '38' => 'Pick up, Allowable PIN tries exceeded', + '39' => 'Transaction Not Allowed', + '40' => 'Requested function not supported', + '41' => 'Lost Card, Pickup', + '42' => 'No universal account', + '43' => 'Pick up, stolen card', + '44' => 'No investment account', + '50' => 'Do not renew', + '51' => 'Not sufficient funds', + '52' => 'No checking Account', + '53' => 'No savings account', + '54' => 'Expired card', + '55' => 'Pin incorrect', + '56' => 'No card record', + '57' => 'Transaction not allowed for cardholder', + '58' => 'Transaction not allowed for merchant', + '59' => 'Suspected Fraud', + '60' => 'Card acceptor contact acquirer', + '61' => 'Exceeds withdrawal amount limit', + '62' => 'Restricted card', + '63' => 'Security violation', + '64' => 'Wrong original amount', + '65' => 'Activity count limit exceeded', + '66' => 'Call acquirers security department', + '67' => 'Card to be picked up at ATM', + '68' => 'Response received too late.', + '70' => 'Invalid transaction; contact card issuer', + '71' => 'Decline PIN not changed', + '75' => 'Pin tries exceeded', + '76' => 'Wrong PIN, number of PIN tries exceeded', + '77' => 'Wrong Reference No.', + '78' => 'Record Not Found', + '79' => 'Already reversed', + '80' => 'Network error', + '81' => 'Foreign network error / PIN cryptographic error', + '82' => 'Time out at issuer system', + '83' => 'Transaction failed', + '84' => 'Pre-authorization timed out', + '85' => 'No reason to decline', + '86' => 'Cannot verify pin', + '87' => 'Purchase amount only, no cashback allowed', + '88' => 'MAC sync Error', + '89' => 'Authentication failure', + '91' => 'Issuer not available', + '92' => 'Unable to route at acquirer Module', + '93' => 'Cannot be completed, violation of law', + '94' => 'Duplicate Transmission', + '95' => 'Reconcile error / Auth Not found', + '96' => 'System malfunction', + 'R0' => 'Stop Payment Order', + 'R1' => 'Revocation of Authorisation Order', + 'R3' => 'Revocation of all Authorisations Order' } def initialize(options={}) @@ -219,9 +219,9 @@ def add_invoice(post, money, options) end CARD_TYPES = { - "visa" => '1', - "mastercard" => '2', - "maestro" => '9' + 'visa' => '1', + 'mastercard' => '2', + 'maestro' => '9' } def add_payment_method(post, payment_method) @@ -246,7 +246,7 @@ def add_customer_data(post, options) end def add_reference(post, authorization) - response_id, authorization_code, request_id, action = authorization.split(";") + response_id, authorization_code, request_id, action = authorization.split(';') post[:g2] = response_id post[:g3] = authorization_code post[:g4] = request_id @@ -293,8 +293,8 @@ def commit(action, params, reference_action = nil) message_from(response), response, authorization: "#{response["Z1"]};#{response["Z4"]};#{response["A1"]};#{action}", - avs_result: AVSResult.new(code: response["Z9"]), - cvv_result: CVVResult.new(response["Z14"]), + avs_result: AVSResult.new(code: response['Z9']), + cvv_result: CVVResult.new(response['Z14']), test: test? ) end @@ -331,14 +331,14 @@ def parse(body) end def success_from(response) - response["Z2"] == "0" + response['Z2'] == '0' end def message_from(response) if success_from(response) - "Succeeded" + 'Succeeded' else - RESPONSE_MESSAGES[response["Z6"]] || response["Z3"] || "Unable to read error message" + RESPONSE_MESSAGES[response['Z6']] || response['Z3'] || 'Unable to read error message' end end end diff --git a/lib/active_merchant/billing/gateways/culqi.rb b/lib/active_merchant/billing/gateways/culqi.rb index 964df74d8cf..d7dde785353 100644 --- a/lib/active_merchant/billing/gateways/culqi.rb +++ b/lib/active_merchant/billing/gateways/culqi.rb @@ -9,14 +9,14 @@ module Billing #:nodoc: # largely depends on the transaction acquiring bank. Be sure to understand how # your account was configured prior to using this gateway. class CulqiGateway < Gateway - self.display_name = "Culqi" - self.homepage_url = "https://www.culqi.com" + self.display_name = 'Culqi' + self.homepage_url = 'https://www.culqi.com' - self.test_url = "https://staging.paymentz.com/transaction/" - self.live_url = "https://secure.culqi.com/transaction/" + self.test_url = 'https://staging.paymentz.com/transaction/' + self.live_url = 'https://secure.culqi.com/transaction/' - self.supported_countries = ["PE"] - self.default_currency = "PEN" + self.supported_countries = ['PE'] + self.default_currency = 'PEN' self.money_format = :dollars self.supported_cardtypes = [:visa, :master, :diners_club, :american_express] @@ -86,8 +86,8 @@ def verify(credit_card, options={}) end def verify_credentials - response = void("0", order_id: "0") - response.message.include? "Transaction not found" + response = void('0', order_id: '0') + response.message.include? 'Transaction not found' end def store(credit_card, options={}) @@ -198,13 +198,13 @@ def add_reference(post, authorization) end ACTIONS = { - authorize: "SingleCallGenericServlet", - capture: "SingleCallGenericCaptureServlet", - void: "SingleCallGenericVoid", - refund: "SingleCallGenericReverse", - tokenize: "SingleCallTokenServlet", - invalidate: "SingleCallInvalidateToken", - tokenpay: "SingleCallTokenTransaction", + authorize: 'SingleCallGenericServlet', + capture: 'SingleCallGenericCaptureServlet', + void: 'SingleCallGenericVoid', + refund: 'SingleCallGenericReverse', + tokenize: 'SingleCallTokenServlet', + invalidate: 'SingleCallInvalidateToken', + tokenpay: 'SingleCallTokenTransaction', } def commit(action, params) @@ -229,8 +229,8 @@ def commit(action, params) def headers { - "Accept" => "application/json", - "Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8" + 'Accept' => 'application/json', + 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8' } end @@ -246,11 +246,11 @@ def parse(body) begin JSON.parse(body) rescue JSON::ParserError - message = "Invalid JSON response received from CulqiGateway. Please contact CulqiGateway if you continue to receive this message." + message = 'Invalid JSON response received from CulqiGateway. Please contact CulqiGateway if you continue to receive this message.' message += "(The raw response returned by the API was #{body.inspect})" { - "status" => "N", - "statusdescription" => message + 'status' => 'N', + 'statusdescription' => message } end end diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 85a1c08a0a0..7d7beba89d6 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -24,7 +24,7 @@ class CyberSourceGateway < Gateway self.test_url = 'https://ics2wstesta.ic3.com/commerce/1.x/transactionProcessor' self.live_url = 'https://ics2wsa.ic3.com/commerce/1.x/transactionProcessor' - XSD_VERSION = "1.121" + XSD_VERSION = '1.121' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :switch, :dankort, :maestro] self.supported_countries = %w(US BR CA CN DK FI FR DE JP MX NO SE GB SG LB) @@ -48,44 +48,44 @@ class CyberSourceGateway < Gateway } @@response_codes = { - :r100 => "Successful transaction", - :r101 => "Request is missing one or more required fields" , - :r102 => "One or more fields contains invalid data", - :r150 => "General failure", - :r151 => "The request was received but a server time-out occurred", - :r152 => "The request was received, but a service timed out", - :r200 => "The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the AVS check", - :r201 => "The issuing bank has questions about the request", - :r202 => "Expired card", - :r203 => "General decline of the card", - :r204 => "Insufficient funds in the account", - :r205 => "Stolen or lost card", - :r207 => "Issuing bank unavailable", - :r208 => "Inactive card or card not authorized for card-not-present transactions", - :r209 => "American Express Card Identifiction Digits (CID) did not match", - :r210 => "The card has reached the credit limit", - :r211 => "Invalid card verification number", + :r100 => 'Successful transaction', + :r101 => 'Request is missing one or more required fields' , + :r102 => 'One or more fields contains invalid data', + :r150 => 'General failure', + :r151 => 'The request was received but a server time-out occurred', + :r152 => 'The request was received, but a service timed out', + :r200 => 'The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the AVS check', + :r201 => 'The issuing bank has questions about the request', + :r202 => 'Expired card', + :r203 => 'General decline of the card', + :r204 => 'Insufficient funds in the account', + :r205 => 'Stolen or lost card', + :r207 => 'Issuing bank unavailable', + :r208 => 'Inactive card or card not authorized for card-not-present transactions', + :r209 => 'American Express Card Identifiction Digits (CID) did not match', + :r210 => 'The card has reached the credit limit', + :r211 => 'Invalid card verification number', :r221 => "The customer matched an entry on the processor's negative file", - :r230 => "The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the card verification check", - :r231 => "Invalid account number", - :r232 => "The card type is not accepted by the payment processor", - :r233 => "General decline by the processor", - :r234 => "A problem exists with your CyberSource merchant configuration", - :r235 => "The requested amount exceeds the originally authorized amount", - :r236 => "Processor failure", - :r237 => "The authorization has already been reversed", - :r238 => "The authorization has already been captured", - :r239 => "The requested transaction amount must match the previous transaction amount", - :r240 => "The card type sent is invalid or does not correlate with the credit card number", - :r241 => "The request ID is invalid", - :r242 => "You requested a capture, but there is no corresponding, unused authorization record.", - :r243 => "The transaction has already been settled or reversed", - :r244 => "The bank account number failed the validation check", - :r246 => "The capture or credit is not voidable because the capture or credit information has already been submitted to your processor", - :r247 => "You requested a credit for a capture that was previously voided", - :r250 => "The request was received, but a time-out occurred with the payment processor", - :r254 => "Your CyberSource account is prohibited from processing stand-alone refunds", - :r255 => "Your CyberSource account is not configured to process the service in the country you specified" + :r230 => 'The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the card verification check', + :r231 => 'Invalid account number', + :r232 => 'The card type is not accepted by the payment processor', + :r233 => 'General decline by the processor', + :r234 => 'A problem exists with your CyberSource merchant configuration', + :r235 => 'The requested amount exceeds the originally authorized amount', + :r236 => 'Processor failure', + :r237 => 'The authorization has already been reversed', + :r238 => 'The authorization has already been captured', + :r239 => 'The requested transaction amount must match the previous transaction amount', + :r240 => 'The card type sent is invalid or does not correlate with the credit card number', + :r241 => 'The request ID is invalid', + :r242 => 'You requested a capture, but there is no corresponding, unused authorization record.', + :r243 => 'The transaction has already been settled or reversed', + :r244 => 'The bank account number failed the validation check', + :r246 => 'The capture or credit is not voidable because the capture or credit information has already been submitted to your processor', + :r247 => 'You requested a credit for a capture that was previously voided', + :r250 => 'The request was received, but a time-out occurred with the payment processor', + :r254 => 'Your CyberSource account is prohibited from processing stand-alone refunds', + :r255 => 'Your CyberSource account is not configured to process the service in the country you specified' } # These are the options that can be used when creating a new CyberSource @@ -232,8 +232,8 @@ def supports_network_tokenization? end def verify_credentials - response = void("0") - response.params["reasonCode"] == "102" + response = void('0') + response.params['reasonCode'] == '102' end private @@ -276,7 +276,7 @@ def build_tax_calculation_request(creditcard, options) end def build_capture_request(money, authorization, options) - order_id, request_id, request_token = authorization.split(";") + order_id, request_id, request_token = authorization.split(';') options[:order_id] = order_id xml = Builder::XmlMarkup.new :indent => 2 @@ -303,11 +303,11 @@ def build_purchase_request(money, payment_method_or_reference, options) end def build_void_request(identification, options) - order_id, request_id, request_token, action, money, currency = identification.split(";") + order_id, request_id, request_token, action, money, currency = identification.split(';') options[:order_id] = order_id xml = Builder::XmlMarkup.new :indent => 2 - if action == "capture" + if action == 'capture' add_void_service(xml, request_id, request_token) else add_purchase_data(xml, money, true, options.merge(:currency => currency || default_currency)) @@ -317,7 +317,7 @@ def build_void_request(identification, options) end def build_refund_request(money, identification, options) - order_id, request_id, request_token = identification.split(";") + order_id, request_id, request_token = identification.split(';') options[:order_id] = order_id xml = Builder::XmlMarkup.new :indent => 2 @@ -338,7 +338,7 @@ def build_credit_request(money, reference, options) end def build_create_subscription_request(payment_method, options) - default_subscription_params = {:frequency => "on-demand", :amount => 0, :automatic_renew => false} + default_subscription_params = {:frequency => 'on-demand', :amount => 0, :automatic_renew => false} options[:subscription] = default_subscription_params.update( options[:subscription] || {} ) @@ -485,7 +485,7 @@ def add_decision_manager_fields(xml, options) end def add_mdd_fields(xml, options) - return unless options.keys.any? { |key| key.to_s.start_with?("mdd_field") } + return unless options.keys.any? { |key| key.to_s.start_with?('mdd_field') } xml.tag! 'merchantDefinedData' do (1..100).each do |each| @@ -528,24 +528,24 @@ def add_auth_network_tokenization(xml, payment_method, options) case card_brand(payment_method).to_sym when :visa xml.tag! 'ccAuthService', {'run' => 'true'} do - xml.tag!("cavv", payment_method.payment_cryptogram) - xml.tag!("commerceIndicator", "vbv") - xml.tag!("xid", payment_method.payment_cryptogram) + xml.tag!('cavv', payment_method.payment_cryptogram) + xml.tag!('commerceIndicator', 'vbv') + xml.tag!('xid', payment_method.payment_cryptogram) end when :mastercard xml.tag! 'ucaf' do - xml.tag!("authenticationData", payment_method.payment_cryptogram) - xml.tag!("collectionIndicator", "2") + xml.tag!('authenticationData', payment_method.payment_cryptogram) + xml.tag!('collectionIndicator', '2') end xml.tag! 'ccAuthService', {'run' => 'true'} do - xml.tag!("commerceIndicator", "spa") + xml.tag!('commerceIndicator', 'spa') end when :american_express cryptogram = Base64.decode64(payment_method.payment_cryptogram) xml.tag! 'ccAuthService', {'run' => 'true'} do - xml.tag!("cavv", Base64.encode64(cryptogram[0...20])) - xml.tag!("commerceIndicator", "aesk") - xml.tag!("xid", Base64.encode64(cryptogram[20...40])) + xml.tag!('cavv', Base64.encode64(cryptogram[0...20])) + xml.tag!('commerceIndicator', 'aesk') + xml.tag!('xid', Base64.encode64(cryptogram[20...40])) end end end @@ -618,7 +618,7 @@ def add_subscription(xml, options, reference = nil) xml.tag! 'recurringSubscriptionInfo' do if reference - subscription_id = reference.split(";")[6] + subscription_id = reference.split(';')[6] xml.tag! 'subscriptionID', subscription_id end @@ -627,8 +627,8 @@ def add_subscription(xml, options, reference = nil) xml.tag! 'numberOfPayments', options[:subscription][:occurrences] if options[:subscription][:occurrences] xml.tag! 'automaticRenew', options[:subscription][:automatic_renew] if options[:subscription][:automatic_renew] xml.tag! 'frequency', options[:subscription][:frequency] if options[:subscription][:frequency] - xml.tag! 'startDate', options[:subscription][:start_date].strftime("%Y%m%d") if options[:subscription][:start_date] - xml.tag! 'endDate', options[:subscription][:end_date].strftime("%Y%m%d") if options[:subscription][:end_date] + xml.tag! 'startDate', options[:subscription][:start_date].strftime('%Y%m%d') if options[:subscription][:start_date] + xml.tag! 'endDate', options[:subscription][:end_date].strftime('%Y%m%d') if options[:subscription][:end_date] xml.tag! 'approvalRequired', options[:subscription][:approval_required] || false xml.tag! 'event', options[:subscription][:event] if options[:subscription][:event] xml.tag! 'billPayment', options[:subscription][:bill_payment] if options[:subscription][:bill_payment] @@ -637,13 +637,13 @@ def add_subscription(xml, options, reference = nil) def add_creditcard_payment_method(xml) xml.tag! 'subscription' do - xml.tag! 'paymentMethod', "credit card" + xml.tag! 'paymentMethod', 'credit card' end end def add_check_payment_method(xml) xml.tag! 'subscription' do - xml.tag! 'paymentMethod', "check" + xml.tag! 'paymentMethod', 'check' end end @@ -715,7 +715,7 @@ def commit(request, action, amount, options) response = { message: e.to_s } end - success = response[:decision] == "ACCEPT" + success = response[:decision] == 'ACCEPT' message = response[:message] authorization = success ? authorization_from(response, action, amount, options) : nil @@ -733,7 +733,7 @@ def commit(request, action, amount, options) def parse(xml) reply = {} xml = REXML::Document.new(xml) - if root = REXML::XPath.first(xml, "//c:replyMessage") + if root = REXML::XPath.first(xml, '//c:replyMessage') root.elements.to_a.each do |node| case node.expanded_name when 'c:reasonCode' @@ -743,7 +743,7 @@ def parse(xml) parse_element(reply, node) end end - elsif root = REXML::XPath.first(xml, "//soap:Fault") + elsif root = REXML::XPath.first(xml, '//soap:Fault') parse_element(reply, root) reply[:message] = "#{reply[:faultcode]}: #{reply[:faultstring]}" end @@ -756,7 +756,7 @@ def parse_element(reply, node) else if node.parent.name =~ /item/ parent = node.parent.name - parent += '_' + node.parent.attributes["id"] if node.parent.attributes["id"] + parent += '_' + node.parent.attributes['id'] if node.parent.attributes['id'] parent += '_' end reply["#{parent}#{node.name}".to_sym] ||= node.text @@ -771,7 +771,7 @@ def reason_message(reason_code) def authorization_from(response, action, amount, options) [options[:order_id], response[:requestID], response[:requestToken], action, amount, - options[:currency], response[:subscriptionID]].join(";") + options[:currency], response[:subscriptionID]].join(';') end end end diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb index 6a23e86d009..5c94454e2ad 100644 --- a/lib/active_merchant/billing/gateways/data_cash.rb +++ b/lib/active_merchant/billing/gateways/data_cash.rb @@ -1,4 +1,4 @@ -require "active_support/core_ext/string/access" +require 'active_support/core_ext/string/access' module ActiveMerchant module Billing @@ -142,7 +142,7 @@ def build_purchase_or_authorization_request_with_credit_card_request(type, money def build_purchase_or_authorization_request_with_continuous_authority_reference_request(type, money, authorization, options) parsed_authorization = parse_authorization_string(authorization) - raise ArgumentError, "The continuous authority reference is required for continuous authority transactions" if parsed_authorization[:ca_reference].blank? + raise ArgumentError, 'The continuous authority reference is required for continuous authority transactions' if parsed_authorization[:ca_reference].blank? xml = Builder::XmlMarkup.new :indent => 2 xml.instruct! @@ -288,7 +288,7 @@ def parse(body) response = {} xml = REXML::Document.new(body) - root = REXML::XPath.first(xml, "//Response") + root = REXML::XPath.first(xml, '//Response') root.elements.to_a.each do |node| parse_element(response, node) @@ -306,7 +306,7 @@ def parse_element(response, node) end def format_reference_number(number) - number.to_s.gsub(/[^A-Za-z0-9]/, '').rjust(6, "0").first(30) + number.to_s.gsub(/[^A-Za-z0-9]/, '').rjust(6, '0').first(30) end def parse_authorization_string(authorization) diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb index 0121a7c6e34..ef5dfd425c2 100644 --- a/lib/active_merchant/billing/gateways/dibs.rb +++ b/lib/active_merchant/billing/gateways/dibs.rb @@ -1,13 +1,13 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class DibsGateway < Gateway - self.display_name = "DIBS" - self.homepage_url = "http://www.dibspayment.com/" + self.display_name = 'DIBS' + self.homepage_url = 'http://www.dibspayment.com/' - self.live_url = "https://api.dibspayment.com/merchant/v1/JSON/Transaction/" + self.live_url = 'https://api.dibspayment.com/merchant/v1/JSON/Transaction/' - self.supported_countries = ["US", "FI", "NO", "SE", "GB"] - self.default_currency = "USD" + self.supported_countries = ['US', 'FI', 'NO', 'SE', 'GB'] + self.default_currency = 'USD' self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express, :discover] @@ -89,12 +89,12 @@ def scrub(transcript) private CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")} - CURRENCY_CODES["USD"] = "840" - CURRENCY_CODES["DKK"] = "208" - CURRENCY_CODES["NOK"] = "578" - CURRENCY_CODES["SEK"] = "752" - CURRENCY_CODES["GBP"] = "826" - CURRENCY_CODES["EUR"] = "978" + CURRENCY_CODES['USD'] = '840' + CURRENCY_CODES['DKK'] = '208' + CURRENCY_CODES['NOK'] = '578' + CURRENCY_CODES['SEK'] = '752' + CURRENCY_CODES['GBP'] = '826' + CURRENCY_CODES['EUR'] = '978' def add_invoice(post, money, options) post[:orderId] = options[:order_id] || generate_unique_id @@ -114,7 +114,7 @@ def add_payment_method(post, payment_method, options) post[:startMonth] = payment_method.start_month if payment_method.start_month post[:startYear] = payment_method.start_year if payment_method.start_year post[:issueNumber] = payment_method.issue_number if payment_method.issue_number - post[:clientIp] = options[:ip] || "127.0.0.1" + post[:clientIp] = options[:ip] || '127.0.0.1' post[:test] = true if test? end @@ -128,12 +128,12 @@ def add_amount(post, amount) end ACTIONS = { - authorize: "AuthorizeCard", - authorize_ticket: "AuthorizeTicket", - capture: "CaptureTransaction", - void: "CancelTransaction", - refund: "RefundTransaction", - store: "CreateTicket" + authorize: 'AuthorizeCard', + authorize_ticket: 'AuthorizeTicket', + capture: 'CaptureTransaction', + void: 'CancelTransaction', + refund: 'RefundTransaction', + store: 'CreateTicket' } def commit(action, post) @@ -155,7 +155,7 @@ def commit(action, post) def headers { - "Content-Type" => "application/x-www-form-urlencoded" + 'Content-Type' => 'application/x-www-form-urlencoded' } end @@ -165,7 +165,7 @@ def build_request(post) end def add_hmac(post) - data = post.sort.collect { |key, value| "#{key}=#{value.to_s}" }.join("&") + data = post.sort.collect { |key, value| "#{key}=#{value.to_s}" }.join('&') digest = OpenSSL::Digest.new('sha256') key = [@options[:secret_key]].pack('H*') post[:MAC] = OpenSSL::HMAC.hexdigest(digest, key, data) @@ -180,14 +180,14 @@ def parse(body) end def success_from(raw_response) - raw_response["status"] == "ACCEPT" + raw_response['status'] == 'ACCEPT' end def message_from(succeeded, response) if succeeded - "Succeeded" + 'Succeeded' else - response["status"] + ": " + response["declineReason"] || "Unable to read error message" + response['status'] + ': ' + response['declineReason'] || 'Unable to read error message' end end @@ -196,7 +196,7 @@ def authorization_from(request, response) end def unparsable_response(raw_response) - message = "Invalid JSON response received from Dibs. Please contact Dibs if you continue to receive this message." + message = 'Invalid JSON response received from Dibs. Please contact Dibs if you continue to receive this message.' message += " (The raw response returned by the API was #{raw_response.inspect})" return Response.new(false, message) end diff --git a/lib/active_merchant/billing/gateways/digitzs.rb b/lib/active_merchant/billing/gateways/digitzs.rb index d1eadd7ffd2..80510bf8e0a 100644 --- a/lib/active_merchant/billing/gateways/digitzs.rb +++ b/lib/active_merchant/billing/gateways/digitzs.rb @@ -21,21 +21,21 @@ def initialize(options={}) def purchase(money, payment, options={}) MultiResponse.run do |r| - r.process { commit("auth/token", app_token_request(options)) } + r.process { commit('auth/token', app_token_request(options)) } r.process { commit('payments', purchase_request(money, payment, options), options.merge({ app_token: app_token_from(r) })) } end end def refund(money, authorization, options={}) MultiResponse.run do |r| - r.process { commit("auth/token", app_token_request(options)) } + r.process { commit('auth/token', app_token_request(options)) } r.process { commit('payments', refund_request(money, authorization, options), options.merge({ app_token: app_token_from(r) })) } end end def store(payment, options = {}) MultiResponse.run do |r| - r.process { commit("auth/token", app_token_request(options)) } + r.process { commit('auth/token', app_token_request(options)) } options.merge!({ app_token: app_token_from(r) }) if options[:customer_id].present? @@ -78,7 +78,7 @@ def new_post end def add_split(post, options) - return unless options[:payment_type] == "card_split" || options[:payment_type] == "token_split" + return unless options[:payment_type] == 'card_split' || options[:payment_type] == 'token_split' post[:data][:attributes][:split] = { merchantId: options[:split_merchant_id], @@ -115,19 +115,19 @@ def add_transaction(post, money, options) def add_address(post, options) if address = options[:billing_address] || options[:address] post[:data][:attributes][:billingAddress] = { - line1: address[:address1] || "", - line2: address[:address2] || "", - city: address[:city] || "", - state: address[:state] || "", - zip: address[:zip] || "", - country: address["country"] || "USA" + line1: address[:address1] || '', + line2: address[:address2] || '', + city: address[:city] || '', + state: address[:state] || '', + zip: address[:zip] || '', + country: address['country'] || 'USA' } end end def app_token_request(options) post = new_post - post[:data][:type] = "auth" + post[:data][:type] = 'auth' post[:data][:attributes] = { appKey: @options[:app_key] } post @@ -135,7 +135,7 @@ def app_token_request(options) def purchase_request(money, payment, options) post = new_post - post[:data][:type] = "payments" + post[:data][:type] = 'payments' post[:data][:attributes][:merchantId] = options[:merchant_id] post[:data][:attributes][:paymentType] = determine_payment_type(payment, options) add_split(post, options) @@ -148,9 +148,9 @@ def purchase_request(money, payment, options) def refund_request(money, authorization, options) post = new_post - post[:data][:type] = "payments" + post[:data][:type] = 'payments' post[:data][:attributes][:merchantId] = options[:merchant_id] - post[:data][:attributes][:paymentType] = "cardRefund" + post[:data][:attributes][:paymentType] = 'cardRefund' post[:data][:attributes][:originalTransaction] = {id: authorization} add_transaction(post, money, options) @@ -159,7 +159,7 @@ def refund_request(money, authorization, options) def create_customer_request(payment, options) post = new_post - post[:data][:type] = "customers" + post[:data][:type] = 'customers' post[:data][:attributes] = { merchantId: options[:merchant_id], name: payment.name, @@ -171,11 +171,11 @@ def create_customer_request(payment, options) def create_token_request(payment, options) post = new_post - post[:data][:type] = "tokens" + post[:data][:type] = 'tokens' post[:data][:attributes] = { - tokenType: "card", + tokenType: 'card', customerId: options[:customer_id], - label: "Credit Card", + label: 'Credit Card', } add_payment(post, payment, options) add_address(post, options) @@ -187,7 +187,7 @@ def check_customer_exists(options = {}) url = (test? ? test_url : live_url) response = parse(ssl_get(url + "/customers/#{options[:customer_id]}", headers(options))) - return response.try(:[], "data").try(:[], "customerId") if success_from(response) + return response.try(:[], 'data').try(:[], 'customerId') if success_from(response) return nil end @@ -222,33 +222,33 @@ def commit(action, parameters, options={}) end def success_from(response) - response["errors"].nil? && response["message"].nil? + response['errors'].nil? && response['message'].nil? end def message_from(response) - return response["message"] if response["message"] - return "Success" if success_from(response) - response["errors"].map {|error_hash| error_hash["detail"] }.join(", ") + return response['message'] if response['message'] + return 'Success' if success_from(response) + response['errors'].map {|error_hash| error_hash['detail'] }.join(', ') end def authorization_from(response) - if customer_id = response.try(:[], "data").try(:[], "attributes").try(:[], "customerId") + if customer_id = response.try(:[], 'data').try(:[], 'attributes').try(:[], 'customerId') "#{customer_id}|#{response.try(:[], "data").try(:[], "id")}" else - response.try(:[], "data").try(:[], "id") + response.try(:[], 'data').try(:[], 'id') end end def avs_result_from(response) - response.try(:[], "data").try(:[], "attributes").try(:[], "transaction").try(:[], "avsResult") + response.try(:[], 'data').try(:[], 'attributes').try(:[], 'transaction').try(:[], 'avsResult') end def cvv_result_from(response) - response.try(:[], "data").try(:[], "attributes").try(:[], "transaction").try(:[], "codeResult") + response.try(:[], 'data').try(:[], 'attributes').try(:[], 'transaction').try(:[], 'codeResult') end def app_token_from(response) - response.params.try(:[], "data").try(:[], "attributes").try(:[], "appToken") + response.params.try(:[], 'data').try(:[], 'attributes').try(:[], 'appToken') end def headers(options) @@ -257,26 +257,26 @@ def headers(options) 'x-api-key' => @options[:api_key] } - headers.merge!({"Authorization" => "Bearer #{options[:app_token]}"}) if options[:app_token] + headers.merge!({'Authorization' => "Bearer #{options[:app_token]}"}) if options[:app_token] headers end def error_code_from(response) unless success_from(response) - response["errors"].nil? ? response["message"] : response["errors"].map {|error_hash| error_hash["code"] }.join(", ") + response['errors'].nil? ? response['message'] : response['errors'].map {|error_hash| error_hash['code'] }.join(', ') end end def split_authorization(authorization) - customer_id, token = authorization.split("|") + customer_id, token = authorization.split('|') [customer_id, token] end def determine_payment_type(payment, options) - return "cardSplit" if options[:payment_type] == "card_split" - return "tokenSplit" if options[:payment_type] == "token_split" - return "token" if payment.is_a? String - "card" + return 'cardSplit' if options[:payment_type] == 'card_split' + return 'tokenSplit' if options[:payment_type] == 'token_split' + return 'token' if payment.is_a? String + 'card' end def handle_response(response) diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb index 353bfd9bacb..ef42b12d449 100644 --- a/lib/active_merchant/billing/gateways/ebanx.rb +++ b/lib/active_merchant/billing/gateways/ebanx.rb @@ -12,20 +12,20 @@ class EbanxGateway < Gateway self.display_name = 'Ebanx' CARD_BRAND = { - visa: "visa", - master: "master_card", - american_express: "amex", - discover: "discover", - diners_club: "diners" + visa: 'visa', + master: 'master_card', + american_express: 'amex', + discover: 'discover', + diners_club: 'diners' } URL_MAP = { - purchase: "direct", - authorize: "direct", - capture: "capture", - refund: "refund", - void: "cancel", - store: "token" + purchase: 'direct', + authorize: 'direct', + capture: 'capture', + refund: 'refund', + void: 'cancel', + store: 'token' } HTTP_METHOD = { @@ -131,7 +131,7 @@ def add_integration_key(post) end def add_operation(post) - post[:operation] = "request" + post[:operation] = 'request' end def add_authorization(post, authorization) @@ -140,7 +140,7 @@ def add_authorization(post, authorization) def add_customer_data(post, payment, options) post[:payment][:name] = customer_name(payment, options) - post[:payment][:email] = options[:email] || "unspecified@example.com" + post[:payment][:email] = options[:email] || 'unspecified@example.com' post[:payment][:document] = options[:document] post[:payment][:birth_date] = options[:birth_date] if options[:birth_date] end @@ -157,7 +157,7 @@ def add_customer_responsible_person(post, payment, options) def add_address(post, options) if address = options[:billing_address] || options[:address] - post[:payment][:address] = address[:address1].split[1..-1].join(" ") if address[:address1] + post[:payment][:address] = address[:address1].split[1..-1].join(' ') if address[:address1] post[:payment][:street_number] = address[:address1].split.first if address[:address1] post[:payment][:city] = address[:city] post[:payment][:state] = address[:state] @@ -176,7 +176,7 @@ def add_invoice(post, money, options) def add_card_or_token(post, payment) if payment.is_a?(String) - payment, brand = payment.split("|") + payment, brand = payment.split('|') end post[:payment][:payment_type_code] = payment.is_a?(String) ? brand : CARD_BRAND[payment.brand.to_sym] post[:payment][:creditcard] = payment_details(payment) @@ -222,28 +222,28 @@ def commit(action, parameters) def success_from(action, response) if [:purchase, :capture, :refund].include?(action) - response.try(:[], "payment").try(:[], "status") == "CO" + response.try(:[], 'payment').try(:[], 'status') == 'CO' elsif action == :authorize - response.try(:[], "payment").try(:[], "status") == "PE" + response.try(:[], 'payment').try(:[], 'status') == 'PE' elsif action == :void - response.try(:[], "payment").try(:[], "status") == "CA" + response.try(:[], 'payment').try(:[], 'status') == 'CA' elsif action == :store - response.try(:[], "status") == "SUCCESS" + response.try(:[], 'status') == 'SUCCESS' else false end end def message_from(response) - return response["status_message"] if response["status"] == "ERROR" - response.try(:[], "payment").try(:[], "transaction_status").try(:[], "description") + return response['status_message'] if response['status'] == 'ERROR' + response.try(:[], 'payment').try(:[], 'transaction_status').try(:[], 'description') end def authorization_from(action, parameters, response) if action == :store "#{response.try(:[], "token")}|#{CARD_BRAND[parameters[:payment_type_code].to_sym]}" else - response.try(:[], "payment").try(:[], "hash") + response.try(:[], 'payment').try(:[], 'hash') end end @@ -267,13 +267,13 @@ def convert_to_url_form_encoded(parameters) parameters.map do |key, value| next if value != false && value.blank? "#{key}=#{value}" - end.compact.join("&") + end.compact.join('&') end def error_code_from(response, success) unless success - return response["status_code"] if response["status"] == "ERROR" - response.try(:[], "payment").try(:[], "transaction_status").try(:[], "code") + return response['status_code'] if response['status'] == 'ERROR' + response.try(:[], 'payment').try(:[], 'transaction_status').try(:[], 'code') end end @@ -286,7 +286,7 @@ def customer_country(options) def customer_name(payment, options) address_name = options[:billing_address][:name] if options[:billing_address] && options[:billing_address][:name] if payment.is_a?(String) - address_name || "Not Provided" + address_name || 'Not Provided' else payment.name end diff --git a/lib/active_merchant/billing/gateways/efsnet.rb b/lib/active_merchant/billing/gateways/efsnet.rb index 6051db0efb2..da3d95ae0be 100644 --- a/lib/active_merchant/billing/gateways/efsnet.rb +++ b/lib/active_merchant/billing/gateways/efsnet.rb @@ -54,7 +54,7 @@ def refund(money, reference, options = {}) def void(identification, options = {}) requires!(options, :order_id) - original_transaction_id, _ = identification.split(";") + original_transaction_id, _ = identification.split(';') commit(:void_transaction, {:reference_number => format_reference_number(options[:order_id]), :transaction_id => original_transaction_id}) end @@ -77,7 +77,7 @@ def system_check private def build_refund_or_settle_request(money, identification, options = {}) - original_transaction_id, original_transaction_amount = identification.split(";") + original_transaction_id, original_transaction_amount = identification.split(';') requires!(options, :order_id) @@ -139,8 +139,8 @@ def add_creditcard(post, creditcard) post[:billing_name] = creditcard.name if creditcard.name post[:account_number] = creditcard.number post[:card_verification_value] = creditcard.verification_value if creditcard.verification_value? - post[:expiration_month] = sprintf("%.2i", creditcard.month) - post[:expiration_year] = sprintf("%.4i", creditcard.year)[-2..-1] + post[:expiration_month] = sprintf('%.2i', creditcard.month) + post[:expiration_year] = sprintf('%.4i', creditcard.year)[-2..-1] end @@ -179,10 +179,10 @@ def parse(xml) def post_data(action, parameters = {}) xml = REXML::Document.new("<?xml version='1.0' encoding='UTF-8'?>") - root = xml.add_element("Request") - root.attributes["StoreID"] = options[:login] - root.attributes["StoreKey"] = options[:password] - root.attributes["ApplicationID"] = 'ot 1.0' + root = xml.add_element('Request') + root.attributes['StoreID'] = options[:login] + root.attributes['StoreKey'] = options[:password] + root.attributes['ApplicationID'] = 'ot 1.0' transaction = root.add_element(action.to_s.camelize) actions[action].each do |key| @@ -194,7 +194,7 @@ def post_data(action, parameters = {}) def message_from(message) return 'Unspecified error' if message.blank? - message.gsub(/[^\w]/, ' ').split.join(" ").capitalize + message.gsub(/[^\w]/, ' ').split.join(' ').capitalize end def actions @@ -208,7 +208,7 @@ def actions :credit_card_charge => CREDIT_CARD_FIELDS, :credit_card_voice_authorize => CREDIT_CARD_FIELDS, :credit_card_capture => CREDIT_CARD_FIELDS, - :credit_card_credit => CREDIT_CARD_FIELDS + ["OriginalTransactionAmount"], + :credit_card_credit => CREDIT_CARD_FIELDS + ['OriginalTransactionAmount'], :credit_card_refund => %w(ReferenceNumber TransactionAmount OriginalTransactionAmount OriginalTransactionID ClientIpAddress), :void_transaction => %w(ReferenceNumber TransactionID), :credit_card_settle => %w(ReferenceNumber TransactionAmount OriginalTransactionAmount OriginalTransactionID ClientIpAddress), diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb index 5ac0eaacabf..9814d760966 100644 --- a/lib/active_merchant/billing/gateways/elavon.rb +++ b/lib/active_merchant/billing/gateways/elavon.rb @@ -96,7 +96,7 @@ def void(identification, options = {}) def credit(money, creditcard, options = {}) if creditcard.is_a?(String) - raise ArgumentError, "Reference credits are not supported. Please supply the original credit card or use the #refund method." + raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card or use the #refund method.' end form = {} @@ -271,7 +271,7 @@ def commit(action, money, parameters, options) def post_data(parameters, options) result = preamble result.merge!(parameters) - result.collect { |key, value| post_data_string(key, value, options) }.join("&") + result.collect { |key, value| post_data_string(key, value, options) }.join('&') end def post_data_string(key, value, options) @@ -302,7 +302,7 @@ def preamble def parse(msg) resp = {} msg.split(self.delimiter).collect{|li| - key, value = li.split("=") + key, value = li.split('=') resp[key.to_s.strip.gsub(/^ssl_/, '')] = value.to_s.strip } resp diff --git a/lib/active_merchant/billing/gateways/element.rb b/lib/active_merchant/billing/gateways/element.rb index d32c720cbf2..163402df436 100644 --- a/lib/active_merchant/billing/gateways/element.rb +++ b/lib/active_merchant/billing/gateways/element.rb @@ -23,10 +23,10 @@ def initialize(options={}) end def purchase(money, payment, options={}) - action = payment.is_a?(Check) ? "CheckSale" : "CreditCardSale" + action = payment.is_a?(Check) ? 'CheckSale' : 'CreditCardSale' request = build_soap_request do |xml| - xml.send(action, xmlns: "https://transaction.elementexpress.com") do + xml.send(action, xmlns: 'https://transaction.elementexpress.com') do add_credentials(xml) add_payment_method(xml, payment) add_transaction(xml, money, options) @@ -40,7 +40,7 @@ def purchase(money, payment, options={}) def authorize(money, payment, options={}) request = build_soap_request do |xml| - xml.CreditCardAuthorization(xmlns: "https://transaction.elementexpress.com") do + xml.CreditCardAuthorization(xmlns: 'https://transaction.elementexpress.com') do add_credentials(xml) add_payment_method(xml, payment) add_transaction(xml, money, options) @@ -57,7 +57,7 @@ def capture(money, authorization, options={}) options.merge!({trans_id: trans_id}) request = build_soap_request do |xml| - xml.CreditCardAuthorizationCompletion(xmlns: "https://transaction.elementexpress.com") do + xml.CreditCardAuthorizationCompletion(xmlns: 'https://transaction.elementexpress.com') do add_credentials(xml) add_transaction(xml, money, options) add_terminal(xml, options) @@ -72,7 +72,7 @@ def refund(money, authorization, options={}) options.merge!({trans_id: trans_id}) request = build_soap_request do |xml| - xml.CreditCardReturn(xmlns: "https://transaction.elementexpress.com") do + xml.CreditCardReturn(xmlns: 'https://transaction.elementexpress.com') do add_credentials(xml) add_transaction(xml, money, options) add_terminal(xml, options) @@ -84,10 +84,10 @@ def refund(money, authorization, options={}) def void(authorization, options={}) trans_id, trans_amount = split_authorization(authorization) - options.merge!({trans_id: trans_id, trans_amount: trans_amount, reversal_type: "Full"}) + options.merge!({trans_id: trans_id, trans_amount: trans_amount, reversal_type: 'Full'}) request = build_soap_request do |xml| - xml.CreditCardReversal(xmlns: "https://transaction.elementexpress.com") do + xml.CreditCardReversal(xmlns: 'https://transaction.elementexpress.com') do add_credentials(xml) add_transaction(xml, trans_amount, options) add_terminal(xml, options) @@ -99,7 +99,7 @@ def void(authorization, options={}) def store(payment, options = {}) request = build_soap_request do |xml| - xml.PaymentAccountCreate(xmlns: "https://services.elementexpress.com") do + xml.PaymentAccountCreate(xmlns: 'https://services.elementexpress.com') do add_credentials(xml) add_payment_method(xml, payment) add_payment_account(xml, payment, options[:payment_account_reference_number] || SecureRandom.hex(20)) @@ -165,8 +165,8 @@ def add_payment_account(xml, payment, payment_account_reference_number) def add_payment_account_id(xml, payment) xml.extendedParameters do xml.ExtendedParameters do - xml.Key "PaymentAccount" - xml.Value("xsi:type" => "PaymentAccount") do + xml.Key 'PaymentAccount' + xml.Value('xsi:type' => 'PaymentAccount') do xml.PaymentAccountID payment end end @@ -178,21 +178,21 @@ def add_transaction(xml, money, options = {}) xml.ReversalType options[:reversal_type] if options[:reversal_type] xml.TransactionID options[:trans_id] if options[:trans_id] xml.TransactionAmount amount(money.to_i) if money - xml.MarketCode "Default" if money + xml.MarketCode 'Default' if money xml.ReferenceNumber options[:order_id] || SecureRandom.hex(20) end end def add_terminal(xml, options) xml.terminal do - xml.TerminalID "01" - xml.CardPresentCode "UseDefault" - xml.CardholderPresentCode "UseDefault" - xml.CardInputCode "UseDefault" - xml.CVVPresenceCode "UseDefault" - xml.TerminalCapabilityCode "UseDefault" - xml.TerminalEnvironmentCode "UseDefault" - xml.MotoECICode "NonAuthenticatedSecureECommerceTransaction" + xml.TerminalID '01' + xml.CardPresentCode 'UseDefault' + xml.CardholderPresentCode 'UseDefault' + xml.CardInputCode 'UseDefault' + xml.CVVPresenceCode 'UseDefault' + xml.TerminalCapabilityCode 'UseDefault' + xml.TerminalEnvironmentCode 'UseDefault' + xml.MotoECICode 'NonAuthenticatedSecureECommerceTransaction' end end @@ -201,7 +201,7 @@ def add_credit_card(xml, payment) xml.CardNumber payment.number xml.ExpirationMonth format(payment.month, :two_digits) xml.ExpirationYear format(payment.year, :two_digits) - xml.CardholderName payment.first_name + " " + payment.last_name + xml.CardholderName payment.first_name + ' ' + payment.last_name xml.CVV payment.verification_value end end @@ -244,10 +244,10 @@ def parse(xml) doc = Nokogiri::XML(xml) doc.remove_namespaces! - root = doc.root.xpath("//response/*") + root = doc.root.xpath('//response/*') if root.empty? - root = doc.root.xpath("//Response/*") + root = doc.root.xpath('//Response/*') end root.each do |node| @@ -281,31 +281,31 @@ def commit(action, xml, amount) end def authorization_from(action, response, amount) - if action == "PaymentAccountCreate" - response["paymentaccount"]["paymentaccountid"] + if action == 'PaymentAccountCreate' + response['paymentaccount']['paymentaccountid'] else "#{response['transaction']['transactionid']}|#{amount}" if response['transaction'] end end def success_from(response) - response["expressresponsecode"] == "0" + response['expressresponsecode'] == '0' end def message_from(response) - response["expressresponsemessage"] + response['expressresponsemessage'] end def avs_from(response) - AVSResult.new(code: response["card"]["avsresponsecode"]) if response["card"] + AVSResult.new(code: response['card']['avsresponsecode']) if response['card'] end def cvv_from(response) - CVVResult.new(response["card"]["cvvresponsecode"]) if response["card"] + CVVResult.new(response['card']['cvvresponsecode']) if response['card'] end def split_authorization(authorization) - authorization.split("|") + authorization.split('|') end def build_soap_request @@ -327,13 +327,13 @@ def payment_account_type(payment) if payment.is_a?(Check) payment_account_type = payment.account_type else - payment_account_type = "CreditCard" + payment_account_type = 'CreditCard' end payment_account_type end def url(action) - if action == "PaymentAccountCreate" + if action == 'PaymentAccountCreate' url = (test? ? SERVICE_TEST_URL : SERVICE_LIVE_URL) else url = (test? ? test_url : live_url) @@ -341,14 +341,14 @@ def url(action) end def interface(action) - return "transaction" if action != "PaymentAccountCreate" - return "services" if action == "PaymentAccountCreate" + return 'transaction' if action != 'PaymentAccountCreate' + return 'services' if action == 'PaymentAccountCreate' end def headers(action) { - "Content-Type" => "text/xml; charset=utf-8", - "SOAPAction" => "https://#{interface(action)}.elementexpress.com/#{action}" + 'Content-Type' => 'text/xml; charset=utf-8', + 'SOAPAction' => "https://#{interface(action)}.elementexpress.com/#{action}" } end end diff --git a/lib/active_merchant/billing/gateways/epay.rb b/lib/active_merchant/billing/gateways/epay.rb index aab61a11d3c..937589eda90 100644 --- a/lib/active_merchant/billing/gateways/epay.rb +++ b/lib/active_merchant/billing/gateways/epay.rb @@ -191,7 +191,7 @@ def soap_post(method, params) def do_authorize(params) headers = {} - headers['Referer'] = (options[:password] || "activemerchant.org") + headers['Referer'] = (options[:password] || 'activemerchant.org') response = raw_ssl_request(:post, live_url + 'auth/default.aspx', authorize_post_data(params), headers) @@ -244,7 +244,7 @@ def do_void(params) def make_headers(data, soap_call) { 'Content-Type' => 'text/xml; charset=utf-8', - 'Host' => "ssl.ditonlinebetalingssystem.dk", + 'Host' => 'ssl.ditonlinebetalingssystem.dk', 'Content-Length' => data.size.to_s, 'SOAPAction' => self.live_url + 'remote/payment/' + soap_call } @@ -274,12 +274,12 @@ def authorize_post_data(params = {}) params[:declineurl] = live_url + 'auth/default.aspx?decline=1' params[:merchantnumber] = @options[:login] - params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end # Limited to 20 digits max def format_order_number(number) - number.to_s.gsub(/[^\w]/, '').rjust(4, "0")[0...20] + number.to_s.gsub(/[^\w]/, '').rjust(4, '0')[0...20] end end end diff --git a/lib/active_merchant/billing/gateways/evo_ca.rb b/lib/active_merchant/billing/gateways/evo_ca.rb index c2f76883ebf..b5f976b7cee 100644 --- a/lib/active_merchant/billing/gateways/evo_ca.rb +++ b/lib/active_merchant/billing/gateways/evo_ca.rb @@ -301,7 +301,7 @@ def post_data(action, parameters = {}) post[:username] = options[:username] post[:password] = options[:password] end - post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" unless value.nil? }.compact.join("&") + post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" unless value.nil? }.compact.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/eway.rb b/lib/active_merchant/billing/gateways/eway.rb index 6e31e39b337..1c24fb8032f 100644 --- a/lib/active_merchant/billing/gateways/eway.rb +++ b/lib/active_merchant/billing/gateways/eway.rb @@ -65,13 +65,13 @@ def scrub(transcript) private def requires_address!(options) - raise ArgumentError.new("Missing eWay required parameters: address or billing_address") unless (options.has_key?(:address) or options.has_key?(:billing_address)) + raise ArgumentError.new('Missing eWay required parameters: address or billing_address') unless (options.has_key?(:address) or options.has_key?(:billing_address)) end def add_creditcard(post, creditcard) post[:CardNumber] = creditcard.number - post[:CardExpiryMonth] = sprintf("%.2i", creditcard.month) - post[:CardExpiryYear] = sprintf("%.4i", creditcard.year)[-2..-1] + post[:CardExpiryMonth] = sprintf('%.2i', creditcard.month) + post[:CardExpiryYear] = sprintf('%.4i', creditcard.year)[-2..-1] post[:CustomerFirstName] = creditcard.first_name post[:CustomerLastName] = creditcard.last_name post[:CardHoldersName] = creditcard.name @@ -119,7 +119,7 @@ def commit(url, money, parameters) end def success?(response) - response[:ewaytrxnstatus] == "True" + response[:ewaytrxnstatus] == 'True' end def parse(xml) @@ -134,7 +134,7 @@ def parse(xml) def post_data(parameters = {}) xml = REXML::Document.new - root = xml.add_element("ewaygateway") + root = xml.add_element('ewaygateway') parameters.each do |key, value| root.add_element("eway#{key}").text = value @@ -159,66 +159,66 @@ def refund_url end MESSAGES = { - "00" => "Transaction Approved", - "01" => "Refer to Issuer", - "02" => "Refer to Issuer, special", - "03" => "No Merchant", - "04" => "Pick Up Card", - "05" => "Do Not Honour", - "06" => "Error", - "07" => "Pick Up Card, Special", - "08" => "Honour With Identification", - "09" => "Request In Progress", - "10" => "Approved For Partial Amount", - "11" => "Approved, VIP", - "12" => "Invalid Transaction", - "13" => "Invalid Amount", - "14" => "Invalid Card Number", - "15" => "No Issuer", - "16" => "Approved, Update Track 3", - "19" => "Re-enter Last Transaction", - "21" => "No Action Taken", - "22" => "Suspected Malfunction", - "23" => "Unacceptable Transaction Fee", - "25" => "Unable to Locate Record On File", - "30" => "Format Error", - "31" => "Bank Not Supported By Switch", - "33" => "Expired Card, Capture", - "34" => "Suspected Fraud, Retain Card", - "35" => "Card Acceptor, Contact Acquirer, Retain Card", - "36" => "Restricted Card, Retain Card", - "37" => "Contact Acquirer Security Department, Retain Card", - "38" => "PIN Tries Exceeded, Capture", - "39" => "No Credit Account", - "40" => "Function Not Supported", - "41" => "Lost Card", - "42" => "No Universal Account", - "43" => "Stolen Card", - "44" => "No Investment Account", - "51" => "Insufficient Funds", - "52" => "No Cheque Account", - "53" => "No Savings Account", - "54" => "Expired Card", - "55" => "Incorrect PIN", - "56" => "No Card Record", - "57" => "Function Not Permitted to Cardholder", - "58" => "Function Not Permitted to Terminal", - "59" => "Suspected Fraud", - "60" => "Acceptor Contact Acquirer", - "61" => "Exceeds Withdrawal Limit", - "62" => "Restricted Card", - "63" => "Security Violation", - "64" => "Original Amount Incorrect", - "66" => "Acceptor Contact Acquirer, Security", - "67" => "Capture Card", - "75" => "PIN Tries Exceeded", - "82" => "CVV Validation Error", - "90" => "Cutoff In Progress", - "91" => "Card Issuer Unavailable", - "92" => "Unable To Route Transaction", - "93" => "Cannot Complete, Violation Of The Law", - "94" => "Duplicate Transaction", - "96" => "System Error" + '00' => 'Transaction Approved', + '01' => 'Refer to Issuer', + '02' => 'Refer to Issuer, special', + '03' => 'No Merchant', + '04' => 'Pick Up Card', + '05' => 'Do Not Honour', + '06' => 'Error', + '07' => 'Pick Up Card, Special', + '08' => 'Honour With Identification', + '09' => 'Request In Progress', + '10' => 'Approved For Partial Amount', + '11' => 'Approved, VIP', + '12' => 'Invalid Transaction', + '13' => 'Invalid Amount', + '14' => 'Invalid Card Number', + '15' => 'No Issuer', + '16' => 'Approved, Update Track 3', + '19' => 'Re-enter Last Transaction', + '21' => 'No Action Taken', + '22' => 'Suspected Malfunction', + '23' => 'Unacceptable Transaction Fee', + '25' => 'Unable to Locate Record On File', + '30' => 'Format Error', + '31' => 'Bank Not Supported By Switch', + '33' => 'Expired Card, Capture', + '34' => 'Suspected Fraud, Retain Card', + '35' => 'Card Acceptor, Contact Acquirer, Retain Card', + '36' => 'Restricted Card, Retain Card', + '37' => 'Contact Acquirer Security Department, Retain Card', + '38' => 'PIN Tries Exceeded, Capture', + '39' => 'No Credit Account', + '40' => 'Function Not Supported', + '41' => 'Lost Card', + '42' => 'No Universal Account', + '43' => 'Stolen Card', + '44' => 'No Investment Account', + '51' => 'Insufficient Funds', + '52' => 'No Cheque Account', + '53' => 'No Savings Account', + '54' => 'Expired Card', + '55' => 'Incorrect PIN', + '56' => 'No Card Record', + '57' => 'Function Not Permitted to Cardholder', + '58' => 'Function Not Permitted to Terminal', + '59' => 'Suspected Fraud', + '60' => 'Acceptor Contact Acquirer', + '61' => 'Exceeds Withdrawal Limit', + '62' => 'Restricted Card', + '63' => 'Security Violation', + '64' => 'Original Amount Incorrect', + '66' => 'Acceptor Contact Acquirer, Security', + '67' => 'Capture Card', + '75' => 'PIN Tries Exceeded', + '82' => 'CVV Validation Error', + '90' => 'Cutoff In Progress', + '91' => 'Card Issuer Unavailable', + '92' => 'Unable To Route Transaction', + '93' => 'Cannot Complete, Violation Of The Law', + '94' => 'Duplicate Transaction', + '96' => 'System Error' } end end diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb index b89d5555d0a..72e45021922 100644 --- a/lib/active_merchant/billing/gateways/eway_managed.rb +++ b/lib/active_merchant/billing/gateways/eway_managed.rb @@ -46,7 +46,7 @@ def store(creditcard, options = {}) add_address(post, billing_address) add_misc_fields(post, options) - commit("CreateCustomer", post) + commit('CreateCustomer', post) end def update(billing_id, creditcard, options={}) @@ -64,7 +64,7 @@ def update(billing_id, creditcard, options={}) add_address(post, billing_address) add_misc_fields(post, options) - commit("UpdateCustomer", post) + commit('UpdateCustomer', post) end # Process a payment in the given amount against the stored credit card given by billing_id @@ -86,7 +86,7 @@ def purchase(money, billing_id, options={}) post[:amount]=money add_invoice(post, options) - commit("ProcessPayment", post) + commit('ProcessPayment', post) end # Get customer's stored credit card details given by billing_id @@ -98,7 +98,7 @@ def retrieve(billing_id) post = {} post[:managedCustomerID] = billing_id.to_s - commit("QueryCustomer", post) + commit('QueryCustomer', post) end # TODO: eWay API also provides QueryPayment @@ -106,8 +106,8 @@ def retrieve(billing_id) private def eway_requires!(hash) - raise ArgumentError.new("Missing eWay required parameter in `billing_address`: title") unless hash.has_key?(:title) - raise ArgumentError.new("Missing eWay required parameter in `billing_address`: country") unless hash.has_key?(:country) + raise ArgumentError.new('Missing eWay required parameter in `billing_address`: title') unless hash.has_key?(:title) + raise ArgumentError.new('Missing eWay required parameter in `billing_address`: country') unless hash.has_key?(:country) end def add_address(post, address) @@ -140,8 +140,8 @@ def add_invoice(post, options) # add credit card details to be stored by eway. NOTE eway requires "title" field def add_creditcard(post, creditcard) post[:CCNumber] = creditcard.number - post[:CCExpiryMonth] = sprintf("%.2i", creditcard.month) - post[:CCExpiryYear] = sprintf("%.4i", creditcard.year)[-2..-1] + post[:CCExpiryMonth] = sprintf('%.2i', creditcard.month) + post[:CCExpiryYear] = sprintf('%.4i', creditcard.year)[-2..-1] post[:CCNameOnCard] = creditcard.name post[:FirstName] = creditcard.first_name post[:LastName] = creditcard.last_name @@ -150,7 +150,7 @@ def add_creditcard(post, creditcard) def parse(body) reply = {} xml = REXML::Document.new(body) - if root = REXML::XPath.first(xml, "//soap:Fault") then + if root = REXML::XPath.first(xml, '//soap:Fault') then reply=parse_fault(root) else if root = REXML::XPath.first(xml, '//ProcessPaymentResponse/ewayResponse') then @@ -173,12 +173,12 @@ def parse(body) # ERROR: This state should never occur. If there is a problem, # a soap:Fault will be returned. The presence of this # element always means a success. - raise StandardError, "Unexpected \"false\" in UpdateCustomerResult" + raise StandardError, 'Unexpected "false" in UpdateCustomerResult' end else # ERROR: This state should never occur currently. We have handled # responses for all the methods which we support. - raise StandardError, "Unexpected response" + raise StandardError, 'Unexpected response' end end end diff --git a/lib/active_merchant/billing/gateways/eway_rapid.rb b/lib/active_merchant/billing/gateways/eway_rapid.rb index 130254682db..c8fb53e0aa0 100644 --- a/lib/active_merchant/billing/gateways/eway_rapid.rb +++ b/lib/active_merchant/billing/gateways/eway_rapid.rb @@ -3,15 +3,15 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class EwayRapidGateway < Gateway - self.test_url = "https://api.sandbox.ewaypayments.com/" - self.live_url = "https://api.ewaypayments.com/" + self.test_url = 'https://api.sandbox.ewaypayments.com/' + self.live_url = 'https://api.ewaypayments.com/' self.money_format = :cents self.supported_countries = ['AU', 'NZ', 'GB', 'SG', 'MY', 'HK'] self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb] - self.homepage_url = "http://www.eway.com.au/" - self.display_name = "eWAY Rapid 3.1" - self.default_currency = "AUD" + self.homepage_url = 'http://www.eway.com.au/' + self.display_name = 'eWAY Rapid 3.1' + self.default_currency = 'AUD' class_attribute :partner_id @@ -72,13 +72,13 @@ def capture(amount, identification, options = {}) add_metadata(params, options) add_invoice(params, amount, options) add_reference(params, identification) - commit(url_for("CapturePayment"), params) + commit(url_for('CapturePayment'), params) end def void(identification, options = {}) params = {} add_reference(params, identification) - commit(url_for("CancelAuthorisation"), params) + commit(url_for('CancelAuthorisation'), params) end # Public: Refund a transaction. @@ -109,8 +109,8 @@ def void(identification, options = {}) def refund(amount, identification, options = {}) params = {} add_metadata(params, options) - add_invoice(params, amount, options, "Refund") - add_reference(params["Refund"], identification) + add_invoice(params, amount, options, 'Refund') + add_reference(params['Refund'], identification) add_customer_data(params, options) commit(url_for("Transaction/#{identification}/Refund"), params) end @@ -140,7 +140,7 @@ def store(payment_method, options = {}) add_customer_data(params, options) add_credit_card(params, payment_method, options) params['Method'] = 'CreateTokenCustomer' - commit(url_for("Transaction"), params) + commit(url_for('Transaction'), params) end # Public: Update a customer's data @@ -170,7 +170,7 @@ def update(customer_token, payment_method, options = {}) add_credit_card(params, payment_method, options) add_customer_token(params, customer_token) params['Method'] = 'UpdateTokenCustomer' - commit(url_for("Transaction"), params) + commit(url_for('Transaction'), params) end def supports_scrubbing @@ -197,7 +197,7 @@ def add_metadata(params, options) params end - def add_invoice(params, money, options, key = "Payment") + def add_invoice(params, money, options, key = 'Payment') currency_code = options[:currency] || currency(money) params[key] = { 'TotalAmount' => localized_amount(money, currency_code), @@ -243,8 +243,8 @@ def add_credit_card(params, credit_card, options) card_details = params['Customer']['CardDetails'] = {} card_details['Name'] = truncate(credit_card.name, 50) card_details['Number'] = credit_card.number - card_details['ExpiryMonth'] = "%02d" % (credit_card.month || 0) - card_details['ExpiryYear'] = "%02d" % (credit_card.year || 0) + card_details['ExpiryMonth'] = '%02d' % (credit_card.month || 0) + card_details['ExpiryYear'] = '%02d' % (credit_card.year || 0) card_details['CVN'] = credit_card.verification_value else add_customer_token(params, credit_card) @@ -262,8 +262,8 @@ def url_for(action) def commit(url, params) headers = { - "Authorization" => ("Basic " + Base64.strict_encode64(@options[:login].to_s + ":" + @options[:password].to_s).chomp), - "Content-Type" => "application/json" + 'Authorization' => ('Basic ' + Base64.strict_encode64(@options[:login].to_s + ':' + @options[:password].to_s).chomp), + 'Content-Type' => 'application/json' } request = params.to_json raw = parse(ssl_post(url, request, headers)) @@ -287,12 +287,12 @@ def parse(data) end def success?(response) - if response['ResponseCode'] == "00" + if response['ResponseCode'] == '00' true elsif response['TransactionStatus'] (response['TransactionStatus'] == true) - elsif response["Succeeded"] - (response["Succeeded"] == true) + elsif response['Succeeded'] + (response['Succeeded'] == true) else false end @@ -311,9 +311,9 @@ def message_from(succeeded, response) elsif response['ResponseCode'] ActiveMerchant::Billing::EwayGateway::MESSAGES[response['ResponseCode']] elsif succeeded - "Succeeded" + 'Succeeded' else - "Failed" + 'Failed' end end @@ -326,12 +326,12 @@ def authorization_from(response) def avs_result_from(response) verification = response['Verification'] || {} code = case verification['Address'] - when "Valid" - "M" - when "Invalid" - "N" + when 'Valid' + 'M' + when 'Invalid' + 'N' else - "I" + 'I' end {:code => code} end @@ -339,12 +339,12 @@ def avs_result_from(response) def cvv_result_from(response) verification = response['Verification'] || {} case verification['CVN'] - when "Valid" - "M" - when "Invalid" - "N" + when 'Valid' + 'M' + when 'Invalid' + 'N' else - "P" + 'P' end end diff --git a/lib/active_merchant/billing/gateways/exact.rb b/lib/active_merchant/billing/gateways/exact.rb index 1341f184c10..f72ba4247af 100644 --- a/lib/active_merchant/billing/gateways/exact.rb +++ b/lib/active_merchant/billing/gateways/exact.rb @@ -3,15 +3,15 @@ module Billing #:nodoc: class ExactGateway < Gateway self.live_url = self.test_url = 'https://secure2.e-xact.com/vplug-in/transaction/rpc-enc/service.asmx' - API_VERSION = "8.5" + API_VERSION = '8.5' - TEST_LOGINS = [ {:login => "A00049-01", :password => "test1"}, - {:login => "A00427-01", :password => "testus"} ] + TEST_LOGINS = [ {:login => 'A00049-01', :password => 'test1'}, + {:login => 'A00427-01', :password => 'testus'} ] - TRANSACTIONS = { :sale => "00", - :authorization => "01", - :capture => "32", - :credit => "34" } + TRANSACTIONS = { :sale => '00', + :authorization => '01', + :capture => '32', + :credit => '34' } ENVELOPE_NAMESPACES = { 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', @@ -19,7 +19,7 @@ class ExactGateway < Gateway 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance' } - SEND_AND_COMMIT_ATTRIBUTES = { 'xmlns:n1' => "http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/Request", + SEND_AND_COMMIT_ATTRIBUTES = { 'xmlns:n1' => 'http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/Request', 'env:encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/' } @@ -27,11 +27,11 @@ class ExactGateway < Gateway 'xsi:type' => 'n2:Transaction' } - POST_HEADERS = { 'soapAction' => "http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/SendAndCommit", + POST_HEADERS = { 'soapAction' => 'http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/SendAndCommit', 'Content-Type' => 'text/xml' } - SUCCESS = "true" + SUCCESS = 'true' SENSITIVE_FIELDS = [ :verification_str2, :expiry_date, :card_number ] @@ -207,9 +207,9 @@ def parse(xml) response = {} xml = REXML::Document.new(xml) - if root = REXML::XPath.first(xml, "//types:TransactionResult") + if root = REXML::XPath.first(xml, '//types:TransactionResult') parse_elements(response, root) - elsif root = REXML::XPath.first(xml, "//soap:Fault") + elsif root = REXML::XPath.first(xml, '//soap:Fault') parse_elements(response, root) end diff --git a/lib/active_merchant/billing/gateways/ezic.rb b/lib/active_merchant/billing/gateways/ezic.rb index 7c1367cb650..15f81847ef4 100644 --- a/lib/active_merchant/billing/gateways/ezic.rb +++ b/lib/active_merchant/billing/gateways/ezic.rb @@ -23,7 +23,7 @@ def purchase(money, payment, options={}) add_payment(post, payment) add_customer_data(post, options) - commit("S", post) + commit('S', post) end def authorize(money, payment, options={}) @@ -34,7 +34,7 @@ def authorize(money, payment, options={}) add_payment(post, payment) add_customer_data(post, options) - commit("A", post) + commit('A', post) end def capture(money, authorization, options={}) @@ -45,7 +45,7 @@ def capture(money, authorization, options={}) add_authorization(post, authorization) add_pay_type(post) - commit("D", post) + commit('D', post) end def refund(money, authorization, options={}) @@ -56,7 +56,7 @@ def refund(money, authorization, options={}) add_authorization(post, authorization) add_pay_type(post) - commit("R", post) + commit('R', post) end def void(authorization, options={}) @@ -66,7 +66,7 @@ def void(authorization, options={}) add_authorization(post, authorization) add_pay_type(post) - commit("U", post) + commit('U', post) end def verify(credit_card, options={}) @@ -143,7 +143,7 @@ def add_authorization(post, authorization) end def add_pay_type(post) - post[:pay_type] = "C" + post[:pay_type] = 'C' end def parse(body) @@ -160,8 +160,8 @@ def commit(transaction_type, parameters) message_from(response), response, authorization: authorization_from(response), - avs_result: AVSResult.new(code: response["avs_code"]), - cvv_result: CVVResult.new(response["cvv2_code"]), + avs_result: AVSResult.new(code: response['avs_code']), + cvv_result: CVVResult.new(response['cvv2_code']), test: test? ) rescue ResponseError => e @@ -170,24 +170,24 @@ def commit(transaction_type, parameters) end def success_from(response) - response["status_code"] == "1" || response["status_code"] == "T" + response['status_code'] == '1' || response['status_code'] == 'T' end def message_from(response) - response["auth_msg"] + response['auth_msg'] end def authorization_from(response) - response["trans_id"] + response['trans_id'] end def post_data(parameters = {}) - parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def headers { - "User-Agent" => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}", + 'User-Agent' => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}", } end end diff --git a/lib/active_merchant/billing/gateways/fat_zebra.rb b/lib/active_merchant/billing/gateways/fat_zebra.rb index c63b0c2d1d5..aa64f4dad68 100644 --- a/lib/active_merchant/billing/gateways/fat_zebra.rb +++ b/lib/active_merchant/billing/gateways/fat_zebra.rb @@ -3,8 +3,8 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class FatZebraGateway < Gateway - self.live_url = "https://gateway.fatzebra.com.au/v1.0" - self.test_url = "https://gateway.sandbox.fatzebra.com.au/v1.0" + self.live_url = 'https://gateway.fatzebra.com.au/v1.0' + self.test_url = 'https://gateway.sandbox.fatzebra.com.au/v1.0' self.supported_countries = ['AU'] self.default_currency = 'AUD' @@ -61,14 +61,14 @@ def refund(money, txn_id, options={}) post[:transaction_id] = txn_id add_order_id(post, options) - commit(:post, "refunds", post) + commit(:post, 'refunds', post) end def store(creditcard, options={}) post = {} add_creditcard(post, creditcard) - commit(:post, "credit_cards", post) + commit(:post, 'credit_cards', post) end def supports_scrubbing? @@ -100,7 +100,7 @@ def add_creditcard(post, creditcard, options = {}) post[:card_token] = creditcard post[:cvv] = options[:cvv] elsif creditcard.is_a?(Hash) - ActiveMerchant.deprecated "Passing the credit card as a Hash is deprecated. Use a String and put the (optional) CVV in the options hash instead." + ActiveMerchant.deprecated 'Passing the credit card as a Hash is deprecated. Use a String and put the (optional) CVV in the options hash instead.' post[:card_token] = creditcard[:token] post[:cvv] = creditcard[:cvv] else @@ -110,7 +110,7 @@ def add_creditcard(post, creditcard, options = {}) def add_extra_options(post, options) extra = {} - extra[:ecm] = "32" if options[:recurring] + extra[:ecm] = '32' if options[:recurring] extra[:cavv] = options[:cavv] if options[:cavv] extra[:xid] = options[:xid] if options[:xid] extra[:sli] = options[:sli] if options[:sli] @@ -124,14 +124,14 @@ def add_order_id(post, options) end def add_ip(post, options) - post[:customer_ip] = options[:ip] || "127.0.0.1" + post[:customer_ip] = options[:ip] || '127.0.0.1' end def commit(method, uri, parameters=nil) response = begin parse(ssl_request(method, get_url(uri), parameters.to_json, headers)) rescue ResponseError => e - return Response.new(false, "Invalid Login") if(e.response.code == "401") + return Response.new(false, 'Invalid Login') if(e.response.code == '401') parse(e.response.body) end @@ -140,34 +140,34 @@ def commit(method, uri, parameters=nil) success, message_from(response), response, - :test => response["test"], + :test => response['test'], :authorization => authorization_from(response, success) ) end def success_from(response) ( - response["successful"] && - response["response"] && - (response["response"]["successful"] || response["response"]["token"]) + response['successful'] && + response['response'] && + (response['response']['successful'] || response['response']['token']) ) end def authorization_from(response, success) if success - (response["response"]["id"] || response["response"]["token"]) + (response['response']['id'] || response['response']['token']) else nil end end def message_from(response) - if !response["errors"].empty? - response["errors"].join(", ") - elsif response["response"]["message"] - response["response"]["message"] + if !response['errors'].empty? + response['errors'].join(', ') + elsif response['response']['message'] + response['response']['message'] else - "Unknown Error" + 'Unknown Error' end end @@ -178,22 +178,22 @@ def parse(response) msg = 'Invalid JSON response received from Fat Zebra. Please contact support@fatzebra.com.au if you continue to receive this message.' msg += " (The raw response returned by the API was #{response.inspect})" { - "successful" => false, - "response" => {}, - "errors" => [msg] + 'successful' => false, + 'response' => {}, + 'errors' => [msg] } end end def get_url(uri) base = test? ? self.test_url : self.live_url - base + "/" + uri + base + '/' + uri end def headers { - "Authorization" => "Basic " + Base64.strict_encode64(@options[:username].to_s + ":" + @options[:token].to_s).strip, - "User-Agent" => "Fat Zebra v1.0/ActiveMerchant #{ActiveMerchant::VERSION}" + 'Authorization' => 'Basic ' + Base64.strict_encode64(@options[:username].to_s + ':' + @options[:token].to_s).strip, + 'User-Agent' => "Fat Zebra v1.0/ActiveMerchant #{ActiveMerchant::VERSION}" } end end diff --git a/lib/active_merchant/billing/gateways/federated_canada.rb b/lib/active_merchant/billing/gateways/federated_canada.rb index c6694712ad9..d434f8307d2 100644 --- a/lib/active_merchant/billing/gateways/federated_canada.rb +++ b/lib/active_merchant/billing/gateways/federated_canada.rb @@ -140,11 +140,11 @@ def test? def message_from(response) case response['response'].to_i when APPROVED - "Transaction Approved" + 'Transaction Approved' when DECLINED - "Transaction Declined" + 'Transaction Declined' else - "Error in transaction data or system error" + 'Error in transaction data or system error' end end diff --git a/lib/active_merchant/billing/gateways/first_giving.rb b/lib/active_merchant/billing/gateways/first_giving.rb index 715b585e782..3adb5ab8d85 100644 --- a/lib/active_merchant/billing/gateways/first_giving.rb +++ b/lib/active_merchant/billing/gateways/first_giving.rb @@ -31,7 +31,7 @@ def refund(money, identifier, options = {}) get = {} get[:transactionId] = identifier get[:tranType] = 'REFUNDREQUEST' - commit("/transaction/refundrequest?" + encode(get)) + commit('/transaction/refundrequest?' + encode(get)) end private @@ -39,13 +39,13 @@ def refund(money, identifier, options = {}) def add_donation_data(post, money, options) post[:amount] = amount(money) post[:charityId] = @options[:charity_id] - post[:description] = (options[:description] || "Purchase") + post[:description] = (options[:description] || 'Purchase') post[:currencyCode] = (options[:currency] || currency(money)) end def add_customer_data(post, options) - post[:billToEmail] = (options[:email] || "activemerchant@example.com") - post[:remoteAddr] = (options[:ip] || "127.0.0.1") + post[:billToEmail] = (options[:email] || 'activemerchant@example.com') + post[:remoteAddr] = (options[:ip] || '127.0.0.1') end def add_address(post, options) @@ -76,7 +76,7 @@ def parse(body) response = {} xml = Nokogiri::XML(body) - element = xml.xpath("//firstGivingDonationApi/firstGivingResponse").first + element = xml.xpath('//firstGivingDonationApi/firstGivingResponse').first element.attributes.each do |name, attribute| response[name] = attribute.content @@ -103,16 +103,16 @@ def commit(action, post=nil) end Response.new( - (response["acknowledgement"] == "Success"), - (response["friendlyErrorMessage"] || response["verboseErrorMessage"] || response["acknowledgement"]), + (response['acknowledgement'] == 'Success'), + (response['friendlyErrorMessage'] || response['verboseErrorMessage'] || response['acknowledgement']), response, - authorization: response["transactionId"], + authorization: response['transactionId'], test: test?, ) end def post_data(post) - post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def encode(hash) @@ -121,10 +121,10 @@ def encode(hash) def creditcard_brand(brand) case brand - when "visa" then "VI" - when "master" then "MC" - when "discover" then "DI" - when "american_express" then "AX" + when 'visa' then 'VI' + when 'master' then 'MC' + when 'discover' then 'DI' + when 'american_express' then 'AX' else raise "Unhandled credit card brand #{brand}" end @@ -132,9 +132,9 @@ def creditcard_brand(brand) def headers { - "User-Agent" => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}", - "JG_APPLICATIONKEY" => "#{@options[:application_key]}", - "JG_SECURITYTOKEN" => "#{@options[:security_token]}" + 'User-Agent' => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}", + 'JG_APPLICATIONKEY' => "#{@options[:application_key]}", + 'JG_SECURITYTOKEN' => "#{@options[:security_token]}" } end end diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb index 88f40b5513e..b218557b4c7 100644 --- a/lib/active_merchant/billing/gateways/first_pay.rb +++ b/lib/active_merchant/billing/gateways/first_pay.rb @@ -107,7 +107,7 @@ def parse(xml) response = {} doc = Nokogiri::XML(xml) - doc.root.xpath("//RESPONSE/FIELDS/FIELD").each do |field| + doc.root.xpath('//RESPONSE/FIELDS/FIELD').each do |field| response[field['KEY']] = field.text end unless doc.root.nil? diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index 2644ecb53b1..58d18a49a52 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -2,45 +2,45 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class FirstdataE4Gateway < Gateway # TransArmor support requires v11 or lower - self.test_url = "https://api.demo.globalgatewaye4.firstdata.com/transaction/v11" - self.live_url = "https://api.globalgatewaye4.firstdata.com/transaction/v11" + self.test_url = 'https://api.demo.globalgatewaye4.firstdata.com/transaction/v11' + self.live_url = 'https://api.globalgatewaye4.firstdata.com/transaction/v11' TRANSACTIONS = { - sale: "00", - authorization: "01", - verify: "05", - capture: "32", - void: "33", - credit: "34", - store: "05" + sale: '00', + authorization: '01', + verify: '05', + capture: '32', + void: '33', + credit: '34', + store: '05' } POST_HEADERS = { - "Accepts" => "application/xml", - "Content-Type" => "application/xml" + 'Accepts' => 'application/xml', + 'Content-Type' => 'application/xml' } - SUCCESS = "true" + SUCCESS = 'true' SENSITIVE_FIELDS = [:verification_str2, :expiry_date, :card_number] BRANDS = { :visa => 'Visa', - :master => "Mastercard", - :american_express => "American Express", - :jcb => "JCB", - :discover => "Discover" + :master => 'Mastercard', + :american_express => 'American Express', + :jcb => 'JCB', + :discover => 'Discover' } - E4_BRANDS = BRANDS.merge({:mastercard => "Mastercard"}) + E4_BRANDS = BRANDS.merge({:mastercard => 'Mastercard'}) - DEFAULT_ECI = "07" + DEFAULT_ECI = '07' self.supported_cardtypes = BRANDS.keys - self.supported_countries = ["CA", "US"] - self.default_currency = "USD" - self.homepage_url = "http://www.firstdata.com" - self.display_name = "FirstData Global Gateway e4" + self.supported_countries = ['CA', 'US'] + self.default_currency = 'USD' + self.homepage_url = 'http://www.firstdata.com' + self.display_name = 'FirstData Global Gateway e4' STANDARD_ERROR_CODE_MAPPING = { # Bank error codes: https://firstdata.zendesk.com/entries/471297-First-Data-Global-Gateway-e4-Bank-Response-Codes @@ -132,8 +132,8 @@ def store(credit_card, options = {}) end def verify_credentials - response = void("0") - response.message != "Unauthorized Request. Bad or missing credentials." + response = void('0') + response.message != 'Unauthorized Request. Bad or missing credentials.' end def supports_scrubbing? @@ -159,7 +159,7 @@ def build_request(action, body) xml = Builder::XmlMarkup.new xml.instruct! - xml.tag! "Transaction", xmlns: "http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes" do + xml.tag! 'Transaction', xmlns: 'http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes' do add_credentials(xml) add_transaction_type(xml, action) xml << body @@ -208,19 +208,19 @@ def build_store_request(credit_card, options) end def add_credentials(xml) - xml.tag! "ExactID", @options[:login] - xml.tag! "Password", @options[:password] + xml.tag! 'ExactID', @options[:login] + xml.tag! 'Password', @options[:password] end def add_transaction_type(xml, action) - xml.tag! "Transaction_Type", TRANSACTIONS[action] + xml.tag! 'Transaction_Type', TRANSACTIONS[action] end def add_identification(xml, identification) - authorization_num, transaction_tag, _ = identification.split(";") + authorization_num, transaction_tag, _ = identification.split(';') - xml.tag! "Authorization_Num", authorization_num - xml.tag! "Transaction_Tag", transaction_tag + xml.tag! 'Authorization_Num', authorization_num + xml.tag! 'Transaction_Tag', transaction_tag end def add_amount(xml, money, options) @@ -231,13 +231,13 @@ def add_amount(xml, money, options) def add_credit_card(xml, credit_card, options) if credit_card.respond_to?(:track_data) && credit_card.track_data.present? - xml.tag! "Track1", credit_card.track_data - xml.tag! "Ecommerce_Flag", "R" + xml.tag! 'Track1', credit_card.track_data + xml.tag! 'Ecommerce_Flag', 'R' else - xml.tag! "Card_Number", credit_card.number - xml.tag! "Expiry_Date", expdate(credit_card) - xml.tag! "CardHoldersName", credit_card.name - xml.tag! "CardType", card_type(credit_card.brand) + xml.tag! 'Card_Number', credit_card.number + xml.tag! 'Expiry_Date', expdate(credit_card) + xml.tag! 'CardHoldersName', credit_card.name + xml.tag! 'CardType', card_type(credit_card.brand) add_credit_card_eci(xml, credit_card, options) add_credit_card_verification_strings(xml, credit_card, options) @@ -245,16 +245,16 @@ def add_credit_card(xml, credit_card, options) end def add_credit_card_eci(xml, credit_card, options) - eci = if credit_card.is_a?(NetworkTokenizationCreditCard) && credit_card.source == :apple_pay && card_brand(credit_card) == "discover" + eci = if credit_card.is_a?(NetworkTokenizationCreditCard) && credit_card.source == :apple_pay && card_brand(credit_card) == 'discover' # Discover requires any Apple Pay transaction, regardless of in-app # or web, and regardless of the ECI contained in the PKPaymentToken, # to have an ECI value explicitly of 04. - "04" + '04' else (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI end - xml.tag! "Ecommerce_Flag", eci.to_s =~ /^[0-9]+$/ ? eci.to_s.rjust(2, '0') : eci + xml.tag! 'Ecommerce_Flag', eci.to_s =~ /^[0-9]+$/ ? eci.to_s.rjust(2, '0') : eci end def add_credit_card_verification_strings(xml, credit_card, options) @@ -262,15 +262,15 @@ def add_credit_card_verification_strings(xml, credit_card, options) if address address_values = [] [:address1, :zip, :city, :state, :country].each { |part| address_values << address[part].to_s } - xml.tag! "VerificationStr1", address_values.join("|") + xml.tag! 'VerificationStr1', address_values.join('|') end if credit_card.is_a?(NetworkTokenizationCreditCard) add_network_tokenization_credit_card(xml, credit_card) else if credit_card.verification_value? - xml.tag! "CVD_Presence_Ind", "1" - xml.tag! "VerificationStr2", credit_card.verification_value + xml.tag! 'CVD_Presence_Ind', '1' + xml.tag! 'VerificationStr2', credit_card.verification_value end add_card_authentication_data(xml, options) @@ -281,21 +281,21 @@ def add_network_tokenization_credit_card(xml, credit_card) case card_brand(credit_card).to_sym when :american_express cryptogram = Base64.decode64(credit_card.payment_cryptogram) - xml.tag!("XID", Base64.encode64(cryptogram[20...40])) - xml.tag!("CAVV", Base64.encode64(cryptogram[0...20])) + xml.tag!('XID', Base64.encode64(cryptogram[20...40])) + xml.tag!('CAVV', Base64.encode64(cryptogram[0...20])) else - xml.tag!("XID", credit_card.transaction_id) if credit_card.transaction_id - xml.tag!("CAVV", credit_card.payment_cryptogram) + xml.tag!('XID', credit_card.transaction_id) if credit_card.transaction_id + xml.tag!('CAVV', credit_card.payment_cryptogram) end end def add_card_authentication_data(xml, options) - xml.tag! "CAVV", options[:cavv] - xml.tag! "XID", options[:xid] + xml.tag! 'CAVV', options[:cavv] + xml.tag! 'XID', options[:xid] end def add_credit_card_token(xml, store_authorization, options) - params = store_authorization.split(";") + params = store_authorization.split(';') credit_card = CreditCard.new( :brand => params[1], :first_name => params[2], @@ -303,37 +303,37 @@ def add_credit_card_token(xml, store_authorization, options) :month => params[4], :year => params[5]) - xml.tag! "TransarmorToken", params[0] - xml.tag! "Expiry_Date", expdate(credit_card) - xml.tag! "CardHoldersName", credit_card.name - xml.tag! "CardType", card_type(credit_card.brand) + xml.tag! 'TransarmorToken', params[0] + xml.tag! 'Expiry_Date', expdate(credit_card) + xml.tag! 'CardHoldersName', credit_card.name + xml.tag! 'CardType', card_type(credit_card.brand) add_card_authentication_data(xml, options) end def add_customer_data(xml, options) - xml.tag! "Customer_Ref", options[:customer] if options[:customer] - xml.tag! "Client_IP", options[:ip] if options[:ip] - xml.tag! "Client_Email", options[:email] if options[:email] + xml.tag! 'Customer_Ref', options[:customer] if options[:customer] + xml.tag! 'Client_IP', options[:ip] if options[:ip] + xml.tag! 'Client_Email', options[:email] if options[:email] end def add_address(xml, options) if address = (options[:billing_address] || options[:address]) - xml.tag! "ZipCode", address[:zip] + xml.tag! 'ZipCode', address[:zip] end end def add_invoice(xml, options) - xml.tag! "Reference_No", options[:order_id] - xml.tag! "Reference_3", options[:description] if options[:description] + xml.tag! 'Reference_No', options[:order_id] + xml.tag! 'Reference_3', options[:description] if options[:description] end def add_tax_fields(xml, options) - xml.tag! "Tax1Amount", options[:tax1_amount] if options[:tax1_amount] - xml.tag! "Tax1Number", options[:tax1_number] if options[:tax1_number] + xml.tag! 'Tax1Amount', options[:tax1_amount] if options[:tax1_amount] + xml.tag! 'Tax1Number', options[:tax1_number] if options[:tax1_number] end def add_level_3(xml, options) - xml.tag!("Level3") { |x| x << options[:level_3] } if options[:level_3] + xml.tag!('Level3') { |x| x << options[:level_3] } if options[:level_3] end def expdate(credit_card) @@ -379,9 +379,9 @@ def authorization_from(response) response[:authorization_num], response[:transaction_tag], (response[:dollar_amount].to_f * 100).round - ].join(";") + ].join(';') else - "" + '' end end @@ -394,7 +394,7 @@ def store_authorization_from(response, credit_card) credit_card.last_name, credit_card.month, credit_card.year - ].map { |value| value.to_s.gsub(/;/, "") }.join(";") + ].map { |value| value.to_s.gsub(/;/, '') }.join(';') else raise StandardError, "TransArmor support is not enabled on your #{display_name} account" end @@ -408,10 +408,10 @@ def money_from_authorization(auth) def message_from(response) if(response[:faultcode] && response[:faultstring]) response[:faultstring] - elsif(response[:error_number] && response[:error_number] != "0") + elsif(response[:error_number] && response[:error_number] != '0') response[:error_description] else - result = (response[:exact_message] || "") + result = (response[:exact_message] || '') result << " - #{response[:bank_message]}" if response[:bank_message].present? result end @@ -419,7 +419,7 @@ def message_from(response) def parse_error(error) { - :transaction_approved => "false", + :transaction_approved => 'false', :error_number => error.code, :error_description => error.body, :ecommerce_error_code => error.body.gsub(/[^\d]/, '') @@ -434,7 +434,7 @@ def parse(xml) response = {} xml = REXML::Document.new(xml) - if root = REXML::XPath.first(xml, "//TransactionResult") + if root = REXML::XPath.first(xml, '//TransactionResult') parse_elements(response, root) end @@ -443,7 +443,7 @@ def parse(xml) def parse_elements(response, root) root.elements.to_a.each do |node| - response[node.name.gsub(/EXact/, "Exact").underscore.to_sym] = (node.text || "").strip + response[node.name.gsub(/EXact/, 'Exact').underscore.to_sym] = (node.text || '').strip end end end diff --git a/lib/active_merchant/billing/gateways/flo2cash.rb b/lib/active_merchant/billing/gateways/flo2cash.rb index 9db34880391..83bdb83f50f 100644 --- a/lib/active_merchant/billing/gateways/flo2cash.rb +++ b/lib/active_merchant/billing/gateways/flo2cash.rb @@ -13,10 +13,10 @@ class Flo2cashGateway < Gateway self.supported_cardtypes = [:visa, :master, :american_express, :diners_club] BRAND_MAP = { - "visa" => "VISA", - "master" => "MC", - "american_express" => "AMEX", - "diners_club" => "DINERS" + 'visa' => 'VISA', + 'master' => 'MC', + 'american_express' => 'AMEX', + 'diners_club' => 'DINERS' } def initialize(options={}) @@ -37,7 +37,7 @@ def authorize(amount, payment_method, options={}) add_payment_method(post, payment_method) add_customer_data(post, options) - commit("ProcessAuthorise", post) + commit('ProcessAuthorise', post) end def capture(amount, authorization, options={}) @@ -46,7 +46,7 @@ def capture(amount, authorization, options={}) add_reference(post, authorization) add_customer_data(post, options) - commit("ProcessCapture", post) + commit('ProcessCapture', post) end def refund(amount, authorization, options={}) @@ -55,7 +55,7 @@ def refund(amount, authorization, options={}) add_reference(post, authorization) add_customer_data(post, options) - commit("ProcessRefund", post) + commit('ProcessRefund', post) end def supports_scrubbing? @@ -72,7 +72,7 @@ def scrub(transcript) private CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")} - CURRENCY_CODES["NZD"] = "554" + CURRENCY_CODES['NZD'] = '554' def add_invoice(post, money, options) post[:Amount] = amount(money) @@ -107,7 +107,7 @@ def commit(action, post) begin raw = parse(ssl_post(url, data, headers(action)), action) rescue ActiveMerchant::ResponseError => e - if(e.response.code == "500" && e.response.body.start_with?("<?xml")) + if(e.response.code == '500' && e.response.body.start_with?('<?xml')) raw = parse(e.response.body, action) else raise @@ -161,7 +161,7 @@ def url def parse(body, action) response = {} xml = REXML::Document.new(body) - root = (REXML::XPath.first(xml, "//#{action}Response") || REXML::XPath.first(xml, "//detail")) + root = (REXML::XPath.first(xml, "//#{action}Response") || REXML::XPath.first(xml, '//detail')) root.elements.to_a.each do |node| parse_element(response, node) @@ -184,9 +184,9 @@ def success_from(response) def message_from(succeeded, response) if succeeded - "Succeeded" + 'Succeeded' else - response[:message] || response[:errormessage] || "Unable to read error message" + response[:message] || response[:errormessage] || 'Unable to read error message' end end diff --git a/lib/active_merchant/billing/gateways/flo2cash_simple.rb b/lib/active_merchant/billing/gateways/flo2cash_simple.rb index 683aacafca9..f0662ff463c 100644 --- a/lib/active_merchant/billing/gateways/flo2cash_simple.rb +++ b/lib/active_merchant/billing/gateways/flo2cash_simple.rb @@ -9,7 +9,7 @@ def purchase(amount, payment_method, options={}) add_payment_method(post, payment_method) add_customer_data(post, options) - commit("ProcessPurchase", post) + commit('ProcessPurchase', post) end # Flo2Cash's "simple mode" does not support auth/capture diff --git a/lib/active_merchant/billing/gateways/forte.rb b/lib/active_merchant/billing/gateways/forte.rb index b13ec679b03..12b2e6e3308 100644 --- a/lib/active_merchant/billing/gateways/forte.rb +++ b/lib/active_merchant/billing/gateways/forte.rb @@ -27,7 +27,7 @@ def purchase(money, payment_method, options={}) add_payment_method(post, payment_method) add_billing_address(post, payment_method, options) add_shipping_address(post, options) - post[:action] = "sale" + post[:action] = 'sale' commit(:post, post) end @@ -39,7 +39,7 @@ def authorize(money, payment_method, options={}) add_payment_method(post, payment_method) add_billing_address(post, payment_method, options) add_shipping_address(post, options) - post[:action] = "authorize" + post[:action] = 'authorize' commit(:post, post) end @@ -47,8 +47,8 @@ def authorize(money, payment_method, options={}) def capture(money, authorization, options={}) post = {} post[:transaction_id] = transaction_id_from(authorization) - post[:authorization_code] = authorization_code_from(authorization) || "" - post[:action] = "capture" + post[:authorization_code] = authorization_code_from(authorization) || '' + post[:action] = 'capture' commit(:put, post) end @@ -59,7 +59,7 @@ def credit(money, payment_method, options={}) add_invoice(post, options) add_payment_method(post, payment_method) add_billing_address(post, payment_method, options) - post[:action] = "disburse" + post[:action] = 'disburse' commit(:post, post) end @@ -78,7 +78,7 @@ def void(authorization, options={}) post = {} post[:transaction_id] = transaction_id_from(authorization) post[:authorization_code] = authorization_code_from(authorization) - post[:action] = "void" + post[:action] = 'void' commit(:put, post) end @@ -192,8 +192,8 @@ def commit(type, parameters) message_from(response), response, authorization: authorization_from(response), - avs_result: AVSResult.new(code: response["response"]["avs_result"]), - cvv_result: CVVResult.new(response["response"]["cvv_code"]), + avs_result: AVSResult.new(code: response['response']['avs_result']), + cvv_result: CVVResult.new(response['response']['cvv_code']), test: test? ) end @@ -212,15 +212,15 @@ def parse(response_body) end def success_from(response) - response["response"]["response_code"] == "A01" + response['response']['response_code'] == 'A01' end def message_from(response) - response["response"]["response_desc"] + response['response']['response_desc'] end def authorization_from(response) - [response.try(:[], "transaction_id"), response.try(:[], "response").try(:[], "authorization_code")].join("#") + [response.try(:[], 'transaction_id'), response.try(:[], 'response').try(:[], 'authorization_code')].join('#') end def endpoint @@ -229,7 +229,7 @@ def endpoint def headers { - 'Authorization' => ("Basic " + Base64.strict_encode64("#{@options[:api_key]}:#{@options[:secret]}")), + 'Authorization' => ('Basic ' + Base64.strict_encode64("#{@options[:api_key]}:#{@options[:secret]}")), 'X-Forte-Auth-Account-Id' => "act_#{@options[:account_id]}", 'Content-Type' => 'application/json' } @@ -249,7 +249,7 @@ def format_card_brand(card_brand) end def split_authorization(authorization) - authorization.split("#") + authorization.split('#') end def authorization_code_from(authorization) diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb index c4b2c802b19..cd567c73d6c 100644 --- a/lib/active_merchant/billing/gateways/garanti.rb +++ b/lib/active_merchant/billing/gateways/garanti.rb @@ -37,24 +37,24 @@ def initialize(options = {}) end def purchase(money, credit_card, options = {}) - options = options.merge(:gvp_order_type => "sales") + options = options.merge(:gvp_order_type => 'sales') commit(money, build_sale_request(money, credit_card, options)) end def authorize(money, credit_card, options = {}) - options = options.merge(:gvp_order_type => "preauth") + options = options.merge(:gvp_order_type => 'preauth') commit(money, build_authorize_request(money, credit_card, options)) end def capture(money, ref_id, options = {}) - options = options.merge(:gvp_order_type => "postauth") + options = options.merge(:gvp_order_type => 'postauth') commit(money, build_capture_request(money, ref_id, options)) end private def security_data - rjusted_terminal_id = @options[:terminal_id].to_s.rjust(9, "0") + rjusted_terminal_id = @options[:terminal_id].to_s.rjust(9, '0') Digest::SHA1.hexdigest(@options[:password].to_s + rjusted_terminal_id).upcase end @@ -68,7 +68,7 @@ def build_xml_request(money, credit_card, options, &block) hash_data = generate_hash_data(format_order_id(options[:order_id]), @options[:terminal_id], card_number, amount(money), security_data) xml = Builder::XmlMarkup.new(:indent => 2) - xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8" + xml.instruct! :xml, :version => '1.0', :encoding => 'UTF-8' xml.tag! 'GVPSRequest' do xml.tag! 'Mode', test? ? 'TEST' : 'PROD' @@ -217,7 +217,7 @@ def currency_code(currency) def commit(money,request) url = test? ? self.test_url : self.live_url - raw_response = ssl_post(url, "data=" + request) + raw_response = ssl_post(url, 'data=' + request) response = parse(raw_response) success = success?(response) @@ -248,7 +248,7 @@ def parse_element(response, node) end def success?(response) - response[:message] == "Approved" + response[:message] == 'Approved' end def strip_invalid_xml_chars(xml) diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 4c069323eb2..3f37eb85177 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -1,14 +1,14 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class GlobalCollectGateway < Gateway - self.display_name = "GlobalCollect" - self.homepage_url = "http://www.globalcollect.com/" + self.display_name = 'GlobalCollect' + self.homepage_url = 'http://www.globalcollect.com/' - self.test_url = "https://api-sandbox.globalcollect.com/" - self.live_url = "https://api.globalcollect.com/" + self.test_url = 'https://api-sandbox.globalcollect.com/' + self.live_url = 'https://api.globalcollect.com/' - self.supported_countries = ["AD", "AE", "AG", "AI", "AL", "AM", "AO", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PL", "PN", "PS", "PT", "PW", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SR", "ST", "SV", "SZ", "TC", "TD", "TG", "TH", "TJ", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "US", "UY", "UZ", "VC", "VE", "VG", "VI", "VN", "WF", "WS", "ZA", "ZM", "ZW"] - self.default_currency = "USD" + self.supported_countries = ['AD', 'AE', 'AG', 'AI', 'AL', 'AM', 'AO', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PL', 'PN', 'PS', 'PT', 'PW', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SR', 'ST', 'SV', 'SZ', 'TC', 'TD', 'TG', 'TH', 'TJ', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'US', 'UY', 'UZ', 'VC', 'VE', 'VG', 'VI', 'VN', 'WF', 'WS', 'ZA', 'ZM', 'ZW'] + self.default_currency = 'USD' self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express, :discover] @@ -79,25 +79,25 @@ def scrub(transcript) private BRAND_MAP = { - "visa" => "1", - "american_express" => "2", - "master" => "3", - "discover" => "128", - "jcb" => "125", - "diners_club" => "132" + 'visa' => '1', + 'american_express' => '2', + 'master' => '3', + 'discover' => '128', + 'jcb' => '125', + 'diners_club' => '132' } def add_order(post, money, options) - post["order"]["amountOfMoney"] = { - "amount" => amount(money), - "currencyCode" => options[:currency] || currency(money) + post['order']['amountOfMoney'] = { + 'amount' => amount(money), + 'currencyCode' => options[:currency] || currency(money) } - post["order"]["references"] = { - "merchantReference" => options[:order_id], - "descriptor" => options[:description] # Max 256 chars + post['order']['references'] = { + 'merchantReference' => options[:order_id], + 'descriptor' => options[:description] # Max 256 chars } - post["order"]["references"]["invoiceData"] = { - "invoiceNumber" => options[:invoice] + post['order']['references']['invoiceData'] = { + 'invoiceNumber' => options[:invoice] } end @@ -113,9 +113,9 @@ def add_creator_info(post, options) end def add_amount(post, money, options={}) - post["amountOfMoney"] = { - "amount" => amount(money), - "currencyCode" => options[:currency] || currency(money) + post['amountOfMoney'] = { + 'amount' => amount(money), + 'currencyCode' => options[:currency] || currency(money) } end @@ -125,53 +125,53 @@ def add_payment(post, payment, options) expirydate = "#{month}#{year}" pre_authorization = options[:pre_authorization] ? 'PRE_AUTHORIZATION' : 'FINAL_AUTHORIZATION' - post["cardPaymentMethodSpecificInput"] = { - "paymentProductId" => BRAND_MAP[payment.brand], - "skipAuthentication" => "true", # refers to 3DSecure - "skipFraudService" => "true", - "authorizationMode" => pre_authorization + post['cardPaymentMethodSpecificInput'] = { + 'paymentProductId' => BRAND_MAP[payment.brand], + 'skipAuthentication' => 'true', # refers to 3DSecure + 'skipFraudService' => 'true', + 'authorizationMode' => pre_authorization } - post["cardPaymentMethodSpecificInput"]["card"] = { - "cvv" => payment.verification_value, - "cardNumber" => payment.number, - "expiryDate" => expirydate, - "cardholderName" => payment.name + post['cardPaymentMethodSpecificInput']['card'] = { + 'cvv' => payment.verification_value, + 'cardNumber' => payment.number, + 'expiryDate' => expirydate, + 'cardholderName' => payment.name } end def add_customer_data(post, options, payment = nil) - post["order"]["customer"] = { - "merchantCustomerId" => options[:customer] + post['order']['customer'] = { + 'merchantCustomerId' => options[:customer] } if payment - post["order"]["customer"]["personalInformation"] = { - "name" => { - "firstName" => payment.first_name[0..14], - "surname" => payment.last_name[0..69] + post['order']['customer']['personalInformation'] = { + 'name' => { + 'firstName' => payment.first_name[0..14], + 'surname' => payment.last_name[0..69] } } end - post["order"]["companyInformation"] = { - "name" => options[:company] + post['order']['companyInformation'] = { + 'name' => options[:company] } - post["order"]["contactDetails"] = { - "emailAddress" => options[:email] + post['order']['contactDetails'] = { + 'emailAddress' => options[:email] } if address = options[:billing_address] || options[:address] - post["order"]["contactDetails"] = { - "phoneNumber" => address[:phone] + post['order']['contactDetails'] = { + 'phoneNumber' => address[:phone] } end end def add_refund_customer_data(post, options) if address = options[:billing_address] || options[:address] - post["customer"]["address"] = { - "countryCode" => address[:country] + post['customer']['address'] = { + 'countryCode' => address[:country] } - post["customer"]["contactDetails"] = { - "emailAddress" => options[:email], - "phoneNumber" => address[:phone] + post['customer']['contactDetails'] = { + 'emailAddress' => options[:email], + 'phoneNumber' => address[:phone] } end end @@ -180,27 +180,27 @@ def add_address(post, creditcard, options) billing_address = options[:billing_address] || options[:address] shipping_address = options[:shipping_address] if billing_address = options[:billing_address] || options[:address] - post["order"]["customer"]["billingAddress"] = { - "street" => billing_address[:address1], - "additionalInfo" => billing_address[:address2], - "zip" => billing_address[:zip], - "city" => billing_address[:city], - "state" => billing_address[:state], - "countryCode" => billing_address[:country] + post['order']['customer']['billingAddress'] = { + 'street' => billing_address[:address1], + 'additionalInfo' => billing_address[:address2], + 'zip' => billing_address[:zip], + 'city' => billing_address[:city], + 'state' => billing_address[:state], + 'countryCode' => billing_address[:country] } end if shipping_address - post["order"]["customer"]["shippingAddress"] = { - "street" => shipping_address[:address1], - "additionalInfo" => shipping_address[:address2], - "zip" => shipping_address[:zip], - "city" => shipping_address[:city], - "state" => shipping_address[:state], - "countryCode" => shipping_address[:country] + post['order']['customer']['shippingAddress'] = { + 'street' => shipping_address[:address1], + 'additionalInfo' => shipping_address[:address2], + 'zip' => shipping_address[:zip], + 'city' => shipping_address[:city], + 'state' => shipping_address[:state], + 'countryCode' => shipping_address[:country] } - post["order"]["customer"]["shippingAddress"]["name"] = { - "firstName" => shipping_address[:firstname], - "surname" => shipping_address[:lastname] + post['order']['customer']['shippingAddress']['name'] = { + 'firstName' => shipping_address[:firstname], + 'surname' => shipping_address[:lastname] } end end @@ -210,7 +210,7 @@ def add_fraud_fields(post, options) fraud_fields.merge!(options[:fraud_fields]) if options[:fraud_fields] fraud_fields.merge!({customerIpAddress: options[:ip]}) if options[:ip] - post["fraudFields"] = fraud_fields unless fraud_fields.empty? + post['fraudFields'] = fraud_fields unless fraud_fields.empty? end def parse(body) @@ -225,7 +225,7 @@ def uri(action, authorization) uri = "/v1/#{@options[:merchant_id]}/" case action when :authorize - uri + "payments" + uri + 'payments' when :capture uri + "payments/#{authorization}/approve" when :refund @@ -258,9 +258,9 @@ def commit(action, post, authorization = nil) def headers(action, post, authorization = nil) { - "Content-Type" => content_type, - "Authorization" => auth_digest(action, post, authorization), - "Date" => date + 'Content-Type' => content_type, + 'Authorization' => auth_digest(action, post, authorization), + 'Date' => date } end @@ -277,47 +277,47 @@ def auth_digest(action, post, authorization = nil) end def date - @date ||= Time.now.strftime("%a, %d %b %Y %H:%M:%S %Z") # Must be same in digest and HTTP header + @date ||= Time.now.strftime('%a, %d %b %Y %H:%M:%S %Z') # Must be same in digest and HTTP header end def content_type - "application/json" + 'application/json' end def success_from(response) - !response["errorId"] && response["status"] != "REJECTED" + !response['errorId'] && response['status'] != 'REJECTED' end def message_from(succeeded, response) if succeeded - "Succeeded" + 'Succeeded' else - if errors = response["errors"] - errors.first.try(:[], "message") - elsif status = response["status"] - "Status: " + status + if errors = response['errors'] + errors.first.try(:[], 'message') + elsif status = response['status'] + 'Status: ' + status else - "No message available" + 'No message available' end end end def authorization_from(succeeded, response) if succeeded - response["id"] || response["payment"]["id"] || response["paymentResult"]["payment"]["id"] + response['id'] || response['payment']['id'] || response['paymentResult']['payment']['id'] else - response["errorId"] + response['errorId'] end end def error_code_from(succeeded, response) unless succeeded - if errors = response["errors"] - errors.first.try(:[], "code") - elsif status = response.try(:[], "statusOutput").try(:[], "statusCode") + if errors = response['errors'] + errors.first.try(:[], 'code') + elsif status = response.try(:[], 'statusOutput').try(:[], 'statusCode') status.to_s else - "No error code available" + 'No error code available' end end end @@ -327,7 +327,7 @@ def nestable_hash end def capture_requested?(response) - response.params.try(:[], "payment").try(:[], "status") == "CAPTURE_REQUESTED" + response.params.try(:[], 'payment').try(:[], 'status') == 'CAPTURE_REQUESTED' end end end diff --git a/lib/active_merchant/billing/gateways/global_transport.rb b/lib/active_merchant/billing/gateways/global_transport.rb index 3ccd1159513..94087b23e17 100644 --- a/lib/active_merchant/billing/gateways/global_transport.rb +++ b/lib/active_merchant/billing/gateways/global_transport.rb @@ -120,8 +120,8 @@ def parse(body) end ext_data = Nokogiri::HTML.parse(response[:extdata]) - response[:approved_amount] = ext_data.xpath("//approvedamount").text - response[:balance_due] = ext_data.xpath("//balancedue").text + response[:approved_amount] = ext_data.xpath('//approvedamount').text + response[:balance_due] = ext_data.xpath('//balancedue').text response end @@ -146,7 +146,7 @@ def post_data(action, params, options) post[:TransType] = action post[:ExtData] = "<TermType>#{@options[:term_type]}</TermType>" - post.merge(params).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + post.merge(params).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def url @@ -154,7 +154,7 @@ def url end def success_from(response) - response[:result] == "0" || response[:result] == "200" + response[:result] == '0' || response[:result] == '200' end def message_from(response) diff --git a/lib/active_merchant/billing/gateways/hdfc.rb b/lib/active_merchant/billing/gateways/hdfc.rb index be973857764..01404cd8d00 100644 --- a/lib/active_merchant/billing/gateways/hdfc.rb +++ b/lib/active_merchant/billing/gateways/hdfc.rb @@ -1,16 +1,16 @@ -require "nokogiri" +require 'nokogiri' module ActiveMerchant #:nodoc: module Billing #:nodoc: class HdfcGateway < Gateway - self.display_name = "HDFC" - self.homepage_url = "http://www.hdfcbank.com/sme/sme-details/merchant-services/guzh6m0i" + self.display_name = 'HDFC' + self.homepage_url = 'http://www.hdfcbank.com/sme/sme-details/merchant-services/guzh6m0i' - self.test_url = "https://securepgtest.fssnet.co.in/pgway/servlet/" - self.live_url = "https://securepg.fssnet.co.in/pgway/servlet/" + self.test_url = 'https://securepgtest.fssnet.co.in/pgway/servlet/' + self.live_url = 'https://securepg.fssnet.co.in/pgway/servlet/' - self.supported_countries = ["IN"] - self.default_currency = "INR" + self.supported_countries = ['IN'] + self.default_currency = 'INR' self.money_format = :dollars self.supported_cardtypes = [:visa, :master, :discover, :diners_club] @@ -25,7 +25,7 @@ def purchase(amount, payment_method, options={}) add_payment_method(post, payment_method) add_customer_data(post, options) - commit("purchase", post) + commit('purchase', post) end def authorize(amount, payment_method, options={}) @@ -34,7 +34,7 @@ def authorize(amount, payment_method, options={}) add_payment_method(post, payment_method) add_customer_data(post, options) - commit("authorize", post) + commit('authorize', post) end def capture(amount, authorization, options={}) @@ -43,7 +43,7 @@ def capture(amount, authorization, options={}) add_reference(post, authorization) add_customer_data(post, options) - commit("capture", post) + commit('capture', post) end def refund(amount, authorization, options={}) @@ -52,22 +52,22 @@ def refund(amount, authorization, options={}) add_reference(post, authorization) add_customer_data(post, options) - commit("refund", post) + commit('refund', post) end private CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")} - CURRENCY_CODES["AED"] = "784" - CURRENCY_CODES["AUD"] = "036" - CURRENCY_CODES["CAD"] = "124" - CURRENCY_CODES["EUR"] = "978" - CURRENCY_CODES["GBP"] = "826" - CURRENCY_CODES["INR"] = "356" - CURRENCY_CODES["OMR"] = "512" - CURRENCY_CODES["QAR"] = "634" - CURRENCY_CODES["SGD"] = "702" - CURRENCY_CODES["USD"] = "840" + CURRENCY_CODES['AED'] = '784' + CURRENCY_CODES['AUD'] = '036' + CURRENCY_CODES['CAD'] = '124' + CURRENCY_CODES['EUR'] = '978' + CURRENCY_CODES['GBP'] = '826' + CURRENCY_CODES['INR'] = '356' + CURRENCY_CODES['OMR'] = '512' + CURRENCY_CODES['QAR'] = '634' + CURRENCY_CODES['SGD'] = '702' + CURRENCY_CODES['USD'] = '840' def add_invoice(post, amount, options) post[:amt] = amount(amount) @@ -127,14 +127,14 @@ def parse(xml) end def fix_xml(xml) - xml.gsub(/&(?!(?:amp|quot|apos|lt|gt);)/, "&amp;") + xml.gsub(/&(?!(?:amp|quot|apos|lt|gt);)/, '&amp;') end ACTIONS = { - "purchase" => "1", - "refund" => "2", - "authorize" => "4", - "capture" => "5", + 'purchase' => '1', + 'refund' => '2', + 'authorize' => '4', + 'capture' => '5', } def commit(action, post) @@ -164,13 +164,13 @@ def build_request(post) end def url(action) - endpoint = "TranPortalXMLServlet" + endpoint = 'TranPortalXMLServlet' (test? ? test_url : live_url) + endpoint end def success_from(result) case result - when "CAPTURED", "APPROVED", "NOT ENROLLED", "ENROLLED" + when 'CAPTURED', 'APPROVED', 'NOT ENROLLED', 'ENROLLED' true else false @@ -179,23 +179,23 @@ def success_from(result) def message_from(succeeded, response) if succeeded - "Succeeded" + 'Succeeded' else - (response[:error_text] || response[:result] || "Unable to read error message").split("-").last + (response[:error_text] || response[:result] || 'Unable to read error message').split('-').last end end def authorization_from(request, response) - [response[:tranid], request[:member]].join("|") + [response[:tranid], request[:member]].join('|') end def split_authorization(authorization) - tranid, member = authorization.split("|") + tranid, member = authorization.split('|') [tranid, member] end def escape(string, max_length=250) - return "" unless string + return '' unless string if max_length string = string[0...max_length] end diff --git a/lib/active_merchant/billing/gateways/hps.rb b/lib/active_merchant/billing/gateways/hps.rb index 6bd1141e9d8..07f4fb26597 100644 --- a/lib/active_merchant/billing/gateways/hps.rb +++ b/lib/active_merchant/billing/gateways/hps.rb @@ -1,4 +1,4 @@ -require "nokogiri" +require 'nokogiri' module ActiveMerchant #:nodoc: module Billing #:nodoc: @@ -117,7 +117,7 @@ def add_payment(xml, card_or_token, options) xml.hps :CardData do if card_or_token.respond_to?(:number) if card_or_token.track_data - xml.tag!("hps:TrackData", 'method'=>'swipe') do + xml.tag!('hps:TrackData', 'method'=>'swipe') do xml.text! card_or_token.track_data end if options[:encryption_type] @@ -202,7 +202,7 @@ def parse(raw) doc = Nokogiri::XML(raw) doc.remove_namespaces! - if(header = doc.xpath("//Header").first) + if(header = doc.xpath('//Header').first) header.elements.each do |node| if (node.elements.size == 0) response[node.name] = node.text @@ -213,13 +213,13 @@ def parse(raw) end end end - if(transaction = doc.xpath("//Transaction/*[1]").first) + if(transaction = doc.xpath('//Transaction/*[1]').first) transaction.elements.each do |node| response[node.name] = node.text end end - if(fault = doc.xpath("//Fault/Reason/Text").first) - response["Fault"] = fault.text + if(fault = doc.xpath('//Fault/Reason/Text').first) + response['Fault'] = fault.text end response @@ -250,22 +250,22 @@ def commit(action, &request) def successful?(response) ( - (response["GatewayRspCode"] == "0") && - ((response["RspCode"] || "00") == "00" || response["RspCode"] == "85") + (response['GatewayRspCode'] == '0') && + ((response['RspCode'] || '00') == '00' || response['RspCode'] == '85') ) end def message_from(response) - if(response["Fault"]) - response["Fault"] - elsif(response["GatewayRspCode"] == "0") - if(response["RspCode"] != "00" && response["RspCode"] != "85") - issuer_message(response["RspCode"]) + if(response['Fault']) + response['Fault'] + elsif(response['GatewayRspCode'] == '0') + if(response['RspCode'] != '00' && response['RspCode'] != '85') + issuer_message(response['RspCode']) else response['GatewayRspMsg'] end else - (GATEWAY_MESSAGES[response["GatewayRspCode"]] || response["GatewayRspMsg"]) + (GATEWAY_MESSAGES[response['GatewayRspCode']] || response['GatewayRspMsg']) end end @@ -278,27 +278,27 @@ def test? end ISSUER_MESSAGES = { - "13" => "Must be greater than or equal 0.", - "14" => "The card number is incorrect.", - "54" => "The card has expired.", - "55" => "The 4-digit pin is invalid.", - "75" => "Maximum number of pin retries exceeded.", - "80" => "Card expiration date is invalid.", - "86" => "Can't verify card pin number." + '13' => 'Must be greater than or equal 0.', + '14' => 'The card number is incorrect.', + '54' => 'The card has expired.', + '55' => 'The 4-digit pin is invalid.', + '75' => 'Maximum number of pin retries exceeded.', + '80' => 'Card expiration date is invalid.', + '86' => "Can't verify card pin number." } def issuer_message(code) - return "The card was declined." if %w(02 03 04 05 41 43 44 51 56 61 62 63 65 78).include?(code) - return "An error occurred while processing the card." if %w(06 07 12 15 19 12 52 53 57 58 76 77 91 96 EC).include?(code) + return 'The card was declined.' if %w(02 03 04 05 41 43 44 51 56 61 62 63 65 78).include?(code) + return 'An error occurred while processing the card.' if %w(06 07 12 15 19 12 52 53 57 58 76 77 91 96 EC).include?(code) return "The card's security code is incorrect." if %w(EB N7).include?(code) ISSUER_MESSAGES[code] end GATEWAY_MESSAGES = { - "-2" => "Authentication error. Please double check your service configuration.", - "12" => "Invalid CPC data.", - "13" => "Invalid card data.", - "14" => "The card number is not a valid credit card number.", - "30" => "Gateway timed out." + '-2' => 'Authentication error. Please double check your service configuration.', + '12' => 'Invalid CPC data.', + '13' => 'Invalid card data.', + '14' => 'The card number is not a valid credit card number.', + '30' => 'Gateway timed out.' } end end diff --git a/lib/active_merchant/billing/gateways/iats_payments.rb b/lib/active_merchant/billing/gateways/iats_payments.rb index e96f94d3f4f..dcc43765847 100644 --- a/lib/active_merchant/billing/gateways/iats_payments.rb +++ b/lib/active_merchant/billing/gateways/iats_payments.rb @@ -14,12 +14,12 @@ class IatsPaymentsGateway < Gateway self.display_name = 'iATS Payments' ACTIONS = { - purchase: "ProcessCreditCardV1", - purchase_check: "ProcessACHEFTV1", - refund: "ProcessCreditCardRefundWithTransactionIdV1", - refund_check: "ProcessACHEFTRefundWithTransactionIdV1", - store: "CreateCreditCardCustomerCodeV1", - unstore: "DeleteCustomerCodeV1" + purchase: 'ProcessCreditCardV1', + purchase_check: 'ProcessACHEFTV1', + refund: 'ProcessCreditCardRefundWithTransactionIdV1', + refund_check: 'ProcessACHEFTRefundWithTransactionIdV1', + store: 'CreateCreditCardCustomerCodeV1', + unstore: 'DeleteCustomerCodeV1' } def initialize(options={}) @@ -145,19 +145,19 @@ def add_store_defaults(post) end def expdate(creditcard) - year = sprintf("%.4i", creditcard.year) - month = sprintf("%.2i", creditcard.month) + year = sprintf('%.4i', creditcard.year) + month = sprintf('%.2i', creditcard.month) "#{month}/#{year[-2..-1]}" end def creditcard_brand(brand) case brand - when "visa" then "VISA" - when "master" then "MC" - when "discover" then "DSC" - when "american_express" then "AMX" - when "maestro" then "MAESTR" + when 'visa' then 'VISA' + when 'master' then 'MC' + when 'discover' then 'DSC' + when 'american_express' then 'AMX' + when 'maestro' then 'MAESTR' else raise "Unhandled credit card brand #{brand}" end @@ -178,12 +178,12 @@ def commit(action, parameters) def endpoints { - purchase: "ProcessLink.asmx", - purchase_check: "ProcessLink.asmx", - refund: "ProcessLink.asmx", - refund_check: "ProcessLink.asmx", - store: "CustomerLink.asmx", - unstore: "CustomerLink.asmx" + purchase: 'ProcessLink.asmx', + purchase_check: 'ProcessLink.asmx', + refund: 'ProcessLink.asmx', + refund_check: 'ProcessLink.asmx', + store: 'CustomerLink.asmx', + unstore: 'CustomerLink.asmx' } end @@ -211,7 +211,7 @@ def dexmlize_param_name(name) def hashify_xml!(xml, response) xml = REXML::Document.new(xml) - xml.elements.each("//IATSRESPONSE/*") do |node| + xml.elements.each('//IATSRESPONSE/*') do |node| recursively_parse_element(node, response) end end @@ -229,7 +229,7 @@ def successful_result_message?(response) end def success_from(response) - response[:status] == "Success" && successful_result_message?(response) + response[:status] == 'Success' && successful_result_message?(response) end def message_from(response) @@ -253,14 +253,14 @@ def authorization_from(action, response) end def split_authorization(authorization) - authorization.split("|") + authorization.split('|') end def envelope_namespaces { - "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", - "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema", - "xmlns:soap12" => "http://www.w3.org/2003/05/soap-envelope" + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', + 'xmlns:soap12' => 'http://www.w3.org/2003/05/soap-envelope' } end @@ -269,7 +269,7 @@ def post_data(action, parameters = {}) xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8') xml.tag! 'soap12:Envelope', envelope_namespaces do xml.tag! 'soap12:Body' do - xml.tag! ACTIONS[action], { "xmlns" => "https://www.iatspayments.com/NetGate/" } do + xml.tag! ACTIONS[action], { 'xmlns' => 'https://www.iatspayments.com/NetGate/' } do xml.tag!('agentCode', @options[:agent_code]) xml.tag!('password', @options[:password]) parameters.each do |name, value| diff --git a/lib/active_merchant/billing/gateways/inspire.rb b/lib/active_merchant/billing/gateways/inspire.rb index 0c08f18b98b..52122d4d0b6 100644 --- a/lib/active_merchant/billing/gateways/inspire.rb +++ b/lib/active_merchant/billing/gateways/inspire.rb @@ -73,7 +73,7 @@ def refund(money, authorization, options = {}) # CreditCard object. def update(vault_id, creditcard, options = {}) post = {} - post[:customer_vault] = "update_customer" + post[:customer_vault] = 'update_customer' add_customer_vault_id(post, vault_id) add_creditcard(post, creditcard, options) add_address(post, creditcard, options) @@ -84,7 +84,7 @@ def update(vault_id, creditcard, options = {}) def delete(vault_id) post = {} - post[:customer_vault] = "delete_customer" + post[:customer_vault] = 'delete_customer' add_customer_vault_id(post, vault_id) commit(nil, nil, post) end @@ -141,7 +141,7 @@ def add_customer_vault_id(params,vault_id) def add_creditcard(post, creditcard,options) if options[:store] - post[:customer_vault] = "add_customer" + post[:customer_vault] = 'add_customer' post[:customer_vault_id] = options[:store] unless options[:store] == true end post[:ccnumber] = creditcard.number @@ -175,23 +175,23 @@ def commit(action, money, parameters) response = parse( ssl_post(self.live_url, post_data(action,parameters)) ) - Response.new(response["response"] == "1", message_from(response), response, - :authorization => response["transactionid"], + Response.new(response['response'] == '1', message_from(response), response, + :authorization => response['transactionid'], :test => test?, - :cvv_result => response["cvvresponse"], - :avs_result => { :code => response["avsresponse"] } + :cvv_result => response['cvvresponse'], + :avs_result => { :code => response['avsresponse'] } ) end def message_from(response) - case response["responsetext"] - when "SUCCESS","Approved" - "This transaction has been approved" - when "DECLINE" - "This transaction has been declined" + case response['responsetext'] + when 'SUCCESS','Approved' + 'This transaction has been approved' + when 'DECLINE' + 'This transaction has been declined' else - response["responsetext"] + response['responsetext'] end end @@ -201,7 +201,7 @@ def post_data(action, parameters = {}) post[:password] = @options[:password] post[:type] = action if action - request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&") + request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') request end @@ -210,7 +210,7 @@ def determine_funding_source(source) when source.is_a?(String) then :vault when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card when card_brand(source) == 'check' then :check - else raise ArgumentError, "Unsupported funding source provided" + else raise ArgumentError, 'Unsupported funding source provided' end end end diff --git a/lib/active_merchant/billing/gateways/instapay.rb b/lib/active_merchant/billing/gateways/instapay.rb index ee4ddc55007..13a41a76593 100644 --- a/lib/active_merchant/billing/gateways/instapay.rb +++ b/lib/active_merchant/billing/gateways/instapay.rb @@ -16,8 +16,8 @@ class InstapayGateway < Gateway # The name of the gateway self.display_name = 'InstaPay' - SUCCESS = "Accepted" - SUCCESS_MESSAGE = "The transaction has been approved" + SUCCESS = 'Accepted' + SUCCESS_MESSAGE = 'The transaction has been approved' def initialize(options = {}) requires!(options, :login) @@ -66,7 +66,7 @@ def add_reference(post, reference) def add_customer_data(post, options) post[:ci_email] = options[:email] - post["ci_IP Address"] = options[:ip] + post['ci_IP Address'] = options[:ip] end def add_address(post, options) @@ -154,7 +154,7 @@ def post_data(action, parameters = {}) post[:merchantpin] = @options[:password] end post[:action] = action - request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') request end end diff --git a/lib/active_merchant/billing/gateways/ipp.rb b/lib/active_merchant/billing/gateways/ipp.rb index dd475462a39..a7595b82388 100644 --- a/lib/active_merchant/billing/gateways/ipp.rb +++ b/lib/active_merchant/billing/gateways/ipp.rb @@ -1,4 +1,4 @@ -require "nokogiri" +require 'nokogiri' module ActiveMerchant #:nodoc: module Billing #:nodoc: @@ -15,10 +15,10 @@ class IppGateway < Gateway self.money_format = :cents STANDARD_ERROR_CODE_MAPPING = { - "05" => STANDARD_ERROR_CODE[:card_declined], - "06" => STANDARD_ERROR_CODE[:processing_error], - "14" => STANDARD_ERROR_CODE[:invalid_number], - "54" => STANDARD_ERROR_CODE[:expired_card], + '05' => STANDARD_ERROR_CODE[:card_declined], + '06' => STANDARD_ERROR_CODE[:processing_error], + '14' => STANDARD_ERROR_CODE[:invalid_number], + '54' => STANDARD_ERROR_CODE[:expired_card], } def initialize(options={}) @@ -27,11 +27,11 @@ def initialize(options={}) end def purchase(money, payment, options={}) - commit("SubmitSinglePayment") do |xml| + commit('SubmitSinglePayment') do |xml| xml.Transaction do xml.CustRef options[:order_id] add_amount(xml, money) - xml.TrnType "1" + xml.TrnType '1' add_credit_card(xml, payment) add_credentials(xml) xml.TrnSource options[:ip] @@ -40,11 +40,11 @@ def purchase(money, payment, options={}) end def authorize(money, payment, options={}) - commit("SubmitSinglePayment") do |xml| + commit('SubmitSinglePayment') do |xml| xml.Transaction do xml.CustRef options[:order_id] add_amount(xml, money) - xml.TrnType "2" + xml.TrnType '2' add_credit_card(xml, payment) add_credentials(xml) xml.TrnSource options[:ip] @@ -53,7 +53,7 @@ def authorize(money, payment, options={}) end def capture(money, authorization, options={}) - commit("SubmitSingleCapture") do |xml| + commit('SubmitSingleCapture') do |xml| xml.Capture do xml.Receipt authorization add_amount(xml, money) @@ -63,7 +63,7 @@ def capture(money, authorization, options={}) end def refund(money, authorization, options={}) - commit("SubmitSingleRefund") do |xml| + commit('SubmitSingleRefund') do |xml| xml.Refund do xml.Receipt authorization add_amount(xml, money) @@ -97,7 +97,7 @@ def add_amount(xml, money) end def add_credit_card(xml, payment) - xml.CreditCard :Registered => "False" do + xml.CreditCard :Registered => 'False' do xml.CardNumber payment.number xml.ExpM format(payment.month, :two_digits) xml.ExpY format(payment.year, :four_digits) @@ -119,8 +119,8 @@ def parse(body) def commit(action, &block) headers = { - "Content-Type" => "text/xml; charset=utf-8", - "SOAPAction" => "http://www.ippayments.com.au/interface/api/dts/#{action}", + 'Content-Type' => 'text/xml; charset=utf-8', + 'SOAPAction' => "http://www.ippayments.com.au/interface/api/dts/#{action}", } response = parse(ssl_post(commit_url, new_submit_xml(action, &block), headers)) @@ -137,9 +137,9 @@ def commit(action, &block) def new_submit_xml(action) xml = Builder::XmlMarkup.new(indent: 2) xml.instruct! - xml.soap :Envelope, "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema", "xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/" do + xml.soap :Envelope, 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' do xml.soap :Body do - xml.__send__(action, "xmlns" => "http://www.ippayments.com.au/interface/api/dts") do + xml.__send__(action, 'xmlns' => 'http://www.ippayments.com.au/interface/api/dts') do xml.trnXML do inner_xml = Builder::XmlMarkup.new(indent: 2) yield(inner_xml) @@ -156,7 +156,7 @@ def commit_url end def success_from(response) - (response[:response_code] == "0") + (response[:response_code] == '0') end def error_code_from(response) diff --git a/lib/active_merchant/billing/gateways/iridium.rb b/lib/active_merchant/billing/gateways/iridium.rb index 615dae08661..102a1677029 100644 --- a/lib/active_merchant/billing/gateways/iridium.rb +++ b/lib/active_merchant/billing/gateways/iridium.rb @@ -24,202 +24,202 @@ class IridiumGateway < Gateway self.display_name = 'Iridium' CURRENCY_CODES = { - "AED" => '784', - "AFN" => '971', - "ALL" => '008', - "AMD" => '051', - "ANG" => '532', - "AOA" => '973', - "ARS" => '032', - "AUD" => '036', - "AWG" => '533', - "AZN" => '944', - "BAM" => '977', - "BBD" => '052', - "BDT" => '050', - "BGN" => '975', - "BHD" => '048', - "BIF" => '108', - "BMD" => '060', - "BND" => '096', - "BOB" => '068', - "BOV" => '984', - "BRL" => '986', - "BSD" => '044', - "BTN" => '064', - "BWP" => '072', - "BYR" => '974', - "BZD" => '084', - "CAD" => '124', - "CDF" => '976', - "CHE" => '947', - "CHF" => '756', - "CHW" => '948', - "CLF" => '990', - "CLP" => '152', - "CNY" => '156', - "COP" => '170', - "COU" => '970', - "CRC" => '188', - "CUP" => '192', - "CVE" => '132', - "CYP" => '196', - "CZK" => '203', - "DJF" => '262', - "DKK" => '208', - "DOP" => '214', - "DZD" => '012', - "EEK" => '233', - "EGP" => '818', - "ERN" => '232', - "ETB" => '230', - "EUR" => '978', - "FJD" => '242', - "FKP" => '238', - "GBP" => '826', - "GEL" => '981', - "GHS" => '288', - "GIP" => '292', - "GMD" => '270', - "GNF" => '324', - "GTQ" => '320', - "GYD" => '328', - "HKD" => '344', - "HNL" => '340', - "HRK" => '191', - "HTG" => '332', - "HUF" => '348', - "IDR" => '360', - "ILS" => '376', - "INR" => '356', - "IQD" => '368', - "IRR" => '364', - "ISK" => '352', - "JMD" => '388', - "JOD" => '400', - "JPY" => '392', - "KES" => '404', - "KGS" => '417', - "KHR" => '116', - "KMF" => '174', - "KPW" => '408', - "KRW" => '410', - "KWD" => '414', - "KYD" => '136', - "KZT" => '398', - "LAK" => '418', - "LBP" => '422', - "LKR" => '144', - "LRD" => '430', - "LSL" => '426', - "LTL" => '440', - "LVL" => '428', - "LYD" => '434', - "MAD" => '504', - "MDL" => '498', - "MGA" => '969', - "MKD" => '807', - "MMK" => '104', - "MNT" => '496', - "MOP" => '446', - "MRO" => '478', - "MTL" => '470', - "MUR" => '480', - "MVR" => '462', - "MWK" => '454', - "MXN" => '484', - "MXV" => '979', - "MYR" => '458', - "MZN" => '943', - "NAD" => '516', - "NGN" => '566', - "NIO" => '558', - "NOK" => '578', - "NPR" => '524', - "NZD" => '554', - "OMR" => '512', - "PAB" => '590', - "PEN" => '604', - "PGK" => '598', - "PHP" => '608', - "PKR" => '586', - "PLN" => '985', - "PYG" => '600', - "QAR" => '634', - "ROL" => '642', - "RON" => '946', - "RSD" => '941', - "RUB" => '643', - "RWF" => '646', - "SAR" => '682', - "SBD" => '090', - "SCR" => '690', - "SDG" => '938', - "SEK" => '752', - "SGD" => '702', - "SHP" => '654', - "SKK" => '703', - "SLL" => '694', - "SOS" => '706', - "SRD" => '968', - "STD" => '678', - "SYP" => '760', - "SZL" => '748', - "THB" => '764', - "TJS" => '972', - "TMM" => '795', - "TND" => '788', - "TOP" => '776', - "TRY" => '949', - "TTD" => '780', - "TWD" => '901', - "TZS" => '834', - "UAH" => '980', - "UGX" => '800', - "USD" => '840', - "USN" => '997', - "USS" => '998', - "UYU" => '858', - "UZS" => '860', - "VEB" => '862', - "VND" => '704', - "VUV" => '548', - "WST" => '882', - "XAF" => '950', - "XAG" => '961', - "XAU" => '959', - "XBA" => '955', - "XBB" => '956', - "XBC" => '957', - "XBD" => '958', - "XCD" => '951', - "XDR" => '960', - "XOF" => '952', - "XPD" => '964', - "XPF" => '953', - "XPT" => '962', - "XTS" => '963', - "XXX" => '999', - "YER" => '886', - "ZAR" => '710', - "ZMK" => '894', - "ZWD" => '716', + 'AED' => '784', + 'AFN' => '971', + 'ALL' => '008', + 'AMD' => '051', + 'ANG' => '532', + 'AOA' => '973', + 'ARS' => '032', + 'AUD' => '036', + 'AWG' => '533', + 'AZN' => '944', + 'BAM' => '977', + 'BBD' => '052', + 'BDT' => '050', + 'BGN' => '975', + 'BHD' => '048', + 'BIF' => '108', + 'BMD' => '060', + 'BND' => '096', + 'BOB' => '068', + 'BOV' => '984', + 'BRL' => '986', + 'BSD' => '044', + 'BTN' => '064', + 'BWP' => '072', + 'BYR' => '974', + 'BZD' => '084', + 'CAD' => '124', + 'CDF' => '976', + 'CHE' => '947', + 'CHF' => '756', + 'CHW' => '948', + 'CLF' => '990', + 'CLP' => '152', + 'CNY' => '156', + 'COP' => '170', + 'COU' => '970', + 'CRC' => '188', + 'CUP' => '192', + 'CVE' => '132', + 'CYP' => '196', + 'CZK' => '203', + 'DJF' => '262', + 'DKK' => '208', + 'DOP' => '214', + 'DZD' => '012', + 'EEK' => '233', + 'EGP' => '818', + 'ERN' => '232', + 'ETB' => '230', + 'EUR' => '978', + 'FJD' => '242', + 'FKP' => '238', + 'GBP' => '826', + 'GEL' => '981', + 'GHS' => '288', + 'GIP' => '292', + 'GMD' => '270', + 'GNF' => '324', + 'GTQ' => '320', + 'GYD' => '328', + 'HKD' => '344', + 'HNL' => '340', + 'HRK' => '191', + 'HTG' => '332', + 'HUF' => '348', + 'IDR' => '360', + 'ILS' => '376', + 'INR' => '356', + 'IQD' => '368', + 'IRR' => '364', + 'ISK' => '352', + 'JMD' => '388', + 'JOD' => '400', + 'JPY' => '392', + 'KES' => '404', + 'KGS' => '417', + 'KHR' => '116', + 'KMF' => '174', + 'KPW' => '408', + 'KRW' => '410', + 'KWD' => '414', + 'KYD' => '136', + 'KZT' => '398', + 'LAK' => '418', + 'LBP' => '422', + 'LKR' => '144', + 'LRD' => '430', + 'LSL' => '426', + 'LTL' => '440', + 'LVL' => '428', + 'LYD' => '434', + 'MAD' => '504', + 'MDL' => '498', + 'MGA' => '969', + 'MKD' => '807', + 'MMK' => '104', + 'MNT' => '496', + 'MOP' => '446', + 'MRO' => '478', + 'MTL' => '470', + 'MUR' => '480', + 'MVR' => '462', + 'MWK' => '454', + 'MXN' => '484', + 'MXV' => '979', + 'MYR' => '458', + 'MZN' => '943', + 'NAD' => '516', + 'NGN' => '566', + 'NIO' => '558', + 'NOK' => '578', + 'NPR' => '524', + 'NZD' => '554', + 'OMR' => '512', + 'PAB' => '590', + 'PEN' => '604', + 'PGK' => '598', + 'PHP' => '608', + 'PKR' => '586', + 'PLN' => '985', + 'PYG' => '600', + 'QAR' => '634', + 'ROL' => '642', + 'RON' => '946', + 'RSD' => '941', + 'RUB' => '643', + 'RWF' => '646', + 'SAR' => '682', + 'SBD' => '090', + 'SCR' => '690', + 'SDG' => '938', + 'SEK' => '752', + 'SGD' => '702', + 'SHP' => '654', + 'SKK' => '703', + 'SLL' => '694', + 'SOS' => '706', + 'SRD' => '968', + 'STD' => '678', + 'SYP' => '760', + 'SZL' => '748', + 'THB' => '764', + 'TJS' => '972', + 'TMM' => '795', + 'TND' => '788', + 'TOP' => '776', + 'TRY' => '949', + 'TTD' => '780', + 'TWD' => '901', + 'TZS' => '834', + 'UAH' => '980', + 'UGX' => '800', + 'USD' => '840', + 'USN' => '997', + 'USS' => '998', + 'UYU' => '858', + 'UZS' => '860', + 'VEB' => '862', + 'VND' => '704', + 'VUV' => '548', + 'WST' => '882', + 'XAF' => '950', + 'XAG' => '961', + 'XAU' => '959', + 'XBA' => '955', + 'XBB' => '956', + 'XBC' => '957', + 'XBD' => '958', + 'XCD' => '951', + 'XDR' => '960', + 'XOF' => '952', + 'XPD' => '964', + 'XPF' => '953', + 'XPT' => '962', + 'XTS' => '963', + 'XXX' => '999', + 'YER' => '886', + 'ZAR' => '710', + 'ZMK' => '894', + 'ZWD' => '716', } AVS_CODE = { - "PASSED" => "Y", - "FAILED" => "N", - "PARTIAL" => "X", - "NOT_CHECKED" => "X", - "UNKNOWN" => "X" + 'PASSED' => 'Y', + 'FAILED' => 'N', + 'PARTIAL' => 'X', + 'NOT_CHECKED' => 'X', + 'UNKNOWN' => 'X' } CVV_CODE = { - "PASSED" => "M", - "FAILED" => "N", - "PARTIAL" => "I", - "NOT_CHECKED" => "P", - "UNKNOWN" => "U" + 'PASSED' => 'M', + 'FAILED' => 'N', + 'PARTIAL' => 'I', + 'NOT_CHECKED' => 'P', + 'UNKNOWN' => 'U' } def initialize(options = {}) @@ -288,7 +288,7 @@ def build_purchase_request(type, money, creditcard, options) def build_reference_request(type, money, authorization, options) options.merge!(:action => 'CrossReferenceTransaction') - order_id, cross_reference, _ = authorization.split(";") + order_id, cross_reference, _ = authorization.split(';') build_request(options) do |xml| if money details = {'CurrencyCode' => currency_code(options[:currency] || default_currency), 'Amount' => amount(money)} @@ -310,7 +310,7 @@ def build_request(options) 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do xml.tag! 'soap:Body' do - xml.tag! options[:action], {'xmlns' => "https://www.thepaymentgateway.net/"} do + xml.tag! options[:action], {'xmlns' => 'https://www.thepaymentgateway.net/'} do xml.tag! 'PaymentMessage' do add_merchant_data(xml, options) yield(xml) @@ -357,7 +357,7 @@ def add_customerdetails(xml, creditcard, address, options, shipTo = false) end xml.tag! 'EmailAddress', options[:email] - xml.tag! 'CustomerIPAddress', options[:ip] || "127.0.0.1" + xml.tag! 'CustomerIPAddress', options[:ip] || '127.0.0.1' end end @@ -366,23 +366,23 @@ def add_creditcard(xml, creditcard) xml.tag! 'CardName', creditcard.name xml.tag! 'CV2', creditcard.verification_value if creditcard.verification_value xml.tag! 'CardNumber', creditcard.number - xml.tag! 'ExpiryDate', { 'Month' => creditcard.month.to_s.rjust(2, "0"), 'Year' => creditcard.year.to_s[/\d\d$/] } + xml.tag! 'ExpiryDate', { 'Month' => creditcard.month.to_s.rjust(2, '0'), 'Year' => creditcard.year.to_s[/\d\d$/] } end end def add_merchant_data(xml, options) - xml.tag! 'MerchantAuthentication', {"MerchantID" => @options[:login], "Password" => @options[:password]} + xml.tag! 'MerchantAuthentication', {'MerchantID' => @options[:login], 'Password' => @options[:password]} end def commit(request, options) requires!(options, :action) response = parse(ssl_post(test? ? self.test_url : self.live_url, request, - {"SOAPAction" => "https://www.thepaymentgateway.net/" + options[:action], - "Content-Type" => "text/xml; charset=utf-8" })) + {'SOAPAction' => 'https://www.thepaymentgateway.net/' + options[:action], + 'Content-Type' => 'text/xml; charset=utf-8' })) - success = response[:transaction_result][:status_code] == "0" + success = response[:transaction_result][:status_code] == '0' message = response[:transaction_result][:message] - authorization = success ? [ options[:order_id], response[:transaction_output_data][:cross_reference], response[:transaction_output_data][:auth_code] ].compact.join(";") : nil + authorization = success ? [ options[:order_id], response[:transaction_output_data][:cross_reference], response[:transaction_output_data][:auth_code] ].compact.join(';') : nil Response.new(success, message, response, :test => test?, @@ -398,8 +398,8 @@ def commit(request, options) def parse(xml) reply = {} xml = REXML::Document.new(xml) - if (root = REXML::XPath.first(xml, "//CardDetailsTransactionResponse")) or - (root = REXML::XPath.first(xml, "//CrossReferenceTransactionResponse")) + if (root = REXML::XPath.first(xml, '//CardDetailsTransactionResponse')) or + (root = REXML::XPath.first(xml, '//CrossReferenceTransactionResponse')) root.elements.to_a.each do |node| case node.name when 'Message' @@ -408,7 +408,7 @@ def parse(xml) parse_element(reply, node) end end - elsif root = REXML::XPath.first(xml, "//soap:Fault") + elsif root = REXML::XPath.first(xml, '//soap:Fault') parse_element(reply, root) reply[:message] = "#{reply[:faultcode]}: #{reply[:faultstring]}" end @@ -417,29 +417,29 @@ def parse(xml) def parse_element(reply, node) case node.name - when "CrossReferenceTransactionResult" + when 'CrossReferenceTransactionResult' reply[:transaction_result] = {} node.attributes.each do |a,b| reply[:transaction_result][a.underscore.to_sym] = b end node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements? - when "CardDetailsTransactionResult" + when 'CardDetailsTransactionResult' reply[:transaction_result] = {} node.attributes.each do |a,b| reply[:transaction_result][a.underscore.to_sym] = b end node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements? - when "TransactionOutputData" + when 'TransactionOutputData' reply[:transaction_output_data] = {} node.attributes.each{|a,b| reply[:transaction_output_data][a.underscore.to_sym] = b } node.elements.each{|e| parse_element(reply[:transaction_output_data], e) } if node.has_elements? - when "CustomVariables" + when 'CustomVariables' reply[:custom_variables] = {} node.attributes.each{|a,b| reply[:custom_variables][a.underscore.to_sym] = b } node.elements.each{|e| parse_element(reply[:custom_variables], e) } if node.has_elements? - when "GatewayEntryPoints" + when 'GatewayEntryPoints' reply[:gateway_entry_points] = {} node.attributes.each{|a,b| reply[:gateway_entry_points][a.underscore.to_sym] = b } node.elements.each{|e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements? diff --git a/lib/active_merchant/billing/gateways/iveri.rb b/lib/active_merchant/billing/gateways/iveri.rb index a1ec20624cc..64f08999b39 100644 --- a/lib/active_merchant/billing/gateways/iveri.rb +++ b/lib/active_merchant/billing/gateways/iveri.rb @@ -175,18 +175,18 @@ def mode def headers(post) { - "Content-Type" => "text/xml; charset=utf-8", - "Content-Length" => post.size.to_s, - "SOAPAction" => "http://iveri.com/Execute" + 'Content-Type' => 'text/xml; charset=utf-8', + 'Content-Length' => post.size.to_s, + 'SOAPAction' => 'http://iveri.com/Execute' } end def parse(body) parsed = {} - vxml = Nokogiri::XML(body).remove_namespaces!.xpath("//Envelope/Body/ExecuteResponse/ExecuteResult").inner_text + vxml = Nokogiri::XML(body).remove_namespaces!.xpath('//Envelope/Body/ExecuteResponse/ExecuteResult').inner_text doc = Nokogiri::XML(vxml) - doc.xpath("*").each do |node| + doc.xpath('*').each do |node| if (node.elements.empty?) parsed[underscore(node.name)] = node.text else @@ -201,7 +201,7 @@ def parse(body) def parse_element(parsed, node) if !node.attributes.empty? node.attributes.each do |a| - parsed[underscore(node.name)+ "_" + underscore(a[1].name)] = a[1].value + parsed[underscore(node.name)+ '_' + underscore(a[1].name)] = a[1].value end end @@ -218,7 +218,7 @@ def success_from(response) def message_from(response, succeeded) if succeeded - "Succeeded" + 'Succeeded' else response['result_description'] || response['result_acquirer_description'] end @@ -243,7 +243,7 @@ def underscore(camel_cased_word) camel_cased_word.to_s.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). - tr("-", "_"). + tr('-', '_'). downcase end end diff --git a/lib/active_merchant/billing/gateways/jetpay.rb b/lib/active_merchant/billing/gateways/jetpay.rb index 7a32ae1a1fb..948c4799941 100644 --- a/lib/active_merchant/billing/gateways/jetpay.rb +++ b/lib/active_merchant/billing/gateways/jetpay.rb @@ -23,132 +23,132 @@ class JetpayGateway < Gateway self.money_format = :cents ACTION_CODE_MESSAGES = { - "000" => "Approved.", - "001" => "Refer to card issuer.", - "002" => "Refer to card issuer, special condition.", - "003" => "Invalid merchant or service provider.", - "004" => "Pick up card.", - "005" => "Do not honor.", - "006" => "Error.", - "007" => "Pick up card, special condition.", - "008" => "Honor with ID (Show ID).", - "010" => "Partial approval.", - "011" => "VIP approval.", - "012" => "Invalid transaction.", - "013" => "Invalid amount or exceeds maximum for card program.", - "014" => "Invalid account number (no such number).", - "015" => "No such issuer.", - "019" => "Re-enter Transaction.", - "021" => "No action taken (unable to back out prior transaction).", - "025" => "Transaction Not Found.", - "027" => "File update field edit error.", - "028" => "File is temporarily unavailable.", - "030" => "Format error.", - "039" => "No credit account.", - "041" => "Pick up card (lost card).", - "043" => "Pick up card (stolen card).", - "051" => "Insufficient funds.", - "052" => "No checking account.", - "053" => "No savings account.", - "054" => "Expired Card.", - "055" => "Incorrect PIN.", - "057" => "Transaction not permitted to cardholder.", - "058" => "Transaction not allowed at terminal.", - "061" => "Exceeds withdrawal limit.", - "062" => "Restricted card (eg, Country Exclusion).", - "063" => "Security violation.", - "065" => "Activity count limit exceeded.", - "068" => "Response late.", - "070" => "Contact card issuer.", - "071" => "PIN not changed.", - "075" => "Allowable number of PIN-entry tries exceeded.", - "076" => "Unable to locate previous message (no matching retrieval reference number).", - "077" => "Repeat or reversal data are inconsistent with original message.", - "078" => "Blocked (first use), or non-existent account.", - "079" => "Key exchange validation failed.", - "080" => "Credit issuer unavailable or invalid date.", - "081" => "PIN cryptographic error found.", - "082" => "Negative online CVV results.", - "084" => "Invalid auth life cycle.", - "085" => "No reason to decline - CVV or AVS approved.", - "086" => "Cannot verify PIN.", - "087" => "Cashback not allowed.", - "089" => "Issuer Down.", - "091" => "Issuer Down.", - "092" => "Unable to route transaction.", - "093" => "Transaction cannot be completed - violation of law.", - "094" => "Duplicate transmission.", - "096" => "System error.", - "100" => "Deny.", - "101" => "Expired Card.", - "103" => "Deny - Invalid manual Entry 4DBC.", - "104" => "Deny - New card issued.", - "105" => "Deny - Account Cancelled.", - "106" => "Exceeded PIN Attempts.", - "107" => "Please Call Issuer.", - "109" => "Invalid merchant.", - "110" => "Invalid amount.", - "111" => "Invalid account.", - "115" => "Service not permitted.", - "122" => "Invalid card (CID) security code.", - "125" => "Invalid effective date.", - "181" => "Format error.", - "182" => "Please wait.", - "183" => "Invalid currency code.", - "187" => "Deny - new card issued.", - "188" => "Deny - Expiration date required.", - "189" => "Deny - Cancelled or Closed Merchant/SE.", - "200" => "Deny - Pick up card.", - "400" => "Reversal accepted.", - "601" => "Reject - EMV Chip Declined Transaction.", - "602" => "Reject - Suspected Fraud.", - "603" => "Reject - Communications Error.", - "604" => "Reject - Insufficient Approval.", - "750" => "Velocity Check Fail.", - "899" => "Misc Decline.", - "900" => "Invalid Message Type.", - "901" => "Invalid Merchant ID.", - "903" => "Debit not supported.", - "904" => "Private label not supported.", - "905" => "Invalid card type.", - "906" => "Unit not active.", - "908" => "Manual card entry invalid.", - "909" => "Invalid track information.", - "911" => "Master merchant not found.", - "912" => "Invalid card format.", - "913" => "Invalid card type.", - "914" => "Invalid card length.", - "917" => "Expired card.", - "919" => "Invalid entry type.", - "920" => "Invalid amount.", - "921" => "Invalid messge format.", - "923" => "Invalid ABA.", - "924" => "Invalid DDA.", - "925" => "Invalid TID.", - "926" => "Invalid Password.", - "930" => "Invalid zipcode.", - "931" => "Invalid Address.", - "932" => "Invalid ZIP and Address.", - "933" => "Invalid CVV2.", - "934" => "Program Not Allowed.", - "940" => "Record Not Found.", - "941" => "Merchant ID error.", - "942" => "Refund Not Allowed.", - "943" => "Refund denied.", - "955" => "Invalid PIN block.", - "956" => "Invalid KSN.", - "958" => "Bad Status.", - "959" => "Seek Record limit exceeded.", - "962" => "Invalid PIN key (Unknown KSN).", - "981" => "Invalid AVS.", - "987" => "Issuer Unavailable.", - "988" => "System error SD.", - "989" => "Database Error.", - "992" => "Transaction Timeout.", - "996" => "Bad Terminal ID.", - "997" => "Message rejected by association.", - "999" => "Communication failure", - nil => "No response returned (missing credentials?)." + '000' => 'Approved.', + '001' => 'Refer to card issuer.', + '002' => 'Refer to card issuer, special condition.', + '003' => 'Invalid merchant or service provider.', + '004' => 'Pick up card.', + '005' => 'Do not honor.', + '006' => 'Error.', + '007' => 'Pick up card, special condition.', + '008' => 'Honor with ID (Show ID).', + '010' => 'Partial approval.', + '011' => 'VIP approval.', + '012' => 'Invalid transaction.', + '013' => 'Invalid amount or exceeds maximum for card program.', + '014' => 'Invalid account number (no such number).', + '015' => 'No such issuer.', + '019' => 'Re-enter Transaction.', + '021' => 'No action taken (unable to back out prior transaction).', + '025' => 'Transaction Not Found.', + '027' => 'File update field edit error.', + '028' => 'File is temporarily unavailable.', + '030' => 'Format error.', + '039' => 'No credit account.', + '041' => 'Pick up card (lost card).', + '043' => 'Pick up card (stolen card).', + '051' => 'Insufficient funds.', + '052' => 'No checking account.', + '053' => 'No savings account.', + '054' => 'Expired Card.', + '055' => 'Incorrect PIN.', + '057' => 'Transaction not permitted to cardholder.', + '058' => 'Transaction not allowed at terminal.', + '061' => 'Exceeds withdrawal limit.', + '062' => 'Restricted card (eg, Country Exclusion).', + '063' => 'Security violation.', + '065' => 'Activity count limit exceeded.', + '068' => 'Response late.', + '070' => 'Contact card issuer.', + '071' => 'PIN not changed.', + '075' => 'Allowable number of PIN-entry tries exceeded.', + '076' => 'Unable to locate previous message (no matching retrieval reference number).', + '077' => 'Repeat or reversal data are inconsistent with original message.', + '078' => 'Blocked (first use), or non-existent account.', + '079' => 'Key exchange validation failed.', + '080' => 'Credit issuer unavailable or invalid date.', + '081' => 'PIN cryptographic error found.', + '082' => 'Negative online CVV results.', + '084' => 'Invalid auth life cycle.', + '085' => 'No reason to decline - CVV or AVS approved.', + '086' => 'Cannot verify PIN.', + '087' => 'Cashback not allowed.', + '089' => 'Issuer Down.', + '091' => 'Issuer Down.', + '092' => 'Unable to route transaction.', + '093' => 'Transaction cannot be completed - violation of law.', + '094' => 'Duplicate transmission.', + '096' => 'System error.', + '100' => 'Deny.', + '101' => 'Expired Card.', + '103' => 'Deny - Invalid manual Entry 4DBC.', + '104' => 'Deny - New card issued.', + '105' => 'Deny - Account Cancelled.', + '106' => 'Exceeded PIN Attempts.', + '107' => 'Please Call Issuer.', + '109' => 'Invalid merchant.', + '110' => 'Invalid amount.', + '111' => 'Invalid account.', + '115' => 'Service not permitted.', + '122' => 'Invalid card (CID) security code.', + '125' => 'Invalid effective date.', + '181' => 'Format error.', + '182' => 'Please wait.', + '183' => 'Invalid currency code.', + '187' => 'Deny - new card issued.', + '188' => 'Deny - Expiration date required.', + '189' => 'Deny - Cancelled or Closed Merchant/SE.', + '200' => 'Deny - Pick up card.', + '400' => 'Reversal accepted.', + '601' => 'Reject - EMV Chip Declined Transaction.', + '602' => 'Reject - Suspected Fraud.', + '603' => 'Reject - Communications Error.', + '604' => 'Reject - Insufficient Approval.', + '750' => 'Velocity Check Fail.', + '899' => 'Misc Decline.', + '900' => 'Invalid Message Type.', + '901' => 'Invalid Merchant ID.', + '903' => 'Debit not supported.', + '904' => 'Private label not supported.', + '905' => 'Invalid card type.', + '906' => 'Unit not active.', + '908' => 'Manual card entry invalid.', + '909' => 'Invalid track information.', + '911' => 'Master merchant not found.', + '912' => 'Invalid card format.', + '913' => 'Invalid card type.', + '914' => 'Invalid card length.', + '917' => 'Expired card.', + '919' => 'Invalid entry type.', + '920' => 'Invalid amount.', + '921' => 'Invalid messge format.', + '923' => 'Invalid ABA.', + '924' => 'Invalid DDA.', + '925' => 'Invalid TID.', + '926' => 'Invalid Password.', + '930' => 'Invalid zipcode.', + '931' => 'Invalid Address.', + '932' => 'Invalid ZIP and Address.', + '933' => 'Invalid CVV2.', + '934' => 'Program Not Allowed.', + '940' => 'Record Not Found.', + '941' => 'Merchant ID error.', + '942' => 'Refund Not Allowed.', + '943' => 'Refund denied.', + '955' => 'Invalid PIN block.', + '956' => 'Invalid KSN.', + '958' => 'Bad Status.', + '959' => 'Seek Record limit exceeded.', + '962' => 'Invalid PIN key (Unknown KSN).', + '981' => 'Invalid AVS.', + '987' => 'Issuer Unavailable.', + '988' => 'System error SD.', + '989' => 'Database Error.', + '992' => 'Transaction Timeout.', + '996' => 'Bad Terminal ID.', + '997' => 'Message rejected by association.', + '999' => 'Communication failure', + nil => 'No response returned (missing credentials?).' } def initialize(options = {}) @@ -165,14 +165,14 @@ def authorize(money, credit_card, options = {}) end def capture(money, reference, options = {}) - split_authorization = reference.split(";") + split_authorization = reference.split(';') transaction_id = split_authorization[0] token = split_authorization[3] commit(money, build_capture_request(transaction_id, money, options), token) end def void(reference, options = {}) - transaction_id, approval, amount, token = reference.split(";") + transaction_id, approval, amount, token = reference.split(';') commit(amount.to_i, build_void_request(amount.to_i, transaction_id, approval, token, options), token) end @@ -186,7 +186,7 @@ def credit(money, transaction_id_or_card, options = {}) end def refund(money, reference, options = {}) - split_authorization = reference.split(";") + split_authorization = reference.split(';') transaction_id = split_authorization[0] token = split_authorization[3] credit_card = options[:credit_card] @@ -326,7 +326,7 @@ def format_exp(value) end def success?(response) - response[:action_code] == "000" + response[:action_code] == '000' end def message_from(response) @@ -335,11 +335,11 @@ def message_from(response) def authorization_from(response, money, previous_token) original_amount = amount(money) if money - [ response[:transaction_id], response[:approval], original_amount, (response[:token] || previous_token)].join(";") + [ response[:transaction_id], response[:approval], original_amount, (response[:token] || previous_token)].join(';') end def add_credit_card(xml, credit_card) - xml.tag! 'CardNum', credit_card.number, "Tokenize" => true + xml.tag! 'CardNum', credit_card.number, 'Tokenize' => true xml.tag! 'CardExpMonth', format_exp(credit_card.month) xml.tag! 'CardExpYear', format_exp(credit_card.year) @@ -354,7 +354,7 @@ def add_credit_card(xml, credit_card) def add_addresses(xml, options) if billing_address = options[:billing_address] || options[:address] - xml.tag! 'BillingAddress', [billing_address[:address1], billing_address[:address2]].compact.join(" ") + xml.tag! 'BillingAddress', [billing_address[:address1], billing_address[:address2]].compact.join(' ') xml.tag! 'BillingCity', billing_address[:city] xml.tag! 'BillingStateProv', billing_address[:state] xml.tag! 'BillingPostalCode', billing_address[:zip] @@ -367,7 +367,7 @@ def add_addresses(xml, options) xml.tag! 'ShippingName', shipping_address[:name] xml.tag! 'ShippingAddr' do - xml.tag! 'Address', [shipping_address[:address1], shipping_address[:address2]].compact.join(" ") + xml.tag! 'Address', [shipping_address[:address1], shipping_address[:address2]].compact.join(' ') xml.tag! 'City', shipping_address[:city] xml.tag! 'StateProv', shipping_address[:state] xml.tag! 'PostalCode', shipping_address[:zip] diff --git a/lib/active_merchant/billing/gateways/jetpay_v2.rb b/lib/active_merchant/billing/gateways/jetpay_v2.rb index 31d92e00960..0eb900d2aea 100644 --- a/lib/active_merchant/billing/gateways/jetpay_v2.rb +++ b/lib/active_merchant/billing/gateways/jetpay_v2.rb @@ -15,137 +15,137 @@ class JetpayV2Gateway < Gateway API_VERSION = '2.2' ACTION_CODE_MESSAGES = { - "000" => "Approved.", - "001" => "Refer to card issuer.", - "002" => "Refer to card issuer, special condition.", - "003" => "Invalid merchant or service provider.", - "004" => "Pick up card.", - "005" => "Do not honor.", - "006" => "Error.", - "007" => "Pick up card, special condition.", - "008" => "Honor with ID (Show ID).", - "010" => "Partial approval.", - "011" => "VIP approval.", - "012" => "Invalid transaction.", - "013" => "Invalid amount or exceeds maximum for card program.", - "014" => "Invalid account number (no such number).", - "015" => "No such issuer.", - "019" => "Re-enter Transaction.", - "021" => "No action taken (unable to back out prior transaction).", - "025" => "Transaction Not Found.", - "027" => "File update field edit error.", - "028" => "File is temporarily unavailable.", - "030" => "Format error.", - "039" => "No credit account.", - "041" => "Pick up card (lost card).", - "043" => "Pick up card (stolen card).", - "051" => "Insufficient funds.", - "052" => "No checking account.", - "053" => "No savings account.", - "054" => "Expired Card.", - "055" => "Incorrect PIN.", - "057" => "Transaction not permitted to cardholder.", - "058" => "Transaction not allowed at terminal.", - "061" => "Exceeds withdrawal limit.", - "062" => "Restricted card (eg, Country Exclusion).", - "063" => "Security violation.", - "065" => "Activity count limit exceeded.", - "068" => "Response late.", - "070" => "Contact card issuer.", - "071" => "PIN not changed.", - "075" => "Allowable number of PIN-entry tries exceeded.", - "076" => "Unable to locate previous message (no matching retrieval reference number).", - "077" => "Repeat or reversal data are inconsistent with original message.", - "078" => "Blocked (first use), or non-existent account.", - "079" => "Key exchange validation failed.", - "080" => "Credit issuer unavailable or invalid date.", - "081" => "PIN cryptographic error found.", - "082" => "Negative online CVV results.", - "084" => "Invalid auth life cycle.", - "085" => "No reason to decline - CVV or AVS approved.", - "086" => "Cannot verify PIN.", - "087" => "Cashback not allowed.", - "089" => "Issuer Down.", - "091" => "Issuer Down.", - "092" => "Unable to route transaction.", - "093" => "Transaction cannot be completed - violation of law.", - "094" => "Duplicate transmission.", - "096" => "System error.", - "100" => "Deny.", - "101" => "Expired Card.", - "103" => "Deny - Invalid manual Entry 4DBC.", - "104" => "Deny - New card issued.", - "105" => "Deny - Account Cancelled.", - "106" => "Exceeded PIN Attempts.", - "107" => "Please Call Issuer.", - "109" => "Invalid merchant.", - "110" => "Invalid amount.", - "111" => "Invalid account.", - "115" => "Service not permitted.", - "117" => "Invalid PIN.", - "119" => "Card member not enrolled.", - "122" => "Invalid card (CID) security code.", - "125" => "Invalid effective date.", - "181" => "Format error.", - "182" => "Please wait.", - "183" => "Invalid currency code.", - "187" => "Deny - new card issued.", - "188" => "Deny - Expiration date required.", - "189" => "Deny - Cancelled or Closed Merchant/SE.", - "200" => "Deny - Pick up card.", - "400" => "Reversal accepted.", - "601" => "Reject - EMV Chip Declined Transaction.", - "602" => "Reject - Suspected Fraud.", - "603" => "Reject - Communications Error.", - "604" => "Reject - Insufficient Approval.", - "750" => "Velocity Check Fail.", - "899" => "Misc Decline.", - "900" => "Invalid Message Type.", - "901" => "Invalid Merchant ID.", - "903" => "Debit not supported.", - "904" => "Private label not supported.", - "905" => "Invalid card type.", - "906" => "Unit not active.", - "908" => "Manual card entry invalid.", - "909" => "Invalid track information.", - "911" => "Master merchant not found.", - "912" => "Invalid card format.", - "913" => "Invalid card type.", - "914" => "Invalid card length.", - "917" => "Expired card.", - "919" => "Invalid entry type.", - "920" => "Invalid amount.", - "921" => "Invalid messge format.", - "923" => "Invalid ABA.", - "924" => "Invalid DDA.", - "925" => "Invalid TID.", - "926" => "Invalid Password.", - "930" => "Invalid zipcode.", - "931" => "Invalid Address.", - "932" => "Invalid ZIP and Address.", - "933" => "Invalid CVV2.", - "934" => "Program Not Allowed.", - "935" => "Invalid Device/App.", - "940" => "Record Not Found.", - "941" => "Merchant ID error.", - "942" => "Refund Not Allowed.", - "943" => "Refund denied.", - "955" => "Invalid PIN block.", - "956" => "Invalid KSN.", - "958" => "Bad Status.", - "959" => "Seek Record limit exceeded.", - "960" => "Internal Key Database Error.", - "961" => "TRANS not Supported. Cash Disbursement required a specific MCC.", - "962" => "Invalid PIN key (Unknown KSN).", - "981" => "Invalid AVS.", - "987" => "Issuer Unavailable.", - "988" => "System error SD.", - "989" => "Database Error.", - "992" => "Transaction Timeout.", - "996" => "Bad Terminal ID.", - "997" => "Message rejected by association.", - "999" => "Communication failure", - nil => "No response returned (missing credentials?)." + '000' => 'Approved.', + '001' => 'Refer to card issuer.', + '002' => 'Refer to card issuer, special condition.', + '003' => 'Invalid merchant or service provider.', + '004' => 'Pick up card.', + '005' => 'Do not honor.', + '006' => 'Error.', + '007' => 'Pick up card, special condition.', + '008' => 'Honor with ID (Show ID).', + '010' => 'Partial approval.', + '011' => 'VIP approval.', + '012' => 'Invalid transaction.', + '013' => 'Invalid amount or exceeds maximum for card program.', + '014' => 'Invalid account number (no such number).', + '015' => 'No such issuer.', + '019' => 'Re-enter Transaction.', + '021' => 'No action taken (unable to back out prior transaction).', + '025' => 'Transaction Not Found.', + '027' => 'File update field edit error.', + '028' => 'File is temporarily unavailable.', + '030' => 'Format error.', + '039' => 'No credit account.', + '041' => 'Pick up card (lost card).', + '043' => 'Pick up card (stolen card).', + '051' => 'Insufficient funds.', + '052' => 'No checking account.', + '053' => 'No savings account.', + '054' => 'Expired Card.', + '055' => 'Incorrect PIN.', + '057' => 'Transaction not permitted to cardholder.', + '058' => 'Transaction not allowed at terminal.', + '061' => 'Exceeds withdrawal limit.', + '062' => 'Restricted card (eg, Country Exclusion).', + '063' => 'Security violation.', + '065' => 'Activity count limit exceeded.', + '068' => 'Response late.', + '070' => 'Contact card issuer.', + '071' => 'PIN not changed.', + '075' => 'Allowable number of PIN-entry tries exceeded.', + '076' => 'Unable to locate previous message (no matching retrieval reference number).', + '077' => 'Repeat or reversal data are inconsistent with original message.', + '078' => 'Blocked (first use), or non-existent account.', + '079' => 'Key exchange validation failed.', + '080' => 'Credit issuer unavailable or invalid date.', + '081' => 'PIN cryptographic error found.', + '082' => 'Negative online CVV results.', + '084' => 'Invalid auth life cycle.', + '085' => 'No reason to decline - CVV or AVS approved.', + '086' => 'Cannot verify PIN.', + '087' => 'Cashback not allowed.', + '089' => 'Issuer Down.', + '091' => 'Issuer Down.', + '092' => 'Unable to route transaction.', + '093' => 'Transaction cannot be completed - violation of law.', + '094' => 'Duplicate transmission.', + '096' => 'System error.', + '100' => 'Deny.', + '101' => 'Expired Card.', + '103' => 'Deny - Invalid manual Entry 4DBC.', + '104' => 'Deny - New card issued.', + '105' => 'Deny - Account Cancelled.', + '106' => 'Exceeded PIN Attempts.', + '107' => 'Please Call Issuer.', + '109' => 'Invalid merchant.', + '110' => 'Invalid amount.', + '111' => 'Invalid account.', + '115' => 'Service not permitted.', + '117' => 'Invalid PIN.', + '119' => 'Card member not enrolled.', + '122' => 'Invalid card (CID) security code.', + '125' => 'Invalid effective date.', + '181' => 'Format error.', + '182' => 'Please wait.', + '183' => 'Invalid currency code.', + '187' => 'Deny - new card issued.', + '188' => 'Deny - Expiration date required.', + '189' => 'Deny - Cancelled or Closed Merchant/SE.', + '200' => 'Deny - Pick up card.', + '400' => 'Reversal accepted.', + '601' => 'Reject - EMV Chip Declined Transaction.', + '602' => 'Reject - Suspected Fraud.', + '603' => 'Reject - Communications Error.', + '604' => 'Reject - Insufficient Approval.', + '750' => 'Velocity Check Fail.', + '899' => 'Misc Decline.', + '900' => 'Invalid Message Type.', + '901' => 'Invalid Merchant ID.', + '903' => 'Debit not supported.', + '904' => 'Private label not supported.', + '905' => 'Invalid card type.', + '906' => 'Unit not active.', + '908' => 'Manual card entry invalid.', + '909' => 'Invalid track information.', + '911' => 'Master merchant not found.', + '912' => 'Invalid card format.', + '913' => 'Invalid card type.', + '914' => 'Invalid card length.', + '917' => 'Expired card.', + '919' => 'Invalid entry type.', + '920' => 'Invalid amount.', + '921' => 'Invalid messge format.', + '923' => 'Invalid ABA.', + '924' => 'Invalid DDA.', + '925' => 'Invalid TID.', + '926' => 'Invalid Password.', + '930' => 'Invalid zipcode.', + '931' => 'Invalid Address.', + '932' => 'Invalid ZIP and Address.', + '933' => 'Invalid CVV2.', + '934' => 'Program Not Allowed.', + '935' => 'Invalid Device/App.', + '940' => 'Record Not Found.', + '941' => 'Merchant ID error.', + '942' => 'Refund Not Allowed.', + '943' => 'Refund denied.', + '955' => 'Invalid PIN block.', + '956' => 'Invalid KSN.', + '958' => 'Bad Status.', + '959' => 'Seek Record limit exceeded.', + '960' => 'Internal Key Database Error.', + '961' => 'TRANS not Supported. Cash Disbursement required a specific MCC.', + '962' => 'Invalid PIN key (Unknown KSN).', + '981' => 'Invalid AVS.', + '987' => 'Issuer Unavailable.', + '988' => 'System error SD.', + '989' => 'Database Error.', + '992' => 'Transaction Timeout.', + '996' => 'Bad Terminal ID.', + '997' => 'Message rejected by association.', + '999' => 'Communication failure', + nil => 'No response returned (missing credentials?).' } def initialize(options = {}) @@ -162,12 +162,12 @@ def authorize(money, payment, options = {}) end def capture(money, reference, options = {}) - transaction_id, _, _, token = reference.split(";") + transaction_id, _, _, token = reference.split(';') commit(money, build_capture_request(money, transaction_id, options), token) end def void(reference, options = {}) - transaction_id, _, amount, token = reference.split(";") + transaction_id, _, amount, token = reference.split(';') commit(amount.to_i, build_void_request(amount.to_i, transaction_id, options), token) end @@ -176,7 +176,7 @@ def credit(money, payment, options = {}) end def refund(money, reference, options = {}) - transaction_id, _, _, token = reference.split(";") + transaction_id, _, _, token = reference.split(';') commit(money, build_credit_request(money, transaction_id, token, options), token) end @@ -335,7 +335,7 @@ def format_exp(value) end def success?(response) - response[:action_code] == "000" + response[:action_code] == '000' end def message_from(response) @@ -344,7 +344,7 @@ def message_from(response) def authorization_from(response, money, previous_token) original_amount = amount(money) if money - [ response[:transaction_id], response[:approval], original_amount, (response[:token] || previous_token)].join(";") + [ response[:transaction_id], response[:approval], original_amount, (response[:token] || previous_token)].join(';') end def error_code_from(response) @@ -356,7 +356,7 @@ def add_payment(xml, payment) if payment.is_a? String token = payment - _, _, _, token = payment.split(";") if payment.include? ";" + _, _, _, token = payment.split(';') if payment.include? ';' xml.tag! 'Token', token if token else add_credit_card(xml, payment) @@ -364,7 +364,7 @@ def add_payment(xml, payment) end def add_credit_card(xml, credit_card) - xml.tag! 'CardNum', credit_card.number, "CardPresent" => false, "Tokenize" => true + xml.tag! 'CardNum', credit_card.number, 'CardPresent' => false, 'Tokenize' => true xml.tag! 'CardExpMonth', format_exp(credit_card.month) xml.tag! 'CardExpYear', format_exp(credit_card.year) @@ -380,7 +380,7 @@ def add_credit_card(xml, credit_card) def add_addresses(xml, options) if billing_address = options[:billing_address] || options[:address] xml.tag! 'Billing' do - xml.tag! 'Address', [billing_address[:address1], billing_address[:address2]].compact.join(" ") + xml.tag! 'Address', [billing_address[:address1], billing_address[:address2]].compact.join(' ') xml.tag! 'City', billing_address[:city] xml.tag! 'StateProv', billing_address[:state] xml.tag! 'PostalCode', billing_address[:zip] @@ -393,7 +393,7 @@ def add_addresses(xml, options) if shipping_address = options[:shipping_address] xml.tag! 'Shipping' do xml.tag! 'Name', shipping_address[:name] - xml.tag! 'Address', [shipping_address[:address1], shipping_address[:address2]].compact.join(" ") + xml.tag! 'Address', [shipping_address[:address1], shipping_address[:address2]].compact.join(' ') xml.tag! 'City', shipping_address[:city] xml.tag! 'StateProv', shipping_address[:state] xml.tag! 'PostalCode', shipping_address[:zip] @@ -410,7 +410,7 @@ def add_customer_data(xml, options) def add_invoice_data(xml, options) xml.tag! 'OrderNumber', options[:order_id] if options[:order_id] if tax_amount = options[:tax_amount] - xml.tag! 'TaxAmount', tax_amount, {'ExemptInd' => options[:tax_exempt] || "false"} + xml.tag! 'TaxAmount', tax_amount, {'ExemptInd' => options[:tax_exempt] || 'false'} end end diff --git a/lib/active_merchant/billing/gateways/komoju.rb b/lib/active_merchant/billing/gateways/komoju.rb index f2e5f172411..8aa3fc1b636 100644 --- a/lib/active_merchant/billing/gateways/komoju.rb +++ b/lib/active_merchant/billing/gateways/komoju.rb @@ -3,8 +3,8 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class KomojuGateway < Gateway - self.test_url = "https://sandbox.komoju.com/api/v1" - self.live_url = "https://komoju.com/api/v1" + self.test_url = 'https://sandbox.komoju.com/api/v1' + self.live_url = 'https://komoju.com/api/v1' self.supported_countries = ['JP'] self.default_currency = 'JPY' self.money_format = :cents @@ -13,10 +13,10 @@ class KomojuGateway < Gateway self.supported_cardtypes = [:visa, :master, :american_express, :jcb] STANDARD_ERROR_CODE_MAPPING = { - "bad_verification_value" => "incorrect_cvc", - "card_expired" => "expired_card", - "card_declined" => "card_declined", - "invalid_number" => "invalid_number" + 'bad_verification_value' => 'incorrect_cvc', + 'card_expired' => 'expired_card', + 'card_declined' => 'card_declined', + 'invalid_number' => 'invalid_number' } def initialize(options = {}) @@ -34,7 +34,7 @@ def purchase(money, payment, options = {}) post[:tax] = options[:tax] if options[:tax] add_fraud_details(post, options) - commit("/payments", post) + commit('/payments', post) end def refund(money, identification, options = {}) @@ -82,15 +82,15 @@ def api_request(path, data) def commit(path, params) response = api_request(path, params.to_json) - success = !response.key?("error") - message = (success ? "Transaction succeeded" : response["error"]["message"]) + success = !response.key?('error') + message = (success ? 'Transaction succeeded' : response['error']['message']) Response.new( success, message, response, test: test?, - error_code: (success ? nil : error_code(response["error"]["code"])), - authorization: (success ? response["id"] : nil) + error_code: (success ? nil : error_code(response['error']['code'])), + authorization: (success ? response['id'] : nil) ) end @@ -104,10 +104,10 @@ def url def headers { - "Authorization" => "Basic " + Base64.encode64(@options[:login].to_s + ":").strip, - "Accept" => "application/json", - "Content-Type" => "application/json", - "User-Agent" => "Komoju/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}" + 'Authorization' => 'Basic ' + Base64.encode64(@options[:login].to_s + ':').strip, + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + 'User-Agent' => "Komoju/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}" } end end diff --git a/lib/active_merchant/billing/gateways/kushki.rb b/lib/active_merchant/billing/gateways/kushki.rb index 0265235cd11..14598237a74 100644 --- a/lib/active_merchant/billing/gateways/kushki.rb +++ b/lib/active_merchant/billing/gateways/kushki.rb @@ -1,14 +1,14 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class KushkiGateway < Gateway - self.display_name = "Kushki" - self.homepage_url = "https://www.kushkipagos.com" + self.display_name = 'Kushki' + self.homepage_url = 'https://www.kushkipagos.com' - self.test_url = "https://api-uat.kushkipagos.com/v1/" - self.live_url = "https://api.kushkipagos.com/v1/" + self.test_url = 'https://api-uat.kushkipagos.com/v1/' + self.live_url = 'https://api.kushkipagos.com/v1/' - self.supported_countries = ["CO", "EC"] - self.default_currency = "USD" + self.supported_countries = ['CO', 'EC'] + self.default_currency = 'USD' self.money_format = :dollars self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club] @@ -25,7 +25,7 @@ def purchase(amount, payment_method, options={}) end def refund(amount, authorization, options={}) - action = "refund" + action = 'refund' post = {} post[:ticketNumber] = authorization @@ -34,7 +34,7 @@ def refund(amount, authorization, options={}) end def void(authorization, options={}) - action = "void" + action = 'void' post = {} post[:ticketNumber] = authorization @@ -56,7 +56,7 @@ def scrub(transcript) private def tokenize(amount, payment_method, options) - action = "tokenize" + action = 'tokenize' post = {} add_invoice(action, post, amount, options) @@ -66,7 +66,7 @@ def tokenize(amount, payment_method, options) end def charge(amount, authorization, options) - action = "charge" + action = 'charge' post = {} add_reference(post, authorization, options) @@ -76,7 +76,7 @@ def charge(amount, authorization, options) end def add_invoice(action, post, money, options) - if action == "tokenize" + if action == 'tokenize' post[:totalAmount] = amount(money).to_f post[:currency] = options[:currency] || currency(money) post[:isDeferred] = false @@ -94,7 +94,7 @@ def add_amount_defaults(sum, money, options) sum[:iva] = 0 sum[:subtotalIva0] = 0 - if sum[:currency] != "COP" + if sum[:currency] != 'COP' sum[:ice] = 0 end end @@ -105,7 +105,7 @@ def add_amount_by_country(sum, options) sum[:iva] = amount[:iva].to_f if amount[:iva] sum[:subtotalIva0] = amount[:subtotal_iva_0].to_f if amount[:subtotal_iva_0] sum[:ice] = amount[:ice].to_f if amount[:ice] - if (extra_taxes = amount[:extra_taxes]) && sum[:currency] == "COP" + if (extra_taxes = amount[:extra_taxes]) && sum[:currency] == 'COP' sum[:extraTaxes] ||= Hash.new sum[:extraTaxes][:propina] = extra_taxes[:propina].to_f if extra_taxes[:propina] sum[:extraTaxes][:tasaAeroportuaria] = extra_taxes[:tasa_aeroportuaria].to_f if extra_taxes[:tasa_aeroportuaria] @@ -130,10 +130,10 @@ def add_reference(post, authorization, options) end ENDPOINT = { - "tokenize" => "tokens", - "charge" => "charges", - "void" => "charges", - "refund" => "refund" + 'tokenize' => 'tokens', + 'charge' => 'charges', + 'void' => 'charges', + 'refund' => 'refund' } def commit(action, params) @@ -156,7 +156,7 @@ def commit(action, params) end def ssl_invoke(action, params) - if ["void", "refund"].include?(action) + if ['void', 'refund'].include?(action) ssl_request(:delete, url(action, params), nil, headers(action)) else ssl_post(url(action, params), post_data(params), headers(action)) @@ -165,9 +165,9 @@ def ssl_invoke(action, params) def headers(action) hfields = {} - hfields["Public-Merchant-Id"] = @options[:public_merchant_id] if action == "tokenize" - hfields["Private-Merchant-Id"] = @options[:private_merchant_id] unless action == "tokenize" - hfields["Content-Type"] = "application/json" + hfields['Public-Merchant-Id'] = @options[:public_merchant_id] if action == 'tokenize' + hfields['Private-Merchant-Id'] = @options[:private_merchant_id] unless action == 'tokenize' + hfields['Content-Type'] = 'application/json' hfields end @@ -178,8 +178,8 @@ def post_data(params) def url(action, params) base_url = test? ? test_url : live_url - if ["void", "refund"].include?(action) - base_url + ENDPOINT[action] + "/" + params[:ticketNumber].to_s + if ['void', 'refund'].include?(action) + base_url + ENDPOINT[action] + '/' + params[:ticketNumber].to_s else base_url + ENDPOINT[action] end @@ -189,32 +189,32 @@ def parse(body) begin JSON.parse(body) rescue JSON::ParserError - message = "Invalid JSON response received from KushkiGateway. Please contact KushkiGateway if you continue to receive this message." + message = 'Invalid JSON response received from KushkiGateway. Please contact KushkiGateway if you continue to receive this message.' message += " (The raw response returned by the API was #{body.inspect})" { - "message" => message + 'message' => message } end end def success_from(response) - return true if response["token"] || response["ticketNumber"] || response["code"] == "K000" + return true if response['token'] || response['ticketNumber'] || response['code'] == 'K000' end def message_from(succeeded, response) if succeeded - "Succeeded" + 'Succeeded' else - response["message"] + response['message'] end end def authorization_from(response) - response["token"] || response["ticketNumber"] + response['token'] || response['ticketNumber'] end def error_from(response) - response["code"] + response['code'] end end end diff --git a/lib/active_merchant/billing/gateways/latitude19.rb b/lib/active_merchant/billing/gateways/latitude19.rb index b7daf2a2f7d..b380d1a1c17 100644 --- a/lib/active_merchant/billing/gateways/latitude19.rb +++ b/lib/active_merchant/billing/gateways/latitude19.rb @@ -1,14 +1,14 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class Latitude19Gateway < Gateway - self.display_name = "Latitude19 Gateway" - self.homepage_url = "http://www.l19tech.com" + self.display_name = 'Latitude19 Gateway' + self.homepage_url = 'http://www.l19tech.com' - self.live_url = "https://gateway.l19tech.com/payments/" - self.test_url = "https://gateway-sb.l19tech.com/payments/" + self.live_url = 'https://gateway.l19tech.com/payments/' + self.test_url = 'https://gateway-sb.l19tech.com/payments/' - self.supported_countries = ["US", "CA"] - self.default_currency = "USD" + self.supported_countries = ['US', 'CA'] + self.default_currency = 'USD' self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb] @@ -43,12 +43,12 @@ class Latitude19Gateway < Gateway } BRAND_MAP = { - "master" => "MC", - "visa" => "VI", - "american_express" => "AX", - "discover" => "DS", - "diners_club" => "DC", - "jcb" => "JC" + 'master' => 'MC', + 'visa' => 'VI', + 'american_express' => 'AX', + 'discover' => 'DS', + 'diners_club' => 'DC', + 'jcb' => 'JC' } def initialize(options={}) @@ -58,31 +58,31 @@ def initialize(options={}) def purchase(amount, payment_method, options={}) if payment_method.is_a?(String) - auth_or_sale("sale", payment_method, amount, nil, options) + auth_or_sale('sale', payment_method, amount, nil, options) else MultiResponse.run() do |r| r.process { get_session(options) } r.process { get_token(r.authorization, payment_method, options) } - r.process { auth_or_sale("sale", r.authorization, amount, payment_method, options) } + r.process { auth_or_sale('sale', r.authorization, amount, payment_method, options) } end end end def authorize(amount, payment_method, options={}) if payment_method.is_a?(String) - auth_or_sale("auth", payment_method, amount, nil, options) + auth_or_sale('auth', payment_method, amount, nil, options) else MultiResponse.run() do |r| r.process { get_session(options) } r.process { get_token(r.authorization, payment_method, options) } - r.process { auth_or_sale("auth", r.authorization, amount, payment_method, options) } + r.process { auth_or_sale('auth', r.authorization, amount, payment_method, options) } end end end def capture(amount, authorization, options={}) post = {} - post[:method] = "deposit" + post[:method] = 'deposit' add_request_id(post) params = {} @@ -93,18 +93,18 @@ def capture(amount, authorization, options={}) add_credentials(params, post[:method]) post[:params] = [params] - commit("v1/", post) + commit('v1/', post) end def void(authorization, options={}) method, pgwTID = split_authorization(authorization) case method - when "auth" - reverse_or_void("reversal", pgwTID, options) - when "deposit", "sale" - reverse_or_void("void", pgwTID, options) + when 'auth' + reverse_or_void('reversal', pgwTID, options) + when 'deposit', 'sale' + reverse_or_void('void', pgwTID, options) else - message = "Unsupported operation: successful Purchase, Authorize and unsettled Capture transactions can only be voided." + message = 'Unsupported operation: successful Purchase, Authorize and unsettled Capture transactions can only be voided.' return Response.new(false, message) end end @@ -134,7 +134,7 @@ def verify(payment_method, options={}, action=nil) end def store(payment_method, options={}) - verify(payment_method, options, "store") + verify(payment_method, options, 'store') end def supports_scrubbing? @@ -155,14 +155,14 @@ def add_request_id(post) end def add_timestamp() - Time.now.getutc.strftime("%Y%m%d%H%M%S") + Time.now.getutc.strftime('%Y%m%d%H%M%S') end def add_hmac(params, method) - if method == "getSession" - hmac_message = params[:pgwAccountNumber] + "|" + params[:pgwConfigurationId] + "|" + params[:requestTimeStamp] + "|" + method + if method == 'getSession' + hmac_message = params[:pgwAccountNumber] + '|' + params[:pgwConfigurationId] + '|' + params[:requestTimeStamp] + '|' + method else - hmac_message = params[:pgwAccountNumber] + "|" + params[:pgwConfigurationId] + "|" + (params[:orderNumber] || "") + "|" + method + "|" + (params[:amount] || "") + "|" + (params[:sessionToken] || "") + "|" + (params[:accountToken] || "") + hmac_message = params[:pgwAccountNumber] + '|' + params[:pgwConfigurationId] + '|' + (params[:orderNumber] || '') + '|' + method + '|' + (params[:amount] || '') + '|' + (params[:sessionToken] || '') + '|' + (params[:accountToken] || '') end OpenSSL::HMAC.hexdigest('sha512', @options[:secret], hmac_message) @@ -172,7 +172,7 @@ def add_credentials(params, method) params[:pgwAccountNumber] = @options[:account_number] params[:pgwConfigurationId] = @options[:configuration_id] - params[:requestTimeStamp] = add_timestamp() if method == "getSession" + params[:requestTimeStamp] = add_timestamp() if method == 'getSession' params[:pgwHMAC] = add_hmac(params, method) end @@ -180,11 +180,11 @@ def add_credentials(params, method) def add_invoice(params, money, options) params[:amount] = amount(money) params[:orderNumber] = options[:order_id] - params[:transactionClass] = options[:transaction_class] || "eCommerce" + params[:transactionClass] = options[:transaction_class] || 'eCommerce' end def add_payment_method(params, credit_card) - params[:cardExp] = format(credit_card.month, :two_digits).to_s + "/" + format(credit_card.year, :two_digits).to_s + params[:cardExp] = format(credit_card.month, :two_digits).to_s + '/' + format(credit_card.year, :two_digits).to_s params[:cardType] = BRAND_MAP[credit_card.brand.to_s] params[:cvv] = credit_card.verification_value params[:firstName] = credit_card.first_name @@ -204,19 +204,19 @@ def add_customer_data(params, options) def get_session(options={}) post = {} - post[:method] = "getSession" + post[:method] = 'getSession' add_request_id(post) params = {} add_credentials(params, post[:method]) post[:params] = [params] - commit("session", post) + commit('session', post) end def get_token(authorization, payment_method, options={}) post = {} - post[:method] = "tokenize" + post[:method] = 'tokenize' add_request_id(post) params = {} @@ -224,7 +224,7 @@ def get_token(authorization, payment_method, options={}) params[:cardNumber] = payment_method.number post[:params] = [params] - commit("token", post) + commit('token', post) end def auth_or_sale(method, authorization, amount, credit_card, options={}) @@ -244,12 +244,12 @@ def auth_or_sale(method, authorization, amount, credit_card, options={}) add_credentials(params, post[:method]) post[:params] = [params] - commit("v1/", post) + commit('v1/', post) end def verifyOnly(action, authorization, credit_card, options={}) post = {} - post[:method] = "verifyOnly" + post[:method] = 'verifyOnly' add_request_id(post) params = {} @@ -260,17 +260,17 @@ def verifyOnly(action, authorization, credit_card, options={}) else _, params[:accountToken] = split_authorization(authorization) end - params[:requestAccountToken] = "1" if action == "store" + params[:requestAccountToken] = '1' if action == 'store' add_invoice(params, 0, options) add_credentials(params, post[:method]) post[:params] = [params] - commit("v1/", post) + commit('v1/', post) end def refundWithCard(authorization, amount, credit_card, options={}) post = {} - post[:method] = "refundWithCard" + post[:method] = 'refundWithCard' add_request_id(post) params = {} @@ -284,7 +284,7 @@ def refundWithCard(authorization, amount, credit_card, options={}) add_credentials(params, post[:method]) post[:params] = [params] - commit("v1/", post) + commit('v1/', post) end def reverse_or_void(method, pgwTID, options={}) @@ -298,7 +298,7 @@ def reverse_or_void(method, pgwTID, options={}) add_credentials(params, post[:method]) post[:params] = [params] - commit("v1/", post) + commit('v1/', post) end def commit(endpoint, post) @@ -327,7 +327,7 @@ def commit(endpoint, post) def headers { - "Content-Type" => "application/json" + 'Content-Type' => 'application/json' } end @@ -344,51 +344,51 @@ def parse(body) end def success_from(response) - return false if response["result"].nil? || response["error"] + return false if response['result'].nil? || response['error'] - if response["result"].key?("pgwResponseCode") - response["error"].nil? && response["result"]["lastActionSucceeded"] == 1 && response["result"]["pgwResponseCode"] == "100" + if response['result'].key?('pgwResponseCode') + response['error'].nil? && response['result']['lastActionSucceeded'] == 1 && response['result']['pgwResponseCode'] == '100' else - response["error"].nil? && response["result"]["lastActionSucceeded"] == 1 + response['error'].nil? && response['result']['lastActionSucceeded'] == 1 end end def message_from(response) - return response["error"] if response["error"] - return "Failed" unless response.key?("result") + return response['error'] if response['error'] + return 'Failed' unless response.key?('result') - if response["result"].key?("pgwResponseCode") - RESPONSE_CODE_MAPPING[response["result"]["pgwResponseCode"]] || response["result"]["responseText"] + if response['result'].key?('pgwResponseCode') + RESPONSE_CODE_MAPPING[response['result']['pgwResponseCode']] || response['result']['responseText'] else - response["result"]["lastActionSucceeded"] == 1 ? "Succeeded" : "Failed" + response['result']['lastActionSucceeded'] == 1 ? 'Succeeded' : 'Failed' end end def error_from(response) - return response["error"] if response["error"] - return "Failed" unless response.key?("result") - return response["result"]["pgwResponseCode"] || response["result"]["processor"]["responseCode"] || "Failed" + return response['error'] if response['error'] + return 'Failed' unless response.key?('result') + return response['result']['pgwResponseCode'] || response['result']['processor']['responseCode'] || 'Failed' end def authorization_from(response, method) - method + "|" + ( - response["result"]["sessionId"] || - response["result"]["sessionToken"] || - response["result"]["pgwTID"] || - response["result"]["accountToken"] + method + '|' + ( + response['result']['sessionId'] || + response['result']['sessionToken'] || + response['result']['pgwTID'] || + response['result']['accountToken'] ) end def split_authorization(authorization) - authorization.split("|") + authorization.split('|') end def avs_from(response) - response["result"].key?("avsResponse") ? AVSResult.new(code: response["result"]["avsResponse"]) : nil + response['result'].key?('avsResponse') ? AVSResult.new(code: response['result']['avsResponse']) : nil end def cvv_from(response) - response["result"].key?("cvvResponse") ? CVVResult.new(response["result"]["cvvResponse"]) : nil + response['result'].key?('cvvResponse') ? CVVResult.new(response['result']['cvvResponse']) : nil end def response_error(raw_response) @@ -407,7 +407,7 @@ def response_error(raw_response) end def unparsable_response(raw_response) - message = "Invalid JSON response received from Latitude19Gateway. Please contact Latitude19Gateway if you continue to receive this message." + message = 'Invalid JSON response received from Latitude19Gateway. Please contact Latitude19Gateway if you continue to receive this message.' message += " (The raw response returned by the API was #{raw_response.inspect})" return Response.new(false, message) end diff --git a/lib/active_merchant/billing/gateways/linkpoint.rb b/lib/active_merchant/billing/gateways/linkpoint.rb index 653cd8e3946..9c63d503254 100644 --- a/lib/active_merchant/billing/gateways/linkpoint.rb +++ b/lib/active_merchant/billing/gateways/linkpoint.rb @@ -173,11 +173,11 @@ def recurring(money, creditcard, options={}) requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily], :installments, :order_id ) options.update( - :ordertype => "SALE", - :action => options[:action] || "SUBMIT", + :ordertype => 'SALE', + :action => options[:action] || 'SUBMIT', :installments => options[:installments] || 12, - :startdate => options[:startdate] || "immediate", - :periodicity => options[:periodicity].to_s || "monthly", + :startdate => options[:startdate] || 'immediate', + :periodicity => options[:periodicity].to_s || 'monthly', :comments => options[:comments] || nil, :threshold => options[:threshold] || 3 ) @@ -188,7 +188,7 @@ def recurring(money, creditcard, options={}) def purchase(money, creditcard, options={}) requires!(options, :order_id) options.update( - :ordertype => "SALE" + :ordertype => 'SALE' ) commit(money, creditcard, options) end @@ -201,7 +201,7 @@ def purchase(money, creditcard, options={}) def authorize(money, creditcard, options = {}) requires!(options, :order_id) options.update( - :ordertype => "PREAUTH" + :ordertype => 'PREAUTH' ) commit(money, creditcard, options) end @@ -215,7 +215,7 @@ def authorize(money, creditcard, options = {}) def capture(money, authorization, options = {}) options.update( :order_id => authorization, - :ordertype => "POSTAUTH" + :ordertype => 'POSTAUTH' ) commit(money, nil, options) end @@ -224,7 +224,7 @@ def capture(money, authorization, options = {}) def void(identification, options = {}) options.update( :order_id => identification, - :ordertype => "VOID" + :ordertype => 'VOID' ) commit(nil, nil, options) end @@ -236,7 +236,7 @@ def void(identification, options = {}) # def refund(money, identification, options = {}) options.update( - :ordertype => "CREDIT", + :ordertype => 'CREDIT', :order_id => identification ) commit(money, nil, options) @@ -272,7 +272,7 @@ def commit(money, creditcard, options = {}) end def successful?(response) - response[:approved] == "APPROVED" + response[:approved] == 'APPROVED' end # Build the XML file @@ -280,11 +280,11 @@ def post_data(money, creditcard, options) params = parameters(money, creditcard, options) xml = REXML::Document.new - order = xml.add_element("order") + order = xml.add_element('order') # Merchant Info - merchantinfo = order.add_element("merchantinfo") - merchantinfo.add_element("configfile").text = @options[:login] + merchantinfo = order.add_element('merchantinfo') + merchantinfo.add_element('configfile').text = @options[:login] # Loop over the params hash to construct the XML string for key, value in params @@ -305,14 +305,14 @@ def post_data(money, creditcard, options) # adds LinkPoint's Items entity to the XML. Called from post_data def build_items(element, items) for item in items - item_element = element.add_element("item") + item_element = element.add_element('item') for key, value in item if key == :options - options_element = item_element.add_element("options") + options_element = item_element.add_element('options') for option in value - opt_element = options_element.add_element("option") - opt_element.add_element("name").text = option[:name] unless option[:name].blank? - opt_element.add_element("value").text = option[:value] unless option[:value].blank? + opt_element = options_element.add_element('option') + opt_element.add_element('name').text = option[:name] unless option[:name].blank? + opt_element.add_element('value').text = option[:value] unless option[:value].blank? end else item_element.add_element(key.to_s).text = item[key].to_s unless item[key].blank? @@ -334,14 +334,14 @@ def parameters(money, creditcard, options = {}) :chargetotal => amount(money) }, :transactiondetails => { - :transactionorigin => options[:transactionorigin] || "ECI", + :transactionorigin => options[:transactionorigin] || 'ECI', :oid => options[:order_id], :ponumber => options[:ponumber], :taxexempt => options[:taxexempt], :terminaltype => options[:terminaltype], :ip => options[:ip], :reference_number => options[:reference_number], - :recurring => options[:recurring] || "NO", #DO NOT USE if you are using the periodic billing option. + :recurring => options[:recurring] || 'NO', #DO NOT USE if you are using the periodic billing option. :tdate => options[:tdate] }, :orderoptions => { @@ -433,7 +433,7 @@ def parse(xml) # <r_approved>APPROVED</r_approved> # <r_avs></r_avs> - response = {:message => "Global Error Receipt", :complete => false} + response = {:message => 'Global Error Receipt', :complete => false} xml = REXML::Document.new("<response>#{xml}</response>") xml.root.elements.each do |node| @@ -444,7 +444,7 @@ def parse(xml) end def format_creditcard_expiry_year(year) - sprintf("%.4i", year)[-2..-1] + sprintf('%.4i', year)[-2..-1] end end end diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index a4dfdd8dc03..e702dc297ed 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -376,7 +376,7 @@ def parse(kind, xml) if parsed.empty? %w(response message).each do |attribute| - parsed[attribute.to_sym] = doc.xpath("//litleOnlineResponse").attribute(attribute).value + parsed[attribute.to_sym] = doc.xpath('//litleOnlineResponse').attribute(attribute).value end end @@ -423,7 +423,7 @@ def root_attributes { merchantId: @options[:merchant_id], version: SCHEMA_VERSION, - xmlns: "http://www.litle.com/schema" + xmlns: 'http://www.litle.com/schema' } end diff --git a/lib/active_merchant/billing/gateways/mastercard.rb b/lib/active_merchant/billing/gateways/mastercard.rb index ecec06dcff8..d15bb6cbfc6 100644 --- a/lib/active_merchant/billing/gateways/mastercard.rb +++ b/lib/active_merchant/billing/gateways/mastercard.rb @@ -59,7 +59,7 @@ def verify(credit_card, options={}) end def verify_credentials - url = build_url(SecureRandom.uuid, "nonexistent") + url = build_url(SecureRandom.uuid, 'nonexistent') begin ssl_get(url, headers) rescue ResponseError => e @@ -164,7 +164,7 @@ def add_customer_data(post, payment_method, options) def add_3dsecure_id(post, options) return unless options[:threed_secure_id] - post.merge!({"3DSecureId" => options[:threed_secure_id]}) + post.merge!({'3DSecureId' => options[:threed_secure_id]}) end def country_code(country) @@ -221,7 +221,7 @@ def parse(body) end def success_from(response) - response['result'] == "SUCCESS" + response['result'] == 'SUCCESS' end def message_from(succeeded, response) diff --git a/lib/active_merchant/billing/gateways/maxipago.rb b/lib/active_merchant/billing/gateways/maxipago.rb index 69ae9a8bd9f..d029d261b93 100644 --- a/lib/active_merchant/billing/gateways/maxipago.rb +++ b/lib/active_merchant/billing/gateways/maxipago.rb @@ -98,7 +98,7 @@ def url def build_xml_request(action) builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') - builder.send("transaction-request") do |xml| + builder.send('transaction-request') do |xml| xml.version '3.1.1.15' xml.verification do xml.merchantId @options[:login] @@ -127,7 +127,7 @@ def authorization_from(response) end def split_authorization(authorization) - authorization.split("|") + authorization.split('|') end def parse(body) diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index c7262d47bfd..ad5f4a555d8 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -11,8 +11,8 @@ class MercadoPagoGateway < Gateway self.money_format = :dollars CARD_BRAND = { - "american_express" => "amex", - "diners_club" => "diners" + 'american_express' => 'amex', + 'diners_club' => 'diners' } def initialize(options={}) @@ -22,41 +22,41 @@ def initialize(options={}) def purchase(money, payment, options={}) MultiResponse.run do |r| - r.process { commit("tokenize", "card_tokens", card_token_request(money, payment, options)) } + r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) } options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand)) - options.merge!(card_token: r.authorization.split("|").first) - r.process { commit("purchase", "payments", purchase_request(money, payment, options) ) } + options.merge!(card_token: r.authorization.split('|').first) + r.process { commit('purchase', 'payments', purchase_request(money, payment, options) ) } end end def authorize(money, payment, options={}) MultiResponse.run do |r| - r.process { commit("tokenize", "card_tokens", card_token_request(money, payment, options)) } + r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) } options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand)) - options.merge!(card_token: r.authorization.split("|").first) - r.process { commit("authorize", "payments", authorize_request(money, payment, options) ) } + options.merge!(card_token: r.authorization.split('|').first) + r.process { commit('authorize', 'payments', authorize_request(money, payment, options) ) } end end def capture(money, authorization, options={}) post = {} - authorization, _ = authorization.split("|") + authorization, _ = authorization.split('|') post[:capture] = true post[:transaction_amount] = amount(money).to_f - commit("capture", "payments/#{authorization}", post) + commit('capture', "payments/#{authorization}", post) end def refund(money, authorization, options={}) post = {} - authorization, original_amount = authorization.split("|") + authorization, original_amount = authorization.split('|') post[:amount] = amount(money).to_f if original_amount && original_amount.to_f > amount(money).to_f - commit("refund", "payments/#{authorization}/refunds", post) + commit('refund', "payments/#{authorization}/refunds", post) end def void(authorization, options={}) - authorization, _ = authorization.split("|") - post = { status: "cancelled" } - commit("void", "payments/#{authorization}", post) + authorization, _ = authorization.split('|') + post = { status: 'cancelled' } + commit('void', "payments/#{authorization}", post) end def verify(credit_card, options={}) @@ -161,10 +161,10 @@ def add_shipping_address(post, options) end def split_street_address(address1) - street_number = address1.split(" ").first + street_number = address1.split(' ').first - if street_name = address1.split(" ")[1..-1] - street_name = street_name.join(" ") + if street_name = address1.split(' ')[1..-1] + street_name = street_name.join(' ') else nil end @@ -190,7 +190,7 @@ def parse(body) end def commit(action, path, parameters) - if ["capture", "void"].include?(action) + if ['capture', 'void'].include?(action) response = parse(ssl_request(:put, url(path), post_data(parameters), headers)) else response = parse(ssl_post(url(path), post_data(parameters), headers(parameters))) @@ -207,19 +207,19 @@ def commit(action, path, parameters) end def success_from(action, response) - if action == "refund" - response["error"].nil? + if action == 'refund' + response['error'].nil? else - ["active", "approved", "authorized", "cancelled", "in_process"].include?(response["status"]) + ['active', 'approved', 'authorized', 'cancelled', 'in_process'].include?(response['status']) end end def message_from(response) - (response["status_detail"]) || (response["message"]) + (response['status_detail']) || (response['message']) end def authorization_from(response, params) - [response["id"], params[:transaction_amount]].join("|") + [response['id'], params[:transaction_amount]].join('|') end def post_data(parameters = {}) @@ -228,10 +228,10 @@ def post_data(parameters = {}) def error_code_from(action, response) unless success_from(action, response) - if cause = response["cause"] - cause.empty? ? nil : cause.first["code"] + if cause = response['cause'] + cause.empty? ? nil : cause.first['code'] else - response["status"] + response['status'] end end end @@ -243,7 +243,7 @@ def url(action) def headers(options = {}) headers = { - "Content-Type" => "application/json" + 'Content-Type' => 'application/json' } headers['X-Device-Session-ID'] = options[:device_id] if options[:device_id] headers diff --git a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb index 8a855661cbe..8af50c307e6 100644 --- a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +++ b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb @@ -162,22 +162,22 @@ def commit(action, money, parameters) response = begin parse( ssl_post(url, post_data(action,parameters)) ) rescue ActiveMerchant::ResponseError => e - { "error_code" => "404", "auth_response_text" => e.to_s } + { 'error_code' => '404', 'auth_response_text' => e.to_s } end - Response.new(response["error_code"] == "000", message_from(response), response, - :authorization => response["transaction_id"], + Response.new(response['error_code'] == '000', message_from(response), response, + :authorization => response['transaction_id'], :test => test?, - :cvv_result => response["cvv2_result"], - :avs_result => { :code => response["avs_result"] } + :cvv_result => response['cvv2_result'], + :avs_result => { :code => response['avs_result'] } ) end def message_from(response) - if response["error_code"] == "000" - "This transaction has been approved" + if response['error_code'] == '000' + 'This transaction has been approved' else - response["auth_response_text"] + response['auth_response_text'] end end @@ -187,7 +187,7 @@ def post_data(action, parameters = {}) post[:profile_key] = @options[:password] post[:transaction_type] = action if action - request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&") + request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') request end end diff --git a/lib/active_merchant/billing/gateways/merchant_one.rb b/lib/active_merchant/billing/gateways/merchant_one.rb index 3d5cb0558e0..1a2c457fec5 100644 --- a/lib/active_merchant/billing/gateways/merchant_one.rb +++ b/lib/active_merchant/billing/gateways/merchant_one.rb @@ -1,4 +1,4 @@ -require "cgi" +require 'cgi' module ActiveMerchant #:nodoc: module Billing #:nodoc: @@ -88,11 +88,11 @@ def commit(action, money, parameters={}) def post_data(action, parameters = {}) parameters.merge!({:type => action}) - ret = "" + ret = '' for key in parameters.keys ret += "#{key}=#{CGI.escape(parameters[key].to_s)}" if key != parameters.keys.last - ret += "&" + ret += '&' end end ret.to_s @@ -101,11 +101,11 @@ def post_data(action, parameters = {}) def parse(data) responses = CGI.parse(data).inject({}){|h,(k, v)| h[k] = v.first; h} Response.new( - (responses["response"].to_i == 1), - responses["responsetext"], + (responses['response'].to_i == 1), + responses['responsetext'], responses, :test => test?, - :authorization => responses["transactionid"] + :authorization => responses['transactionid'] ) end end diff --git a/lib/active_merchant/billing/gateways/merchant_partners.rb b/lib/active_merchant/billing/gateways/merchant_partners.rb index 9c5c407d3b1..3af4a301cdf 100644 --- a/lib/active_merchant/billing/gateways/merchant_partners.rb +++ b/lib/active_merchant/billing/gateways/merchant_partners.rb @@ -3,13 +3,13 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class MerchantPartnersGateway < Gateway - self.display_name = "Merchant Partners" - self.homepage_url = "http://www.merchantpartners.com/" + self.display_name = 'Merchant Partners' + self.homepage_url = 'http://www.merchantpartners.com/' - self.live_url = "https://trans.merchantpartners.com/cgi-bin/ProcessXML.cgi" + self.live_url = 'https://trans.merchantpartners.com/cgi-bin/ProcessXML.cgi' - self.supported_countries = ["US"] - self.default_currency = "USD" + self.supported_countries = ['US'] + self.default_currency = 'USD' self.money_format = :dollars self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb] @@ -143,19 +143,19 @@ def add_reference(post, authorization) end ACTIONS = { - purchase: "2", - authorize: "1", - capture: "3", - void: "5", - refund: "4", - credit: "6", - store: "7", - stored_purchase: "8", - stored_credit: "13" + purchase: '2', + authorize: '1', + capture: '3', + void: '5', + refund: '4', + credit: '6', + store: '7', + stored_purchase: '8', + stored_credit: '13' } STORE_TX_TYPES = { - store_only: "3" + store_only: '3' } def commit(action, post) @@ -172,15 +172,15 @@ def commit(action, post) message_from(succeeded, response_data), response_data, authorization: authorization_from(post, response_data), - :avs_result => AVSResult.new(code: response_data["avs_response"]), - :cvv_result => CVVResult.new(response_data["cvv2_response"]), + :avs_result => AVSResult.new(code: response_data['avs_response']), + :cvv_result => CVVResult.new(response_data['cvv2_response']), test: test? ) end def headers { - "Content-Type" => "application/xml" + 'Content-Type' => 'application/xml' } end @@ -188,7 +188,7 @@ def build_request(post) Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml| xml.interface_driver { xml.trans_catalog { - xml.transaction(name: "creditcard") { + xml.transaction(name: 'creditcard') { xml.inputs { post.each do |field, value| xml.send(field, value) @@ -202,7 +202,7 @@ def build_request(post) def parse(body) response = {} - Nokogiri::XML(CGI.unescapeHTML(body)).xpath("//trans_catalog/transaction/outputs").children.each do |node| + Nokogiri::XML(CGI.unescapeHTML(body)).xpath('//trans_catalog/transaction/outputs').children.each do |node| parse_element(response, node) end response @@ -217,11 +217,11 @@ def parse_element(response, node) end def success_from(response) - response[:status] == "Approved" + response[:status] == 'Approved' end def message_from(succeeded, response) - succeeded ? "Succeeded" : error_message_from(response) + succeeded ? 'Succeeded' : error_message_from(response) end def authorization_from(request, response) @@ -231,11 +231,11 @@ def authorization_from(request, response) end def split_authorization(authorization) - authorization.split("|") + authorization.split('|') end def error_message_from(response) - if(response[:status] == "Declined") + if(response[:status] == 'Declined') match = response[:result].match(/DECLINED:\d{10}:(.+):/) match[1] if match end diff --git a/lib/active_merchant/billing/gateways/merchant_ware.rb b/lib/active_merchant/billing/gateways/merchant_ware.rb index 47d596b3343..3b8d4a20b0e 100644 --- a/lib/active_merchant/billing/gateways/merchant_ware.rb +++ b/lib/active_merchant/billing/gateways/merchant_ware.rb @@ -11,25 +11,25 @@ class MerchantWareGateway < Gateway self.homepage_url = 'http://merchantwarehouse.com/merchantware' self.display_name = 'MerchantWARE' - ENV_NAMESPACES = { "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", - "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema", - "xmlns:env" => "http://schemas.xmlsoap.org/soap/envelope/" + ENV_NAMESPACES = { 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', + 'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/' } - ENV_NAMESPACES_V4 = { "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", - "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema", - "xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/" + ENV_NAMESPACES_V4 = { 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', + 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' } - TX_NAMESPACE = "http://merchantwarehouse.com/MerchantWARE/Client/TransactionRetail" - TX_NAMESPACE_V4 = "http://schemas.merchantwarehouse.com/merchantware/40/Credit/" + TX_NAMESPACE = 'http://merchantwarehouse.com/MerchantWARE/Client/TransactionRetail' + TX_NAMESPACE_V4 = 'http://schemas.merchantwarehouse.com/merchantware/40/Credit/' ACTIONS = { - :purchase => "IssueKeyedSale", - :authorize => "IssueKeyedPreAuth", - :capture => "IssuePostAuth", - :void => "VoidPreAuthorization", - :credit => "IssueKeyedRefund", - :reference_credit => "IssueRefundByReference" + :purchase => 'IssueKeyedSale', + :authorize => 'IssueKeyedPreAuth', + :capture => 'IssuePostAuth', + :void => 'VoidPreAuthorization', + :credit => 'IssueKeyedRefund', + :reference_credit => 'IssueRefundByReference' } # Creates a new MerchantWareGateway @@ -121,9 +121,9 @@ def refund(money, reference, options = {}) def soap_request(action) xml = Builder::XmlMarkup.new :indent => 2 xml.instruct! - xml.tag! "env:Envelope", ENV_NAMESPACES do - xml.tag! "env:Body" do - xml.tag! ACTIONS[action], "xmlns" => TX_NAMESPACE do + xml.tag! 'env:Envelope', ENV_NAMESPACES do + xml.tag! 'env:Body' do + xml.tag! ACTIONS[action], 'xmlns' => TX_NAMESPACE do add_credentials(xml) yield xml end @@ -135,12 +135,12 @@ def soap_request(action) def v4_soap_request(action) xml = Builder::XmlMarkup.new :indent => 2 xml.instruct! - xml.tag! "soap:Envelope", ENV_NAMESPACES_V4 do - xml.tag! "soap:Body" do - xml.tag! ACTIONS[:void], "xmlns" => TX_NAMESPACE_V4 do - xml.tag! "merchantName", @options[:name] - xml.tag! "merchantSiteId", @options[:login] - xml.tag! "merchantKey", @options[:password] + xml.tag! 'soap:Envelope', ENV_NAMESPACES_V4 do + xml.tag! 'soap:Body' do + xml.tag! ACTIONS[:void], 'xmlns' => TX_NAMESPACE_V4 do + xml.tag! 'merchantName', @options[:name] + xml.tag! 'merchantSiteId', @options[:login] + xml.tag! 'merchantKey', @options[:password] yield xml end end @@ -175,7 +175,7 @@ def perform_reference_credit(money, identification, options) request = soap_request(:reference_credit) do |xml| add_reference(xml, reference) add_invoice(xml, options) - add_amount(xml, money, "strOverrideAmount") + add_amount(xml, money, 'strOverrideAmount') end commit(:reference_credit, request) @@ -194,47 +194,47 @@ def perform_credit(money, credit_card, options) end def add_credentials(xml) - xml.tag! "strSiteId", @options[:login] - xml.tag! "strKey", @options[:password] - xml.tag! "strName", @options[:name] + xml.tag! 'strSiteId', @options[:login] + xml.tag! 'strKey', @options[:password] + xml.tag! 'strName', @options[:name] end def add_invoice(xml, options) - xml.tag! "strOrderNumber", options[:order_id].to_s.gsub(/[^\w]/, '').slice(0, 25) + xml.tag! 'strOrderNumber', options[:order_id].to_s.gsub(/[^\w]/, '').slice(0, 25) end - def add_amount(xml, money, tag = "strAmount") + def add_amount(xml, money, tag = 'strAmount') xml.tag! tag, amount(money) end def add_reference(xml, reference) - xml.tag! "strReferenceCode", reference + xml.tag! 'strReferenceCode', reference end def add_reference_token(xml, reference) - xml.tag! "token", reference + xml.tag! 'token', reference end def add_address(xml, options) if address = options[:billing_address] || options[:address] - xml.tag! "strAVSStreetAddress", address[:address1] - xml.tag! "strAVSZipCode", address[:zip] + xml.tag! 'strAVSStreetAddress', address[:address1] + xml.tag! 'strAVSZipCode', address[:zip] end end def add_credit_card(xml, credit_card) if credit_card.respond_to?(:track_data) && credit_card.track_data.present? - xml.tag! "trackData", credit_card.track_data + xml.tag! 'trackData', credit_card.track_data else - xml.tag! "strPAN", credit_card.number - xml.tag! "strExpDate", expdate(credit_card) - xml.tag! "strCardHolder", credit_card.name - xml.tag! "strCVCode", credit_card.verification_value if credit_card.verification_value? + xml.tag! 'strPAN', credit_card.number + xml.tag! 'strExpDate', expdate(credit_card) + xml.tag! 'strCardHolder', credit_card.name + xml.tag! 'strCVCode', credit_card.verification_value if credit_card.verification_value? end end def split_reference(reference) - reference.to_s.split(";") + reference.to_s.split(';') end def parse(action, data) @@ -247,10 +247,10 @@ def parse(action, data) response[element.name] = element.text end - status, code, message = response["ApprovalStatus"].split(";") + status, code, message = response['ApprovalStatus'].split(';') response[:status] = status - if response[:success] = status == "APPROVED" + if response[:success] = status == 'APPROVED' response[:message] = status else response[:message] = message @@ -268,17 +268,17 @@ def parse_error(http_response) document = REXML::Document.new(http_response.body) - node = REXML::XPath.first(document, "//soap:Fault") + node = REXML::XPath.first(document, '//soap:Fault') node.elements.each do |element| response[element.name] = element.text end - response[:message] = response["faultstring"].to_s.gsub("\n", " ") + response[:message] = response['faultstring'].to_s.gsub("\n", ' ') response rescue REXML::ParseException response[:http_body] = http_response.body - response[:message] = "Failed to parse the failed response" + response[:message] = 'Failed to parse the failed response' response end @@ -293,8 +293,8 @@ def url(v4 = false) def commit(action, request, v4 = false) begin data = ssl_post(url(v4), request, - "Content-Type" => 'text/xml; charset=utf-8', - "SOAPAction" => soap_action(action, v4) + 'Content-Type' => 'text/xml; charset=utf-8', + 'SOAPAction' => soap_action(action, v4) ) response = parse(action, data) rescue ActiveMerchant::ResponseError => e @@ -304,14 +304,14 @@ def commit(action, request, v4 = false) Response.new(response[:success], response[:message], response, :test => test?, :authorization => authorization_from(response), - :avs_result => { :code => response["AVSResponse"] }, - :cvv_result => response["CVResponse"] + :avs_result => { :code => response['AVSResponse'] }, + :cvv_result => response['CVResponse'] ) end def authorization_from(response) if response[:success] - [ response["ReferenceID"], response["OrderNumber"] ].join(";") + [ response['ReferenceID'], response['OrderNumber'] ].join(';') end end end diff --git a/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb b/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb index 5107e7cd48e..109d00fce00 100644 --- a/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +++ b/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb @@ -9,19 +9,19 @@ class MerchantWareVersionFourGateway < Gateway self.homepage_url = 'http://merchantwarehouse.com/merchantware' self.display_name = 'MerchantWARE' - ENV_NAMESPACES = { "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", - "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema", - "xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/" } + ENV_NAMESPACES = { 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', + 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' } - TX_NAMESPACE = "http://schemas.merchantwarehouse.com/merchantware/40/Credit/" + TX_NAMESPACE = 'http://schemas.merchantwarehouse.com/merchantware/40/Credit/' ACTIONS = { - :purchase => "SaleKeyed", + :purchase => 'SaleKeyed', :reference_purchase => 'RepeatSale', - :authorize => "PreAuthorizationKeyed", - :capture => "PostAuthorization", - :void => "Void", - :refund => "Refund" + :authorize => 'PreAuthorizationKeyed', + :capture => 'PostAuthorization', + :void => 'Void', + :refund => 'Refund' } # Creates a new MerchantWareVersionFourGateway @@ -102,7 +102,7 @@ def refund(money, identification, options = {}) request = soap_request(:refund) do |xml| add_reference_token(xml, reference) add_invoice(xml, options) - add_amount(xml, money, "overrideAmount") + add_amount(xml, money, 'overrideAmount') end commit(:refund, request) @@ -131,12 +131,12 @@ def scrub(transcript) def soap_request(action) xml = Builder::XmlMarkup.new :indent => 2 xml.instruct! - xml.tag! "soap:Envelope", ENV_NAMESPACES do - xml.tag! "soap:Body" do - xml.tag! ACTIONS[action], "xmlns" => TX_NAMESPACE do - xml.tag! "merchantName", @options[:name] - xml.tag! "merchantSiteId", @options[:login] - xml.tag! "merchantKey", @options[:password] + xml.tag! 'soap:Envelope', ENV_NAMESPACES do + xml.tag! 'soap:Body' do + xml.tag! ACTIONS[action], 'xmlns' => TX_NAMESPACE do + xml.tag! 'merchantName', @options[:name] + xml.tag! 'merchantSiteId', @options[:login] + xml.tag! 'merchantKey', @options[:password] yield xml end end @@ -166,21 +166,21 @@ def build_capture_request(action, money, identification, options) end def add_invoice(xml, options) - xml.tag! "invoiceNumber", truncate(options[:order_id].to_s.gsub(/[^\w]/, ''), 8) + xml.tag! 'invoiceNumber', truncate(options[:order_id].to_s.gsub(/[^\w]/, ''), 8) end - def add_amount(xml, money, tag = "amount") + def add_amount(xml, money, tag = 'amount') xml.tag! tag, amount(money) end def add_reference_token(xml, reference) - xml.tag! "token", reference + xml.tag! 'token', reference end def add_address(xml, options) address = options[:billing_address] || options[:address] || {} - xml.tag! "avsStreetAddress", address[:address1] - xml.tag! "avsStreetZipCode", address[:zip] + xml.tag! 'avsStreetAddress', address[:address1] + xml.tag! 'avsStreetZipCode', address[:zip] end def add_payment_source(xml, source) @@ -192,14 +192,14 @@ def add_payment_source(xml, source) end def add_credit_card(xml, credit_card) - xml.tag! "cardNumber", credit_card.number - xml.tag! "expirationDate", expdate(credit_card) - xml.tag! "cardholder", credit_card.name - xml.tag! "cardSecurityCode", credit_card.verification_value if credit_card.verification_value? + xml.tag! 'cardNumber', credit_card.number + xml.tag! 'expirationDate', expdate(credit_card) + xml.tag! 'cardholder', credit_card.name + xml.tag! 'cardSecurityCode', credit_card.verification_value if credit_card.verification_value? end def split_reference(reference) - reference.to_s.split(";") + reference.to_s.split(';') end def parse(action, data) @@ -212,14 +212,14 @@ def parse(action, data) response[element.name] = element.text end - if response["ErrorMessage"].present? - response[:message] = response["ErrorMessage"] + if response['ErrorMessage'].present? + response[:message] = response['ErrorMessage'] response[:success] = false else - status, code, message = response["ApprovalStatus"].split(";") + status, code, message = response['ApprovalStatus'].split(';') response[:status] = status - if response[:success] = status == "APPROVED" + if response[:success] = status == 'APPROVED' response[:message] = status else response[:message] = message @@ -243,11 +243,11 @@ def parse_error(http_response, action) response[element.name] = element.text end - response[:message] = response["ErrorMessage"].to_s.gsub("\n", " ") + response[:message] = response['ErrorMessage'].to_s.gsub("\n", ' ') response rescue REXML::ParseException response[:http_body] = http_response.body - response[:message] = "Failed to parse the failed response" + response[:message] = 'Failed to parse the failed response' response end @@ -262,8 +262,8 @@ def url def commit(action, request) begin data = ssl_post(url, request, - "Content-Type" => 'text/xml; charset=utf-8', - "SOAPAction" => soap_action(action) + 'Content-Type' => 'text/xml; charset=utf-8', + 'SOAPAction' => soap_action(action) ) response = parse(action, data) rescue ActiveMerchant::ResponseError => e @@ -273,8 +273,8 @@ def commit(action, request) Response.new(response[:success], response[:message], response, :test => test?, :authorization => authorization_from(response), - :avs_result => { :code => response["AvsResponse"] }, - :cvv_result => response["CvResponse"] + :avs_result => { :code => response['AvsResponse'] }, + :cvv_result => response['CvResponse'] ) end diff --git a/lib/active_merchant/billing/gateways/merchant_warrior.rb b/lib/active_merchant/billing/gateways/merchant_warrior.rb index 52495836532..701b44ab049 100644 --- a/lib/active_merchant/billing/gateways/merchant_warrior.rb +++ b/lib/active_merchant/billing/gateways/merchant_warrior.rb @@ -119,7 +119,7 @@ def add_token(post, token) def add_creditcard(post, creditcard) post['paymentCardNumber'] = creditcard.number post['paymentCardName'] = scrub_name(creditcard.name) - post['paymentCardExpiry'] = creditcard.expiry_date.expiration.strftime("%m%y") + post['paymentCardExpiry'] = creditcard.expiry_date.expiration.strftime('%m%y') post['paymentCardCSC'] = creditcard.verification_value if creditcard.verification_value? end @@ -188,14 +188,14 @@ def add_auth(action, post) def url_for(action, post) if token?(post) - [(test? ? TOKEN_TEST_URL : TOKEN_LIVE_URL), action].join("/") + [(test? ? TOKEN_TEST_URL : TOKEN_LIVE_URL), action].join('/') else (test? ? POST_TEST_URL : POST_LIVE_URL) end end def token?(post) - (post["cardID"] || post["cardName"]) + (post['cardID'] || post['cardName']) end def success?(response) @@ -203,7 +203,7 @@ def success?(response) end def post_data(post) - post.collect{|k,v| "#{k}=#{CGI.escape(v.to_s)}" }.join("&") + post.collect{|k,v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/mercury.rb b/lib/active_merchant/billing/gateways/mercury.rb index bda96b1ab04..54f51af876c 100644 --- a/lib/active_merchant/billing/gateways/mercury.rb +++ b/lib/active_merchant/billing/gateways/mercury.rb @@ -87,8 +87,8 @@ def supports_scrubbing? def scrub(transcript) transcript. - gsub(%r(&lt;), "<"). - gsub(%r(&gt;), ">"). + gsub(%r(&lt;), '<'). + gsub(%r(&gt;), '>'). gsub(%r((<pw>).*(</pw>))i, '\1[FILTERED]\2'). gsub(%r((<AcctNo>)(\d|x)*(</AcctNo>))i, '\1[FILTERED]\3'). gsub(%r((<CVVData>)\d*(</CVVData>))i, '\1[FILTERED]\2') @@ -99,15 +99,15 @@ def scrub(transcript) def build_non_authorized_request(action, money, credit_card, options) xml = Builder::XmlMarkup.new - xml.tag! "TStream" do - xml.tag! "Transaction" do + xml.tag! 'TStream' do + xml.tag! 'Transaction' do xml.tag! 'TranType', 'Credit' xml.tag! 'TranCode', action if options[:allow_partial_auth] && (action == 'PreAuth' || action == 'Sale') - xml.tag! "PartialAuth", "Allow" + xml.tag! 'PartialAuth', 'Allow' end add_invoice(xml, options[:order_id], nil, options) - add_reference(xml, "RecordNumberRequested") + add_reference(xml, 'RecordNumberRequested') add_customer_data(xml, options) add_amount(xml, money, options) add_credit_card(xml, credit_card, action) @@ -121,15 +121,15 @@ def build_authorized_request(action, money, authorization, credit_card, options) xml = Builder::XmlMarkup.new invoice_no, ref_no, auth_code, acq_ref_data, process_data, record_no, amount = split_authorization(authorization) - ref_no = "1" if ref_no.blank? + ref_no = '1' if ref_no.blank? - xml.tag! "TStream" do - xml.tag! "Transaction" do + xml.tag! 'TStream' do + xml.tag! 'Transaction' do xml.tag! 'TranType', 'Credit' if options[:allow_partial_auth] && (action == 'PreAuthCapture') - xml.tag! "PartialAuth", "Allow" + xml.tag! 'PartialAuth', 'Allow' end - xml.tag! 'TranCode', (@use_tokenization ? (action + "ByRecordNo") : action) + xml.tag! 'TranCode', (@use_tokenization ? (action + 'ByRecordNo') : action) add_invoice(xml, invoice_no, ref_no, options) add_reference(xml, record_no) add_customer_data(xml, options) @@ -137,9 +137,9 @@ def build_authorized_request(action, money, authorization, credit_card, options) add_credit_card(xml, credit_card, action) if credit_card add_address(xml, options) xml.tag! 'TranInfo' do - xml.tag! "AuthCode", auth_code - xml.tag! "AcqRefData", acq_ref_data - xml.tag! "ProcessData", process_data + xml.tag! 'AuthCode', auth_code + xml.tag! 'AcqRefData', acq_ref_data + xml.tag! 'ProcessData', process_data end end end @@ -149,8 +149,8 @@ def build_authorized_request(action, money, authorization, credit_card, options) def build_card_lookup_request(credit_card, options) xml = Builder::XmlMarkup.new - xml.tag! "TStream" do - xml.tag! "Transaction" do + xml.tag! 'TStream' do + xml.tag! 'Transaction' do xml.tag! 'TranType', 'CardLookup' xml.tag! 'RecordNo', 'RecordNumberRequested' xml.tag! 'Frequency', 'OneTime' @@ -172,15 +172,15 @@ def add_invoice(xml, invoice_no, ref_no, options) def add_reference(xml, record_no) if @use_tokenization - xml.tag! "Frequency", "OneTime" - xml.tag! "RecordNo", record_no + xml.tag! 'Frequency', 'OneTime' + xml.tag! 'RecordNo', record_no end end def add_customer_data(xml, options) xml.tag! 'IpAddress', options[:ip] if options[:ip] if options[:customer] - xml.tag! "TranInfo" do + xml.tag! 'TranInfo' do xml.tag! 'CustomerCode', options[:customer] end end @@ -255,12 +255,12 @@ def parse(action, body) def hashify_xml!(xml, response) xml = REXML::Document.new(xml) - xml.elements.each("//CmdResponse/*") do |node| + xml.elements.each('//CmdResponse/*') do |node| response[node.name.underscore.to_sym] = node.text end - xml.elements.each("//TranResponse/*") do |node| - if node.name.to_s == "Amount" + xml.elements.each('//TranResponse/*') do |node| + if node.name.to_s == 'Amount' node.elements.each do |amt| response[amt.name.underscore.to_sym] = amt.text end @@ -293,8 +293,8 @@ def build_soap_request(body) def build_header { - "SOAPAction" => "http://www.mercurypay.com/CreditTransaction", - "Content-Type" => "text/xml; charset=utf-8" + 'SOAPAction' => 'http://www.mercurypay.com/CreditTransaction', + 'Content-Type' => 'text/xml; charset=utf-8' } end @@ -319,7 +319,7 @@ def message_from(response) end def authorization_from(response) - dollars, cents = (response[:purchase] || "").split(".").collect{|e| e.to_i} + dollars, cents = (response[:purchase] || '').split('.').collect{|e| e.to_i} dollars ||= 0 cents ||= 0 [ @@ -330,17 +330,17 @@ def authorization_from(response) response[:process_data], response[:record_no], ((dollars * 100) + cents).to_s - ].join(";") + ].join(';') end def split_authorization(authorization) - invoice_no, ref_no, auth_code, acq_ref_data, process_data, record_no, amount = authorization.split(";") + invoice_no, ref_no, auth_code, acq_ref_data, process_data, record_no, amount = authorization.split(';') [invoice_no, ref_no, auth_code, acq_ref_data, process_data, record_no, amount] end ENVELOPE_NAMESPACES = { 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', - 'xmlns:soap' => "http://schemas.xmlsoap.org/soap/envelope/", + 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance' } diff --git a/lib/active_merchant/billing/gateways/metrics_global.rb b/lib/active_merchant/billing/gateways/metrics_global.rb index 58ddab8753b..de046d9932b 100644 --- a/lib/active_merchant/billing/gateways/metrics_global.rb +++ b/lib/active_merchant/billing/gateways/metrics_global.rb @@ -20,8 +20,8 @@ class MetricsGlobalGateway < Gateway class_attribute :test_url, :live_url - self.test_url = "https://secure.metricsglobalgateway.com/gateway/transact.dll?testing=true" - self.live_url = "https://secure.metricsglobalgateway.com/gateway/transact.dll" + self.test_url = 'https://secure.metricsglobalgateway.com/gateway/transact.dll?testing=true' + self.live_url = 'https://secure.metricsglobalgateway.com/gateway/transact.dll' class_attribute :duplicate_window @@ -213,14 +213,14 @@ def post_data(action, parameters = {}) post[:version] = API_VERSION post[:login] = @options[:login] post[:tran_key] = @options[:password] - post[:relay_response] = "FALSE" + post[:relay_response] = 'FALSE' post[:type] = action - post[:delim_data] = "TRUE" - post[:delim_char] = "," - post[:encap_char] = "$" + post[:delim_data] = 'TRUE' + post[:delim_char] = ',' + post[:encap_char] = '$' post[:solution_ID] = application_id if application_id - request = post.merge(parameters).collect { |key, value| "x_#{key}=#{CGI.escape(value.to_s)}" }.join("&") + request = post.merge(parameters).collect { |key, value| "x_#{key}=#{CGI.escape(value.to_s)}" }.join('&') request end diff --git a/lib/active_merchant/billing/gateways/micropayment.rb b/lib/active_merchant/billing/gateways/micropayment.rb index 226bb9c469b..3172e3ec4f1 100644 --- a/lib/active_merchant/billing/gateways/micropayment.rb +++ b/lib/active_merchant/billing/gateways/micropayment.rb @@ -2,13 +2,13 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class MicropaymentGateway < Gateway - self.display_name = "micropayment" - self.homepage_url = "https://www.micropayment.de/" + self.display_name = 'micropayment' + self.homepage_url = 'https://www.micropayment.de/' - self.test_url = self.live_url = "https://sipg.micropayment.de/public/creditcardpsp/v1/nvp/" + self.test_url = self.live_url = 'https://sipg.micropayment.de/public/creditcardpsp/v1/nvp/' self.supported_countries = %w(DE) - self.default_currency = "EUR" + self.default_currency = 'EUR' self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express] @@ -24,7 +24,7 @@ def purchase(amount, payment_method, options={}) add_payment_method(post, payment_method, options) add_customer_data(post, options) add_address(post, options) - commit("purchase", post) + commit('purchase', post) end def authorize(amount, payment_method, options={}) @@ -33,27 +33,27 @@ def authorize(amount, payment_method, options={}) add_payment_method(post, payment_method, options) add_customer_data(post, options) add_address(post, options) - commit("authorize", post) + commit('authorize', post) end def capture(amount, authorization, options={}) post = {} add_reference(post, authorization) add_invoice(post, amount, options) - commit("capture", post) + commit('capture', post) end def void(authorization, options={}) post = {} add_reference(post, authorization) - commit("void", post) + commit('void', post) end def refund(amount, authorization, options={}) post = {} add_reference(post, authorization) add_invoice(post, amount, options) - commit("refund", post) + commit('refund', post) end def verify(credit_card, options={}) @@ -83,7 +83,7 @@ def add_invoice(post, money, options) post[:currency] = options[:currency] || currency(money) end post[:project] = options[:project] if options[:project] - post["params[title]"] = options[:description] if options[:description] + post['params[title]'] = options[:description] if options[:description] end def add_payment_method(post, payment_method, options={}) @@ -93,24 +93,24 @@ def add_payment_method(post, payment_method, options={}) post[:expiryYear] = format(payment_method.year, :four_digits) post[:expiryMonth] = format(payment_method.month, :two_digits) - post["params[firstname]"] = payment_method.first_name - post["params[surname]"] = payment_method.last_name + post['params[firstname]'] = payment_method.first_name + post['params[surname]'] = payment_method.last_name end def add_customer_data(post, options) - post["params[email]"] = options[:email] if options[:email] - post["params[ip]"] = options[:ip] || "1.1.1.1" - post["params[sendMail]"] = options[:send_mail] || 'false' + post['params[email]'] = options[:email] if options[:email] + post['params[ip]'] = options[:ip] || '1.1.1.1' + post['params[sendMail]'] = options[:send_mail] || 'false' end def add_address(post, options) address = options[:billing_address] return unless address - post["params[address]"] = address[:address1] if address[:address1] - post["params[zipcode]"] = address[:zip] if address[:zip] - post["params[town]"] = address[:city] if address[:city] - post["params[country]"] = address[:country] if address[:country] + post['params[address]'] = address[:address1] if address[:address1] + post['params[zipcode]'] = address[:zip] if address[:zip] + post['params[town]'] = address[:city] if address[:city] + post['params[country]'] = address[:country] if address[:country] end def add_reference(post, authorization) @@ -122,7 +122,7 @@ def add_reference(post, authorization) def commit(action, params) params[:testMode] = 1 if test? params[:accessKey] = @options[:access_key] - params[:apiKey] = @options[:api_key] || "af1fd841af792f4c50131414ff76e004" + params[:apiKey] = @options[:api_key] || 'af1fd841af792f4c50131414ff76e004' response = parse(ssl_post(url(action), post_data(action, params), headers)) @@ -131,14 +131,14 @@ def commit(action, params) message_from(succeeded, response), response, authorization: authorization_from(response, params), - avs_result: AVSResult.new(code: response["some_avs_result_key"]), - cvv_result: CVVResult.new(response["some_cvv_result_key"]), + avs_result: AVSResult.new(code: response['some_avs_result_key']), + cvv_result: CVVResult.new(response['some_cvv_result_key']), test: test? ) end def headers - { "Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8" } + { 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8' } end def post_data(action, params) @@ -152,32 +152,32 @@ def url(action) def parse(body) body.split(/\r?\n/).inject({}) do |acc, pair| - key, value = pair.split("=") + key, value = pair.split('=') acc[key] = CGI.unescape(value) acc end end def success_from(response) - response["error"] == "0" && - response["transactionResultCode"] == "00" && - response["transactionStatus"] == "SUCCESS" + response['error'] == '0' && + response['transactionResultCode'] == '00' && + response['transactionStatus'] == 'SUCCESS' end def message_from(succeeded, response) if succeeded - "Succeeded" + 'Succeeded' else - response["errorMessage"] || response["transactionResultMessage"] + response['errorMessage'] || response['transactionResultMessage'] end end def split_authorization(authorization) - authorization.split("|") + authorization.split('|') end def authorization_from(response, request_params) - session_id = response["sessionId"] || request_params[:sessionId] + session_id = response['sessionId'] || request_params[:sessionId] "#{session_id}|#{response["transactionId"]}" end end diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb index 39b3d9f2cd3..d0fa0d72411 100644 --- a/lib/active_merchant/billing/gateways/migs.rb +++ b/lib/active_merchant/billing/gateways/migs.rb @@ -194,7 +194,7 @@ def purchase_offsite_response(data) expected_secure_hash = calculate_secure_hash(response_hash, @options[:secure_hash]) unless response_hash[:SecureHash] == expected_secure_hash - raise SecurityError, "Secure Hash mismatch, response may be tampered with" + raise SecurityError, 'Secure Hash mismatch, response may be tampered with' end response_object(response_hash) @@ -237,10 +237,10 @@ def add_invoice(post, options) def add_3ds(post, options) post[:VerType] = options[:ver_type] if options[:ver_type] post[:VerToken] = options[:ver_token] if options[:ver_token] - post["3DSXID"] = options[:three_ds_xid] if options[:three_ds_xid] - post["3DSECI"] = options[:three_ds_eci] if options[:three_ds_eci] - post["3DSenrolled"] = options[:three_ds_enrolled] if options[:three_ds_enrolled] - post["3DSstatus"] = options[:three_ds_status] if options[:three_ds_status] + post['3DSXID'] = options[:three_ds_xid] if options[:three_ds_xid] + post['3DSECI'] = options[:three_ds_eci] if options[:three_ds_eci] + post['3DSenrolled'] = options[:three_ds_enrolled] if options[:three_ds_enrolled] + post['3DSstatus'] = options[:three_ds_status] if options[:three_ds_status] end def add_creditcard(post, creditcard) @@ -272,10 +272,10 @@ def commit(post) def response_object(response) avs_response_code = response[:AVSResultCode] - avs_response_code = 'S' if avs_response_code == "Unsupported" + avs_response_code = 'S' if avs_response_code == 'Unsupported' cvv_result_code = response[:CSCResultCode] - cvv_result_code = 'P' if cvv_result_code == "Unsupported" + cvv_result_code = 'P' if cvv_result_code == 'Unsupported' Response.new(success?(response), response[:Message], response, :test => test?, @@ -305,7 +305,7 @@ def add_standard_parameters(action, post, unique_id = nil) end def post_data(post) - post.collect { |key, value| "vpc_#{key}=#{CGI.escape(value.to_s)}" }.join("&") + post.collect { |key, value| "vpc_#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def add_secure_hash(post) diff --git a/lib/active_merchant/billing/gateways/modern_payments.rb b/lib/active_merchant/billing/gateways/modern_payments.rb index ca1bce5a639..340e3e7a0c7 100644 --- a/lib/active_merchant/billing/gateways/modern_payments.rb +++ b/lib/active_merchant/billing/gateways/modern_payments.rb @@ -19,7 +19,7 @@ def purchase(money, credit_card, options = {}) customer_response = cim.create_customer(options) return customer_response unless customer_response.success? - customer_id = customer_response.params["create_customer_result"] + customer_id = customer_response.params['create_customer_result'] card_response = cim.modify_customer_credit_card(customer_id, credit_card) return card_response unless card_response.success? diff --git a/lib/active_merchant/billing/gateways/modern_payments_cim.rb b/lib/active_merchant/billing/gateways/modern_payments_cim.rb index 4145d70e296..688598fd8d9 100644 --- a/lib/active_merchant/billing/gateways/modern_payments_cim.rb +++ b/lib/active_merchant/billing/gateways/modern_payments_cim.rb @@ -1,20 +1,20 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class ModernPaymentsCimGateway < Gateway #:nodoc: - self.test_url = "https://secure.modpay.com/netservices/test/ModpayTest.asmx" + self.test_url = 'https://secure.modpay.com/netservices/test/ModpayTest.asmx' self.live_url = 'https://secure.modpay.com/ws/modpay.asmx' - LIVE_XMLNS = "https://secure.modpay.com/ws/" - TEST_XMLNS = "https://secure.modpay.com/netservices/test/" + LIVE_XMLNS = 'https://secure.modpay.com/ws/' + TEST_XMLNS = 'https://secure.modpay.com/netservices/test/' self.supported_countries = ['US'] self.supported_cardtypes = [:visa, :master, :american_express, :discover] self.homepage_url = 'http://www.modpay.com' self.display_name = 'Modern Payments' - SUCCESS_MESSAGE = "Transaction accepted" - FAILURE_MESSAGE = "Transaction failed" - ERROR_MESSAGE = "Transaction error" + SUCCESS_MESSAGE = 'Transaction accepted' + FAILURE_MESSAGE = 'Transaction failed' + ERROR_MESSAGE = 'Transaction error' PAYMENT_METHOD = { :check => 1, @@ -35,7 +35,7 @@ def create_customer(options = {}) end def modify_customer_credit_card(customer_id, credit_card) - raise ArgumentError, "The customer_id cannot be blank" if customer_id.blank? + raise ArgumentError, 'The customer_id cannot be blank' if customer_id.blank? post = {} add_customer_id(post, customer_id) @@ -45,7 +45,7 @@ def modify_customer_credit_card(customer_id, credit_card) end def authorize_credit_card_payment(customer_id, amount) - raise ArgumentError, "The customer_id cannot be blank" if customer_id.blank? + raise ArgumentError, 'The customer_id cannot be blank' if customer_id.blank? post = {} add_customer_id(post, customer_id) @@ -55,7 +55,7 @@ def authorize_credit_card_payment(customer_id, amount) end def create_payment(customer_id, amount, options = {}) - raise ArgumentError, "The customer_id cannot be blank" if customer_id.blank? + raise ArgumentError, 'The customer_id cannot be blank' if customer_id.blank? post = {} add_customer_id(post, customer_id) @@ -67,7 +67,7 @@ def create_payment(customer_id, amount, options = {}) private def add_payment_details(post, options) - post[:pmtDate] = (options[:payment_date] || Time.now.utc).strftime("%Y-%m-%dT%H:%M:%SZ") + post[:pmtDate] = (options[:payment_date] || Time.now.utc).strftime('%Y-%m-%dT%H:%M:%SZ') post[:pmtType] = PAYMENT_METHOD[options[:payment_method] || :credit_card] end @@ -118,9 +118,9 @@ def build_request(action, params) 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance' } do xml.tag! 'env:Body' do - xml.tag! action, { "xmlns" => xmlns(action) } do - xml.tag! "clientId", @options[:login] - xml.tag! "clientCode", @options[:password] + xml.tag! action, { 'xmlns' => xmlns(action) } do + xml.tag! 'clientId', @options[:login] + xml.tag! 'clientCode', @options[:password] params.each {|key, value| xml.tag! key, value } end end @@ -163,14 +163,14 @@ def authorization_from(action, response) end def authorization_key(action) - action == "AuthorizeCreditCardPayment" ? :trans_id : "#{action.underscore}_result".to_sym + action == 'AuthorizeCreditCardPayment' ? :trans_id : "#{action.underscore}_result".to_sym end def successful?(action, response) key = authorization_key(action) if key == :trans_id - response[:approved] == "true" + response[:approved] == 'true' else response[key].to_i > 0 end @@ -195,7 +195,7 @@ def parse(action, xml) root.elements.to_a.each do |node| parse_element(response, node) end - elsif root = REXML::XPath.first(xml, "//soap:Fault") + elsif root = REXML::XPath.first(xml, '//soap:Fault') root.elements.to_a.each do |node| response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/monei.rb b/lib/active_merchant/billing/gateways/monei.rb index 1b0cd6ba848..a5fce7eb0f0 100755 --- a/lib/active_merchant/billing/gateways/monei.rb +++ b/lib/active_merchant/billing/gateways/monei.rb @@ -151,7 +151,7 @@ def execute_dependant(action, money, authorization, options) # Private: Build XML wrapping code yielding to code to fill the transaction information def build_request builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| - xml.Request(:version => "1.0") do + xml.Request(:version => '1.0') do xml.Header { xml.Security(:sender => @options[:sender_id]) } xml.Transaction(:mode => test? ? 'CONNECTOR_TEST' : 'LIVE', :response => 'SYNC', :channel => @options[:channel_id]) do xml.User(:login => @options[:login], :pwd => @options[:pwd]) @@ -229,10 +229,10 @@ def add_customer(xml, credit_card, options) def parse(body) xml = Nokogiri::XML(body) { - :unique_id => xml.xpath("//Response/Transaction/Identification/UniqueID").text, - :status => translate_status_code(xml.xpath("//Response/Transaction/Processing/Status/@code").text), - :reason => translate_status_code(xml.xpath("//Response/Transaction/Processing/Reason/@code").text), - :message => xml.xpath("//Response/Transaction/Processing/Return").text + :unique_id => xml.xpath('//Response/Transaction/Identification/UniqueID').text, + :status => translate_status_code(xml.xpath('//Response/Transaction/Processing/Status/@code').text), + :reason => translate_status_code(xml.xpath('//Response/Transaction/Processing/Reason/@code').text), + :message => xml.xpath('//Response/Transaction/Processing/Return').text } end diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb index cb98b443d2a..5ce35929532 100644 --- a/lib/active_merchant/billing/gateways/moneris.rb +++ b/lib/active_merchant/billing/gateways/moneris.rb @@ -178,7 +178,7 @@ def scrub(transcript) private # :nodoc: all def expdate(creditcard) - sprintf("%.4i", creditcard.year)[-2..-1] + sprintf("%.2i", creditcard.month) + sprintf('%.4i', creditcard.year)[-2..-1] + sprintf('%.2i', creditcard.month) end def add_payment_source(post, payment_method, options) @@ -249,7 +249,7 @@ def successful?(response) end def parse(xml) - response = { :message => "Global Error Receipt", :complete => false } + response = { :message => 'Global Error Receipt', :complete => false } hashify_xml!(xml, response) response end @@ -264,9 +264,9 @@ def hashify_xml!(xml, response) def post_data(action, parameters = {}) xml = REXML::Document.new - root = xml.add_element("request") - root.add_element("store_id").text = options[:login] - root.add_element("api_token").text = options[:password] + root = xml.add_element('request') + root.add_element('store_id').text = options[:login] + root.add_element('api_token').text = options[:password] root.add_element(transaction_element(action, parameters)) xml.to_s @@ -304,10 +304,10 @@ def avs_element(address) def cvd_element(cvd_value) element = REXML::Element.new('cvd_info') if cvd_value - element.add_element('cvd_indicator').text = "1" + element.add_element('cvd_indicator').text = '1' element.add_element('cvd_value').text = cvd_value else - element.add_element('cvd_indicator').text = "0" + element.add_element('cvd_indicator').text = '0' end element end @@ -320,29 +320,29 @@ def wallet_indicator(token_source) def message_from(message) return 'Unspecified error' if message.blank? - message.gsub(/[^\w]/, ' ').split.join(" ").capitalize + message.gsub(/[^\w]/, ' ').split.join(' ').capitalize end def actions { - "purchase" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code], - "preauth" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code], - "command" => [:order_id], - "refund" => [:order_id, :amount, :txn_number, :crypt_type], - "indrefund" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], - "completion" => [:order_id, :comp_amount, :txn_number, :crypt_type], - "purchasecorrection" => [:order_id, :txn_number, :crypt_type], - "cavv_preauth" => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator], - "cavv_purchase" => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator], - "transact" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], - "Batchcloseall" => [], - "opentotals" => [:ecr_number], - "batchclose" => [:ecr_number], - "res_add_cc" => [:pan, :expdate, :crypt_type], - "res_delete" => [:data_key], - "res_update_cc" => [:data_key, :pan, :expdate, :crypt_type], - "res_purchase_cc" => [:data_key, :order_id, :cust_id, :amount, :crypt_type], - "res_preauth_cc" => [:data_key, :order_id, :cust_id, :amount, :crypt_type] + 'purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code], + 'preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code], + 'command' => [:order_id], + 'refund' => [:order_id, :amount, :txn_number, :crypt_type], + 'indrefund' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], + 'completion' => [:order_id, :comp_amount, :txn_number, :crypt_type], + 'purchasecorrection' => [:order_id, :txn_number, :crypt_type], + 'cavv_preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator], + 'cavv_purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator], + 'transact' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], + 'Batchcloseall' => [], + 'opentotals' => [:ecr_number], + 'batchclose' => [:ecr_number], + 'res_add_cc' => [:pan, :expdate, :crypt_type], + 'res_delete' => [:data_key], + 'res_update_cc' => [:data_key, :pan, :expdate, :crypt_type], + 'res_purchase_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type], + 'res_preauth_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type] } end end diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb index b4101be56b6..e9e5ed3d476 100644 --- a/lib/active_merchant/billing/gateways/moneris_us.rb +++ b/lib/active_merchant/billing/gateways/moneris_us.rb @@ -154,7 +154,7 @@ def scrub(transcript) private # :nodoc: all def expdate(creditcard) - sprintf("%.4i", creditcard.year)[-2..-1] + sprintf("%.2i", creditcard.month) + sprintf('%.4i', creditcard.year)[-2..-1] + sprintf('%.2i', creditcard.month) end def add_address(post, payment_method, options) @@ -244,7 +244,7 @@ def successful?(response) end def parse(xml) - response = { :message => "Global Error Receipt", :complete => false } + response = { :message => 'Global Error Receipt', :complete => false } hashify_xml!(xml, response) response end @@ -259,9 +259,9 @@ def hashify_xml!(xml, response) def post_data(action, parameters = {}) xml = REXML::Document.new - root = xml.add_element("request") - root.add_element("store_id").text = options[:login] - root.add_element("api_token").text = options[:password] + root = xml.add_element('request') + root.add_element('store_id').text = options[:login] + root.add_element('api_token').text = options[:password] root.add_element(transaction_element(action, parameters)) xml.to_s @@ -301,10 +301,10 @@ def avs_element(address) def cvd_element(cvd_value) element = REXML::Element.new('cvd_info') if cvd_value - element.add_element('cvd_indicator').text = "1" + element.add_element('cvd_indicator').text = '1' element.add_element('cvd_value').text = cvd_value else - element.add_element('cvd_indicator').text = "0" + element.add_element('cvd_indicator').text = '0' end element end @@ -319,33 +319,33 @@ def ach_element(ach_info) def message_from(message) return 'Unspecified error' if message.blank? - message.gsub(/[^\w]/, ' ').split.join(" ").capitalize + message.gsub(/[^\w]/, ' ').split.join(' ').capitalize end def actions { - "us_purchase" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info], - "us_preauth" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info], - "us_command" => [:order_id], - "us_refund" => [:order_id, :amount, :txn_number, :crypt_type], - "us_indrefund" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], - "us_completion" => [:order_id, :comp_amount, :txn_number, :crypt_type], - "us_purchasecorrection" => [:order_id, :txn_number, :crypt_type], - "us_cavvpurcha" => [:order_id, :cust_id, :amount, :pan, :expdate, :cav], - "us_cavvpreaut" => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv], - "us_transact" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], - "us_Batchcloseall" => [], - "us_opentotals" => [:ecr_number], - "us_batchclose" => [:ecr_number], - "us_res_add_cc" => [:pan, :expdate, :crypt_type], - "us_res_delete" => [:data_key], - "us_res_update_cc" => [:data_key, :pan, :expdate, :crypt_type], - "us_res_purchase_cc" => [:data_key, :order_id, :cust_id, :amount, :crypt_type], - "us_res_preauth_cc" => [:data_key, :order_id, :cust_id, :amount, :crypt_type], - "us_ach_debit" => [:order_id, :cust_id, :amount, :ach_info], - "us_res_add_ach" => [:order_id, :cust_id, :amount, :ach_info], - "us_res_update_ach" => [:order_id, :data_key, :cust_id, :amount, :ach_info], - "ach_info" => [:sec, :cust_first_name, :cust_last_name, :cust_address1, :cust_address2, :cust_city, :cust_state, :cust_zip, :routing_num, :account_num, :check_num, :account_type] + 'us_purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info], + 'us_preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info], + 'us_command' => [:order_id], + 'us_refund' => [:order_id, :amount, :txn_number, :crypt_type], + 'us_indrefund' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], + 'us_completion' => [:order_id, :comp_amount, :txn_number, :crypt_type], + 'us_purchasecorrection' => [:order_id, :txn_number, :crypt_type], + 'us_cavvpurcha' => [:order_id, :cust_id, :amount, :pan, :expdate, :cav], + 'us_cavvpreaut' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv], + 'us_transact' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], + 'us_Batchcloseall' => [], + 'us_opentotals' => [:ecr_number], + 'us_batchclose' => [:ecr_number], + 'us_res_add_cc' => [:pan, :expdate, :crypt_type], + 'us_res_delete' => [:data_key], + 'us_res_update_cc' => [:data_key, :pan, :expdate, :crypt_type], + 'us_res_purchase_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type], + 'us_res_preauth_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type], + 'us_ach_debit' => [:order_id, :cust_id, :amount, :ach_info], + 'us_res_add_ach' => [:order_id, :cust_id, :amount, :ach_info], + 'us_res_update_ach' => [:order_id, :data_key, :cust_id, :amount, :ach_info], + 'ach_info' => [:sec, :cust_first_name, :cust_last_name, :cust_address1, :cust_address2, :cust_city, :cust_state, :cust_zip, :routing_num, :account_num, :check_num, :account_type] } end end diff --git a/lib/active_merchant/billing/gateways/money_movers.rb b/lib/active_merchant/billing/gateways/money_movers.rb index cc01dae258a..95165a42479 100644 --- a/lib/active_merchant/billing/gateways/money_movers.rb +++ b/lib/active_merchant/billing/gateways/money_movers.rb @@ -132,11 +132,11 @@ def test? def message_from(response) case response['response'].to_i when APPROVED - "Transaction Approved" + 'Transaction Approved' when DECLINED - "Transaction Declined" + 'Transaction Declined' else - "Error in transaction data or system error" + 'Error in transaction data or system error' end end diff --git a/lib/active_merchant/billing/gateways/nab_transact.rb b/lib/active_merchant/billing/gateways/nab_transact.rb index 446450f4322..85123a13ebd 100644 --- a/lib/active_merchant/billing/gateways/nab_transact.rb +++ b/lib/active_merchant/billing/gateways/nab_transact.rb @@ -6,7 +6,7 @@ module Billing #:nodoc: # be a rebadged Securepay Australia service, though some differences exist. class NabTransactGateway < Gateway API_VERSION = 'xml-4.2' - PERIODIC_API_VERSION = "spxml-4.2" + PERIODIC_API_VERSION = 'spxml-4.2' class_attribute :test_periodic_url, :live_periodic_url @@ -84,7 +84,7 @@ def supports_scrubbing? end def scrub(transcript) - return "" if transcript.blank? + return '' if transcript.blank? transcript. gsub(%r((<cardNumber>)[^<]+(<))i, '\1[FILTERED]\2'). gsub(%r((<cvv>)[^<]+(<))i, '\1[FILTERED]\2'). @@ -156,8 +156,8 @@ def build_request(action, body) xml.tag! 'RequestType', 'Payment' xml.tag! 'Payment' do - xml.tag! 'TxnList', "count" => 1 do - xml.tag! 'Txn', "ID" => 1 do + xml.tag! 'TxnList', 'count' => 1 do + xml.tag! 'Txn', 'ID' => 1 do xml.tag! 'txnType', TRANSACTIONS[action] xml.tag! 'txnSource', 23 xml << body @@ -187,8 +187,8 @@ def build_periodic_request(action, body) xml.tag! 'RequestType', 'Periodic' xml.tag! 'Periodic' do - xml.tag! 'PeriodicList', "count" => 1 do - xml.tag! 'PeriodicItem', "ID" => 1 do + xml.tag! 'PeriodicList', 'count' => 1 do + xml.tag! 'PeriodicItem', 'ID' => 1 do xml.tag! 'actionType', action.to_s xml.tag! 'periodicType', PERIODIC_TYPES[action] if PERIODIC_TYPES[action] xml << body diff --git a/lib/active_merchant/billing/gateways/ncr_secure_pay.rb b/lib/active_merchant/billing/gateways/ncr_secure_pay.rb index 3fcc6587dc0..1a595dd196d 100644 --- a/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +++ b/lib/active_merchant/billing/gateways/ncr_secure_pay.rb @@ -105,7 +105,7 @@ def add_payment(post, payment) def parse(body) doc = Nokogiri::XML(body) doc.remove_namespaces! - response = doc.xpath("/MonetraResp/Resp")[0] + response = doc.xpath('/MonetraResp/Resp')[0] resp_params = {} response.elements.each do |node| @@ -129,7 +129,7 @@ def commit(action, parameters) end def success_from(response) - response[:code] == "AUTH" + response[:code] == 'AUTH' end def message_from(response) @@ -143,7 +143,7 @@ def authorization_from(response) def request_body(action, parameters = {}) Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml| xml.MonetraTrans do - xml.Trans(identifier: parameters.delete(:identifier) || "1") do + xml.Trans(identifier: parameters.delete(:identifier) || '1') do xml.username(options[:username]) xml.password(options[:password]) xml.action(action) diff --git a/lib/active_merchant/billing/gateways/netaxept.rb b/lib/active_merchant/billing/gateways/netaxept.rb index 3ee6443f5a9..b3f1652c662 100644 --- a/lib/active_merchant/billing/gateways/netaxept.rb +++ b/lib/active_merchant/billing/gateways/netaxept.rb @@ -50,24 +50,24 @@ def capture(money, authorization, options = {}) post = {} add_credentials(post, options) add_authorization(post, authorization, money) - post[:operation] = "Capture" - commit("Netaxept/process.aspx", post) + post[:operation] = 'Capture' + commit('Netaxept/process.aspx', post) end def refund(money, authorization, options = {}) post = {} add_credentials(post, options) add_authorization(post, authorization, money) - post[:operation] = "Credit" - commit("Netaxept/process.aspx", post) + post[:operation] = 'Credit' + commit('Netaxept/process.aspx', post) end def void(authorization, options = {}) post = {} add_credentials(post, options) add_authorization(post, authorization) - post[:operation] = "Annul" - commit("Netaxept/process.aspx", post) + post[:operation] = 'Annul' + commit('Netaxept/process.aspx', post) end private @@ -76,7 +76,7 @@ def setup_transaction(money, options) post = {} add_credentials(post, options) add_order(post, money, options) - commit("Netaxept/Register.aspx", post) + commit('Netaxept/Register.aspx', post) end def add_and_auth_credit_card(authorization, creditcard, options) @@ -84,14 +84,14 @@ def add_and_auth_credit_card(authorization, creditcard, options) add_credentials(post, options, false) add_authorization(post, authorization) add_creditcard(post, creditcard) - commit("terminal/default.aspx", post, false) + commit('terminal/default.aspx', post, false) end def query_transaction(authorization, options) post = {} add_credentials(post, options) add_authorization(post, authorization) - commit("Netaxept/query.aspx", post) + commit('Netaxept/query.aspx', post) end def add_credentials(post, options, secure=true) @@ -109,7 +109,7 @@ def add_order(post, money, options) post[:orderNumber] = options[:order_id] post[:amount] = amount(money) post[:currencyCode] = (options[:currency] || currency(money)) - post[:autoAuth] = "true" + post[:autoAuth] = 'true' end def add_creditcard(post, options) @@ -122,13 +122,13 @@ def commit(path, parameters, xml=true) raw = parse(ssl_get(build_url(path, parameters)), xml) success = false - authorization = (raw["TransactionId"] || parameters[:transactionId]) + authorization = (raw['TransactionId'] || parameters[:transactionId]) if raw[:container] =~ /Exception|Error/ - message = (raw["Message"] || raw["Error"]["Message"]) - elsif raw["Error"] && !raw["Error"].empty? - message = (raw["Error"]["ResponseText"] || raw["Error"]["ResponseCode"]) + message = (raw['Message'] || raw['Error']['Message']) + elsif raw['Error'] && !raw['Error'].empty? + message = (raw['Error']['ResponseText'] || raw['Error']['ResponseCode']) else - message = (raw["ResponseText"] || raw["ResponseCode"] || "OK") + message = (raw['ResponseText'] || raw['ResponseCode'] || 'OK') success = true end diff --git a/lib/active_merchant/billing/gateways/netbanx.rb b/lib/active_merchant/billing/gateways/netbanx.rb index 1c1fdc227eb..444723f66ff 100644 --- a/lib/active_merchant/billing/gateways/netbanx.rb +++ b/lib/active_merchant/billing/gateways/netbanx.rb @@ -212,7 +212,7 @@ def success_from(response) end def message_from(success, response) - success ? 'OK' : (response['error']['message'] || "Unknown error - please contact Netbanx-Paysafe") + success ? 'OK' : (response['error']['message'] || 'Unknown error - please contact Netbanx-Paysafe') end def authorization_from(success, url, method, response) @@ -229,7 +229,7 @@ def authorization_from(success, url, method, response) # # both id's are used to unstore, the payment token is only used for # purchase transactions - [response['id'], response['cards'].first['id'], response['cards'].first['paymentToken']].join("|") + [response['id'], response['cards'].first['id'], response['cards'].first['paymentToken']].join('|') end end diff --git a/lib/active_merchant/billing/gateways/netbilling.rb b/lib/active_merchant/billing/gateways/netbilling.rb index 32d48b71d6c..32635e806dd 100644 --- a/lib/active_merchant/billing/gateways/netbilling.rb +++ b/lib/active_merchant/billing/gateways/netbilling.rb @@ -224,7 +224,7 @@ def post_data(action, parameters = {}) parameters[:pay_type] = 'C' parameters[:tran_type] = TRANSACTIONS[action] - parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end end diff --git a/lib/active_merchant/billing/gateways/netpay.rb b/lib/active_merchant/billing/gateways/netpay.rb index b950d33073b..5068fa894c6 100644 --- a/lib/active_merchant/billing/gateways/netpay.rb +++ b/lib/active_merchant/billing/gateways/netpay.rb @@ -51,7 +51,7 @@ class NetpayGateway < Gateway self.display_name = 'NETPAY Gateway' CURRENCY_CODES = { - "MXN" => '484' + 'MXN' => '484' } # The header keys that we will provide in the response params hash @@ -157,7 +157,7 @@ def build_authorization(request_params, response_params) end def split_authorization(authorization) - order_id, amount, currency = authorization.split("|") + order_id, amount, currency = authorization.split('|') [order_id, amount, currency] end @@ -166,8 +166,8 @@ def order_id_from(authorization) end def expdate(credit_card) - year = sprintf("%.4i", credit_card.year) - month = sprintf("%.2i", credit_card.month) + year = sprintf('%.4i', credit_card.year) + month = sprintf('%.2i', credit_card.month) "#{month}/#{year[-2..-1]}" end @@ -191,7 +191,7 @@ def commit(action, parameters, options) add_login_data(parameters) add_action(parameters, action, options) - post = parameters.collect{|key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + post = parameters.collect{|key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') parse(ssl_post(url, post), parameters) end diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb index 3af76b0150f..7ed61265c54 100644 --- a/lib/active_merchant/billing/gateways/nmi.rb +++ b/lib/active_merchant/billing/gateways/nmi.rb @@ -3,7 +3,7 @@ module Billing #:nodoc: class NmiGateway < Gateway include Empty - DUP_WINDOW_DEPRECATION_MESSAGE = "The class-level duplicate_window variable is deprecated. Please use the :dup_seconds transaction option instead." + DUP_WINDOW_DEPRECATION_MESSAGE = 'The class-level duplicate_window variable is deprecated. Please use the :dup_seconds transaction option instead.' self.test_url = self.live_url = 'https://secure.nmi.com/api/transact.php' self.default_currency = 'USD' @@ -34,7 +34,7 @@ def purchase(amount, payment_method, options={}) add_customer_data(post, options) add_merchant_defined_fields(post, options) - commit("sale", post) + commit('sale', post) end def authorize(amount, payment_method, options={}) @@ -44,7 +44,7 @@ def authorize(amount, payment_method, options={}) add_customer_data(post, options) add_merchant_defined_fields(post, options) - commit("auth", post) + commit('auth', post) end def capture(amount, authorization, options={}) @@ -53,7 +53,7 @@ def capture(amount, authorization, options={}) add_reference(post, authorization) add_merchant_defined_fields(post, options) - commit("capture", post) + commit('capture', post) end def void(authorization, options={}) @@ -61,7 +61,7 @@ def void(authorization, options={}) add_reference(post, authorization) add_payment_type(post, authorization) - commit("void", post) + commit('void', post) end def refund(amount, authorization, options={}) @@ -70,7 +70,7 @@ def refund(amount, authorization, options={}) add_reference(post, authorization) add_payment_type(post, authorization) - commit("refund", post) + commit('refund', post) end def credit(amount, payment_method, options={}) @@ -79,7 +79,7 @@ def credit(amount, payment_method, options={}) add_payment_method(post, payment_method, options) add_customer_data(post, options) - commit("credit", post) + commit('credit', post) end def verify(payment_method, options={}) @@ -88,7 +88,7 @@ def verify(payment_method, options={}) add_customer_data(post, options) add_merchant_defined_fields(post, options) - commit("validate", post) + commit('validate', post) end def store(payment_method, options = {}) @@ -98,12 +98,12 @@ def store(payment_method, options = {}) add_customer_data(post, options) add_merchant_defined_fields(post, options) - commit("add_customer", post) + commit('add_customer', post) end def verify_credentials - response = void("0") - response.message != "Authentication Failed" + response = void('0') + response.message != 'Authentication Failed' end def supports_scrubbing? @@ -131,7 +131,7 @@ def add_invoice(post, money, options) post[:orderid] = options[:order_id] post[:orderdescription] = options[:description] post[:currency] = options[:currency] || currency(money) - post[:billing_method] = "recurring" if options[:recurring] + post[:billing_method] = 'recurring' if options[:recurring] if (dup_seconds = (options[:dup_seconds] || self.class.duplicate_window)) post[:dup_seconds] = dup_seconds end @@ -215,7 +215,7 @@ def exp_date(payment_method) def commit(action, params) - params[action == "add_customer" ? :customer_vault : :type] = action + params[action == 'add_customer' ? :customer_vault : :type] = action params[:username] = @options[:login] params[:password] = @options[:password] @@ -235,15 +235,15 @@ def commit(action, params) end def authorization_from(response, payment_type) - [ response[:transactionid], payment_type ].join("#") + [ response[:transactionid], payment_type ].join('#') end def split_authorization(authorization) - authorization.split("#") + authorization.split('#') end def headers - { "Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8" } + { 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8' } end def post_data(action, params) @@ -259,12 +259,12 @@ def parse(body) end def success_from(response) - response[:response] == "1" + response[:response] == '1' end def message_from(succeeded, response) if succeeded - "Succeeded" + 'Succeeded' else response[:responsetext] end diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb index 792f3f07984..ef81e22b14e 100644 --- a/lib/active_merchant/billing/gateways/ogone.rb +++ b/lib/active_merchant/billing/gateways/ogone.rb @@ -119,7 +119,7 @@ class OgoneGateway < Gateway 'KO' => 'N', 'NO' => 'R' } - SUCCESS_MESSAGE = "The transaction was successful" + SUCCESS_MESSAGE = 'The transaction was successful' THREE_D_SECURE_DISPLAY_WAYS = { :main_window => 'MAINW', # display the identification page in the main window # (default value). @@ -128,11 +128,11 @@ class OgoneGateway < Gateway :pop_ix => 'POPIX' } # display the identification page in a pop-up window # and remain in the pop-up window. - OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE = "Signature usage will be the default for a future release of ActiveMerchant. You should either begin using it, or update your configuration to explicitly disable it (signature_encryptor: none)" + OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE = 'Signature usage will be the default for a future release of ActiveMerchant. You should either begin using it, or update your configuration to explicitly disable it (signature_encryptor: none)' OGONE_STORE_OPTION_DEPRECATION_MESSAGE = "The 'store' option has been renamed to 'billing_id', and its usage is deprecated." - self.test_url = "https://secure.ogone.com/ncol/test/" - self.live_url = "https://secure.ogone.com/ncol/prod/" + self.test_url = 'https://secure.ogone.com/ncol/test/' + self.live_url = 'https://secure.ogone.com/ncol/prod/' self.supported_countries = ['BE', 'DE', 'FR', 'NL', 'AT', 'CH'] # also supports Airplus and UATP @@ -150,7 +150,7 @@ def initialize(options = {}) # Verify and reserve the specified amount on the account, without actually doing the transaction. def authorize(money, payment_source, options = {}) post = {} - action = (payment_source.brand == "mastercard") ? "PAU" : "RES" + action = (payment_source.brand == 'mastercard') ? 'PAU' : 'RES' add_invoice(post, options) add_payment_source(post, payment_source, options) add_address(post, payment_source, options) @@ -235,12 +235,12 @@ def scrub(transcript) private def reference_from(authorization) - authorization.split(";").first + authorization.split(';').first end def reference_transaction?(identifier) return false unless identifier.is_a?(String) - _, action = identifier.split(";") + _, action = identifier.split(';') !action.nil? end @@ -286,7 +286,7 @@ def add_d3d(post, options) THREE_D_SECURE_DISPLAY_WAYS[:main_window] add_pair post, 'WIN3DS', win_3ds - add_pair post, 'HTTP_ACCEPT', options[:http_accept] || "*/*" + add_pair post, 'HTTP_ACCEPT', options[:http_accept] || '*/*' add_pair post, 'HTTP_USER_AGENT', options[:http_user_agent] if options[:http_user_agent] add_pair post, 'ACCEPTURL', options[:accept_url] if options[:accept_url] add_pair post, 'DECLINEURL', options[:decline_url] if options[:decline_url] @@ -339,7 +339,7 @@ def add_invoice(post, options) def add_creditcard(post, creditcard) add_pair post, 'CN', creditcard.name add_pair post, 'CARDNO', creditcard.number - add_pair post, 'ED', "%02d%02s" % [creditcard.month, creditcard.year.to_s[-2..-1]] + add_pair post, 'ED', '%02d%02s' % [creditcard.month, creditcard.year.to_s[-2..-1]] add_pair post, 'CVC', creditcard.verification_value end @@ -349,8 +349,8 @@ def parse(body) # Add HTML_ANSWER element (3-D Secure specific to the response's params) # Note: HTML_ANSWER is not an attribute so we add it "by hand" to the response - if html_answer = REXML::XPath.first(xml_root, "//HTML_ANSWER") - response["HTML_ANSWER"] = html_answer.text + if html_answer = REXML::XPath.first(xml_root, '//HTML_ANSWER') + response['HTML_ANSWER'] = html_answer.text end response @@ -365,27 +365,27 @@ def commit(action, parameters) response = parse(ssl_post(url(parameters['PAYID']), post_data(action, parameters))) options = { - :authorization => [response["PAYID"], action].join(";"), + :authorization => [response['PAYID'], action].join(';'), :test => test?, - :avs_result => { :code => AVS_MAPPING[response["AAVCheck"]] }, - :cvv_result => CVV_MAPPING[response["CVCCheck"]] + :avs_result => { :code => AVS_MAPPING[response['AAVCheck']] }, + :cvv_result => CVV_MAPPING[response['CVCCheck']] } OgoneResponse.new(successful?(response), message_from(response), response, options) end def url(payid) - (test? ? test_url : live_url) + (payid ? "maintenancedirect.asp" : "orderdirect.asp") + (test? ? test_url : live_url) + (payid ? 'maintenancedirect.asp' : 'orderdirect.asp') end def successful?(response) - response["NCERROR"] == "0" + response['NCERROR'] == '0' end def message_from(response) if successful?(response) SUCCESS_MESSAGE else - format_error_message(response["NCERRORPLUS"]) + format_error_message(response['NCERRORPLUS']) end end @@ -393,9 +393,9 @@ def format_error_message(message) raw_message = message.to_s.strip case raw_message when /\|/ - raw_message.split("|").join(", ").capitalize + raw_message.split('|').join(', ').capitalize when /\// - raw_message.split("/").first.to_s.capitalize + raw_message.split('/').first.to_s.capitalize else raw_message.to_s.capitalize end @@ -409,7 +409,7 @@ def post_data(action, parameters = {}) def add_signature(parameters) if @options[:signature].blank? - ActiveMerchant.deprecated(OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE) unless(@options[:signature_encryptor] == "none") + ActiveMerchant.deprecated(OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE) unless(@options[:signature_encryptor] == 'none') return end @@ -432,7 +432,7 @@ def calculate_signature(signed_parameters, algorithm, secret) filtered_params = signed_parameters.select{|k,v| !v.blank?} sha_encryptor.hexdigest( - filtered_params.sort_by{|k,v| k.upcase}.map{|k, v| "#{k.upcase}=#{v}#{secret}"}.join("") + filtered_params.sort_by{|k,v| k.upcase}.map{|k, v| "#{k.upcase}=#{v}#{secret}"}.join('') ).upcase end @@ -449,7 +449,7 @@ def legacy_calculate_signature(parameters, secret) ALIAS ).map{|key| parameters[key]} + [secret] - ).join("") + ).join('') ).upcase end diff --git a/lib/active_merchant/billing/gateways/omise.rb b/lib/active_merchant/billing/gateways/omise.rb index 31acde05a16..2d37f1dd5de 100644 --- a/lib/active_merchant/billing/gateways/omise.rb +++ b/lib/active_merchant/billing/gateways/omise.rb @@ -182,7 +182,7 @@ def headers(options={}) key = options[:key] || @secret_key { 'Content-Type' => 'application/json;utf-8', - 'Omise-Version' => @api_version || "2014-07-27", + 'Omise-Version' => @api_version || '2014-07-27', 'User-Agent' => "ActiveMerchantBindings/#{ActiveMerchant::VERSION} Ruby/#{RUBY_VERSION}", 'Authorization' => 'Basic ' + Base64.encode64(key.to_s + ':').strip, 'Accept-Encoding' => 'utf-8' @@ -216,7 +216,7 @@ def parse(body) end def json_error(raw_response) - msg = "Invalid response received from Omise API. Please contact support@omise.co if you continue to receive this message." + msg = 'Invalid response received from Omise API. Please contact support@omise.co if you continue to receive this message.' msg += "The raw response returned by the API was #{raw_response.inspect})" { message: msg } end diff --git a/lib/active_merchant/billing/gateways/openpay.rb b/lib/active_merchant/billing/gateways/openpay.rb index 4ad00ec4999..42db1200b97 100644 --- a/lib/active_merchant/billing/gateways/openpay.rb +++ b/lib/active_merchant/billing/gateways/openpay.rb @@ -165,10 +165,10 @@ def add_address(card, options) def headers(options = {}) { - "Content-Type" => "application/json", - "Authorization" => "Basic " + Base64.strict_encode64(@api_key.to_s + ":").strip, - "User-Agent" => "Openpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}", - "X-Openpay-Client-User-Agent" => user_agent + 'Content-Type' => 'application/json', + 'Authorization' => 'Basic ' + Base64.strict_encode64(@api_key.to_s + ':').strip, + 'User-Agent' => "Openpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}", + 'X-Openpay-Client-User-Agent' => user_agent } end diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb index 60ef5774116..f685d70ee9b 100644 --- a/lib/active_merchant/billing/gateways/opp.rb +++ b/lib/active_merchant/billing/gateways/opp.rb @@ -253,7 +253,7 @@ def add_payment_method(post, payment, options) post[:card] = { holder: payment.name, number: payment.number, - expiryMonth: "%02d" % payment.month, + expiryMonth: '%02d' % payment.month, expiryYear: payment.year, cvv: payment.verification_value, } @@ -297,8 +297,8 @@ def commit(post, authorization, options) parse( ssl_post( url, - post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&"), - "Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8" + post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&'), + 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8' ) ) rescue ResponseError => e diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb index 10c809fdc04..2bf3b323f97 100644 --- a/lib/active_merchant/billing/gateways/optimal_payment.rb +++ b/lib/active_merchant/billing/gateways/optimal_payment.rb @@ -75,10 +75,10 @@ def scrub(transcript) def parse_card_or_auth(card_or_auth, options) if card_or_auth.respond_to?(:number) @credit_card = card_or_auth - @stored_data = "" + @stored_data = '' else options[:confirmationNumber] = card_or_auth - @stored_data = "StoredData" + @stored_data = 'StoredData' end end diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index 94143ac7eef..27402de05be 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -1,5 +1,5 @@ require 'active_merchant/billing/gateways/orbital/orbital_soft_descriptors' -require "rexml/document" +require 'rexml/document' module ActiveMerchant #:nodoc: module Billing #:nodoc: @@ -30,15 +30,15 @@ module Billing #:nodoc: class OrbitalGateway < Gateway include Empty - API_VERSION = "7.1" + API_VERSION = '7.1' POST_HEADERS = { - "MIME-Version" => "1.1", - "Content-Type" => "application/PTI#{API_VERSION.gsub(/\./, '')}", - "Content-transfer-encoding" => "text", - "Request-number" => '1', - "Document-type" => "Request", - "Interface-Version" => "Ruby|ActiveMerchant|Proprietary Gateway" + 'MIME-Version' => '1.1', + 'Content-Type' => "application/PTI#{API_VERSION.gsub(/\./, '')}", + 'Content-transfer-encoding' => 'text', + 'Request-number' => '1', + 'Document-type' => 'Request', + 'Interface-Version' => 'Ruby|ActiveMerchant|Proprietary Gateway' } SUCCESS = '0' @@ -65,14 +65,14 @@ class OrbitalGateway < Gateway class_attribute :secondary_test_url, :secondary_live_url - self.test_url = "https://orbitalvar1.chasepaymentech.com/authorize" - self.secondary_test_url = "https://orbitalvar2.chasepaymentech.com/authorize" + self.test_url = 'https://orbitalvar1.chasepaymentech.com/authorize' + self.secondary_test_url = 'https://orbitalvar2.chasepaymentech.com/authorize' - self.live_url = "https://orbital1.chasepaymentech.com/authorize" - self.secondary_live_url = "https://orbital2.chasepaymentech.com/authorize" + self.live_url = 'https://orbital1.chasepaymentech.com/authorize' + self.secondary_live_url = 'https://orbital2.chasepaymentech.com/authorize' - self.supported_countries = ["US", "CA"] - self.default_currency = "CAD" + self.supported_countries = ['US', 'CA'] + self.default_currency = 'CAD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb] self.display_name = 'Orbital Paymentech' @@ -83,45 +83,45 @@ class OrbitalGateway < Gateway AVS_SUPPORTED_COUNTRIES = ['US', 'CA', 'UK', 'GB'] CURRENCY_CODES = { - "AUD" => '036', - "BRL" => '986', - "CAD" => '124', - "CLP" => '152', - "CZK" => '203', - "DKK" => '208', - "HKD" => '344', - "ICK" => '352', - "JPY" => '392', - "MXN" => '484', - "NZD" => '554', - "NOK" => '578', - "SGD" => '702', - "SEK" => '752', - "CHF" => '756', - "GBP" => '826', - "USD" => '840', - "EUR" => '978' + 'AUD' => '036', + 'BRL' => '986', + 'CAD' => '124', + 'CLP' => '152', + 'CZK' => '203', + 'DKK' => '208', + 'HKD' => '344', + 'ICK' => '352', + 'JPY' => '392', + 'MXN' => '484', + 'NZD' => '554', + 'NOK' => '578', + 'SGD' => '702', + 'SEK' => '752', + 'CHF' => '756', + 'GBP' => '826', + 'USD' => '840', + 'EUR' => '978' } CURRENCY_EXPONENTS = { - "AUD" => '2', - "BRL" => '2', - "CAD" => '2', - "CLP" => '2', - "CZK" => '2', - "DKK" => '2', - "HKD" => '2', - "ICK" => '2', - "JPY" => '0', - "MXN" => '2', - "NZD" => '2', - "NOK" => '2', - "SGD" => '2', - "SEK" => '2', - "CHF" => '2', - "GBP" => '2', - "USD" => '2', - "EUR" => '2' + 'AUD' => '2', + 'BRL' => '2', + 'CAD' => '2', + 'CLP' => '2', + 'CZK' => '2', + 'DKK' => '2', + 'HKD' => '2', + 'ICK' => '2', + 'JPY' => '0', + 'MXN' => '2', + 'NZD' => '2', + 'NOK' => '2', + 'SGD' => '2', + 'SEK' => '2', + 'CHF' => '2', + 'GBP' => '2', + 'USD' => '2', + 'EUR' => '2' } # INDUSTRY TYPES @@ -243,7 +243,7 @@ def credit(money, authorization, options= {}) def void(authorization, options = {}, deprecated = {}) if(!options.kind_of?(Hash)) - ActiveMerchant.deprecated("Calling the void method with an amount parameter is deprecated and will be removed in a future version.") + ActiveMerchant.deprecated('Calling the void method with an amount parameter is deprecated and will be removed in a future version.') return void(options, deprecated.merge(:amount => authorization)) end @@ -315,7 +315,7 @@ def scrub(transcript) private def authorization_string(*args) - args.compact.join(";") + args.compact.join(';') end def split_authorization(authorization) @@ -509,8 +509,8 @@ def add_managed_billing(xml, options) def parse(body) response = {} xml = REXML::Document.new(body) - root = REXML::XPath.first(xml, "//Response") || - REXML::XPath.first(xml, "//ErrorResponse") + root = REXML::XPath.first(xml, '//Response') || + REXML::XPath.first(xml, '//ErrorResponse') if root root.elements.to_a.each do |node| recurring_parse_element(response, node) @@ -529,9 +529,9 @@ def recurring_parse_element(response, node) end def commit(order, message_type, trace_number=nil) - headers = POST_HEADERS.merge("Content-length" => order.size.to_s) - headers.merge!( "Trace-number" => trace_number.to_s, - "Merchant-Id" => @options[:merchant_id] ) if @options[:retry_logic] && trace_number + headers = POST_HEADERS.merge('Content-length' => order.size.to_s) + headers.merge!( 'Trace-number' => trace_number.to_s, + 'Merchant-Id' => @options[:merchant_id] ) if @options[:retry_logic] && trace_number request = lambda{|url| parse(ssl_post(url, order, headers))} # Failover URL will be attempted in the event of a connection error @@ -643,7 +643,7 @@ def build_new_order_xml(action, money, creditcard, parameters = {}) # RS - Subsequent Recurring Transactions def set_recurring_ind(xml, parameters) if parameters[:recurring_ind] - raise "RecurringInd must be set to either \"RF\" or \"RS\"" unless %w(RF RS).include?(parameters[:recurring_ind]) + raise 'RecurringInd must be set to either "RF" or "RS"' unless %w(RF RS).include?(parameters[:recurring_ind]) xml.tag! :RecurringInd, parameters[:recurring_ind] end end @@ -745,7 +745,7 @@ def format_address_field(value) # Field lengths should be limited by byte count instead of character count # Returns the truncated value or nil def byte_limit(value, byte_length) - limited_value = "" + limited_value = '' value.to_s.each_char do |c| break if((limited_value.bytesize + c.bytesize) > byte_length) @@ -756,7 +756,7 @@ def byte_limit(value, byte_length) end def build_customer_request_xml(creditcard, options = {}) - ActiveMerchant.deprecated "Customer Profile support in Orbital is non-conformant to the ActiveMerchant API and will be removed in its current form in a future version. Please contact the ActiveMerchant maintainers if you have an interest in modifying it to conform to the store/unstore/update API." + ActiveMerchant.deprecated 'Customer Profile support in Orbital is non-conformant to the ActiveMerchant API and will be removed in its current form in a future version. Please contact the ActiveMerchant maintainers if you have an interest in modifying it to conform to the store/unstore/update API.' xml = xml_envelope xml.tag! :Request do xml.tag! :Profile do @@ -793,7 +793,7 @@ def build_customer_request_xml(creditcard, options = {}) end xml.tag! :CCAccountNum, creditcard.number if creditcard - xml.tag! :CCExpireDate, creditcard.expiry_date.expiration.strftime("%m%y") if creditcard + xml.tag! :CCExpireDate, creditcard.expiry_date.expiration.strftime('%m%y') if creditcard # This has to come after CCExpireDate. add_managed_billing(xml, options) diff --git a/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb b/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb index 44eceace7e2..da1d82d0ca0 100644 --- a/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +++ b/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb @@ -27,16 +27,16 @@ def initialize(options = {}) def validate errors = [] - errors << [:merchant_name, "is required"] if self.merchant_name.blank? - errors << [:merchant_name, "is required to be 25 bytes or less"] if self.merchant_name.bytesize > 25 + errors << [:merchant_name, 'is required'] if self.merchant_name.blank? + errors << [:merchant_name, 'is required to be 25 bytes or less'] if self.merchant_name.bytesize > 25 if(!empty?(self.merchant_phone) && !self.merchant_phone.match(PHONE_FORMAT_1) && !self.merchant_phone.match(PHONE_FORMAT_2)) - errors << [:merchant_phone, "is required to follow \"NNN-NNN-NNNN\" or \"NNN-AAAAAAA\" format"] + errors << [:merchant_phone, 'is required to follow "NNN-NNN-NNNN" or "NNN-AAAAAAA" format'] end [:merchant_email, :merchant_url].each do |attr| unless self.send(attr).blank? - errors << [attr, "is required to be 13 bytes or less"] if(self.send(attr).bytesize > 13) + errors << [attr, 'is required to be 13 bytes or less'] if(self.send(attr).bytesize > 13) end end diff --git a/lib/active_merchant/billing/gateways/pac_net_raven.rb b/lib/active_merchant/billing/gateways/pac_net_raven.rb index ad400d48c25..1fd15b5c0ae 100644 --- a/lib/active_merchant/billing/gateways/pac_net_raven.rb +++ b/lib/active_merchant/billing/gateways/pac_net_raven.rb @@ -159,11 +159,11 @@ def message_from(response) return response['Message'] if response['Message'] if response['Status'] == 'Approved' - "This transaction has been approved" + 'This transaction has been approved' elsif response['Status'] == 'Declined' - "This transaction has been declined" + 'This transaction has been declined' elsif response['Status'] == 'Voided' - "This transaction has been voided" + 'This transaction has been voided' else response['Status'] end @@ -179,12 +179,12 @@ def post_data(action, parameters = {}) post['RequestID'] = request_id post['Signature'] = signature(action, post, parameters) - request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') request end def timestamp - Time.now.strftime("%Y-%m-%dT%H:%M:%S.Z") + Time.now.strftime('%Y-%m-%dT%H:%M:%S.Z') end def request_id diff --git a/lib/active_merchant/billing/gateways/pagarme.rb b/lib/active_merchant/billing/gateways/pagarme.rb index 449a440990d..77786486739 100644 --- a/lib/active_merchant/billing/gateways/pagarme.rb +++ b/lib/active_merchant/billing/gateways/pagarme.rb @@ -132,18 +132,18 @@ def post_data(params) end post_data(h) elsif value.is_a?(Array) - value.map { |v| "#{key}[]=#{CGI.escape(v.to_s)}" }.join("&") + value.map { |v| "#{key}[]=#{CGI.escape(v.to_s)}" }.join('&') else "#{key}=#{CGI.escape(value.to_s)}" end - end.compact.join("&") + end.compact.join('&') end def headers(options = {}) { - "Authorization" => "Basic " + Base64.encode64(@api_key.to_s + ":x").strip, - "User-Agent" => "Pagar.me/1 ActiveMerchant/#{ActiveMerchant::VERSION}", - "Accept-Encoding" => "deflate" + 'Authorization' => 'Basic ' + Base64.encode64(@api_key.to_s + ':x').strip, + 'User-Agent' => "Pagar.me/1 ActiveMerchant/#{ActiveMerchant::VERSION}", + 'Accept-Encoding' => 'deflate' } end @@ -186,61 +186,61 @@ def json_error(raw_response) msg = 'Resposta inválida retornada pela API do Pagar.me. Por favor entre em contato com suporte@pagar.me se você continuar recebendo essa mensagem.' msg += " (A resposta retornada pela API foi #{raw_response.inspect})" { - "errors" => [{ - "message" => msg + 'errors' => [{ + 'message' => msg }] } end def success_from(response) - success_purchase = response.key?("status") && response["status"] == "paid" - success_authorize = response.key?("status") && response["status"] == "authorized" - success_refund = response.key?("status") && response["status"] == "refunded" + success_purchase = response.key?('status') && response['status'] == 'paid' + success_authorize = response.key?('status') && response['status'] == 'authorized' + success_refund = response.key?('status') && response['status'] == 'refunded' success_purchase || success_authorize || success_refund end def failure_from(response) - response.key?("status") && response["status"] == "refused" + response.key?('status') && response['status'] == 'refused' end def message_from(response) if success_from(response) - case response["status"] - when "paid" - "Transação aprovada" - when "authorized" - "Transação autorizada" - when "refunded" - "Transação estornada" + case response['status'] + when 'paid' + 'Transação aprovada' + when 'authorized' + 'Transação autorizada' + when 'refunded' + 'Transação estornada' else "Transação com status '#{response["status"]}'" end elsif failure_from(response) - "Transação recusada" - elsif response.key?("errors") - response["errors"][0]["message"] + 'Transação recusada' + elsif response.key?('errors') + response['errors'][0]['message'] else msg = json_error(response) - msg["errors"][0]["message"] + msg['errors'][0]['message'] end end def authorization_from(response) if success_from(response) - response["id"] + response['id'] end end def test?() - @api_key.start_with?("ak_test") + @api_key.start_with?('ak_test') end def error_code_from(response) if failure_from(response) - STANDARD_ERROR_CODE_MAPPING["refused"] - elsif response.key?("errors") - STANDARD_ERROR_CODE_MAPPING["processing_error"] + STANDARD_ERROR_CODE_MAPPING['refused'] + elsif response.key?('errors') + STANDARD_ERROR_CODE_MAPPING['processing_error'] end end end diff --git a/lib/active_merchant/billing/gateways/pago_facil.rb b/lib/active_merchant/billing/gateways/pago_facil.rb index 49d2bf72c12..85793fbb369 100644 --- a/lib/active_merchant/billing/gateways/pago_facil.rb +++ b/lib/active_merchant/billing/gateways/pago_facil.rb @@ -63,7 +63,7 @@ def add_payment(post, credit_card) post[:apellidos] = credit_card.last_name post[:numeroTarjeta] = credit_card.number post[:cvt] = credit_card.verification_value - post[:mesExpiracion] = sprintf("%02d", credit_card.month) + post[:mesExpiracion] = sprintf('%02d', credit_card.month) post[:anyoExpiracion] = credit_card.year.to_s.slice(-2, 2) end @@ -74,7 +74,7 @@ def add_merchant_data(post) end def parse(body) - JSON.parse(body)["WebServices_Transacciones"]["transaccion"] + JSON.parse(body)['WebServices_Transacciones']['transaccion'] rescue JSON::ParserError json_error(body) end @@ -92,16 +92,16 @@ def commit(parameters) end def success_from(response) - response["autorizado"] == "1" || - response["autorizado"] == true + response['autorizado'] == '1' || + response['autorizado'] == true end def message_from(response) - response["texto"] + response['texto'] end def authorization_from(response) - response["autorizacion"] + response['autorizacion'] end def post_data(parameters = {}) @@ -113,8 +113,8 @@ def post_data(parameters = {}) def json_error(response) { - "texto" => 'Invalid response received from the PagoFacil API.', - "raw_response" => response + 'texto' => 'Invalid response received from the PagoFacil API.', + 'raw_response' => response } end end diff --git a/lib/active_merchant/billing/gateways/pay_conex.rb b/lib/active_merchant/billing/gateways/pay_conex.rb index 0161ca0ac3f..bb97a65cde7 100644 --- a/lib/active_merchant/billing/gateways/pay_conex.rb +++ b/lib/active_merchant/billing/gateways/pay_conex.rb @@ -3,15 +3,15 @@ module Billing #:nodoc: class PayConexGateway < Gateway include Empty - self.test_url = "https://cert.payconex.net/api/qsapi/3.8/" - self.live_url = "https://secure.payconex.net/api/qsapi/3.8/" + self.test_url = 'https://cert.payconex.net/api/qsapi/3.8/' + self.live_url = 'https://secure.payconex.net/api/qsapi/3.8/' self.supported_countries = %w(US CA) - self.default_currency = "USD" + self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club] - self.homepage_url = "http://www.bluefincommerce.com/" - self.display_name = "PayConex" + self.homepage_url = 'http://www.bluefincommerce.com/' + self.display_name = 'PayConex' def initialize(options={}) requires!(options, :account_id, :api_accesskey) @@ -21,43 +21,43 @@ def initialize(options={}) def purchase(money, payment_method, options={}) post = {} add_auth_purchase_params(post, money, payment_method, options) - commit("SALE", post) + commit('SALE', post) end def authorize(money, payment_method, options={}) post = {} add_auth_purchase_params(post, money, payment_method, options) - commit("AUTHORIZATION", post) + commit('AUTHORIZATION', post) end def capture(money, authorization, options={}) post = {} add_reference_params(post, authorization, options) add_amount(post, money, options) - commit("CAPTURE", post) + commit('CAPTURE', post) end def refund(money, authorization, options={}) post = {} add_reference_params(post, authorization, options) add_amount(post, money, options) - commit("REFUND", post) + commit('REFUND', post) end def void(authorization, options = {}) post = {} add_reference_params(post, authorization, options) - commit("REVERSAL", post) + commit('REVERSAL', post) end def credit(money, payment_method, options={}) if payment_method.is_a?(String) - raise ArgumentError, "Reference credits are not supported. Please supply the original credit card or use the #refund method." + raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card or use the #refund method.' end post = {} add_auth_purchase_params(post, money, payment_method, options) - commit("CREDIT", post) + commit('CREDIT', post) end def verify(payment_method, options={}) @@ -70,7 +70,7 @@ def store(payment_method, options={}) add_payment_method(post, payment_method) add_address(post, options) add_common_options(post, options) - commit("STORE", post) + commit('STORE', post) end def supports_scrubbing? @@ -88,8 +88,8 @@ def scrub(transcript) def force_utf8(string) return nil unless string - binary = string.encode("BINARY", invalid: :replace, undef: :replace, replace: "?") # Needed for Ruby 2.0 since #encode is a no-op if the string is already UTF-8. It's not needed for Ruby 2.1 and up since it's not a no-op there. - binary.encode("UTF-8", invalid: :replace, undef: :replace, replace: "?") + binary = string.encode('BINARY', invalid: :replace, undef: :replace, replace: '?') # Needed for Ruby 2.0 since #encode is a no-op if the string is already UTF-8. It's not needed for Ruby 2.1 and up since it's not a no-op there. + binary.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') end def add_credentials(post) @@ -134,7 +134,7 @@ def add_payment_method(post, payment_method) end def add_credit_card(post, payment_method) - post[:tender_type] = "CARD" + post[:tender_type] = 'CARD' post[:card_number] = payment_method.number post[:card_expiration] = expdate(payment_method) post[:card_verification] = payment_method.verification_value @@ -143,18 +143,18 @@ def add_credit_card(post, payment_method) end def add_token_payment_method(post, payment_method) - post[:tender_type] = "CARD" + post[:tender_type] = 'CARD' post[:token_id] = payment_method post[:reissue] = true end def add_card_present_payment_method(post, payment_method) - post[:tender_type] = "CARD" + post[:tender_type] = 'CARD' post[:card_tracks] = payment_method.track_data end def add_check(post, payment_method) - post[:tender_type] = "ACH" + post[:tender_type] = 'ACH' post[:first_name] = payment_method.first_name post[:last_name] = payment_method.last_name post[:bank_account_number] = payment_method.account_number @@ -208,9 +208,9 @@ def commit(action, params) success_from(response), message_from(response), response, - authorization: response["transaction_id"], - :avs_result => AVSResult.new(code: response["avs_response"]), - :cvv_result => CVVResult.new(response["cvv2_response"]), + authorization: response['transaction_id'], + :avs_result => AVSResult.new(code: response['avs_response']), + :cvv_result => CVVResult.new(response['cvv2_response']), test: test? ) @@ -223,11 +223,11 @@ def url end def success_from(response) - response["transaction_approved"] || !response["error"] + response['transaction_approved'] || !response['error'] end def message_from(response) - success_from(response) ? response["authorization_message"] : response["error_message"] + success_from(response) ? response['authorization_message'] : response['error_message'] end def post_data(action, params) @@ -236,7 +236,7 @@ def post_data(action, params) end def unparsable_response(raw_response) - message = "Invalid JSON response received from PayConex. Please contact PayConex if you continue to receive this message." + message = 'Invalid JSON response received from PayConex. Please contact PayConex if you continue to receive this message.' message += " (The raw response returned by the API was #{raw_response.inspect})" return Response.new(false, message) end diff --git a/lib/active_merchant/billing/gateways/pay_gate_xml.rb b/lib/active_merchant/billing/gateways/pay_gate_xml.rb index 86b2d5d8f30..55c9b7b67af 100644 --- a/lib/active_merchant/billing/gateways/pay_gate_xml.rb +++ b/lib/active_merchant/billing/gateways/pay_gate_xml.rb @@ -102,45 +102,45 @@ class PayGateXmlGateway < Gateway DECLINE_CODES = { # Credit Card Errors - These RESULT_CODEs are returned if the transaction cannot be authorized due to a problem with the card. The TRANSACTION_STATUS will be 2 - 900001 => "Call for Approval", - 900002 => "Card Expired", - 900003 => "Insufficient Funds", - 900004 => "Invalid Card Number", - 900005 => "Bank Interface Timeout", # indicates a communications failure between the banks systems - 900006 => "Invalid Card", - 900007 => "Declined", - 900009 => "Lost Card", - 900010 => "Invalid Card Length", - 900011 => "Suspected Fraud", - 900012 => "Card Reported As Stolen", - 900013 => "Restricted Card", - 900014 => "Excessive Card Usage", - 900015 => "Card Blacklisted", - - 900207 => "Declined; authentication failed", # indicates the cardholder did not enter their MasterCard SecureCode / Verified by Visa password correctly - - 990020 => "Auth Declined", - - 991001 => "Invalid expiry date", - 991002 => "Invalid amount", + 900001 => 'Call for Approval', + 900002 => 'Card Expired', + 900003 => 'Insufficient Funds', + 900004 => 'Invalid Card Number', + 900005 => 'Bank Interface Timeout', # indicates a communications failure between the banks systems + 900006 => 'Invalid Card', + 900007 => 'Declined', + 900009 => 'Lost Card', + 900010 => 'Invalid Card Length', + 900011 => 'Suspected Fraud', + 900012 => 'Card Reported As Stolen', + 900013 => 'Restricted Card', + 900014 => 'Excessive Card Usage', + 900015 => 'Card Blacklisted', + + 900207 => 'Declined; authentication failed', # indicates the cardholder did not enter their MasterCard SecureCode / Verified by Visa password correctly + + 990020 => 'Auth Declined', + + 991001 => 'Invalid expiry date', + 991002 => 'Invalid amount', # Communication Errors - These RESULT_CODEs are returned if the transaction cannot be completed due to an unexpected error. TRANSACTION_STATUS will be 0. - 900205 => "Unexpected authentication result (phase 1)", - 900206 => "Unexpected authentication result (phase 1)", + 900205 => 'Unexpected authentication result (phase 1)', + 900206 => 'Unexpected authentication result (phase 1)', - 990001 => "Could not insert into Database", + 990001 => 'Could not insert into Database', - 990022 => "Bank not available", + 990022 => 'Bank not available', - 990053 => "Error processing transaction", + 990053 => 'Error processing transaction', # Miscellaneous - Unless otherwise noted, the TRANSACTION_STATUS will be 0. - 900209 => "Transaction verification failed (phase 2)", # Indicates the verification data returned from MasterCard SecureCode / Verified by Visa has been altered - 900210 => "Authentication complete; transaction must be restarted", # Indicates that the MasterCard SecuerCode / Verified by Visa transaction has already been completed. Most likely caused by the customer clicking the refresh button + 900209 => 'Transaction verification failed (phase 2)', # Indicates the verification data returned from MasterCard SecureCode / Verified by Visa has been altered + 900210 => 'Authentication complete; transaction must be restarted', # Indicates that the MasterCard SecuerCode / Verified by Visa transaction has already been completed. Most likely caused by the customer clicking the refresh button - 990024 => "Duplicate Transaction Detected. Please check before submitting", + 990024 => 'Duplicate Transaction Detected. Please check before submitting', - 990028 => "Transaction cancelled" # Customer clicks the 'Cancel' button on the payment page + 990028 => 'Transaction cancelled' # Customer clicks the 'Cancel' button on the payment page } SUCCESS_CODES = %w( 990004 990005 990017 990012 990018 990031 ) @@ -210,7 +210,7 @@ def build_request(action, options={}) when 'refundtx' build_refund(protocol, money, authorization, options) else - raise "no action specified for build_request" + raise 'no action specified for build_request' end end diff --git a/lib/active_merchant/billing/gateways/pay_hub.rb b/lib/active_merchant/billing/gateways/pay_hub.rb index afd6be918c2..d354f5c1db9 100644 --- a/lib/active_merchant/billing/gateways/pay_hub.rb +++ b/lib/active_merchant/billing/gateways/pay_hub.rb @@ -19,32 +19,32 @@ class PayHubGateway < Gateway } AVS_CODE_TRANSLATOR = { - '0' => "Approved, Address verification was not requested.", - 'A' => "Approved, Address matches only.", - 'B' => "Address Match. Street Address math for international transaction Postal Code not verified because of incompatible formats (Acquirer sent both street address and Postal Code)", - 'C' => "Serv Unavailable. Street address and Postal Code not verified for international transaction because of incompatible formats (Acquirer sent both street and Postal Code).", - 'D' => "Exact Match, Street Address and Postal Code match for international transaction.", - 'F' => "Exact Match, Street Address and Postal Code match. Applies to UK only.", - 'G' => "Ver Unavailable, Non-U.S. Issuer does not participate.", - 'I' => "Ver Unavailable, Address information not verified for international transaction", - 'M' => "Exact Match, Street Address and Postal Code match for international transaction", - 'N' => "No - Address and ZIP Code does not match", - 'P' => "Zip Match, Postal Codes match for international transaction Street address not verified because of incompatible formats (Acquirer sent both street address and Postal Code).", - 'R' => "Retry - Issuer system unavailable", - 'S' => "Serv Unavailable, Service not supported", - 'U' => "Ver Unavailable, Address unavailable.", - 'W' => "ZIP match - Nine character numeric ZIP match only.", - 'X' => "Exact match, Address and nine-character ZIP match.", - 'Y' => "Exact Match, Address and five character ZIP match.", - 'Z' => "Zip Match, Five character numeric ZIP match only.", - '1' => "Cardholder name and ZIP match AMEX only.", - '2' => "Cardholder name, address, and ZIP match AMEX only.", - '3' => "Cardholder name and address match AMEX only.", - '4' => "Cardholder name match AMEX only.", - '5' => "Cardholder name incorrect, ZIP match AMEX only.", - '6' => "Cardholder name incorrect, address and ZIP match AMEX only.", - '7' => "Cardholder name incorrect, address match AMEX only.", - '8' => "Cardholder, all do not match AMEX only." + '0' => 'Approved, Address verification was not requested.', + 'A' => 'Approved, Address matches only.', + 'B' => 'Address Match. Street Address math for international transaction Postal Code not verified because of incompatible formats (Acquirer sent both street address and Postal Code)', + 'C' => 'Serv Unavailable. Street address and Postal Code not verified for international transaction because of incompatible formats (Acquirer sent both street and Postal Code).', + 'D' => 'Exact Match, Street Address and Postal Code match for international transaction.', + 'F' => 'Exact Match, Street Address and Postal Code match. Applies to UK only.', + 'G' => 'Ver Unavailable, Non-U.S. Issuer does not participate.', + 'I' => 'Ver Unavailable, Address information not verified for international transaction', + 'M' => 'Exact Match, Street Address and Postal Code match for international transaction', + 'N' => 'No - Address and ZIP Code does not match', + 'P' => 'Zip Match, Postal Codes match for international transaction Street address not verified because of incompatible formats (Acquirer sent both street address and Postal Code).', + 'R' => 'Retry - Issuer system unavailable', + 'S' => 'Serv Unavailable, Service not supported', + 'U' => 'Ver Unavailable, Address unavailable.', + 'W' => 'ZIP match - Nine character numeric ZIP match only.', + 'X' => 'Exact match, Address and nine-character ZIP match.', + 'Y' => 'Exact Match, Address and five character ZIP match.', + 'Z' => 'Zip Match, Five character numeric ZIP match only.', + '1' => 'Cardholder name and ZIP match AMEX only.', + '2' => 'Cardholder name, address, and ZIP match AMEX only.', + '3' => 'Cardholder name and address match AMEX only.', + '4' => 'Cardholder name match AMEX only.', + '5' => 'Cardholder name incorrect, ZIP match AMEX only.', + '6' => 'Cardholder name incorrect, address and ZIP match AMEX only.', + '7' => 'Cardholder name incorrect, address match AMEX only.', + '8' => 'Cardholder, all do not match AMEX only.' } STANDARD_ERROR_CODE_MAPPING = { @@ -173,7 +173,7 @@ def commit(post) begin raw_response = ssl_post(live_url, post.to_json, {'Content-Type' => 'application/json'} ) response = parse(raw_response) - success = (response['RESPONSE_CODE'] == "00") + success = (response['RESPONSE_CODE'] == '00') rescue ResponseError => e raw_response = e.response.body response = response_error(raw_response) @@ -200,13 +200,13 @@ def response_error(raw_response) def json_error(raw_response) { - error_message: "Invalid response received from the Payhub API. Please contact wecare@payhub.com if you continue to receive this message." + + error_message: 'Invalid response received from the Payhub API. Please contact wecare@payhub.com if you continue to receive this message.' + " (The raw response returned by the API was #{raw_response.inspect})" } end def response_message(response) - (response['RESPONSE_TEXT'] || response["RESPONSE_CODE"] || response[:error_message]) + (response['RESPONSE_TEXT'] || response['RESPONSE_CODE'] || response[:error_message]) end end end diff --git a/lib/active_merchant/billing/gateways/pay_junction.rb b/lib/active_merchant/billing/gateways/pay_junction.rb index 57a3f7356bd..5255ef2106d 100644 --- a/lib/active_merchant/billing/gateways/pay_junction.rb +++ b/lib/active_merchant/billing/gateways/pay_junction.rb @@ -101,19 +101,19 @@ class PayJunctionGateway < Gateway class_attribute :test_url, :live_url - self.test_url = "https://www.payjunctionlabs.com/quick_link" - self.live_url = "https://payjunction.com/quick_link" + self.test_url = 'https://www.payjunctionlabs.com/quick_link' + self.live_url = 'https://payjunction.com/quick_link' TEST_LOGIN = 'pj-ql-01' TEST_PASSWORD = 'pj-ql-01p' - SUCCESS_CODES = ["00", "85"] + SUCCESS_CODES = ['00', '85'] SUCCESS_MESSAGE = 'The transaction was approved.' FAILURE_MESSAGE = 'The transaction was declined.' DECLINE_CODES = { - "AE" => 'Address verification failed because address did not match.', + 'AE' => 'Address verification failed because address did not match.', 'ZE' => 'Address verification failed because zip did not match.', 'XE' => 'Address verification failed because zip and address did not match.', 'YE' => 'Address verification failed because zip and address did not match.', @@ -144,8 +144,8 @@ class PayJunctionGateway < Gateway '96' => 'Declined because of a system error.', 'N7' => 'Declined because of a CVV2/CVC2 mismatch.', 'M4' => 'Declined.', - "FE" => "There was a format error with your Trinity Gateway Service (API) request.", - "LE" => "Could not log you in (problem with dc_logon and/or dc_password).", + 'FE' => 'There was a format error with your Trinity Gateway Service (API) request.', + 'LE' => 'Could not log you in (problem with dc_logon and/or dc_password).', 'NL' => 'Aborted because of a system error, please try again later. ', 'AB' => 'Aborted because of an upstream system error, please try again later.' } @@ -366,7 +366,7 @@ def post_data(action, params) params[:version] = API_VERSION params[:transaction_type] = action - params.reject{|k,v| v.blank?}.collect{ |k, v| "dc_#{k.to_s}=#{CGI.escape(v.to_s)}" }.join("&") + params.reject{|k,v| v.blank?}.collect{ |k, v| "dc_#{k.to_s}=#{CGI.escape(v.to_s)}" }.join('&') end def parse(body) diff --git a/lib/active_merchant/billing/gateways/pay_junction_v2.rb b/lib/active_merchant/billing/gateways/pay_junction_v2.rb index f93aea23655..9cac25e238a 100644 --- a/lib/active_merchant/billing/gateways/pay_junction_v2.rb +++ b/lib/active_merchant/billing/gateways/pay_junction_v2.rb @@ -1,14 +1,14 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class PayJunctionV2Gateway < Gateway - self.display_name = "PayJunction" - self.homepage_url = "https://www.payjunction.com/" + self.display_name = 'PayJunction' + self.homepage_url = 'https://www.payjunction.com/' - self.test_url = "https://api.payjunctionlabs.com/transactions" - self.live_url = "https://api.payjunction.com/transactions" + self.test_url = 'https://api.payjunctionlabs.com/transactions' + self.live_url = 'https://api.payjunction.com/transactions' - self.supported_countries = ["US"] - self.default_currency = "USD" + self.supported_countries = ['US'] + self.default_currency = 'USD' self.money_format = :dollars self.supported_cardtypes = [:visa, :master, :american_express, :discover] @@ -22,51 +22,51 @@ def purchase(amount, payment_method, options={}) add_invoice(post, amount, options) add_payment_method(post, payment_method) - commit("purchase", post) + commit('purchase', post) end def authorize(amount, payment_method, options={}) post = {} - post[:status] = "HOLD" + post[:status] = 'HOLD' add_invoice(post, amount, options) add_payment_method(post, payment_method) - commit("authorize", post) + commit('authorize', post) end def capture(amount, authorization, options={}) post = {} - post[:status] = "CAPTURE" + post[:status] = 'CAPTURE' post[:transactionId] = authorization add_invoice(post, amount, options) - commit("capture", post) + commit('capture', post) end def void(authorization, options={}) post = {} - post[:status] = "VOID" + post[:status] = 'VOID' post[:transactionId] = authorization - commit("void", post) + commit('void', post) end def refund(amount, authorization, options={}) post = {} - post[:action] = "REFUND" + post[:action] = 'REFUND' post[:transactionId] = authorization add_invoice(post, amount, options) - commit("refund", post) + commit('refund', post) end def credit(amount, payment_method, options={}) post = {} - post[:action] = "REFUND" + post[:action] = 'REFUND' add_invoice(post, amount, options) add_payment_method(post, payment_method) - commit("credit", post) + commit('credit', post) end def verify(credit_card, options={}) @@ -129,7 +129,7 @@ def commit(action, params) end def ssl_invoke(action, params) - if ["purchase", "authorize", "refund", "credit"].include?(action) + if ['purchase', 'authorize', 'refund', 'credit'].include?(action) ssl_post(url(), post_data(params), headers) else ssl_request(:put, url(params), post_data(params), headers) @@ -138,10 +138,10 @@ def ssl_invoke(action, params) def headers { - "Authorization" => "Basic " + Base64.encode64("#{@options[:api_login]}:#{@options[:api_password]}").strip, - "Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8", - "Accept" => "application/json", - "X-PJ-Application-Key" => "#{@options[:api_key]}" + 'Authorization' => 'Basic ' + Base64.encode64("#{@options[:api_login]}:#{@options[:api_password]}").strip, + 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8', + 'Accept' => 'application/json', + 'X-PJ-Application-Key' => "#{@options[:api_key]}" } end @@ -157,33 +157,33 @@ def parse(body) begin JSON.parse(body) rescue JSON::ParserError - message = "Invalid JSON response received from PayJunctionV2Gateway. Please contact PayJunctionV2Gateway if you continue to receive this message." + message = 'Invalid JSON response received from PayJunctionV2Gateway. Please contact PayJunctionV2Gateway if you continue to receive this message.' message += " (The raw response returned by the API was #{body.inspect})" { - "errors" => [{ - "message" => message + 'errors' => [{ + 'message' => message }] } end end def success_from(response) - return response["response"]["approved"] if response["response"] + return response['response']['approved'] if response['response'] false end def message_from(response) - return response["response"]["message"] if response["response"] + return response['response']['message'] if response['response'] - response["errors"].inject(""){ |message,error| error["message"] + "|" + message } if response["errors"] + response['errors'].inject(''){ |message,error| error['message'] + '|' + message } if response['errors'] end def authorization_from(response) - response["transactionId"] + response['transactionId'] end def error_from(response) - response["response"]["code"] if response["response"] + response['response']['code'] if response['response'] end end end diff --git a/lib/active_merchant/billing/gateways/pay_secure.rb b/lib/active_merchant/billing/gateways/pay_secure.rb index 0faeaef2cf5..10dcbfbed57 100644 --- a/lib/active_merchant/billing/gateways/pay_secure.rb +++ b/lib/active_merchant/billing/gateways/pay_secure.rb @@ -41,7 +41,7 @@ def purchase(money, credit_card, options = {}) private # Used for capturing, which is currently not supported. def add_reference(post, identification) - auth, trans_id = identification.split(";") + auth, trans_id = identification.split(';') post[:authnum] = auth post[:transid] = trans_id end @@ -79,7 +79,7 @@ def successful?(response) end def authorization_from(response) - [ response[:authnum], response[:transid] ].compact.join(";") + [ response[:authnum], response[:transid] ].compact.join(';') end def test_response?(response) @@ -93,7 +93,7 @@ def message_from(response) def parse(body) response = {} body.to_s.each_line do |l| - key, value = l.split(":", 2) + key, value = l.split(':', 2) response[key.to_s.downcase.to_sym] = value.strip end response @@ -104,7 +104,7 @@ def post_data(action, parameters = {}) parameters[:merchant_id] = @options[:login] parameters[:password] = @options[:password] - parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join("&") + parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/paybox_direct.rb b/lib/active_merchant/billing/gateways/paybox_direct.rb index b4fd36a97c4..4e51c84ba0c 100644 --- a/lib/active_merchant/billing/gateways/paybox_direct.rb +++ b/lib/active_merchant/billing/gateways/paybox_direct.rb @@ -21,20 +21,20 @@ class PayboxDirectGateway < Gateway } CURRENCY_CODES = { - "AUD"=> '036', - "CAD"=> '124', - "CZK"=> '203', - "DKK"=> '208', - "HKD"=> '344', - "ICK"=> '352', - "JPY"=> '392', - "NOK"=> '578', - "SGD"=> '702', - "SEK"=> '752', - "CHF"=> '756', - "GBP"=> '826', - "USD"=> '840', - "EUR"=> '978' + 'AUD'=> '036', + 'CAD'=> '124', + 'CZK'=> '203', + 'DKK'=> '208', + 'HKD'=> '344', + 'ICK'=> '352', + 'JPY'=> '392', + 'NOK'=> '578', + 'SGD'=> '702', + 'SEK'=> '752', + 'CHF'=> '756', + 'GBP'=> '826', + 'USD'=> '840', + 'EUR'=> '978' } SUCCESS_CODES = ['00000'] @@ -187,7 +187,7 @@ def post_data(action, parameters = {}) :archivage => parameters[:order_id] ) - parameters.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join("&") + parameters.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&') end def unique_id(seed = 0) diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index b26f74a710a..fb8609b526a 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -159,8 +159,8 @@ def add_payment_method(params, payment_method, options) def add_echeck(params, echeck, options) tele_check = {} - tele_check[:check_number] = echeck.number || "001" - tele_check[:check_type] = "P" + tele_check[:check_number] = echeck.number || '001' + tele_check[:check_type] = 'P' tele_check[:routing_number] = echeck.routing_number tele_check[:account_number] = echeck.account_number tele_check[:accountholder_name] = "#{echeck.first_name} #{echeck.last_name}" @@ -281,7 +281,7 @@ def api_request(url, params) def post_data(params) return nil unless params - params.reject { |k, v| v.blank? }.collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join("&") + params.reject { |k, v| v.blank? }.collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') end def generate_hmac(nonce, current_timestamp, payload) @@ -291,7 +291,7 @@ def generate_hmac(nonce, current_timestamp, payload) current_timestamp.to_s, @options[:token], payload - ].join("") + ].join('') hash = Base64.strict_encode64(OpenSSL::HMAC.hexdigest('sha256', @options[:apisecret], message)) hash end @@ -379,7 +379,7 @@ def response_error(raw_response) end def json_error(raw_response) - {"error" => "Unable to parse response: #{raw_response.inspect}"} + {'error' => "Unable to parse response: #{raw_response.inspect}"} end end end diff --git a/lib/active_merchant/billing/gateways/payex.rb b/lib/active_merchant/billing/gateways/payex.rb index 047effa7f10..3a63f379872 100644 --- a/lib/active_merchant/billing/gateways/payex.rb +++ b/lib/active_merchant/billing/gateways/payex.rb @@ -1,4 +1,4 @@ -require "nokogiri" +require 'nokogiri' module ActiveMerchant #:nodoc: module Billing #:nodoc: @@ -16,7 +16,7 @@ class PayexGateway < Gateway self.supported_cardtypes = [:visa, :master, :american_express, :discover] self.homepage_url = 'http://payex.com/' self.display_name = 'Payex' - self.default_currency = "EUR" + self.default_currency = 'EUR' TRANSACTION_STATUS = { sale: '0', @@ -360,11 +360,11 @@ def parse(xml) response = {} xmldoc = Nokogiri::XML(xml) - body = xmldoc.xpath("//soap:Body/*[1]")[0].inner_text + body = xmldoc.xpath('//soap:Body/*[1]')[0].inner_text doc = Nokogiri::XML(body) - doc.root.xpath("*").each do |node| + doc.root.xpath('*').each do |node| if (node.elements.size == 0) response[node.name.downcase.to_sym] = node.text else diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb index 523d3c746c5..da13e3a1d40 100644 --- a/lib/active_merchant/billing/gateways/payflow.rb +++ b/lib/active_merchant/billing/gateways/payflow.rb @@ -56,8 +56,8 @@ def verify(payment, options={}) end def verify_credentials - response = void("0") - response.params["result"] != "26" + response = void('0') + response.params['result'] != '26' end # Adds or modifies a recurring Payflow profile. See the Payflow Pro Recurring Billing Guide for more details: @@ -252,8 +252,8 @@ def credit_card_type(credit_card) end def expdate(creditcard) - year = sprintf("%.4i", creditcard.year.to_s.sub(/^0+/, '')) - month = sprintf("%.2i", creditcard.month.to_s.sub(/^0+/, '')) + year = sprintf('%.4i', creditcard.year.to_s.sub(/^0+/, '')) + month = sprintf('%.2i', creditcard.month.to_s.sub(/^0+/, '')) "#{year}#{month}" end @@ -309,10 +309,10 @@ def build_recurring_request(action, money, options) end end if action != :add - xml.tag! "ProfileID", options[:profile_id] + xml.tag! 'ProfileID', options[:profile_id] end if action == :inquiry - xml.tag! "PaymentHistory", ( options[:history] ? 'Y' : 'N' ) + xml.tag! 'PaymentHistory', ( options[:history] ? 'Y' : 'N' ) end end end @@ -335,7 +335,7 @@ def get_pay_period(options) def format_rp_date(time) case time - when Time, Date then time.strftime("%m%d%Y") + when Time, Date then time.strftime('%m%d%Y') else time.to_s end diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb index 82820e6dcd4..fc0b78a5013 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb @@ -48,11 +48,11 @@ def self.included(base) } TRANSACTIONS = { - :purchase => "Sale", - :authorization => "Authorization", - :capture => "Capture", - :void => "Void", - :credit => "Credit" + :purchase => 'Sale', + :authorization => 'Authorization', + :capture => 'Capture', + :void => 'Void', + :credit => 'Credit' } CVV_CODE = { @@ -83,7 +83,7 @@ def void(authorization, options = {}) def build_request(body, options = {}) xml = Builder::XmlMarkup.new xml.instruct! - xml.tag! 'XMLPayRequest', 'Timeout' => timeout.to_s, 'version' => "2.1", "xmlns" => XMLNS do + xml.tag! 'XMLPayRequest', 'Timeout' => timeout.to_s, 'version' => '2.1', 'xmlns' => XMLNS do xml.tag! 'RequestData' do xml.tag! 'Vendor', @options[:login] xml.tag! 'Partner', @options[:partner] @@ -139,7 +139,7 @@ def add_address(xml, tag, address, options) xml.tag! 'Street', address[:address1] unless address[:address1].blank? xml.tag! 'Street2', address[:address2] unless address[:address2].blank? xml.tag! 'City', address[:city] unless address[:city].blank? - xml.tag! 'State', address[:state].blank? ? "N/A" : address[:state] + xml.tag! 'State', address[:state].blank? ? 'N/A' : address[:state] xml.tag! 'Country', address[:country] unless address[:country].blank? xml.tag! 'Zip', address[:zip] unless address[:zip].blank? end @@ -150,16 +150,16 @@ def parse(data) response = {} xml = Nokogiri::XML(data) xml.remove_namespaces! - root = xml.xpath("//ResponseData") + root = xml.xpath('//ResponseData') # REXML::XPath in Ruby 1.8.6 is now unable to match nodes based on their attributes - tx_result = root.xpath(".//TransactionResult").first + tx_result = root.xpath('.//TransactionResult').first - if tx_result && tx_result.attributes['Duplicate'].to_s == "true" + if tx_result && tx_result.attributes['Duplicate'].to_s == 'true' response[:duplicate] = true end - root.xpath(".//*").each do |node| + root.xpath('.//*').each do |node| parse_element(response, node) end @@ -175,9 +175,9 @@ def parse_element(response, node) # in an RPPaymentResults element so we'll come here multiple times response[node_name] ||= [] response[node_name] << ( payment_result_response = {} ) - node.xpath(".//*").each{ |e| parse_element(payment_result_response, e) } - when node.xpath(".//*").to_a.any? - node.xpath(".//*").each{|e| parse_element(response, e) } + node.xpath('.//*').each{ |e| parse_element(payment_result_response, e) } + when node.xpath('.//*').to_a.any? + node.xpath('.//*').each{|e| parse_element(response, e) } when node_name.to_s =~ /amt$/ # *Amt elements don't put the value in the #text - instead they use a Currency attribute response[node_name] = node.attributes['Currency'].to_s @@ -190,15 +190,15 @@ def parse_element(response, node) def build_headers(content_length) headers = { - "Content-Type" => "text/xml", - "Content-Length" => content_length.to_s, - "X-VPS-Client-Timeout" => timeout.to_s, - "X-VPS-VIT-Integration-Product" => "ActiveMerchant", - "X-VPS-VIT-Runtime-Version" => RUBY_VERSION, - "X-VPS-Request-ID" => SecureRandom.hex(16) + 'Content-Type' => 'text/xml', + 'Content-Length' => content_length.to_s, + 'X-VPS-Client-Timeout' => timeout.to_s, + 'X-VPS-VIT-Integration-Product' => 'ActiveMerchant', + 'X-VPS-VIT-Runtime-Version' => RUBY_VERSION, + 'X-VPS-Request-ID' => SecureRandom.hex(16) } - headers.merge!("PAYPAL-NVP" => "Y") if self.use_paypal_nvp + headers.merge!('PAYPAL-NVP' => 'Y') if self.use_paypal_nvp headers end @@ -224,7 +224,7 @@ def success_for(response) end def under_fraud_review?(response) - (response[:result] == "126") + (response[:result] == '126') end end end diff --git a/lib/active_merchant/billing/gateways/payflow_express.rb b/lib/active_merchant/billing/gateways/payflow_express.rb index 25f31b19787..d2e0b27ede5 100644 --- a/lib/active_merchant/billing/gateways/payflow_express.rb +++ b/lib/active_merchant/billing/gateways/payflow_express.rb @@ -178,7 +178,7 @@ def add_pay_data(xml, money, options) end if items.any? xml.tag! 'ExtData', 'Name' => 'CURRENCY', 'Value' => options[:currency] || currency(money) - xml.tag! 'ExtData', 'Name' => "ITEMAMT", 'Value' => amount(options[:subtotal] || money) + xml.tag! 'ExtData', 'Name' => 'ITEMAMT', 'Value' => amount(options[:subtotal] || money) end xml.tag! 'DiscountAmt', amount(options[:discount]) if options[:discount] xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money) diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb index f8a1cc41df2..b78e112a8f0 100644 --- a/lib/active_merchant/billing/gateways/payment_express.rb +++ b/lib/active_merchant/billing/gateways/payment_express.rb @@ -176,66 +176,66 @@ def build_token_request(credit_card, options) end def add_credentials(xml) - xml.add_element("PostUsername").text = @options[:login] - xml.add_element("PostPassword").text = @options[:password] + xml.add_element('PostUsername').text = @options[:login] + xml.add_element('PostPassword').text = @options[:password] end def add_reference(xml, identification) - xml.add_element("DpsTxnRef").text = identification + xml.add_element('DpsTxnRef').text = identification end def add_credit_card(xml, credit_card) - xml.add_element("CardHolderName").text = credit_card.name - xml.add_element("CardNumber").text = credit_card.number - xml.add_element("DateExpiry").text = format_date(credit_card.month, credit_card.year) + xml.add_element('CardHolderName').text = credit_card.name + xml.add_element('CardNumber').text = credit_card.number + xml.add_element('DateExpiry').text = format_date(credit_card.month, credit_card.year) if credit_card.verification_value? - xml.add_element("Cvc2").text = credit_card.verification_value - xml.add_element("Cvc2Presence").text = "1" + xml.add_element('Cvc2').text = credit_card.verification_value + xml.add_element('Cvc2Presence').text = '1' end if requires_start_date_or_issue_number?(credit_card) - xml.add_element("DateStart").text = format_date(credit_card.start_month, credit_card.start_year) unless credit_card.start_month.blank? || credit_card.start_year.blank? - xml.add_element("IssueNumber").text = credit_card.issue_number unless credit_card.issue_number.blank? + xml.add_element('DateStart').text = format_date(credit_card.start_month, credit_card.start_year) unless credit_card.start_month.blank? || credit_card.start_year.blank? + xml.add_element('IssueNumber').text = credit_card.issue_number unless credit_card.issue_number.blank? end end def add_billing_token(xml, token) if use_custom_payment_token? - xml.add_element("BillingId").text = token + xml.add_element('BillingId').text = token else - xml.add_element("DpsBillingId").text = token + xml.add_element('DpsBillingId').text = token end end def add_token_request(xml, options) - xml.add_element("BillingId").text = options[:billing_id] if options[:billing_id] - xml.add_element("EnableAddBillCard").text = 1 + xml.add_element('BillingId').text = options[:billing_id] if options[:billing_id] + xml.add_element('EnableAddBillCard').text = 1 end def add_amount(xml, money, options) - xml.add_element("Amount").text = amount(money) - xml.add_element("InputCurrency").text = options[:currency] || currency(money) + xml.add_element('Amount').text = amount(money) + xml.add_element('InputCurrency').text = options[:currency] || currency(money) end def add_transaction_type(xml, action) - xml.add_element("TxnType").text = TRANSACTIONS[action] + xml.add_element('TxnType').text = TRANSACTIONS[action] end def add_invoice(xml, options) - xml.add_element("TxnId").text = options[:order_id].to_s.slice(0, 16) unless options[:order_id].blank? - xml.add_element("MerchantReference").text = options[:description].to_s.slice(0, 50) unless options[:description].blank? + xml.add_element('TxnId').text = options[:order_id].to_s.slice(0, 16) unless options[:order_id].blank? + xml.add_element('MerchantReference').text = options[:description].to_s.slice(0, 50) unless options[:description].blank? end def add_address_verification_data(xml, options) address = options[:billing_address] || options[:address] return if address.nil? - xml.add_element("EnableAvsData").text = 1 - xml.add_element("AvsAction").text = 1 + xml.add_element('EnableAvsData').text = 1 + xml.add_element('AvsAction').text = 1 - xml.add_element("AvsStreetAddress").text = address[:address1] - xml.add_element("AvsPostCode").text = address[:zip] + xml.add_element('AvsStreetAddress').text = address[:address1] + xml.add_element('AvsPostCode').text = address[:zip] end # The options hash may contain optional data which will be passed @@ -276,16 +276,16 @@ def add_address_verification_data(xml, options) # +purchase+, +authorize+, +capture+, +refund+, +store+ def add_optional_elements(xml, options) if client_type = normalized_client_type(options[:client_type]) - xml.add_element("ClientType").text = client_type + xml.add_element('ClientType').text = client_type end - xml.add_element("TxnData1").text = options[:txn_data1].to_s.slice(0,255) unless options[:txn_data1].blank? - xml.add_element("TxnData2").text = options[:txn_data2].to_s.slice(0,255) unless options[:txn_data2].blank? - xml.add_element("TxnData3").text = options[:txn_data3].to_s.slice(0,255) unless options[:txn_data3].blank? + xml.add_element('TxnData1').text = options[:txn_data1].to_s.slice(0,255) unless options[:txn_data1].blank? + xml.add_element('TxnData2').text = options[:txn_data2].to_s.slice(0,255) unless options[:txn_data2].blank? + xml.add_element('TxnData3').text = options[:txn_data3].to_s.slice(0,255) unless options[:txn_data3].blank? end def new_transaction - REXML::Document.new.add_element("Txn") + REXML::Document.new.add_element('Txn') end # Take in the request and post it to DPS @@ -343,12 +343,12 @@ def format_date(month, year) def normalized_client_type(client_type_from_options) case client_type_from_options.to_s.downcase - when 'web' then "Web" - when 'ivr' then "IVR" - when 'moto' then "MOTO" - when 'unattended' then "Unattended" - when 'internet' then "Internet" - when 'recurring' then "Recurring" + when 'web' then 'Web' + when 'ivr' then 'IVR' + when 'moto' then 'MOTO' + when 'unattended' then 'Unattended' + when 'internet' then 'Internet' + when 'recurring' then 'Recurring' else nil end end @@ -358,7 +358,7 @@ class PaymentExpressResponse < Response # add a method to response so we can easily get the token # for Validate transactions def token - @params["billing_id"] || @params["dps_billing_id"] + @params['billing_id'] || @params['dps_billing_id'] end end end diff --git a/lib/active_merchant/billing/gateways/paymill.rb b/lib/active_merchant/billing/gateways/paymill.rb index 58a39f24572..95b4028b670 100644 --- a/lib/active_merchant/billing/gateways/paymill.rb +++ b/lib/active_merchant/billing/gateways/paymill.rb @@ -10,7 +10,7 @@ class PaymillGateway < Gateway self.display_name = 'PAYMILL' self.money_format = :cents self.default_currency = 'EUR' - self.live_url = "https://api.paymill.com/v2/" + self.live_url = 'https://api.paymill.com/v2/' def initialize(options = {}) requires!(options, :public_key, :private_key) @@ -64,7 +64,7 @@ def scrub(transcript) def verify_credentials begin - ssl_get(live_url + "transactions/nonexistent", headers) + ssl_get(live_url + 'transactions/nonexistent', headers) rescue ResponseError => e return false if e.response.code.to_i == 401 end @@ -75,10 +75,10 @@ def verify_credentials private def add_credit_card(post, credit_card, options) - post['account.holder'] = (credit_card.try(:name) || "") + post['account.holder'] = (credit_card.try(:name) || '') post['account.number'] = credit_card.number - post['account.expiry.month'] = sprintf("%.2i", credit_card.month) - post['account.expiry.year'] = sprintf("%.4i", credit_card.year) + post['account.expiry.month'] = sprintf('%.2i', credit_card.month) + post['account.expiry.year'] = sprintf('%.4i', credit_card.year) post['account.verification'] = credit_card.verification_value post['account.email'] = (options[:email] || nil) post['presentation.amount3D'] = (options[:money] || nil) @@ -122,7 +122,7 @@ def authorization_from(parsed_response) [ parsed_data['id'], parsed_data['preauthorization'].try(:[], 'id') - ].join(";") + ].join(';') end def action_with_token(action, money, payment_method, options) @@ -194,7 +194,7 @@ def post_data(params) return nil unless params no_blanks = params.reject { |key, value| value.blank? } - no_blanks.map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + no_blanks.map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def add_amount(post, money, options) @@ -203,7 +203,7 @@ def add_amount(post, money, options) end def preauth(authorization) - authorization.split(";").last + authorization.split(';').last end def transaction_id(authorization) @@ -211,113 +211,113 @@ def transaction_id(authorization) end RESPONSE_CODES = { - 10001 => "Undefined response", - 10002 => "Waiting for something", - 11000 => "Retry request at a later time", - - 20000 => "Operation successful", - 20100 => "Funds held by acquirer", - 20101 => "Funds held by acquirer because merchant is new", - 20200 => "Transaction reversed", - 20201 => "Reversed due to chargeback", - 20202 => "Reversed due to money-back guarantee", - 20203 => "Reversed due to complaint by buyer", - 20204 => "Payment has been refunded", - 20300 => "Reversal has been canceled", - 22000 => "Initiation of transaction successful", - - 30000 => "Transaction still in progress", - 30100 => "Transaction has been accepted", - 31000 => "Transaction pending", - 31100 => "Pending due to address", - 31101 => "Pending due to uncleared eCheck", - 31102 => "Pending due to risk review", - 31103 => "Pending due regulatory review", - 31104 => "Pending due to unregistered/unconfirmed receiver", - 31200 => "Pending due to unverified account", - 31201 => "Pending due to non-captured funds", - 31202 => "Pending due to international account (accept manually)", - 31203 => "Pending due to currency conflict (accept manually)", - 31204 => "Pending due to fraud filters (accept manually)", - - - 40000 => "Problem with transaction data", - 40001 => "Problem with payment data", - 40002 => "Invalid checksum", - 40100 => "Problem with credit card data", - 40101 => "Problem with CVV", - 40102 => "Card expired or not yet valid", - 40103 => "Card limit exceeded", - 40104 => "Card is not valid", - 40105 => "Expiry date not valid", - 40106 => "Credit card brand required", - 40200 => "Problem with bank account data", - 40201 => "Bank account data combination mismatch", - 40202 => "User authentication failed", - 40300 => "Problem with 3-D Secure data", - 40301 => "Currency/amount mismatch", - 40400 => "Problem with input data", - 40401 => "Amount too low or zero", - 40402 => "Usage field too long", - 40403 => "Currency not allowed", - 40410 => "Problem with shopping cart data", - 40420 => "Problem with address data", - 40500 => "Permission error with acquirer API", - 40510 => "Rate limit reached for acquirer API", - 42000 => "Initiation of transaction failed", - 42410 => "Initiation of transaction expired", - - 50000 => "Problem with back end", - 50001 => "Country blacklisted", - 50002 => "IP address blacklisted", - 50004 => "Live mode not allowed", - 50005 => "Insufficient permissions (API key)", - 50100 => "Technical error with credit card", - 50101 => "Error limit exceeded", - 50102 => "Card declined", - 50103 => "Manipulation or stolen card", - 50104 => "Card restricted", - 50105 => "Invalid configuration data", - 50200 => "Technical error with bank account", - 50201 => "Account blacklisted", - 50300 => "Technical error with 3-D Secure", - 50400 => "Declined because of risk issues", - 50401 => "Checksum was wrong", - 50402 => "Bank account number was invalid (formal check)", - 50403 => "Technical error with risk check", - 50404 => "Unknown error with risk check", - 50405 => "Unknown bank code", - 50406 => "Open chargeback", - 50407 => "Historical chargeback", - 50408 => "Institution / public bank account (NCA)", - 50409 => "KUNO/Fraud", - 50410 => "Personal Account Protection (PAP)", - 50420 => "Rejected due to acquirer fraud settings", - 50430 => "Rejected due to acquirer risk settings", - 50440 => "Failed due to restrictions with acquirer account", - 50450 => "Failed due to restrictions with user account", - 50500 => "General timeout", - 50501 => "Timeout on side of the acquirer", - 50502 => "Risk management transaction timeout", - 50600 => "Duplicate operation", - 50700 => "Cancelled by user", - 50710 => "Failed due to funding source", - 50711 => "Payment method not usable, use other payment method", - 50712 => "Limit of funding source was exceeded", - 50713 => "Means of payment not reusable (canceled by user)", - 50714 => "Means of payment not reusable (expired)", - 50720 => "Rejected by acquirer", - 50730 => "Transaction denied by merchant", - 50800 => "Preauthorisation failed", - 50810 => "Authorisation has been voided", - 50820 => "Authorisation period expired" + 10001 => 'Undefined response', + 10002 => 'Waiting for something', + 11000 => 'Retry request at a later time', + + 20000 => 'Operation successful', + 20100 => 'Funds held by acquirer', + 20101 => 'Funds held by acquirer because merchant is new', + 20200 => 'Transaction reversed', + 20201 => 'Reversed due to chargeback', + 20202 => 'Reversed due to money-back guarantee', + 20203 => 'Reversed due to complaint by buyer', + 20204 => 'Payment has been refunded', + 20300 => 'Reversal has been canceled', + 22000 => 'Initiation of transaction successful', + + 30000 => 'Transaction still in progress', + 30100 => 'Transaction has been accepted', + 31000 => 'Transaction pending', + 31100 => 'Pending due to address', + 31101 => 'Pending due to uncleared eCheck', + 31102 => 'Pending due to risk review', + 31103 => 'Pending due regulatory review', + 31104 => 'Pending due to unregistered/unconfirmed receiver', + 31200 => 'Pending due to unverified account', + 31201 => 'Pending due to non-captured funds', + 31202 => 'Pending due to international account (accept manually)', + 31203 => 'Pending due to currency conflict (accept manually)', + 31204 => 'Pending due to fraud filters (accept manually)', + + + 40000 => 'Problem with transaction data', + 40001 => 'Problem with payment data', + 40002 => 'Invalid checksum', + 40100 => 'Problem with credit card data', + 40101 => 'Problem with CVV', + 40102 => 'Card expired or not yet valid', + 40103 => 'Card limit exceeded', + 40104 => 'Card is not valid', + 40105 => 'Expiry date not valid', + 40106 => 'Credit card brand required', + 40200 => 'Problem with bank account data', + 40201 => 'Bank account data combination mismatch', + 40202 => 'User authentication failed', + 40300 => 'Problem with 3-D Secure data', + 40301 => 'Currency/amount mismatch', + 40400 => 'Problem with input data', + 40401 => 'Amount too low or zero', + 40402 => 'Usage field too long', + 40403 => 'Currency not allowed', + 40410 => 'Problem with shopping cart data', + 40420 => 'Problem with address data', + 40500 => 'Permission error with acquirer API', + 40510 => 'Rate limit reached for acquirer API', + 42000 => 'Initiation of transaction failed', + 42410 => 'Initiation of transaction expired', + + 50000 => 'Problem with back end', + 50001 => 'Country blacklisted', + 50002 => 'IP address blacklisted', + 50004 => 'Live mode not allowed', + 50005 => 'Insufficient permissions (API key)', + 50100 => 'Technical error with credit card', + 50101 => 'Error limit exceeded', + 50102 => 'Card declined', + 50103 => 'Manipulation or stolen card', + 50104 => 'Card restricted', + 50105 => 'Invalid configuration data', + 50200 => 'Technical error with bank account', + 50201 => 'Account blacklisted', + 50300 => 'Technical error with 3-D Secure', + 50400 => 'Declined because of risk issues', + 50401 => 'Checksum was wrong', + 50402 => 'Bank account number was invalid (formal check)', + 50403 => 'Technical error with risk check', + 50404 => 'Unknown error with risk check', + 50405 => 'Unknown bank code', + 50406 => 'Open chargeback', + 50407 => 'Historical chargeback', + 50408 => 'Institution / public bank account (NCA)', + 50409 => 'KUNO/Fraud', + 50410 => 'Personal Account Protection (PAP)', + 50420 => 'Rejected due to acquirer fraud settings', + 50430 => 'Rejected due to acquirer risk settings', + 50440 => 'Failed due to restrictions with acquirer account', + 50450 => 'Failed due to restrictions with user account', + 50500 => 'General timeout', + 50501 => 'Timeout on side of the acquirer', + 50502 => 'Risk management transaction timeout', + 50600 => 'Duplicate operation', + 50700 => 'Cancelled by user', + 50710 => 'Failed due to funding source', + 50711 => 'Payment method not usable, use other payment method', + 50712 => 'Limit of funding source was exceeded', + 50713 => 'Means of payment not reusable (canceled by user)', + 50714 => 'Means of payment not reusable (expired)', + 50720 => 'Rejected by acquirer', + 50730 => 'Transaction denied by merchant', + 50800 => 'Preauthorisation failed', + 50810 => 'Authorisation has been voided', + 50820 => 'Authorisation period expired' } def response_message(parsed_response) - return parsed_response["error"] if parsed_response["error"] - return "Transaction approved." if (parsed_response['data'] == []) + return parsed_response['error'] if parsed_response['error'] + return 'Transaction approved.' if (parsed_response['data'] == []) - code = parsed_response["data"]["response_code"].to_i + code = parsed_response['data']['response_code'].to_i RESPONSE_CODES[code] || code.to_s end @@ -325,7 +325,7 @@ def response_message(parsed_response) class ResponseParser attr_reader :raw_response, :parsed, :succeeded, :message, :options - def initialize(raw_response="", options={}) + def initialize(raw_response='', options={}) @raw_response = raw_response @options = options end diff --git a/lib/active_merchant/billing/gateways/paypal.rb b/lib/active_merchant/billing/gateways/paypal.rb index 3a2b84b45e0..4ca95d13f48 100644 --- a/lib/active_merchant/billing/gateways/paypal.rb +++ b/lib/active_merchant/billing/gateways/paypal.rb @@ -50,7 +50,7 @@ def define_transaction_type(transaction_arg) def build_sale_or_authorization_request(action, money, credit_card_or_referenced_id, options) transaction_type = define_transaction_type(credit_card_or_referenced_id) - reference_id = credit_card_or_referenced_id if transaction_type == "DoReferenceTransaction" + reference_id = credit_card_or_referenced_id if transaction_type == 'DoReferenceTransaction' billing_address = options[:billing_address] || options[:address] currency_code = options[:currency] || currency(money) diff --git a/lib/active_merchant/billing/gateways/paypal_digital_goods.rb b/lib/active_merchant/billing/gateways/paypal_digital_goods.rb index 80f3b5064a7..653a8c59015 100644 --- a/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +++ b/lib/active_merchant/billing/gateways/paypal_digital_goods.rb @@ -30,7 +30,7 @@ def redirect_url_for(token, options = {}) # :category => "Digital" } ] ) def build_setup_request(action, money, options) requires!(options, :items) - raise ArgumentError, "Must include at least 1 Item" unless options[:items].length > 0 + raise ArgumentError, 'Must include at least 1 Item' unless options[:items].length > 0 options[:items].each do |item| requires!(item, :name, :number, :quantity, :amount, :description, :category) raise ArgumentError, "Each of the items must have the category 'Digital'" unless item[:category] == 'Digital' diff --git a/lib/active_merchant/billing/gateways/payscout.rb b/lib/active_merchant/billing/gateways/payscout.rb index 5fab0d5e67a..f0f9602e4fc 100644 --- a/lib/active_merchant/billing/gateways/payscout.rb +++ b/lib/active_merchant/billing/gateways/payscout.rb @@ -153,7 +153,7 @@ def post_data(action, parameters = {}) post[:password] = @options[:password] post[:type] = action - request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') request end end diff --git a/lib/active_merchant/billing/gateways/paystation.rb b/lib/active_merchant/billing/gateways/paystation.rb index 0eedd12f0fb..da9ff63c15d 100644 --- a/lib/active_merchant/billing/gateways/paystation.rb +++ b/lib/active_merchant/billing/gateways/paystation.rb @@ -2,7 +2,7 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class PaystationGateway < Gateway - self.live_url = self.test_url = "https://www.paystation.co.nz/direct/paystation.dll" + self.live_url = self.test_url = 'https://www.paystation.co.nz/direct/paystation.dll' # an "error code" of "0" means "No error - transaction successful" SUCCESSFUL_RESPONSE_CODE = '0' @@ -104,9 +104,9 @@ def new_request { :pi => @options[:paystation_id], # paystation account id :gi => @options[:gateway_id], # paystation gateway id - "2p" => "t", # two-party transaction type - :nr => "t", # -- redirect?? - :df => "yymm" # date format: optional sometimes, required others + '2p' => 't', # two-party transaction type + :nr => 't', # -- redirect?? + :df => 'yymm' # date format: optional sometimes, required others } end @@ -128,27 +128,27 @@ def add_credit_card(post, credit_card) end def add_token(post, token) - post[:fp] = "t" # turn on "future payments" - what paystation calls Token Billing + post[:fp] = 't' # turn on "future payments" - what paystation calls Token Billing post[:ft] = token end def store_credit_card(post, options) - post[:fp] = "t" # turn on "future payments" - what paystation calls Token Billing - post[:fs] = "t" # tells paystation to store right now, not bill + post[:fp] = 't' # turn on "future payments" - what paystation calls Token Billing + post[:fs] = 't' # tells paystation to store right now, not bill post[:ft] = options[:token] if options[:token] # specify a token to use that, or let Paystation generate one end def add_authorize_flag(post, options) - post[:pa] = "t" # tells Paystation that this is a pre-auth authorisation payment (account must be in pre-auth mode) + post[:pa] = 't' # tells Paystation that this is a pre-auth authorisation payment (account must be in pre-auth mode) end def add_refund_specific_fields(post, authorization) - post[:rc] = "t" + post[:rc] = 't' post[:rt] = authorization end def add_authorization_token(post, auth_token, verification_value = nil) - post[:cp] = "t" # Capture Payment flag – tells Paystation this transaction should be treated as a capture payment + post[:cp] = 't' # Capture Payment flag – tells Paystation this transaction should be treated as a capture payment post[:cx] = auth_token post[:cc] = verification_value end @@ -171,15 +171,15 @@ def parse(xml_response) end def commit(post) - post[:tm] = "T" if test? - pstn_prefix_params = post.collect { |key, value| "pstn_#{key}=#{CGI.escape(value.to_s)}" }.join("&") + post[:tm] = 'T' if test? + pstn_prefix_params = post.collect { |key, value| "pstn_#{key}=#{CGI.escape(value.to_s)}" }.join('&') data = ssl_post(self.live_url, "#{pstn_prefix_params}&paystation=_empty") response = parse(data) message = message_from(response) PaystationResponse.new(success?(response), message, response, - :test => (response[:tm] && response[:tm].downcase == "t"), + :test => (response[:tm] && response[:tm].downcase == 't'), :authorization => response[:paystation_transaction_id] ) end @@ -200,7 +200,7 @@ def format_date(month, year) class PaystationResponse < Response def token - @params["future_payment_token"] + @params['future_payment_token'] end end end diff --git a/lib/active_merchant/billing/gateways/payu_in.rb b/lib/active_merchant/billing/gateways/payu_in.rb index e9820ea315d..f75cbbd7df7 100644 --- a/lib/active_merchant/billing/gateways/payu_in.rb +++ b/lib/active_merchant/billing/gateways/payu_in.rb @@ -3,11 +3,11 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class PayuInGateway < Gateway - self.test_url = "https://test.payu.in/_payment" - self.live_url = "https://secure.payu.in/_payment" + self.test_url = 'https://test.payu.in/_payment' + self.live_url = 'https://secure.payu.in/_payment' - TEST_INFO_URL = "https://test.payu.in/merchant/postservice.php?form=2" - LIVE_INFO_URL = "https://info.payu.in/merchant/postservice.php?form=2" + TEST_INFO_URL = 'https://test.payu.in/merchant/postservice.php?form=2' + LIVE_INFO_URL = 'https://info.payu.in/merchant/postservice.php?form=2' self.supported_countries = ['IN'] self.default_currency = 'INR' @@ -32,9 +32,9 @@ def purchase(money, payment, options={}) add_auth(post) MultiResponse.run do |r| - r.process{commit(url("purchase"), post)} - if(r.params["enrolled"].to_s == "0") - r.process{commit(r.params["post_uri"], r.params["form_post_vars"])} + r.process{commit(url('purchase'), post)} + if(r.params['enrolled'].to_s == '0') + r.process{commit(r.params['post_uri'], r.params['form_post_vars'])} else r.process{handle_3dsecure(r)} end @@ -42,18 +42,18 @@ def purchase(money, payment, options={}) end def refund(money, authorization, options={}) - raise ArgumentError, "Amount is required" unless money + raise ArgumentError, 'Amount is required' unless money post = {} - post[:command] = "cancel_refund_transaction" + post[:command] = 'cancel_refund_transaction' post[:var1] = authorization post[:var2] = generate_unique_id post[:var3] = amount(money) add_auth(post, :command, :var1) - commit(url("refund"), post) + commit(url('refund'), post) end def supports_scrubbing? @@ -82,17 +82,17 @@ def add_auth(post, *digest_keys) digest_keys = PAYMENT_DIGEST_KEYS if digest_keys.empty? digest = Digest::SHA2.new(512) - digest << @options[:key] << "|" + digest << @options[:key] << '|' digest_keys.each do |key| - digest << (post[key.to_sym] || "") << "|" + digest << (post[key.to_sym] || '') << '|' end digest << @options[:salt] post[:hash] = digest.hexdigest end def add_customer_data(post, options) - post[:email] = clean(options[:email] || "unknown@example.com", nil, 50) - post[:phone] = clean((options[:billing_address] && options[:billing_address][:phone]) || "11111111111", :numeric, 50) + post[:email] = clean(options[:email] || 'unknown@example.com', nil, 50) + post[:phone] = clean((options[:billing_address] && options[:billing_address][:phone]) || '11111111111', :numeric, 50) end def add_addresses(post, options) @@ -109,7 +109,7 @@ def add_addresses(post, options) if options[:shipping_address][:name] first, *rest = options[:shipping_address][:name].split(/\s+/) post[:shipping_firstname] = clean(first, :name, 60) - post[:shipping_lastname] = clean(rest.join(" "), :name, 20) + post[:shipping_lastname] = clean(rest.join(' '), :name, 20) end post[:shipping_address1] = clean(options[:shipping_address][:address1], :text, 100) post[:shipping_address2] = clean(options[:shipping_address][:address2], :text, 100) @@ -125,22 +125,22 @@ def add_invoice(post, money, options) post[:amount] = amount(money) post[:txnid] = clean(options[:order_id], :alphanumeric, 30) - post[:productinfo] = clean(options[:description] || "Purchase", nil, 100) + post[:productinfo] = clean(options[:description] || 'Purchase', nil, 100) - post[:surl] = "http://example.com" - post[:furl] = "http://example.com" + post[:surl] = 'http://example.com' + post[:furl] = 'http://example.com' end BRAND_MAP = { - visa: "VISA", - master: "MAST", - american_express: "AMEX", - diners_club: "DINR", - maestro: "MAES" + visa: 'VISA', + master: 'MAST', + american_express: 'AMEX', + diners_club: 'DINR', + maestro: 'MAES' } def add_payment(post, payment) - post[:pg] = "CC" + post[:pg] = 'CC' post[:firstname] = clean(payment.first_name, :name, 60) post[:lastname] = clean(payment.last_name, :name, 20) @@ -153,16 +153,16 @@ def add_payment(post, payment) end def clean(value, format, maxlength) - value ||= "" + value ||= '' value = case format when :alphanumeric - value.gsub(/[^A-Za-z0-9]/, "") + value.gsub(/[^A-Za-z0-9]/, '') when :name - value.gsub(/[^A-Za-z ]/, "") + value.gsub(/[^A-Za-z ]/, '') when :numeric - value.gsub(/[^0-9]/, "") + value.gsub(/[^0-9]/, '') when :text - value.gsub(/[^A-Za-z0-9@\-_\/\. ]/, "") + value.gsub(/[^A-Za-z0-9@\-_\/\. ]/, '') when nil value else @@ -174,10 +174,10 @@ def clean(value, format, maxlength) def parse(body) top = JSON.parse(body) - if result = top.delete("result") - result.split("&").inject({}) do |hash, string| - key, value = string.split("=") - hash[CGI.unescape(key).downcase] = CGI.unescape(value || "") + if result = top.delete('result') + result.split('&').inject({}) do |hash, string| + key, value = string.split('=') + hash[CGI.unescape(key).downcase] = CGI.unescape(value || '') hash end.each do |key, value| if top[key] @@ -188,19 +188,19 @@ def parse(body) end end - if response = top.delete("response") + if response = top.delete('response') top.merge!(response) end top rescue JSON::ParserError { - "error" => "Invalid response received from the PayU API. (The raw response was `#{body}`)." + 'error' => "Invalid response received from the PayU API. (The raw response was `#{body}`)." } end def commit(url, parameters) - response = parse(ssl_post(url, post_data(parameters), "Accept-Encoding" => "identity")) + response = parse(ssl_post(url, post_data(parameters), 'Accept-Encoding' => 'identity')) Response.new( success_from(response), @@ -213,7 +213,7 @@ def commit(url, parameters) def url(action) case action - when "purchase" + when 'purchase' (test? ? test_url : live_url) else (test? ? TEST_INFO_URL : LIVE_INFO_URL) @@ -221,19 +221,19 @@ def url(action) end def success_from(response) - if response["result_status"] - (response["status"] == "success" && response["result_status"] == "success") + if response['result_status'] + (response['status'] == 'success' && response['result_status'] == 'success') else - (response["status"] == "success" || response["status"].to_s == "1") + (response['status'] == 'success' || response['status'].to_s == '1') end end def message_from(response) - (response["error_message"] || response["error"] || response["msg"]) + (response['error_message'] || response['error'] || response['msg']) end def authorization_from(response) - response["mihpayid"] + response['mihpayid'] end def post_data(parameters = {}) @@ -241,7 +241,7 @@ def post_data(parameters = {}) end def handle_3dsecure(response) - Response.new(false, "3D-secure enrolled cards are not supported.") + Response.new(false, '3D-secure enrolled cards are not supported.') end end end diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index 3d5904348d0..a3192fe79e7 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -3,29 +3,29 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class PayuLatamGateway < Gateway - self.display_name = "PayU Latam" - self.homepage_url = "http://www.payulatam.com" + self.display_name = 'PayU Latam' + self.homepage_url = 'http://www.payulatam.com' - self.test_url = "https://sandbox.api.payulatam.com/payments-api/4.0/service.cgi" - self.live_url = "https://api.payulatam.com/payments-api/4.0/service.cgi" + self.test_url = 'https://sandbox.api.payulatam.com/payments-api/4.0/service.cgi' + self.live_url = 'https://api.payulatam.com/payments-api/4.0/service.cgi' - self.supported_countries = ["AR", "BR", "CL", "CO", "MX", "PA", "PE"] - self.default_currency = "USD" + self.supported_countries = ['AR', 'BR', 'CL', 'CO', 'MX', 'PA', 'PE'] + self.default_currency = 'USD' self.money_format = :dollars self.supported_cardtypes = [:visa, :master, :american_express, :diners_club] BRAND_MAP = { - "visa" => "VISA", - "master" => "MASTERCARD", - "american_express" => "AMEX", - "diners_club" => "DINERS" + 'visa' => 'VISA', + 'master' => 'MASTERCARD', + 'american_express' => 'AMEX', + 'diners_club' => 'DINERS' } MINIMUMS = { - "ARS" => 1700, - "BRL" => 600, - "MXN" => 3900, - "PEN" => 500 + 'ARS' => 1700, + 'BRL' => 600, + 'MXN' => 3900, + 'PEN' => 500 } def initialize(options={}) @@ -251,7 +251,7 @@ def signature_from(post) post[:transaction][:order][:referenceCode], post[:transaction][:order][:additionalValues][:TX_VALUE][:value], post[:transaction][:order][:additionalValues][:TX_VALUE][:currency] - ].compact.join("~") + ].compact.join('~') Digest::MD5.hexdigest(signature_string) end @@ -333,8 +333,8 @@ def commit(action, params) def headers { - "Content-Type" => "application/json", - "Accept" => "application/json" + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' } end @@ -354,32 +354,32 @@ def parse(body) def success_from(action, response) case action when 'store' - response["code"] == "SUCCESS" && response["creditCardToken"] && response["creditCardToken"]["creditCardTokenId"].present? + response['code'] == 'SUCCESS' && response['creditCardToken'] && response['creditCardToken']['creditCardTokenId'].present? when 'verify_credentials' - response["code"] == "SUCCESS" + response['code'] == 'SUCCESS' when 'refund', 'void' - response["code"] == "SUCCESS" && response["transactionResponse"] && (response["transactionResponse"]["state"] == "PENDING" || response["transactionResponse"]["state"] == "APPROVED") + response['code'] == 'SUCCESS' && response['transactionResponse'] && (response['transactionResponse']['state'] == 'PENDING' || response['transactionResponse']['state'] == 'APPROVED') else - response["code"] == "SUCCESS" && response["transactionResponse"] && (response["transactionResponse"]["state"] == "APPROVED") + response['code'] == 'SUCCESS' && response['transactionResponse'] && (response['transactionResponse']['state'] == 'APPROVED') end end def message_from(action, success, response) case action when 'store' - return response["code"] if success - error_description = response["creditCardToken"]["errorDescription"] if response["creditCardToken"] - response["error"] || error_description || "FAILED" + return response['code'] if success + error_description = response['creditCardToken']['errorDescription'] if response['creditCardToken'] + response['error'] || error_description || 'FAILED' when 'verify_credentials' - return "VERIFIED" if success - "FAILED" + return 'VERIFIED' if success + 'FAILED' else - if response["transactionResponse"] - response_message = response["transactionResponse"]["responseMessage"] - response_code = response["transactionResponse"]["responseCode"] || response["transactionResponse"]["pendingReason"] + if response['transactionResponse'] + response_message = response['transactionResponse']['responseMessage'] + response_code = response['transactionResponse']['responseCode'] || response['transactionResponse']['pendingReason'] end return response_code if success - response["error"] || response_message || response_code || "FAILED" + response['error'] || response_message || response_code || 'FAILED' end end @@ -387,31 +387,31 @@ def authorization_from(action, response) case action when 'store' [ - response["creditCardToken"]["paymentMethod"], - response["creditCardToken"]["creditCardTokenId"] - ].compact.join("|") + response['creditCardToken']['paymentMethod'], + response['creditCardToken']['creditCardTokenId'] + ].compact.join('|') when 'verify_credentials' nil else [ - response["transactionResponse"]["orderId"], - response["transactionResponse"]["transactionId"] - ].compact.join("|") + response['transactionResponse']['orderId'], + response['transactionResponse']['transactionId'] + ].compact.join('|') end end def split_authorization(authorization) - authorization.split("|") + authorization.split('|') end def error_from(action, response) case action when 'store' - response["creditCardToken"]["errorDescription"] if response["creditCardToken"] + response['creditCardToken']['errorDescription'] if response['creditCardToken'] when 'verify_credentials' - response["error"] || "FAILED" + response['error'] || 'FAILED' else - response["transactionResponse"]["errorCode"] || response["transactionResponse"]["responseCode"] if response["transactionResponse"] + response['transactionResponse']['errorCode'] || response['transactionResponse']['responseCode'] if response['transactionResponse'] end end @@ -431,7 +431,7 @@ def response_error(raw_response) end def unparsable_response(raw_response) - message = "Invalid JSON response received from PayuLatamGateway. Please contact PayuLatamGateway if you continue to receive this message." + message = 'Invalid JSON response received from PayuLatamGateway. Please contact PayuLatamGateway if you continue to receive this message.' message += " (The raw response returned by the API was #{raw_response.inspect})" return Response.new(false, message) end diff --git a/lib/active_merchant/billing/gateways/payway.rb b/lib/active_merchant/billing/gateways/payway.rb index 10777f7b00a..b7b40b6c8b0 100644 --- a/lib/active_merchant/billing/gateways/payway.rb +++ b/lib/active_merchant/billing/gateways/payway.rb @@ -179,28 +179,28 @@ def commit(action, post) add_auth(post) post.merge!('order.type' => TRANSACTIONS[action]) - request = post.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join("&") + request = post.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') response = ssl_post(self.live_url, request) params = {} CGI.parse(response).each_pair do |key, value| - actual_key = key.split(".").last + actual_key = key.split('.').last params[actual_key.underscore.to_sym] = value[0] end message = "#{SUMMARY_CODES[params[:summary_code]]} - #{RESPONSE_CODES[params[:response_code]]}" - success = (params[:summary_code] ? (params[:summary_code] == "0") : (params[:response_code] == "00")) + success = (params[:summary_code] ? (params[:summary_code] == '0') : (params[:response_code] == '00')) Response.new(success, message, params, - :test => (@options[:merchant].to_s == "TEST"), + :test => (@options[:merchant].to_s == 'TEST'), :authorization => post[:order_number] ) rescue ActiveMerchant::ResponseError => e raise unless e.response.code == '403' - return Response.new(false, "Invalid credentials", {}, :test => test?) + return Response.new(false, 'Invalid credentials', {}, :test => test?) rescue ActiveMerchant::ClientCertificateError - return Response.new(false, "Invalid certificate", {}, :test => test?) + return Response.new(false, 'Invalid certificate', {}, :test => test?) end end end diff --git a/lib/active_merchant/billing/gateways/pin.rb b/lib/active_merchant/billing/gateways/pin.rb index a7e04216977..7b364e2eaea 100644 --- a/lib/active_merchant/billing/gateways/pin.rb +++ b/lib/active_merchant/billing/gateways/pin.rb @@ -113,7 +113,7 @@ def add_address(post, creditcard, options) end def add_invoice(post, options) - post[:description] = options[:description] || "Active Merchant Purchase" + post[:description] = options[:description] || 'Active Merchant Purchase' end def add_capture(post, options) @@ -148,8 +148,8 @@ def add_metadata(post, options) def headers(params = {}) result = { - "Content-Type" => "application/json", - "Authorization" => "Basic #{Base64.strict_encode64(options[:api_key] + ':').strip}" + 'Content-Type' => 'application/json', + 'Authorization' => "Basic #{Base64.strict_encode64(options[:api_key] + ':').strip}" } result['X-Partner-Key'] = params[:partner_key] if params[:partner_key] @@ -167,9 +167,9 @@ def commit(method, action, params, options) body = parse(e.response.body) end - if body["response"] + if body['response'] success_response(body) - elsif body["error"] + elsif body['error'] error_response(body) end @@ -178,7 +178,7 @@ def commit(method, action, params, options) end def success_response(body) - response = body["response"] + response = body['response'] Response.new( true, response['status_message'], @@ -199,7 +199,7 @@ def error_response(body) end def unparsable_response(raw_response) - message = "Invalid JSON response received from Pin Payments. Please contact support@pin.net.au if you continue to receive this message." + message = 'Invalid JSON response received from Pin Payments. Please contact support@pin.net.au if you continue to receive this message.' message += " (The raw response returned by the API was #{raw_response.inspect})" return Response.new(false, message) end diff --git a/lib/active_merchant/billing/gateways/plugnpay.rb b/lib/active_merchant/billing/gateways/plugnpay.rb index e7820d5b382..1b78b25c299 100644 --- a/lib/active_merchant/billing/gateways/plugnpay.rb +++ b/lib/active_merchant/billing/gateways/plugnpay.rb @@ -9,74 +9,74 @@ class PlugnpayPostData < PostData self.live_url = self.test_url = 'https://pay1.plugnpay.com/payment/pnpremote.cgi' CARD_CODE_MESSAGES = { - "M" => "Card verification number matched", - "N" => "Card verification number didn't match", - "P" => "Card verification number was not processed", - "S" => "Card verification number should be on card but was not indicated", - "U" => "Issuer was not certified for card verification" + 'M' => 'Card verification number matched', + 'N' => "Card verification number didn't match", + 'P' => 'Card verification number was not processed', + 'S' => 'Card verification number should be on card but was not indicated', + 'U' => 'Issuer was not certified for card verification' } CARD_CODE_ERRORS = %w( N S ) AVS_MESSAGES = { - "A" => "Street address matches billing information, zip/postal code does not", - "B" => "Address information not provided for address verification check", - "E" => "Address verification service error", - "G" => "Non-U.S. card-issuing bank", - "N" => "Neither street address nor zip/postal match billing information", - "P" => "Address verification not applicable for this transaction", - "R" => "Payment gateway was unavailable or timed out", - "S" => "Address verification service not supported by issuer", - "U" => "Address information is unavailable", - "W" => "9-digit zip/postal code matches billing information, street address does not", - "X" => "Street address and 9-digit zip/postal code matches billing information", - "Y" => "Street address and 5-digit zip/postal code matches billing information", - "Z" => "5-digit zip/postal code matches billing information, street address does not", + 'A' => 'Street address matches billing information, zip/postal code does not', + 'B' => 'Address information not provided for address verification check', + 'E' => 'Address verification service error', + 'G' => 'Non-U.S. card-issuing bank', + 'N' => 'Neither street address nor zip/postal match billing information', + 'P' => 'Address verification not applicable for this transaction', + 'R' => 'Payment gateway was unavailable or timed out', + 'S' => 'Address verification service not supported by issuer', + 'U' => 'Address information is unavailable', + 'W' => '9-digit zip/postal code matches billing information, street address does not', + 'X' => 'Street address and 9-digit zip/postal code matches billing information', + 'Y' => 'Street address and 5-digit zip/postal code matches billing information', + 'Z' => '5-digit zip/postal code matches billing information, street address does not', } AVS_ERRORS = %w( A E N R W Z ) PAYMENT_GATEWAY_RESPONSES = { - "P01" => "AVS Mismatch Failure", - "P02" => "CVV2 Mismatch Failure", - "P21" => "Transaction may not be marked", - "P30" => "Test Tran. Bad Card", - "P35" => "Test Tran. Problem", - "P40" => "Username already exists", - "P41" => "Username is blank", - "P50" => "Fraud Screen Failure", - "P51" => "Missing PIN Code", - "P52" => "Invalid Bank Acct. No.", - "P53" => "Invalid Bank Routing No.", - "P54" => "Invalid/Missing Check No.", - "P55" => "Invalid Credit Card No.", - "P56" => "Invalid CVV2/CVC2 No.", - "P57" => "Expired. CC Exp. Date", - "P58" => "Missing Data", - "P59" => "Missing Email Address", - "P60" => "Zip Code does not match Billing State.", - "P61" => "Invalid Billing Zip Code", - "P62" => "Zip Code does not match Shipping State.", - "P63" => "Invalid Shipping Zip Code", - "P64" => "Invalid Credit Card CVV2/CVC2 Format.", - "P65" => "Maximum number of attempts has been exceeded.", - "P66" => "Credit Card number has been flagged and can not be used to access this service.", - "P67" => "IP Address is on Blocked List.", - "P68" => "Billing country does not match ipaddress country.", - "P69" => "US based ipaddresses are currently blocked.", - "P70" => "Credit Cards issued from this bank are currently not being accepted.", - "P71" => "Credit Cards issued from this bank are currently not being accepted.", - "P72" => "Daily volume exceeded.", - "P73" => "Too many transactions within allotted time.", - "P91" => "Missing/incorrect password", - "P92" => "Account not configured for mobil administration", - "P93" => "IP Not registered to username.", - "P94" => "Mode not permitted for this account.", - "P95" => "Currently Blank", - "P96" => "Currently Blank", - "P97" => "Processor not responding", - "P98" => "Missing merchant/publisher name", - "P99" => "Currently Blank" + 'P01' => 'AVS Mismatch Failure', + 'P02' => 'CVV2 Mismatch Failure', + 'P21' => 'Transaction may not be marked', + 'P30' => 'Test Tran. Bad Card', + 'P35' => 'Test Tran. Problem', + 'P40' => 'Username already exists', + 'P41' => 'Username is blank', + 'P50' => 'Fraud Screen Failure', + 'P51' => 'Missing PIN Code', + 'P52' => 'Invalid Bank Acct. No.', + 'P53' => 'Invalid Bank Routing No.', + 'P54' => 'Invalid/Missing Check No.', + 'P55' => 'Invalid Credit Card No.', + 'P56' => 'Invalid CVV2/CVC2 No.', + 'P57' => 'Expired. CC Exp. Date', + 'P58' => 'Missing Data', + 'P59' => 'Missing Email Address', + 'P60' => 'Zip Code does not match Billing State.', + 'P61' => 'Invalid Billing Zip Code', + 'P62' => 'Zip Code does not match Shipping State.', + 'P63' => 'Invalid Shipping Zip Code', + 'P64' => 'Invalid Credit Card CVV2/CVC2 Format.', + 'P65' => 'Maximum number of attempts has been exceeded.', + 'P66' => 'Credit Card number has been flagged and can not be used to access this service.', + 'P67' => 'IP Address is on Blocked List.', + 'P68' => 'Billing country does not match ipaddress country.', + 'P69' => 'US based ipaddresses are currently blocked.', + 'P70' => 'Credit Cards issued from this bank are currently not being accepted.', + 'P71' => 'Credit Cards issued from this bank are currently not being accepted.', + 'P72' => 'Daily volume exceeded.', + 'P73' => 'Too many transactions within allotted time.', + 'P91' => 'Missing/incorrect password', + 'P92' => 'Account not configured for mobil administration', + 'P93' => 'IP Not registered to username.', + 'P94' => 'Mode not permitted for this account.', + 'P95' => 'Currently Blank', + 'P96' => 'Currently Blank', + 'P97' => 'Processor not responding', + 'P98' => 'Missing merchant/publisher name', + 'P99' => 'Currently Blank' } TRANSACTIONS = { @@ -273,8 +273,8 @@ def message_from(results) end def expdate(creditcard) - year = sprintf("%.4i", creditcard.year) - month = sprintf("%.2i", creditcard.month) + year = sprintf('%.4i', creditcard.year) + month = sprintf('%.2i', creditcard.month) "#{month}/#{year[-2..-1]}" end diff --git a/lib/active_merchant/billing/gateways/pro_pay.rb b/lib/active_merchant/billing/gateways/pro_pay.rb index 73bc14ed749..ef3eb1050a9 100644 --- a/lib/active_merchant/billing/gateways/pro_pay.rb +++ b/lib/active_merchant/billing/gateways/pro_pay.rb @@ -15,122 +15,122 @@ class ProPayGateway < Gateway self.display_name = 'ProPay' STATUS_RESPONSE_CODES = { - "00" => "Success", - "20" => "Invalid username", - "21" => "Invalid transType", - "22" => "Invalid Currency Code", - "23" => "Invalid accountType", - "24" => "Invalid sourceEmail", - "25" => "Invalid firstName", - "26" => "Invalid mInitial", - "27" => "Invalid lastName", - "28" => "Invalid billAddr", - "29" => "Invalid aptNum", - "30" => "Invalid city", - "31" => "Invalid state", - "32" => "Invalid billZip", - "33" => "Invalid mailAddr", - "34" => "Invalid mailApt", - "35" => "Invalid mailCity", - "36" => "Invalid mailState", - "37" => "Invalid mailZip", - "38" => "Invalid dayPhone", - "39" => "Invalid evenPhone", - "40" => "Invalid ssn", - "41" => "Invalid dob", - "42" => "Invalid recEmail", - "43" => "Invalid knownAccount", - "44" => "Invalid amount", - "45" => "Invalid invNum", - "46" => "Invalid rtNum", - "47" => "Invalid accntNum", - "48" => "Invalid ccNum", - "49" => "Invalid expDate", - "50" => "Invalid cvv2", - "51" => "Invalid transNum and/or Unable to act perform actions on transNum due to funding", - "52" => "Invalid splitNum", - "53" => "A ProPay account with this email address already exists AND/OR User has no account number", - "54" => "A ProPay account with this social security number already exists", - "55" => "The email address provided does not correspond to a ProPay account.", - "56" => "Recipient’s email address shouldn’t have a ProPay account and does", - "57" => "Cannot settle transaction because it already expired", - "58" => "Credit card declined", - "59" => "Invalid Credential or IP address not allowed", - "60" => "Credit card authorization timed out; retry at a later time", - "61" => "Amount exceeds single transaction limit", - "62" => "Amount exceeds monthly volume limit", - "63" => "Insufficient funds in account", - "64" => "Over credit card use limit", - "65" => "Miscellaneous error", - "66" => "Denied a ProPay account", - "67" => "Unauthorized service requested", - "68" => "Account not affiliated", - "69" => "Duplicate invoice number (The same card was charged for the same amount with the same invoice number (including blank invoices) in a 1 minute period. Details about the original transaction are included whenever a 69 response is returned. These details include a repeat of the auth code, the original AVS response, and the original CVV response.)", - "70" => "Duplicate external ID", - "71" => "Account previously set up, but problem affiliating it with partner", - "72" => "The ProPay Account has already been upgraded to a Premium Account", - "73" => "Invalid Destination Account", - "74" => "Account or Trans Error", - "75" => "Money already pulled", - "76" => "Not Premium (used only for push/pull transactions)", - "77" => "Empty results", - "78" => "Invalid Authentication", - "79" => "Generic account status error", - "80" => "Invalid Password", - "81" => "Account Expired", - "82" => "InvalidUserID", - "83" => "BatchTransCountError", - "84" => "InvalidBeginDate", - "85" => "InvalidEndDate", - "86" => "InvalidExternalID", - "87" => "DuplicateUserID", - "88" => "Invalid track 1", - "89" => "Invalid track 2", - "90" => "Transaction already refunded", - "91" => "Duplicate Batch ID" + '00' => 'Success', + '20' => 'Invalid username', + '21' => 'Invalid transType', + '22' => 'Invalid Currency Code', + '23' => 'Invalid accountType', + '24' => 'Invalid sourceEmail', + '25' => 'Invalid firstName', + '26' => 'Invalid mInitial', + '27' => 'Invalid lastName', + '28' => 'Invalid billAddr', + '29' => 'Invalid aptNum', + '30' => 'Invalid city', + '31' => 'Invalid state', + '32' => 'Invalid billZip', + '33' => 'Invalid mailAddr', + '34' => 'Invalid mailApt', + '35' => 'Invalid mailCity', + '36' => 'Invalid mailState', + '37' => 'Invalid mailZip', + '38' => 'Invalid dayPhone', + '39' => 'Invalid evenPhone', + '40' => 'Invalid ssn', + '41' => 'Invalid dob', + '42' => 'Invalid recEmail', + '43' => 'Invalid knownAccount', + '44' => 'Invalid amount', + '45' => 'Invalid invNum', + '46' => 'Invalid rtNum', + '47' => 'Invalid accntNum', + '48' => 'Invalid ccNum', + '49' => 'Invalid expDate', + '50' => 'Invalid cvv2', + '51' => 'Invalid transNum and/or Unable to act perform actions on transNum due to funding', + '52' => 'Invalid splitNum', + '53' => 'A ProPay account with this email address already exists AND/OR User has no account number', + '54' => 'A ProPay account with this social security number already exists', + '55' => 'The email address provided does not correspond to a ProPay account.', + '56' => 'Recipient’s email address shouldn’t have a ProPay account and does', + '57' => 'Cannot settle transaction because it already expired', + '58' => 'Credit card declined', + '59' => 'Invalid Credential or IP address not allowed', + '60' => 'Credit card authorization timed out; retry at a later time', + '61' => 'Amount exceeds single transaction limit', + '62' => 'Amount exceeds monthly volume limit', + '63' => 'Insufficient funds in account', + '64' => 'Over credit card use limit', + '65' => 'Miscellaneous error', + '66' => 'Denied a ProPay account', + '67' => 'Unauthorized service requested', + '68' => 'Account not affiliated', + '69' => 'Duplicate invoice number (The same card was charged for the same amount with the same invoice number (including blank invoices) in a 1 minute period. Details about the original transaction are included whenever a 69 response is returned. These details include a repeat of the auth code, the original AVS response, and the original CVV response.)', + '70' => 'Duplicate external ID', + '71' => 'Account previously set up, but problem affiliating it with partner', + '72' => 'The ProPay Account has already been upgraded to a Premium Account', + '73' => 'Invalid Destination Account', + '74' => 'Account or Trans Error', + '75' => 'Money already pulled', + '76' => 'Not Premium (used only for push/pull transactions)', + '77' => 'Empty results', + '78' => 'Invalid Authentication', + '79' => 'Generic account status error', + '80' => 'Invalid Password', + '81' => 'Account Expired', + '82' => 'InvalidUserID', + '83' => 'BatchTransCountError', + '84' => 'InvalidBeginDate', + '85' => 'InvalidEndDate', + '86' => 'InvalidExternalID', + '87' => 'DuplicateUserID', + '88' => 'Invalid track 1', + '89' => 'Invalid track 2', + '90' => 'Transaction already refunded', + '91' => 'Duplicate Batch ID' } TRANSACTION_RESPONSE_CODES = { - "00" => "Success", - "1" => "Transaction blocked by issuer", - "4" => "Pick up card and deny transaction", - "5" => "Problem with the account", - "6" => "Customer requested stop to recurring payment", - "7" => "Customer requested stop to all recurring payments", - "8" => "Honor with ID only", - "9" => "Unpaid items on customer account", - "12" => "Invalid transaction", - "13" => "Amount Error", - "14" => "Invalid card number", - "15" => "No such issuer. Could not route transaction", - "16" => "Refund error", - "17" => "Over limit", - "19" => "Reenter transaction or the merchant account may be boarded incorrectly", - "25" => "Invalid terminal 41 Lost card", - "43" => "Stolen card", - "51" => "Insufficient funds", - "52" => "No such account", - "54" => "Expired card", - "55" => "Incorrect PIN", - "57" => "Bank does not allow this type of purchase", - "58" => "Credit card network does not allow this type of purchase for your merchant account.", - "61" => "Exceeds issuer withdrawal limit", - "62" => "Issuer does not allow this card to be charged for your business.", - "63" => "Security Violation", - "65" => "Activity limit exceeded", - "75" => "PIN tries exceeded", - "76" => "Unable to locate account", - "78" => "Account not recognized", - "80" => "Invalid Date", - "82" => "Invalid CVV2", - "83" => "Cannot verify the PIN", - "85" => "Service not supported for this card", - "93" => "Cannot complete transaction. Customer should call 800 number.", - "95" => "Misc Error Transaction failure", - "96" => "Issuer system malfunction or timeout.", - "97" => "Approved for a lesser amount. ProPay will not settle and consider this a decline.", - "98" => "Failure HV", - "99" => "Generic decline or unable to parse issuer response code" + '00' => 'Success', + '1' => 'Transaction blocked by issuer', + '4' => 'Pick up card and deny transaction', + '5' => 'Problem with the account', + '6' => 'Customer requested stop to recurring payment', + '7' => 'Customer requested stop to all recurring payments', + '8' => 'Honor with ID only', + '9' => 'Unpaid items on customer account', + '12' => 'Invalid transaction', + '13' => 'Amount Error', + '14' => 'Invalid card number', + '15' => 'No such issuer. Could not route transaction', + '16' => 'Refund error', + '17' => 'Over limit', + '19' => 'Reenter transaction or the merchant account may be boarded incorrectly', + '25' => 'Invalid terminal 41 Lost card', + '43' => 'Stolen card', + '51' => 'Insufficient funds', + '52' => 'No such account', + '54' => 'Expired card', + '55' => 'Incorrect PIN', + '57' => 'Bank does not allow this type of purchase', + '58' => 'Credit card network does not allow this type of purchase for your merchant account.', + '61' => 'Exceeds issuer withdrawal limit', + '62' => 'Issuer does not allow this card to be charged for your business.', + '63' => 'Security Violation', + '65' => 'Activity limit exceeded', + '75' => 'PIN tries exceeded', + '76' => 'Unable to locate account', + '78' => 'Account not recognized', + '80' => 'Invalid Date', + '82' => 'Invalid CVV2', + '83' => 'Cannot verify the PIN', + '85' => 'Service not supported for this card', + '93' => 'Cannot complete transaction. Customer should call 800 number.', + '95' => 'Misc Error Transaction failure', + '96' => 'Issuer system malfunction or timeout.', + '97' => 'Approved for a lesser amount. ProPay will not settle and consider this a decline.', + '98' => 'Failure HV', + '99' => 'Generic decline or unable to parse issuer response code' } def initialize(options={}) @@ -145,7 +145,7 @@ def purchase(money, payment, options={}) add_address(xml, options) add_account(xml, options) add_recurring(xml, options) - xml.transType "04" + xml.transType '04' end commit(request) @@ -158,7 +158,7 @@ def authorize(money, payment, options={}) add_address(xml, options) add_account(xml, options) add_recurring(xml, options) - xml.transType "05" + xml.transType '05' end commit(request) @@ -169,7 +169,7 @@ def capture(money, authorization, options={}) add_invoice(xml, money, options) add_account(xml, options) xml.transNum authorization - xml.transType "06" + xml.transType '06' end commit(request) @@ -180,7 +180,7 @@ def refund(money, authorization, options={}) add_invoice(xml, money, options) add_account(xml, options) xml.transNum authorization - xml.transType "07" + xml.transType '07' end commit(request) @@ -195,7 +195,7 @@ def credit(money, payment, options={}) add_invoice(xml, money, options) add_payment(xml, payment, options) add_account(xml, options) - xml.transType "35" + xml.transType '35' end commit(request) @@ -255,7 +255,7 @@ def add_recurring(xml, options) def parse(body) results = {} xml = Nokogiri::XML(body) - resp = xml.xpath("//XMLResponse/XMLTrans") + resp = xml.xpath('//XMLResponse/XMLTrans') resp.children.each do |element| results[element.name.underscore.downcase.to_sym] = element.text end @@ -279,11 +279,11 @@ def commit(parameters) end def success_from(response) - response[:status] == "00" + response[:status] == '00' end def message_from(response) - return "Success" if success_from(response) + return 'Success' if success_from(response) message = STATUS_RESPONSE_CODES[response[:status]] message += " - #{TRANSACTION_RESPONSE_CODES[response[:response_code]]}" if response[:response_code] @@ -304,7 +304,7 @@ def build_xml_request builder = Nokogiri::XML::Builder.new do |xml| xml.XMLRequest do xml.certStr @options[:cert_str] - xml.class_ "partner" + xml.class_ 'partner' xml.XMLTrans do yield(xml) end @@ -319,7 +319,7 @@ def underscore(camel_cased_word) camel_cased_word.to_s.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). - tr("-", "_"). + tr('-', '_'). downcase end end diff --git a/lib/active_merchant/billing/gateways/psigate.rb b/lib/active_merchant/billing/gateways/psigate.rb index 39737289639..e83b86c2c86 100644 --- a/lib/active_merchant/billing/gateways/psigate.rb +++ b/lib/active_merchant/billing/gateways/psigate.rb @@ -53,18 +53,18 @@ def initialize(options = {}) def authorize(money, creditcard, options = {}) requires!(options, :order_id) - options[:CardAction] = "1" + options[:CardAction] = '1' commit(money, creditcard, options) end def purchase(money, creditcard, options = {}) requires!(options, :order_id) - options[:CardAction] = "0" + options[:CardAction] = '0' commit(money, creditcard, options) end def capture(money, authorization, options = {}) - options[:CardAction] = "2" + options[:CardAction] = '2' options[:order_id], options[:trans_ref_number] = split_authorization(authorization) commit(money, nil, options) end @@ -75,13 +75,13 @@ def credit(money, authorization, options = {}) end def refund(money, authorization, options = {}) - options[:CardAction] = "3" + options[:CardAction] = '3' options[:order_id], options[:trans_ref_number] = split_authorization(authorization) commit(money, nil, options) end def void(authorization, options = {}) - options[:CardAction] = "9" + options[:CardAction] = '9' options[:order_id], options[:trans_ref_number] = split_authorization(authorization) commit(nil, nil, options) end @@ -115,11 +115,11 @@ def url end def successful?(response) - response[:approved] == "APPROVED" + response[:approved] == 'APPROVED' end def parse(xml) - response = {:message => "Global Error Receipt", :complete => false} + response = {:message => 'Global Error Receipt', :complete => false} xml = REXML::Document.new(xml) xml.elements.each('//Result/*') do |node| @@ -132,7 +132,7 @@ def parse(xml) def post_data(money, creditcard, options) xml = REXML::Document.new xml << REXML::XMLDecl.new - root = xml.add_element("Order") + root = xml.add_element('Order') parameters(money, creditcard, options).each do |key, value| root.add_element(key.to_s).text = value if value @@ -155,7 +155,7 @@ def parameters(money, creditcard, options = {}) :TransRefNumber => options[:trans_ref_number], # Credit Card parameters - :PaymentType => "CC", + :PaymentType => 'CC', :CardAction => options[:CardAction], # Financial parameters @@ -167,9 +167,9 @@ def parameters(money, creditcard, options = {}) } if creditcard - exp_month = sprintf("%.2i", creditcard.month) unless creditcard.month.blank? + exp_month = sprintf('%.2i', creditcard.month) unless creditcard.month.blank? exp_year = creditcard.year.to_s[2,2] unless creditcard.year.blank? - card_id_code = (creditcard.verification_value.blank? ? nil : "1") + card_id_code = (creditcard.verification_value.blank? ? nil : '1') params.update( :CardNumber => creditcard.number, @@ -206,11 +206,11 @@ def parameters(money, creditcard, options = {}) end def message_from(response) - if response[:approved] == "APPROVED" + if response[:approved] == 'APPROVED' return SUCCESS_MESSAGE else return FAILURE_MESSAGE if response[:errmsg].blank? - return response[:errmsg].gsub(/[^\w]/, ' ').split.join(" ").capitalize + return response[:errmsg].gsub(/[^\w]/, ' ').split.join(' ').capitalize end end @@ -220,7 +220,7 @@ def split_authorization(authorization) end def build_authorization(response) - [response[:orderid], response[:transrefnumber]].join(";") + [response[:orderid], response[:transrefnumber]].join(';') end end end diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb index 10027303daf..4bd7f56f977 100644 --- a/lib/active_merchant/billing/gateways/psl_card.rb +++ b/lib/active_merchant/billing/gateways/psl_card.rb @@ -63,21 +63,21 @@ class PslCardGateway < Gateway NOMINAL_AMOUNT = 101 AVS_CODE = { - "ALL MATCH" => 'Y', - "SECURITY CODE MATCH ONLY" => 'N', - "ADDRESS MATCH ONLY" => 'Y', - "NO DATA MATCHES" => 'N', - "DATA NOT CHECKED" => 'R', - "SECURITY CHECKS NOT SUPPORTED" => 'X' + 'ALL MATCH' => 'Y', + 'SECURITY CODE MATCH ONLY' => 'N', + 'ADDRESS MATCH ONLY' => 'Y', + 'NO DATA MATCHES' => 'N', + 'DATA NOT CHECKED' => 'R', + 'SECURITY CHECKS NOT SUPPORTED' => 'X' } CVV_CODE = { - "ALL MATCH" => 'M', - "SECURITY CODE MATCH ONLY" => 'M', - "ADDRESS MATCH ONLY" => 'N', - "NO DATA MATCHES" => 'N', - "DATA NOT CHECKED" => 'P', - "SECURITY CHECKS NOT SUPPORTED" => 'X' + 'ALL MATCH' => 'M', + 'SECURITY CODE MATCH ONLY' => 'M', + 'ADDRESS MATCH ONLY' => 'N', + 'NO DATA MATCHES' => 'N', + 'DATA NOT CHECKED' => 'P', + 'SECURITY CHECKS NOT SUPPORTED' => 'X' } # Create a new PslCardGateway @@ -296,7 +296,7 @@ def post_data(post) post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s.tr('&=', ' '))}" - }.join("&") + }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/qbms.rb b/lib/active_merchant/billing/gateways/qbms.rb index 4cf2a999f31..85c9adf939a 100644 --- a/lib/active_merchant/billing/gateways/qbms.rb +++ b/lib/active_merchant/billing/gateways/qbms.rb @@ -5,8 +5,8 @@ class QbmsGateway < Gateway class_attribute :test_url, :live_url - self.test_url = "https://webmerchantaccount.ptc.quickbooks.com/j/AppGateway" - self.live_url = "https://webmerchantaccount.quickbooks.com/j/AppGateway" + self.test_url = 'https://webmerchantaccount.ptc.quickbooks.com/j/AppGateway' + self.live_url = 'https://webmerchantaccount.quickbooks.com/j/AppGateway' self.homepage_url = 'http://payments.intuit.com/' self.display_name = 'QuickBooks Merchant Services' @@ -138,7 +138,7 @@ def commit(action, money, parameters) req = build_request(type, money, parameters) - data = ssl_post(url, req, "Content-Type" => "application/x-qbmsxml") + data = ssl_post(url, req, 'Content-Type' => 'application/x-qbmsxml') response = parse(type, data) message = (response[:status_message] || '').strip @@ -163,20 +163,20 @@ def parse(type, body) xml = REXML::Document.new(body) signon = REXML::XPath.first(xml, "//SignonMsgsRs/#{hosted? ? 'SignonAppCertRs' : 'SignonDesktopRs'}") - status_code = signon.attributes["statusCode"].to_i + status_code = signon.attributes['statusCode'].to_i if status_code != 0 return { :status_code => status_code, - :status_message => signon.attributes["statusMessage"], + :status_message => signon.attributes['statusMessage'], } end response = REXML::XPath.first(xml, "//QBMSXMLMsgsRs/#{type}Rs") results = { - :status_code => response.attributes["statusCode"].to_i, - :status_message => response.attributes["statusMessage"], + :status_code => response.attributes['statusCode'].to_i, + :status_message => response.attributes['statusMessage'], } response.elements.each do |e| @@ -200,16 +200,16 @@ def build_request(type, money, parameters = {}) xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8') xml.instruct!(:qbmsxml, :version => API_VERSION) - xml.tag!("QBMSXML") do - xml.tag!("SignonMsgsRq") do - xml.tag!(hosted? ? "SignonAppCertRq" : "SignonDesktopRq") do - xml.tag!("ClientDateTime", Time.now.xmlschema) - xml.tag!("ApplicationLogin", @options[:login]) - xml.tag!("ConnectionTicket", @options[:ticket]) + xml.tag!('QBMSXML') do + xml.tag!('SignonMsgsRq') do + xml.tag!(hosted? ? 'SignonAppCertRq' : 'SignonDesktopRq') do + xml.tag!('ClientDateTime', Time.now.xmlschema) + xml.tag!('ApplicationLogin', @options[:login]) + xml.tag!('ConnectionTicket', @options[:ticket]) end end - xml.tag!("QBMSXMLMsgsRq") do + xml.tag!('QBMSXMLMsgsRq') do xml.tag!("#{type}Rq") do method("build_#{type}").call(xml, money, parameters) end @@ -223,47 +223,47 @@ def build_CustomerCreditCardAuth(xml, money, parameters) cc = parameters[:credit_card] name = "#{cc.first_name} #{cc.last_name}"[0...30] - xml.tag!("TransRequestID", parameters[:trans_request_id]) - xml.tag!("CreditCardNumber", cc.number) - xml.tag!("ExpirationMonth", cc.month) - xml.tag!("ExpirationYear", cc.year) - xml.tag!("IsECommerce", "true") - xml.tag!("Amount", amount(money)) - xml.tag!("NameOnCard", name) + xml.tag!('TransRequestID', parameters[:trans_request_id]) + xml.tag!('CreditCardNumber', cc.number) + xml.tag!('ExpirationMonth', cc.month) + xml.tag!('ExpirationYear', cc.year) + xml.tag!('IsECommerce', 'true') + xml.tag!('Amount', amount(money)) + xml.tag!('NameOnCard', name) add_address(xml, parameters) - xml.tag!("CardSecurityCode", cc.verification_value) if cc.verification_value? + xml.tag!('CardSecurityCode', cc.verification_value) if cc.verification_value? end def build_CustomerCreditCardCapture(xml, money, parameters) - xml.tag!("TransRequestID", parameters[:trans_request_id]) - xml.tag!("CreditCardTransID", parameters[:transaction_id]) - xml.tag!("Amount", amount(money)) + xml.tag!('TransRequestID', parameters[:trans_request_id]) + xml.tag!('CreditCardTransID', parameters[:transaction_id]) + xml.tag!('Amount', amount(money)) end def build_CustomerCreditCardCharge(xml, money, parameters) cc = parameters[:credit_card] name = "#{cc.first_name} #{cc.last_name}"[0...30] - xml.tag!("TransRequestID", parameters[:trans_request_id]) - xml.tag!("CreditCardNumber", cc.number) - xml.tag!("ExpirationMonth", cc.month) - xml.tag!("ExpirationYear", cc.year) - xml.tag!("IsECommerce", "true") - xml.tag!("Amount", amount(money)) - xml.tag!("NameOnCard", name) + xml.tag!('TransRequestID', parameters[:trans_request_id]) + xml.tag!('CreditCardNumber', cc.number) + xml.tag!('ExpirationMonth', cc.month) + xml.tag!('ExpirationYear', cc.year) + xml.tag!('IsECommerce', 'true') + xml.tag!('Amount', amount(money)) + xml.tag!('NameOnCard', name) add_address(xml, parameters) - xml.tag!("CardSecurityCode", cc.verification_value) if cc.verification_value? + xml.tag!('CardSecurityCode', cc.verification_value) if cc.verification_value? end def build_CustomerCreditCardTxnVoidOrRefund(xml, money, parameters) - xml.tag!("TransRequestID", parameters[:trans_request_id]) - xml.tag!("CreditCardTransID", parameters[:transaction_id]) - xml.tag!("Amount", amount(money)) + xml.tag!('TransRequestID', parameters[:trans_request_id]) + xml.tag!('CreditCardTransID', parameters[:transaction_id]) + xml.tag!('Amount', amount(money)) end def build_CustomerCreditCardTxnVoid(xml, money, parameters) - xml.tag!("TransRequestID", parameters[:trans_request_id]) - xml.tag!("CreditCardTransID", parameters[:transaction_id]) + xml.tag!('TransRequestID', parameters[:trans_request_id]) + xml.tag!('CreditCardTransID', parameters[:transaction_id]) end # Called reflectively by build_request @@ -272,30 +272,30 @@ def build_MerchantAccountQuery(xml, money, parameters) def add_address(xml, parameters) if address = parameters[:billing_address] || parameters[:address] - xml.tag!("CreditCardAddress", (address[:address1] || "")[0...30]) - xml.tag!("CreditCardPostalCode", (address[:zip] || "")[0...9]) + xml.tag!('CreditCardAddress', (address[:address1] || '')[0...30]) + xml.tag!('CreditCardPostalCode', (address[:zip] || '')[0...9]) end end def cvv_result(response) case response[:card_security_code_match] - when "Pass" then 'M' - when "Fail" then 'N' - when "NotAvailable" then 'P' + when 'Pass' then 'M' + when 'Fail' then 'N' + when 'NotAvailable' then 'P' end end def avs_result(response) case "#{response[:avs_street]}|#{response[:avs_zip]}" - when "Pass|Pass" then "D" - when "Pass|Fail" then "A" - when "Pass|NotAvailable" then "B" - when "Fail|Pass" then "Z" - when "Fail|Fail" then "C" - when "Fail|NotAvailable" then "N" - when "NotAvailable|Pass" then "P" - when "NotAvailable|Fail" then "N" - when "NotAvailable|NotAvailable" then "U" + when 'Pass|Pass' then 'D' + when 'Pass|Fail' then 'A' + when 'Pass|NotAvailable' then 'B' + when 'Fail|Pass' then 'Z' + when 'Fail|Fail' then 'C' + when 'Fail|NotAvailable' then 'N' + when 'NotAvailable|Pass' then 'P' + when 'NotAvailable|Fail' then 'N' + when 'NotAvailable|NotAvailable' then 'U' end end end diff --git a/lib/active_merchant/billing/gateways/quantum.rb b/lib/active_merchant/billing/gateways/quantum.rb index 9dd778eca3f..65e7b9e6dcb 100644 --- a/lib/active_merchant/billing/gateways/quantum.rb +++ b/lib/active_merchant/billing/gateways/quantum.rb @@ -206,7 +206,7 @@ def commit(request, options) headers = { 'Content-Type' => 'text/xml' } response = parse(ssl_post(self.live_url, build_request(request, options), headers)) - success = response[:request_status] == "Success" + success = response[:request_status] == 'Success' message = response[:request_message] if success # => checking for connectivity success first @@ -231,19 +231,19 @@ def parse(xml) begin xml = REXML::Document.new(xml) - root = REXML::XPath.first(xml, "//QGWRequest/ResponseSummary") + root = REXML::XPath.first(xml, '//QGWRequest/ResponseSummary') parse_element(reply, root) reply[:request_status] = reply[:Status] reply[:request_message] = "#{reply[:Status]}: #{reply[:StatusDescription]}" - if root = REXML::XPath.first(xml, "//QGWRequest/Result") + if root = REXML::XPath.first(xml, '//QGWRequest/Result') root.elements.to_a.each do |node| parse_element(reply, node) end end rescue Exception reply[:request_status] = 'Failure' - reply[:request_message] = "Failure: There was a problem parsing the response XML" + reply[:request_message] = 'Failure: There was a problem parsing the response XML' end return reply @@ -254,7 +254,7 @@ def parse_element(reply, node) node.elements.each{|e| parse_element(reply, e) } else if node.parent.name =~ /item/ - parent = node.parent.name + (node.parent.attributes["id"] ? "_" + node.parent.attributes["id"] : '') + parent = node.parent.name + (node.parent.attributes['id'] ? '_' + node.parent.attributes['id'] : '') reply[(parent + '_' + node.name).to_sym] = node.text else reply[node.name.to_sym] = node.text diff --git a/lib/active_merchant/billing/gateways/quickbooks.rb b/lib/active_merchant/billing/gateways/quickbooks.rb index a4f52206ec9..ed51d7266dd 100644 --- a/lib/active_merchant/billing/gateways/quickbooks.rb +++ b/lib/active_merchant/billing/gateways/quickbooks.rb @@ -10,7 +10,7 @@ class QuickbooksGateway < Gateway self.homepage_url = 'http://payments.intuit.com' self.display_name = 'QuickBooks Payments' - ENDPOINT = "/quickbooks/v4/payments/charges" + ENDPOINT = '/quickbooks/v4/payments/charges' OAUTH_ENDPOINTS = { site: 'https://oauth.intuit.com', request_token_path: '/oauth/v1/get_request_token', @@ -60,7 +60,7 @@ def purchase(money, payment, options = {}) post = {} add_amount(post, money, options) add_charge_data(post, payment, options) - post[:capture] = "true" + post[:capture] = 'true' commit(ENDPOINT, post) end @@ -69,7 +69,7 @@ def authorize(money, payment, options = {}) post = {} add_amount(post, money, options) add_charge_data(post, payment, options) - post[:capture] = "false" + post[:capture] = 'false' commit(ENDPOINT, post) end @@ -145,7 +145,7 @@ def add_payment(post, payment, options = {}) def add_creditcard(post, creditcard, options = {}) card = {} card[:number] = creditcard.number - card[:expMonth] = "%02d" % creditcard.month + card[:expMonth] = '%02d' % creditcard.month card[:expYear] = creditcard.year card[:cvc] = creditcard.verification_value if creditcard.verification_value? card[:name] = creditcard.name if creditcard.name @@ -218,7 +218,7 @@ def headers(method, uri) oauth_nonce: generate_unique_id, oauth_timestamp: Time.now.to_i.to_s, oauth_signature_method: 'HMAC-SHA1', - oauth_version: "1.0", + oauth_version: '1.0', oauth_consumer_key: @options[:consumer_key], oauth_token: @options[:access_token] } @@ -237,9 +237,9 @@ def headers(method, uri) oauth_headers += oauth_parameters.map {|k, v| "#{k}=\"#{v}\""} { - "Content-type" => "application/json", - "Request-Id" => generate_unique_id, - "Authorization" => oauth_headers.join(', ') + 'Content-type' => 'application/json', + 'Request-Id' => generate_unique_id, + 'Authorization' => oauth_headers.join(', ') } end @@ -258,11 +258,11 @@ def success?(response) end def message_from(response) - response['errors'].present? ? response["errors"].map {|error_hash| error_hash["message"] }.join(" ") : response['status'] + response['errors'].present? ? response['errors'].map {|error_hash| error_hash['message'] }.join(' ') : response['status'] end def errors_from(response) - response['errors'].present? ? STANDARD_ERROR_CODE_MAPPING[response["errors"].first["code"]] : "" + response['errors'].present? ? STANDARD_ERROR_CODE_MAPPING[response['errors'].first['code']] : '' end def authorization_from(response) diff --git a/lib/active_merchant/billing/gateways/quickpay.rb b/lib/active_merchant/billing/gateways/quickpay.rb index 3cc61e5656a..34d36f93196 100644 --- a/lib/active_merchant/billing/gateways/quickpay.rb +++ b/lib/active_merchant/billing/gateways/quickpay.rb @@ -10,7 +10,7 @@ class QuickpayGateway < Gateway self.abstract_class = true def self.new(options = {}) - options.fetch(:login) { raise ArgumentError.new("Missing required parameter: login") } + options.fetch(:login) { raise ArgumentError.new('Missing required parameter: login') } version = options[:login].to_i < 10000000 ? 10 : 7 if version <= 7 diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb index ca185b8ccdf..f321a7c33b8 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb @@ -160,10 +160,10 @@ def commit(action, params = {}) end def authorization_from(response) - if response["token"] - response["token"].to_s + if response['token'] + response['token'].to_s else - response["id"].to_s + response['id'].to_s end end @@ -231,13 +231,13 @@ def successful?(response) end def message_from(success, response) - success ? 'OK' : (response['message'] || invalid_operation_message(response) || "Unknown error - please contact QuickPay") + success ? 'OK' : (response['message'] || invalid_operation_message(response) || 'Unknown error - please contact QuickPay') end def invalid_operation_code?(response) if response['operations'] operation = response['operations'].last - operation && operation['qp_status_code'] != "20000" + operation && operation['qp_status_code'] != '20000' end end @@ -267,11 +267,11 @@ def format_order_id(order_id) def headers auth = Base64.strict_encode64(":#{@options[:api_key]}") { - "Authorization" => "Basic " + auth, - "User-Agent" => "Quickpay-v#{API_VERSION} ActiveMerchantBindings/#{ActiveMerchant::VERSION}", - "Accept" => "application/json", - "Accept-Version" => "v#{API_VERSION}", - "Content-Type" => "application/json" + 'Authorization' => 'Basic ' + auth, + 'User-Agent' => "Quickpay-v#{API_VERSION} ActiveMerchantBindings/#{ActiveMerchant::VERSION}", + 'Accept' => 'application/json', + 'Accept-Version' => "v#{API_VERSION}", + 'Content-Type' => 'application/json' } end @@ -286,7 +286,7 @@ def response_error(raw_response) def json_error(raw_response) msg = 'Invalid response received from the Quickpay API.' msg += " (The raw response returned by the API was #{raw_response.inspect})" - { "message" => msg } + { 'message' => msg } end def synchronized_path(path) diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb index b1889db2ed2..95fae367036 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb @@ -136,7 +136,7 @@ def recurring_or_authorize(credit_card_or_reference) end def add_description(post, options) - post[:description] = options[:description] || "Description" + post[:description] = options[:description] || 'Description' end def add_testmode(post) @@ -196,7 +196,7 @@ def post_data(action, params = {}) params[:apikey] = @options[:apikey] if @options[:apikey] params[:md5check] = generate_check_hash(action, params) - params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def generate_check_hash(action, params) @@ -219,7 +219,7 @@ def expdate(credit_card) # Limited to 20 digits max def format_order_number(number) - number.to_s.gsub(/[^\w]/, '').rjust(4, "0")[0...20] + number.to_s.gsub(/[^\w]/, '').rjust(4, '0')[0...20] end end end diff --git a/lib/active_merchant/billing/gateways/qvalent.rb b/lib/active_merchant/billing/gateways/qvalent.rb index e78523c2fe5..6d59464a09c 100644 --- a/lib/active_merchant/billing/gateways/qvalent.rb +++ b/lib/active_merchant/billing/gateways/qvalent.rb @@ -1,14 +1,14 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class QvalentGateway < Gateway - self.display_name = "Qvalent" - self.homepage_url = "https://www.qvalent.com/" + self.display_name = 'Qvalent' + self.homepage_url = 'https://www.qvalent.com/' - self.test_url = "https://ccapi.client.support.qvalent.com/post/CreditCardAPIReceiver" - self.live_url = "https://ccapi.client.qvalent.com/post/CreditCardAPIReceiver" + self.test_url = 'https://ccapi.client.support.qvalent.com/post/CreditCardAPIReceiver' + self.live_url = 'https://ccapi.client.qvalent.com/post/CreditCardAPIReceiver' - self.supported_countries = ["AU"] - self.default_currency = "AUD" + self.supported_countries = ['AU'] + self.default_currency = 'AUD' self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners] @@ -26,7 +26,7 @@ def purchase(amount, payment_method, options={}) add_customer_data(post, options) add_soft_descriptors(post, options) - commit("capture", post) + commit('capture', post) end def authorize(amount, payment_method, options={}) @@ -38,7 +38,7 @@ def authorize(amount, payment_method, options={}) add_customer_data(post, options) add_soft_descriptors(post, options) - commit("preauth", post) + commit('preauth', post) end def capture(amount, authorization, options={}) @@ -48,7 +48,7 @@ def capture(amount, authorization, options={}) add_customer_data(post, options) add_soft_descriptors(post, options) - commit("captureWithoutAuth", post) + commit('captureWithoutAuth', post) end def refund(amount, authorization, options={}) @@ -58,7 +58,7 @@ def refund(amount, authorization, options={}) add_customer_data(post, options) add_soft_descriptors(post, options) - commit("refund", post) + commit('refund', post) end # Credit requires the merchant account to be enabled for "Adhoc Refunds" @@ -70,7 +70,7 @@ def credit(amount, payment_method, options={}) add_customer_data(post, options) add_soft_descriptors(post, options) - commit("refund", post) + commit('refund', post) end def void(authorization, options={}) @@ -79,7 +79,7 @@ def void(authorization, options={}) add_customer_data(post, options) add_soft_descriptors(post, options) - commit("reversal", post) + commit('reversal', post) end def store(payment_method, options = {}) @@ -87,7 +87,7 @@ def store(payment_method, options = {}) add_payment_method(post, payment_method) add_card_reference(post) - commit("registerAccount", post) + commit('registerAccount', post) end def supports_scrubbing? @@ -104,70 +104,70 @@ def scrub(transcript) private CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")} - CURRENCY_CODES["AUD"] = "AUD" - CURRENCY_CODES["INR"] = "INR" + CURRENCY_CODES['AUD'] = 'AUD' + CURRENCY_CODES['INR'] = 'INR' def add_soft_descriptors(post, options) - post["customer.merchantName"] = options[:customer_merchant_name] if options[:customer_merchant_name] - post["customer.merchantStreetAddress"] = options[:customer_merchant_street_address] if options[:customer_merchant_street_address] - post["customer.merchantLocation"] = options[:customer_merchant_location] if options[:customer_merchant_location] - post["customer.merchantState"] = options[:customer_merchant_state] if options[:customer_merchant_state] - post["customer.merchantCountry"] = options[:customer_merchant_country] if options[:customer_merchant_country] - post["customer.merchantPostCode"] = options[:customer_merchant_post_code] if options[:customer_merchant_post_code] - post["customer.subMerchantId"] = options[:customer_sub_merchant_id] if options[:customer_sub_merchant_id] + post['customer.merchantName'] = options[:customer_merchant_name] if options[:customer_merchant_name] + post['customer.merchantStreetAddress'] = options[:customer_merchant_street_address] if options[:customer_merchant_street_address] + post['customer.merchantLocation'] = options[:customer_merchant_location] if options[:customer_merchant_location] + post['customer.merchantState'] = options[:customer_merchant_state] if options[:customer_merchant_state] + post['customer.merchantCountry'] = options[:customer_merchant_country] if options[:customer_merchant_country] + post['customer.merchantPostCode'] = options[:customer_merchant_post_code] if options[:customer_merchant_post_code] + post['customer.subMerchantId'] = options[:customer_sub_merchant_id] if options[:customer_sub_merchant_id] end def add_invoice(post, money, options) - post["order.amount"] = amount(money) - post["card.currency"] = CURRENCY_CODES[options[:currency] || currency(money)] - post["order.ECI"] = options[:eci] || "SSL" + post['order.amount'] = amount(money) + post['card.currency'] = CURRENCY_CODES[options[:currency] || currency(money)] + post['order.ECI'] = options[:eci] || 'SSL' end def add_payment_method(post, payment_method) - post["card.cardHolderName"] = payment_method.name - post["card.PAN"] = payment_method.number - post["card.expiryYear"] = format(payment_method.year, :two_digits) - post["card.expiryMonth"] = format(payment_method.month, :two_digits) + post['card.cardHolderName'] = payment_method.name + post['card.PAN'] = payment_method.number + post['card.expiryYear'] = format(payment_method.year, :two_digits) + post['card.expiryMonth'] = format(payment_method.month, :two_digits) end def add_verification_value(post, payment_method) - post["card.CVN"] = payment_method.verification_value + post['card.CVN'] = payment_method.verification_value end def add_card_reference(post) - post["customer.customerReferenceNumber"] = options[:order_id] + post['customer.customerReferenceNumber'] = options[:order_id] end def add_reference(post, authorization, options) - post["customer.originalOrderNumber"] = authorization + post['customer.originalOrderNumber'] = authorization add_order_number(post, options) end def add_order_number(post, options) - post["customer.orderNumber"] = options[:order_id] || SecureRandom.uuid + post['customer.orderNumber'] = options[:order_id] || SecureRandom.uuid end def add_customer_data(post, options) - post["order.ipAddress"] = options[:ip] || "127.0.0.1" - post["order.xid"] = options[:xid] if options[:xid] - post["order.cavv"] = options[:cavv] if options[:cavv] + post['order.ipAddress'] = options[:ip] || '127.0.0.1' + post['order.xid'] = options[:xid] if options[:xid] + post['order.cavv'] = options[:cavv] if options[:cavv] end def commit(action, post) - post["customer.username"] = @options[:username] - post["customer.password"] = @options[:password] - post["customer.merchant"] = @options[:merchant] - post["order.type"] = action + post['customer.username'] = @options[:username] + post['customer.password'] = @options[:password] + post['customer.merchant'] = @options[:merchant] + post['order.type'] = action data = build_request(post) raw = parse(ssl_post(url(action), data, headers)) - succeeded = success_from(raw["response.responseCode"]) + succeeded = success_from(raw['response.responseCode']) Response.new( succeeded, message_from(succeeded, raw), raw, - authorization: raw["response.orderNumber"] || raw["response.customerReferenceNumber"], + authorization: raw['response.orderNumber'] || raw['response.customerReferenceNumber'], error_code: error_code_from(succeeded, raw), test: test? ) @@ -175,12 +175,12 @@ def commit(action, post) def headers { - "Content-Type" => "application/x-www-form-urlencoded" + 'Content-Type' => 'application/x-www-form-urlencoded' } end def build_request(post) - post.to_query + "&message.end" + post.to_query + '&message.end' end def url(action) @@ -211,25 +211,25 @@ def success_from(response) def message_from(succeeded, response) if succeeded - "Succeeded" + 'Succeeded' else - response["response.text"] || "Unable to read error message" + response['response.text'] || 'Unable to read error message' end end STANDARD_ERROR_CODE_MAPPING = { - "14" => STANDARD_ERROR_CODE[:invalid_number], - "QQ" => STANDARD_ERROR_CODE[:invalid_cvc], - "33" => STANDARD_ERROR_CODE[:expired_card], - "NT" => STANDARD_ERROR_CODE[:incorrect_address], - "12" => STANDARD_ERROR_CODE[:card_declined], - "06" => STANDARD_ERROR_CODE[:processing_error], - "01" => STANDARD_ERROR_CODE[:call_issuer], - "04" => STANDARD_ERROR_CODE[:pickup_card], + '14' => STANDARD_ERROR_CODE[:invalid_number], + 'QQ' => STANDARD_ERROR_CODE[:invalid_cvc], + '33' => STANDARD_ERROR_CODE[:expired_card], + 'NT' => STANDARD_ERROR_CODE[:incorrect_address], + '12' => STANDARD_ERROR_CODE[:card_declined], + '06' => STANDARD_ERROR_CODE[:processing_error], + '01' => STANDARD_ERROR_CODE[:call_issuer], + '04' => STANDARD_ERROR_CODE[:pickup_card], } def error_code_from(succeeded, response) - succeeded ? nil : STANDARD_ERROR_CODE_MAPPING[response["response.responseCode"]] + succeeded ? nil : STANDARD_ERROR_CODE_MAPPING[response['response.responseCode']] end end end diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index ce68055a1e4..08280b4b76b 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -39,9 +39,9 @@ class RealexGateway < Gateway self.homepage_url = 'http://www.realexpayments.com/' self.display_name = 'Realex' - SUCCESS, DECLINED = "Successful", "Declined" - BANK_ERROR = REALEX_ERROR = "Gateway is in maintenance. Please try again later." - ERROR = CLIENT_DEACTIVATED = "Gateway Error" + SUCCESS, DECLINED = 'Successful', 'Declined' + BANK_ERROR = REALEX_ERROR = 'Gateway is in maintenance. Please try again later.' + ERROR = CLIENT_DEACTIVATED = 'Gateway Error' def initialize(options = {}) requires!(options, :login, :password) @@ -98,7 +98,7 @@ def commit(request) response = parse(ssl_post(self.live_url, request)) Response.new( - (response[:result] == "00"), + (response[:result] == '00'), message_from(response), response, :test => (response[:message] =~ %r{\[ test system \]}), @@ -267,7 +267,7 @@ def add_network_tokenization_card(xml, payment) def format_address_code(address) code = [address[:zip].to_s, address[:address1].to_s + address[:address2].to_s] - code.collect{|e| e.gsub(/\D/, "")}.reject{|e| e.empty?}.join("|") + code.collect{|e| e.gsub(/\D/, '')}.reject{|e| e.empty?}.join('|') end def new_timestamp @@ -275,8 +275,8 @@ def new_timestamp end def add_signed_digest(xml, *values) - string = Digest::SHA1.hexdigest(values.join(".")) - xml.tag! 'sha1hash', Digest::SHA1.hexdigest([string, @options[:password]].join(".")) + string = Digest::SHA1.hexdigest(values.join('.')) + xml.tag! 'sha1hash', Digest::SHA1.hexdigest([string, @options[:password]].join('.')) end def auto_settle_flag(action) @@ -290,11 +290,11 @@ def expiry_date(credit_card) def message_from(response) message = nil case response[:result] - when "00" + when '00' message = SUCCESS - when "101" + when '101' message = response[:message] - when "102", "103" + when '102', '103' message = DECLINED when /^2[0-9][0-9]/ message = BANK_ERROR @@ -302,9 +302,9 @@ def message_from(response) message = REALEX_ERROR when /^5[0-9][0-9]/ message = response[:message] - when "600", "601", "603" + when '600', '601', '603' message = ERROR - when "666" + when '666' message = CLIENT_DEACTIVATED else message = DECLINED diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb index 8611832637d..9e9ab4313e2 100644 --- a/lib/active_merchant/billing/gateways/redsys.rb +++ b/lib/active_merchant/billing/gateways/redsys.rb @@ -35,8 +35,8 @@ module Billing #:nodoc: # # class RedsysGateway < Gateway - self.live_url = "https://sis.sermepa.es/sis/operaciones" - self.test_url = "https://sis-t.redsys.es:25443/sis/operaciones" + self.live_url = 'https://sis.sermepa.es/sis/operaciones' + self.test_url = 'https://sis-t.redsys.es:25443/sis/operaciones' self.supported_countries = ['ES'] self.default_currency = 'EUR' @@ -44,46 +44,46 @@ class RedsysGateway < Gateway # Not all card types may be activated by the bank! self.supported_cardtypes = [:visa, :master, :american_express, :jcb, :diners_club] - self.homepage_url = "http://www.redsys.es/" - self.display_name = "Redsys" + self.homepage_url = 'http://www.redsys.es/' + self.display_name = 'Redsys' CURRENCY_CODES = { - "AED" => '784', - "ARS" => '32', - "AUD" => '36', - "BRL" => '986', - "BOB" => '68', - "CAD" => '124', - "CHF" => '756', - "CLP" => '152', - "CNY" => '156', - "COP" => '170', - "CRC" => '188', - "CZK" => '203', - "DKK" => '208', - "DOP" => '214', - "EUR" => '978', - "GBP" => '826', - "GTQ" => '320', - "HUF" => '348', - "IDR" => '360', - "INR" => '356', - "JPY" => '392', - "KRW" => '410', - "MYR" => '458', - "MXN" => '484', - "NOK" => '578', - "NZD" => '554', - "PEN" => '604', - "PLN" => '985', - "RUB" => '643', - "SAR" => '682', - "SEK" => '752', - "SGD" => '702', - "THB" => '764', - "TWD" => '901', - "USD" => '840', - "UYU" => '858' + 'AED' => '784', + 'ARS' => '32', + 'AUD' => '36', + 'BRL' => '986', + 'BOB' => '68', + 'CAD' => '124', + 'CHF' => '756', + 'CLP' => '152', + 'CNY' => '156', + 'COP' => '170', + 'CRC' => '188', + 'CZK' => '203', + 'DKK' => '208', + 'DOP' => '214', + 'EUR' => '978', + 'GBP' => '826', + 'GTQ' => '320', + 'HUF' => '348', + 'IDR' => '360', + 'INR' => '356', + 'JPY' => '392', + 'KRW' => '410', + 'MYR' => '458', + 'MXN' => '484', + 'NOK' => '578', + 'NZD' => '554', + 'PEN' => '604', + 'PLN' => '985', + 'RUB' => '643', + 'SAR' => '682', + 'SEK' => '752', + 'SGD' => '702', + 'THB' => '764', + 'TWD' => '901', + 'USD' => '840', + 'UYU' => '858' } # The set of supported transactions for this gateway. @@ -101,72 +101,72 @@ class RedsysGateway < Gateway # a card has been rejected. Syntax or general request errors # are not covered here. RESPONSE_TEXTS = { - 0 => "Transaction Approved", - 400 => "Cancellation Accepted", - 481 => "Cancellation Accepted", - 500 => "Reconciliation Accepted", - 900 => "Refund / Confirmation approved", - - 101 => "Card expired", - 102 => "Card blocked temporarily or under susciption of fraud", - 104 => "Transaction not permitted", - 107 => "Contact the card issuer", - 109 => "Invalid identification by merchant or POS terminal", - 110 => "Invalid amount", - 114 => "Card cannot be used to the requested transaction", - 116 => "Insufficient credit", - 118 => "Non-registered card", - 125 => "Card not effective", - 129 => "CVV2/CVC2 Error", - 167 => "Contact the card issuer: suspected fraud", - 180 => "Card out of service", - 181 => "Card with credit or debit restrictions", - 182 => "Card with credit or debit restrictions", - 184 => "Authentication error", - 190 => "Refusal with no specific reason", - 191 => "Expiry date incorrect", - - 201 => "Card expired", - 202 => "Card blocked temporarily or under suspicion of fraud", - 204 => "Transaction not permitted", - 207 => "Contact the card issuer", - 208 => "Lost or stolen card", - 209 => "Lost or stolen card", - 280 => "CVV2/CVC2 Error", - 290 => "Declined with no specific reason", - - 480 => "Original transaction not located, or time-out exceeded", - 501 => "Original transaction not located, or time-out exceeded", - 502 => "Original transaction not located, or time-out exceeded", - 503 => "Original transaction not located, or time-out exceeded", - - 904 => "Merchant not registered at FUC", - 909 => "System error", - 912 => "Issuer not available", - 913 => "Duplicate transmission", - 916 => "Amount too low", - 928 => "Time-out exceeded", - 940 => "Transaction cancelled previously", - 941 => "Authorization operation already cancelled", - 942 => "Original authorization declined", - 943 => "Different details from origin transaction", - 944 => "Session error", - 945 => "Duplicate transmission", - 946 => "Cancellation of transaction while in progress", - 947 => "Duplicate tranmission while in progress", - 949 => "POS Inoperative", - 950 => "Refund not possible", - 9064 => "Card number incorrect", - 9078 => "No payment method available", - 9093 => "Non-existent card", - 9218 => "Recursive transaction in bad gateway", - 9253 => "Check-digit incorrect", - 9256 => "Preauth not allowed for merchant", - 9257 => "Preauth not allowed for card", - 9261 => "Operating limit exceeded", - 9912 => "Issuer not available", - 9913 => "Confirmation error", - 9914 => "KO Confirmation" + 0 => 'Transaction Approved', + 400 => 'Cancellation Accepted', + 481 => 'Cancellation Accepted', + 500 => 'Reconciliation Accepted', + 900 => 'Refund / Confirmation approved', + + 101 => 'Card expired', + 102 => 'Card blocked temporarily or under susciption of fraud', + 104 => 'Transaction not permitted', + 107 => 'Contact the card issuer', + 109 => 'Invalid identification by merchant or POS terminal', + 110 => 'Invalid amount', + 114 => 'Card cannot be used to the requested transaction', + 116 => 'Insufficient credit', + 118 => 'Non-registered card', + 125 => 'Card not effective', + 129 => 'CVV2/CVC2 Error', + 167 => 'Contact the card issuer: suspected fraud', + 180 => 'Card out of service', + 181 => 'Card with credit or debit restrictions', + 182 => 'Card with credit or debit restrictions', + 184 => 'Authentication error', + 190 => 'Refusal with no specific reason', + 191 => 'Expiry date incorrect', + + 201 => 'Card expired', + 202 => 'Card blocked temporarily or under suspicion of fraud', + 204 => 'Transaction not permitted', + 207 => 'Contact the card issuer', + 208 => 'Lost or stolen card', + 209 => 'Lost or stolen card', + 280 => 'CVV2/CVC2 Error', + 290 => 'Declined with no specific reason', + + 480 => 'Original transaction not located, or time-out exceeded', + 501 => 'Original transaction not located, or time-out exceeded', + 502 => 'Original transaction not located, or time-out exceeded', + 503 => 'Original transaction not located, or time-out exceeded', + + 904 => 'Merchant not registered at FUC', + 909 => 'System error', + 912 => 'Issuer not available', + 913 => 'Duplicate transmission', + 916 => 'Amount too low', + 928 => 'Time-out exceeded', + 940 => 'Transaction cancelled previously', + 941 => 'Authorization operation already cancelled', + 942 => 'Original authorization declined', + 943 => 'Different details from origin transaction', + 944 => 'Session error', + 945 => 'Duplicate transmission', + 946 => 'Cancellation of transaction while in progress', + 947 => 'Duplicate tranmission while in progress', + 949 => 'POS Inoperative', + 950 => 'Refund not possible', + 9064 => 'Card number incorrect', + 9078 => 'No payment method available', + 9093 => 'Non-existent card', + 9218 => 'Recursive transaction in bad gateway', + 9253 => 'Check-digit incorrect', + 9256 => 'Preauth not allowed for merchant', + 9257 => 'Preauth not allowed for card', + 9261 => 'Operating limit exceeded', + 9912 => 'Issuer not available', + 9913 => 'Confirmation error', + 9914 => 'KO Confirmation' } # Creates a new instance @@ -184,7 +184,7 @@ class RedsysGateway < Gateway def initialize(options = {}) requires!(options, :login, :secret_key) options[:terminal] ||= 1 - options[:signature_algorithm] ||= "sha1" + options[:signature_algorithm] ||= 'sha1' super end @@ -299,8 +299,8 @@ def add_payment(data, card) data[:credit_card_token] = card else name = [card.first_name, card.last_name].join(' ').slice(0, 60) - year = sprintf("%.4i", card.year) - month = sprintf("%.2i", card.month) + year = sprintf('%.4i', card.year) + month = sprintf('%.2i', card.month) data[:card] = { :name => name, :pan => card.number, @@ -402,12 +402,12 @@ def build_merchant_data(xml, data) def parse(data) params = {} success = false - message = "" + message = '' options = @options.merge(:test => test?) xml = Nokogiri::XML(data) - code = xml.xpath("//RETORNOXML/CODIGO").text - if code == "0" - op = xml.xpath("//RETORNOXML/OPERACION") + code = xml.xpath('//RETORNOXML/CODIGO').text + if code == '0' + op = xml.xpath('//RETORNOXML/OPERACION') op.children.each do |element| params[element.name.downcase.to_sym] = element.text end @@ -417,7 +417,7 @@ def parse(data) options[:authorization] = build_authorization(params) success = is_success_response?(params[:ds_response]) else - message = "Response failed validation check" + message = 'Response failed validation check' end else # Some kind of programmer error with the request! @@ -448,11 +448,11 @@ def validate_signature(data) end def build_authorization(params) - [params[:ds_order], params[:ds_amount], params[:ds_currency]].join("|") + [params[:ds_order], params[:ds_amount], params[:ds_currency]].join('|') end def split_authorization(authorization) - order_id, amount, currency = authorization.split("|") + order_id, amount, currency = authorization.split('|') [order_id, amount.to_i, currency] end @@ -469,7 +469,7 @@ def transaction_code(type) def response_text(code) code = code.to_i code = 0 if code < 100 - RESPONSE_TEXTS[code] || "Unkown code, please check in manual" + RESPONSE_TEXTS[code] || 'Unkown code, please check in manual' end def is_success_response?(code) @@ -481,12 +481,12 @@ def clean_order_id(order_id) if cleansed =~ /^\d{4}/ cleansed[0..11] else - "%04d%s" % [rand(0..9999), cleansed[0...8]] + '%04d%s' % [rand(0..9999), cleansed[0...8]] end end def sha256_authentication? - @options[:signature_algorithm] == "sha256" + @options[:signature_algorithm] == 'sha256' end def sign_request(xml_request_string, order_id) diff --git a/lib/active_merchant/billing/gateways/s5.rb b/lib/active_merchant/billing/gateways/s5.rb index 50049e6128b..6e5ec5e80a7 100644 --- a/lib/active_merchant/billing/gateways/s5.rb +++ b/lib/active_merchant/billing/gateways/s5.rb @@ -80,7 +80,7 @@ def void(authorization, options={}) def store(payment, options = {}) request = build_xml_request do |xml| - xml.Payment(code: SUPPORTED_TRANSACTIONS["store"]) + xml.Payment(code: SUPPORTED_TRANSACTIONS['store']) add_account(xml, payment) add_customer(xml, payment, options) add_recurrence_mode(xml, options) @@ -174,20 +174,20 @@ def add_address(xml, address) def add_recurrence_mode(xml, options) if options[:recurring] == true - xml.Recurrence(mode: "REPEATED") + xml.Recurrence(mode: 'REPEATED') else - xml.Recurrence(mode: "INITIAL") + xml.Recurrence(mode: 'INITIAL') end end def parse(body) results = {} xml = Nokogiri::XML(body) - resp = xml.xpath("//Response/Transaction/Identification") + resp = xml.xpath('//Response/Transaction/Identification') resp.children.each do |element| results[element.name.downcase.to_sym] = element.text end - resp = xml.xpath("//Response/Transaction/Processing") + resp = xml.xpath('//Response/Transaction/Processing') resp.children.each do |element| results[element.name.downcase.to_sym] = element.text end diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index dbbac0788e7..a2c8022655e 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -23,7 +23,7 @@ def initialize(options={}) def purchase(money, payment, options={}) post = {} post[:sg_APIType] = 1 if options[:three_d_secure] - trans_type = options[:three_d_secure] ? "Sale3D" : "Sale" + trans_type = options[:three_d_secure] ? 'Sale3D' : 'Sale' add_transaction_data(trans_type, post, money, options) add_payment(post, payment, options) add_customer_details(post, payment, options) @@ -33,7 +33,7 @@ def purchase(money, payment, options={}) def authorize(money, payment, options={}) post = {} - add_transaction_data("Auth", post, money, options) + add_transaction_data('Auth', post, money, options) add_payment(post, payment, options) add_customer_details(post, payment, options) @@ -42,8 +42,8 @@ def authorize(money, payment, options={}) def capture(money, authorization, options={}) post = {} - auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split("|") - add_transaction_data("Settle", post, money, (options.merge!({currency: original_currency}))) + auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split('|') + add_transaction_data('Settle', post, money, (options.merge!({currency: original_currency}))) post[:sg_AuthCode] = auth post[:sg_TransactionID] = transaction_id post[:sg_CCToken] = token @@ -55,8 +55,8 @@ def capture(money, authorization, options={}) def refund(money, authorization, options={}) post = {} - auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split("|") - add_transaction_data("Credit", post, money, (options.merge!({currency: original_currency}))) + auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split('|') + add_transaction_data('Credit', post, money, (options.merge!({currency: original_currency}))) post[:sg_CreditType] = 2 post[:sg_AuthCode] = auth post[:sg_TransactionID] = transaction_id @@ -70,7 +70,7 @@ def refund(money, authorization, options={}) def credit(money, payment, options={}) post = {} add_payment(post, payment, options) - add_transaction_data("Credit", post, money, options) + add_transaction_data('Credit', post, money, options) post[:sg_CreditType] = 1 commit(post) @@ -78,8 +78,8 @@ def credit(money, payment, options={}) def void(authorization, options={}) post = {} - auth, transaction_id, token, exp_month, exp_year, original_amount, original_currency = authorization.split("|") - add_transaction_data("Void", post, (original_amount.to_f * 100), (options.merge!({currency: original_currency}))) + auth, transaction_id, token, exp_month, exp_year, original_amount, original_currency = authorization.split('|') + add_transaction_data('Void', post, (original_amount.to_f * 100), (options.merge!({currency: original_currency}))) post[:sg_CreditType] = 2 post[:sg_AuthCode] = auth post[:sg_TransactionID] = transaction_id @@ -116,7 +116,7 @@ def add_transaction_data(trans_type, post, money, options) post[:sg_Amount] = amount(money) post[:sg_ClientLoginID] = @options[:client_login_id] post[:sg_ClientPassword] = @options[:client_password] - post[:sg_ResponseFormat] = "4" + post[:sg_ResponseFormat] = '4' post[:sg_Version] = VERSION post[:sg_ClientUniqueID] = options[:order_id] if options[:order_id] post[:sg_UserID] = options[:user_id] if options[:user_id] @@ -202,11 +202,11 @@ def commit(parameters) end def success_from(response) - response[:status] == "APPROVED" + response[:status] == 'APPROVED' end def message_from(response) - return "Success" if success_from(response) + return 'Success' if success_from(response) response[:reason_codes] || response[:reason] end @@ -219,11 +219,11 @@ def authorization_from(response, parameters) parameters[:sg_ExpYear], parameters[:sg_Amount], parameters[:sg_Currency] - ].join("|") + ].join('|') end def split_authorization(authorization) - auth_code, transaction_id, token, month, year, original_amount = authorization.split("|") + auth_code, transaction_id, token, month, year, original_amount = authorization.split('|') { auth_code: auth_code, @@ -241,7 +241,7 @@ def post_data(params) params.map do |key, value| next if value != false && value.blank? "#{key}=#{CGI.escape(value.to_s)}" - end.compact.join("&") + end.compact.join('&') end def error_code_from(response) @@ -254,7 +254,7 @@ def underscore(camel_cased_word) camel_cased_word.to_s.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). - tr("-", "_"). + tr('-', '_'). downcase end end diff --git a/lib/active_merchant/billing/gateways/sage.rb b/lib/active_merchant/billing/gateways/sage.rb index 3841615c7a2..f4a029284dc 100644 --- a/lib/active_merchant/billing/gateways/sage.rb +++ b/lib/active_merchant/billing/gateways/sage.rb @@ -19,8 +19,8 @@ class SageGateway < Gateway :refund => '10' } - SOURCE_CARD = "bankcard" - SOURCE_ECHECK = "virtual_check" + SOURCE_CARD = 'bankcard' + SOURCE_ECHECK = 'virtual_check' def initialize(options = {}) requires!(options, :login, :password) @@ -36,7 +36,7 @@ def authorize(money, credit_card, options = {}) def purchase(money, payment_method, options = {}) post = {} - if card_brand(payment_method) == "check" + if card_brand(payment_method) == 'check' source = SOURCE_ECHECK add_check(post, payment_method) add_check_customer_data(post, options) @@ -59,13 +59,13 @@ def capture(money, reference, options = {}) def void(reference, options = {}) post = {} add_reference(post, reference) - source = reference.split(";").last + source = reference.split(';').last commit(:void, post, source) end def credit(money, payment_method, options = {}) post = {} - if card_brand(payment_method) == "check" + if card_brand(payment_method) == 'check' source = SOURCE_ECHECK add_check(post, payment_method) add_check_customer_data(post, options) @@ -115,8 +115,8 @@ def scrub(transcript) # use the same method as in pay_conex def force_utf8(string) return nil unless string - binary = string.encode("BINARY", invalid: :replace, undef: :replace, replace: "?") # Needed for Ruby 2.0 since #encode is a no-op if the string is already UTF-8. It's not needed for Ruby 2.1 and up since it's not a no-op there. - binary.encode("UTF-8", invalid: :replace, undef: :replace, replace: "?") + binary = string.encode('BINARY', invalid: :replace, undef: :replace, replace: '?') # Needed for Ruby 2.0 since #encode is a no-op if the string is already UTF-8. It's not needed for Ruby 2.1 and up since it's not a no-op there. + binary.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') end def add_credit_card(post, credit_card) @@ -143,7 +143,7 @@ def add_check_customer_data(post, options) # RCK for Returned Checks # ARC for Account Receivable Entry # TEL for TelephoneInitiated - post[:C_customer_type] = "WEB" + post[:C_customer_type] = 'WEB' # Optional  10  Digit Originator  ID – Assigned  By for  each transaction  class  or  business  purpose. If  not provided, the default Originator ID for the specific  Customer Type will be applied.  post[:C_originator_id] = options[:originator_id] @@ -160,7 +160,7 @@ def add_check_customer_data(post, options) end def format_birth_date(date) - date.respond_to?(:strftime) ? date.strftime("%m/%d/%Y") : date + date.respond_to?(:strftime) ? date.strftime('%m/%d/%Y') : date end # DDA for Checking @@ -214,7 +214,7 @@ def add_invoice(post, options) end def add_reference(post, reference) - ref, _ = reference.to_s.split(";") + ref, _ = reference.to_s.split(';') post[:T_reference] = ref end @@ -231,7 +231,7 @@ def add_addresses(post, options) post[:C_address] = billing_address[:address1] post[:C_city] = billing_address[:city] - post[:C_state] = empty?(billing_address[:state]) ? "Outside of US" : billing_address[:state] + post[:C_state] = empty?(billing_address[:state]) ? 'Outside of US' : billing_address[:state] post[:C_zip] = billing_address[:zip] post[:C_country] = billing_address[:country] post[:C_telephone] = billing_address[:phone] @@ -288,7 +288,7 @@ def post_data(action, params = {}) params[:M_key] = @options[:password] params[:T_code] = TRANSACTIONS[action] - params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def vault @@ -357,8 +357,8 @@ def add_identification(xml, identification, options) end def exp_date(credit_card) - year = sprintf("%.4i", credit_card.year) - month = sprintf("%.2i", credit_card.month) + year = sprintf('%.4i', credit_card.year) + month = sprintf('%.2i', credit_card.month) "#{month}#{year[-2..-1]}" end @@ -384,8 +384,8 @@ def commit(action, request) end ENVELOPE_NAMESPACES = { - 'xmlns:SOAP-ENV' => "http://schemas.xmlsoap.org/soap/envelope/", - 'xmlns:ns1' => "https://www.sagepayments.net/web_services/wsVault/wsVault" + 'xmlns:SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', + 'xmlns:ns1' => 'https://www.sagepayments.net/web_services/wsVault/wsVault' } ACTION_ELEMENTS = { @@ -415,8 +415,8 @@ def build_soap_request(action, body) def build_headers(action) { - "SOAPAction" => SOAP_ACTIONS[action], - "Content-Type" => "text/xml; charset=utf-8" + 'SOAPAction' => SOAP_ACTIONS[action], + 'Content-Type' => 'text/xml; charset=utf-8' } end @@ -430,12 +430,12 @@ def hashify_xml!(xml, response) xml = REXML::Document.new(xml) # Store - xml.elements.each("//Table1/*") do |node| + xml.elements.each('//Table1/*') do |node| response[node.name.underscore.to_sym] = node.text end # Unstore - xml.elements.each("//DELETE_DATAResponse/*") do |node| + xml.elements.each('//DELETE_DATAResponse/*') do |node| response[node.name.underscore.to_sym] = node.text end end diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index bcff3473ac2..97282fc835f 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -25,30 +25,30 @@ class SagePayGateway < Gateway } CREDIT_CARDS = { - :visa => "VISA", - :master => "MC", - :delta => "DELTA", - :solo => "SOLO", - :switch => "MAESTRO", - :maestro => "MAESTRO", - :american_express => "AMEX", - :electron => "UKE", - :diners_club => "DC", - :jcb => "JCB" + :visa => 'VISA', + :master => 'MC', + :delta => 'DELTA', + :solo => 'SOLO', + :switch => 'MAESTRO', + :maestro => 'MAESTRO', + :american_express => 'AMEX', + :electron => 'UKE', + :diners_club => 'DC', + :jcb => 'JCB' } AVS_CODE = { - "NOTPROVIDED" => nil, - "NOTCHECKED" => 'X', - "MATCHED" => 'Y', - "NOTMATCHED" => 'N' + 'NOTPROVIDED' => nil, + 'NOTCHECKED' => 'X', + 'MATCHED' => 'Y', + 'NOTMATCHED' => 'N' } CVV_CODE = { - "NOTPROVIDED" => 'S', - "NOTCHECKED" => 'X', - "MATCHED" => 'M', - "NOTMATCHED" => 'N' + 'NOTPROVIDED' => 'S', + 'NOTCHECKED' => 'X', + 'MATCHED' => 'M', + 'NOTMATCHED' => 'N' } OPTIONAL_REQUEST_FIELDS = { @@ -327,7 +327,7 @@ def is_usa(country) end def map_card_type(credit_card) - raise ArgumentError, "The credit card type must be provided" if card_brand(credit_card).blank? + raise ArgumentError, 'The credit card type must be provided' if card_brand(credit_card).blank? card_type = card_brand(credit_card).to_sym @@ -342,8 +342,8 @@ def map_card_type(credit_card) def format_date(month, year) return nil if year.blank? || month.blank? - year = sprintf("%.4i", year) - month = sprintf("%.2i", month) + year = sprintf('%.4i', year) + month = sprintf('%.2i', month) "#{month}#{year[-2..-1]}" end @@ -351,14 +351,14 @@ def format_date(month, year) def commit(action, parameters) response = parse( ssl_post(url_for(action), post_data(action, parameters)) ) - Response.new(response["Status"] == APPROVED, message_from(response), response, + Response.new(response['Status'] == APPROVED, message_from(response), response, :test => test?, :authorization => authorization_from(response, parameters, action), :avs_result => { - :street_match => AVS_CODE[ response["AddressResult"] ], - :postal_match => AVS_CODE[ response["PostCodeResult"] ], + :street_match => AVS_CODE[ response['AddressResult'] ], + :postal_match => AVS_CODE[ response['PostCodeResult'] ], }, - :cvv_result => CVV_CODE[ response["CV2Result"] ] + :cvv_result => CVV_CODE[ response['CV2Result'] ] ) end @@ -368,10 +368,10 @@ def authorization_from(response, params, action) response['Token'] else [ params[:VendorTxCode], - response["VPSTxId"] || params[:VPSTxId], - response["TxAuthNo"], - response["SecurityKey"] || params[:SecurityKey], - action ].join(";") + response['VPSTxId'] || params[:VPSTxId], + response['TxAuthNo'], + response['SecurityKey'] || params[:SecurityKey], + action ].join(';') end end @@ -386,7 +386,7 @@ def url_for(action) def build_url(action) endpoint = case action - when :purchase, :authorization then "vspdirect-register" + when :purchase, :authorization then 'vspdirect-register' when :store then 'directtoken' else TRANSACTIONS[action].downcase end @@ -394,7 +394,7 @@ def build_url(action) end def build_simulator_url(action) - endpoint = [ :purchase, :authorization ].include?(action) ? "VSPDirectGateway.asp" : "VSPServerGateway.asp?Service=Vendor#{TRANSACTIONS[action].capitalize}Tx" + endpoint = [ :purchase, :authorization ].include?(action) ? 'VSPDirectGateway.asp' : "VSPServerGateway.asp?Service=Vendor#{TRANSACTIONS[action].capitalize}Tx" "#{self.simulator_url}/#{endpoint}" end @@ -413,7 +413,7 @@ def post_data(action, parameters = {}) parameters.update(:ReferrerID => application_id) end - parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end # SagePay returns data in the following format diff --git a/lib/active_merchant/billing/gateways/sallie_mae.rb b/lib/active_merchant/billing/gateways/sallie_mae.rb index 1098790d292..510273a1fc4 100644 --- a/lib/active_merchant/billing/gateways/sallie_mae.rb +++ b/lib/active_merchant/billing/gateways/sallie_mae.rb @@ -21,7 +21,7 @@ def initialize(options = {}) end def test? - @options[:login] == "TEST0" + @options[:login] == 'TEST0' end def authorize(money, creditcard, options = {}) @@ -94,11 +94,11 @@ def add_creditcard(post, creditcard) def parse(body) h = {} - body.gsub!("<html><body><plaintext>", "") + body.gsub!('<html><body><plaintext>', '') body. split("\r\n"). map do |i| - a = i.split("=") + a = i.split('=') h[a.first] = a.last unless a.first.nil? end h @@ -111,30 +111,30 @@ def commit(action, money, parameters) case action when :sale - parameters[:action] = "ns_quicksale_cc" + parameters[:action] = 'ns_quicksale_cc' when :authonly - parameters[:action] = "ns_quicksale_cc" + parameters[:action] = 'ns_quicksale_cc' parameters[:authonly] = 1 when :capture - parameters[:action] = "ns_quicksale_cc" + parameters[:action] = 'ns_quicksale_cc' end - response = parse(ssl_post(self.live_url, parameters.to_post_data) || "") + response = parse(ssl_post(self.live_url, parameters.to_post_data) || '') Response.new(successful?(response), message_from(response), response, :test => test?, - :authorization => response["refcode"] + :authorization => response['refcode'] ) end def successful?(response) - response["Status"] == "Accepted" + response['Status'] == 'Accepted' end def message_from(response) if successful?(response) - "Accepted" + 'Accepted' else - response["Reason"].split(":")[2].capitalize unless response["Reason"].nil? + response['Reason'].split(':')[2].capitalize unless response['Reason'].nil? end end end diff --git a/lib/active_merchant/billing/gateways/secure_net.rb b/lib/active_merchant/billing/gateways/secure_net.rb index 4c18c3b54a4..0bf4f8ff55b 100644 --- a/lib/active_merchant/billing/gateways/secure_net.rb +++ b/lib/active_merchant/billing/gateways/secure_net.rb @@ -2,21 +2,21 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class SecureNetGateway < Gateway - API_VERSION = "4.0" + API_VERSION = '4.0' TRANSACTIONS = { - :auth_only => "0000", - :auth_capture => "0100", - :prior_auth_capture => "0200", - :void => "0400", - :credit => "0500" + :auth_only => '0000', + :auth_capture => '0100', + :prior_auth_capture => '0200', + :void => '0400', + :credit => '0500' } XML_ATTRIBUTES = { - 'xmlns' => "http://gateway.securenet.com/API/Contracts", - 'xmlns:i' => "http://www.w3.org/2001/XMLSchema-instance" + 'xmlns' => 'http://gateway.securenet.com/API/Contracts', + 'xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance' } - NIL_ATTRIBUTE = { 'i:nil' => "true" } + NIL_ATTRIBUTE = { 'i:nil' => 'true' } self.supported_countries = ['US'] self.supported_cardtypes = [:visa, :master, :american_express, :discover] @@ -77,7 +77,7 @@ def scrub(transcript) def commit(request) xml = build_request(request) url = test? ? self.test_url : self.live_url - data = ssl_post(url, xml, "Content-Type" => "text/xml") + data = ssl_post(url, xml, 'Content-Type' => 'text/xml') response = parse(data) Response.new(success?(response), message_from(response), response, @@ -92,7 +92,7 @@ def build_request(request) xml = Builder::XmlMarkup.new xml.instruct! - xml.tag!("TRANSACTION", XML_ATTRIBUTES) do + xml.tag!('TRANSACTION', XML_ATTRIBUTES) do xml << request end @@ -116,7 +116,7 @@ def build_capture_refund_void(authorization, options, action, money = nil) transaction_id, amount_in_ref, last_four = split_authorization(authorization) xml.tag! 'AMOUNT', amount(money) || amount_in_ref - xml.tag!("CARD") do + xml.tag!('CARD') do xml.tag! 'CARDNUMBER', last_four end @@ -128,7 +128,7 @@ def build_capture_refund_void(authorization, options, action, money = nil) end def add_credit_card(xml, creditcard) - xml.tag!("CARD") do + xml.tag!('CARD') do xml.tag! 'CARDCODE', creditcard.verification_value if creditcard.verification_value? xml.tag! 'CARDNUMBER', creditcard.number xml.tag! 'EXPDATE', expdate(creditcard) @@ -149,7 +149,7 @@ def add_address(xml, creditcard, options) return unless creditcard if address = options[:billing_address] || options[:address] - xml.tag!("CUSTOMER_BILL") do + xml.tag!('CUSTOMER_BILL') do xml.tag! 'ADDRESS', address[:address1].to_s xml.tag! 'CITY', address[:city].to_s xml.tag! 'COMPANY', address[:company].to_s @@ -167,7 +167,7 @@ def add_address(xml, creditcard, options) end if address = options[:shipping_address] - xml.tag!("CUSTOMER_SHIP") do + xml.tag!('CUSTOMER_SHIP') do xml.tag! 'ADDRESS', address[:address1].to_s xml.tag! 'CITY', address[:city].to_s xml.tag! 'COMPANY', address[:company].to_s @@ -193,7 +193,7 @@ def add_address(xml, creditcard, options) end def add_merchant_key(xml, options) - xml.tag!("MERCHANT_KEY") do + xml.tag!('MERCHANT_KEY') do xml.tag! 'GROUPID', 0 xml.tag! 'SECUREKEY', @options[:password] xml.tag! 'SECURENETID', @options[:login] @@ -236,7 +236,7 @@ def message_from(response) def parse(xml) response = {} xml = REXML::Document.new(xml) - root = REXML::XPath.first(xml, "//GATEWAYRESPONSE") + root = REXML::XPath.first(xml, '//GATEWAYRESPONSE') if root root.elements.to_a.each do |node| recurring_parse_element(response, node) @@ -255,12 +255,12 @@ def recurring_parse_element(response, node) end def split_authorization(authorization) - transaction_id, amount, last_four = authorization.split("|") + transaction_id, amount, last_four = authorization.split('|') [transaction_id, amount, last_four] end def build_authorization(response) - [response[:transactionid], response[:transactionamount], response[:last4_digits]].join("|") + [response[:transactionid], response[:transactionamount], response[:last4_digits]].join('|') end end diff --git a/lib/active_merchant/billing/gateways/secure_pay.rb b/lib/active_merchant/billing/gateways/secure_pay.rb index db3f6ad8f86..68d32c5b5c2 100644 --- a/lib/active_merchant/billing/gateways/secure_pay.rb +++ b/lib/active_merchant/billing/gateways/secure_pay.rb @@ -95,14 +95,14 @@ def post_data(action, parameters = {}) post[:version] = API_VERSION post[:login] = @options[:login] post[:tran_key] = @options[:password] - post[:relay_response] = "FALSE" + post[:relay_response] = 'FALSE' post[:type] = action - post[:delim_data] = "TRUE" - post[:delim_char] = "," - post[:encap_char] = "$" + post[:delim_data] = 'TRUE' + post[:delim_char] = ',' + post[:encap_char] = '$' post[:solution_ID] = application_id if application_id - request = post.merge(parameters).collect { |key, value| "x_#{key}=#{CGI.escape(value.to_s)}" }.join("&") + request = post.merge(parameters).collect { |key, value| "x_#{key}=#{CGI.escape(value.to_s)}" }.join('&') request end diff --git a/lib/active_merchant/billing/gateways/secure_pay_au.rb b/lib/active_merchant/billing/gateways/secure_pay_au.rb index 0bf27eb522d..f4e569253a3 100644 --- a/lib/active_merchant/billing/gateways/secure_pay_au.rb +++ b/lib/active_merchant/billing/gateways/secure_pay_au.rb @@ -43,9 +43,9 @@ class SecurePayAuGateway < Gateway } PERIODIC_ACTIONS = { - :add_triggered => "add", - :remove_triggered => "delete", - :trigger => "trigger" + :add_triggered => 'add', + :remove_triggered => 'delete', + :trigger => 'trigger' } PERIODIC_TYPES = { @@ -167,8 +167,8 @@ def build_request(action, body) xml.tag! 'RequestType', 'Payment' xml.tag! 'Payment' do - xml.tag! 'TxnList', "count" => 1 do - xml.tag! 'Txn', "ID" => 1 do + xml.tag! 'TxnList', 'count' => 1 do + xml.tag! 'Txn', 'ID' => 1 do xml.tag! 'txnType', TRANSACTIONS[action] xml.tag! 'txnSource', 23 xml << body @@ -226,8 +226,8 @@ def build_periodic_request(body) xml.tag! 'RequestType', 'Periodic' xml.tag! 'Periodic' do - xml.tag! 'PeriodicList', "count" => 1 do - xml.tag! 'PeriodicItem', "ID" => 1 do + xml.tag! 'PeriodicList', 'count' => 1 do + xml.tag! 'PeriodicItem', 'ID' => 1 do xml << body end end diff --git a/lib/active_merchant/billing/gateways/secure_pay_tech.rb b/lib/active_merchant/billing/gateways/secure_pay_tech.rb index 7f09342a448..5a6036afcd1 100644 --- a/lib/active_merchant/billing/gateways/secure_pay_tech.rb +++ b/lib/active_merchant/billing/gateways/secure_pay_tech.rb @@ -8,15 +8,15 @@ class SecurePayTechPostData < PostData self.live_url = self.test_url = 'https://tx.securepaytech.com/web/HttpPostPurchase' PAYMENT_GATEWAY_RESPONSES = { - 1 => "Transaction OK", - 2 => "Insufficient funds", - 3 => "Card expired", - 4 => "Card declined", - 5 => "Server error", - 6 => "Communications error", - 7 => "Unsupported transaction type", - 8 => "Bad or malformed request", - 9 => "Invalid card number" + 1 => 'Transaction OK', + 2 => 'Insufficient funds', + 3 => 'Card expired', + 4 => 'Card declined', + 5 => 'Server error', + 6 => 'Communications error', + 7 => 'Unsupported transaction type', + 8 => 'Bad or malformed request', + 9 => 'Invalid card number' } self.default_currency = 'NZD' diff --git a/lib/active_merchant/billing/gateways/securion_pay.rb b/lib/active_merchant/billing/gateways/securion_pay.rb index 5a1048d95ed..4d3035d3336 100644 --- a/lib/active_merchant/billing/gateways/securion_pay.rb +++ b/lib/active_merchant/billing/gateways/securion_pay.rb @@ -44,7 +44,7 @@ def purchase(money, payment, options={}) def authorize(money, payment, options={}) post = create_post_for_auth_or_purchase(money, payment, options) - post[:captured] = "false" + post[:captured] = 'false' commit('charges', post, options) end @@ -79,7 +79,7 @@ def store(credit_card, options = {}) #create customer and save card r.process { create_customer_add_card(r.authorization, options) } #void the charge - r.process(:ignore_result) { void(r.params["metadata"]["chargeId"], options) } + r.process(:ignore_result) { void(r.params['metadata']['chargeId'], options) } end else verify(credit_card, options) @@ -183,14 +183,14 @@ def parse(body) def commit(url, parameters = nil, options = {}, method = nil) response = api_request(url, parameters, options, method) - success = !response.key?("error") + success = !response.key?('error') Response.new(success, - (success ? "Transaction approved" : response["error"]["message"]), + (success ? 'Transaction approved' : response['error']['message']), response, test: test?, - authorization: (success ? response["id"] : response["error"]["charge"]), - error_code: (success ? nil : STANDARD_ERROR_CODE_MAPPING[response["error"]["code"]]) + authorization: (success ? response['id'] : response['error']['charge']), + error_code: (success ? nil : STANDARD_ERROR_CODE_MAPPING[response['error']['code']]) ) end @@ -198,8 +198,8 @@ def headers(options = {}) secret_key = options[:secret_key] || @options[:secret_key] headers = { - "Authorization" => "Basic " + Base64.encode64(secret_key.to_s + ":").strip, - "User-Agent" => "SecurionPay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}" + 'Authorization' => 'Basic ' + Base64.encode64(secret_key.to_s + ':').strip, + 'User-Agent' => "SecurionPay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}" } headers end @@ -224,11 +224,11 @@ def post_data(params) end post_data(h) elsif value.is_a?(Array) - value.map { |v| "#{key}[]=#{CGI.escape(v.to_s)}" }.join("&") + value.map { |v| "#{key}[]=#{CGI.escape(v.to_s)}" }.join('&') else "#{key}=#{CGI.escape(value.to_s)}" end - end.compact.join("&") + end.compact.join('&') end def api_request(endpoint, parameters = nil, options = {}, method = nil) @@ -253,8 +253,8 @@ def json_error(raw_response) msg = 'Invalid response received from the SecurionPay API.' msg += " (The raw response returned by the API was #{raw_response.inspect})" { - "error" => { - "message" => msg + 'error' => { + 'message' => msg } } end diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb index ef483288b32..6de7356d1de 100644 --- a/lib/active_merchant/billing/gateways/skip_jack.rb +++ b/lib/active_merchant/billing/gateways/skip_jack.rb @@ -6,11 +6,11 @@ module Billing #:nodoc: class SkipJackGateway < Gateway API_VERSION = '?.?' - self.live_url = "https://www.skipjackic.com" - self.test_url = "https://developer.skipjackic.com" + self.live_url = 'https://www.skipjackic.com' + self.test_url = 'https://developer.skipjackic.com' - BASIC_PATH = "/scripts/evolvcc.dll" - ADVANCED_PATH = "/evolvcc/evolvcc.aspx" + BASIC_PATH = '/scripts/evolvcc.dll' + ADVANCED_PATH = '/evolvcc/evolvcc.aspx' ACTIONS = { :authorization => 'AuthorizeAPI', @@ -25,34 +25,34 @@ class SkipJackGateway < Gateway CARD_CODE_ERRORS = %w( N S "" ) CARD_CODE_MESSAGES = { - "M" => "Card verification number matched", - "N" => "Card verification number didn't match", - "P" => "Card verification number was not processed", - "S" => "Card verification number should be on card but was not indicated", - "U" => "Issuer was not certified for card verification", - "" => "Transaction failed because incorrect card verification number was entered or no number was entered" + 'M' => 'Card verification number matched', + 'N' => "Card verification number didn't match", + 'P' => 'Card verification number was not processed', + 'S' => 'Card verification number should be on card but was not indicated', + 'U' => 'Issuer was not certified for card verification', + '' => 'Transaction failed because incorrect card verification number was entered or no number was entered' } AVS_ERRORS = %w( A B C E I N O P R W Z ) AVS_MESSAGES = { - "A" => "Street address matches billing information, zip/postal code does not", - "B" => "Street address match for international transaction. Postal code not verified due to incompatible formats", - "C" => "Street address and postal code not verified for internation transaction due to incompatible formats", - "D" => "Street address and postal code match for international transaction", - "E" => "Address verification service error", - "I" => "Address information not verified by international issuer", - "M" => "Street address and postal code match for international transaction", - "N" => "Neither street address nor zip/postal match billing information", - "O" => "Non-US issuer does not participate", - "P" => "Postal codes match for international transaction but street address not verified due to incompatible formats", - "R" => "Payment gateway was unavailable or timed out", - "S" => "Address verification service not supported by issuer", - "U" => "Address information is unavailable", - "W" => "9-digit zip/postal code matches billing information, street address does not", - "X" => "Street address and 9-digit zip/postal code matches billing information", - "Y" => "Street address and 5-digit zip/postal code matches billing information", - "Z" => "5-digit zip/postal code matches billing information, street address does not", + 'A' => 'Street address matches billing information, zip/postal code does not', + 'B' => 'Street address match for international transaction. Postal code not verified due to incompatible formats', + 'C' => 'Street address and postal code not verified for internation transaction due to incompatible formats', + 'D' => 'Street address and postal code match for international transaction', + 'E' => 'Address verification service error', + 'I' => 'Address information not verified by international issuer', + 'M' => 'Street address and postal code match for international transaction', + 'N' => 'Neither street address nor zip/postal match billing information', + 'O' => 'Non-US issuer does not participate', + 'P' => 'Postal codes match for international transaction but street address not verified due to incompatible formats', + 'R' => 'Payment gateway was unavailable or timed out', + 'S' => 'Address verification service not supported by issuer', + 'U' => 'Address information is unavailable', + 'W' => '9-digit zip/postal code matches billing information, street address does not', + 'X' => 'Street address and 9-digit zip/postal code matches billing information', + 'Y' => 'Street address and 5-digit zip/postal code matches billing information', + 'Z' => '5-digit zip/postal code matches billing information, street address does not', } CHANGE_STATUS_ERROR_MESSAGES = { @@ -355,7 +355,7 @@ def post_data(action, money, params = {}) add_credentials(params, action) add_amount(params, action, money) sorted_params = params.to_a.sort{|a,b| a.to_s <=> b.to_s}.reverse - sorted_params.collect { |key, value| "#{key.to_s}=#{CGI.escape(value.to_s)}" }.join("&") + sorted_params.collect { |key, value| "#{key.to_s}=#{CGI.escape(value.to_s)}" }.join('&') end def add_transaction_id(post, transaction_id) diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb index 64b59c3f6fe..2b572aaa9d5 100644 --- a/lib/active_merchant/billing/gateways/smart_ps.rb +++ b/lib/active_merchant/billing/gateways/smart_ps.rb @@ -25,7 +25,7 @@ def authorize(money, creditcard, options = {}) add_invoice(post, options) add_payment_source(post, creditcard,options) add_address(post, options[:billing_address] || options[:address]) - add_address(post, options[:shipping_address], "shipping") + add_address(post, options[:shipping_address], 'shipping') add_customer_data(post, options) add_currency(post, money, options) add_taxes(post, options) @@ -38,7 +38,7 @@ def purchase(money, payment_source, options = {}) add_invoice(post, options) add_payment_source(post, payment_source, options) add_address(post, options[:billing_address] || options[:address]) - add_address(post, options[:shipping_address], "shipping") + add_address(post, options[:shipping_address], 'shipping') add_customer_data(post, options) add_currency(post, money, options) add_taxes(post, options) @@ -89,7 +89,7 @@ def verify(credit_card, options = {}) # CreditCard object. def update(vault_id, creditcard, options = {}) post = {} - post[:customer_vault] = "update_customer" + post[:customer_vault] = 'update_customer' add_customer_vault_id(post, vault_id) add_creditcard(post, creditcard, options) add_address(post, options[:billing_address] || options[:address]) @@ -109,7 +109,7 @@ def amend(auth, options = {}) def delete(vault_id) post = {} - post[:customer_vault] = "delete_customer" + post[:customer_vault] = 'delete_customer' add_customer_vault_id(post, vault_id) commit(nil, nil, post) end @@ -138,17 +138,17 @@ def add_customer_data(post, options) end end - def add_address(post, address,prefix="") - prefix +="_" unless prefix.blank? + def add_address(post, address,prefix='') + prefix +='_' unless prefix.blank? unless address.blank? or address.values.blank? - post[prefix+"address1"] = address[:address1].to_s - post[prefix+"address2"] = address[:address2].to_s unless address[:address2].blank? - post[prefix+"company"] = address[:company].to_s - post[prefix+"phone"] = address[:phone].to_s - post[prefix+"zip"] = address[:zip].to_s - post[prefix+"city"] = address[:city].to_s - post[prefix+"country"] = address[:country].to_s - post[prefix+"state"] = address[:state].blank? ? 'n/a' : address[:state] + post[prefix+'address1'] = address[:address1].to_s + post[prefix+'address2'] = address[:address2].to_s unless address[:address2].blank? + post[prefix+'company'] = address[:company].to_s + post[prefix+'phone'] = address[:phone].to_s + post[prefix+'zip'] = address[:zip].to_s + post[prefix+'city'] = address[:city].to_s + post[prefix+'country'] = address[:country].to_s + post[prefix+'state'] = address[:state].blank? ? 'n/a' : address[:state] end end @@ -182,7 +182,7 @@ def add_customer_vault_id(params, vault_id) def add_creditcard(post, creditcard, options) if options[:store] - post[:customer_vault] = "add_customer" + post[:customer_vault] = 'add_customer' post[:customer_vault_id] = options[:store] unless options[:store] == true end post[:ccnumber] = creditcard.number @@ -194,7 +194,7 @@ def add_creditcard(post, creditcard, options) def add_check(post, check, options) if options[:store] - post[:customer_vault] = "add_customer" + post[:customer_vault] = 'add_customer' post[:customer_vault_id] = options[:store] unless options[:store] == true end @@ -207,7 +207,7 @@ def add_check(post, check, options) end def add_sku(post,options) - post["product_sku_#"] = options[:sku] || options["product_sku_#"] + post['product_sku_#'] = options[:sku] || options['product_sku_#'] end def add_transaction(post, auth) @@ -231,31 +231,31 @@ def parse(body) def commit(action, money, parameters) parameters[:amount] = localized_amount(money, parameters[:currency] || default_currency) if money response = parse( ssl_post(self.live_url, post_data(action,parameters)) ) - Response.new(response["response"] == "1", message_from(response), response, - :authorization => (response["transactionid"] || response["customer_vault_id"]), + Response.new(response['response'] == '1', message_from(response), response, + :authorization => (response['transactionid'] || response['customer_vault_id']), :test => test?, - :cvv_result => response["cvvresponse"], - :avs_result => { :code => response["avsresponse"] } + :cvv_result => response['cvvresponse'], + :avs_result => { :code => response['avsresponse'] } ) end def expdate(creditcard) - year = sprintf("%.04i", creditcard.year) - month = sprintf("%.02i", creditcard.month) + year = sprintf('%.04i', creditcard.year) + month = sprintf('%.02i', creditcard.month) "#{month}#{year[-2..-1]}" end def message_from(response) - case response["responsetext"] - when "SUCCESS", "Approved", nil # This is dubious, but responses from UPDATE are nil. - "This transaction has been approved" - when "DECLINE" - "This transaction has been declined" + case response['responsetext'] + when 'SUCCESS', 'Approved', nil # This is dubious, but responses from UPDATE are nil. + 'This transaction has been approved' + when 'DECLINE' + 'This transaction has been declined' else - response["responsetext"] + response['responsetext'] end end @@ -265,7 +265,7 @@ def post_data(action, parameters = {}) post[:password] = @options[:password] post[:type] = action if action - request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&") + request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') request end @@ -274,7 +274,7 @@ def determine_funding_source(source) when source.is_a?(String) then :vault when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card when card_brand(source) == 'check' then :check - else raise ArgumentError, "Unsupported funding source provided" + else raise ArgumentError, 'Unsupported funding source provided' end end end diff --git a/lib/active_merchant/billing/gateways/so_easy_pay.rb b/lib/active_merchant/billing/gateways/so_easy_pay.rb index 2227a74ebe4..cb80073bff0 100644 --- a/lib/active_merchant/billing/gateways/so_easy_pay.rb +++ b/lib/active_merchant/billing/gateways/so_easy_pay.rb @@ -135,7 +135,7 @@ def fill_transaction_id(soap, transaction_id) def fill_card(soap, card) soap.tag!('cardNumber', card.number.to_s) soap.tag!('cardSecurityCode', card.verification_value.to_s) - soap.tag!('cardExpireMonth', card.month.to_s.rjust(2, "0")) + soap.tag!('cardExpireMonth', card.month.to_s.rjust(2, '0')) soap.tag!('cardExpireYear', card.year.to_s) end @@ -157,8 +157,8 @@ def parse(response, action) end def commit(soap_action, soap, options) - headers = {"SOAPAction" => "\"urn:Interface##{soap_action}\"", - "Content-Type" => "text/xml; charset=utf-8"} + headers = {'SOAPAction' => "\"urn:Interface##{soap_action}\"", + 'Content-Type' => 'text/xml; charset=utf-8'} response_string = ssl_post(test? ? self.test_url : self.live_url, soap, headers) response = parse(response_string, soap_action) return Response.new(response['errorcode'] == '000', diff --git a/lib/active_merchant/billing/gateways/spreedly_core.rb b/lib/active_merchant/billing/gateways/spreedly_core.rb index 1aab6d811ce..20a92886494 100644 --- a/lib/active_merchant/billing/gateways/spreedly_core.rb +++ b/lib/active_merchant/billing/gateways/spreedly_core.rb @@ -152,7 +152,7 @@ def save_card(retain, credit_card, options) doc.retained(true) if retain end - commit("payment_methods.xml", request, :post, :payment_method_token) + commit('payment_methods.xml', request, :post, :payment_method_token) end def purchase_with_token(money, payment_method_token, options) diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 2616d4e07b7..aeaac0b4b82 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -48,24 +48,24 @@ class StripeGateway < Gateway } BANK_ACCOUNT_HOLDER_TYPE_MAPPING = { - "personal" => "individual", - "business" => "company", + 'personal' => 'individual', + 'business' => 'company', } MINIMUM_AUTHORIZE_AMOUNTS = { - "USD" => 100, - "CAD" => 100, - "GBP" => 60, - "EUR" => 100, - "DKK" => 500, - "NOK" => 600, - "SEK" => 600, - "CHF" => 100, - "AUD" => 100, - "JPY" => 100, - "MXN" => 2000, - "SGD" => 100, - "HKD" => 800 + 'USD' => 100, + 'CAD' => 100, + 'GBP' => 60, + 'EUR' => 100, + 'DKK' => 500, + 'NOK' => 600, + 'SEK' => 600, + 'CHF' => 100, + 'AUD' => 100, + 'JPY' => 100, + 'MXN' => 2000, + 'SGD' => 100, + 'HKD' => 800 } def initialize(options = {}) @@ -79,14 +79,14 @@ def authorize(money, payment, options = {}) MultiResponse.run do |r| if payment.is_a?(ApplePayPaymentToken) r.process { tokenize_apple_pay_token(payment) } - payment = StripePaymentToken.new(r.params["token"]) if r.success? + payment = StripePaymentToken.new(r.params['token']) if r.success? end r.process do post = create_post_for_auth_or_purchase(money, payment, options) if emv_payment?(payment) add_application_fee(post, options) else - post[:capture] = "false" + post[:capture] = 'false' end commit(:post, 'charges', post, options) end @@ -102,14 +102,14 @@ def authorize(money, payment, options = {}) # purchase(money, nil, { :customer => id, ... }) def purchase(money, payment, options = {}) if ach?(payment) - direct_bank_error = "Direct bank account transactions are not supported. Bank accounts must be stored and verified before use." + direct_bank_error = 'Direct bank account transactions are not supported. Bank accounts must be stored and verified before use.' return Response.new(false, direct_bank_error) end MultiResponse.run do |r| if payment.is_a?(ApplePayPaymentToken) r.process { tokenize_apple_pay_token(payment) } - payment = StripePaymentToken.new(r.params["token"]) if r.success? + payment = StripePaymentToken.new(r.params['token']) if r.success? end r.process do post = create_post_for_auth_or_purchase(money, payment, options) @@ -168,11 +168,11 @@ def verify(payment, options = {}) def application_fee_from_response(response) return unless response.success? - response.params["application_fee"] unless response.params["application_fee"].empty? + response.params['application_fee'] unless response.params['application_fee'].empty? end def refund_application_fee(money, identification, options = {}) - return Response.new(false, "Application fee id could not be found") unless identification + return Response.new(false, 'Application fee id could not be found') unless identification post = {} add_amount(post, money, options) @@ -190,13 +190,13 @@ def store(payment, options = {}) if payment.is_a?(ApplePayPaymentToken) token_exchange_response = tokenize_apple_pay_token(payment) - params = { card: token_exchange_response.params["token"]["id"] } if token_exchange_response.success? + params = { card: token_exchange_response.params['token']['id'] } if token_exchange_response.success? elsif payment.is_a?(StripePaymentToken) add_payment_token(params, payment, options) elsif payment.is_a?(Check) bank_token_response = tokenize_bank_account(payment) return bank_token_response unless bank_token_response.success? - params = { source: bank_token_response.params["token"]["id"] } + params = { source: bank_token_response.params['token']['id'] } else add_creditcard(params, payment, options) end @@ -235,10 +235,10 @@ def update_customer(customer_id, options = {}) end def unstore(identification, options = {}, deprecated_options = {}) - customer_id, card_id = identification.split("|") + customer_id, card_id = identification.split('|') if options.kind_of?(String) - ActiveMerchant.deprecated "Passing the card_id as the 2nd parameter is deprecated. The response authorization includes both the customer_id and the card_id." + ActiveMerchant.deprecated 'Passing the card_id as the 2nd parameter is deprecated. The response authorization includes both the customer_id and the card_id.' card_id ||= options options = deprecated_options end @@ -248,18 +248,18 @@ def unstore(identification, options = {}, deprecated_options = {}) def tokenize_apple_pay_token(apple_pay_payment_token, options = {}) token_response = api_request(:post, "tokens?pk_token=#{CGI.escape(apple_pay_payment_token.payment_data.to_json)}") - success = !token_response.key?("error") + success = !token_response.key?('error') - if success && token_response.key?("id") + if success && token_response.key?('id') Response.new(success, nil, token: token_response) else - Response.new(success, token_response["error"]["message"]) + Response.new(success, token_response['error']['message']) end end def verify_credentials begin - ssl_get(live_url + "charges/nonexistent", headers) + ssl_get(live_url + 'charges/nonexistent', headers) rescue ResponseError => e return false if e.response.code.to_i == 401 end @@ -355,7 +355,7 @@ def add_expand_parameters(post, options) def add_external_account(post, card_params, payment) external_account = {} - external_account[:object] ="card" + external_account[:object] ='card' external_account[:currency] = (options[:currency] || currency(payment)).downcase post[:external_account] = external_account.merge(card_params[:card]) end @@ -396,7 +396,7 @@ def add_creditcard(post, creditcard, options) card = {} if emv_payment?(creditcard) add_emv_creditcard(post, creditcard.icc_data) - post[:card][:read_method] = "contactless" if creditcard.read_method == 'contactless' + post[:card][:read_method] = 'contactless' if creditcard.read_method == 'contactless' if creditcard.encrypted_pin_cryptogram.present? && creditcard.encrypted_pin_ksn.present? post[:card][:encrypted_pin] = creditcard.encrypted_pin_cryptogram post[:card][:encrypted_pin_key_id] = creditcard.encrypted_pin_ksn @@ -407,7 +407,7 @@ def add_creditcard(post, creditcard, options) if creditcard.respond_to?(:read_method) card[:fallback_reason] = 'no_chip' if creditcard.read_method == 'fallback_no_chip' card[:fallback_reason] = 'chip_error' if creditcard.read_method == 'fallback_chip_error' - card[:read_method] = "contactless_magstripe_mode" if creditcard.read_method == 'contactless_magstripe' + card[:read_method] = 'contactless_magstripe_mode' if creditcard.read_method == 'contactless_magstripe' end else card[:number] = creditcard.number @@ -428,8 +428,8 @@ def add_creditcard(post, creditcard, options) elsif creditcard.kind_of?(String) if options[:track_data] card[:swipe_data] = options[:track_data] - elsif creditcard.include?("|") - customer_id, card_id = creditcard.split("|") + elsif creditcard.include?('|') + customer_id, card_id = creditcard.split('|') card = card_id post[:customer] = customer_id else @@ -444,12 +444,12 @@ def add_emv_creditcard(post, icc_data, options = {}) end def add_payment_token(post, token, options = {}) - post[:card] = token.payment_data["id"] + post[:card] = token.payment_data['id'] end def add_customer(post, payment, options) if options[:customer] && !payment.respond_to?(:number) - ActiveMerchant.deprecated "Passing the customer in the options is deprecated. Just use the response.authorization instead." + ActiveMerchant.deprecated 'Passing the customer in the options is deprecated. Just use the response.authorization instead.' post[:customer] = options[:customer] end end @@ -499,11 +499,11 @@ def post_data(params) end post_data(h) elsif value.is_a?(Array) - value.map { |v| "#{key}[]=#{CGI.escape(v.to_s)}" }.join("&") + value.map { |v| "#{key}[]=#{CGI.escape(v.to_s)}" }.join('&') else "#{key}=#{CGI.escape(value.to_s)}" end - end.compact.join("&") + end.compact.join('&') end def headers(options = {}) @@ -511,14 +511,14 @@ def headers(options = {}) idempotency_key = options[:idempotency_key] headers = { - "Authorization" => "Basic " + Base64.encode64(key.to_s + ":").strip, - "User-Agent" => "Stripe/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}", - "Stripe-Version" => api_version(options), - "X-Stripe-Client-User-Agent" => stripe_client_user_agent(options), - "X-Stripe-Client-User-Metadata" => {:ip => options[:ip]}.to_json + 'Authorization' => 'Basic ' + Base64.encode64(key.to_s + ':').strip, + 'User-Agent' => "Stripe/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}", + 'Stripe-Version' => api_version(options), + 'X-Stripe-Client-User-Agent' => stripe_client_user_agent(options), + 'X-Stripe-Client-User-Metadata' => {:ip => options[:ip]}.to_json } - headers.merge!("Idempotency-Key" => idempotency_key) if idempotency_key - headers.merge!("Stripe-Account" => options[:stripe_account]) if options[:stripe_account] + headers.merge!('Idempotency-Key' => idempotency_key) if idempotency_key + headers.merge!('Stripe-Account' => options[:stripe_account]) if options[:stripe_account] headers end @@ -528,7 +528,7 @@ def stripe_client_user_agent(options) end def api_version(options) - options[:version] || @options[:version] || "2015-04-07" + options[:version] || @options[:version] || '2015-04-07' end def api_request(method, endpoint, parameters = nil, options = {}) @@ -553,7 +553,7 @@ def commit(method, url, parameters = nil, options = {}) card = card_from_response(response) avs_code = AVS_CODE_TRANSLATOR["line1: #{card["address_line1_check"]}, zip: #{card["address_zip_check"]}"] - cvc_code = CVC_CODE_TRANSLATOR[card["cvc_check"]] + cvc_code = CVC_CODE_TRANSLATOR[card['cvc_check']] Response.new(success, message_from(success, response), @@ -568,23 +568,23 @@ def commit(method, url, parameters = nil, options = {}) end def authorization_from(success, url, method, response) - return response.fetch("error", {})["charge"] unless success + return response.fetch('error', {})['charge'] unless success - if url == "customers" - [response["id"], response["sources"]["data"].first["id"]].join("|") + if url == 'customers' + [response['id'], response['sources']['data'].first['id']].join('|') elsif method == :post && url.match(/customers\/.*\/cards/) - [response["customer"], response["id"]].join("|") + [response['customer'], response['id']].join('|') else - response["id"] + response['id'] end end def message_from(success, response) - success ? "Transaction approved" : response.fetch("error", {"message" => "No error details"})["message"] + success ? 'Transaction approved' : response.fetch('error', {'message' => 'No error details'})['message'] end def success_from(response) - !response.key?("error") && response["status"] != "failed" + !response.key?('error') && response['status'] != 'failed' end def response_error(raw_response) @@ -599,8 +599,8 @@ def json_error(raw_response) msg = 'Invalid response received from the Stripe API. Please contact support@stripe.com if you continue to receive this message.' msg += " (The raw response returned by the API was #{raw_response.inspect})" { - "error" => { - "message" => msg + 'error' => { + 'message' => msg } } end @@ -624,13 +624,13 @@ def quickchip_payment?(payment) end def card_from_response(response) - response["card"] || response["active_card"] || response["source"] || {} + response['card'] || response['active_card'] || response['source'] || {} end def emv_authorization_from_response(response) - return response["error"]["emv_auth_data"] if response["error"] + return response['error']['emv_auth_data'] if response['error'] - card_from_response(response)["emv_auth_data"] + card_from_response(response)['emv_auth_data'] end def error_code_from(response) @@ -659,12 +659,12 @@ def tokenize_bank_account(bank_account, options = {}) } token_response = api_request(:post, "tokens?#{post_data(post)}") - success = token_response["error"].nil? + success = token_response['error'].nil? - if success && token_response["id"] + if success && token_response['id'] Response.new(success, nil, token: token_response) else - Response.new(success, token_response["error"]["message"]) + Response.new(success, token_response['error']['message']) end end @@ -673,7 +673,7 @@ def ach?(payment_method) when String, nil false else - card_brand(payment_method) == "check" + card_brand(payment_method) == 'check' end end diff --git a/lib/active_merchant/billing/gateways/swipe_checkout.rb b/lib/active_merchant/billing/gateways/swipe_checkout.rb index 78ad5f5da43..802a033188f 100644 --- a/lib/active_merchant/billing/gateways/swipe_checkout.rb +++ b/lib/active_merchant/billing/gateways/swipe_checkout.rb @@ -69,7 +69,7 @@ def add_invoice(post, options) post[:td_user_data] = options[:order_id] if options[:order_id] post[:td_item] = options[:description] if options[:description] post[:td_description] = options[:description] if options[:description] - post[:item_quantity] = "1" + post[:item_quantity] = '1' end def add_creditcard(post, creditcard) @@ -95,16 +95,16 @@ def add_amount(post, money, options) def commit(action, money, parameters) case action - when "sale" + when 'sale' begin response = call_api(TRANSACTION_API, parameters) # response code and message params should always be present - code = response["response_code"] - message = response["message"] + code = response['response_code'] + message = response['message'] if code == 200 - result = response["data"]["result"] + result = response['data']['result'] success = (result == 'accepted' || (test? && result == 'test-accepted')) Response.new(success, diff --git a/lib/active_merchant/billing/gateways/telr.rb b/lib/active_merchant/billing/gateways/telr.rb index 6211af9abd6..9d8085fb175 100644 --- a/lib/active_merchant/billing/gateways/telr.rb +++ b/lib/active_merchant/billing/gateways/telr.rb @@ -3,13 +3,13 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class TelrGateway < Gateway - self.display_name = "Telr" - self.homepage_url = "http://www.telr.com/" + self.display_name = 'Telr' + self.homepage_url = 'http://www.telr.com/' - self.live_url = "https://secure.telr.com/gateway/remote.xml" + self.live_url = 'https://secure.telr.com/gateway/remote.xml' - self.supported_countries = ["AE", "IN", "SA"] - self.default_currency = "AED" + self.supported_countries = ['AE', 'IN', 'SA'] + self.default_currency = 'AED' self.money_format = :dollars self.supported_cardtypes = [:visa, :master, :american_express, :maestro, :solo, :jcb] @@ -35,7 +35,7 @@ def initialize(options={}) def purchase(amount, payment_method, options={}) commit(:purchase, amount, options[:currency]) do |doc| - add_invoice(doc, "sale", amount, payment_method, options) + add_invoice(doc, 'sale', amount, payment_method, options) add_payment_method(doc, payment_method, options) add_customer_data(doc, payment_method, options) end @@ -43,7 +43,7 @@ def purchase(amount, payment_method, options={}) def authorize(amount, payment_method, options={}) commit(:authorize, amount, options[:currency]) do |doc| - add_invoice(doc, "auth", amount, payment_method, options) + add_invoice(doc, 'auth', amount, payment_method, options) add_payment_method(doc, payment_method, options) add_customer_data(doc, payment_method, options) end @@ -51,34 +51,34 @@ def authorize(amount, payment_method, options={}) def capture(amount, authorization, options={}) commit(:capture) do |doc| - add_invoice(doc, "capture", amount, authorization, options) + add_invoice(doc, 'capture', amount, authorization, options) end end def void(authorization, options={}) _, amount, currency = split_authorization(authorization) commit(:void) do |doc| - add_invoice(doc, "void", amount.to_i, authorization, options.merge(currency: currency)) + add_invoice(doc, 'void', amount.to_i, authorization, options.merge(currency: currency)) end end def refund(amount, authorization, options={}) commit(:refund) do |doc| - add_invoice(doc, "refund", amount, authorization, options) + add_invoice(doc, 'refund', amount, authorization, options) end end def verify(credit_card, options={}) commit(:verify) do |doc| - add_invoice(doc, "verify", 100, credit_card, options) + add_invoice(doc, 'verify', 100, credit_card, options) add_payment_method(doc, credit_card, options) add_customer_data(doc, credit_card, options) end end def verify_credentials - response = void("0") - !["01", "04"].include?(response.error_code) + response = void('0') + !['01', '04'].include?(response.error_code) end def supports_scrubbing? @@ -101,7 +101,7 @@ def add_invoice(doc, action, money, payment_method, options) doc.currency(options[:currency] || currency(money)) doc.cartid(options[:order_id]) doc.class_(transaction_class(action, payment_method)) - doc.description(options[:description] || "Description") + doc.description(options[:description] || 'Description') doc.test_(test_mode) add_ref(doc, action, payment_method) end @@ -126,7 +126,7 @@ def add_customer_data(doc, payment_method, options) doc.first(payment_method.first_name) doc.last(payment_method.last_name) end - doc.email(options[:email] || "unspecified@email.com") + doc.email(options[:email] || 'unspecified@email.com') doc.ip(options[:ip]) if options[:ip] doc.address do add_address(doc, options) @@ -136,9 +136,9 @@ def add_customer_data(doc, payment_method, options) def add_address(doc, options) address = options[:billing_address] || {} - doc.country(address[:country] ? lookup_country_code(address[:country]) : "NA") - doc.city(address[:city] || "City") - doc.line1(address[:address1] || "Address") + doc.country(address[:country] ? lookup_country_code(address[:country]) : 'NA') + doc.city(address[:city] || 'City') + doc.line1(address[:address1] || 'Address') return unless address doc.line2(address[:address2]) if address[:address2] doc.zip(address[:zip]) if address[:zip] @@ -146,7 +146,7 @@ def add_address(doc, options) end def add_ref(doc, action, payment_method) - if ["capture", "refund", "void"].include?(action) || payment_method.is_a?(String) + if ['capture', 'refund', 'void'].include?(action) || payment_method.is_a?(String) doc.ref(split_authorization(payment_method)[0]) end end @@ -204,10 +204,10 @@ def test_mode end def transaction_class(action, payment_method) - if payment_method.is_a?(String) && action == "sale" - return "cont" + if payment_method.is_a?(String) && action == 'sale' + return 'cont' else - return "moto" + return 'moto' end end @@ -215,7 +215,7 @@ def parse(xml) response = {} doc = Nokogiri::XML(xml) - doc.root.xpath("*").each do |node| + doc.root.xpath('*').each do |node| if (node.elements.size == 0) response[node.name.downcase.to_sym] = node.text else @@ -240,12 +240,12 @@ def split_authorization(authorization) end def success_from(response) - response[:status] == "A" + response[:status] == 'A' end def message_from(succeeded, response) if succeeded - "Succeeded" + 'Succeeded' else response[:message] end @@ -267,7 +267,7 @@ def avs_result(parsed) def headers { - "Content-Type" => "text/xml" + 'Content-Type' => 'text/xml' } end end diff --git a/lib/active_merchant/billing/gateways/trans_first.rb b/lib/active_merchant/billing/gateways/trans_first.rb index c79d5fab0b2..337a4f03d9b 100644 --- a/lib/active_merchant/billing/gateways/trans_first.rb +++ b/lib/active_merchant/billing/gateways/trans_first.rb @@ -15,19 +15,19 @@ class TransFirstGateway < Gateway DECLINED = 'The transaction was declined' ACTIONS = { - purchase: "CCSale", - purchase_echeck: "ACHDebit", - refund: "CreditCardCredit", - refund_echeck: "ACHVoidTransaction", - void: "CreditCardAutoRefundorVoid", + purchase: 'CCSale', + purchase_echeck: 'ACHDebit', + refund: 'CreditCardCredit', + refund_echeck: 'ACHVoidTransaction', + void: 'CreditCardAutoRefundorVoid', } ENDPOINTS = { - purchase: "creditcard.asmx", - purchase_echeck: "checkverifyws/checkverifyws.asmx", - refund: "creditcard.asmx", - refund_echeck: "checkverifyws/checkverifyws.asmx", - void: "creditcard.asmx" + purchase: 'creditcard.asmx', + purchase_echeck: 'checkverifyws/checkverifyws.asmx', + refund: 'creditcard.asmx', + refund_echeck: 'checkverifyws/checkverifyws.asmx', + void: 'creditcard.asmx' } def initialize(options = {}) @@ -55,7 +55,7 @@ def refund(money, authorization, options={}) add_pair(post, :TransID, transaction_id) add_pair(post, :RefID, options[:order_id], required: true) - commit((payment_type == "check" ? :refund_echeck : :refund), post) + commit((payment_type == 'check' ? :refund_echeck : :refund), post) end def void(authorization, options={}) @@ -93,8 +93,8 @@ def add_address(post, options) add_pair(post, :Address, address[:address1], required: true) add_pair(post, :ZipCode, address[:zip], required: true) else - add_pair(post, :Address, "", required: true) - add_pair(post, :ZipCode, "", required: true) + add_pair(post, :Address, '', required: true) + add_pair(post, :ZipCode, '', required: true) end end @@ -103,8 +103,8 @@ def add_invoice(post, options) add_pair(post, :PONumber, options[:invoice], required: true) add_pair(post, :SaleTaxAmount, amount(options[:tax] || 0)) add_pair(post, :TaxIndicator, 0) - add_pair(post, :PaymentDesc, options[:description] || "", required: true) - add_pair(post, :CompanyName, options[:company_name] || "", required: true) + add_pair(post, :PaymentDesc, options[:description] || '', required: true) + add_pair(post, :CompanyName, options[:company_name] || '', required: true) end def add_payment(post, payment) @@ -125,11 +125,11 @@ def add_credit_card(post, payment) def add_echeck(post, payment) add_pair(post, :TransRoute, payment.routing_number, required: true) add_pair(post, :BankAccountNo, payment.account_number, required: true) - add_pair(post, :BankAccountType, add_or_use_default(payment.account_type, "Checking"), required: true) - add_pair(post, :CheckType, add_or_use_default(payment.account_holder_type, "Personal"), required: true) + add_pair(post, :BankAccountType, add_or_use_default(payment.account_type, 'Checking'), required: true) + add_pair(post, :CheckType, add_or_use_default(payment.account_holder_type, 'Personal'), required: true) add_pair(post, :Name, payment.name, required: true) - add_pair(post, :ProcessDate, Time.now.strftime("%m%d%y"), required: true) - add_pair(post, :Description, "", required: true) + add_pair(post, :ProcessDate, Time.now.strftime('%m%d%y'), required: true) + add_pair(post, :Description, '', required: true) end def add_or_use_default(payment_data, default_value) @@ -141,7 +141,7 @@ def add_unused_fields(action, post) return unless action == :purchase UNUSED_CREDIT_CARD_FIELDS.each do |f| - post[f] = "" + post[f] = '' end end @@ -156,7 +156,7 @@ def parse(data) response = {} xml = REXML::Document.new(data) - root = REXML::XPath.first(xml, "*") + root = REXML::XPath.first(xml, '*') if root.nil? response[:message] = data.to_s.strip @@ -183,7 +183,7 @@ def commit(action, params) end def authorization_from(response) - if response[:status] == "APPROVED" + if response[:status] == 'APPROVED' "#{response[:trans_id]}|check" else "#{response[:trans_id]}|creditcard" @@ -192,13 +192,13 @@ def authorization_from(response) def success_from(response) case response[:status] - when "Authorized" + when 'Authorized' true - when "Voided" + when 'Voided' true - when "APPROVED" + when 'APPROVED' true - when "VOIDED" + when 'VOIDED' true else false @@ -219,7 +219,7 @@ def post_data(action, params = {}) params[:MerchantID] = @options[:login] params[:RegKey] = @options[:password] - request = params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + request = params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') request end @@ -233,7 +233,7 @@ def url(action) end def split_authorization(authorization) - authorization.split("|") + authorization.split('|') end end end diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb index 388ff8b575c..546a3d4d0c1 100644 --- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb @@ -1,162 +1,162 @@ -require "nokogiri" +require 'nokogiri' module ActiveMerchant #:nodoc: module Billing #:nodoc: class TransFirstTransactionExpressGateway < Gateway - self.display_name = "TransFirst Transaction Express" - self.homepage_url = "http://transactionexpress.com/" + self.display_name = 'TransFirst Transaction Express' + self.homepage_url = 'http://transactionexpress.com/' - self.test_url = "https://ws.cert.transactionexpress.com/portal/merchantframework/MerchantWebServices-v1?wsdl" - self.live_url = "https://ws.transactionexpress.com/portal/merchantframework/MerchantWebServices-v1?wsdl" + self.test_url = 'https://ws.cert.transactionexpress.com/portal/merchantframework/MerchantWebServices-v1?wsdl' + self.live_url = 'https://ws.transactionexpress.com/portal/merchantframework/MerchantWebServices-v1?wsdl' - self.supported_countries = ["US"] - self.default_currency = "USD" + self.supported_countries = ['US'] + self.default_currency = 'USD' self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club] - V1_NAMESPACE = "http://postilion/realtime/merchantframework/xsd/v1/" - SOAPENV_NAMESPACE = "http://schemas.xmlsoap.org/soap/envelope/" - AUTHORIZATION_FIELD_SEPARATOR = "|" + V1_NAMESPACE = 'http://postilion/realtime/merchantframework/xsd/v1/' + SOAPENV_NAMESPACE = 'http://schemas.xmlsoap.org/soap/envelope/' + AUTHORIZATION_FIELD_SEPARATOR = '|' APPROVAL_CODES = %w(00 10) RESPONSE_MESSAGES = { - "00" => "Approved", - "01" => "Refer to card issuer", - "02" => "Refer to card issuer, special condition", - "03" => "Invalid merchant", - "04" => "Pick-up card", - "05" => "Do not honor", - "06" => "Error", - "07" => "Pick-up card, special condition", - "08" => "Honor with identification", - "09" => "Request in progress", - "10" => "Approved, partial authorization", - "11" => "VIP Approval", - "12" => "Invalid transaction", - "13" => "Invalid amount", - "14" => "Invalid card number", - "15" => "No such issuer", - "16" => "Approved, update track 3", - "17" => "Customer cancellation", - "18" => "Customer dispute", - "19" => "Re-enter transaction", - "20" => "Invalid response", - "21" => "No action taken", - "22" => "Suspected malfunction", - "23" => "Unacceptable transaction fee", - "24" => "File update not supported", - "25" => "Unable to locate record", - "26" => "Duplicate record", - "27" => "File update field edit error", - "28" => "File update file locked", - "29" => "File update failed", - "30" => "Format error", - "31" => "Bank not supported", - "33" => "Expired card, pick-up", - "34" => "Suspected fraud, pick-up", - "35" => "Contact acquirer, pick-up", - "36" => "Restricted card, pick-up", - "37" => "Call acquirer security, pick-up", - "38" => "PIN tries exceeded, pick-up", - "39" => "No credit account", - "40" => "Function not supported", - "41" => "Lost card, pick-up", - "42" => "No universal account", - "43" => "Stolen card, pick-up", - "44" => "No investment account", - "45" => "Account closed", - "46" => "Identification required", - "47" => "Identification cross-check required", - "48" => "No customer record", - "49" => "Reserved for future Realtime use", - "50" => "Reserved for future Realtime use", - "51" => "Not sufficient funds", - "52" => "No checking account", - "53" => "No savings account", - "54" => "Expired card", - "55" => "Incorrect PIN", - "56" => "No card record", - "57" => "Transaction not permitted to cardholder", - "58" => "Transaction not permitted on terminal", - "59" => "Suspected fraud", - "60" => "Contact acquirer", - "61" => "Exceeds withdrawal limit", - "62" => "Restricted card", - "63" => "Security violation", - "64" => "Original amount incorrect", - "65" => "Exceeds withdrawal frequency", - "66" => "Call acquirer security", - "67" => "Hard capture", - "68" => "Response received too late", - "69" => "Advice received too late (the response from a request was received too late )", - "70" => "Reserved for future use", - "71" => "Reserved for future Realtime use", - "72" => "Reserved for future Realtime use", - "73" => "Reserved for future Realtime use", - "74" => "Reserved for future Realtime use", - "75" => "PIN tries exceeded", - "76" => "Reversal: Unable to locate previous message (no match on Retrieval Reference Number)/ Reserved for future Realtime use", - "77" => "Previous message located for a repeat or reversal, but repeat or reversal data is inconsistent with original message/ Intervene, bank approval required", - "78" => "Invalid/non-existent account – Decline (MasterCard specific)/ Intervene, bank approval required for partial amount", - "79" => "Already reversed (by Switch)/ Reserved for client-specific use (declined)", - "80" => "No financial Impact (Reserved for declined debit)/ Reserved for client-specific use (declined)", - "81" => "PIN cryptographic error found by the Visa security module during PIN decryption/ Reserved for client-specific use (declined)", - "82" => "Incorrect CVV/ Reserved for client-specific use (declined)", - "83" => "Unable to verify PIN/ Reserved for client-specific use (declined)", - "84" => "Invalid Authorization Life Cycle – Decline (MasterCard) or Duplicate Transaction Detected (Visa)/ Reserved for client-specific use (declined)", - "85" => "No reason to decline a request for Account Number Verification or Address Verification/ Reserved for client-specific use (declined)", - "86" => "Cannot verify PIN/ Reserved for client-specific use (declined)", - "87" => "Reserved for client-specific use (declined)", - "88" => "Reserved for client-specific use (declined)", - "89" => "Reserved for client-specific use (declined)", - "90" => "Cut-off in progress", - "91" => "Issuer or switch inoperative", - "92" => "Routing error", - "93" => "Violation of law", - "94" => "Duplicate Transmission (Integrated Debit and MasterCard)", - "95" => "Reconcile error", - "96" => "System malfunction", - "97" => "Reserved for future Realtime use", - "98" => "Exceeds cash limit", - "99" => "Reserved for future Realtime use", - "1106" => "Reserved for future Realtime use", - "0A" => "Reserved for future Realtime use", - "A0" => "Reserved for future Realtime use", - "A1" => "ATC not incremented", - "A2" => "ATC limit exceeded", - "A3" => "ATC configuration error", - "A4" => "CVR check failure", - "A5" => "CVR configuration error", - "A6" => "TVR check failure", - "A7" => "TVR configuration error", - "A8" => "Reserved for future Realtime use", - "B1" => "Surcharge amount not permitted on Visa cards or EBT Food Stamps/ Reserved for future Realtime use", - "B2" => "Surcharge amount not supported by debit network issuer/ Reserved for future Realtime use", - "C1" => "Unacceptable PIN", - "C2" => "PIN Change failed", - "C3" => "PIN Unblock failed", - "D1" => "MAC Error", - "E1" => "Prepay error", - "N1" => "Network Error within the TXP platform", - "N0" => "Force STIP/ Reserved for client-specific use (declined)", - "N3" => "Cash service not available/ Reserved for client-specific use (declined)", - "N4" => "Cash request exceeds Issuer limit/ Reserved for client-specific use (declined)", - "N5" => "Ineligible for re-submission/ Reserved for client-specific use (declined)", - "N7" => "Decline for CVV2 failure/ Reserved for client-specific use (declined)", - "N8" => "Transaction amount exceeds preauthorized approval amount/ Reserved for client-specific use (declined)", - "P0" => "Approved; PVID code is missing, invalid, or has expired", - "P1" => "Declined; PVID code is missing, invalid, or has expired/ Reserved for client-specific use (declined)", - "P2" => "Invalid biller Information/ Reserved for client-specific use (declined)/ Reserved for client-specific use (declined)", - "R0" => "The transaction was declined or returned, because the cardholder requested that payment of a specific recurring or installment payment transaction be stopped/ Reserved for client-specific use (declined)", - "R1" => "The transaction was declined or returned, because the cardholder requested that payment of all recurring or installment payment transactions for a specific merchant account be stopped/ Reserved for client-specific use (declined)", - "Q1" => "Card Authentication failed/ Reserved for client-specific use (declined)", - "XA" => "Forward to Issuer/ Reserved for client-specific use (declined)", - "XD" => "Forward to Issuer/ Reserved for client-specific use (declined)", + '00' => 'Approved', + '01' => 'Refer to card issuer', + '02' => 'Refer to card issuer, special condition', + '03' => 'Invalid merchant', + '04' => 'Pick-up card', + '05' => 'Do not honor', + '06' => 'Error', + '07' => 'Pick-up card, special condition', + '08' => 'Honor with identification', + '09' => 'Request in progress', + '10' => 'Approved, partial authorization', + '11' => 'VIP Approval', + '12' => 'Invalid transaction', + '13' => 'Invalid amount', + '14' => 'Invalid card number', + '15' => 'No such issuer', + '16' => 'Approved, update track 3', + '17' => 'Customer cancellation', + '18' => 'Customer dispute', + '19' => 'Re-enter transaction', + '20' => 'Invalid response', + '21' => 'No action taken', + '22' => 'Suspected malfunction', + '23' => 'Unacceptable transaction fee', + '24' => 'File update not supported', + '25' => 'Unable to locate record', + '26' => 'Duplicate record', + '27' => 'File update field edit error', + '28' => 'File update file locked', + '29' => 'File update failed', + '30' => 'Format error', + '31' => 'Bank not supported', + '33' => 'Expired card, pick-up', + '34' => 'Suspected fraud, pick-up', + '35' => 'Contact acquirer, pick-up', + '36' => 'Restricted card, pick-up', + '37' => 'Call acquirer security, pick-up', + '38' => 'PIN tries exceeded, pick-up', + '39' => 'No credit account', + '40' => 'Function not supported', + '41' => 'Lost card, pick-up', + '42' => 'No universal account', + '43' => 'Stolen card, pick-up', + '44' => 'No investment account', + '45' => 'Account closed', + '46' => 'Identification required', + '47' => 'Identification cross-check required', + '48' => 'No customer record', + '49' => 'Reserved for future Realtime use', + '50' => 'Reserved for future Realtime use', + '51' => 'Not sufficient funds', + '52' => 'No checking account', + '53' => 'No savings account', + '54' => 'Expired card', + '55' => 'Incorrect PIN', + '56' => 'No card record', + '57' => 'Transaction not permitted to cardholder', + '58' => 'Transaction not permitted on terminal', + '59' => 'Suspected fraud', + '60' => 'Contact acquirer', + '61' => 'Exceeds withdrawal limit', + '62' => 'Restricted card', + '63' => 'Security violation', + '64' => 'Original amount incorrect', + '65' => 'Exceeds withdrawal frequency', + '66' => 'Call acquirer security', + '67' => 'Hard capture', + '68' => 'Response received too late', + '69' => 'Advice received too late (the response from a request was received too late )', + '70' => 'Reserved for future use', + '71' => 'Reserved for future Realtime use', + '72' => 'Reserved for future Realtime use', + '73' => 'Reserved for future Realtime use', + '74' => 'Reserved for future Realtime use', + '75' => 'PIN tries exceeded', + '76' => 'Reversal: Unable to locate previous message (no match on Retrieval Reference Number)/ Reserved for future Realtime use', + '77' => 'Previous message located for a repeat or reversal, but repeat or reversal data is inconsistent with original message/ Intervene, bank approval required', + '78' => 'Invalid/non-existent account – Decline (MasterCard specific)/ Intervene, bank approval required for partial amount', + '79' => 'Already reversed (by Switch)/ Reserved for client-specific use (declined)', + '80' => 'No financial Impact (Reserved for declined debit)/ Reserved for client-specific use (declined)', + '81' => 'PIN cryptographic error found by the Visa security module during PIN decryption/ Reserved for client-specific use (declined)', + '82' => 'Incorrect CVV/ Reserved for client-specific use (declined)', + '83' => 'Unable to verify PIN/ Reserved for client-specific use (declined)', + '84' => 'Invalid Authorization Life Cycle – Decline (MasterCard) or Duplicate Transaction Detected (Visa)/ Reserved for client-specific use (declined)', + '85' => 'No reason to decline a request for Account Number Verification or Address Verification/ Reserved for client-specific use (declined)', + '86' => 'Cannot verify PIN/ Reserved for client-specific use (declined)', + '87' => 'Reserved for client-specific use (declined)', + '88' => 'Reserved for client-specific use (declined)', + '89' => 'Reserved for client-specific use (declined)', + '90' => 'Cut-off in progress', + '91' => 'Issuer or switch inoperative', + '92' => 'Routing error', + '93' => 'Violation of law', + '94' => 'Duplicate Transmission (Integrated Debit and MasterCard)', + '95' => 'Reconcile error', + '96' => 'System malfunction', + '97' => 'Reserved for future Realtime use', + '98' => 'Exceeds cash limit', + '99' => 'Reserved for future Realtime use', + '1106' => 'Reserved for future Realtime use', + '0A' => 'Reserved for future Realtime use', + 'A0' => 'Reserved for future Realtime use', + 'A1' => 'ATC not incremented', + 'A2' => 'ATC limit exceeded', + 'A3' => 'ATC configuration error', + 'A4' => 'CVR check failure', + 'A5' => 'CVR configuration error', + 'A6' => 'TVR check failure', + 'A7' => 'TVR configuration error', + 'A8' => 'Reserved for future Realtime use', + 'B1' => 'Surcharge amount not permitted on Visa cards or EBT Food Stamps/ Reserved for future Realtime use', + 'B2' => 'Surcharge amount not supported by debit network issuer/ Reserved for future Realtime use', + 'C1' => 'Unacceptable PIN', + 'C2' => 'PIN Change failed', + 'C3' => 'PIN Unblock failed', + 'D1' => 'MAC Error', + 'E1' => 'Prepay error', + 'N1' => 'Network Error within the TXP platform', + 'N0' => 'Force STIP/ Reserved for client-specific use (declined)', + 'N3' => 'Cash service not available/ Reserved for client-specific use (declined)', + 'N4' => 'Cash request exceeds Issuer limit/ Reserved for client-specific use (declined)', + 'N5' => 'Ineligible for re-submission/ Reserved for client-specific use (declined)', + 'N7' => 'Decline for CVV2 failure/ Reserved for client-specific use (declined)', + 'N8' => 'Transaction amount exceeds preauthorized approval amount/ Reserved for client-specific use (declined)', + 'P0' => 'Approved; PVID code is missing, invalid, or has expired', + 'P1' => 'Declined; PVID code is missing, invalid, or has expired/ Reserved for client-specific use (declined)', + 'P2' => 'Invalid biller Information/ Reserved for client-specific use (declined)/ Reserved for client-specific use (declined)', + 'R0' => 'The transaction was declined or returned, because the cardholder requested that payment of a specific recurring or installment payment transaction be stopped/ Reserved for client-specific use (declined)', + 'R1' => 'The transaction was declined or returned, because the cardholder requested that payment of all recurring or installment payment transactions for a specific merchant account be stopped/ Reserved for client-specific use (declined)', + 'Q1' => 'Card Authentication failed/ Reserved for client-specific use (declined)', + 'XA' => 'Forward to Issuer/ Reserved for client-specific use (declined)', + 'XD' => 'Forward to Issuer/ Reserved for client-specific use (declined)', } EXTENDED_RESPONSE_MESSAGES = { - "B40K" => "Declined Post – Credit linked to unextracted settle transaction" + 'B40K' => 'Declined Post – Credit linked to unextracted settle transaction' } TRANSACTION_CODES = { @@ -290,14 +290,14 @@ def store(payment_method, options={}) MultiResponse.run do |r| r.process { commit(:store, store_customer_request) } - return r unless r.success? && r.params["custId"] - customer_id = r.params["custId"] + return r unless r.success? && r.params['custId'] + customer_id = r.params['custId'] store_payment_method_request = build_xml_payment_storage_request do |doc| - doc["v1"].cust do + doc['v1'].cust do add_customer_id(doc, customer_id) - doc["v1"].pmt do - doc["v1"].type 0 # add + doc['v1'].pmt do + doc['v1'].type 0 # add add_credit_card(doc, payment_method) end end @@ -322,11 +322,11 @@ def scrub(transcript) private CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")} - CURRENCY_CODES["USD"] = "840" + CURRENCY_CODES['USD'] = '840' def headers { - "Content-Type" => "text/xml" + 'Content-Type' => 'text/xml' } end @@ -349,8 +349,8 @@ def commit(action, request) response, error_code: error_code_from(succeeded, response), authorization: authorization_from(action, response), - avs_result: AVSResult.new(code: response["avsRslt"]), - cvv_result: CVVResult.new(response["secRslt"]), + avs_result: AVSResult.new(code: response['avsRslt']), + cvv_result: CVVResult.new(response['secRslt']), test: test? ) end @@ -363,7 +363,7 @@ def parse(xml) response = {} doc = Nokogiri::XML(xml).remove_namespaces! - doc.css("Envelope Body *").each do |node| + doc.css('Envelope Body *').each do |node| # node.name is more readable, but uniq_name is occasionally necessary uniq_name = [node.parent.name, node.name].join('_') response[uniq_name] = node.text @@ -374,37 +374,37 @@ def parse(xml) end def success_from(response) - fault = response["Fault"] - approved_transaction = APPROVAL_CODES.include?(response["rspCode"]) - found_contact = response["FndRecurrProfResponse"] + fault = response['Fault'] + approved_transaction = APPROVAL_CODES.include?(response['rspCode']) + found_contact = response['FndRecurrProfResponse'] return !fault && (approved_transaction || found_contact) end def error_code_from(succeeded, response) return if succeeded - response["errorCode"] || response["rspCode"] + response['errorCode'] || response['rspCode'] end def message_from(succeeded, response) - return "Succeeded" if succeeded + return 'Succeeded' if succeeded - if response["rspCode"] - code = response["rspCode"] - extended_code = response["extRspCode"] + if response['rspCode'] + code = response['rspCode'] + extended_code = response['extRspCode'] message = RESPONSE_MESSAGES[code] extended = EXTENDED_RESPONSE_MESSAGES[extended_code] - ach_response = response["achResponse"] + ach_response = response['achResponse'] [message, extended, ach_response].compact.join('. ') else - response["faultstring"] + response['faultstring'] end end def authorization_from(action, response) - authorization = response["tranNr"] || response["pmtId"] + authorization = response['tranNr'] || response['pmtId'] # guard so we don't return something like "purchase|" return unless authorization @@ -435,35 +435,35 @@ def refund_type(action) # -- request methods --------------------------------------------------- def build_xml_transaction_request - build_xml_request("SendTranRequest") do |doc| + build_xml_request('SendTranRequest') do |doc| yield doc end end def build_xml_payment_storage_request - build_xml_request("UpdtRecurrProfRequest") do |doc| + build_xml_request('UpdtRecurrProfRequest') do |doc| yield doc end end def build_xml_payment_update_request merchant_product_type = 5 # credit card - build_xml_request("UpdtRecurrProfRequest", merchant_product_type) do |doc| + build_xml_request('UpdtRecurrProfRequest', merchant_product_type) do |doc| yield doc end end def build_xml_payment_search_request - build_xml_request("FndRecurrProfRequest") do |doc| + build_xml_request('FndRecurrProfRequest') do |doc| yield doc end end def build_xml_request(wrapper, merchant_product_type=nil) - Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| - xml["soapenv"].Envelope("xmlns:soapenv" => SOAPENV_NAMESPACE) do - xml["soapenv"].Body do - xml["v1"].send(wrapper, "xmlns:v1" => V1_NAMESPACE) do + Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml| + xml['soapenv'].Envelope('xmlns:soapenv' => SOAPENV_NAMESPACE) do + xml['soapenv'].Body do + xml['v1'].send(wrapper, 'xmlns:v1' => V1_NAMESPACE) do add_merchant(xml) yield(xml) end @@ -483,38 +483,38 @@ def add_transaction_code_to_request(request, action) end def add_merchant(doc, product_type=nil) - doc["v1"].merc do - doc["v1"].id @options[:gateway_id] - doc["v1"].regKey @options[:reg_key] - doc["v1"].inType "1" - doc["v1"].prodType product_type if product_type + doc['v1'].merc do + doc['v1'].id @options[:gateway_id] + doc['v1'].regKey @options[:reg_key] + doc['v1'].inType '1' + doc['v1'].prodType product_type if product_type end end def add_amount(doc, money) - doc["v1"].reqAmt amount(money) + doc['v1'].reqAmt amount(money) end def add_order_number(doc, options) return unless options[:order_id] - doc["v1"].authReq { - doc["v1"].ordNr options[:order_id] + doc['v1'].authReq { + doc['v1'].ordNr options[:order_id] } end def add_credit_card(doc, payment_method) - doc["v1"].card { - doc["v1"].pan payment_method.number - doc["v1"].sec payment_method.verification_value if payment_method.verification_value? - doc["v1"].xprDt expiration_date(payment_method) + doc['v1'].card { + doc['v1'].pan payment_method.number + doc['v1'].sec payment_method.verification_value if payment_method.verification_value? + doc['v1'].xprDt expiration_date(payment_method) } end def add_echeck(doc, payment_method) - doc["v1"].achEcheck { - doc["v1"].bankRtNr payment_method.routing_number - doc["v1"].acctNr payment_method.account_number + doc['v1'].achEcheck { + doc['v1'].bankRtNr payment_method.routing_number + doc['v1'].acctNr payment_method.account_number } end @@ -525,60 +525,60 @@ def expiration_date(payment_method) end def add_pan(doc, payment_method) - doc["v1"].card do - doc["v1"].pan payment_method.number + doc['v1'].card do + doc['v1'].pan payment_method.number end end def add_contact(doc, fullname, options) - doc["v1"].contact do - doc["v1"].fullName fullname - doc["v1"].coName options[:company_name] if options[:company_name] - doc["v1"].title options[:title] if options[:title] + doc['v1'].contact do + doc['v1'].fullName fullname + doc['v1'].coName options[:company_name] if options[:company_name] + doc['v1'].title options[:title] if options[:title] if (billing_address = options[:billing_address]) if billing_address[:phone] - doc["v1"].phone do - doc["v1"].type (options[:phone_number_type] || "4") - doc["v1"].nr billing_address[:phone].gsub(/\D/, '') + doc['v1'].phone do + doc['v1'].type (options[:phone_number_type] || '4') + doc['v1'].nr billing_address[:phone].gsub(/\D/, '') end end - doc["v1"].addrLn1 billing_address[:address1] if billing_address[:address1] - doc["v1"].addrLn2 billing_address[:address2] if billing_address[:address2] - doc["v1"].city billing_address[:city] if billing_address[:city] - doc["v1"].state billing_address[:state] if billing_address[:state] - doc["v1"].zipCode billing_address[:zip] if billing_address[:zip] - doc["v1"].ctry "US" + doc['v1'].addrLn1 billing_address[:address1] if billing_address[:address1] + doc['v1'].addrLn2 billing_address[:address2] if billing_address[:address2] + doc['v1'].city billing_address[:city] if billing_address[:city] + doc['v1'].state billing_address[:state] if billing_address[:state] + doc['v1'].zipCode billing_address[:zip] if billing_address[:zip] + doc['v1'].ctry 'US' end - doc["v1"].email options[:email] if options[:email] - doc["v1"].type options[:contact_type] if options[:contact_type] - doc["v1"].stat options[:contact_stat] if options[:contact_stat] + doc['v1'].email options[:email] if options[:email] + doc['v1'].type options[:contact_type] if options[:contact_type] + doc['v1'].stat options[:contact_stat] if options[:contact_stat] if (shipping_address = options[:shipping_address]) - doc["v1"].ship do - doc["v1"].fullName fullname - doc["v1"].addrLn1 shipping_address[:address1] if shipping_address[:address1] - doc["v1"].addrLn2 shipping_address[:address2] if shipping_address[:address2] - doc["v1"].city shipping_address[:city] if shipping_address[:city] - doc["v1"].state shipping_address[:state] if shipping_address[:state] - doc["v1"].zipCode shipping_address[:zip] if shipping_address[:zip] - doc["v1"].phone shipping_address[:phone].gsub(/\D/, '') if shipping_address[:phone] - doc["v1"].email shipping_address[:email] if shipping_address[:email] + doc['v1'].ship do + doc['v1'].fullName fullname + doc['v1'].addrLn1 shipping_address[:address1] if shipping_address[:address1] + doc['v1'].addrLn2 shipping_address[:address2] if shipping_address[:address2] + doc['v1'].city shipping_address[:city] if shipping_address[:city] + doc['v1'].state shipping_address[:state] if shipping_address[:state] + doc['v1'].zipCode shipping_address[:zip] if shipping_address[:zip] + doc['v1'].phone shipping_address[:phone].gsub(/\D/, '') if shipping_address[:phone] + doc['v1'].email shipping_address[:email] if shipping_address[:email] end end end end def add_name(doc, payment_method) - doc["v1"].contact do - doc["v1"].fullName payment_method.name + doc['v1'].contact do + doc['v1'].fullName payment_method.name end end def add_original_transaction_data(doc, authorization) - doc["v1"].origTranData do - doc["v1"].tranNr authorization + doc['v1'].origTranData do + doc['v1'].tranNr authorization end end @@ -586,21 +586,21 @@ def store_customer_details(doc, fullname, options) options[:contact_type] = 1 # recurring options[:contact_stat] = 1 # active - doc["v1"].cust do - doc["v1"].type 0 # add + doc['v1'].cust do + doc['v1'].type 0 # add add_contact(doc, fullname, options) end end def add_customer_id(doc, customer_id) - doc["v1"].contact do - doc["v1"].id customer_id + doc['v1'].contact do + doc['v1'].id customer_id end end def add_wallet_id(doc, wallet_id) - doc["v1"].recurMan do - doc["v1"].id wallet_id + doc['v1'].recurMan do + doc['v1'].id wallet_id end end end diff --git a/lib/active_merchant/billing/gateways/transact_pro.rb b/lib/active_merchant/billing/gateways/transact_pro.rb index eae571d017d..5855527bfc0 100644 --- a/lib/active_merchant/billing/gateways/transact_pro.rb +++ b/lib/active_merchant/billing/gateways/transact_pro.rb @@ -122,7 +122,7 @@ def add_address(post, creditcard, options) post[:state] = (address[:state].blank? ? 'NA' : address[:state].to_s) post[:zip] = address[:zip].to_s post[:country] = address[:country].to_s - post[:phone] = (address[:phone].to_s.gsub(/[^0-9]/, '') || "0000000") + post[:phone] = (address[:phone].to_s.gsub(/[^0-9]/, '') || '0000000') end if address = options[:shipping_address] @@ -153,8 +153,8 @@ def add_payment(post, payment) def add_payment_cc(post, credit_card) post[:cc] = credit_card.number post[:cvv] = credit_card.verification_value if credit_card.verification_value? - year = sprintf("%.4i", credit_card.year) - month = sprintf("%.2i", credit_card.month) + year = sprintf('%.4i', credit_card.year) + month = sprintf('%.2i', credit_card.month) post[:expire] = "#{month}/#{year[2..3]}" end @@ -166,10 +166,10 @@ def add_credentials(post, key=:guid) def parse(body) if body =~ /^ID:/ body.split('~').reduce(Hash.new) { |h,v| - m = v.match("(.*?):(.*)") + m = v.match('(.*?):(.*)') h.merge!(m[1].underscore.to_sym => m[2]) } - elsif (m = body.match("(.*?):(.*)")) + elsif (m = body.match('(.*?):(.*)')) m[1] == 'OK' ? { status: 'success', id: m[2] } : { status: 'failure', message: m[2] } @@ -195,12 +195,12 @@ def authorization_from(parameters, response, amount) identifier = (response[:id] || parameters[:init_transaction_id]) authorization = [identifier] authorization << amount if amount - authorization.join("|") + authorization.join('|') end def split_authorization(authorization) if authorization =~ /|/ - identifier, amount = authorization.split("|") + identifier, amount = authorization.split('|') [identifier, amount.to_i] else authorization diff --git a/lib/active_merchant/billing/gateways/transnational.rb b/lib/active_merchant/billing/gateways/transnational.rb index 2e0be041683..bce37f5eede 100644 --- a/lib/active_merchant/billing/gateways/transnational.rb +++ b/lib/active_merchant/billing/gateways/transnational.rb @@ -3,7 +3,7 @@ module Billing #:nodoc: class TransnationalGateway < NetworkMerchantsGateway self.homepage_url = 'http://www.tnbci.com/' self.display_name = 'Transnational' - self.supported_countries = ["US"] + self.supported_countries = ['US'] end end end diff --git a/lib/active_merchant/billing/gateways/trexle.rb b/lib/active_merchant/billing/gateways/trexle.rb index e50c72d481c..b4601860b27 100644 --- a/lib/active_merchant/billing/gateways/trexle.rb +++ b/lib/active_merchant/billing/gateways/trexle.rb @@ -120,7 +120,7 @@ def add_address(post, creditcard, options) end def add_invoice(post, options) - post[:description] = options[:description] || "Active Merchant Purchase" + post[:description] = options[:description] || 'Active Merchant Purchase' end def add_creditcard(post, creditcard) @@ -145,8 +145,8 @@ def add_creditcard(post, creditcard) def headers(params = {}) result = { - "Content-Type" => "application/json", - "Authorization" => "Basic #{Base64.strict_encode64(options[:api_key] + ':').strip}" + 'Content-Type' => 'application/json', + 'Authorization' => "Basic #{Base64.strict_encode64(options[:api_key] + ':').strip}" } result['X-Partner-Key'] = params[:partner_key] if params[:partner_key] @@ -190,13 +190,13 @@ def error_response(body) end def unparsable_response(raw_response) - message = "Invalid JSON response received from Trexle. Please contact support@trexle.com if you continue to receive this message." + message = 'Invalid JSON response received from Trexle. Please contact support@trexle.com if you continue to receive this message.' message += " (The raw response returned by the API was #{raw_response.inspect})" return Response.new(false, message) end def invalid_response - message = "Invalid response." + message = 'Invalid response.' return Response.new(false, message) end diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb index 68fbd4a5b23..87872c59122 100644 --- a/lib/active_merchant/billing/gateways/trust_commerce.rb +++ b/lib/active_merchant/billing/gateways/trust_commerce.rb @@ -67,38 +67,38 @@ module Billing #:nodoc: class TrustCommerceGateway < Gateway self.live_url = self.test_url = 'https://vault.trustcommerce.com/trans/' - SUCCESS_TYPES = ["approved", "accepted"] + SUCCESS_TYPES = ['approved', 'accepted'] DECLINE_CODES = { - "decline" => "The credit card was declined", - "avs" => "AVS failed; the address entered does not match the billing address on file at the bank", - "cvv" => "CVV failed; the number provided is not the correct verification number for the card", - "call" => "The card must be authorized manually over the phone", - "expiredcard" => "Issuer was not certified for card verification", - "carderror" => "Card number is invalid", - "authexpired" => "Attempt to postauth an expired (more than 14 days old) preauth", - "fraud" => "CrediGuard fraud score was below requested threshold", - "blacklist" => "CrediGuard blacklist value was triggered", - "velocity" => "CrediGuard velocity control value was triggered", - "dailylimit" => "Daily limit in transaction count or amount as been reached", - "weeklylimit" => "Weekly limit in transaction count or amount as been reached", - "monthlylimit" => "Monthly limit in transaction count or amount as been reached" + 'decline' => 'The credit card was declined', + 'avs' => 'AVS failed; the address entered does not match the billing address on file at the bank', + 'cvv' => 'CVV failed; the number provided is not the correct verification number for the card', + 'call' => 'The card must be authorized manually over the phone', + 'expiredcard' => 'Issuer was not certified for card verification', + 'carderror' => 'Card number is invalid', + 'authexpired' => 'Attempt to postauth an expired (more than 14 days old) preauth', + 'fraud' => 'CrediGuard fraud score was below requested threshold', + 'blacklist' => 'CrediGuard blacklist value was triggered', + 'velocity' => 'CrediGuard velocity control value was triggered', + 'dailylimit' => 'Daily limit in transaction count or amount as been reached', + 'weeklylimit' => 'Weekly limit in transaction count or amount as been reached', + 'monthlylimit' => 'Monthly limit in transaction count or amount as been reached' } BADDATA_CODES = { - "missingfields" => "One or more parameters required for this transaction type were not sent", - "extrafields" => "Parameters not allowed for this transaction type were sent", - "badformat" => "A field was improperly formatted, such as non-digit characters in a number field", - "badlength" => "A field was longer or shorter than the server allows", - "merchantcantaccept" => "The merchant can't accept data passed in this field", - "mismatch" => "Data in one of the offending fields did not cross-check with the other offending field" + 'missingfields' => 'One or more parameters required for this transaction type were not sent', + 'extrafields' => 'Parameters not allowed for this transaction type were sent', + 'badformat' => 'A field was improperly formatted, such as non-digit characters in a number field', + 'badlength' => 'A field was longer or shorter than the server allows', + 'merchantcantaccept' => "The merchant can't accept data passed in this field", + 'mismatch' => 'Data in one of the offending fields did not cross-check with the other offending field' } ERROR_CODES = { - "cantconnect" => "Couldn't connect to the TrustCommerce gateway", - "dnsfailure" => "The TCLink software was unable to resolve DNS hostnames", - "linkfailure" => "The connection was established, but was severed before the transaction could complete", - "failtoprocess" => "The bank servers are offline and unable to authorize transactions" + 'cantconnect' => "Couldn't connect to the TrustCommerce gateway", + 'dnsfailure' => 'The TCLink software was unable to resolve DNS hostnames', + 'linkfailure' => 'The connection was established, but was severed before the transaction could complete', + 'failtoprocess' => 'The bank servers are offline and unable to authorize transactions' } TEST_LOGIN = 'TestMerchant' @@ -313,7 +313,7 @@ def add_payment_source(params, source) end def add_creditcard(params, creditcard) - params[:media] = "cc" + params[:media] = 'cc' params[:name] = creditcard.name params[:cc] = creditcard.number params[:exp] = expdate(creditcard) @@ -370,7 +370,7 @@ def clean_and_stringify_params(parameters) end def post_data(parameters) - parameters.collect { |key, value| "#{key}=#{ CGI.escape(value.to_s)}" }.join("&") + parameters.collect { |key, value| "#{key}=#{ CGI.escape(value.to_s)}" }.join('&') end def commit(action, parameters) @@ -388,13 +388,13 @@ def commit(action, parameters) end # to be considered successful, transaction status must be either "approved" or "accepted" - success = SUCCESS_TYPES.include?(data["status"]) + success = SUCCESS_TYPES.include?(data['status']) message = message_from(data) Response.new(success, message, data, :test => test?, - :authorization => data["transid"], - :cvv_result => data["cvv"], - :avs_result => { :code => data["avs"] } + :authorization => data['transid'], + :cvv_result => data['cvv'], + :avs_result => { :code => data['avs'] } ) end @@ -410,15 +410,15 @@ def parse(body) end def message_from(data) - case data["status"] - when "decline" - return DECLINE_CODES[data["declinetype"]] - when "baddata" - return BADDATA_CODES[data["error"]] - when "error" - return ERROR_CODES[data["errortype"]] + case data['status'] + when 'decline' + return DECLINE_CODES[data['declinetype']] + when 'baddata' + return BADDATA_CODES[data['error']] + when 'error' + return ERROR_CODES[data['errortype']] else - return "The transaction was successful" + return 'The transaction was successful' end end diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb index 627d2de95d2..d831807ec29 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb @@ -62,7 +62,7 @@ module Billing #:nodoc: # * {USA ePay Developer Login}[https://www.usaepay.com/developer/login] # class UsaEpayAdvancedGateway < Gateway - API_VERSION = "1.4" + API_VERSION = '1.4' TEST_URL_BASE = 'https://sandbox.usaepay.com/soap/gate/' #:nodoc: LIVE_URL_BASE = 'https://www.usaepay.com/soap/gate/' #:nodoc: @@ -70,7 +70,7 @@ class UsaEpayAdvancedGateway < Gateway self.test_url = TEST_URL_BASE self.live_url = LIVE_URL_BASE - FAILURE_MESSAGE = "Default Failure" #:nodoc: + FAILURE_MESSAGE = 'Default Failure' #:nodoc: self.supported_countries = ['US'] self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb] @@ -1032,14 +1032,14 @@ def get_account_details def build_request(action, options = {}) soap = Builder::XmlMarkup.new soap.instruct!(:xml, :version => '1.0', :encoding => 'utf-8') - soap.tag! "SOAP-ENV:Envelope", + soap.tag! 'SOAP-ENV:Envelope', 'xmlns:SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xmlns:ns1' => 'urn:usaepay', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/', 'SOAP-ENV:encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/' do - soap.tag! "SOAP-ENV:Body" do + soap.tag! 'SOAP-ENV:Body' do send("build_#{action}", soap, options) end end @@ -1058,9 +1058,9 @@ def build_token(soap, options) soap.Token 'xsi:type' => 'ns1:ueSecurityToken' do build_tag soap, :string, 'ClientIP', options[:client_ip] soap.PinHash 'xsi:type' => 'ns1:ueHash' do - build_tag soap, :string, "HashValue", hash - build_tag soap, :string, "Seed", seed - build_tag soap, :string, "Type", 'sha1' + build_tag soap, :string, 'HashValue', hash + build_tag soap, :string, 'Seed', seed + build_tag soap, :string, 'Type', 'sha1' end build_tag soap, :string, 'SourceKey', @options[:login] end @@ -1069,12 +1069,12 @@ def build_token(soap, options) # Customer ====================================================== def build_add_customer(soap, options) - soap.tag! "ns1:addCustomer" do + soap.tag! 'ns1:addCustomer' do build_token soap, options build_customer_data soap, options build_tag soap, :double, 'Amount', amount(options[:amount]) build_tag soap, :double, 'Tax', amount(options[:tax]) - build_tag soap, :string, 'Next', options[:next].strftime("%Y-%m-%d") if options[:next] + build_tag soap, :string, 'Next', options[:next].strftime('%Y-%m-%d') if options[:next] end end @@ -1103,15 +1103,15 @@ def build_delete_customer(soap, options) end def build_quick_update_customer(soap, options) - soap.tag! "ns1:quickUpdateCustomer" do + soap.tag! 'ns1:quickUpdateCustomer' do build_token soap, options build_tag soap, :integer, 'CustNum', options[:customer_number] - build_field_value_array soap, "UpdateData", "FieldValue", options[:update_data], CUSTOMER_UPDATE_DATA_FIELDS + build_field_value_array soap, 'UpdateData', 'FieldValue', options[:update_data], CUSTOMER_UPDATE_DATA_FIELDS end end def build_add_customer_payment_method(soap, options) - soap.tag! "ns1:addCustomerPaymentMethod" do + soap.tag! 'ns1:addCustomerPaymentMethod' do build_token soap, options build_tag soap, :integer, 'CustNum', options[:customer_number] build_customer_payment_methods soap, options @@ -1141,7 +1141,7 @@ def build_update_customer_payment_method(soap, options) end def build_delete_customer_payment_method(soap, options) - soap.tag! "ns1:deleteCustomerPaymentMethod" do + soap.tag! 'ns1:deleteCustomerPaymentMethod' do build_token soap, options build_tag soap, :integer, 'Custnum', options[:customer_number] build_tag soap, :integer, 'PaymentMethodID', options[:method_id] @@ -1149,7 +1149,7 @@ def build_delete_customer_payment_method(soap, options) end def build_run_customer_transaction(soap, options) - soap.tag! "ns1:runCustomerTransaction" do + soap.tag! 'ns1:runCustomerTransaction' do build_token soap, options build_tag soap, :integer, 'CustNum', options[:customer_number] build_tag soap, :integer, 'PaymentMethodID', options[:method_id] || 0 @@ -1226,21 +1226,21 @@ def build_run_quick_credit(soap, options) end def build_get_transaction(soap, options) - soap.tag! "ns1:getTransaction" do + soap.tag! 'ns1:getTransaction' do build_token soap, options build_tag soap, :integer, 'RefNum', options[:reference_number] end end def build_get_transaction_status(soap, options) - soap.tag! "ns1:getTransactionStatus" do + soap.tag! 'ns1:getTransactionStatus' do build_token soap, options build_tag soap, :integer, 'RefNum', options[:reference_number] end end def build_get_transaction_custom(soap, options) - soap.tag! "ns1:getTransactionCustom" do + soap.tag! 'ns1:getTransactionCustom' do build_token soap, options build_tag soap, :integer, 'RefNum', options[:reference_number] build_transaction_field_array soap, options @@ -1248,14 +1248,14 @@ def build_get_transaction_custom(soap, options) end def build_get_check_trace(soap, options) - soap.tag! "ns1:getCheckTrace" do + soap.tag! 'ns1:getCheckTrace' do build_token soap, options build_tag soap, :integer, 'RefNum', options[:reference_number] end end def build_capture_transaction(soap, options) - soap.tag! "ns1:captureTransaction" do + soap.tag! 'ns1:captureTransaction' do build_token soap, options build_tag soap, :integer, 'RefNum', options[:reference_number] build_tag soap, :double, 'Amount', amount(options[:amount]) @@ -1263,14 +1263,14 @@ def build_capture_transaction(soap, options) end def build_void_transaction(soap, options) - soap.tag! "ns1:voidTransaction" do + soap.tag! 'ns1:voidTransaction' do build_token soap, options build_tag soap, :integer, 'RefNum', options[:reference_number] end end def build_refund_transaction(soap, options) - soap.tag! "ns1:refundTransaction" do + soap.tag! 'ns1:refundTransaction' do build_token soap, options build_tag soap, :integer, 'RefNum', options[:reference_number] build_tag soap, :integer, 'Amount', amount(options[:amount]) @@ -1278,7 +1278,7 @@ def build_refund_transaction(soap, options) end def build_override_transaction(soap, options) - soap.tag! "ns1:overrideTransaction" do + soap.tag! 'ns1:overrideTransaction' do build_token soap, options build_tag soap, :integer, 'RefNum', options[:reference_number] build_tag soap, :string, 'Reason', options[:reason] @@ -1288,7 +1288,7 @@ def build_override_transaction(soap, options) # Account ======================================================= def build_get_account_details(soap, options) - soap.tag! "ns1:getAccountDetails" do + soap.tag! 'ns1:getAccountDetails' do build_token soap, options end end @@ -1310,7 +1310,7 @@ def build_customer_payments(soap, options) if options[:payment_methods] length = options[:payment_methods].length soap.PaymentMethods 'SOAP-ENC:arrayType' => "ns1:PaymentMethod[#{length}]", - 'xsi:type' =>"ns1:PaymentMethodArray" do + 'xsi:type' =>'ns1:PaymentMethodArray' do build_customer_payment_methods soap, options end end @@ -1357,7 +1357,7 @@ def build_credit_card_or_check(soap, payment_method) def build_customer_payment_methods(soap, options) payment_methods, tag_name = extract_methods_and_tag(options) payment_methods.each do |payment_method| - soap.tag! tag_name, 'xsi:type' => "ns1:PaymentMethod" do + soap.tag! tag_name, 'xsi:type' => 'ns1:PaymentMethod' do build_tag soap, :integer, 'MethodID', payment_method[:method_id] build_tag soap, :string, 'MethodType', payment_method[:type] build_tag soap, :string, 'MethodName', payment_method[:name] @@ -1368,7 +1368,7 @@ def build_customer_payment_methods(soap, options) end def build_customer_transaction(soap, options) - soap.Parameters 'xsi:type' => "ns1:CustomerTransactionRequest" do + soap.Parameters 'xsi:type' => 'ns1:CustomerTransactionRequest' do build_transaction_detail soap, options CUSTOMER_TRANSACTION_REQUEST_OPTIONS.each do |k,v| build_tag soap, v[0], v[1], options[k] @@ -1381,7 +1381,7 @@ def build_customer_transaction(soap, options) # Transaction Helpers =========================================== def build_transaction_request_object(soap, options, name='Params') - soap.tag! name, 'xsi:type' => "ns1:TransactionRequestObject" do + soap.tag! name, 'xsi:type' => 'ns1:TransactionRequestObject' do TRANSACTION_REQUEST_OBJECT_OPTIONS.each do |k,v| build_tag soap, v[0], v[1], options[k] end @@ -1404,7 +1404,7 @@ def build_transaction_request_object(soap, options, name='Params') end def build_transaction_detail(soap, options) - soap.Details 'xsi:type' => "ns1:TransactionDetail" do + soap.Details 'xsi:type' => 'ns1:TransactionDetail' do TRANSACTION_DETAIL_OPTIONS.each do |k,v| build_tag soap, v[0], v[1], options[k] end @@ -1415,7 +1415,7 @@ def build_transaction_detail(soap, options) end def build_credit_card_data(soap, options) - soap.CreditCardData 'xsi:type' => "ns1:CreditCardData" do + soap.CreditCardData 'xsi:type' => 'ns1:CreditCardData' do build_tag soap, :string, 'CardNumber', options[:payment_method].number build_tag soap, :string, 'CardExpiration', build_card_expiration(options) if options[:billing_address] @@ -1439,7 +1439,7 @@ def build_card_expiration(options) end def build_check_data(soap, options) - soap.CheckData 'xsi:type' => "ns1:CheckData" do + soap.CheckData 'xsi:type' => 'ns1:CheckData' do build_tag soap, :integer, 'CheckNumber', options[:payment_method].number build_tag soap, :string, 'Account', options[:payment_method].account_number build_tag soap, :string, 'Routing', options[:payment_method].routing_number @@ -1452,10 +1452,10 @@ def build_check_data(soap, options) def build_recurring_billing(soap, options) if options[:recurring] - soap.RecurringBilling 'xsi:type' => "ns1:RecurringBilling" do + soap.RecurringBilling 'xsi:type' => 'ns1:RecurringBilling' do build_tag soap, :double, 'Amount', amount(options[:recurring][:amount]) - build_tag soap, :string, 'Next', options[:recurring][:next].strftime("%Y-%m-%d") if options[:recurring][:next] - build_tag soap, :string, 'Expire', options[:recurring][:expire].strftime("%Y-%m-%d") if options[:recurring][:expire] + build_tag soap, :string, 'Next', options[:recurring][:next].strftime('%Y-%m-%d') if options[:recurring][:next] + build_tag soap, :string, 'Expire', options[:recurring][:expire].strftime('%Y-%m-%d') if options[:recurring][:expire] RECURRING_BILLING_OPTIONS.each do |k,v| build_tag soap, v[0], v[1], options[:recurring][k] end @@ -1478,7 +1478,7 @@ def build_billing_address(soap, options) if options[:billing_address][:name] options[:billing_address][:first_name], options[:billing_address][:last_name] = split_names(options[:billing_address][:name]) end - soap.BillingAddress 'xsi:type' => "ns1:Address" do + soap.BillingAddress 'xsi:type' => 'ns1:Address' do ADDRESS_OPTIONS.each do |k,v| build_tag soap, v[0], v[1], options[:billing_address][k] end @@ -1491,7 +1491,7 @@ def build_shipping_address(soap, options) if options[:shipping_address][:name] options[:shipping_address][:first_name], options[:shipping_address][:last_name] = split_names(options[:shipping_address][:name]) end - soap.ShippingAddress 'xsi:type' => "ns1:Address" do + soap.ShippingAddress 'xsi:type' => 'ns1:Address' do ADDRESS_OPTIONS.each do |k,v| build_tag soap, v[0], v[1], options[:shipping_address][k] end @@ -1526,7 +1526,7 @@ def commit(action, request) url = test? ? test_url : live_url begin - soap = ssl_post(url, request, "Content-Type" => "text/xml") + soap = ssl_post(url, request, 'Content-Type' => 'text/xml') rescue ActiveMerchant::ResponseError => error soap = error.response.body end @@ -1558,7 +1558,7 @@ def avs_from(avs) def parse(action, soap) xml = REXML::Document.new(soap) - root = REXML::XPath.first(xml, "//SOAP-ENV:Body") + root = REXML::XPath.first(xml, '//SOAP-ENV:Body') response = root ? parse_element(root[0]) : { :response => soap } success, message, authorization, avs, cvv = false, FAILURE_MESSAGE, nil, nil, nil diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb index c36e54f43fa..b2f4a7fb590 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb @@ -269,7 +269,7 @@ def commit(action, parameters) end def message_from(response) - if response[:status] == "Approved" + if response[:status] == 'Approved' return 'Success' else return 'Unspecified error' if response[:error].blank? @@ -286,7 +286,7 @@ def post_data(action, parameters = {}) hash = Digest::SHA1.hexdigest("#{parameters[:command]}:#{@options[:password]}:#{parameters[:amount]}:#{parameters[:invoice]}:#{seed}") parameters[:hash] = "s/#{seed}/#{hash}/n" - parameters.collect { |key, value| "UM#{key}=#{CGI.escape(value.to_s)}" }.join("&") + parameters.collect { |key, value| "UM#{key}=#{CGI.escape(value.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/vanco.rb b/lib/active_merchant/billing/gateways/vanco.rb index e8a3617de91..8f9925bb946 100644 --- a/lib/active_merchant/billing/gateways/vanco.rb +++ b/lib/active_merchant/billing/gateways/vanco.rb @@ -23,14 +23,14 @@ def initialize(options={}) def purchase(money, payment_method, options={}) MultiResponse.run do |r| r.process { login } - r.process { commit(purchase_request(money, payment_method, r.params["response_sessionid"], options), :response_transactionref) } + r.process { commit(purchase_request(money, payment_method, r.params['response_sessionid'], options), :response_transactionref) } end end def refund(money, authorization, options={}) MultiResponse.run do |r| r.process { login } - r.process { commit(refund_request(money, authorization, r.params["response_sessionid"]), :response_creditrequestreceived) } + r.process { commit(refund_request(money, authorization, r.params['response_sessionid']), :response_creditrequestreceived) } end end @@ -66,7 +66,7 @@ def parse(xml) def childnode_to_response(response, node, childnode) name = "#{node.name.downcase}_#{childnode.name.downcase}" - if name == "response_errors" && !childnode.elements.empty? + if name == 'response_errors' && !childnode.elements.empty? add_errors_to_response(response, childnode.to_s) else response[name.downcase.to_sym] = childnode.text @@ -77,13 +77,13 @@ def add_errors_to_response(response, errors_xml) errors_hash = Hash.from_xml(errors_xml).values.first response[:response_errors] = errors_hash - error = errors_hash["Error"] + error = errors_hash['Error'] if error.kind_of?(Hash) - response[:error_message] = error["ErrorDescription"] - response[:error_codes] = error["ErrorCode"] + response[:error_message] = error['ErrorDescription'] + response[:error_codes] = error['ErrorCode'] elsif error.kind_of?(Array) - error_str = error.map { |e| e["ErrorDescription"]}.join(". ") - error_codes = error.map { |e| e["ErrorCode"]}.join(", ") + error_str = error.map { |e| e['ErrorDescription']}.join('. ') + error_codes = error.map { |e| e['ErrorCode']}.join(', ') response[:error_message] = "#{error_str}." response[:error_codes] = error_codes end @@ -107,7 +107,7 @@ def success_from(response, success_field_name) end def message_from(succeeded, response) - return "Success" if succeeded + return 'Success' if succeeded response[:error_message] end @@ -116,7 +116,7 @@ def authorization_from(response) response[:response_customerref], response[:response_paymentmethodref], response[:response_transactionref] - ].join("|") + ].join('|') end def split_authorization(authorization) @@ -125,7 +125,7 @@ def split_authorization(authorization) def purchase_request(money, payment_method, session_id, options) build_xml_request do |doc| - add_auth(doc, "EFTAddCompleteTransaction", session_id) + add_auth(doc, 'EFTAddCompleteTransaction', session_id) doc.Request do doc.RequestVars do @@ -141,7 +141,7 @@ def purchase_request(money, payment_method, session_id, options) def refund_request(money, authorization, session_id) build_xml_request do |doc| - add_auth(doc, "EFTAddCredit", session_id) + add_auth(doc, 'EFTAddCredit', session_id) doc.Request do doc.RequestVars do @@ -203,7 +203,7 @@ def add_credit_card(doc, credit_card, options) doc.CardExpYear(format(credit_card.year, :two_digits)) doc.CardCVV2(credit_card.verification_value) doc.CardBillingName(credit_card.name) - doc.AccountType("CC") + doc.AccountType('CC') add_billing_address(doc, options) end @@ -220,28 +220,28 @@ def add_billing_address(doc, options) end def add_echeck(doc, echeck) - if echeck.account_type == "savings" - doc.AccountType("S") + if echeck.account_type == 'savings' + doc.AccountType('S') else - doc.AccountType("C") + doc.AccountType('C') end doc.CustomerName("#{echeck.last_name}, #{echeck.first_name}") doc.AccountNumber(echeck.account_number) doc.RoutingNumber(echeck.routing_number) - doc.TransactionTypeCode("WEB") + doc.TransactionTypeCode('WEB') end def add_purchase_noise(doc) - doc.StartDate("0000-00-00") - doc.FrequencyCode("O") + doc.StartDate('0000-00-00') + doc.FrequencyCode('O') end def add_refund_noise(doc) - doc.ContactName("Bilbo Baggins") - doc.ContactPhone("1234567890") - doc.ContactExtension("None") - doc.ReasonForCredit("Refund requested") + doc.ContactName('Bilbo Baggins') + doc.ContactPhone('1234567890') + doc.ContactExtension('None') + doc.ReasonForCredit('Refund requested') end def add_options(doc, options) @@ -259,7 +259,7 @@ def login def login_request build_xml_request do |doc| doc.Auth do - add_request(doc, "Login") + add_request(doc, 'Login') end doc.Request do @@ -273,7 +273,7 @@ def login_request def build_xml_request builder = Nokogiri::XML::Builder.new - builder.__send__("VancoWS") do |doc| + builder.__send__('VancoWS') do |doc| yield(doc) end builder.to_xml diff --git a/lib/active_merchant/billing/gateways/verifi.rb b/lib/active_merchant/billing/gateways/verifi.rb index 2459edf5eb3..b8c2142e621 100644 --- a/lib/active_merchant/billing/gateways/verifi.rb +++ b/lib/active_merchant/billing/gateways/verifi.rb @@ -12,39 +12,39 @@ class VerifiPostData < PostData self.live_url = self.test_url = 'https://secure.verifi.com/gw/api/transact.php' RESPONSE_CODE_MESSAGES = { - "100" => "Transaction was Approved", - "200" => "Transaction was Declined by Processor", - "201" => "Do Not Honor", - "202" => "Insufficient Funds", - "203" => "Over Limit", - "204" => "Transaction not allowed", - "220" => "Incorrect payment Data", - "221" => "No Such Card Issuer", - "222" => "No Card Number on file with Issuer", - "223" => "Expired Card", - "224" => "Invalid Expiration Date", - "225" => "Invalid Card Security Code", - "240" => "Call Issuer for Further Information", - "250" => "Pick Up Card", - "251" => "Lost Card", - "252" => "Stolen Card", - "253" => "Fraudulent Card", - "260" => "Declined With further Instructions Available (see response text)", - "261" => "Declined - Stop All Recurring Payments", - "262" => "Declined - Stop this Recurring Program", - "263" => "Declined - Update Cardholder Data Available", - "264" => "Declined - Retry in a few days", - "300" => "Transaction was Rejected by Gateway", - "400" => "Transaction Error Returned by Processor", - "410" => "Invalid Merchant Configuration", - "411" => "Merchant Account is Inactive", - "420" => "Communication Error", - "421" => "Communication Error with Issuer", - "430" => "Duplicate Transaction at Processor", - "440" => "Processor Format Error", - "441" => "Invalid Transaction Information", - "460" => "Processor Feature Not Available", - "461" => "Unsupported Card Type" + '100' => 'Transaction was Approved', + '200' => 'Transaction was Declined by Processor', + '201' => 'Do Not Honor', + '202' => 'Insufficient Funds', + '203' => 'Over Limit', + '204' => 'Transaction not allowed', + '220' => 'Incorrect payment Data', + '221' => 'No Such Card Issuer', + '222' => 'No Card Number on file with Issuer', + '223' => 'Expired Card', + '224' => 'Invalid Expiration Date', + '225' => 'Invalid Card Security Code', + '240' => 'Call Issuer for Further Information', + '250' => 'Pick Up Card', + '251' => 'Lost Card', + '252' => 'Stolen Card', + '253' => 'Fraudulent Card', + '260' => 'Declined With further Instructions Available (see response text)', + '261' => 'Declined - Stop All Recurring Payments', + '262' => 'Declined - Stop this Recurring Program', + '263' => 'Declined - Update Cardholder Data Available', + '264' => 'Declined - Retry in a few days', + '300' => 'Transaction was Rejected by Gateway', + '400' => 'Transaction Error Returned by Processor', + '410' => 'Invalid Merchant Configuration', + '411' => 'Merchant Account is Inactive', + '420' => 'Communication Error', + '421' => 'Communication Error with Issuer', + '430' => 'Duplicate Transaction at Processor', + '440' => 'Processor Format Error', + '441' => 'Invalid Transaction Information', + '460' => 'Processor Feature Not Available', + '461' => 'Unsupported Card Type' } SUCCESS = 1 @@ -180,10 +180,10 @@ def add_security_key_data(post, options, money) # MD5(username|password|orderid|amount|time) now = Time.now.to_i.to_s md5 = Digest::MD5.new - md5 << @options[:login].to_s + "|" - md5 << @options[:password].to_s + "|" - md5 << options[:order_id].to_s + "|" - md5 << amount(money).to_s + "|" + md5 << @options[:login].to_s + '|' + md5 << @options[:password].to_s + '|' + md5 << options[:order_id].to_s + '|' + md5 << amount(money).to_s + '|' md5 << now post[:key] = md5.hexdigest post[:time] = now @@ -203,7 +203,7 @@ def commit(trx_type, money, post) end def message_from(response) - response[:response_code_message] || "" + response[:response_code_message] || '' end def parse(body) diff --git a/lib/active_merchant/billing/gateways/viaklix.rb b/lib/active_merchant/billing/gateways/viaklix.rb index 3c9a1c18118..c2e800b9b4c 100644 --- a/lib/active_merchant/billing/gateways/viaklix.rb +++ b/lib/active_merchant/billing/gateways/viaklix.rb @@ -50,7 +50,7 @@ def purchase(money, creditcard, options = {}) # Viaklix does not support credits by reference. You must pass in the credit card def credit(money, creditcard, options = {}) if creditcard.is_a?(String) - raise ArgumentError, "Reference credits are not supported. Please supply the original credit card" + raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card' end form = {} @@ -158,14 +158,14 @@ def message_from(response) def post_data(parameters) result = preamble result.merge!(parameters) - result.collect { |key, value| "ssl_#{key}=#{CGI.escape(value.to_s)}" }.join("&") + result.collect { |key, value| "ssl_#{key}=#{CGI.escape(value.to_s)}" }.join('&') end # Parse the response message def parse(msg) resp = {} msg.split(self.delimiter).collect{|li| - key, value = li.split("=") + key, value = li.split('=') resp[key.strip.gsub(/^ssl_/, '')] = value.to_s.strip } resp diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb index f2c3e60acd1..cc84e95f9c1 100644 --- a/lib/active_merchant/billing/gateways/visanet_peru.rb +++ b/lib/active_merchant/billing/gateways/visanet_peru.rb @@ -2,14 +2,14 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class VisanetPeruGateway < Gateway include Empty - self.display_name = "VisaNet Peru Gateway" - self.homepage_url = "http://www.visanet.com.pe" + self.display_name = 'VisaNet Peru Gateway' + self.homepage_url = 'http://www.visanet.com.pe' - self.test_url = "https://devapi.vnforapps.com/api.tokenization/api/v2/merchant" - self.live_url = "https://api.vnforapps.com/api.tokenization/api/v2/merchant" + self.test_url = 'https://devapi.vnforapps.com/api.tokenization/api/v2/merchant' + self.live_url = 'https://api.vnforapps.com/api.tokenization/api/v2/merchant' - self.supported_countries = ["US", "PE"] - self.default_currency = "PEN" + self.supported_countries = ['US', 'PE'] + self.default_currency = 'PEN' self.money_format = :dollars self.supported_cardtypes = [:visa, :master, :american_express, :discover] @@ -34,27 +34,27 @@ def authorize(amount, payment_method, options={}) params[:email] = options[:email] || 'unknown@email.com' params[:createAlias] = false - commit("authorize", params, options) + commit('authorize', params, options) end def capture(authorization, options={}) params = {} options[:id_unico] = split_authorization(authorization)[1] add_auth_order_id(params, authorization, options) - commit("deposit", params, options) + commit('deposit', params, options) end def void(authorization, options={}) params = {} add_auth_order_id(params, authorization, options) - commit("void", params, options) + commit('void', params, options) end def refund(amount, authorization, options={}) params = {} params[:amount] = amount(amount) if amount add_auth_order_id(params, authorization, options) - response = commit("cancelDeposit", params, options) + response = commit('cancelDeposit', params, options) return response if response.success? || split_authorization(authorization).length == 1 || !options[:force_full_refund_if_unsettled] # Attempt RefundSingleTransaction if unsettled @@ -83,8 +83,8 @@ def scrub(transcript) private CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")} - CURRENCY_CODES["USD"] = 840 - CURRENCY_CODES["PEN"] = 604 + CURRENCY_CODES['USD'] = 840 + CURRENCY_CODES['PEN'] = 604 def add_invoice(params, money, options) # Visanet Peru expects a 9-digit numeric purchaseNumber @@ -155,20 +155,20 @@ def commit(action, params, options={}) response, :test => test?, :authorization => authorization_from(params, response, options), - :error_code => response["errorCode"] + :error_code => response['errorCode'] ) end end def headers { - "Authorization" => "Basic " + Base64.strict_encode64("#{@options[:access_key_id]}:#{@options[:secret_access_key]}").strip, - "Content-Type" => "application/json" + 'Authorization' => 'Basic ' + Base64.strict_encode64("#{@options[:access_key_id]}:#{@options[:secret_access_key]}").strip, + 'Content-Type' => 'application/json' } end def url(action, params, options={}) - if (action == "authorize") + if (action == 'authorize') "#{base_url}/#{@options[:merchant_id]}" elsif (action == 'refund') "#{base_url}/#{@options[:merchant_id]}/#{action}/#{options[:transaction_id]}" @@ -195,15 +195,15 @@ def parse(body) end def success_from(response) - response["errorCode"] == 0 + response['errorCode'] == 0 end def message_from(response, options, action) - if empty?(response["errorMessage"]) || response["errorMessage"] == "[ ]" - action == 'refund' ? "#{response["data"]["DSC_COD_ACCION"]}, #{options[:error_message]}" : response['data']['DSC_COD_ACCION'] + if empty?(response['errorMessage']) || response['errorMessage'] == '[ ]' + action == 'refund' ? "#{response['data']['DSC_COD_ACCION']}, #{options[:error_message]}" : response['data']['DSC_COD_ACCION'] elsif action == 'refund' - message = "#{response["errorMessage"]}, #{options[:error_message]}" - options[:error_message] = response["errorMessage"] + message = "#{response['errorMessage']}, #{options[:error_message]}" + options[:error_message] = response['errorMessage'] message else response['errorMessage'] @@ -221,14 +221,14 @@ def response_error(raw_response, options, action) message_from(response, options, action), response, :test => test?, - :authorization => response["transactionUUID"], - :error_code => response["errorCode"] + :authorization => response['transactionUUID'], + :error_code => response['errorCode'] ) end end def unparsable_response(raw_response) - message = "Invalid JSON response received from VisanetPeruGateway. Please contact VisanetPeruGateway if you continue to receive this message." + message = 'Invalid JSON response received from VisanetPeruGateway. Please contact VisanetPeruGateway if you continue to receive this message.' message += " (The raw response returned by the API was #{raw_response.inspect})" return Response.new(false, message) end diff --git a/lib/active_merchant/billing/gateways/webpay.rb b/lib/active_merchant/billing/gateways/webpay.rb index f35d8c5250e..29636897892 100644 --- a/lib/active_merchant/billing/gateways/webpay.rb +++ b/lib/active_merchant/billing/gateways/webpay.rb @@ -51,9 +51,9 @@ def store(creditcard, options = {}) MultiResponse.run(:first) do |r| r.process { commit(:post, "customers/#{CGI.escape(options[:customer])}/", post, options) } - return r unless options[:set_default] and r.success? and !r.params["id"].blank? + return r unless options[:set_default] and r.success? and !r.params['id'].blank? - r.process { update_customer(options[:customer], :default_card => r.params["id"]) } + r.process { update_customer(options[:customer], :default_card => r.params['id']) } end else commit(:post, 'customers', post, options) @@ -78,18 +78,18 @@ def json_error(raw_response) msg = 'Invalid response received from the WebPay API. Please contact support@webpay.jp if you continue to receive this message.' msg += " (The raw response returned by the API was #{raw_response.inspect})" { - "error" => { - "message" => msg + 'error' => { + 'message' => msg } } end def headers(options = {}) { - "Authorization" => "Basic " + Base64.encode64(@api_key.to_s + ":").strip, - "User-Agent" => "Webpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}", - "X-Webpay-Client-User-Agent" => user_agent, - "X-Webpay-Client-User-Metadata" => {:ip => options[:ip]}.to_json + 'Authorization' => 'Basic ' + Base64.encode64(@api_key.to_s + ':').strip, + 'User-Agent' => "Webpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}", + 'X-Webpay-Client-User-Agent' => user_agent, + 'X-Webpay-Client-User-Metadata' => {:ip => options[:ip]}.to_json } end end diff --git a/lib/active_merchant/billing/gateways/wepay.rb b/lib/active_merchant/billing/gateways/wepay.rb index b9cd338213a..4ae60420421 100644 --- a/lib/active_merchant/billing/gateways/wepay.rb +++ b/lib/active_merchant/billing/gateways/wepay.rb @@ -57,7 +57,7 @@ def capture(money, identifier, options = {}) def void(identifier, options = {}) post = {} post[:checkout_id] = split_authorization(identifier).first - post[:cancel_reason] = (options[:description] || "Void") + post[:cancel_reason] = (options[:description] || 'Void') commit('/checkout/cancel', post, options) end @@ -69,17 +69,17 @@ def refund(money, identifier, options = {}) if(money && (original_amount != amount(money))) post[:amount] = amount(money) end - post[:refund_reason] = (options[:description] || "Refund") + post[:refund_reason] = (options[:description] || 'Refund') post[:payer_email_message] = options[:payer_email_message] if options[:payer_email_message] post[:payee_email_message] = options[:payee_email_message] if options[:payee_email_message] - commit("/checkout/refund", post, options) + commit('/checkout/refund', post, options) end def store(creditcard, options = {}) post = {} post[:client_id] = @options[:client_id] post[:user_name] = "#{creditcard.first_name} #{creditcard.last_name}" - post[:email] = options[:email] || "unspecified@example.com" + post[:email] = options[:email] || 'unspecified@example.com' post[:cc_number] = creditcard.number post[:cvv] = creditcard.verification_value unless options[:recurring] post[:expiration_month] = creditcard.month @@ -87,11 +87,11 @@ def store(creditcard, options = {}) if(billing_address = (options[:billing_address] || options[:address])) post[:address] = {} - post[:address]["address1"] = billing_address[:address1] if billing_address[:address1] - post[:address]["city"] = billing_address[:city] if billing_address[:city] - post[:address]["country"] = billing_address[:country] if billing_address[:country] - post[:address]["region"] = billing_address[:state] if billing_address[:state] - post[:address]["postal_code"] = billing_address[:zip] + post[:address]['address1'] = billing_address[:address1] if billing_address[:address1] + post[:address]['city'] = billing_address[:city] if billing_address[:city] + post[:address]['country'] = billing_address[:country] if billing_address[:country] + post[:address]['region'] = billing_address[:state] if billing_address[:state] + post[:address]['postal_code'] = billing_address[:zip] end if options[:recurring] == true @@ -126,8 +126,8 @@ def authorize_with_token(post, money, token, options) def add_product_data(post, money, options) post[:account_id] = @options[:account_id] post[:amount] = amount(money) - post[:short_description] = (options[:description] || "Purchase") - post[:type] = (options[:type] || "goods") + post[:short_description] = (options[:description] || 'Purchase') + post[:type] = (options[:type] || 'goods') post[:currency] = (options[:currency] || currency(money)) post[:long_description] = options[:long_description] if options[:long_description] post[:payer_email_message] = options[:payer_email_message] if options[:payer_email_message] @@ -151,7 +151,7 @@ def add_product_data(post, money, options) def add_token(post, token) payment_method = {} - payment_method[:type] = "credit_card" + payment_method[:type] = 'credit_card' payment_method[:credit_card] = { id: token, auto_capture: false @@ -196,40 +196,40 @@ def commit(action, params, options={}) end def success_from(response) - (!response["error"]) + (!response['error']) end def message_from(response) - (response["error"] ? response["error_description"] : "Success") + (response['error'] ? response['error_description'] : 'Success') end def authorization_from(response, params) - return response["credit_card_id"].to_s if response["credit_card_id"] + return response['credit_card_id'].to_s if response['credit_card_id'] - original_amount = response["amount"].nil? ? nil : sprintf("%0.02f", response["amount"]) - [response["checkout_id"], original_amount].join('|') + original_amount = response['amount'].nil? ? nil : sprintf('%0.02f', response['amount']) + [response['checkout_id'], original_amount].join('|') end def split_authorization(authorization) - auth, original_amount = authorization.to_s.split("|") + auth, original_amount = authorization.to_s.split('|') [auth, original_amount] end def unparsable_response(raw_response) - message = "Invalid JSON response received from WePay. Please contact WePay support if you continue to receive this message." + message = 'Invalid JSON response received from WePay. Please contact WePay support if you continue to receive this message.' message += " (The raw response returned by the API was #{raw_response.inspect})" return Response.new(false, message) end def headers(options) headers = { - "Content-Type" => "application/json", - "User-Agent" => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}", - "Authorization" => "Bearer #{@options[:access_token]}" + 'Content-Type' => 'application/json', + 'User-Agent' => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}", + 'Authorization' => "Bearer #{@options[:access_token]}" } - headers["Api-Version"] = options[:version] if options[:version] - headers["Client-IP"] = options[:ip] if options[:ip] - headers["WePay-Risk-Token"] = options[:risk_token] if options[:risk_token] + headers['Api-Version'] = options[:version] if options[:version] + headers['Client-IP'] = options[:ip] if options[:ip] + headers['WePay-Risk-Token'] = options[:risk_token] if options[:risk_token] headers end diff --git a/lib/active_merchant/billing/gateways/wirecard.rb b/lib/active_merchant/billing/gateways/wirecard.rb index 4093149f03f..321cd379565 100644 --- a/lib/active_merchant/billing/gateways/wirecard.rb +++ b/lib/active_merchant/billing/gateways/wirecard.rb @@ -139,7 +139,7 @@ def scrub(transcript) private def clean_description(description) - description.to_s.slice(0,32).encode("US-ASCII", invalid: :replace, undef: :replace, replace: '?') + description.to_s.slice(0,32).encode('US-ASCII', invalid: :replace, undef: :replace, replace: '?') end def prepare_options_hash(options) @@ -174,7 +174,7 @@ def commit(action, money, options) response = parse(ssl_post(test? ? self.test_url : self.live_url, request, headers)) # Pending Status also means Acknowledged (as stated in their specification) - success = response[:FunctionResult] == "ACK" || response[:FunctionResult] == "PENDING" + success = response[:FunctionResult] == 'ACK' || response[:FunctionResult] == 'PENDING' message = response[:Message] authorization = response[:GuWID] @@ -185,8 +185,8 @@ def commit(action, money, options) :cvv_result => response[:CVCResponseCode] ) rescue ResponseError => e - if e.response.code == "401" - return Response.new(false, "Invalid Login") + if e.response.code == '401' + return Response.new(false, 'Invalid Login') else raise end @@ -261,7 +261,7 @@ def add_amount(xml, money, options) # Includes the credit-card data to the transaction-xml def add_creditcard(xml, creditcard) - raise "Creditcard must be supplied!" if creditcard.nil? + raise 'Creditcard must be supplied!' if creditcard.nil? xml.tag! 'CREDIT_CARD_DATA' do xml.tag! 'CreditCardNumber', creditcard.number xml.tag! 'CVC2', creditcard.verification_value @@ -309,7 +309,7 @@ def parse(xml) xml = REXML::Document.new(xml) if root = REXML::XPath.first(xml, "#{basepath}/W_JOB") parse_response(response, root) - elsif root = REXML::XPath.first(xml, "//ERROR") + elsif root = REXML::XPath.first(xml, '//ERROR') parse_error_only_response(response, root) else response[:Message] = "No valid XML response message received. \ @@ -320,7 +320,7 @@ def parse(xml) end def parse_error_only_response(response, root) - error_code = REXML::XPath.first(root, "Number") + error_code = REXML::XPath.first(root, 'Number') response[:ErrorCode] = error_code.text if error_code response[:Message] = parse_error(root) end @@ -331,11 +331,11 @@ def parse_response(response, root) root.elements.to_a.each do |node| if node.name =~ /FNC_CC_/ - status = REXML::XPath.first(node, "CC_TRANSACTION/PROCESSING_STATUS") + status = REXML::XPath.first(node, 'CC_TRANSACTION/PROCESSING_STATUS') end end - message = "" + message = '' if status if info = status.elements['Info'] message << info.text @@ -352,7 +352,7 @@ def parse_response(response, root) end end - error_code = REXML::XPath.first(status, "ERROR/Number") + error_code = REXML::XPath.first(status, 'ERROR/Number') response['ErrorCode'] = error_code.text if error_code end @@ -361,7 +361,7 @@ def parse_response(response, root) end # Parse a generic error response from the gateway - def parse_error(root, message = "") + def parse_error(root, message = '') # Get errors if available and append them to the message errors = errors_to_string(root) unless errors.strip.blank? @@ -376,7 +376,7 @@ def parse_error(root, message = "") def errors_to_string(root) # Get context error messages (can be 0..*) errors = [] - REXML::XPath.each(root, "//ERROR") do |error_elem| + REXML::XPath.each(root, '//ERROR') do |error_elem| error = {} error[:Advice] = [] error[:Message] = error_elem.elements['Message'].text @@ -401,18 +401,18 @@ def errors_to_string(root) # Amex have different AVS response codes AMEX_TRANSLATED_AVS_CODES = { - "A" => "B", # CSC and Address Matched - "F" => "D", # All Data Matched - "N" => "I", # CSC Match - "U" => "U", # Data Not Checked - "Y" => "D", # All Data Matched - "Z" => "P", # CSC and Postcode Matched + 'A' => 'B', # CSC and Address Matched + 'F' => 'D', # All Data Matched + 'N' => 'I', # CSC Match + 'U' => 'U', # Data Not Checked + 'Y' => 'D', # All Data Matched + 'Z' => 'P', # CSC and Postcode Matched } # Amex have different AVS response codes to visa etc def avs_code(response, options) if response.has_key?(:AVS_ProviderResultCode) - if options[:credit_card].present? && ActiveMerchant::Billing::CreditCard.brand?(options[:credit_card].number) == "american_express" + if options[:credit_card].present? && ActiveMerchant::Billing::CreditCard.brand?(options[:credit_card].number) == 'american_express' AMEX_TRANSLATED_AVS_CODES[response[:AVS_ProviderResultCode]] else response[:AVS_ProviderResultCode] @@ -424,7 +424,7 @@ def avs_code(response, options) # (for http basic authentication) def encoded_credentials credentials = [@options[:login], @options[:password]].join(':') - "Basic " << Base64.encode64(credentials).strip + 'Basic ' << Base64.encode64(credentials).strip end end end diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index f6864fb3752..b88c10afe04 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -44,7 +44,7 @@ def authorize(money, payment_method, options = {}) def capture(money, authorization, options = {}) MultiResponse.run do |r| - r.process{inquire_request(authorization, options, "AUTHORISED")} unless options[:authorization_validated] + r.process{inquire_request(authorization, options, 'AUTHORISED')} unless options[:authorization_validated] if r.params authorization_currency = r.params['amount_currency_code'] options = options.merge(:currency => authorization_currency) if authorization_currency.present? @@ -55,21 +55,21 @@ def capture(money, authorization, options = {}) def void(authorization, options = {}) MultiResponse.run do |r| - r.process{inquire_request(authorization, options, "AUTHORISED")} unless options[:authorization_validated] + r.process{inquire_request(authorization, options, 'AUTHORISED')} unless options[:authorization_validated] r.process{cancel_request(authorization, options)} end end def refund(money, authorization, options = {}) response = MultiResponse.run do |r| - r.process { inquire_request(authorization, options, "CAPTURED", "SETTLED", "SETTLED_BY_MERCHANT") } + r.process { inquire_request(authorization, options, 'CAPTURED', 'SETTLED', 'SETTLED_BY_MERCHANT') } r.process { refund_request(money, authorization, options) } end return response if response.success? return response unless options[:force_full_refund_if_unsettled] - void(authorization, options ) if response.params["last_event"] == "AUTHORISED" + void(authorization, options ) if response.params['last_event'] == 'AUTHORISED' end # Credits only function on a Merchant ID/login/profile flagged for Payouts @@ -101,7 +101,7 @@ def scrub(transcript) private def authorize_request(money, payment_method, options) - commit('authorize', build_authorization_request(money, payment_method, options), "AUTHORISED", options) + commit('authorize', build_authorization_request(money, payment_method, options), 'AUTHORISED', options) end def capture_request(money, authorization, options) @@ -127,8 +127,8 @@ def credit_request(money, payment_method, options) def build_request xml = Builder::XmlMarkup.new :indent => 2 xml.instruct! :xml, :encoding => 'UTF-8' - xml.declare! :DOCTYPE, :paymentService, :PUBLIC, "-//WorldPay//DTD WorldPay PaymentService v1//EN", "http://dtd.worldpay.com/paymentService_v1.dtd" - xml.tag! 'paymentService', 'version' => "1.4", 'merchantCode' => @options[:login] do + xml.declare! :DOCTYPE, :paymentService, :PUBLIC, '-//WorldPay//DTD WorldPay PaymentService v1//EN', 'http://dtd.worldpay.com/paymentService_v1.dtd' + xml.tag! 'paymentService', 'version' => '1.4', 'merchantCode' => @options[:login] do yield xml end xml.target! @@ -156,7 +156,7 @@ def build_authorization_request(money, payment_method, options) build_request do |xml| xml.tag! 'submit' do xml.tag! 'order', order_tag_attributes(options) do - xml.description(options[:description].blank? ? "Purchase" : options[:description]) + xml.description(options[:description].blank? ? 'Purchase' : options[:description]) add_amount(xml, money, options) if options[:order_content] xml.tag! 'orderContent' do @@ -196,7 +196,7 @@ def build_void_request(authorization, options) def build_refund_request(money, authorization, options) build_order_modify_request(authorization) do |xml| xml.tag! 'refund' do - add_amount(xml, money, options.merge(:debit_credit_indicator => "credit")) + add_amount(xml, money, options.merge(:debit_credit_indicator => 'credit')) end end end @@ -287,7 +287,7 @@ def add_address(xml, address) def add_hcg_additional_data(xml, options) xml.tag! 'hcgAdditionalData' do options[:hcg_additional_data].each do |k, v| - xml.tag! "param", {name: k.to_s}, v + xml.tag! 'param', {name: k.to_s}, v end end end @@ -354,8 +354,8 @@ def commit(action, request, *success_criteria, options) :test => test?) rescue ActiveMerchant::ResponseError => e - if e.response.code.to_s == "401" - return Response.new(false, "Invalid credentials", {}, :test => test?) + if e.response.code.to_s == '401' + return Response.new(false, 'Invalid credentials', {}, :test => test?) else raise e end @@ -384,7 +384,7 @@ def handle_response(response) def success_and_message_from(raw, success_criteria) success = (success_criteria.include?(raw[:last_event]) || raw[:ok].present?) if success - message = "SUCCESS" + message = 'SUCCESS' else message = (raw[:iso8583_return_code_description] || raw[:error] || required_status_message(raw, success_criteria)) end @@ -393,7 +393,7 @@ def success_and_message_from(raw, success_criteria) end def error_code_from(success, raw) - unless success == "SUCCESS" + unless success == 'SUCCESS' raw[:iso8583_return_code_code] || raw[:error_code] || nil end end @@ -411,7 +411,7 @@ def authorization_from(raw) def credit_fund_transfer_attribute(options) return unless options[:credit] - {'action' => "REFUND"} + {'action' => 'REFUND'} end def encoded_credentials diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb index f9ffe71cad3..4d4490efb9e 100644 --- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb @@ -32,7 +32,7 @@ def authorize(money, credit_card, options={}) def capture(money, authorization, options={}) if authorization - commit(:post, "orders/#{CGI.escape(authorization)}/capture", {"captureAmount"=>money}, options, 'capture') + commit(:post, "orders/#{CGI.escape(authorization)}/capture", {'captureAmount'=>money}, options, 'capture') else Response.new(false, 'FAILED', @@ -56,7 +56,7 @@ def purchase(money, credit_card, options={}) end def refund(money, orderCode, options={}) - obj = money ? {"refundAmount" => money} : {} + obj = money ? {'refundAmount' => money} : {} commit(:post, "orders/#{CGI.escape(orderCode)}/refund", obj, options, 'refund') end @@ -76,16 +76,16 @@ def verify(credit_card, options={}) def create_token(reusable, name, exp_month, exp_year, number, cvc) obj = { - "reusable"=> reusable, - "paymentMethod"=> { - "type"=> "Card", - "name"=> name, - "expiryMonth"=> exp_month, - "expiryYear"=> exp_year, - "cardNumber"=> number, - "cvc"=> cvc + 'reusable'=> reusable, + 'paymentMethod'=> { + 'type'=> 'Card', + 'name'=> name, + 'expiryMonth'=> exp_month, + 'expiryYear'=> exp_year, + 'cardNumber'=> number, + 'cvc'=> cvc }, - "clientKey"=> @client_key + 'clientKey'=> @client_key } token_response = commit(:post, 'tokens', obj, {'Authorization' => @service_key}, 'token') token_response @@ -93,23 +93,23 @@ def create_token(reusable, name, exp_month, exp_year, number, cvc) def create_post_for_auth_or_purchase(token, money, options) { - "token" => token, - "orderDescription" => options[:description] || 'Worldpay Order', - "amount" => money, - "currencyCode" => options[:currency] || default_currency, - "name" => options[:billing_address]&&options[:billing_address][:name] ? options[:billing_address][:name] : '', - "billingAddress" => { - "address1"=>options[:billing_address]&&options[:billing_address][:address1] ? options[:billing_address][:address1] : '', - "address2"=>options[:billing_address]&&options[:billing_address][:address2] ? options[:billing_address][:address2] : '', - "address3"=>"", - "postalCode"=>options[:billing_address]&&options[:billing_address][:zip] ? options[:billing_address][:zip] : '', - "city"=>options[:billing_address]&&options[:billing_address][:city] ? options[:billing_address][:city] : '', - "state"=>options[:billing_address]&&options[:billing_address][:state] ? options[:billing_address][:state] : '', - "countryCode"=>options[:billing_address]&&options[:billing_address][:country] ? options[:billing_address][:country] : '' + 'token' => token, + 'orderDescription' => options[:description] || 'Worldpay Order', + 'amount' => money, + 'currencyCode' => options[:currency] || default_currency, + 'name' => options[:billing_address]&&options[:billing_address][:name] ? options[:billing_address][:name] : '', + 'billingAddress' => { + 'address1'=>options[:billing_address]&&options[:billing_address][:address1] ? options[:billing_address][:address1] : '', + 'address2'=>options[:billing_address]&&options[:billing_address][:address2] ? options[:billing_address][:address2] : '', + 'address3'=>'', + 'postalCode'=>options[:billing_address]&&options[:billing_address][:zip] ? options[:billing_address][:zip] : '', + 'city'=>options[:billing_address]&&options[:billing_address][:city] ? options[:billing_address][:city] : '', + 'state'=>options[:billing_address]&&options[:billing_address][:state] ? options[:billing_address][:state] : '', + 'countryCode'=>options[:billing_address]&&options[:billing_address][:country] ? options[:billing_address][:country] : '' }, - "customerOrderCode" => options[:order_id], - "orderType" => "ECOM", - "authorizeOnly" => options[:authorizeOnly] ? true : false + 'customerOrderCode' => options[:order_id], + 'orderType' => 'ECOM', + 'authorizeOnly' => options[:authorizeOnly] ? true : false } end @@ -119,11 +119,11 @@ def parse(body) def headers(options = {}) headers = { - "Authorization" => @service_key, - "Content-Type" => 'application/json', - "User-Agent" => "Worldpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}", - "X-Worldpay-Client-User-Agent" => user_agent, - "X-Worldpay-Client-User-Metadata" => {:ip => options[:ip]}.to_json + 'Authorization' => @service_key, + 'Content-Type' => 'application/json', + 'User-Agent' => "Worldpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}", + 'X-Worldpay-Client-User-Agent' => user_agent, + 'X-Worldpay-Client-User-Metadata' => {:ip => options[:ip]}.to_json } if options['Authorization'] headers['Authorization'] = options['Authorization'] @@ -168,27 +168,27 @@ def commit(method, url, parameters=nil, options = {}, type = false) response = json_error(raw_response) end - if response["orderCode"] - authorization = response["orderCode"] - elsif response["token"] - authorization = response["token"] + if response['orderCode'] + authorization = response['orderCode'] + elsif response['token'] + authorization = response['token'] else - authorization = response["message"] + authorization = response['message'] end Response.new(success, - success ? "SUCCESS" : response["message"], + success ? 'SUCCESS' : response['message'], response, :test => test?, :authorization => authorization, :avs_result => {}, :cvv_result => {}, - :error_code => success ? nil : response["customCode"] + :error_code => success ? nil : response['customCode'] ) end def test? - @service_key[0]=="T" ? true : false + @service_key[0]=='T' ? true : false end def response_error(raw_response) @@ -203,8 +203,8 @@ def json_error(raw_response) msg = 'Invalid response received from the Worldpay Online Payments API. Please contact techsupport.online@worldpay.com if you continue to receive this message.' msg += " (The raw response returned by the API was #{raw_response.inspect})" { - "error" => { - "message" => msg + 'error' => { + 'message' => msg } } end diff --git a/lib/active_merchant/billing/gateways/worldpay_us.rb b/lib/active_merchant/billing/gateways/worldpay_us.rb index 084169424a5..303b5b1767e 100644 --- a/lib/active_merchant/billing/gateways/worldpay_us.rb +++ b/lib/active_merchant/billing/gateways/worldpay_us.rb @@ -1,12 +1,12 @@ -require "nokogiri" +require 'nokogiri' module ActiveMerchant #:nodoc: module Billing #:nodoc: class WorldpayUsGateway < Gateway class_attribute :backup_url - self.display_name = "Worldpay US" - self.homepage_url = "http://www.worldpay.com/us" + self.display_name = 'Worldpay US' + self.homepage_url = 'http://www.worldpay.com/us' # No sandbox, just use test cards. self.live_url = 'https://trans.worldpay.us/cgi-bin/process.cgi' @@ -55,7 +55,7 @@ def refund(amount, authorization, options={}) add_reference(post, authorization) add_customer_data(post, options) - commit("refund", options, post) + commit('refund', options, post) end def void(authorization, options={}) @@ -87,7 +87,7 @@ def scrub(transcript) private def url(options) - options[:use_backup_url].to_s == "true" ? self.backup_url : self.live_url + options[:use_backup_url].to_s == 'true' ? self.backup_url : self.live_url end def add_customer_data(post, options) @@ -138,8 +138,8 @@ def add_credit_card(post, payment_method) end ACCOUNT_TYPES = { - "checking" => "1", - "savings" => "2", + 'checking' => '1', + 'savings' => '2', } def add_check(post, payment_method) @@ -151,7 +151,7 @@ def add_check(post, payment_method) end def split_authorization(authorization) - historyid, orderid = authorization.split("|") + historyid, orderid = authorization.split('|') [historyid, orderid] end @@ -165,7 +165,7 @@ def add_reference(post, authorization) def parse(xml) response = {} doc = Nokogiri::XML(xml) - message = doc.xpath("//plaintext") + message = doc.xpath('//plaintext') message.text.split(/\r?\n/).each do |line| key, value = line.split(%r{=}) response[key] = value if key @@ -174,11 +174,11 @@ def parse(xml) end ACTIONS = { - "purchase" => "ns_quicksale_cc", - "refund" => "ns_credit", - "authorize" => "ns_quicksale_cc", - "capture" => "ns_quicksale_cc", - "void" => "ns_void", + 'purchase' => 'ns_quicksale_cc', + 'refund' => 'ns_credit', + 'authorize' => 'ns_quicksale_cc', + 'capture' => 'ns_quicksale_cc', + 'void' => 'ns_void', } def commit(action, options, post) @@ -207,14 +207,14 @@ def success_from(result) def message_from(succeeded, response) if succeeded - "Succeeded" + 'Succeeded' else - (response['transresult'] || response['Reason'] || "Unable to read error message") + (response['transresult'] || response['Reason'] || 'Unable to read error message') end end def authorization_from(response) - [response['historyid'], response['orderid']].join("|") + [response['historyid'], response['orderid']].join('|') end end end diff --git a/lib/active_merchant/billing/model.rb b/lib/active_merchant/billing/model.rb index c7ee4a69448..ba280a1211e 100644 --- a/lib/active_merchant/billing/model.rb +++ b/lib/active_merchant/billing/model.rb @@ -1,5 +1,5 @@ -require "active_merchant/billing/compatibility" -require "active_merchant/empty" +require 'active_merchant/billing/compatibility' +require 'active_merchant/empty' module ActiveMerchant module Billing diff --git a/lib/active_merchant/billing/network_tokenization_credit_card.rb b/lib/active_merchant/billing/network_tokenization_credit_card.rb index 955557a67d0..0f358948ab8 100644 --- a/lib/active_merchant/billing/network_tokenization_credit_card.rb +++ b/lib/active_merchant/billing/network_tokenization_credit_card.rb @@ -32,7 +32,7 @@ def credit_card? end def type - "network_tokenization" + 'network_tokenization' end end end diff --git a/lib/active_merchant/billing/rails.rb b/lib/active_merchant/billing/rails.rb index f4098fd2ed3..afa9eeb973a 100644 --- a/lib/active_merchant/billing/rails.rb +++ b/lib/active_merchant/billing/rails.rb @@ -1,3 +1,3 @@ -require "active_merchant/billing/compatibility" +require 'active_merchant/billing/compatibility' ActiveMerchant::Billing::Compatibility.rails_required! diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index 6509e68fff8..42ceb2d6770 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -15,7 +15,7 @@ class Connection CA_FILE = File.expand_path('../certs/cacert.pem', File.dirname(__FILE__)) CA_PATH = nil RETRY_SAFE = false - RUBY_184_POST_HEADERS = { "Content-Type" => "application/x-www-form-urlencoded" } + RUBY_184_POST_HEADERS = { 'Content-Type' => 'application/x-www-form-urlencoded' } attr_accessor :endpoint attr_accessor :open_timeout @@ -83,7 +83,7 @@ def request(method, body, headers = {}) result = case method when :get - raise ArgumentError, "GET requests do not support a request body" if body + raise ArgumentError, 'GET requests do not support a request body' if body http.get(endpoint.request_uri, headers) when :post debug body @@ -111,14 +111,14 @@ def request(method, body, headers = {}) end end - info "--> %d %s (%d %.4fs)" % [result.code, result.message, result.body ? result.body.length : 0, realtime], tag + info '--> %d %s (%d %.4fs)' % [result.code, result.message, result.body ? result.body.length : 0, realtime], tag debug result.body result end end ensure - info "connection_request_total_time=%.4fs" % [Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start], tag + info 'connection_request_total_time=%.4fs' % [Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start], tag http.finish if http.started? end @@ -145,7 +145,7 @@ def configure_timeouts(http) end def configure_ssl(http) - return unless endpoint.scheme == "https" + return unless endpoint.scheme == 'https' http.use_ssl = true http.ssl_version = ssl_version if ssl_version diff --git a/lib/active_merchant/country.rb b/lib/active_merchant/country.rb index 85ae1fa67d6..46349e63123 100644 --- a/lib/active_merchant/country.rb +++ b/lib/active_merchant/country.rb @@ -317,7 +317,7 @@ def to_s ] def self.find(name) - raise InvalidCountryCodeError, "Cannot lookup country for an empty name" if name.blank? + raise InvalidCountryCodeError, 'Cannot lookup country for an empty name' if name.blank? case name.length when 2, 3 diff --git a/lib/active_merchant/network_connection_retries.rb b/lib/active_merchant/network_connection_retries.rb index fe2c0e29c61..772e8617936 100644 --- a/lib/active_merchant/network_connection_retries.rb +++ b/lib/active_merchant/network_connection_retries.rb @@ -4,13 +4,13 @@ module ActiveMerchant module NetworkConnectionRetries DEFAULT_RETRIES = 3 DEFAULT_CONNECTION_ERRORS = { - EOFError => "The remote server dropped the connection", - Errno::ECONNRESET => "The remote server reset the connection", - Timeout::Error => "The connection to the remote server timed out", - Errno::ETIMEDOUT => "The connection to the remote server timed out", - SocketError => "The connection to the remote server could not be established", - Errno::EHOSTUNREACH => "The connection to the remote server could not be established", - OpenSSL::SSL::SSLError => "The SSL connection to the remote server could not be established" + EOFError => 'The remote server dropped the connection', + Errno::ECONNRESET => 'The remote server reset the connection', + Timeout::Error => 'The connection to the remote server timed out', + Errno::ETIMEDOUT => 'The connection to the remote server timed out', + SocketError => 'The connection to the remote server could not be established', + Errno::EHOSTUNREACH => 'The connection to the remote server could not be established', + OpenSSL::SSL::SSLError => 'The SSL connection to the remote server could not be established' } def self.included(base) @@ -24,12 +24,12 @@ def retry_exceptions(options={}) begin yield rescue Errno::ECONNREFUSED => e - raise ActiveMerchant::RetriableConnectionError.new("The remote server refused the connection", e) + raise ActiveMerchant::RetriableConnectionError.new('The remote server refused the connection', e) rescue OpenSSL::X509::CertificateError => e NetworkConnectionRetries.log(options[:logger], :error, e.message, options[:tag]) - raise ActiveMerchant::ClientCertificateError, "The remote server did not accept the provided SSL certificate" + raise ActiveMerchant::ClientCertificateError, 'The remote server did not accept the provided SSL certificate' rescue Zlib::BufError => e - raise ActiveMerchant::InvalidResponseError, "The remote server replied with an invalid response" + raise ActiveMerchant::InvalidResponseError, 'The remote server replied with an invalid response' rescue *connection_errors.keys => e raise ActiveMerchant::ConnectionError.new(derived_error_message(connection_errors, e.class), e) end @@ -46,7 +46,7 @@ def retry_network_exceptions(options = {}) begin request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = yield - log_with_retry_details(options[:logger], initial_retries-retries + 1, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, "success", options[:tag]) + log_with_retry_details(options[:logger], initial_retries-retries + 1, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, 'success', options[:tag]) result rescue ActiveMerchant::RetriableConnectionError => e retries -= 1 @@ -70,7 +70,7 @@ def self.log(logger, level, message, tag=nil) private def log_with_retry_details(logger, attempts, time, message, tag) - NetworkConnectionRetries.log(logger, :info, "connection_attempt=%d connection_request_time=%.4fs connection_msg=\"%s\"" % [attempts, time, message], tag) + NetworkConnectionRetries.log(logger, :info, 'connection_attempt=%d connection_request_time=%.4fs connection_msg="%s"' % [attempts, time, message], tag) end def derived_error_message(errors, klass) diff --git a/lib/active_merchant/post_data.rb b/lib/active_merchant/post_data.rb index 192d08e853e..b1c715b0108 100644 --- a/lib/active_merchant/post_data.rb +++ b/lib/active_merchant/post_data.rb @@ -11,7 +11,7 @@ def []=(key, value) end def to_post_data - collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") + collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end alias_method :to_s, :to_post_data diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 199852f1e00..46c298f78d8 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = "1.79.2" + VERSION = '1.79.2' end diff --git a/lib/support/gateway_support.rb b/lib/support/gateway_support.rb index ef649e59adf..29b3fc05a8e 100644 --- a/lib/support/gateway_support.rb +++ b/lib/support/gateway_support.rb @@ -17,7 +17,7 @@ def initialize begin gateway_class = ('ActiveMerchant::Billing::' + gateway_name.camelize).constantize rescue NameError - puts "Could not load gateway " + gateway_name.camelize + " from " + f + "." + puts 'Could not load gateway ' + gateway_name.camelize + ' from ' + f + '.' end end @gateways = Gateway.implementations.sort_by(&:name) @@ -31,7 +31,7 @@ def each_gateway def features width = 15 - print "Name".center(width + 20) + print 'Name'.center(width + 20) ACTIONS.each{|f| print "#{f.to_s.capitalize.center(width)}" } puts diff --git a/lib/support/ssl_verify.rb b/lib/support/ssl_verify.rb index 1ba28878a72..94dbf618695 100644 --- a/lib/support/ssl_verify.rb +++ b/lib/support/ssl_verify.rb @@ -26,13 +26,13 @@ def test_gateways result,message = ssl_verify_peer?(uri) case result when :success - print "." + print '.' success << g when :fail - print "F" + print 'F' failed << {:gateway => g, :message => message} when :error - print "E" + print 'E' errored << {:gateway => g, :message => message} end end @@ -66,7 +66,7 @@ def test_gateways def try_host(http, path) http.get(path) rescue Net::HTTPBadResponse, EOFError, SocketError - http.post(path, "") + http.post(path, '') end def ssl_verify_peer?(uri) @@ -78,7 +78,7 @@ def ssl_verify_peer?(uri) http.read_timeout = 60 if uri.path.blank? - try_host(http, "/") + try_host(http, '/') else try_host(http, uri.path) end diff --git a/lib/support/ssl_version.rb b/lib/support/ssl_version.rb index e45738d7757..ed7c716c9c0 100644 --- a/lib/support/ssl_version.rb +++ b/lib/support/ssl_version.rb @@ -1,5 +1,5 @@ -require "active_merchant" -require "support/gateway_support" +require 'active_merchant' +require 'support/gateway_support' class SSLVersion attr_accessor :success, :failed, :missing, :errored @@ -10,7 +10,7 @@ def initialize end def test_gateways(min_version = :TLS1_1) - raise "Requires Ruby 2.5 or better" unless Net::HTTP.instance_methods.include?(:min_version=) + raise 'Requires Ruby 2.5 or better' unless Net::HTTP.instance_methods.include?(:min_version=) puts "Verifying #{@gateways.count} gateways for SSL min_version=#{min_version}\n\n" @@ -25,13 +25,13 @@ def test_gateways(min_version = :TLS1_1) case result when :success - print "." + print '.' success << g when :fail - print "F" + print 'F' failed << {:gateway => g, :message => message} when :error - print "E" + print 'E' errored << {:gateway => g, :message => message} end end @@ -70,7 +70,7 @@ def test_min_version(uri, min_version) http.open_timeout = 10 http.read_timeout = 10 - http.post("/", "") + http.post('/', '') return :success rescue Net::HTTPBadResponse diff --git a/script/generate b/script/generate index 2988763f103..6312f82aa0c 100755 --- a/script/generate +++ b/script/generate @@ -1,15 +1,15 @@ #!/usr/bin/env ruby -require "rubygems" -require "thor" +require 'rubygems' +require 'thor' -require File.expand_path("../../generators/active_merchant_generator", __FILE__) +require File.expand_path('../../generators/active_merchant_generator', __FILE__) -Dir[File.expand_path("../..", __FILE__) + "/generators/*/*.rb"].each do |generator| +Dir[File.expand_path('../..', __FILE__) + '/generators/*/*.rb'].each do |generator| require generator end class Generate < Thor - register(GatewayGenerator, "gateway", "gateway NAME", "Generates a new gateway.") + register(GatewayGenerator, 'gateway', 'gateway NAME', 'Generates a new gateway.') end Generate.start diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb index 5c23d919776..a5d646f182b 100644 --- a/test/remote/gateways/remote_adyen_test.rb +++ b/test/remote/gateways/remote_adyen_test.rb @@ -18,20 +18,20 @@ def setup @declined_card = credit_card('4000300011112220') @apple_pay_card = network_tokenization_credit_card('4111111111111111', - :payment_cryptogram => "YwAAAAAABaYcCMX/OhNRQAAAAAA=", - :month => "08", - :year => "2018", + :payment_cryptogram => 'YwAAAAAABaYcCMX/OhNRQAAAAAA=', + :month => '08', + :year => '2018', :source => :apple_pay, :verification_value => nil ) @options = { reference: '345123', - shopper_email: "john.smith@test.com", - shopper_ip: "77.110.174.153", - shopper_reference: "John Smith", + shopper_email: 'john.smith@test.com', + shopper_ip: '77.110.174.153', + shopper_reference: 'John Smith', billing_address: address(), - order_id: "123" + order_id: '123' } end @@ -145,7 +145,7 @@ def test_successful_store assert response = @gateway.store(@credit_card, @options) assert_success response - assert !response.authorization.split("#")[2].nil? + assert !response.authorization.split('#')[2].nil? assert_equal 'Authorised', response.message end diff --git a/test/remote/gateways/remote_allied_wallet_test.rb b/test/remote/gateways/remote_allied_wallet_test.rb index 427ef1792f5..8ab761e508b 100644 --- a/test/remote/gateways/remote_allied_wallet_test.rb +++ b/test/remote/gateways/remote_allied_wallet_test.rb @@ -6,7 +6,7 @@ def setup @amount = 100 @credit_card = credit_card - @declined_card = credit_card('4242424242424242', verification_value: "555") + @declined_card = credit_card('4242424242424242', verification_value: '555') @options = { billing_address: address, @@ -16,13 +16,13 @@ def setup def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "The test operation was declined.", response.message + assert_equal 'The test operation was declined.', response.message end def test_failed_purchase_no_address @@ -34,32 +34,32 @@ def test_failed_purchase_no_address def test_successful_purchase_with_more_options response = @gateway.purchase(@amount, @credit_card, @options.merge( order_id: generate_unique_id, - ip: "127.0.0.1", - email: "jim_smith@example.com" + ip: '127.0.0.1', + email: 'jim_smith@example.com' )) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_authorize_and_capture response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert response.authorization capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal "The test operation was declined.", response.message + assert_equal 'The test operation was declined.', response.message end def test_failed_capture - response = @gateway.capture(@amount, "") + response = @gateway.capture(@amount, '') assert_failure response assert_equal "'Authorize Transaction Id' should not be empty.", response.message end @@ -70,11 +70,11 @@ def test_successful_void void = @gateway.void(response.authorization) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end def test_failed_void - response = @gateway.void("") + response = @gateway.void('') assert_failure response assert_equal "'Authorize Transaction Id' should not be empty.", response.message end @@ -85,11 +85,11 @@ def test_successful_refund refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "Succeeded", refund.message + assert_equal 'Succeeded', refund.message end def test_failed_refund - response = @gateway.refund(@amount, "UnknownAuthorization") + response = @gateway.refund(@amount, 'UnknownAuthorization') assert_failure response assert_match(/An internal exception has occurred/, response.message) end @@ -103,7 +103,7 @@ def test_successful_verify def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "The test operation was declined.", response.message + assert_equal 'The test operation was declined.', response.message end def test_transcript_scrubbing @@ -128,7 +128,7 @@ def test_nil_cvv_transcript_scrubbing end def test_empty_string_cvv_transcript_scrubbing - @credit_card.verification_value = "" + @credit_card.verification_value = '' transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) end @@ -138,7 +138,7 @@ def test_empty_string_cvv_transcript_scrubbing end def test_whitespace_string_cvv_transcript_scrubbing - @credit_card.verification_value = " " + @credit_card.verification_value = ' ' transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) end diff --git a/test/remote/gateways/remote_authorize_net_apple_pay_test.rb b/test/remote/gateways/remote_authorize_net_apple_pay_test.rb index 94c867b8009..6b8a632743f 100644 --- a/test/remote/gateways/remote_authorize_net_apple_pay_test.rb +++ b/test/remote/gateways/remote_authorize_net_apple_pay_test.rb @@ -78,9 +78,9 @@ def apple_pay_payment_token(options = {}) }, 'signature' => 'MIIDQgYJKoZIhvcNAQcCoIIDMzCCAy8CAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCCAiswggInMIIBlKADAgECAhBcl+Pf3+U4pk13nVD9nwQQMAkGBSsOAwIdBQAwJzElMCMGA1UEAx4cAGMAaABtAGEAaQBAAHYAaQBzAGEALgBjAG8AbTAeFw0xNDAxMDEwNjAwMDBaFw0yNDAxMDEwNjAwMDBaMCcxJTAjBgNVBAMeHABjAGgAbQBhAGkAQAB2AGkAcwBhAC4AYwBvAG0wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANC8+kgtgmvWF1OzjgDNrjTEBRuo/5MKvlM146pAf7Gx41blE9w4fIXJAD7FfO7QKjIXYNt39rLyy7xDwb/5IkZM60TZ2iI1pj55Uc8fd4fzOpk3ftZaQGXNLYptG1d9V7IS82Oup9MMo1BPVrXTPHNcsM99EPUnPqdbeGc87m0rAgMBAAGjXDBaMFgGA1UdAQRRME+AEHZWPrWtJd7YZ431hCg7YFShKTAnMSUwIwYDVQQDHhwAYwBoAG0AYQBpAEAAdgBpAHMAYQAuAGMAbwBtghBcl+Pf3+U4pk13nVD9nwQQMAkGBSsOAwIdBQADgYEAbUKYCkuIKS9QQ2mFcMYREIm2l+Xg8/JXv+GBVQJkOKoscY4iNDFA/bQlogf9LLU84THwNRnsvV3Prv7RTY81gq0dtC8zYcAaAkCHII3yqMnJ4AOu6EOW9kJk232gSE7WlCtHbfLSKfuSgQX8KXQYuZLk2Rr63N8ApXsXwBL3cJ0xgeAwgd0CAQEwOzAnMSUwIwYDVQQDHhwAYwBoAG0AYQBpAEAAdgBpAHMAYQAuAGMAbwBtAhBcl+Pf3+U4pk13nVD9nwQQMAkGBSsOAwIaBQAwDQYJKoZIhvcNAQEBBQAEgYBaK3ElOstbH8WooseDABf+Jg/129JcIawm7c6Vxn7ZasNbAq3tAt8Pty+uQCgssXqZkLA7kz2GzMolNtv9wYmu9Ujwar1PHYS+B/oGnoz591wjagXWRz0nMo5y3O1KzX0d8CRHAVa88SrV1a5JIiRev3oStIqwv5xuZldag6Tr8w==' }, - payment_instrument_name: "SomeBank Points Card", - payment_network: "MasterCard", - transaction_identifier: "uniqueidentifier123" + payment_instrument_name: 'SomeBank Points Card', + payment_network: 'MasterCard', + transaction_identifier: 'uniqueidentifier123' }.update(options) ActiveMerchant::Billing::ApplePayPaymentToken.new(defaults[:payment_data], diff --git a/test/remote/gateways/remote_authorize_net_cim_test.rb b/test/remote/gateways/remote_authorize_net_cim_test.rb index 8ffd06d7996..8f7f000b54a 100644 --- a/test/remote/gateways/remote_authorize_net_cim_test.rb +++ b/test/remote/gateways/remote_authorize_net_cim_test.rb @@ -102,8 +102,8 @@ def test_successful_create_customer_profile_transaction_auth_only_and_then_captu assert_equal response.authorization, response.params['direct_response']['transaction_id'] assert_match %r{(?:(TESTMODE) )?This transaction has been approved.}, response.params['direct_response']['message'] assert response.params['direct_response']['approval_code'] =~ /\w{6}/ - assert_equal "auth_only", response.params['direct_response']['transaction_type'] - assert_equal "100.00", response.params['direct_response']['amount'] + assert_equal 'auth_only', response.params['direct_response']['transaction_type'] + assert_equal '100.00', response.params['direct_response']['amount'] assert_match %r{\d+}, response.params['direct_response']['transaction_id'] approval_code = response.params['direct_response']['approval_code'] @@ -125,8 +125,8 @@ def test_successful_create_customer_profile_transaction_auth_only_and_then_captu assert_equal response.authorization, response.params['direct_response']['transaction_id'] assert_match %r{(?:(TESTMODE) )?This transaction has been approved.}, response.params['direct_response']['message'] assert_equal approval_code, response.params['direct_response']['approval_code'] - assert_equal "capture_only", response.params['direct_response']['transaction_type'] - assert_equal "100.00", response.params['direct_response']['amount'] + assert_equal 'capture_only', response.params['direct_response']['transaction_type'] + assert_equal '100.00', response.params['direct_response']['amount'] end def test_successful_create_customer_profile_transaction_auth_capture_request @@ -157,8 +157,8 @@ def test_successful_create_customer_profile_transaction_auth_capture_request assert_equal response.authorization, response.params['direct_response']['transaction_id'] assert_match %r{(?:(TESTMODE) )?This transaction has been approved.}, response.params['direct_response']['message'] assert response.params['direct_response']['approval_code'] =~ /\w{6}/ - assert_equal "auth_capture", response.params['direct_response']['transaction_type'] - assert_equal "100.00", response.params['direct_response']['amount'] + assert_equal 'auth_capture', response.params['direct_response']['transaction_type'] + assert_equal '100.00', response.params['direct_response']['amount'] assert_equal response.params['direct_response']['invoice_number'], '1234' assert_equal response.params['direct_response']['order_description'], 'Test Order Description' assert_equal response.params['direct_response']['purchase_order_number'], '4321' @@ -391,7 +391,7 @@ def test_successful_update_customer_payment_profile_request ) # The value before updating - assert_equal "XXXX4242", response.params['payment_profile']['payment']['credit_card']['card_number'], "The card number should contain the last 4 digits of the card we passed in 4242" + assert_equal 'XXXX4242', response.params['payment_profile']['payment']['credit_card']['card_number'], 'The card number should contain the last 4 digits of the card we passed in 4242' # Update the payment profile assert response = @gateway.update_customer_payment_profile( @@ -414,7 +414,7 @@ def test_successful_update_customer_payment_profile_request ) # Show that the payment profile was updated - assert_equal "XXXX1234", response.params['payment_profile']['payment']['credit_card']['card_number'], "The card number should contain the last 4 digits of the card we passed in: 1234" + assert_equal 'XXXX1234', response.params['payment_profile']['payment']['credit_card']['card_number'], 'The card number should contain the last 4 digits of the card we passed in: 1234' # Show that fields that were left out of the update were cleared assert_nil response.params['payment_profile']['customer_type'] @@ -441,7 +441,7 @@ def test_successful_update_customer_payment_profile_request ) # Show that the billing address on the payment profile was updated - assert_equal "Frank", response.params['payment_profile']['bill_to']['first_name'], "The billing address should contain the first name we passed in: Frank" + assert_equal 'Frank', response.params['payment_profile']['bill_to']['first_name'], 'The billing address should contain the first name we passed in: Frank' end def test_successful_update_customer_payment_profile_request_with_credit_card_last_four @@ -460,13 +460,13 @@ def test_successful_update_customer_payment_profile_request_with_credit_card_las ) # Card number last 4 digits is 4242 - assert_equal "XXXX4242", response.params['payment_profile']['payment']['credit_card']['card_number'], "The card number should contain the last 4 digits of the card we passed in 4242" + assert_equal 'XXXX4242', response.params['payment_profile']['payment']['credit_card']['card_number'], 'The card number should contain the last 4 digits of the card we passed in 4242' new_billing_address = response.params['payment_profile']['bill_to'] new_billing_address.update(:first_name => 'Frank', :last_name => 'Brown') # Initialize credit card with only last 4 digits as the number - last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => "4242") #Credit card with only last four digits + last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => '4242') #Credit card with only last four digits # Update only the billing address with a card with the last 4 digits and expiration date assert response = @gateway.update_customer_payment_profile( @@ -487,7 +487,7 @@ def test_successful_update_customer_payment_profile_request_with_credit_card_las ) # Show that the billing address on the payment profile was updated - assert_equal "Frank", response.params['payment_profile']['bill_to']['first_name'], "The billing address should contain the first name we passed in: Frank" + assert_equal 'Frank', response.params['payment_profile']['bill_to']['first_name'], 'The billing address should contain the first name we passed in: Frank' end def test_successful_update_customer_shipping_address_request @@ -507,7 +507,7 @@ def test_successful_update_customer_shipping_address_request assert address = response.params['address'] # The value before updating - assert_equal "1234 Fake Street", address['address'] + assert_equal '1234 Fake Street', address['address'] # Update the address and remove the phone_number new_address = address.symbolize_keys.merge!( @@ -531,7 +531,7 @@ def test_successful_update_customer_shipping_address_request ) # Show that the shipping address was updated - assert_equal "5678 Fake Street", response.params['address']['address'] + assert_equal '5678 Fake Street', response.params['address']['address'] # Show that fields that were left out of the update were cleared assert_nil response.params['address']['phone_number'] end @@ -575,7 +575,7 @@ def test_validate_customer_payment_profile_request_live_requires_billing_address assert response.test? assert_failure response - assert_equal "There is one or more missing or invalid required fields.", response.message + assert_equal 'There is one or more missing or invalid required fields.', response.message end def test_validate_customer_payment_profile_request_old_does_not_require_billing_address @@ -596,7 +596,7 @@ def test_validate_customer_payment_profile_request_old_does_not_require_billing_ assert response.test? assert_success response - assert_equal "Successful.", response.message + assert_equal 'Successful.', response.message end def test_should_create_duplicate_customer_profile_transactions_with_duplicate_window_alteration @@ -620,18 +620,18 @@ def test_should_create_duplicate_customer_profile_transactions_with_duplicate_wi }, :amount => @amount }, - :extra_options => { "x_duplicate_window" => 1 } + :extra_options => { 'x_duplicate_window' => 1 } } assert response = @gateway.create_customer_profile_transaction(customer_profile_transaction) assert_success response - assert_equal "Successful.", response.message + assert_equal 'Successful.', response.message sleep(5) assert response = @gateway.create_customer_profile_transaction(customer_profile_transaction) assert_success response - assert_equal "Successful.", response.message + assert_equal 'Successful.', response.message assert_nil response.error_code end @@ -660,14 +660,14 @@ def test_should_not_create_duplicate_customer_profile_transactions_without_dupli assert response = @gateway.create_customer_profile_transaction(customer_profile_transaction) assert_success response - assert_equal "Successful.", response.message + assert_equal 'Successful.', response.message sleep(5) assert response = @gateway.create_customer_profile_transaction(customer_profile_transaction) assert_failure response - assert_equal "A duplicate transaction has been submitted.", response.message - assert_equal "E00027", response.error_code + assert_equal 'A duplicate transaction has been submitted.', response.message + assert_equal 'E00027', response.error_code end def test_should_create_customer_profile_transaction_auth_capture_and_then_void_request @@ -833,8 +833,8 @@ def get_and_validate_auth_capture_response assert_equal response.authorization, response.params['direct_response']['transaction_id'] assert_match %r{(?:(TESTMODE) )?This transaction has been approved.}, response.params['direct_response']['message'] assert response.params['direct_response']['approval_code'] =~ /\w{6}/ - assert_equal "auth_capture", response.params['direct_response']['transaction_type'] - assert_equal "100.00", response.params['direct_response']['amount'] + assert_equal 'auth_capture', response.params['direct_response']['transaction_type'] + assert_equal '100.00', response.params['direct_response']['amount'] assert_equal response.params['direct_response']['invoice_number'], key.to_s assert_equal response.params['direct_response']['order_description'], "Test Order Description #{key.to_s}" assert_equal response.params['direct_response']['purchase_order_number'], key.to_s @@ -867,8 +867,8 @@ def get_and_validate_auth_only_response assert_success response assert_equal response.authorization, response.params['direct_response']['transaction_id'] assert response.params['direct_response']['approval_code'] =~ /\w{6}/ - assert_equal "auth_only", response.params['direct_response']['transaction_type'] - assert_equal "100.00", response.params['direct_response']['amount'] + assert_equal 'auth_only', response.params['direct_response']['transaction_type'] + assert_equal '100.00', response.params['direct_response']['amount'] return response end diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb index 24e4e4a8769..af48e65a4b5 100644 --- a/test/remote/gateways/remote_authorize_net_test.rb +++ b/test/remote/gateways/remote_authorize_net_test.rb @@ -19,22 +19,22 @@ def setup @level_2_options = { tax: { - amount: "100", - name: "tax name", - description: "tax description" + amount: '100', + name: 'tax name', + description: 'tax description' }, duty: { - amount: "200", - name: "duty name", - description: "duty description" + amount: '200', + name: 'duty name', + description: 'duty description' }, shipping: { - amount: "300", - name: "shipping name", - description: "shipping description", + amount: '300', + name: 'shipping name', + description: 'shipping description', }, - tax_exempt: "false", - po_number: "123" + tax_exempt: 'false', + po_number: '123' } end @@ -71,7 +71,7 @@ def test_successful_purchase_with_false_email_customer end def test_successful_purchase_with_header_email_receipt - response = @gateway.purchase(@amount, @credit_card, duplicate_window: 0, header_email_receipt: "subject line", email: 'anet@example.com', billing_address: address) + response = @gateway.purchase(@amount, @credit_card, duplicate_window: 0, header_email_receipt: 'subject line', email: 'anet@example.com', billing_address: address) assert_success response assert response.test? assert_equal 'This transaction has been approved', response.message @@ -80,21 +80,21 @@ def test_successful_purchase_with_header_email_receipt def test_successful_purchase_with_line_items additional_options = { - email: "anet@example.com", + email: 'anet@example.com', line_items: [ { - item_id: "1", - name: "mug", - description: "coffee", - quantity: "100", - unit_price: "10" + item_id: '1', + name: 'mug', + description: 'coffee', + quantity: '100', + unit_price: '10' }, { - item_id: "2", - name: "vase", - description: "floral", - quantity: "200", - unit_price: "20" + item_id: '2', + name: 'vase', + description: 'floral', + quantity: '200', + unit_price: '20' } ] } @@ -112,7 +112,7 @@ def test_successful_purchase_with_level_2_data end def test_successful_purchase_with_customer - response = @gateway.purchase(@amount, @credit_card, @options.merge(customer: "abcd_123")) + response = @gateway.purchase(@amount, @credit_card, @options.merge(customer: 'abcd_123')) assert_success response assert_equal 'This transaction has been approved', response.message end @@ -205,7 +205,7 @@ def test_successful_echeck_authorization end def test_failed_echeck_authorization - response = @gateway.authorize(@amount, check(routing_number: "121042883"), @options) + response = @gateway.authorize(@amount, check(routing_number: '121042883'), @options) assert_failure response assert_equal 'The ABA code is invalid', response.message assert response.authorization @@ -260,8 +260,8 @@ def test_successful_authorization_with_moto_retail_type def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "This transaction has been approved", response.message - assert_success response.responses.last, "The void should succeed" + assert_equal 'This transaction has been approved', response.message + assert_success response.responses.last, 'The void should succeed' end def test_failed_verify @@ -275,8 +275,8 @@ def test_successful_store assert response = @gateway.store(@credit_card) assert_success response assert response.authorization - assert_equal "Successful", response.message - assert_equal "1", response.params["message_code"] + assert_equal 'Successful', response.message + assert_equal '1', response.params['message_code'] end def test_successful_store_new_payment_profile @@ -285,12 +285,12 @@ def test_successful_store_new_payment_profile assert store.authorization new_card = credit_card('4424222222222222') - customer_profile_id, _, _ = store.authorization.split("#") + customer_profile_id, _, _ = store.authorization.split('#') assert response = @gateway.store(new_card, customer_profile_id: customer_profile_id) assert_success response - assert_equal "Successful", response.message - assert_equal "1", response.params["message_code"] + assert_equal 'Successful', response.message + assert_equal '1', response.params['message_code'] end def test_failed_store_new_payment_profile @@ -299,18 +299,18 @@ def test_failed_store_new_payment_profile assert store.authorization new_card = credit_card('141241') - customer_profile_id, _, _ = store.authorization.split("#") + customer_profile_id, _, _ = store.authorization.split('#') assert response = @gateway.store(new_card, customer_profile_id: customer_profile_id) assert_failure response - assert_equal "The field length is invalid for Card Number", response.message + assert_equal 'The field length is invalid for Card Number', response.message end def test_failed_store - assert response = @gateway.store(credit_card("141241")) + assert response = @gateway.store(credit_card('141241')) assert_failure response - assert_equal "The field length is invalid for Card Number", response.message - assert_equal "15", response.params["message_code"] + assert_equal 'The field length is invalid for Card Number', response.message + assert_equal '15', response.params['message_code'] end def test_successful_purchase_using_stored_card @@ -319,7 +319,7 @@ def test_successful_purchase_using_stored_card response = @gateway.purchase(@amount, response.authorization, @options) assert_success response - assert_equal "This transaction has been approved.", response.message + assert_equal 'This transaction has been approved.', response.message end def test_failed_purchase_using_stored_card @@ -328,11 +328,11 @@ def test_failed_purchase_using_stored_card response = @gateway.purchase(@amount, response.authorization, @options) assert_failure response - assert_equal "The credit card number is invalid.", response.message - assert_equal "incorrect_number", response.error_code - assert_equal "27", response.params["message_code"] - assert_equal "6", response.params["response_reason_code"] - assert_match %r{Address not verified}, response.avs_result["message"] + assert_equal 'The credit card number is invalid.', response.message + assert_equal 'incorrect_number', response.error_code + assert_equal '27', response.params['message_code'] + assert_equal '6', response.params['response_reason_code'] + assert_match %r{Address not verified}, response.avs_result['message'] end def test_successful_purchase_using_stored_card_new_payment_profile @@ -341,14 +341,14 @@ def test_successful_purchase_using_stored_card_new_payment_profile assert store.authorization new_card = credit_card('4007000000027') - customer_profile_id, _, _ = store.authorization.split("#") + customer_profile_id, _, _ = store.authorization.split('#') assert response = @gateway.store(new_card, customer_profile_id: customer_profile_id, email: 'anet@example.com', billing_address: address) assert_success response response = @gateway.purchase(@amount, response.authorization, @options) assert_success response - assert_equal "This transaction has been approved.", response.message + assert_equal 'This transaction has been approved.', response.message end def test_successful_purchase_with_stored_card_and_level_2_data @@ -366,11 +366,11 @@ def test_successful_authorize_and_capture_using_stored_card auth = @gateway.authorize(@amount, store.authorization, @options) assert_success auth - assert_equal "This transaction has been approved.", auth.message + assert_equal 'This transaction has been approved.', auth.message capture = @gateway.capture(@amount, auth.authorization, @options) assert_success capture - assert_equal "This transaction has been approved.", capture.message + assert_equal 'This transaction has been approved.', capture.message end def test_successful_authorize_and_capture_using_stored_card_with_level_2_data @@ -379,11 +379,11 @@ def test_successful_authorize_and_capture_using_stored_card_with_level_2_data auth = @gateway.authorize(@amount, store.authorization, @options.merge(@level_2_options)) assert_success auth - assert_equal "This transaction has been approved.", auth.message + assert_equal 'This transaction has been approved.', auth.message capture = @gateway.capture(@amount, auth.authorization, @options.merge(@level_2_options)) assert_success capture - assert_equal "This transaction has been approved.", capture.message + assert_equal 'This transaction has been approved.', capture.message end def test_failed_authorize_using_stored_card @@ -393,11 +393,11 @@ def test_failed_authorize_using_stored_card response = @gateway.authorize(@amount, response.authorization, @options) assert_failure response - assert_equal "The credit card number is invalid.", response.message - assert_equal "incorrect_number", response.error_code - assert_equal "27", response.params["message_code"] - assert_equal "6", response.params["response_reason_code"] - assert_match %r{Address not verified}, response.avs_result["message"] + assert_equal 'The credit card number is invalid.', response.message + assert_equal 'incorrect_number', response.error_code + assert_equal '27', response.params['message_code'] + assert_equal '6', response.params['response_reason_code'] + assert_match %r{Address not verified}, response.avs_result['message'] end def test_failed_authorize_using_wrong_token @@ -431,7 +431,7 @@ def test_faux_successful_refund_with_billing_address refund = @gateway.refund(@amount, purchase.authorization, @options.merge(first_name: 'Jim', last_name: 'Smith')) assert_failure refund - assert_match %r{does not meet the criteria for issuing a credit}, refund.message, "Only allowed to refund transactions that have settled. This is the best we can do for now testing wise." + assert_match %r{does not meet the criteria for issuing a credit}, refund.message, 'Only allowed to refund transactions that have settled. This is the best we can do for now testing wise.' end def test_faux_successful_refund_without_billing_address @@ -442,7 +442,7 @@ def test_faux_successful_refund_without_billing_address refund = @gateway.refund(@amount, purchase.authorization, @options.merge(first_name: 'Jim', last_name: 'Smith')) assert_failure refund - assert_match %r{does not meet the criteria for issuing a credit}, refund.message, "Only allowed to refund transactions that have settled. This is the best we can do for now testing wise." + assert_match %r{does not meet the criteria for issuing a credit}, refund.message, 'Only allowed to refund transactions that have settled. This is the best we can do for now testing wise.' end def test_faux_successful_refund_using_stored_card @@ -454,7 +454,7 @@ def test_faux_successful_refund_using_stored_card refund = @gateway.refund(@amount, purchase.authorization, @options) assert_failure refund - assert_match %r{does not meet the criteria for issuing a credit}, refund.message, "Only allowed to refund transactions that have settled. This is the best we can do for now testing wise." + assert_match %r{does not meet the criteria for issuing a credit}, refund.message, 'Only allowed to refund transactions that have settled. This is the best we can do for now testing wise.' end def test_faux_successful_refund_using_stored_card_and_level_2_data @@ -466,7 +466,7 @@ def test_faux_successful_refund_using_stored_card_and_level_2_data refund = @gateway.refund(@amount, purchase.authorization, @options.merge(@level_2_options)) assert_failure refund - assert_match %r{does not meet the criteria for issuing a credit}, refund.message, "Only allowed to refund transactions that have settled. This is the best we can do for now testing wise." + assert_match %r{does not meet the criteria for issuing a credit}, refund.message, 'Only allowed to refund transactions that have settled. This is the best we can do for now testing wise.' end def test_failed_refund_using_stored_card @@ -476,10 +476,10 @@ def test_failed_refund_using_stored_card purchase = @gateway.purchase(@amount, store.authorization, @options) assert_success purchase - unknown_authorization = "2235494048#XXXX2224#cim_purchase" + unknown_authorization = '2235494048#XXXX2224#cim_purchase' refund = @gateway.refund(@amount, unknown_authorization, @options) assert_failure refund - assert_equal "The record cannot be found", refund.message + assert_equal 'The record cannot be found', refund.message end def test_successful_void_using_stored_card @@ -491,7 +491,7 @@ def test_successful_void_using_stored_card void = @gateway.void(auth.authorization, @options) assert_success void - assert_equal "This transaction has been approved.", void.message + assert_equal 'This transaction has been approved.', void.message end def test_failed_void_using_stored_card @@ -506,7 +506,7 @@ def test_failed_void_using_stored_card another_void = @gateway.void(auth.authorization, @options) assert_failure another_void - assert_equal "This transaction has already been voided.", another_void.message + assert_equal 'This transaction has already been voided.', another_void.message end def test_bad_login @@ -532,7 +532,7 @@ def test_bad_login transaction_id ), response.params.keys.sort - assert_equal "User authentication failed due to invalid authentication values", response.message + assert_equal 'User authentication failed due to invalid authentication values', response.message end def test_partial_capture @@ -597,7 +597,7 @@ def test_successful_echeck_refund @options.update(transaction_id: purchase.params['transaction_id'], test_request: true) refund = @gateway.credit(@amount, @check, @options) assert_failure refund - assert_match %r{The transaction cannot be found}, refund.message, "Only allowed to refund transactions that have settled. This is the best we can do for now testing wise." + assert_match %r{The transaction cannot be found}, refund.message, 'Only allowed to refund transactions that have settled. This is the best we can do for now testing wise.' end def test_failed_credit @@ -608,13 +608,13 @@ def test_failed_credit end def test_bad_currency - response = @gateway.purchase(@amount, @credit_card, currency: "XYZ") + response = @gateway.purchase(@amount, @credit_card, currency: 'XYZ') assert_failure response assert_equal 'The supplied currency code is either invalid, not supported, not allowed for this merchant or doesn\'t have an exchange rate', response.message end def test_usd_currency - @options[:currency] = "USD" + @options[:currency] = 'USD' response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert response.authorization @@ -626,7 +626,7 @@ def test_dump_transcript def test_successful_authorize_and_capture_with_network_tokenization credit_card = network_tokenization_credit_card('4000100011112224', - payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', verification_value: nil ) auth = @gateway.authorize(@amount, credit_card, @options) @@ -639,7 +639,7 @@ def test_successful_authorize_and_capture_with_network_tokenization def test_successful_refund_with_network_tokenization credit_card = network_tokenization_credit_card('4000100011112224', - payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', verification_value: nil ) @@ -650,12 +650,12 @@ def test_successful_refund_with_network_tokenization refund = @gateway.refund(@amount, purchase.authorization, @options.merge(first_name: 'Jim', last_name: 'Smith')) assert_failure refund - assert_match %r{does not meet the criteria for issuing a credit}, refund.message, "Only allowed to refund transactions that have settled. This is the best we can do for now testing wise." + assert_match %r{does not meet the criteria for issuing a credit}, refund.message, 'Only allowed to refund transactions that have settled. This is the best we can do for now testing wise.' end def test_successful_credit_with_network_tokenization credit_card = network_tokenization_credit_card('4000100011112224', - payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', verification_value: nil ) @@ -668,8 +668,8 @@ def test_successful_credit_with_network_tokenization def test_network_tokenization_transcript_scrubbing credit_card = network_tokenization_credit_card('4111111111111111', :brand => 'visa', - :eci => "05", - :payment_cryptogram => "EHuWW9PiBkWvqE5juRwDzAUFBAk=" + :eci => '05', + :payment_cryptogram => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=' ) transcript = capture_transcript(@gateway) do @@ -696,7 +696,7 @@ def test_purchase_scrubbing def test_verify_credentials assert @gateway.verify_credentials - gateway = AuthorizeNetGateway.new(login: "unknown_login", password: "not_right") + gateway = AuthorizeNetGateway.new(login: 'unknown_login', password: 'not_right') assert !gateway.verify_credentials end diff --git a/test/remote/gateways/remote_axcessms_test.rb b/test/remote/gateways/remote_axcessms_test.rb index 205f828b4b0..54b1c82213a 100644 --- a/test/remote/gateways/remote_axcessms_test.rb +++ b/test/remote/gateways/remote_axcessms_test.rb @@ -5,15 +5,15 @@ def setup @gateway = AxcessmsGateway.new(fixtures(:axcessms)) @amount = 1500 - @credit_card = credit_card("4200000000000000", month: 05, year: 2022) - @declined_card = credit_card("4444444444444444", month: 05, year: 2022) - @mode = "CONNECTOR_TEST" + @credit_card = credit_card('4200000000000000', month: 05, year: 2022) + @declined_card = credit_card('4444444444444444', month: 05, year: 2022) + @mode = 'CONNECTOR_TEST' @options = { order_id: generate_unique_id, - email: "customer@example.com", + email: 'customer@example.com', description: "Order Number #{Time.now.to_f.divmod(2473)[1]}", - ip: "0.0.0.0", + ip: '0.0.0.0', mode: @mode, billing_address: address } @@ -21,37 +21,37 @@ def setup def test_successful_authorization auth = @gateway.authorize(@amount, @credit_card, @options) - assert_success auth, "Authorize failed" + assert_success auth, 'Authorize failed' assert_match %r{Successful Processing - Request successfully processed}, auth.message end def test_successful_authorize_and_capture auth = @gateway.authorize(@amount, @credit_card, @options) - assert_success auth, "Authorize failed" + assert_success auth, 'Authorize failed' assert_match %r{Successful Processing - Request successfully processed}, auth.message assert capture = @gateway.capture(@amount, auth.authorization, {mode: @mode}) - assert_success capture, "Capture failed" + assert_success capture, 'Capture failed' assert_match %r{Successful Processing - Request successfully processed}, capture.message end def test_successful_authorize_and_partial_capture auth = @gateway.authorize(@amount, @credit_card, @options) - assert_success auth, "Authorize failed" + assert_success auth, 'Authorize failed' assert_match %r{Successful Processing - Request successfully processed}, auth.message assert capture = @gateway.capture(@amount-30, auth.authorization, {mode: @mode}) - assert_success capture, "Capture failed" + assert_success capture, 'Capture failed' assert_match %r{Successful Processing - Request successfully processed}, capture.message end def test_successful_authorize_and_void auth = @gateway.authorize(@amount, @credit_card, @options) - assert_success auth, "Authorize failed" + assert_success auth, 'Authorize failed' assert_match %r{Successful Processing - Request successfully processed}, auth.message assert void = @gateway.void(auth.authorization, {mode: @mode}) - assert_success void, "Void failed" + assert_success void, 'Void failed' assert_match %r{Successful Processing - Request successfully processed}, void.message end @@ -79,44 +79,44 @@ def test_successful_reference_purchase def test_successful_purchase_and_refund purchase = @gateway.purchase(@amount, @credit_card, @options) - assert_success purchase, "Purchase failed" + assert_success purchase, 'Purchase failed' assert_match %r{Successful Processing - Request successfully processed}, purchase.message assert refund = @gateway.refund(@amount, purchase.authorization, {mode: @mode}) - assert_success refund, "Refund failed" + assert_success refund, 'Refund failed' assert_match %r{Successful Processing - Request successfully processed}, refund.message end def test_successful_purchase_and_partial_refund purchase = @gateway.purchase(@amount, @credit_card, @options) - assert_success purchase, "Purchase failed" + assert_success purchase, 'Purchase failed' assert_match %r{Successful Processing - Request successfully processed}, purchase.message assert refund = @gateway.refund(@amount-50, purchase.authorization, {mode: @mode}) - assert_success refund, "Refund failed" + assert_success refund, 'Refund failed' assert_match %r{Successful Processing - Request successfully processed}, refund.message end # Failure tested def test_utf8_description_does_not_blow_up - assert response = @gateway.purchase(@amount, @credit_card, @options.merge(description: "Habitación")) + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(description: 'Habitación')) assert_success response assert_match %r{Successful Processing - Request successfully processed}, response.message end def test_failed_capture - assert capture = @gateway.capture(@amount, "invalid authorization") + assert capture = @gateway.capture(@amount, 'invalid authorization') assert_failure capture assert_match %r{Reference Error - capture}, capture.message end def test_failed_bigger_capture_then_authorised auth = @gateway.authorize(@amount, @credit_card, @options) - assert_success auth, "Authorize failed" + assert_success auth, 'Authorize failed' assert capture = @gateway.capture(@amount+30, auth.authorization, {mode: @mode}) - assert_failure capture, "Capture failed" + assert_failure capture, 'Capture failed' assert_match %r{PA value exceeded}, capture.message end @@ -127,27 +127,27 @@ def test_failed_authorize end def test_failed_refund - assert refund = @gateway.refund(@amount, "invalid authorization", {mode: @mode}) + assert refund = @gateway.refund(@amount, 'invalid authorization', {mode: @mode}) assert_failure refund assert_match %r{Configuration Validation - Invalid payment data}, refund.message end def test_failed_void - void = @gateway.void("invalid authorization", {mode: @mode}) + void = @gateway.void('invalid authorization', {mode: @mode}) assert_failure void assert_match %r{Reference Error - reversal}, void.message end def test_unauthorized_capture - assert response = @gateway.capture(@amount, "1234567890123456789012") + assert response = @gateway.capture(@amount, '1234567890123456789012') assert_failure response - assert_equal "Reference Error - capture needs at least one successful transaction of type (PA)", response.message + assert_equal 'Reference Error - capture needs at least one successful transaction of type (PA)', response.message end def test_unauthorized_purchase_by_reference - assert response = @gateway.purchase(@amount, "1234567890123456789012") + assert response = @gateway.purchase(@amount, '1234567890123456789012') assert_failure response - assert_equal "Reference Error - reference id not existing", response.message + assert_equal 'Reference Error - reference id not existing', response.message end def test_failed_purchase_by_card @@ -157,7 +157,7 @@ def test_failed_purchase_by_card end def test_invalid_login - credentials = fixtures(:axcessms).merge(password: "invalid") + credentials = fixtures(:axcessms).merge(password: 'invalid') response = AxcessmsGateway.new(credentials).purchase(@amount, @credit_card, @options) assert_failure response end @@ -166,7 +166,7 @@ def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response assert_match %r{success}i, response.message - assert_success response.responses.last, "The void should succeed" + assert_success response.responses.last, 'The void should succeed' end def test_failed_verify diff --git a/test/remote/gateways/remote_balanced_test.rb b/test/remote/gateways/remote_balanced_test.rb index f253b666811..d5930116419 100644 --- a/test/remote/gateways/remote_balanced_test.rb +++ b/test/remote/gateways/remote_balanced_test.rb @@ -19,7 +19,7 @@ def setup def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message assert_equal @amount, response.params['debits'][0]['amount'] end @@ -27,7 +27,7 @@ def test_successful_purchase_with_outside_token outside_token = @gateway.store(@credit_card).params['cards'][0]['href'] response = @gateway.purchase(@amount, outside_token, @options) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message assert_equal @amount, response.params['debits'][0]['amount'] end @@ -44,19 +44,19 @@ def test_unsuccessful_purchase end def test_passing_appears_on_statement - options = @options.merge(appears_on_statement_as: "Homer Electric") + options = @options.merge(appears_on_statement_as: 'Homer Electric') response = @gateway.purchase(@amount, @credit_card, options) assert_success response - assert_equal "BAL*Homer Electric", response.params['debits'][0]['appears_on_statement_as'] + assert_equal 'BAL*Homer Electric', response.params['debits'][0]['appears_on_statement_as'] end def test_passing_meta - options = @options.merge(meta: { "order_number" => '12345' }) + options = @options.merge(meta: { 'order_number' => '12345' }) response = @gateway.purchase(@amount, @credit_card, options) assert_success response - assert_equal options[:meta], response.params["debits"][0]["meta"] + assert_equal options[:meta], response.params['debits'][0]['meta'] end def test_authorize_and_capture @@ -90,7 +90,7 @@ def test_void_authorization assert void = @gateway.void(authorize.authorization) assert_success void - assert void.params["card_holds"][0]['voided_at'], void.inspect + assert void.params['card_holds'][0]['voided_at'], void.inspect end def test_voiding_a_capture_not_allowed diff --git a/test/remote/gateways/remote_banwire_test.rb b/test/remote/gateways/remote_banwire_test.rb index b7319efd349..2f908d3ea9f 100644 --- a/test/remote/gateways/remote_banwire_test.rb +++ b/test/remote/gateways/remote_banwire_test.rb @@ -28,7 +28,7 @@ def test_successful_visa_purchase def test_successful_purchase_with_extra_options options = { order_id: '1', - email: "test@email.com", + email: 'test@email.com', billing_address: address, description: 'Store Purchase' } diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index 3a4e9249b5b..104808183d1 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -249,14 +249,14 @@ def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Authorised", response.message + assert_equal 'Authorised', response.message assert response.authorization end def test_unsuccessful_verify assert response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "Refused", response.message + assert_equal 'Refused', response.message end def test_invalid_login @@ -272,13 +272,13 @@ def test_invalid_login def test_successful_store response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message end def test_failed_store response = @gateway.store(credit_card('', :month => '', :year => '', :verification_value => ''), @options) assert_failure response - assert_equal "Unprocessable Entity", response.message + assert_equal 'Unprocessable Entity', response.message end # AVS must be enabled on the gateway's end for the test account used diff --git a/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb b/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb index 01c575ce95d..5996436a96a 100644 --- a/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb +++ b/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb @@ -6,7 +6,7 @@ def setup @gateway = BarclaysEpdqExtraPlusGateway.new(fixtures(:barclays_epdq_extra_plus)) @amount = 100 @credit_card = credit_card('4000100011112224', :verification_value => '987') - @mastercard = credit_card('5399999999999999', :brand => "mastercard") + @mastercard = credit_card('5399999999999999', :brand => 'mastercard') @declined_card = credit_card('1111111111111111') @credit_card_d3d = credit_card('4000000000000002', :verification_value => '111') @options = { @@ -21,7 +21,7 @@ def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal BarclaysEpdqExtraPlusGateway::SUCCESS_MESSAGE, response.message - assert_equal @options[:currency], response.params["currency"] + assert_equal @options[:currency], response.params['currency'] assert_equal @options[:order_id], response.order_id end @@ -31,18 +31,18 @@ def test_successful_purchase_with_minimal_info assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal BarclaysEpdqExtraPlusGateway::SUCCESS_MESSAGE, response.message - assert_equal @options[:currency], response.params["currency"] + assert_equal @options[:currency], response.params['currency'] assert_equal @options[:order_id], response.order_id end def test_successful_purchase_with_utf8_encoding_1 - assert response = @gateway.purchase(@amount, credit_card('4000100011112224', :first_name => "Rémy", :last_name => "Fröåïør"), @options) + assert response = @gateway.purchase(@amount, credit_card('4000100011112224', :first_name => 'Rémy', :last_name => 'Fröåïør'), @options) assert_success response assert_equal BarclaysEpdqExtraPlusGateway::SUCCESS_MESSAGE, response.message end def test_successful_purchase_with_utf8_encoding_2 - assert response = @gateway.purchase(@amount, credit_card('4000100011112224', :first_name => "ワタシ", :last_name => "ёжзийклмнопрсуфхцч"), @options) + assert response = @gateway.purchase(@amount, credit_card('4000100011112224', :first_name => 'ワタシ', :last_name => 'ёжзийклмнопрсуфхцч'), @options) assert_success response assert_equal BarclaysEpdqExtraPlusGateway::SUCCESS_MESSAGE, response.message end @@ -218,7 +218,7 @@ def test_invalid_login :login => '', :user => '', :password => '', - :signature_encryptor => "none" + :signature_encryptor => 'none' ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response diff --git a/test/remote/gateways/remote_beanstream_interac_test.rb b/test/remote/gateways/remote_beanstream_interac_test.rb index a4a053d6b70..497b0bb744f 100644 --- a/test/remote/gateways/remote_beanstream_interac_test.rb +++ b/test/remote/gateways/remote_beanstream_interac_test.rb @@ -31,12 +31,12 @@ def setup def test_successful_purchase assert response = @gateway.purchase(@amount, @options) assert_success response - assert_equal "R", response.params["responseType"] + assert_equal 'R', response.params['responseType'] assert_false response.redirect.blank? end def test_failed_confirmation - assert response = @gateway.confirm("") + assert response = @gateway.confirm('') assert_failure response end diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb index 9f382ef4d8b..0002e292bc8 100644 --- a/test/remote/gateways/remote_beanstream_test.rb +++ b/test/remote/gateways/remote_beanstream_test.rb @@ -68,21 +68,21 @@ def test_successful_visa_purchase assert response = @gateway.purchase(@amount, @visa, @options) assert_success response assert_false response.authorization.blank? - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_successful_visa_purchase_with_recurring assert response = @gateway.purchase(@amount, @visa, @options.merge(recurring: true)) assert_success response assert_false response.authorization.blank? - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_successful_visa_purchase_no_cvv assert response = @gateway.purchase(@amount, @visa_no_cvv, @options) assert_success response assert_false response.authorization.blank? - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_unsuccessful_visa_purchase @@ -95,14 +95,14 @@ def test_successful_mastercard_purchase assert response = @gateway.purchase(@amount, @mastercard, @options) assert_success response assert_false response.authorization.blank? - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_successful_mastercard_purchase_with_recurring assert response = @gateway.purchase(@amount, @mastercard, @options.merge(recurring: true)) assert_success response assert_false response.authorization.blank? - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_unsuccessful_mastercard_purchase @@ -115,14 +115,14 @@ def test_successful_amex_purchase assert response = @gateway.purchase(@amount, @amex, @options) assert_success response assert_false response.authorization.blank? - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_successful_amex_purchase_with_recurring assert response = @gateway.purchase(@amount, @amex, @options.merge(recurring: true)) assert_success response assert_false response.authorization.blank? - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_unsuccessful_amex_purchase @@ -135,7 +135,7 @@ def test_successful_purchase_with_state_in_iso_format assert response = @gateway.purchase(@amount, @visa, @options.merge(billing_address: address, shipping_address: address)) assert_success response assert_false response.authorization.blank? - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_successful_purchase_with_only_email @@ -148,7 +148,7 @@ def test_successful_purchase_with_only_email assert response = @gateway.purchase(@amount, @visa, options) assert_success response assert_false response.authorization.blank? - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_successful_purchase_with_no_addresses @@ -157,18 +157,18 @@ def test_successful_purchase_with_no_addresses assert response = @gateway.purchase(@amount, @visa, @options) assert_success response assert_false response.authorization.blank? - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_failed_purchase_due_to_invalid_billing_state - @options[:billing_address][:state] = "Invalid" + @options[:billing_address][:state] = 'Invalid' assert response = @gateway.purchase(@amount, @visa, @options) assert_failure response assert_match %r{province does not match country}, response.message end def test_failed_purchase_due_to_invalid_shipping_state - @options[:shipping_address][:state] = "North" + @options[:shipping_address][:state] = 'North' assert response = @gateway.purchase(@amount, @visa, @options) assert_failure response assert_match %r{Invalid shipping province}, response.message @@ -184,7 +184,7 @@ def test_failed_purchase_due_to_missing_country_with_state def test_authorize_and_capture assert auth = @gateway.authorize(@amount, @visa, @options) assert_success auth - assert_equal "Approved", auth.message + assert_equal 'Approved', auth.message assert_false auth.authorization.blank? assert capture = @gateway.capture(@amount, auth.authorization) @@ -195,7 +195,7 @@ def test_authorize_and_capture def test_authorize_and_capture_with_recurring assert auth = @gateway.authorize(@amount, @visa, @options.merge(recurring: true)) assert_success auth - assert_equal "Approved", auth.message + assert_equal 'Approved', auth.message assert_false auth.authorization.blank? assert capture = @gateway.capture(@amount, auth.authorization, recurring: true) @@ -206,7 +206,7 @@ def test_authorize_and_capture_with_recurring def test_successful_verify response = @gateway.verify(@visa, @options) assert_success response - assert_match "Approved", response.message + assert_match 'Approved', response.message end def test_failed_verify @@ -218,7 +218,7 @@ def test_failed_verify def test_failed_capture assert response = @gateway.capture(@amount, '') assert_failure response - assert_no_match %r{You are not authorized}, response.message, "You need to enable username/password validation" + assert_no_match %r{You are not authorized}, response.message, 'You need to enable username/password validation' assert_match %r{Missing or invalid adjustment id.}, response.message end @@ -277,7 +277,7 @@ def test_successful_update_recurring assert response.test? assert_false response.authorization.blank? - assert response = @gateway.update_recurring(@amount + 500, @visa, @recurring_options.merge(:account_id => response.params["rbAccountId"])) + assert response = @gateway.update_recurring(@amount + 500, @visa, @recurring_options.merge(:account_id => response.params['rbAccountId'])) assert_success response end @@ -287,7 +287,7 @@ def test_successful_cancel_recurring assert response.test? assert_false response.authorization.blank? - assert response = @gateway.cancel_recurring(:account_id => response.params["rbAccountId"]) + assert response = @gateway.cancel_recurring(:account_id => response.params['rbAccountId']) assert_success response end @@ -306,7 +306,7 @@ def test_successful_add_to_vault_with_store_method assert response = @gateway.store(@visa,@options) assert_equal 'Operation Successful', response.message assert_success response - assert_not_nil response.params["customer_vault_id"] + assert_not_nil response.params['customer_vault_id'] end def test_add_to_vault_with_custom_vault_id_with_store_method @@ -314,14 +314,14 @@ def test_add_to_vault_with_custom_vault_id_with_store_method assert response = @gateway.store(@visa, @options.dup) assert_equal 'Operation Successful', response.message assert_success response - assert_equal @options[:vault_id], response.params["customer_vault_id"].to_i + assert_equal @options[:vault_id], response.params['customer_vault_id'].to_i end def test_successful_add_to_vault_with_single_use_token assert response = @gateway.store(generate_single_use_token(@visa)) assert_equal 'Operation Successful', response.message, response.inspect assert_success response - assert_not_nil response.params["customer_vault_id"] + assert_not_nil response.params['customer_vault_id'] end def test_update_vault @@ -395,15 +395,15 @@ def generate_single_use_token(credit_card) http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(uri.path) - request.content_type = "application/json" + request.content_type = 'application/json' request.body = { - "number" => credit_card.number, - "expiry_month" => "01", - "expiry_year" => (Time.now.year + 1) % 100, - "cvd" => credit_card.verification_value, + 'number' => credit_card.number, + 'expiry_month' => '01', + 'expiry_year' => (Time.now.year + 1) % 100, + 'cvd' => credit_card.verification_value, }.to_json response = http.request(request) - JSON.parse(response.body)["token"] + JSON.parse(response.body)['token'] end end diff --git a/test/remote/gateways/remote_blue_pay_test.rb b/test/remote/gateways/remote_blue_pay_test.rb index 161f3a115d5..ee6b779e1b9 100644 --- a/test/remote/gateways/remote_blue_pay_test.rb +++ b/test/remote/gateways/remote_blue_pay_test.rb @@ -72,8 +72,8 @@ def test_that_we_understand_and_parse_all_keys_in_standard_response unknown_response_keys = response_keys - BluePayGateway::FIELD_MAP.values missing_response_keys = BluePayGateway::FIELD_MAP.values - response_keys - assert_empty unknown_response_keys, "unknown_response_keys" - assert_empty missing_response_keys, "missing response_keys" + assert_empty unknown_response_keys, 'unknown_response_keys' + assert_empty missing_response_keys, 'missing response_keys' end def test_that_we_understand_and_parse_all_keys_in_rebilling_response @@ -87,8 +87,8 @@ def test_that_we_understand_and_parse_all_keys_in_rebilling_response unknown_response_keys = response_keys - BluePayGateway::REBILL_FIELD_MAP.values missing_response_keys = BluePayGateway::REBILL_FIELD_MAP.values - response_keys - assert_empty unknown_response_keys, "unknown_response_keys" - assert_empty missing_response_keys, "missing response_keys" + assert_empty unknown_response_keys, 'unknown_response_keys' + assert_empty missing_response_keys, 'missing response_keys' end def test_authorization_and_capture diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb index 81748aac0e3..8530b92dba5 100644 --- a/test/remote/gateways/remote_blue_snap_test.rb +++ b/test/remote/gateways/remote_blue_snap_test.rb @@ -25,15 +25,15 @@ def test_successful_purchase_sans_options def test_successful_purchase_with_more_options more_options = @options.merge({ order_id: '1', - ip: "127.0.0.1", - email: "joe@example.com", - description: "Product Description", - soft_descriptor: "OnCardStatement" + ip: '127.0.0.1', + email: 'joe@example.com', + description: 'Product Description', + soft_descriptor: 'OnCardStatement' }) response = @gateway.purchase(@amount, @credit_card, more_options) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message end def test_successful_purchase_with_currency @@ -41,28 +41,28 @@ def test_successful_purchase_with_currency assert_success response assert_equal 'Success', response.message - assert_equal 'CAD', response.params["currency"] + assert_equal 'CAD', response.params['currency'] end def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response assert_match /Authorization has failed for this transaction/, response.message - assert_equal "14002", response.error_code + assert_equal '14002', response.error_code end def test_cvv_result response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "CVV not processed", response.cvv_result["message"] - assert_equal "P", response.cvv_result["code"] + assert_equal 'CVV not processed', response.cvv_result['message'] + assert_equal 'P', response.cvv_result['code'] end def test_avs_result response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Address not verified.", response.avs_result["message"] - assert_equal "I", response.avs_result["code"] + assert_equal 'Address not verified.', response.avs_result['message'] + assert_equal 'I', response.avs_result['code'] end def test_successful_authorize_and_capture @@ -71,7 +71,7 @@ def test_successful_authorize_and_capture assert capture = @gateway.capture(@amount, auth.authorization) assert_success capture - assert_equal "Success", capture.message + assert_equal 'Success', capture.message end def test_failed_authorize @@ -100,7 +100,7 @@ def test_successful_refund assert refund = @gateway.refund(@amount, purchase.authorization, @options) assert_success refund - assert_equal "Success", refund.message + assert_equal 'Success', refund.message end def test_partial_refund @@ -123,7 +123,7 @@ def test_successful_void assert void = @gateway.void(auth.authorization) assert_success void - assert_equal "Success", void.message + assert_equal 'Success', void.message end def test_failed_void @@ -135,7 +135,7 @@ def test_failed_void def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message end def test_failed_verify @@ -148,11 +148,11 @@ def test_successful_store assert response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message assert response.authorization - assert_equal "I", response.avs_result["code"] - assert_equal "P", response.cvv_result["code"] - assert_match /services\/2\/vaulted-shoppers/, response.params["content-location-header"] + assert_equal 'I', response.avs_result['code'] + assert_equal 'P', response.cvv_result['code'] + assert_match /services\/2\/vaulted-shoppers/, response.params['content-location-header'] end def test_failed_store @@ -160,7 +160,7 @@ def test_failed_store assert_failure response assert_match /Transaction failed because of payment processing failure/, response.message - assert_equal "14002", response.error_code + assert_equal '14002', response.error_code end def test_successful_purchase_using_stored_card @@ -186,7 +186,7 @@ def test_invalid_login response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_match "Unable to authenticate. Please check your credentials.", response.message + assert_match 'Unable to authenticate. Please check your credentials.', response.message end def test_verify_credentials diff --git a/test/remote/gateways/remote_borgun_test.rb b/test/remote/gateways/remote_borgun_test.rb index 4b4ac758865..32f7b1b6fc7 100644 --- a/test/remote/gateways/remote_borgun_test.rb +++ b/test/remote/gateways/remote_borgun_test.rb @@ -29,7 +29,7 @@ def test_successful_purchase end def test_successful_purchase_usd - response = @gateway.purchase(@amount, @credit_card, @options.merge(currency: "USD")) + response = @gateway.purchase(@amount, @credit_card, @options.merge(currency: 'USD')) assert_success response assert_equal 'Succeeded', response.message end @@ -121,8 +121,8 @@ def test_successful_void_with_no_currency_in_authorization auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - *new_auth, _ = auth.authorization.split("|") - assert void = @gateway.void(new_auth.join("|")) + *new_auth, _ = auth.authorization.split('|') + assert void = @gateway.void(new_auth.join('|')) assert_success void end diff --git a/test/remote/gateways/remote_bpoint_test.rb b/test/remote/gateways/remote_bpoint_test.rb index e430cb9eb34..32f0124e787 100644 --- a/test/remote/gateways/remote_bpoint_test.rb +++ b/test/remote/gateways/remote_bpoint_test.rb @@ -21,7 +21,7 @@ def setup def test_successful_store response = @gateway.store(@credit_card, { crn1: 'TEST' }) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message token_key = 'AddTokenResult_Token' assert_not_nil response.params[token_key] assert_not_nil response.authorization @@ -31,7 +31,7 @@ def test_successful_store def test_failed_store response = @gateway.store(@error_card) assert_failure response - assert_equal "Error", response.message + assert_equal 'Error', response.message end def test_successful_purchase diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index cf060f773d2..82ad314494b 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -12,7 +12,7 @@ def setup @options = { :order_id => '1', - :billing_address => address(:country_name => "United States of America"), + :billing_address => address(:country_name => 'United States of America'), :description => 'Store Purchase' } end @@ -20,37 +20,37 @@ def setup def test_credit_card_details_on_store assert response = @gateway.store(@credit_card) assert_success response - assert_equal '5100', response.params["braintree_customer"]["credit_cards"].first["last_4"] - assert_equal('510510******5100', response.params["braintree_customer"]["credit_cards"].first["masked_number"]) - assert_equal('5100', response.params["braintree_customer"]["credit_cards"].first["last_4"]) - assert_equal('MasterCard', response.params["braintree_customer"]["credit_cards"].first["card_type"]) - assert_equal('510510', response.params["braintree_customer"]["credit_cards"].first["bin"]) - assert_match %r{^\d+$}, response.params["customer_vault_id"] - assert_equal response.params["customer_vault_id"], response.authorization - assert_match %r{^\w+$}, response.params["credit_card_token"] - assert_equal response.params["credit_card_token"], response.params["braintree_customer"]["credit_cards"].first["token"] + assert_equal '5100', response.params['braintree_customer']['credit_cards'].first['last_4'] + assert_equal('510510******5100', response.params['braintree_customer']['credit_cards'].first['masked_number']) + assert_equal('5100', response.params['braintree_customer']['credit_cards'].first['last_4']) + assert_equal('MasterCard', response.params['braintree_customer']['credit_cards'].first['card_type']) + assert_equal('510510', response.params['braintree_customer']['credit_cards'].first['bin']) + assert_match %r{^\d+$}, response.params['customer_vault_id'] + assert_equal response.params['customer_vault_id'], response.authorization + assert_match %r{^\w+$}, response.params['credit_card_token'] + assert_equal response.params['credit_card_token'], response.params['braintree_customer']['credit_cards'].first['token'] end def test_successful_authorize assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response assert_equal '1000 Approved', response.message - assert_equal 'authorized', response.params["braintree_transaction"]["status"] + assert_equal 'authorized', response.params['braintree_transaction']['status'] end def test_masked_card_number assert response = @gateway.authorize(@amount, @credit_card, @options) - assert_equal('510510******5100', response.params["braintree_transaction"]["credit_card_details"]["masked_number"]) - assert_equal('5100', response.params["braintree_transaction"]["credit_card_details"]["last_4"]) - assert_equal('MasterCard', response.params["braintree_transaction"]["credit_card_details"]["card_type"]) - assert_equal('510510', response.params["braintree_transaction"]["credit_card_details"]["bin"]) + assert_equal('510510******5100', response.params['braintree_transaction']['credit_card_details']['masked_number']) + assert_equal('5100', response.params['braintree_transaction']['credit_card_details']['last_4']) + assert_equal('MasterCard', response.params['braintree_transaction']['credit_card_details']['card_type']) + assert_equal('510510', response.params['braintree_transaction']['credit_card_details']['bin']) end def test_successful_authorize_with_order_id assert response = @gateway.authorize(@amount, @credit_card, :order_id => '123') assert_success response assert_equal '1000 Approved', response.message - assert_equal '123', response.params["braintree_transaction"]["order_id"] + assert_equal '123', response.params['braintree_transaction']['order_id'] end def test_successful_purchase_with_hold_in_escrow @@ -64,47 +64,47 @@ def test_successful_purchase_using_vault_id assert response = @gateway.store(@credit_card) assert_success response assert_equal 'OK', response.message - customer_vault_id = response.params["customer_vault_id"] + customer_vault_id = response.params['customer_vault_id'] assert_match(/\A\d+\z/, customer_vault_id) assert response = @gateway.purchase(@amount, customer_vault_id) assert_success response assert_equal '1000 Approved', response.message - assert_equal 'submitted_for_settlement', response.params["braintree_transaction"]["status"] - assert_equal customer_vault_id, response.params["braintree_transaction"]["customer_details"]["id"] + assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status'] + assert_equal customer_vault_id, response.params['braintree_transaction']['customer_details']['id'] end def test_successful_purchase_using_vault_id_as_integer assert response = @gateway.store(@credit_card) assert_success response assert_equal 'OK', response.message - customer_vault_id = response.params["customer_vault_id"] + customer_vault_id = response.params['customer_vault_id'] assert_match %r{\A\d+\z}, customer_vault_id assert response = @gateway.purchase(@amount, customer_vault_id.to_i) assert_success response assert_equal '1000 Approved', response.message - assert_equal 'submitted_for_settlement', response.params["braintree_transaction"]["status"] - assert_equal customer_vault_id, response.params["braintree_transaction"]["customer_details"]["id"] + assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status'] + assert_equal customer_vault_id, response.params['braintree_transaction']['customer_details']['id'] end def test_successful_purchase_using_card_token assert response = @gateway.store(@credit_card) assert_success response assert_equal 'OK', response.message - credit_card_token = response.params["credit_card_token"] + credit_card_token = response.params['credit_card_token'] assert_match %r{^\w+$}, credit_card_token assert response = @gateway.purchase(@amount, credit_card_token, :payment_method_token => true) assert_success response assert_equal '1000 Approved', response.message - assert_equal 'submitted_for_settlement', response.params["braintree_transaction"]["status"] + assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status'] end def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "1000 Approved", response.message + assert_equal '1000 Approved', response.message end def test_failed_verify @@ -142,12 +142,12 @@ def test_successful_store_with_invalid_card def test_successful_store_with_billing_address billing_address = { - :address1 => "1 E Main St", - :address2 => "Suite 403", - :city => "Chicago", - :state => "Illinois", - :zip => "60622", - :country_name => "United States of America" + :address1 => '1 E Main St', + :address2 => 'Suite 403', + :city => 'Chicago', + :state => 'Illinois', + :zip => '60622', + :country_name => 'United States of America' } credit_card = credit_card('5105105105105100') assert response = @gateway.store(credit_card, :billing_address => billing_address) @@ -157,13 +157,13 @@ def test_successful_store_with_billing_address vault_id = response.params['customer_vault_id'] purchase_response = @gateway.purchase(@amount, vault_id) response_billing_details = { - "country_name"=>"United States of America", - "region"=>"Illinois", - "company"=>nil, - "postal_code"=>"60622", - "extended_address"=>"Suite 403", - "street_address"=>"1 E Main St", - "locality"=>"Chicago" + 'country_name'=>'United States of America', + 'region'=>'Illinois', + 'company'=>nil, + 'postal_code'=>'60622', + 'extended_address'=>'Suite 403', + 'street_address'=>'1 E Main St', + 'locality'=>'Chicago' } assert_equal purchase_response.params['braintree_transaction']['billing_details'], response_billing_details end @@ -174,7 +174,7 @@ def test_successful_store_with_credit_card_token assert response = @gateway.store(credit_card, credit_card_token: credit_card_token) assert_success response assert_equal 'OK', response.message - assert_equal credit_card_token, response.params["braintree_customer"]["credit_cards"][0]["token"] + assert_equal credit_card_token, response.params['braintree_customer']['credit_cards'][0]['token'] end def test_successful_store_with_new_customer_id @@ -184,7 +184,7 @@ def test_successful_store_with_new_customer_id assert_success response assert_equal 'OK', response.message assert_equal customer_id, response.authorization - assert_equal customer_id, response.params["braintree_customer"]["id"] + assert_equal customer_id, response.params['braintree_customer']['id'] end def test_successful_store_with_existing_customer_id @@ -197,16 +197,16 @@ def test_successful_store_with_existing_customer_id assert response = @gateway.store(credit_card, customer: customer_id) assert_success response assert_equal 2, @braintree_backend.customer.find(customer_id).credit_cards.size - assert_equal customer_id, response.params["customer_vault_id"] + assert_equal customer_id, response.params['customer_vault_id'] assert_equal customer_id, response.authorization - assert_not_nil response.params["credit_card_token"] + assert_not_nil response.params['credit_card_token'] end def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal '1000 Approved', response.message - assert_equal 'submitted_for_settlement', response.params["braintree_transaction"]["status"] + assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status'] end def test_successful_purchase_with_solution_id @@ -214,34 +214,34 @@ def test_successful_purchase_with_solution_id assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal '1000 Approved', response.message - assert_equal 'submitted_for_settlement', response.params["braintree_transaction"]["status"] + assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status'] ensure ActiveMerchant::Billing::BraintreeBlueGateway.application_id = nil end def test_avs - assert_avs("1 Elm", "60622", "M") - assert_avs("1 Elm", "20000", "A") - assert_avs("1 Elm", "20001", "B") - assert_avs("1 Elm", "", "B") + assert_avs('1 Elm', '60622', 'M') + assert_avs('1 Elm', '20000', 'A') + assert_avs('1 Elm', '20001', 'B') + assert_avs('1 Elm', '', 'B') - assert_avs("200 Elm", "60622", "Z") - assert_avs("200 Elm", "20000", "C") - assert_avs("200 Elm", "20001", "C") - assert_avs("200 Elm", "", "C") + assert_avs('200 Elm', '60622', 'Z') + assert_avs('200 Elm', '20000', 'C') + assert_avs('200 Elm', '20001', 'C') + assert_avs('200 Elm', '', 'C') - assert_avs("201 Elm", "60622", "P") - assert_avs("201 Elm", "20000", "N") - assert_avs("201 Elm", "20001", "I") - assert_avs("201 Elm", "", "I") + assert_avs('201 Elm', '60622', 'P') + assert_avs('201 Elm', '20000', 'N') + assert_avs('201 Elm', '20001', 'I') + assert_avs('201 Elm', '', 'I') - assert_avs("", "60622", "P") - assert_avs("", "20000", "C") - assert_avs("", "20001", "I") - assert_avs("", "", "I") + assert_avs('', '60622', 'P') + assert_avs('', '20000', 'C') + assert_avs('', '20001', 'I') + assert_avs('', '', 'I') - assert_avs("1 Elm", "30000", "E") - assert_avs("1 Elm", "30001", "S") + assert_avs('1 Elm', '30000', 'E') + assert_avs('1 Elm', '30001', 'S') end def test_cvv_match @@ -258,32 +258,32 @@ def test_cvv_no_match def test_successful_purchase_with_email assert response = @gateway.purchase(@amount, @credit_card, - :email => "customer@example.com" + :email => 'customer@example.com' ) assert_success response - transaction = response.params["braintree_transaction"] - assert_equal 'customer@example.com', transaction["customer_details"]["email"] + transaction = response.params['braintree_transaction'] + assert_equal 'customer@example.com', transaction['customer_details']['email'] end def test_successful_purchase_with_phone - assert response = @gateway.purchase(@amount, @credit_card, :phone => "123-345-5678") + assert response = @gateway.purchase(@amount, @credit_card, :phone => '123-345-5678') assert_success response - transaction = response.params["braintree_transaction"] - assert_equal '123-345-5678', transaction["customer_details"]["phone"] + transaction = response.params['braintree_transaction'] + assert_equal '123-345-5678', transaction['customer_details']['phone'] end def test_successful_purchase_with_phone_from_address assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - transaction = response.params["braintree_transaction"] - assert_equal '(555)555-5555', transaction["customer_details"]["phone"] + transaction = response.params['braintree_transaction'] + assert_equal '(555)555-5555', transaction['customer_details']['phone'] end def test_successful_purchase_with_skip_advanced_fraud_checking_option assert response = @gateway.purchase(@amount, @credit_card, @options.merge(skip_advanced_fraud_checking: true)) assert_success response assert_equal '1000 Approved', response.message - assert_equal 'submitted_for_settlement', response.params["braintree_transaction"]["status"] + assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status'] end def test_purchase_with_store_using_random_customer_id @@ -292,9 +292,9 @@ def test_purchase_with_store_using_random_customer_id ) assert_success response assert_equal '1000 Approved', response.message - assert_match(/\A\d+\z/, response.params["customer_vault_id"]) - assert_equal '510510', response.params["braintree_transaction"]["vault_customer"]["credit_cards"][0]["bin"] - assert_equal '510510', @braintree_backend.customer.find(response.params["customer_vault_id"]).credit_cards[0].bin + assert_match(/\A\d+\z/, response.params['customer_vault_id']) + assert_equal '510510', response.params['braintree_transaction']['vault_customer']['credit_cards'][0]['bin'] + assert_equal '510510', @braintree_backend.customer.find(response.params['customer_vault_id']).credit_cards[0].bin end def test_purchase_with_store_using_specified_customer_id @@ -304,9 +304,9 @@ def test_purchase_with_store_using_specified_customer_id ) assert_success response assert_equal '1000 Approved', response.message - assert_equal customer_id, response.params["customer_vault_id"] - assert_equal '510510', response.params["braintree_transaction"]["vault_customer"]["credit_cards"][0]["bin"] - assert_equal '510510', @braintree_backend.customer.find(response.params["customer_vault_id"]).credit_cards[0].bin + assert_equal customer_id, response.params['customer_vault_id'] + assert_equal '510510', response.params['braintree_transaction']['vault_customer']['credit_cards'][0]['bin'] + assert_equal '510510', @braintree_backend.customer.find(response.params['customer_vault_id']).credit_cards[0].bin end def test_purchase_using_specified_payment_method_token @@ -315,16 +315,16 @@ def test_purchase_using_specified_payment_method_token :first_name => 'Old First', :last_name => 'Old Last', :month => 9, :year => 2012 ), - :email => "old@example.com", - :phone => "321-654-0987" + :email => 'old@example.com', + :phone => '321-654-0987' ) - payment_method_token = response.params["braintree_customer"]["credit_cards"][0]["token"] + payment_method_token = response.params['braintree_customer']['credit_cards'][0]['token'] assert response = @gateway.purchase( @amount, payment_method_token, @options.merge(payment_method_token: true) ) assert_success response assert_equal '1000 Approved', response.message - assert_equal payment_method_token, response.params["braintree_transaction"]["credit_card_details"]["token"] + assert_equal payment_method_token, response.params['braintree_transaction']['credit_card_details']['token'] end def test_successful_purchase_with_addresses @@ -351,25 +351,25 @@ def test_successful_purchase_with_addresses :shipping_address => shipping_address ) assert_success response - transaction = response.params["braintree_transaction"] - assert_equal '1 E Main St', transaction["billing_details"]["street_address"] - assert_equal 'Suite 101', transaction["billing_details"]["extended_address"] - assert_equal 'Widgets Co', transaction["billing_details"]["company"] - assert_equal 'Chicago', transaction["billing_details"]["locality"] - assert_equal 'IL', transaction["billing_details"]["region"] - assert_equal '60622', transaction["billing_details"]["postal_code"] - assert_equal 'United States of America', transaction["billing_details"]["country_name"] - assert_equal '1 W Main St', transaction["shipping_details"]["street_address"] - assert_equal 'Suite 102', transaction["shipping_details"]["extended_address"] - assert_equal 'Widgets Company', transaction["shipping_details"]["company"] - assert_equal 'Bartlett', transaction["shipping_details"]["locality"] - assert_equal 'Illinois', transaction["shipping_details"]["region"] - assert_equal '60103', transaction["shipping_details"]["postal_code"] - assert_equal 'Mexico', transaction["shipping_details"]["country_name"] + transaction = response.params['braintree_transaction'] + assert_equal '1 E Main St', transaction['billing_details']['street_address'] + assert_equal 'Suite 101', transaction['billing_details']['extended_address'] + assert_equal 'Widgets Co', transaction['billing_details']['company'] + assert_equal 'Chicago', transaction['billing_details']['locality'] + assert_equal 'IL', transaction['billing_details']['region'] + assert_equal '60622', transaction['billing_details']['postal_code'] + assert_equal 'United States of America', transaction['billing_details']['country_name'] + assert_equal '1 W Main St', transaction['shipping_details']['street_address'] + assert_equal 'Suite 102', transaction['shipping_details']['extended_address'] + assert_equal 'Widgets Company', transaction['shipping_details']['company'] + assert_equal 'Bartlett', transaction['shipping_details']['locality'] + assert_equal 'Illinois', transaction['shipping_details']['region'] + assert_equal '60103', transaction['shipping_details']['postal_code'] + assert_equal 'Mexico', transaction['shipping_details']['country_name'] end def test_successful_purchase_with_three_d_secure_pass_thru - three_d_secure_params = { eci: "05", cavv: "cavv", xid: "xid" } + three_d_secure_params = { eci: '05', cavv: 'cavv', xid: 'xid' } assert response = @gateway.purchase(@amount, @credit_card, three_d_secure: three_d_secure_params ) @@ -387,7 +387,7 @@ def test_unsuccessful_purchase_validation_error assert response = @gateway.purchase(@amount, credit_card('51051051051051000')) assert_failure response assert_match %r{Credit card number is invalid\. \(81715\)}, response.message - assert_equal({"processor_response_code"=>"91577"}, response.params["braintree_transaction"]) + assert_equal({'processor_response_code'=>'91577'}, response.params['braintree_transaction']) end def test_authorize_and_capture @@ -402,8 +402,8 @@ def test_authorize_and_capture def test_authorize_and_capture_with_apple_pay_card credit_card = network_tokenization_credit_card('4111111111111111', :brand => 'visa', - :eci => "05", - :payment_cryptogram => "EHuWW9PiBkWvqE5juRwDzAUFBAk=" + :eci => '05', + :payment_cryptogram => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=' ) assert auth = @gateway.authorize(@amount, credit_card, @options) @@ -416,12 +416,12 @@ def test_authorize_and_capture_with_apple_pay_card def test_authorize_and_capture_with_android_pay_card credit_card = network_tokenization_credit_card('4111111111111111', - :payment_cryptogram => "EHuWW9PiBkWvqE5juRwDzAUFBAk=", - :month => "01", - :year => "2024", + :payment_cryptogram => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', + :month => '01', + :year => '2024', :source => :android_pay, - :transaction_id => "123456789", - :eci => "05" + :transaction_id => '123456789', + :eci => '05' ) assert auth = @gateway.authorize(@amount, credit_card, @options) @@ -439,7 +439,7 @@ def test_authorize_and_void assert auth.authorization assert void = @gateway.void(auth.authorization) assert_success void - assert_equal 'voided', void.params["braintree_transaction"]["status"] + assert_equal 'voided', void.params['braintree_transaction']['status'] end def test_purchase_and_void @@ -447,7 +447,7 @@ def test_purchase_and_void assert_success purchase assert void = @gateway.void(purchase.authorization) assert_success void - assert_equal 'voided', void.params["braintree_transaction"]["status"] + assert_equal 'voided', void.params['braintree_transaction']['status'] end def test_capture_and_void @@ -459,7 +459,7 @@ def test_capture_and_void assert void = @gateway.void(capture.authorization) assert_success void - assert_equal 'voided', void.params["braintree_transaction"]["status"] + assert_equal 'voided', void.params['braintree_transaction']['status'] end def test_failed_void @@ -469,11 +469,11 @@ def test_failed_void assert auth.authorization assert void = @gateway.void(auth.authorization) assert_success void - assert_equal 'voided', void.params["braintree_transaction"]["status"] + assert_equal 'voided', void.params['braintree_transaction']['status'] assert failed_void = @gateway.void(auth.authorization) assert_failure failed_void assert_match('Transaction can only be voided if status is authorized', failed_void.message) - assert_equal({"processor_response_code"=>"91504"}, failed_void.params["braintree_transaction"]) + assert_equal({'processor_response_code'=>'91504'}, failed_void.params['braintree_transaction']) end def test_failed_capture_with_invalid_transaction_id @@ -483,7 +483,7 @@ def test_failed_capture_with_invalid_transaction_id end def test_invalid_login - gateway = BraintreeBlueGateway.new(:merchant_id => "invalid", :public_key => "invalid", :private_key => "invalid") + gateway = BraintreeBlueGateway.new(:merchant_id => 'invalid', :public_key => 'invalid', :private_key => 'invalid') assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response assert_equal 'Braintree::AuthenticationError', response.message @@ -493,22 +493,22 @@ def test_successful_add_to_vault_with_store_method assert response = @gateway.store(@credit_card) assert_success response assert_equal 'OK', response.message - assert_match(/\A\d+\z/, response.params["customer_vault_id"]) + assert_match(/\A\d+\z/, response.params['customer_vault_id']) end def test_failed_add_to_vault assert response = @gateway.store(credit_card('5105105105105101')) assert_failure response assert_equal 'Credit card number is invalid. (81715)', response.message - assert_equal nil, response.params["braintree_customer"] - assert_equal nil, response.params["customer_vault_id"] + assert_equal nil, response.params['braintree_customer'] + assert_equal nil, response.params['customer_vault_id'] end def test_unstore_customer assert response = @gateway.store(@credit_card) assert_success response assert_equal 'OK', response.message - assert customer_vault_id = response.params["customer_vault_id"] + assert customer_vault_id = response.params['customer_vault_id'] assert delete_response = @gateway.unstore(customer_vault_id) assert_success delete_response end @@ -517,7 +517,7 @@ def test_unstore_credit_card assert response = @gateway.store(@credit_card) assert_success response assert_equal 'OK', response.message - assert credit_card_token = response.params["credit_card_token"] + assert credit_card_token = response.params['credit_card_token'] assert delete_response = @gateway.unstore(nil, credit_card_token: credit_card_token) assert_success delete_response end @@ -526,7 +526,7 @@ def test_unstore_with_delete_method assert response = @gateway.store(@credit_card) assert_success response assert_equal 'OK', response.message - assert customer_vault_id = response.params["customer_vault_id"] + assert customer_vault_id = response.params['customer_vault_id'] assert delete_response = @gateway.delete(customer_vault_id) assert_success delete_response end @@ -537,21 +537,21 @@ def test_successful_update :first_name => 'Old First', :last_name => 'Old Last', :month => 9, :year => 2012 ), - :email => "old@example.com", - :phone => "321-654-0987" + :email => 'old@example.com', + :phone => '321-654-0987' ) assert_success response assert_equal 'OK', response.message - customer_vault_id = response.params["customer_vault_id"] + customer_vault_id = response.params['customer_vault_id'] assert_match(/\A\d+\z/, customer_vault_id) - assert_equal "old@example.com", response.params["braintree_customer"]["email"] - assert_equal "321-654-0987", response.params["braintree_customer"]["phone"] - assert_equal "Old First", response.params["braintree_customer"]["first_name"] - assert_equal "Old Last", response.params["braintree_customer"]["last_name"] - assert_equal "411111", response.params["braintree_customer"]["credit_cards"][0]["bin"] - assert_equal "09/2012", response.params["braintree_customer"]["credit_cards"][0]["expiration_date"] - assert_not_nil response.params["braintree_customer"]["credit_cards"][0]["token"] - assert_equal customer_vault_id, response.params["braintree_customer"]["id"] + assert_equal 'old@example.com', response.params['braintree_customer']['email'] + assert_equal '321-654-0987', response.params['braintree_customer']['phone'] + assert_equal 'Old First', response.params['braintree_customer']['first_name'] + assert_equal 'Old Last', response.params['braintree_customer']['last_name'] + assert_equal '411111', response.params['braintree_customer']['credit_cards'][0]['bin'] + assert_equal '09/2012', response.params['braintree_customer']['credit_cards'][0]['expiration_date'] + assert_not_nil response.params['braintree_customer']['credit_cards'][0]['token'] + assert_equal customer_vault_id, response.params['braintree_customer']['id'] assert response = @gateway.update( customer_vault_id, @@ -559,25 +559,25 @@ def test_successful_update :first_name => 'New First', :last_name => 'New Last', :month => 10, :year => 2014 ), - :email => "new@example.com", - :phone => "987-765-5432" + :email => 'new@example.com', + :phone => '987-765-5432' ) assert_success response - assert_equal "new@example.com", response.params["braintree_customer"]["email"] - assert_equal "987-765-5432", response.params["braintree_customer"]["phone"] - assert_equal "New First", response.params["braintree_customer"]["first_name"] - assert_equal "New Last", response.params["braintree_customer"]["last_name"] - assert_equal "510510", response.params["braintree_customer"]["credit_cards"][0]["bin"] - assert_equal "10/2014", response.params["braintree_customer"]["credit_cards"][0]["expiration_date"] - assert_not_nil response.params["braintree_customer"]["credit_cards"][0]["token"] - assert_equal customer_vault_id, response.params["braintree_customer"]["id"] + assert_equal 'new@example.com', response.params['braintree_customer']['email'] + assert_equal '987-765-5432', response.params['braintree_customer']['phone'] + assert_equal 'New First', response.params['braintree_customer']['first_name'] + assert_equal 'New Last', response.params['braintree_customer']['last_name'] + assert_equal '510510', response.params['braintree_customer']['credit_cards'][0]['bin'] + assert_equal '10/2014', response.params['braintree_customer']['credit_cards'][0]['expiration_date'] + assert_not_nil response.params['braintree_customer']['credit_cards'][0]['token'] + assert_equal customer_vault_id, response.params['braintree_customer']['id'] end def test_failed_customer_update - assert response = @gateway.store(credit_card('4111111111111111'), :email => "email@example.com", :phone => "321-654-0987") + assert response = @gateway.store(credit_card('4111111111111111'), :email => 'email@example.com', :phone => '321-654-0987') assert_success response assert_equal 'OK', response.message - assert customer_vault_id = response.params["customer_vault_id"] + assert customer_vault_id = response.params['customer_vault_id'] assert response = @gateway.update( customer_vault_id, @@ -585,8 +585,8 @@ def test_failed_customer_update ) assert_failure response assert_equal 'Credit card number is invalid. (81715)', response.message - assert_equal nil, response.params["braintree_customer"] - assert_equal nil, response.params["customer_vault_id"] + assert_equal nil, response.params['braintree_customer'] + assert_equal nil, response.params['customer_vault_id'] end def test_failed_customer_update_invalid_vault_id @@ -599,7 +599,7 @@ def test_failed_credit_card_update assert response = @gateway.store(credit_card('4111111111111111')) assert_success response assert_equal 'OK', response.message - assert customer_vault_id = response.params["customer_vault_id"] + assert customer_vault_id = response.params['customer_vault_id'] assert response = @gateway.update( customer_vault_id, @@ -613,7 +613,7 @@ def test_failed_credit_card_update_on_verify assert response = @gateway.store(credit_card('4111111111111111')) assert_success response assert_equal 'OK', response.message - assert customer_vault_id = response.params["customer_vault_id"] + assert customer_vault_id = response.params['customer_vault_id'] assert response = @gateway.update( customer_vault_id, @@ -633,40 +633,40 @@ def test_customer_does_not_have_credit_card_failed_update def test_successful_credit assert response = @gateway.credit(@amount, @credit_card, @options) - assert_success response, "You must get credits enabled in your Sandbox account for this to pass." + assert_success response, 'You must get credits enabled in your Sandbox account for this to pass.' assert_equal '1002 Processed', response.message - assert_equal 'submitted_for_settlement', response.params["braintree_transaction"]["status"] + assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status'] end def test_failed_credit assert response = @gateway.credit(@amount, credit_card('5105105105105101'), @options) assert_failure response - assert_equal 'Credit card number is invalid. (81715)', response.message, "You must get credits enabled in your Sandbox account for this to pass" + assert_equal 'Credit card number is invalid. (81715)', response.message, 'You must get credits enabled in your Sandbox account for this to pass' end def test_successful_credit_with_merchant_account_id assert response = @gateway.credit(@amount, @credit_card, :merchant_account_id => fixtures(:braintree_blue)[:merchant_account_id]) - assert_success response, "You must specify a valid :merchant_account_id key in your fixtures.yml AND get credits enabled in your Sandbox account for this to pass." + assert_success response, 'You must specify a valid :merchant_account_id key in your fixtures.yml AND get credits enabled in your Sandbox account for this to pass.' assert_equal '1002 Processed', response.message - assert_equal 'submitted_for_settlement', response.params["braintree_transaction"]["status"] + assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status'] end def test_successful_authorize_with_merchant_account_id assert response = @gateway.authorize(@amount, @credit_card, :merchant_account_id => fixtures(:braintree_blue)[:merchant_account_id]) - assert_success response, "You must specify a valid :merchant_account_id key in your fixtures.yml for this to pass." + assert_success response, 'You must specify a valid :merchant_account_id key in your fixtures.yml for this to pass.' assert_equal '1000 Approved', response.message - assert_equal 'authorized', response.params["braintree_transaction"]["status"] + assert_equal 'authorized', response.params['braintree_transaction']['status'] end def test_authorize_with_descriptor - assert auth = @gateway.authorize(@amount, @credit_card, descriptor_name: "company*theproduct", descriptor_phone: "1331131131", descriptor_url: "company.com") + assert auth = @gateway.authorize(@amount, @credit_card, descriptor_name: 'company*theproduct', descriptor_phone: '1331131131', descriptor_url: 'company.com') assert_success auth end def test_successful_validate_on_store_with_verification_merchant_account card = credit_card('4111111111111111', :verification_value => '101') assert response = @gateway.store(card, :verify_card => true, :verification_merchant_account_id => fixtures(:braintree_blue)[:merchant_account_id]) - assert_success response, "You must specify a valid :merchant_account_id key in your fixtures.yml for this to pass." + assert_success response, 'You must specify a valid :merchant_account_id key in your fixtures.yml for this to pass.' assert_equal 'OK', response.message end @@ -683,7 +683,7 @@ def test_transcript_scrubbing def test_verify_credentials assert @gateway.verify_credentials - gateway = BraintreeGateway.new(merchant_id: "UNKNOWN", public_key: "UNKONWN", private_key: "UNKONWN") + gateway = BraintreeGateway.new(merchant_id: 'UNKNOWN', public_key: 'UNKONWN', private_key: 'UNKONWN') assert !gateway.verify_credentials end diff --git a/test/remote/gateways/remote_braintree_orange_test.rb b/test/remote/gateways/remote_braintree_orange_test.rb index 8468633afbf..6f6fb6bd842 100644 --- a/test/remote/gateways/remote_braintree_orange_test.rb +++ b/test/remote/gateways/remote_braintree_orange_test.rb @@ -37,15 +37,15 @@ def test_successful_add_to_vault assert response = @gateway.purchase(@amount, @credit_card, @options) assert_equal 'This transaction has been approved', response.message assert_success response - assert_not_nil response.params["customer_vault_id"] + assert_not_nil response.params['customer_vault_id'] end def test_successful_add_to_vault_with_store_method assert response = @gateway.store(@credit_card) assert_equal 'Customer Added', response.message assert_success response - assert_match %r{^\d+$}, response.params["customer_vault_id"] - assert_equal response.params["customer_vault_id"], response.authorization + assert_match %r{^\d+$}, response.params['customer_vault_id'] + assert_equal response.params['customer_vault_id'], response.authorization end def test_failed_add_to_vault_with_store_method @@ -59,7 +59,7 @@ def test_successful_add_to_vault_and_use assert response = @gateway.purchase(@amount, @credit_card, @options) assert_equal 'This transaction has been approved', response.message assert_success response - assert_not_nil customer_id = response.params["customer_vault_id"] + assert_not_nil customer_id = response.params['customer_vault_id'] assert second_response = @gateway.purchase(@amount*2, customer_id, @options) assert_equal 'This transaction has been approved', second_response.message @@ -71,7 +71,7 @@ def test_add_to_vault_with_custom_vault_id assert response = @gateway.purchase(@amount, @credit_card, @options) assert_equal 'This transaction has been approved', response.message assert_success response - assert_equal @options[:store], response.params["customer_vault_id"].to_i + assert_equal @options[:store], response.params['customer_vault_id'].to_i end def test_add_to_vault_with_custom_vault_id_with_store_method @@ -79,7 +79,7 @@ def test_add_to_vault_with_custom_vault_id_with_store_method assert response = @gateway.store(@credit_card, @options.dup) assert_equal 'Customer Added', response.message assert_success response - assert_equal @options[:billing_id], response.params["customer_vault_id"].to_i + assert_equal @options[:billing_id], response.params['customer_vault_id'].to_i end def test_add_to_vault_with_store_and_check @@ -143,7 +143,7 @@ def test_failed_capture end def test_authorize_with_three_d_secure_pass_thru - assert auth = @gateway.authorize(@amount, @credit_card, @options.merge(eci: "05", xid: "xid", cavv: "cavv")) + assert auth = @gateway.authorize(@amount, @credit_card, @options.merge(eci: '05', xid: 'xid', cavv: 'cavv')) assert_success auth assert_equal 'This transaction has been approved', auth.message end @@ -151,7 +151,7 @@ def test_authorize_with_three_d_secure_pass_thru def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "This transaction has been approved", response.message + assert_equal 'This transaction has been approved', response.message end def test_failed_verify diff --git a/test/remote/gateways/remote_bridge_pay_test.rb b/test/remote/gateways/remote_bridge_pay_test.rb index a5ca8f46680..88f91a8212c 100644 --- a/test/remote/gateways/remote_bridge_pay_test.rb +++ b/test/remote/gateways/remote_bridge_pay_test.rb @@ -103,10 +103,10 @@ def test_failed_void def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message - assert_success response.responses.last, "The void should succeed" - assert_equal "Approved", response.responses.last.params["respmsg"] + assert_success response.responses.last, 'The void should succeed' + assert_equal 'Approved', response.responses.last.params['respmsg'] end def test_unsuccessful_verify diff --git a/test/remote/gateways/remote_card_connect_test.rb b/test/remote/gateways/remote_card_connect_test.rb index a607308976f..10cf459c550 100644 --- a/test/remote/gateways/remote_card_connect_test.rb +++ b/test/remote/gateways/remote_card_connect_test.rb @@ -24,8 +24,8 @@ def test_successful_purchase def test_successful_purchase_with_more_options options = { order_id: '1', - ip: "127.0.0.1", - email: "joe@example.com", + ip: '127.0.0.1', + email: 'joe@example.com', po_number: '5FSD4', tax_amount: '50', freight_amount: '29', diff --git a/test/remote/gateways/remote_card_stream_test.rb b/test/remote/gateways/remote_card_stream_test.rb index 7533036d161..c35543a9b9b 100644 --- a/test/remote/gateways/remote_card_stream_test.rb +++ b/test/remote/gateways/remote_card_stream_test.rb @@ -42,8 +42,8 @@ def setup @amex_options = { :billing_address => { :address1 => 'The Hunts Way', - :city => "", - :state => "Leicester", + :city => '', + :state => 'Leicester', :zip => 'SO18 1GW', :country => 'GB' }, @@ -54,10 +54,10 @@ def setup @visacredit_options = { :billing_address => { - :address1 => "Flat 6, Primrose Rise", - :address2 => "347 Lavender Road", - :city => "", - :state => "Northampton", + :address1 => 'Flat 6, Primrose Rise', + :address2 => '347 Lavender Road', + :city => '', + :state => 'Northampton', :zip => 'NN17 8YG', :country => 'GB' }, @@ -68,10 +68,10 @@ def setup @visacredit_descriptor_options = { :billing_address => { - :address1 => "Flat 6, Primrose Rise", - :address2 => "347 Lavender Road", - :city => "", - :state => "Northampton", + :address1 => 'Flat 6, Primrose Rise', + :address2 => '347 Lavender Road', + :city => '', + :state => 'Northampton', :zip => 'NN17 8YG', :country => 'GB' }, @@ -89,10 +89,10 @@ def setup @visadebit_options = { :billing_address => { :address1 => 'Unit 5, Pickwick Walk', - :address2 => "120 Uxbridge Road", - :city => "Hatch End", - :state => "Middlesex", - :zip => "HA6 7HJ", + :address2 => '120 Uxbridge Road', + :city => 'Hatch End', + :state => 'Middlesex', + :zip => 'HA6 7HJ', :country => 'GB' }, :order_id => generate_unique_id, @@ -103,8 +103,8 @@ def setup @mastercard_options = { :billing_address => { :address1 => '25 The Larches', - :city => "Narborough", - :state => "Leicester", + :city => 'Narborough', + :state => 'Leicester', :zip => 'LE10 2RT', :country => 'GB' }, @@ -333,12 +333,12 @@ def test_failed_visacreditcard_purchase_via_reference def test_purchase_no_currency_specified_defaults_to_GBP assert response = @gateway.purchase(142, @visacreditcard, @visacredit_options.merge(currency: nil)) assert_success response - assert_equal "826", response.params["currencyCode"] + assert_equal '826', response.params['currencyCode'] assert_equal 'APPROVED', response.message end def test_failed_purchase_non_existent_currency - assert response = @gateway.purchase(142, @visacreditcard, @visacredit_options.merge(currency: "CEO")) + assert response = @gateway.purchase(142, @visacreditcard, @visacredit_options.merge(currency: 'CEO')) assert_failure response assert_match %r{MISSING_CURRENCYCODE}, response.message end @@ -399,23 +399,23 @@ def test_failed_verify def test_successful_3dsecure_purchase assert response = @gateway.purchase(1202, @three_ds_enrolled_card, @mastercard_options.merge(threeds_required: true)) assert_equal '3DS AUTHENTICATION REQUIRED', response.message - assert_equal "65802", response.params["responseCode"] + assert_equal '65802', response.params['responseCode'] assert response.test? assert !response.authorization.blank? - assert !response.params["threeDSACSURL"].blank? - assert !response.params["threeDSMD"].blank? - assert !response.params["threeDSPaReq"].blank? + assert !response.params['threeDSACSURL'].blank? + assert !response.params['threeDSMD'].blank? + assert !response.params['threeDSPaReq'].blank? end def test_successful_3dsecure_auth assert response = @gateway.authorize(1202, @three_ds_enrolled_card, @mastercard_options.merge(threeds_required: true)) assert_equal '3DS AUTHENTICATION REQUIRED', response.message - assert_equal "65802", response.params["responseCode"] + assert_equal '65802', response.params['responseCode'] assert response.test? assert !response.authorization.blank? - assert !response.params["threeDSACSURL"].blank? - assert !response.params["threeDSMD"].blank? - assert !response.params["threeDSPaReq"].blank? + assert !response.params['threeDSACSURL'].blank? + assert !response.params['threeDSMD'].blank? + assert !response.params['threeDSPaReq'].blank? end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_cardknox_test.rb b/test/remote/gateways/remote_cardknox_test.rb index 58fc15e4fc3..e3c375aa324 100644 --- a/test/remote/gateways/remote_cardknox_test.rb +++ b/test/remote/gateways/remote_cardknox_test.rb @@ -16,8 +16,8 @@ def setup order_id: generate_unique_id, invoice: generate_unique_id, name: 'Jim Smith', - ip: "127.0.0.1", - email: "joe@example.com", + ip: '127.0.0.1', + email: 'joe@example.com', tip: 2, tax: 3, custom02: 'mycustom', diff --git a/test/remote/gateways/remote_cashnet_test.rb b/test/remote/gateways/remote_cashnet_test.rb index babeb00ae47..87aea788007 100644 --- a/test/remote/gateways/remote_cashnet_test.rb +++ b/test/remote/gateways/remote_cashnet_test.rb @@ -5,7 +5,7 @@ def setup @gateway = CashnetGateway.new(fixtures(:cashnet)) @amount = 100 @credit_card = credit_card( - "5454545454545454", + '5454545454545454', month: 12, year: 2015 ) @@ -29,10 +29,10 @@ def test_successful_purchase_and_refund end def test_successful_refund_with_options - assert purchase = @gateway.purchase(@amount, @credit_card, custcode: "TheCustCode") + assert purchase = @gateway.purchase(@amount, @credit_card, custcode: 'TheCustCode') assert_success purchase - assert refund = @gateway.refund(@amount, purchase.authorization, email: "wow@example.com", custcode: "TheCustCode") + assert refund = @gateway.refund(@amount, purchase.authorization, email: 'wow@example.com', custcode: 'TheCustCode') assert_success refund end @@ -40,7 +40,7 @@ def test_failed_purchase assert response = @gateway.purchase(-44, @credit_card, @options) assert_failure response assert_match %r{Negative amount is not allowed}, response.message - assert_equal "5", response.params["result"] + assert_equal '5', response.params['result'] end def test_failed_refund @@ -50,7 +50,7 @@ def test_failed_refund assert refund = @gateway.refund(@amount + 50, purchase.authorization) assert_failure refund assert_match %r{Amount to refund exceeds}, refund.message - assert_equal "302", refund.params["result"] + assert_equal '302', refund.params['result'] end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_cecabank_test.rb b/test/remote/gateways/remote_cecabank_test.rb index ef91178c9ea..1a6c0131cd2 100644 --- a/test/remote/gateways/remote_cecabank_test.rb +++ b/test/remote/gateways/remote_cecabank_test.rb @@ -37,7 +37,7 @@ def test_successful_refund end def test_unsuccessful_refund - assert response = @gateway.refund(@amount, "wrongreference", @options) + assert response = @gateway.refund(@amount, 'wrongreference', @options) assert_failure response assert_equal 'ERROR', response.message end diff --git a/test/remote/gateways/remote_cenpos_test.rb b/test/remote/gateways/remote_cenpos_test.rb index 29024454559..479545edb08 100644 --- a/test/remote/gateways/remote_cenpos_test.rb +++ b/test/remote/gateways/remote_cenpos_test.rb @@ -1,13 +1,13 @@ -require "test_helper" +require 'test_helper' class RemoteCenposTest < Test::Unit::TestCase def setup @gateway = CenposGateway.new(fixtures(:cenpos)) @amount = SecureRandom.random_number(10000) - @credit_card = credit_card("4111111111111111", month: 02, year: 18, verification_value: 999) - @declined_card = credit_card("4000300011112220") - @invalid_card = credit_card("9999999999999999") + @credit_card = credit_card('4111111111111111', month: 02, year: 18, verification_value: 999) + @declined_card = credit_card('4000300011112220') + @invalid_card = credit_card('9999999999999999') @options = { order_id: SecureRandom.random_number(1000000), @@ -17,53 +17,53 @@ def setup def test_invalid_login gateway = CenposGateway.new( - merchant_id: "", - password: "", - user_id: "" + merchant_id: '', + password: '', + user_id: '' ) response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "See transcript for detailed error description.", response.message + assert_equal 'See transcript for detailed error description.', response.message end def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_purchase_cvv_result response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal "M", response.cvv_result["code"] + assert_equal 'M', response.cvv_result['code'] end def test_successful_purchase_avs_result response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal "D", response.avs_result["code"] + assert_equal 'D', response.avs_result['code'] end def test_successful_purchase_with_invoice_detail - response = @gateway.purchase(@amount, @credit_card, @options.merge(invoice_detail: "<xml><description/></xml>")) + response = @gateway.purchase(@amount, @credit_card, @options.merge(invoice_detail: '<xml><description/></xml>')) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_purchase_with_customer_code - response = @gateway.purchase(@amount, @credit_card, @options.merge(customer_code: "3214")) + response = @gateway.purchase(@amount, @credit_card, @options.merge(customer_code: '3214')) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_purchase_with_currency - response = @gateway.purchase(@amount, @credit_card, @options.merge(currency: "EUR")) + response = @gateway.purchase(@amount, @credit_card, @options.merge(currency: 'EUR')) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "Decline transaction", response.message + assert_equal 'Decline transaction', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code end @@ -84,30 +84,30 @@ def test_failed_purchase_avs_result def test_successful_authorize_and_capture response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^\d+\|.+$), response.authorization capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal "Decline transaction", response.message + assert_equal 'Decline transaction', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code end def test_failed_capture response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message capture = @gateway.capture(@amount, response.authorization) capture = @gateway.capture(@amount, response.authorization) assert_failure capture - assert_equal "Duplicated force transaction.", capture.message + assert_equal 'Duplicated force transaction.', capture.message end def test_successful_void @@ -116,7 +116,7 @@ def test_successful_void void = @gateway.void(response.authorization) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end def test_void_can_receive_order_id @@ -125,7 +125,7 @@ def test_void_can_receive_order_id void = @gateway.void(response.authorization, order_id: SecureRandom.random_number(1000000)) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end def test_failed_void @@ -135,7 +135,7 @@ def test_failed_void void = @gateway.void(response.authorization) void = @gateway.void(response.authorization) assert_failure void - assert_equal "Original Transaction not found", void.message + assert_equal 'Original Transaction not found', void.message end def test_successful_refund @@ -144,25 +144,25 @@ def test_successful_refund refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "Succeeded", refund.message + assert_equal 'Succeeded', refund.message end def test_failed_refund - response = @gateway.refund(nil, "") + response = @gateway.refund(nil, '') assert_failure response - assert_equal "See transcript for detailed error description.", response.message + assert_equal 'See transcript for detailed error description.', response.message end def test_successful_credit response = @gateway.credit(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_credit response = @gateway.credit(@amount, @invalid_card, @options) assert_failure response - assert_equal "Invalid card number", response.message + assert_equal 'Invalid card number', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code end @@ -175,7 +175,7 @@ def test_successful_verify def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "Decline transaction", response.message + assert_equal 'Decline transaction', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code end diff --git a/test/remote/gateways/remote_checkout_test.rb b/test/remote/gateways/remote_checkout_test.rb index 149c3837031..206442a70fa 100644 --- a/test/remote/gateways/remote_checkout_test.rb +++ b/test/remote/gateways/remote_checkout_test.rb @@ -4,10 +4,10 @@ class RemoteCheckoutTest < Test::Unit::TestCase def setup @gateway = ActiveMerchant::Billing::CheckoutGateway.new(fixtures(:checkout)) @credit_card = credit_card( - "4543474002249996", - month: "06", - year: "2017", - verification_value: "956" + '4543474002249996', + month: '06', + year: '2017', + verification_value: '956' ) @declined_card = credit_card( '4543474002249996', @@ -16,7 +16,7 @@ def setup verification_value: '958' ) @options = { - currency: "CAD" + currency: 'CAD' } end @@ -28,11 +28,11 @@ def test_successful_purchase def test_successful_purchase_with_extra_options response = @gateway.purchase(100, @credit_card, @options.merge( - currency: "EUR", - email: "bob@example.com", + currency: 'EUR', + email: 'bob@example.com', order_id: generate_unique_id, customer: generate_unique_id, - ip: "127.0.0.1" + ip: '127.0.0.1' )) assert_success response assert_equal 'Successful', response.message @@ -45,7 +45,7 @@ def test_successful_purchase_without_billing_address end def test_successful_purchase_with_descriptors - response = @gateway.purchase(100, @credit_card, descriptor_name: "TheName", descriptor_city: "Wanaque") + response = @gateway.purchase(100, @credit_card, descriptor_name: 'TheName', descriptor_city: 'Wanaque') assert_success response assert_equal 'Successful', response.message end @@ -60,7 +60,7 @@ def test_successful_authorize_and_capture auth = @gateway.authorize(100, @credit_card, @options) assert_success auth - assert capture = @gateway.capture(100, auth.authorization, {currency: "CAD"}) + assert capture = @gateway.capture(100, auth.authorization, {currency: 'CAD'}) assert_success capture assert_equal 'Successful', capture.message end @@ -101,26 +101,26 @@ def test_successful_refund assert response = @gateway.purchase(100, @credit_card, @options) assert_success response - assert refund = @gateway.refund(100, response.authorization, {currency: "CAD"}) + assert refund = @gateway.refund(100, response.authorization, {currency: 'CAD'}) assert_success refund - assert_equal "Successful", refund.message + assert_equal 'Successful', refund.message end def test_failed_refund assert response = @gateway.purchase(100, @credit_card, @options) assert_success response - assert refund = @gateway.refund(100, '||||', {currency: "CAD"}) + assert refund = @gateway.refund(100, '||||', {currency: 'CAD'}) assert_failure refund end def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Successful", response.message + assert_equal 'Successful', response.message - assert_success response.responses.last, "The void should succeed" - assert_equal "Successful", response.responses.last.params["result"] + assert_success response.responses.last, 'The void should succeed' + assert_equal 'Successful', response.responses.last.params['result'] end def test_failed_verify diff --git a/test/remote/gateways/remote_checkout_v2_test.rb b/test/remote/gateways/remote_checkout_v2_test.rb index c894bd951a1..893347aa7f8 100644 --- a/test/remote/gateways/remote_checkout_v2_test.rb +++ b/test/remote/gateways/remote_checkout_v2_test.rb @@ -13,12 +13,12 @@ def setup order_id: '1', billing_address: address, description: 'Purchase', - email: "longbob.longsen@example.com" + email: 'longbob.longsen@example.com' } @additional_options = @options.merge( card_on_file: true, transaction_indicator: 2, - previous_charge_id: "charge_12312" + previous_charge_id: 'charge_12312' ) end @@ -49,34 +49,34 @@ def test_successful_purchase_includes_avs_result response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal 'Succeeded', response.message - assert_equal 'S', response.avs_result["code"] - assert_equal 'U.S.-issuing bank does not support AVS.', response.avs_result["message"] + assert_equal 'S', response.avs_result['code'] + assert_equal 'U.S.-issuing bank does not support AVS.', response.avs_result['message'] end def test_successful_authorize_includes_avs_result response = @gateway.authorize(@amount, @credit_card, @options) assert_success response assert_equal 'Succeeded', response.message - assert_equal 'S', response.avs_result["code"] - assert_equal 'U.S.-issuing bank does not support AVS.', response.avs_result["message"] + assert_equal 'S', response.avs_result['code'] + assert_equal 'U.S.-issuing bank does not support AVS.', response.avs_result['message'] end def test_successful_purchase_includes_cvv_result response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal 'Succeeded', response.message - assert_equal 'Y', response.cvv_result["code"] + assert_equal 'Y', response.cvv_result['code'] end def test_successful_authorize_includes_cvv_result response = @gateway.authorize(@amount, @credit_card, @options) assert_success response assert_equal 'Succeeded', response.message - assert_equal 'Y', response.cvv_result["code"] + assert_equal 'Y', response.cvv_result['code'] end def test_successful_purchase_with_descriptors - options = @options.merge(descriptor_name: "shop", descriptor_city: "london") + options = @options.merge(descriptor_name: 'shop', descriptor_city: 'london') response = @gateway.purchase(@amount, @credit_card, options) assert_success response assert_equal 'Succeeded', response.message @@ -95,7 +95,7 @@ def test_successful_purchase_without_phone_number end def test_successful_purchase_with_ip - response = @gateway.purchase(@amount, @credit_card, ip: "96.125.185.52") + response = @gateway.purchase(@amount, @credit_card, ip: '96.125.185.52') assert_success response assert_equal 'Succeeded', response.message end diff --git a/test/remote/gateways/remote_citrus_pay_test.rb b/test/remote/gateways/remote_citrus_pay_test.rb index 704d11cf8e0..1acf5ed9a4b 100644 --- a/test/remote/gateways/remote_citrus_pay_test.rb +++ b/test/remote/gateways/remote_citrus_pay_test.rb @@ -22,35 +22,35 @@ def teardown def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_purchase_sans_options assert response = @gateway.purchase(@amount, @credit_card) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_purchase_with_more_options more_options = @options.merge({ - ip: "127.0.0.1", - email: "joe@example.com", + ip: '127.0.0.1', + email: 'joe@example.com', }) assert response = @gateway.purchase(@amount, @credit_card, @options.merge(more_options)) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_adds_3dsecure_id_to_authorize more_options = @options.merge({ - ip: "127.0.0.1", - email: "joe@example.com", - threed_secure_id: "abc123" + ip: '127.0.0.1', + email: 'joe@example.com', + threed_secure_id: 'abc123' }) assert response = @gateway.purchase(@amount, @credit_card, @options.merge(more_options)) - assert_match "No check has been performed for this merchant and 3D Secure Id.", response.message + assert_match 'No check has been performed for this merchant and 3D Secure Id.', response.message end def test_failed_purchase @@ -62,12 +62,12 @@ def test_failed_purchase def test_successful_authorize_and_capture assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^.+\|\d+$), response.authorization assert capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_failed_authorize @@ -82,7 +82,7 @@ def test_successful_refund assert refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "Succeeded", refund.message + assert_equal 'Succeeded', refund.message end def test_successful_void @@ -96,10 +96,10 @@ def test_successful_void def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message - assert_success response.responses.last, "The void should succeed" - assert_equal "SUCCESS", response.responses.last.params["result"] + assert_success response.responses.last, 'The void should succeed' + assert_equal 'SUCCESS', response.responses.last.params['result'] end def test_invalid_login @@ -109,11 +109,11 @@ def test_invalid_login ) response = gateway.authorize(@amount, @credit_card, @options) assert_failure response - assert_equal "ERROR - INVALID_REQUEST - Invalid credentials.", response.message + assert_equal 'ERROR - INVALID_REQUEST - Invalid credentials.', response.message end def test_transcript_scrubbing - card = credit_card("4987654321098769", verification_value: "134") + card = credit_card('4987654321098769', verification_value: '134') transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, card, @options) end diff --git a/test/remote/gateways/remote_clearhaus_test.rb b/test/remote/gateways/remote_clearhaus_test.rb index 006249c9263..9a716294dcb 100644 --- a/test/remote/gateways/remote_clearhaus_test.rb +++ b/test/remote/gateways/remote_clearhaus_test.rb @@ -38,22 +38,22 @@ def test_cleans_whitespace_from_private_key def test_unsuccessful_signing_request credentials = fixtures(:clearhaus_secure) - credentials[:private_key] = "foo" + credentials[:private_key] = 'foo' gateway = ClearhausGateway.new(credentials) assert gateway.options[:private_key] assert auth = gateway.authorize(@amount, @credit_card, @options) assert_failure auth - assert_equal "Neither PUB key nor PRIV key: not enough data", auth.message + assert_equal 'Neither PUB key nor PRIV key: not enough data', auth.message credentials = fixtures(:clearhaus_secure) - credentials[:signing_key] = "foo" + credentials[:signing_key] = 'foo' gateway = ClearhausGateway.new(credentials) assert gateway.options[:signing_key] assert auth = gateway.authorize(@amount, @credit_card, @options) assert_failure auth - assert_equal "invalid signing api-key", auth.message + assert_equal 'invalid signing api-key', auth.message end def test_successful_purchase_without_cvv @@ -66,18 +66,18 @@ def test_successful_purchase_without_cvv end def test_successful_purchase_with_text_on_statement - options = { text_on_statement: "hello" } + options = { text_on_statement: 'hello' } response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) assert_success response - assert_equal response.params["text_on_statement"], "hello" + assert_equal response.params['text_on_statement'], 'hello' assert_equal 'Approved', response.message end def test_successful_purchase_with_more_options options = { order_id: '1', - ip: "127.0.0.1", + ip: '127.0.0.1', } response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) diff --git a/test/remote/gateways/remote_commercegate_test.rb b/test/remote/gateways/remote_commercegate_test.rb index 7077742a19b..3ca37b555c2 100644 --- a/test/remote/gateways/remote_commercegate_test.rb +++ b/test/remote/gateways/remote_commercegate_test.rb @@ -18,24 +18,24 @@ def test_successful_authorize assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response assert_equal response.params['action'], 'AUTH' - assert_equal 'U', response.avs_result["code"] - assert_equal 'M', response.cvv_result["code"] + assert_equal 'U', response.avs_result['code'] + assert_equal 'M', response.cvv_result['code'] end def test_successful_authorize_without_options assert response = @gateway.authorize(@amount, @credit_card) assert_success response assert_equal response.params['action'], 'AUTH' - assert_nil response.avs_result["code"] - assert_equal 'M', response.cvv_result["code"] + assert_nil response.avs_result['code'] + assert_equal 'M', response.cvv_result['code'] end def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal response.params['action'], 'SALE' - assert_equal 'U', response.avs_result["code"] - assert_equal 'M', response.cvv_result["code"] + assert_equal 'U', response.avs_result['code'] + assert_equal 'M', response.cvv_result['code'] end def test_unsuccessful_purchase diff --git a/test/remote/gateways/remote_conekta_test.rb b/test/remote/gateways/remote_conekta_test.rb index ee0d9005d76..c466b8ad74c 100644 --- a/test/remote/gateways/remote_conekta_test.rb +++ b/test/remote/gateways/remote_conekta_test.rb @@ -7,44 +7,44 @@ def setup @amount = 300 @credit_card = ActiveMerchant::Billing::CreditCard.new( - number: "4242424242424242", - verification_value: "183", - month: "01", - year: "2019", - first_name: "Mario F.", - last_name: "Moreno Reyes" + number: '4242424242424242', + verification_value: '183', + month: '01', + year: '2019', + first_name: 'Mario F.', + last_name: 'Moreno Reyes' ) @declined_card = ActiveMerchant::Billing::CreditCard.new( - number: "4000000000000002", - verification_value: "183", - month: "01", - year: "2019", - first_name: "Mario F.", - last_name: "Moreno Reyes" + number: '4000000000000002', + verification_value: '183', + month: '01', + year: '2019', + first_name: 'Mario F.', + last_name: 'Moreno Reyes' ) @options = { - :device_fingerprint => "41l9l92hjco6cuekf0c7dq68v4", + :device_fingerprint => '41l9l92hjco6cuekf0c7dq68v4', description: 'Blue clip', billing_address: { - address1: "Rio Missisipi #123", - address2: "Paris", - city: "Guerrero", - country: "Mexico", - zip: "5555", - name: "Mario Reyes", - phone: "12345678", + address1: 'Rio Missisipi #123', + address2: 'Paris', + city: 'Guerrero', + country: 'Mexico', + zip: '5555', + name: 'Mario Reyes', + phone: '12345678', }, - carrier: "Estafeta", - email: "bob@something.com", + carrier: 'Estafeta', + email: 'bob@something.com', line_items: [{ - name: "Box of Cohiba S1s", - description: "Imported From Mex.", + name: 'Box of Cohiba S1s', + description: 'Imported From Mex.', unit_price: 20000, quantity: 1, - sku: "7500244909", - type: "food" + sku: '7500244909', + type: 'food' }] } end @@ -68,7 +68,7 @@ def test_unsuccessful_purchase def test_successful_refund assert response = @gateway.purchase(@amount, @credit_card, @options) - @options[:order_id] = response.params["id"] + @options[:order_id] = response.params['id'] assert_success response assert_equal nil, response.message @@ -82,7 +82,7 @@ def test_successful_void assert_success response assert_equal nil, response.message - identifier = response.params["id"] + identifier = response.params['id'] assert response = @gateway.void(identifier) assert_success response @@ -94,17 +94,17 @@ def test_unsuccessful_void assert_success response assert_equal nil, response.message - identifier = response.params["id"] + identifier = response.params['id'] assert response = @gateway.void(identifier) assert_failure response - assert_equal "El cargo no existe o no es apto para esta operación.", response.message + assert_equal 'El cargo no existe o no es apto para esta operación.', response.message end def test_unsuccessful_refund - assert response = @gateway.refund(@amount, "1", @options) + assert response = @gateway.refund(@amount, '1', @options) assert_failure response - assert_equal "El recurso no ha sido encontrado.", response.message + assert_equal 'El recurso no ha sido encontrado.', response.message end def test_successful_authorize @@ -129,60 +129,60 @@ def test_successful_capture end def test_unsuccessful_capture - assert response = @gateway.capture(@amount, "1", @options) + assert response = @gateway.capture(@amount, '1', @options) assert_failure response - assert_equal "El recurso no ha sido encontrado.", response.message + assert_equal 'El recurso no ha sido encontrado.', response.message end def test_successful_purchase_passing_more_details more_options = { - customer: "TheCustomerName", + customer: 'TheCustomerName', shipping_address: { - address1: "33 Main Street", - address2: "Apartment 3", - city: "Wanaque", - state: "NJ", - country: "USA", - zip: "01085", + address1: '33 Main Street', + address2: 'Apartment 3', + city: 'Wanaque', + state: 'NJ', + country: 'USA', + zip: '01085', }, line_items: [ { - name: "Box of Cohiba S1s", - description: "Imported From Mex.", + name: 'Box of Cohiba S1s', + description: 'Imported From Mex.', unit_price: 20000, quantity: 1, - sku: "cohb_s1", - type: "other_human_consumption" + sku: 'cohb_s1', + type: 'other_human_consumption' }, { - name: "Basic Toothpicks", - description: "Wooden", + name: 'Basic Toothpicks', + description: 'Wooden', unit_price: 100, quantity: 250, - sku: "tooth_r3", - type: "Extra pointy" + sku: 'tooth_r3', + type: 'Extra pointy' } ] } assert response = @gateway.purchase(@amount, @credit_card, @options.merge(more_options)) assert_success response - assert_equal "Wanaque", response.params['details']['shipment']['address']['city'] - assert_equal "Wooden", response.params['details']['line_items'][-1]['description'] - assert_equal "TheCustomerName", response.params['details']['name'] - assert_equal "Guerrero", response.params['details']['billing_address']['city'] + assert_equal 'Wanaque', response.params['details']['shipment']['address']['city'] + assert_equal 'Wooden', response.params['details']['line_items'][-1]['description'] + assert_equal 'TheCustomerName', response.params['details']['name'] + assert_equal 'Guerrero', response.params['details']['billing_address']['city'] end def test_failed_purchase_with_no_details assert response = @gateway.purchase(@amount, @credit_card, {}) assert_failure response - assert_equal "Falta el correo del comprador.", response.message + assert_equal 'Falta el correo del comprador.', response.message end def test_invalid_key gateway = ConektaGateway.new(key: 'invalid_token') assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Acceso no autorizado.", response.message + assert_equal 'Acceso no autorizado.', response.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_creditcall_test.rb b/test/remote/gateways/remote_creditcall_test.rb index fc599ff8b7a..d84c8695f10 100644 --- a/test/remote/gateways/remote_creditcall_test.rb +++ b/test/remote/gateways/remote_creditcall_test.rb @@ -30,9 +30,9 @@ def test_successful_purchase_sans_options def test_successful_purchase_with_more_options options = { order_id: '1', - ip: "127.0.0.1", - email: "joe@example.com", - manual_type: "cnp" + ip: '127.0.0.1', + email: 'joe@example.com', + manual_type: 'cnp' } response = @gateway.purchase(@amount, @credit_card, options) @@ -144,7 +144,7 @@ def test_successful_verify end def test_failed_verify - @declined_card.number = "" + @declined_card.number = '' response = @gateway.verify(@declined_card, @options) assert_failure response assert_match %r{PAN Must be >= 13 Digits}, response.message diff --git a/test/remote/gateways/remote_credorax_test.rb b/test/remote/gateways/remote_credorax_test.rb index 02937b313ac..52f611fa200 100644 --- a/test/remote/gateways/remote_credorax_test.rb +++ b/test/remote/gateways/remote_credorax_test.rb @@ -5,18 +5,18 @@ def setup @gateway = CredoraxGateway.new(fixtures(:credorax)) @amount = 100 - @credit_card = credit_card('4176661000001015', verification_value: "281", month: "12", year: "2022") - @declined_card = credit_card('4176661000001111', verification_value: "681", month: "12", year: "2022") + @credit_card = credit_card('4176661000001015', verification_value: '281', month: '12', year: '2022') + @declined_card = credit_card('4176661000001111', verification_value: '681', month: '12', year: '2022') @options = { - order_id: "1", - currency: "EUR", + order_id: '1', + currency: 'EUR', billing_address: address, description: 'Store Purchase' } end def test_invalid_login - gateway = CredoraxGateway.new(merchant_id: "", cipher_key: "") + gateway = CredoraxGateway.new(merchant_id: '', cipher_key: '') response = gateway.purchase(@amount, @credit_card, @options) assert_failure response end @@ -24,38 +24,38 @@ def test_invalid_login def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "1", response.params["H9"] - assert_equal "Succeeded", response.message + assert_equal '1', response.params['H9'] + assert_equal 'Succeeded', response.message end def test_successful_purchase_with_extra_options response = @gateway.purchase(@amount, @credit_card, @options.merge(transaction_type: '10')) assert_success response - assert_equal "1", response.params["H9"] - assert_equal "Succeeded", response.message + assert_equal '1', response.params['H9'] + assert_equal 'Succeeded', response.message end def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message + assert_equal 'Transaction not allowed for cardholder', response.message end def test_successful_authorize_and_capture response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert response.authorization capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message + assert_equal 'Transaction not allowed for cardholder', response.message end def test_failed_capture @@ -64,7 +64,7 @@ def test_failed_capture capture = @gateway.capture(0, auth.authorization) assert_failure capture - assert_equal "Invalid amount", capture.message + assert_equal 'Invalid amount', capture.message end def test_successful_purchase_and_void @@ -73,7 +73,7 @@ def test_successful_purchase_and_void void = @gateway.void(response.authorization) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end def test_successful_authorize_and_void @@ -82,28 +82,28 @@ def test_successful_authorize_and_void void = @gateway.void(response.authorization) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end def test_successful_capture_and_void response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert response.authorization capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message void = @gateway.void(capture.authorization) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end def test_failed_void - response = @gateway.void("") + response = @gateway.void('') assert_failure response - assert_equal "Referred to transaction has not been found.", response.message + assert_equal 'Referred to transaction has not been found.', response.message end def test_successful_refund @@ -112,7 +112,7 @@ def test_successful_refund refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "Succeeded", refund.message + assert_equal 'Succeeded', refund.message end def test_successful_refund_and_void @@ -121,41 +121,41 @@ def test_successful_refund_and_void refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "Succeeded", refund.message + assert_equal 'Succeeded', refund.message void = @gateway.void(refund.authorization) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end def test_failed_refund - response = @gateway.refund(nil, "123;123;123") + response = @gateway.refund(nil, '123;123;123') assert_failure response - assert_equal "Referred to transaction has not been found.", response.message + assert_equal 'Referred to transaction has not been found.', response.message end def test_successful_credit response = @gateway.credit(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_credit response = @gateway.credit(0, @declined_card, @options) assert_failure response - assert_equal "Invalid amount", response.message + assert_equal 'Invalid amount', response.message end def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message + assert_equal 'Transaction not allowed for cardholder', response.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_culqi_test.rb b/test/remote/gateways/remote_culqi_test.rb index 1913fd76141..d8241b2aef3 100644 --- a/test/remote/gateways/remote_culqi_test.rb +++ b/test/remote/gateways/remote_culqi_test.rb @@ -1,4 +1,4 @@ -require "test_helper" +require 'test_helper' class RemoteCulqiTest < Test::Unit::TestCase def setup @@ -6,8 +6,8 @@ def setup @gateway = CulqiGateway.new(fixtures(:culqi)) @amount = 1000 - @credit_card = credit_card("4111111111111111") - @declined_card = credit_card("4000300011112220", month: 06, year: 2016) + @credit_card = credit_card('4111111111111111') + @declined_card = credit_card('4000300011112220', month: 06, year: 2016) @options = { order_id: generate_unique_id, @@ -20,7 +20,7 @@ def teardown end def test_invalid_login - gateway = CulqiGateway.new(merchant_id: "", terminal_id: "", secret_key: "") + gateway = CulqiGateway.new(merchant_id: '', terminal_id: '', secret_key: '') response = gateway.purchase(@amount, @credit_card, @options) assert_failure response end @@ -64,7 +64,7 @@ def test_partial_capture end def test_failed_capture - response = @gateway.capture(@amount, "0") + response = @gateway.capture(@amount, '0') assert_failure response assert_match %r{Transaction not found}, response.message end @@ -79,7 +79,7 @@ def test_successful_void end def test_failed_void - response = @gateway.void("0", @options) + response = @gateway.void('0', @options) assert_failure response assert_match %r{Transaction not found}, response.message end @@ -103,7 +103,7 @@ def test_partial_refund end def test_failed_refund - response = @gateway.refund(@amount, "0") + response = @gateway.refund(@amount, '0') assert_failure response assert_match %r{Transaction not found}, response.message end @@ -130,7 +130,7 @@ def test_verify_credentials end def test_successful_store_and_purchase - credit_card = credit_card("4929927409600297") + credit_card = credit_card('4929927409600297') response = @gateway.store(credit_card, @options.merge(partner_id: fixtures(:culqi)[:partner_id])) assert_success response @@ -146,7 +146,7 @@ def test_successful_store_and_purchase end def test_failed_store - credit_card = credit_card("4929927409600297") + credit_card = credit_card('4929927409600297') store = @gateway.store(credit_card, @options.merge(partner_id: fixtures(:culqi)[:partner_id])) assert_success store diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb index 3535e079938..106a3cf3a0d 100644 --- a/test/remote/gateways/remote_cyber_source_test.rb +++ b/test/remote/gateways/remote_cyber_source_test.rb @@ -4,26 +4,26 @@ class RemoteCyberSourceTest < Test::Unit::TestCase def setup Base.mode = :test - @gateway = CyberSourceGateway.new({nexus: "NC"}.merge(fixtures(:cyber_source))) + @gateway = CyberSourceGateway.new({nexus: 'NC'}.merge(fixtures(:cyber_source))) @credit_card = credit_card('4111111111111111', verification_value: '321') @declined_card = credit_card('801111111111111') @pinless_debit_card = credit_card('4002269999999999') @three_ds_unenrolled_card = credit_card('4000000000000051', verification_value: '321', - month: "12", + month: '12', year: "#{Time.now.year + 2}", brand: :visa ) @three_ds_enrolled_card = credit_card('4000000000000002', verification_value: '321', - month: "12", + month: '12', year: "#{Time.now.year + 2}", brand: :visa ) @three_ds_invalid_card = credit_card('4000000000000010', verification_value: '321', - month: "12", + month: '12', year: "#{Time.now.year + 2}", brand: :visa ) @@ -56,7 +56,7 @@ def setup :order_id => generate_unique_id, :credit_card => @credit_card, :subscription => { - :frequency => "weekly", + :frequency => 'weekly', :start_date => Date.today.next_week, :occurrences => 4, :auto_renew => true, @@ -79,8 +79,8 @@ def test_transcript_scrubbing def test_network_tokenization_transcript_scrubbing credit_card = network_tokenization_credit_card('4111111111111111', :brand => 'visa', - :eci => "05", - :payment_cryptogram => "EHuWW9PiBkWvqE5juRwDzAUFBAk=" + :eci => '05', + :payment_cryptogram => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=' ) transcript = capture_transcript(@gateway) do @@ -132,7 +132,7 @@ def test_successful_tax_calculation assert response = @gateway.calculate_tax(@credit_card, @options) assert_equal 'Successful transaction', response.message assert response.params['totalTaxAmount'] - assert_not_equal "0", response.params['totalTaxAmount'] + assert_not_equal '0', response.params['totalTaxAmount'] assert_success response end @@ -158,7 +158,7 @@ def test_successful_purchase_with_billing_address_override end def test_successful_purchase_with_long_country_name - @options[:billing_address] = address(country: "united states", state: "NC") + @options[:billing_address] = address(country: 'united states', state: 'NC') assert response = @gateway.purchase(@amount, @credit_card, @options) assert_equal 'Successful transaction', response.message assert_success response @@ -209,12 +209,12 @@ def test_successful_authorization_and_failed_capture assert capture = @gateway.capture(@amount + 10, auth.authorization, @options) assert_failure capture - assert_equal "The requested amount exceeds the originally authorized amount", capture.message + assert_equal 'The requested amount exceeds the originally authorized amount', capture.message end def test_failed_capture_bad_auth_info assert auth = @gateway.authorize(@amount, @credit_card, @options) - assert capture = @gateway.capture(@amount, "a;b;c", @options) + assert capture = @gateway.capture(@amount, 'a;b;c', @options) assert_failure capture end @@ -238,15 +238,15 @@ def test_successful_refund def test_successful_validate_pinless_debit_card assert response = @gateway.validate_pinless_debit_card(@pinless_debit_card, @options) assert response.test? - assert_equal 'Y', response.params["status"] + assert_equal 'Y', response.params['status'] assert_equal true, response.success? end def test_network_tokenization_authorize_and_capture credit_card = network_tokenization_credit_card('4111111111111111', :brand => 'visa', - :eci => "05", - :payment_cryptogram => "EHuWW9PiBkWvqE5juRwDzAUFBAk=" + :eci => '05', + :payment_cryptogram => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=' ) assert auth = @gateway.authorize(@amount, credit_card, @options) @@ -271,7 +271,7 @@ def test_successful_purchase_with_mdd_fields def test_successful_authorize_with_nonfractional_currency assert response = @gateway.authorize(100, @credit_card, @options.merge(:currency => 'JPY')) - assert_equal "1", response.params['amount'] + assert_equal '1', response.params['amount'] assert_success response end @@ -332,7 +332,7 @@ def test_successful_create_subscription_with_monthly_options response = @gateway.store(@credit_card, @subscription_options.merge(:setup_fee => 99.0, :subscription => {:amount => 49.0, :automatic_renew => false, frequency: 'monthly'})) assert_equal 'Successful transaction', response.message response = @gateway.retrieve(response.authorization, order_id: @subscription_options[:order_id]) - assert_equal "0.49", response.params['recurringAmount'] + assert_equal '0.49', response.params['recurringAmount'] assert_equal 'monthly', response.params['frequency'] end @@ -383,19 +383,19 @@ def test_successful_retrieve_subscription def test_3ds_enroll_request_via_purchase assert response = @gateway.purchase(1202, @three_ds_enrolled_card, @options.merge(payer_auth_enroll_service: true)) - assert_equal "475", response.params["reasonCode"] - assert !response.params["acsURL"].blank? - assert !response.params["paReq"].blank? - assert !response.params["xid"].blank? + assert_equal '475', response.params['reasonCode'] + assert !response.params['acsURL'].blank? + assert !response.params['paReq'].blank? + assert !response.params['xid'].blank? assert !response.success? end def test_3ds_enroll_request_via_authorize assert response = @gateway.authorize(1202, @three_ds_enrolled_card, @options.merge(payer_auth_enroll_service: true)) - assert_equal "475", response.params["reasonCode"] - assert !response.params["acsURL"].blank? - assert !response.params["paReq"].blank? - assert !response.params["xid"].blank? + assert_equal '475', response.params['reasonCode'] + assert !response.params['acsURL'].blank? + assert !response.params['paReq'].blank? + assert !response.params['xid'].blank? assert !response.success? end @@ -409,27 +409,27 @@ def test_successful_3ds_requests_with_unenrolled_card def test_successful_3ds_validate_purchase_request assert response = @gateway.purchase(1202, @three_ds_enrolled_card, @options.merge(payer_auth_validate_service: true, pares: pares)) - assert_equal "100", response.params["reasonCode"] - assert_equal "0", response.params["authenticationResult"] + assert_equal '100', response.params['reasonCode'] + assert_equal '0', response.params['authenticationResult'] assert response.success? end def test_failed_3ds_validate_purchase_request assert response = @gateway.purchase(1202, @three_ds_invalid_card, @options.merge(payer_auth_validate_service: true, pares: pares)) - assert_equal "476", response.params["reasonCode"] + assert_equal '476', response.params['reasonCode'] assert !response.success? end def test_successful_3ds_validate_authorize_request assert response = @gateway.authorize(1202, @three_ds_enrolled_card, @options.merge(payer_auth_validate_service: true, pares: pares)) - assert_equal "100", response.params["reasonCode"] - assert_equal "0", response.params["authenticationResult"] + assert_equal '100', response.params['reasonCode'] + assert_equal '0', response.params['authenticationResult'] assert response.success? end def test_failed_3ds_validate_authorize_request assert response = @gateway.authorize(1202, @three_ds_invalid_card, @options.merge(payer_auth_validate_service: true, pares: pares)) - assert_equal "476", response.params["reasonCode"] + assert_equal '476', response.params['reasonCode'] assert !response.success? end @@ -442,7 +442,7 @@ def pares def test_verify_credentials assert @gateway.verify_credentials - gateway = CyberSourceGateway.new(login: "an_unknown_login", password: "unknown_password") + gateway = CyberSourceGateway.new(login: 'an_unknown_login', password: 'unknown_password') assert !gateway.verify_credentials end diff --git a/test/remote/gateways/remote_dibs_test.rb b/test/remote/gateways/remote_dibs_test.rb index 532be65a61a..1e6b16e36b1 100644 --- a/test/remote/gateways/remote_dibs_test.rb +++ b/test/remote/gateways/remote_dibs_test.rb @@ -12,9 +12,9 @@ def setup } @amount = 100 - @credit_card = credit_card("4711100000000000", cc_options) - @declined_card_auth = credit_card("4711000000000000", cc_options) - @declined_card_capture = credit_card("4711100000000001", cc_options) + @credit_card = credit_card('4711100000000000', cc_options) + @declined_card_auth = credit_card('4711000000000000', cc_options) + @declined_card_capture = credit_card('4711100000000001', cc_options) @options = { order_id: generate_unique_id @@ -23,8 +23,8 @@ def setup def test_invalid_login gateway = DibsGateway.new( - merchant_id: "123456789", - secret_key: "987654321" + merchant_id: '123456789', + secret_key: '987654321' ) response = gateway.authorize(@amount, @credit_card, @options) assert_failure response @@ -33,7 +33,7 @@ def test_invalid_login def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_purchase @@ -45,19 +45,19 @@ def test_failed_purchase def test_successful_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^\d+$), response.authorization end def test_successful_authorize_and_capture response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^\d+$), response.authorization capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_failed_authorize @@ -69,7 +69,7 @@ def test_failed_authorize def test_successful_authorize_and_failed_capture response = @gateway.authorize(@amount, @declined_card_capture, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^\d+$), response.authorization capture = @gateway.capture(@amount, response.authorization) @@ -78,7 +78,7 @@ def test_successful_authorize_and_failed_capture end def test_failed_capture - response = @gateway.capture(@amount, "") + response = @gateway.capture(@amount, '') assert_failure response assert_match %r(ERROR.+), response.message end @@ -89,7 +89,7 @@ def test_successful_void void = @gateway.void(response.authorization) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message capture = @gateway.capture(@amount, response.authorization) assert_failure capture @@ -97,7 +97,7 @@ def test_successful_void end def test_failed_void - response = @gateway.void("") + response = @gateway.void('') assert_failure response assert_match %r(ERROR.+), response.message end @@ -107,11 +107,11 @@ def test_successful_refund assert_success response refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "Succeeded", refund.message + assert_equal 'Succeeded', refund.message end def test_failed_refund - response = @gateway.refund(nil, "") + response = @gateway.refund(nil, '') assert_failure response assert_match %r(ERROR.+), response.message end @@ -131,7 +131,7 @@ def test_failed_verify def test_successful_store response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_not_nil response.params['ticketId'] assert_not_nil response.authorization assert_equal response.params['ticketId'], response.authorization @@ -149,7 +149,7 @@ def test_successful_authorize_with_stored_card assert_not_nil response.authorization response = @gateway.authorize(@amount, response.authorization, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^\d+$), response.authorization end @@ -159,12 +159,12 @@ def test_successful_authorize_and_capture_with_stored_card assert_not_nil response.authorization response = @gateway.authorize(@amount, response.authorization, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^\d+$), response.authorization capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_digitzs_test.rb b/test/remote/gateways/remote_digitzs_test.rb index 1074d1556f1..285dd840f9d 100644 --- a/test/remote/gateways/remote_digitzs_test.rb +++ b/test/remote/gateways/remote_digitzs_test.rb @@ -54,14 +54,14 @@ def test_successful_token_split_purchase response = @gateway.purchase(@amount, store.authorization, @options_token_split) assert_success response assert_equal 'Success', response.message - assert response.params["data"]["attributes"]["split"]["splitId"] + assert response.params['data']['attributes']['split']['splitId'] end def test_successful_card_split_purchase response = @gateway.purchase(@amount, @credit_card, @options_card_split) assert_success response assert_equal 'Success', response.message - assert response.params["data"]["attributes"]["split"]["splitId"] + assert response.params['data']['attributes']['split']['splitId'] end def test_failed_purchase @@ -104,12 +104,12 @@ def test_successful_store_without_billing_address end def test_store_adds_card_to_existing_customer - assert response = @gateway.store(@credit_card, @options.merge({customer_id: "spreedly-susanswidg-32268973-2091076-148408385-5980208887457495-148700575"})) + assert response = @gateway.store(@credit_card, @options.merge({customer_id: 'spreedly-susanswidg-32268973-2091076-148408385-5980208887457495-148700575'})) assert_success response end def test_store_creates_new_customer_and_adds_card - assert response = @gateway.store(@credit_card, @options.merge({customer_id: "nonexistant"})) + assert response = @gateway.store(@credit_card, @options.merge({customer_id: 'nonexistant'})) assert_success response end diff --git a/test/remote/gateways/remote_ebanx_test.rb b/test/remote/gateways/remote_ebanx_test.rb index 8c8232d24f5..d1035d9b62b 100644 --- a/test/remote/gateways/remote_ebanx_test.rb +++ b/test/remote/gateways/remote_ebanx_test.rb @@ -17,7 +17,7 @@ def setup phone_number: '8522847035' }), order_id: generate_unique_id, - document: "853.513.468-93" + document: '853.513.468-93' } end @@ -30,9 +30,9 @@ def test_successful_purchase def test_successful_purchase_with_more_options options = @options.merge({ order_id: generate_unique_id, - ip: "127.0.0.1", - email: "joe@example.com", - birth_date: "10/11/1980", + ip: '127.0.0.1', + email: 'joe@example.com', + birth_date: '10/11/1980', person_type: 'personal' }) @@ -42,11 +42,11 @@ def test_successful_purchase_with_more_options end def test_successful_purchase_as_brazil_business_with_responsible_fields - options = @options.update(document: "32593371000110", + options = @options.update(document: '32593371000110', person_type: 'business', responsible_name: 'Business Person', responsible_document: '32593371000111', - responsible_birth_date: "1/11/1975") + responsible_birth_date: '1/11/1975') response = @gateway.purchase(@amount, @credit_card, options) assert_success response @@ -56,9 +56,9 @@ def test_successful_purchase_as_brazil_business_with_responsible_fields def test_successful_purchase_as_colombian options = @options.merge({ order_id: generate_unique_id, - ip: "127.0.0.1", - email: "jose@example.com.co", - birth_date: "10/11/1980", + ip: '127.0.0.1', + email: 'jose@example.com.co', + birth_date: '10/11/1980', billing_address: address({ address1: '1040 Rua E', city: 'Medellín', @@ -116,7 +116,7 @@ def test_successful_refund purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase - refund_options = @options.merge({description: "full refund"}) + refund_options = @options.merge({description: 'full refund'}) assert refund = @gateway.refund(@amount, purchase.authorization, refund_options) assert_success refund assert_equal 'Accepted', refund.message @@ -126,7 +126,7 @@ def test_partial_refund purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase - refund_options = @options.merge(description: "refund due to returned item") + refund_options = @options.merge(description: 'refund due to returned item') assert refund = @gateway.refund(@amount-1, purchase.authorization, refund_options) assert_success refund end @@ -162,11 +162,11 @@ def test_successful_store_and_purchase end def test_successful_store_and_purchase_as_brazil_business - options = @options.update(document: "32593371000110", + options = @options.update(document: '32593371000110', person_type: 'business', responsible_name: 'Business Person', responsible_document: '32593371000111', - responsible_birth_date: "1/11/1975") + responsible_birth_date: '1/11/1975') store = @gateway.store(@credit_card, options) assert_success store diff --git a/test/remote/gateways/remote_elavon_test.rb b/test/remote/gateways/remote_elavon_test.rb index 866fcd21eb6..63d07da8491 100644 --- a/test/remote/gateways/remote_elavon_test.rb +++ b/test/remote/gateways/remote_elavon_test.rb @@ -8,7 +8,7 @@ def setup @bad_credit_card = credit_card('invalid') @options = { - :email => "paul@domain.com", + :email => 'paul@domain.com', :description => 'Test Transaction', :billing_address => address, :ip => '203.0.113.0' @@ -68,8 +68,8 @@ def test_unsuccessful_authorization def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "APPROVAL", response.message - assert_success response.responses.last, "The void should succeed" + assert_equal 'APPROVAL', response.message + assert_success response.responses.last, 'The void should succeed' end def test_failed_verify @@ -160,13 +160,13 @@ def test_successful_store_with_verify_true def test_unsuccessful_store assert response = @gateway.store(@bad_credit_card, @options) assert_failure response - assert_equal "The Credit Card Number supplied in the authorization request appears to be invalid.", response.message + assert_equal 'The Credit Card Number supplied in the authorization request appears to be invalid.', response.message assert response.test? end def test_successful_update store_response = @gateway.store(@credit_card, @options) - token = store_response.params["token"] + token = store_response.params['token'] credit_card = credit_card('4124939999999990', :month => 10) assert response = @gateway.update(token, credit_card, @options) assert_success response @@ -182,7 +182,7 @@ def test_unsuccessful_update def test_successful_purchase_with_token store_response = @gateway.store(@credit_card, @options) - token = store_response.params["token"] + token = store_response.params['token'] assert response = @gateway.purchase(@amount, token, @options) assert_success response assert response.test? @@ -197,7 +197,7 @@ def test_failed_purchase_with_token end def test_successful_purchase_with_custom_fields - assert response = @gateway.purchase(@amount, @credit_card, @options.merge(custom_fields: {a_key: "a value"})) + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(custom_fields: {a_key: 'a value'})) assert_success response assert response.test? diff --git a/test/remote/gateways/remote_element_test.rb b/test/remote/gateways/remote_element_test.rb index b6a1da7a1b6..4cc1b565471 100644 --- a/test/remote/gateways/remote_element_test.rb +++ b/test/remote/gateways/remote_element_test.rb @@ -18,8 +18,8 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal 'Approved', response.message - assert_match %r{Street address and postal code do not match}, response.avs_result["message"] - assert_match %r{CVV matches}, response.cvv_result["message"] + assert_match %r{Street address and postal code do not match}, response.avs_result['message'] + assert_match %r{CVV matches}, response.cvv_result['message'] end def test_failed_purchase @@ -45,7 +45,7 @@ def test_successful_purchase_with_payment_account_token end def test_successful_purchase_with_shipping_address - response = @gateway.purchase(@amount, @credit_card, @options.merge(shipping_address: address(address1: "Shipping"))) + response = @gateway.purchase(@amount, @credit_card, @options.merge(shipping_address: address(address1: 'Shipping'))) assert_success response assert_equal 'Approved', response.message end diff --git a/test/remote/gateways/remote_eway_managed_test.rb b/test/remote/gateways/remote_eway_managed_test.rb index f4914ac6eff..1322e32676c 100644 --- a/test/remote/gateways/remote_eway_managed_test.rb +++ b/test/remote/gateways/remote_eway_managed_test.rb @@ -21,7 +21,7 @@ def setup def test_successful_purchase assert response = @gateway.purchase(@amount, @valid_customer_id, @options) - assert_equal "00,Transaction Approved(Test Gateway)", response.message + assert_equal '00,Transaction Approved(Test Gateway)', response.message assert_success response assert response.test? assert_not_nil response.authorization @@ -41,7 +41,7 @@ def test_invalid_login def test_store_credit_card assert response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "OK", response.message + assert_equal 'OK', response.message assert !response.token.blank? assert_not_nil response.token end @@ -49,7 +49,7 @@ def test_store_credit_card def test_update_credit_card assert response = @gateway.update(@valid_customer_id, @credit_card, @options) assert_success response - assert_equal "OK", response.message + assert_equal 'OK', response.message assert response.token.blank? end @@ -64,7 +64,7 @@ def test_store_invalid_credit_card def test_retrieve assert response = @gateway.retrieve(@valid_customer_id) assert_success response - assert_equal "OK", response.message + assert_equal 'OK', response.message assert response.test? end end diff --git a/test/remote/gateways/remote_eway_rapid_test.rb b/test/remote/gateways/remote_eway_rapid_test.rb index 733fef285d1..edf59a27625 100644 --- a/test/remote/gateways/remote_eway_rapid_test.rb +++ b/test/remote/gateways/remote_eway_rapid_test.rb @@ -6,60 +6,60 @@ def setup @amount = 100 @failed_amount = -100 - @credit_card = credit_card("4444333322221111") + @credit_card = credit_card('4444333322221111') @options = { - order_id: "1", - invoice: "I1234", + order_id: '1', + invoice: 'I1234', billing_address: address, - description: "Store Purchase", - redirect_url: "http://bogus.com" + description: 'Store Purchase', + redirect_url: 'http://bogus.com' } end def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message end def test_fully_loaded_purchase response = @gateway.purchase(@amount, @credit_card, - redirect_url: "http://awesomesauce.com", - ip: "0.0.0.0", - application_id: "Woohoo", - partner_id: "Woohoo", - transaction_type: "Purchase", - description: "Description", - order_id: "orderid1", - invoice: "I1234", - currency: "AUD", - email: "jim@example.com", + redirect_url: 'http://awesomesauce.com', + ip: '0.0.0.0', + application_id: 'Woohoo', + partner_id: 'Woohoo', + transaction_type: 'Purchase', + description: 'Description', + order_id: 'orderid1', + invoice: 'I1234', + currency: 'AUD', + email: 'jim@example.com', billing_address: { - title: "Mr.", - name: "Jim Awesome Smith", - company: "Awesome Co", - address1: "1234 My Street", - address2: "Apt 1", - city: "Ottawa", - state: "ON", - zip: "K1C2N6", - country: "CA", - phone: "(555)555-5555", - fax: "(555)555-6666" + title: 'Mr.', + name: 'Jim Awesome Smith', + company: 'Awesome Co', + address1: '1234 My Street', + address2: 'Apt 1', + city: 'Ottawa', + state: 'ON', + zip: 'K1C2N6', + country: 'CA', + phone: '(555)555-5555', + fax: '(555)555-6666' }, shipping_address: { - title: "Ms.", - name: "Baker", - company: "Elsewhere Inc.", - address1: "4321 Their St.", - address2: "Apt 2", - city: "Chicago", - state: "IL", - zip: "60625", - country: "US", - phone: "1115555555", - fax: "1115556666" + title: 'Ms.', + name: 'Baker', + company: 'Elsewhere Inc.', + address1: '4321 Their St.', + address2: 'Apt 2', + city: 'Chicago', + state: 'IL', + zip: '60625', + country: 'US', + phone: '1115555555', + fax: '1115556666' } ) assert_success response @@ -67,38 +67,38 @@ def test_fully_loaded_purchase def test_successful_purchase_with_overly_long_fields options = { - order_id: "OrderId must be less than 50 characters otherwise it fails", - invoice: "Max 12 chars", - description: "EWay Rapid transactions fail if the description is more than 64 characters.", + order_id: 'OrderId must be less than 50 characters otherwise it fails', + invoice: 'Max 12 chars', + description: 'EWay Rapid transactions fail if the description is more than 64 characters.', billing_address: { - address1: "The Billing Address 1 Cannot Be More Than Fifty Characters.", - address2: "The Billing Address 2 Cannot Be More Than Fifty Characters.", - city: "TheCityCannotBeMoreThanFiftyCharactersOrItAllFallsApart", + address1: 'The Billing Address 1 Cannot Be More Than Fifty Characters.', + address2: 'The Billing Address 2 Cannot Be More Than Fifty Characters.', + city: 'TheCityCannotBeMoreThanFiftyCharactersOrItAllFallsApart', }, shipping_address: { - address1: "The Shipping Address 1 Cannot Be More Than Fifty Characters.", - address2: "The Shipping Address 2 Cannot Be More Than Fifty Characters.", - city: "TheCityCannotBeMoreThanFiftyCharactersOrItAllFallsApart", + address1: 'The Shipping Address 1 Cannot Be More Than Fifty Characters.', + address2: 'The Shipping Address 2 Cannot Be More Than Fifty Characters.', + city: 'TheCityCannotBeMoreThanFiftyCharactersOrItAllFallsApart', } } - @credit_card.first_name = "FullNameOnACardMustBeLessThanFiftyCharacters" - @credit_card.last_name = "LastName" + @credit_card.first_name = 'FullNameOnACardMustBeLessThanFiftyCharacters' + @credit_card.last_name = 'LastName' response = @gateway.purchase(@amount, @credit_card, options) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message end def test_failed_purchase response = @gateway.purchase(@failed_amount, @credit_card, @options) assert_failure response - assert_equal "Invalid Payment TotalAmount", response.message + assert_equal 'Invalid Payment TotalAmount', response.message end def test_successful_authorize_and_capture authorize = @gateway.authorize(@amount, @credit_card, @options) assert_success authorize - assert_equal "Transaction Approved Successful", authorize.message + assert_equal 'Transaction Approved Successful', authorize.message capture = @gateway.capture(nil, authorize.authorization) assert_success capture @@ -107,13 +107,13 @@ def test_successful_authorize_and_capture def test_failed_authorize response = @gateway.authorize(@failed_amount, @credit_card, @options) assert_failure response - assert_equal "Error Failed", response.message + assert_equal 'Error Failed', response.message end def test_failed_capture - response = @gateway.capture(@amount, "bogus") + response = @gateway.capture(@amount, 'bogus') assert_failure response - assert_equal "Invalid Auth Transaction ID for Capture/Void", response.message + assert_equal 'Invalid Auth Transaction ID for Capture/Void', response.message end def test_successful_void @@ -125,68 +125,68 @@ def test_successful_void end def test_failed_void - response = @gateway.void("bogus") + response = @gateway.void('bogus') assert_failure response - assert_equal "Invalid Auth Transaction ID for Capture/Void", response.message + assert_equal 'Invalid Auth Transaction ID for Capture/Void', response.message end def test_successful_refund response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message response = @gateway.refund(@amount, response.authorization, @options) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message end def test_failed_refund response = @gateway.refund(@amount, 'fakeid', @options) assert_failure response - assert_equal "Invalid DirectRefundRequest, Transaction ID", response.message + assert_equal 'Invalid DirectRefundRequest, Transaction ID', response.message end def test_successful_store response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message end def test_failed_store @options[:billing_address].merge!(country: nil) response = @gateway.store(@credit_card, @options) assert_failure response - assert_equal "V6044", response.params["Errors"] - assert_equal "Customer CountryCode Required", response.message + assert_equal 'V6044', response.params['Errors'] + assert_equal 'Customer CountryCode Required', response.message end def test_successful_update response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message response = @gateway.update(response.authorization, @credit_card, @options) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message end def test_successful_store_purchase response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message response = @gateway.purchase(@amount, response.authorization, transaction_type: 'MOTO') assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message end def test_invalid_login gateway = EwayRapidGateway.new( - login: "bogus", - password: "bogus" + login: 'bogus', + password: 'bogus' ) response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Unauthorized", response.message + assert_equal 'Unauthorized', response.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_eway_test.rb b/test/remote/gateways/remote_eway_test.rb index eaedc481950..693a51282e5 100644 --- a/test/remote/gateways/remote_eway_test.rb +++ b/test/remote/gateways/remote_eway_test.rb @@ -26,7 +26,7 @@ def test_invalid_amount assert response = @gateway.purchase(101, @credit_card_success, @params) assert_failure response assert response.test? - assert_equal EwayGateway::MESSAGES["01"], response.message + assert_equal EwayGateway::MESSAGES['01'], response.message end def test_purchase_success_with_verification_value @@ -34,7 +34,7 @@ def test_purchase_success_with_verification_value assert response.authorization assert_success response assert response.test? - assert_equal EwayGateway::MESSAGES["00"], response.message + assert_equal EwayGateway::MESSAGES['00'], response.message end def test_purchase_success_without_verification_value @@ -44,7 +44,7 @@ def test_purchase_success_without_verification_value assert response.authorization assert_success response assert response.test? - assert_equal EwayGateway::MESSAGES["00"], response.message + assert_equal EwayGateway::MESSAGES['00'], response.message end def test_purchase_error @@ -72,7 +72,7 @@ def test_failed_refund end def test_transcript_scrubbing - @credit_card_success.verification_value = "431" + @credit_card_success.verification_value = '431' transcript = capture_transcript(@gateway) do @gateway.purchase(100, @credit_card_success, @params) end diff --git a/test/remote/gateways/remote_exact_test.rb b/test/remote/gateways/remote_exact_test.rb index 455b495bd7f..879c7b3aa42 100644 --- a/test/remote/gateways/remote_exact_test.rb +++ b/test/remote/gateways/remote_exact_test.rb @@ -49,8 +49,8 @@ def test_failed_capture end def test_invalid_login - gateway = ExactGateway.new( :login => "NotARealUser", - :password => "NotARealPassword" ) + gateway = ExactGateway.new( :login => 'NotARealUser', + :password => 'NotARealPassword' ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_match %r{^Invalid Login}, response.message assert_failure response diff --git a/test/remote/gateways/remote_ezic_test.rb b/test/remote/gateways/remote_ezic_test.rb index ac5d7dc955a..e2051de0ad3 100644 --- a/test/remote/gateways/remote_ezic_test.rb +++ b/test/remote/gateways/remote_ezic_test.rb @@ -18,13 +18,13 @@ def setup def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "TEST APPROVED", response.message + assert_equal 'TEST APPROVED', response.message end def test_failed_purchase response = @gateway.purchase(@failed_amount, @credit_card, @options) assert_failure response - assert_equal "TEST DECLINED", response.message + assert_equal 'TEST DECLINED', response.message end def test_successful_authorize_and_capture @@ -33,13 +33,13 @@ def test_successful_authorize_and_capture assert capture = @gateway.capture(@amount, auth.authorization) assert_success capture - assert_equal "TEST CAPTURED", capture.message + assert_equal 'TEST CAPTURED', capture.message end def test_failed_authorize response = @gateway.authorize(@failed_amount, @credit_card, @options) assert_failure response - assert_equal "TEST DECLINED", response.message + assert_equal 'TEST DECLINED', response.message end def test_failed_capture @@ -57,7 +57,7 @@ def test_successful_refund assert refund = @gateway.refund(@amount, purchase.authorization) assert_success refund - assert_equal "TEST RETURNED", refund.message + assert_equal 'TEST RETURNED', refund.message end def test_partial_refund @@ -66,8 +66,8 @@ def test_partial_refund assert refund = @gateway.refund(@amount-1, purchase.authorization) assert_success refund - assert_equal "TEST RETURNED", refund.message - assert_equal "-0.99", refund.params["settle_amount"] + assert_equal 'TEST RETURNED', refund.message + assert_equal '-0.99', refund.params['settle_amount'] end def test_failed_refund @@ -85,17 +85,17 @@ def test_failed_void assert void = @gateway.void(authorize.authorization) assert_failure void - assert_equal "Processor/Network Error", void.message + assert_equal 'Processor/Network Error', void.message end def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "TEST APPROVED", response.message + assert_equal 'TEST APPROVED', response.message end def test_failed_verify - response = @gateway.verify(credit_card(""), @options) + response = @gateway.verify(credit_card(''), @options) assert_failure response assert_match %r{Missing card or check number}, response.message end diff --git a/test/remote/gateways/remote_fat_zebra_test.rb b/test/remote/gateways/remote_fat_zebra_test.rb index 8dbe064d0ec..0f75fcdac91 100644 --- a/test/remote/gateways/remote_fat_zebra_test.rb +++ b/test/remote/gateways/remote_fat_zebra_test.rb @@ -10,7 +10,7 @@ def setup @options = { :order_id => rand(100000).to_s, - :ip => "1.2.3.4" + :ip => '1.2.3.4' } end diff --git a/test/remote/gateways/remote_federated_canada_test.rb b/test/remote/gateways/remote_federated_canada_test.rb index 9b3ebcb2512..3b48d1795af 100644 --- a/test/remote/gateways/remote_federated_canada_test.rb +++ b/test/remote/gateways/remote_federated_canada_test.rb @@ -24,54 +24,54 @@ def test_gateway_should_exist def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message end def test_unsuccessful_purchase assert response = @gateway.purchase(@declined_amount, @credit_card, @options) assert_failure response - assert_equal "Transaction Declined", response.message + assert_equal 'Transaction Declined', response.message end def test_successful_authorization assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message end def test_failed_capture assert response = @gateway.capture(@amount, '') assert_failure response - assert_equal "Error in transaction data or system error", response.message + assert_equal 'Error in transaction data or system error', response.message end def test_purchase_and_refund assert auth = @gateway.purchase(@amount, @credit_card, @options) assert_success auth - assert_equal "Transaction Approved", auth.message + assert_equal 'Transaction Approved', auth.message assert auth.authorization assert capture = @gateway.refund(@amount, auth.authorization) - assert_equal "Transaction Approved", capture.message + assert_equal 'Transaction Approved', capture.message assert_success capture end def test_authorize_and_void assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert_equal "Transaction Approved", auth.message + assert_equal 'Transaction Approved', auth.message assert auth.authorization assert capture = @gateway.void(auth.authorization) - assert_equal "Transaction Approved", capture.message + assert_equal 'Transaction Approved', capture.message assert_success capture end def test_authorize_and_capture assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert_equal "Transaction Approved", auth.message + assert_equal 'Transaction Approved', auth.message assert auth.authorization assert capture = @gateway.capture(@amount, auth.authorization) - assert_equal "Transaction Approved", capture.message + assert_equal 'Transaction Approved', capture.message assert_success capture end @@ -82,6 +82,6 @@ def test_invalid_login ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Error in transaction data or system error", response.message + assert_equal 'Error in transaction data or system error', response.message end end diff --git a/test/remote/gateways/remote_finansbank_test.rb b/test/remote/gateways/remote_finansbank_test.rb index 9338e31fd10..a59bac99a27 100644 --- a/test/remote/gateways/remote_finansbank_test.rb +++ b/test/remote/gateways/remote_finansbank_test.rb @@ -75,7 +75,7 @@ def test_unsuccessful_refund assert_failure void assert_nil void.params['order_id'] assert_equal 'Declined (Reason: 99 - Net miktardan fazlasi iade edilemez.)', void.message - assert_equal "CORE-2503", void.params['errorcode'] + assert_equal 'CORE-2503', void.params['errorcode'] end def test_void @@ -95,6 +95,6 @@ def test_invalid_login assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response assert_equal 'Declined (Reason: 99 - System based initialization problem. Please try again later.)', response.message - assert_equal "2100", response.params['errorcode'] + assert_equal '2100', response.params['errorcode'] end end diff --git a/test/remote/gateways/remote_first_giving_test.rb b/test/remote/gateways/remote_first_giving_test.rb index 1038c0bb9c6..f884bcc8c04 100644 --- a/test/remote/gateways/remote_first_giving_test.rb +++ b/test/remote/gateways/remote_first_giving_test.rb @@ -7,26 +7,26 @@ def setup @gateway = FirstGivingGateway.new(fixtures(:first_giving)) @amount = 100 - @credit_card = credit_card("4457010000000009") - @declined_card = credit_card("445701000000000") + @credit_card = credit_card('4457010000000009') + @declined_card = credit_card('445701000000000') @options = { - billing_address: address(state: "MA", zip: "01803", country: "US"), - ip: "127.0.0.1" + billing_address: address(state: 'MA', zip: '01803', country: 'US'), + ip: '127.0.0.1' } end def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message end def test_failed_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response assert_equal( - "Unfortunately, we were unable to perform credit card number validation. The credit card number validator responded with the following message ccNumber failed data validation for the following reasons : creditcardLength: 445701000000000 contains an invalid amount of digits.", + 'Unfortunately, we were unable to perform credit card number validation. The credit card number validator responded with the following message ccNumber failed data validation for the following reasons : creditcardLength: 445701000000000 contains an invalid amount of digits.', response.message, response.params.inspect ) @@ -37,23 +37,23 @@ def test_successful_refund assert_success purchase assert response = @gateway.refund(@amount, purchase.authorization) - assert_equal "REFUND_REQUESTED_AWAITING_REFUND", response.message + assert_equal 'REFUND_REQUESTED_AWAITING_REFUND', response.message end def test_failed_refund - assert response = @gateway.refund(@amount, "1234") + assert response = @gateway.refund(@amount, '1234') assert_failure response - assert_equal "An error occurred. Please check your input and try again.", response.message + assert_equal 'An error occurred. Please check your input and try again.', response.message end def test_invalid_login gateway = FirstGivingGateway.new( - application_key: "25151616", - security_token: "63131jnkj", - charity_id: "1234" + application_key: '25151616', + security_token: '63131jnkj', + charity_id: '1234' ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "An error occurred. Please check your input and try again.", response.message + assert_equal 'An error occurred. Please check your input and try again.', response.message end end diff --git a/test/remote/gateways/remote_firstdata_e4_test.rb b/test/remote/gateways/remote_firstdata_e4_test.rb index 51e1bf6af58..3a541b57290 100755 --- a/test/remote/gateways/remote_firstdata_e4_test.rb +++ b/test/remote/gateways/remote_firstdata_e4_test.rb @@ -13,9 +13,9 @@ def setup :description => 'Store Purchase' } @options_with_authentication_data = @options.merge({ - eci: "5", - cavv: "TESTCAVV", - xid: "TESTXID" + eci: '5', + cavv: 'TESTCAVV', + xid: 'TESTXID' }) end @@ -27,7 +27,7 @@ def test_successful_purchase def test_successful_purchase_with_network_tokenization @credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', verification_value: nil ) assert response = @gateway.purchase(@amount, @credit_card, @options) @@ -62,27 +62,27 @@ def test_successful_purchase_with_level_3 response = @gateway.purchase(500, @credit_card, @options.merge(level_3: level_3_xml)) assert_success response - assert_equal "Transaction Normal - Approved", response.message + assert_equal 'Transaction Normal - Approved', response.message end def test_successful_purchase_with_tax_fields - response = @gateway.purchase(500, @credit_card, @options.merge(tax1_amount: 50, tax1_number: "A458")) + response = @gateway.purchase(500, @credit_card, @options.merge(tax1_amount: 50, tax1_number: 'A458')) assert_success response - assert_equal "50.0", response.params["tax1_amount"] - assert_equal "", response.params["tax1_number"], "E4 blanks this out in the response" + assert_equal '50.0', response.params['tax1_amount'] + assert_equal '', response.params['tax1_number'], 'E4 blanks this out in the response' end def test_successful_purchase_with_customer_ref - response = @gateway.purchase(500, @credit_card, @options.merge(customer: "267")) + response = @gateway.purchase(500, @credit_card, @options.merge(customer: '267')) assert_success response - assert_equal "267", response.params["customer_ref"] + assert_equal '267', response.params['customer_ref'] end def test_successful_purchase_with_card_authentication assert response = @gateway.purchase(@amount, @credit_card, @options_with_authentication_data) - assert_equal response.params["cavv"], @options_with_authentication_data[:cavv] - assert_equal response.params["ecommerce_flag"], @options_with_authentication_data[:eci] - assert_equal response.params["xid"], @options_with_authentication_data[:xid] + assert_equal response.params['cavv'], @options_with_authentication_data[:cavv] + assert_equal response.params['ecommerce_flag'], @options_with_authentication_data[:eci] + assert_equal response.params['xid'], @options_with_authentication_data[:xid] assert_success response end @@ -98,7 +98,7 @@ def test_bad_creditcard_number assert response = @gateway.purchase(@amount, @bad_credit_card, @options) assert_match(/Invalid Credit Card/, response.message) assert_failure response - assert_equal response.error_code, "invalid_number" + assert_equal response.error_code, 'invalid_number' end def test_trans_error @@ -107,7 +107,7 @@ def test_trans_error assert response = @gateway.purchase(@amount, @credit_card, @options ) assert_match(/Unable to Send Transaction/, response.message) # 42 is 'unable to send trans' assert_failure response - assert_equal response.error_code, "processing_error" + assert_equal response.error_code, 'processing_error' end def test_purchase_and_credit @@ -165,21 +165,21 @@ def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Transaction Normal - Approved", response.message - assert_equal "0.0", response.params["dollar_amount"] - assert_equal "05", response.params["transaction_type"] + assert_equal 'Transaction Normal - Approved', response.message + assert_equal '0.0', response.params['dollar_amount'] + assert_equal '05', response.params['transaction_type'] end def test_failed_verify assert response = @gateway.verify(@bad_credit_card, @options) assert_failure response assert_match %r{Invalid Credit Card Number}, response.message - assert_equal response.error_code, "invalid_number" + assert_equal response.error_code, 'invalid_number' end def test_invalid_login - gateway = FirstdataE4Gateway.new(:login => "NotARealUser", - :password => "NotARealPassword" ) + gateway = FirstdataE4Gateway.new(:login => 'NotARealUser', + :password => 'NotARealPassword' ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_match %r{Unauthorized Request}, response.message assert_failure response @@ -188,8 +188,8 @@ def test_invalid_login def test_response_contains_cvv_and_avs_results response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal 'M', response.cvv_result["code"] - assert_equal '4', response.avs_result["code"] + assert_equal 'M', response.cvv_result['code'] + assert_equal '4', response.avs_result['code'] end def test_refund diff --git a/test/remote/gateways/remote_flo2cash_simple_test.rb b/test/remote/gateways/remote_flo2cash_simple_test.rb index e27ad16b874..15aafebb4bb 100644 --- a/test/remote/gateways/remote_flo2cash_simple_test.rb +++ b/test/remote/gateways/remote_flo2cash_simple_test.rb @@ -25,7 +25,7 @@ def test_invalid_login ) response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Authentication error. Username and/or Password are incorrect", response.message + assert_equal 'Authentication error. Username and/or Password are incorrect', response.message end def test_successful_purchase @@ -53,7 +53,7 @@ def test_successful_refund def test_failed_refund response = @gateway.refund(@amount, '') assert_failure response - assert_equal "Original transaction not found", response.message + assert_equal 'Original transaction not found', response.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_flo2cash_test.rb b/test/remote/gateways/remote_flo2cash_test.rb index f5a1af2d10f..0c0fe0972f3 100644 --- a/test/remote/gateways/remote_flo2cash_test.rb +++ b/test/remote/gateways/remote_flo2cash_test.rb @@ -25,7 +25,7 @@ def test_invalid_login ) response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Authentication error. Username and/or Password are incorrect", response.message + assert_equal 'Authentication error. Username and/or Password are incorrect', response.message end def test_successful_purchase @@ -62,7 +62,7 @@ def test_failed_authorize def test_failed_capture response = @gateway.capture(@amount, '') assert_failure response - assert_equal "Original transaction not found", response.message + assert_equal 'Original transaction not found', response.message end def test_successful_refund @@ -77,7 +77,7 @@ def test_successful_refund def test_failed_refund response = @gateway.refund(@amount, '') assert_failure response - assert_equal "Original transaction not found", response.message + assert_equal 'Original transaction not found', response.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_forte_test.rb b/test/remote/gateways/remote_forte_test.rb index 9a73d11e081..4fdc41bb801 100644 --- a/test/remote/gateways/remote_forte_test.rb +++ b/test/remote/gateways/remote_forte_test.rb @@ -28,10 +28,10 @@ def setup end def test_invalid_login - gateway = ForteGateway.new(api_key: "InvalidKey", secret: "InvalidSecret", location_id: "11", account_id: "323") + gateway = ForteGateway.new(api_key: 'InvalidKey', secret: 'InvalidSecret', location_id: '11', account_id: '323') assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_match "combination not found.", response.message + assert_match 'combination not found.', response.message end def test_successful_purchase @@ -55,14 +55,14 @@ def test_failed_purchase_with_echeck def test_successful_purchase_with_more_options options = { order_id: '1', - ip: "127.0.0.1", - email: "joe@example.com", + ip: '127.0.0.1', + email: 'joe@example.com', address: address } response = @gateway.purchase(@amount, @credit_card, options) assert_success response - assert_equal "1", response.params["order_number"] + assert_equal '1', response.params['order_number'] assert_equal 'TEST APPROVAL', response.message end diff --git a/test/remote/gateways/remote_garanti_test.rb b/test/remote/gateways/remote_garanti_test.rb index 97c0b616914..189fba6ddd0 100644 --- a/test/remote/gateways/remote_garanti_test.rb +++ b/test/remote/gateways/remote_garanti_test.rb @@ -58,6 +58,6 @@ def test_invalid_login ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal '0651', response.params["reason_code"] + assert_equal '0651', response.params['reason_code'] end end diff --git a/test/remote/gateways/remote_global_collect_test.rb b/test/remote/gateways/remote_global_collect_test.rb index a167ca7caa0..b04a60ae53a 100644 --- a/test/remote/gateways/remote_global_collect_test.rb +++ b/test/remote/gateways/remote_global_collect_test.rb @@ -25,8 +25,8 @@ def test_successful_purchase_with_fraud_fields options = @options.merge( fraud_fields: { - "website" => "www.example.com", - "giftMessage" => "Happy Day!" + 'website' => 'www.example.com', + 'giftMessage' => 'Happy Day!' } ) @@ -38,8 +38,8 @@ def test_successful_purchase_with_fraud_fields def test_successful_purchase_with_more_options options = @options.merge( order_id: '1', - ip: "127.0.0.1", - email: "joe@example.com", + ip: '127.0.0.1', + email: 'joe@example.com', sdk_identifier: 'Channel', sdk_creator: 'Bob', integrator: 'Bill', @@ -55,7 +55,7 @@ def test_successful_purchase_with_more_options end def test_successful_purchase_with_very_long_name - credit_card = credit_card('4567350000427977', { first_name: "thisisaverylongfirstname"}) + credit_card = credit_card('4567350000427977', { first_name: 'thisisaverylongfirstname'}) response = @gateway.purchase(@amount, credit_card, @options) assert_success response diff --git a/test/remote/gateways/remote_global_transport_test.rb b/test/remote/gateways/remote_global_transport_test.rb index da308566248..1f5c45b4cb4 100644 --- a/test/remote/gateways/remote_global_transport_test.rb +++ b/test/remote/gateways/remote_global_transport_test.rb @@ -38,20 +38,20 @@ def test_successful_authorize_and_capture assert capture = @gateway.capture(500, auth.authorization) assert_success capture - assert_equal "Approved", capture.message + assert_equal 'Approved', capture.message end def test_failed_authorize response = @gateway.authorize(40000, @credit_card, @options) assert_failure response - assert_equal "Declined", response.message + assert_equal 'Declined', response.message end def test_successful_partial_authorize_and_capture @credit_card = credit_card('4111111111111111') auth = @gateway.authorize(2354, @credit_card, @options) assert_success auth - assert_equal "Partial Approval", auth.message + assert_equal 'Partial Approval', auth.message assert capture = @gateway.capture(2000, auth.authorization) assert_success capture @@ -72,7 +72,7 @@ def test_successful_refund assert refund = @gateway.refund(500, purchase.authorization) assert_success refund - assert_equal "Approved", refund.message + assert_equal 'Approved', refund.message end def test_partial_refund @@ -81,7 +81,7 @@ def test_partial_refund assert refund = @gateway.refund(490, purchase.authorization) assert_success refund - assert_equal "Approved", refund.message + assert_equal 'Approved', refund.message end def test_failed_refund @@ -99,32 +99,32 @@ def test_successful_void assert void = @gateway.void(auth.authorization) assert_success void - assert_equal "Approved", void.message + assert_equal 'Approved', void.message end def test_failed_void - assert void = @gateway.void("UnknownAuthorization") + assert void = @gateway.void('UnknownAuthorization') assert_failure void - assert_equal "Invalid PNRef", void.message + assert_equal 'Invalid PNRef', void.message end def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_failed_verify response = @gateway.verify(credit_card('4003'), @options) assert_failure response - assert_equal "Invalid Account Number", response.message + assert_equal 'Invalid Account Number', response.message end def test_invalid_login gateway = GlobalTransportGateway.new(global_user_name: '', global_password: '', term_type: '') response = gateway.purchase(500, @credit_card, @options) assert_failure response - assert_equal("Invalid Login Information", response.message) + assert_equal('Invalid Login Information', response.message) end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_hdfc_test.rb b/test/remote/gateways/remote_hdfc_test.rb index 22cd4453d96..e3f2ed395d5 100644 --- a/test/remote/gateways/remote_hdfc_test.rb +++ b/test/remote/gateways/remote_hdfc_test.rb @@ -7,48 +7,48 @@ def setup @gateway = HdfcGateway.new(fixtures(:hdfc)) @amount = 100 - @credit_card = credit_card("4012001037141112") + @credit_card = credit_card('4012001037141112') # Use an American Express card to simulate a failure since HDFC does not # support any proper decline cards outside of 3D secure failures. - @declined_card = credit_card("377182068239368", :brand => :american_express) + @declined_card = credit_card('377182068239368', :brand => :american_express) @options = { :order_id => generate_unique_id, :billing_address => address, - :description => "Store Purchase" + :description => 'Store Purchase' } end def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "Invalid Brand.", response.message - assert_equal "GW00160", response.params["error_code_tag"] + assert_equal 'Invalid Brand.', response.message + assert_equal 'GW00160', response.params['error_code_tag'] end def test_successful_authorize_and_capture assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^\d+\|.+$), response.authorization assert capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_failed_authorize assert response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal "Invalid Brand.", response.message - assert_equal "GW00160", response.params["error_code_tag"] + assert_equal 'Invalid Brand.', response.message + assert_equal 'GW00160', response.params['error_code_tag'] end def test_successful_refund @@ -57,7 +57,7 @@ def test_successful_refund assert refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "Succeeded", refund.message + assert_equal 'Succeeded', refund.message end def test_passing_billing_address @@ -67,11 +67,11 @@ def test_passing_billing_address def test_invalid_login gateway = HdfcGateway.new( - :login => "", - :password => "" + :login => '', + :password => '' ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "TranPortal ID required.", response.message + assert_equal 'TranPortal ID required.', response.message end end diff --git a/test/remote/gateways/remote_hps_test.rb b/test/remote/gateways/remote_hps_test.rb index 4c183b092ef..2650965ecc5 100644 --- a/test/remote/gateways/remote_hps_test.rb +++ b/test/remote/gateways/remote_hps_test.rb @@ -216,8 +216,8 @@ def test_failed_purchase_with_swipe_bad_track_data end def test_successful_purchase_with_swipe_encryption_type_01 - @options[:encryption_type] = "01" - @credit_card.track_data = "&lt;E1052711%B5473501000000014^MC TEST CARD^251200000000000000000000000000000000?|GVEY/MKaKXuqqjKRRueIdCHPPoj1gMccgNOtHC41ymz7bIvyJJVdD3LW8BbwvwoenI+|+++++++C4cI2zjMp|11;5473501000000014=25120000000000000000?|8XqYkQGMdGeiIsgM0pzdCbEGUDP|+++++++C4cI2zjMp|00|||/wECAQECAoFGAgEH2wYcShV78RZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0PX50qfj4dt0lu9oFBESQQNkpoxEVpCW3ZKmoIV3T93zphPS3XKP4+DiVlM8VIOOmAuRrpzxNi0TN/DWXWSjUC8m/PI2dACGdl/hVJ/imfqIs68wYDnp8j0ZfgvM26MlnDbTVRrSx68Nzj2QAgpBCHcaBb/FZm9T7pfMr2Mlh2YcAt6gGG1i2bJgiEJn8IiSDX5M2ybzqRT86PCbKle/XCTwFFe1X|&gt;" + @options[:encryption_type] = '01' + @credit_card.track_data = '&lt;E1052711%B5473501000000014^MC TEST CARD^251200000000000000000000000000000000?|GVEY/MKaKXuqqjKRRueIdCHPPoj1gMccgNOtHC41ymz7bIvyJJVdD3LW8BbwvwoenI+|+++++++C4cI2zjMp|11;5473501000000014=25120000000000000000?|8XqYkQGMdGeiIsgM0pzdCbEGUDP|+++++++C4cI2zjMp|00|||/wECAQECAoFGAgEH2wYcShV78RZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0PX50qfj4dt0lu9oFBESQQNkpoxEVpCW3ZKmoIV3T93zphPS3XKP4+DiVlM8VIOOmAuRrpzxNi0TN/DWXWSjUC8m/PI2dACGdl/hVJ/imfqIs68wYDnp8j0ZfgvM26MlnDbTVRrSx68Nzj2QAgpBCHcaBb/FZm9T7pfMr2Mlh2YcAt6gGG1i2bJgiEJn8IiSDX5M2ybzqRT86PCbKle/XCTwFFe1X|&gt;' response = @gateway.purchase(@amount, @credit_card, @options) assert_success response diff --git a/test/remote/gateways/remote_iats_payments_test.rb b/test/remote/gateways/remote_iats_payments_test.rb index 5f68a03a1d6..4a1a256da8e 100644 --- a/test/remote/gateways/remote_iats_payments_test.rb +++ b/test/remote/gateways/remote_iats_payments_test.rb @@ -75,24 +75,24 @@ def test_successful_check_refund # the original purchase hadn't yet cleared. No way to test immediate failure # due to the delay in original tx processing, even for text txs. assert_failure refund - assert_equal "REJECT: 3", refund.message + assert_equal 'REJECT: 3', refund.message end def test_failed_check_refund - assert refund = @gateway.refund(@amount, "invalidref") + assert refund = @gateway.refund(@amount, 'invalidref') assert_failure refund - assert_equal "REJECT: 39", refund.message + assert_equal 'REJECT: 39', refund.message end def test_successful_store_and_unstore assert store = @gateway.store(@credit_card, @options) assert_success store assert store.authorization - assert_equal "Success", store.message + assert_equal 'Success', store.message assert unstore = @gateway.unstore(store.authorization, @options) assert_success unstore - assert_equal "Success", unstore.message + assert_equal 'Success', unstore.message end def test_failed_store diff --git a/test/remote/gateways/remote_inspire_test.rb b/test/remote/gateways/remote_inspire_test.rb index 28c83c656f2..d9594ceda57 100644 --- a/test/remote/gateways/remote_inspire_test.rb +++ b/test/remote/gateways/remote_inspire_test.rb @@ -49,7 +49,7 @@ def test_successful_add_to_vault_and_use response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal 'This transaction has been approved', response.message - assert_not_nil customer_id = response.params["customer_vault_id"] + assert_not_nil customer_id = response.params['customer_vault_id'] second_response = @gateway.purchase(@amount*2, customer_id, @options) assert_equal 'This transaction has been approved', second_response.message @@ -61,7 +61,7 @@ def test_add_to_vault_with_custom_vault_id response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal 'This transaction has been approved', response.message - assert_equal @options[:store], response.params["customer_vault_id"].to_i + assert_equal @options[:store], response.params['customer_vault_id'].to_i end def test_add_to_vault_with_custom_vault_id_with_store_method @@ -69,7 +69,7 @@ def test_add_to_vault_with_custom_vault_id_with_store_method response = @gateway.store(@credit_card, @options.dup) assert_success response assert_equal 'This transaction has been approved', response.message - assert_equal @options[:billing_id], response.params["customer_vault_id"].to_i + assert_equal @options[:billing_id], response.params['customer_vault_id'].to_i end def test_update_vault @@ -145,7 +145,7 @@ def test_partial_refund end def test_failed_refund - response = @gateway.refund(nil, "bogus") + response = @gateway.refund(nil, 'bogus') assert_failure response end diff --git a/test/remote/gateways/remote_instapay_test.rb b/test/remote/gateways/remote_instapay_test.rb index e43ad00d8ec..2919d97b98d 100644 --- a/test/remote/gateways/remote_instapay_test.rb +++ b/test/remote/gateways/remote_instapay_test.rb @@ -56,6 +56,6 @@ def test_invalid_login assert response = gateway.purchase(@amount, @credit_card) assert_failure response - assert_equal "Invalid merchant", response.message + assert_equal 'Invalid merchant', response.message end end diff --git a/test/remote/gateways/remote_ipp_test.rb b/test/remote/gateways/remote_ipp_test.rb index 635383bd956..16e17ce473b 100644 --- a/test/remote/gateways/remote_ipp_test.rb +++ b/test/remote/gateways/remote_ipp_test.rb @@ -14,7 +14,7 @@ def setup end def test_dump_transcript - skip("Transcript scrubbing for this gateway has been tested.") + skip('Transcript scrubbing for this gateway has been tested.') dump_transcript_and_fail(@gateway, @amount, @credit_card, @options) end diff --git a/test/remote/gateways/remote_iridium_test.rb b/test/remote/gateways/remote_iridium_test.rb index 8a8b2eb9ddc..92dee585764 100644 --- a/test/remote/gateways/remote_iridium_test.rb +++ b/test/remote/gateways/remote_iridium_test.rb @@ -13,11 +13,11 @@ def setup @credit_card = credit_card('4976000000003436', {:verification_value => '452'}) @declined_card = credit_card('4221690000004963') - our_address = address(:address1 => "32 Edward Street", - :address2 => "Camborne", - :state => "Cornwall", - :zip => "TR14 8PA", - :country => "826") + our_address = address(:address1 => '32 Edward Street', + :address2 => 'Camborne', + :state => 'Cornwall', + :zip => 'TR14 8PA', + :country => '826') @options = { :order_id => generate_unique_id, :billing_address => our_address, @@ -41,22 +41,22 @@ def test_failed_purchase def test_avs_failure assert response = @gateway.purchase(@amount, @avs_card, @options) assert_failure response - assert_equal response.avs_result["street_match"], "N" - assert_equal response.avs_result["postal_match"], "N" + assert_equal response.avs_result['street_match'], 'N' + assert_equal response.avs_result['postal_match'], 'N' end def test_cv2_failure assert response = @gateway.purchase(@amount, @cv2_card, @options) assert_failure response - assert_equal response.cvv_result["code"], "N" + assert_equal response.cvv_result['code'], 'N' end def test_avs_cv2_failure assert response = @gateway.purchase(@amount, @avs_cv2_card, @options) assert_failure response - assert_equal response.avs_result["street_match"], "N" - assert_equal response.avs_result["postal_match"], "N" - assert_equal response.cvv_result["code"], "N" + assert_equal response.avs_result['street_match'], 'N' + assert_equal response.avs_result['postal_match'], 'N' + assert_equal response.cvv_result['code'], 'N' end def test_authorize_and_capture @@ -102,7 +102,7 @@ def test_successful_authorization_and_failed_capture def test_failed_capture_bad_auth_info assert auth = @gateway.authorize(@amount, @credit_card, @options) - assert capture = @gateway.capture(@amount, "a;b;c", @options) + assert capture = @gateway.capture(@amount, 'a;b;c', @options) assert_failure capture end @@ -158,7 +158,7 @@ def test_successful_void end def test_failed_void - assert response = @gateway.void("bogus") + assert response = @gateway.void('bogus') assert_failure response end diff --git a/test/remote/gateways/remote_iveri_test.rb b/test/remote/gateways/remote_iveri_test.rb index 2a9ef82ff49..11935d75858 100644 --- a/test/remote/gateways/remote_iveri_test.rb +++ b/test/remote/gateways/remote_iveri_test.rb @@ -26,8 +26,8 @@ def test_successful_purchase def test_successful_purchase_with_more_options options = { - ip: "127.0.0.1", - email: "joe@example.com", + ip: '127.0.0.1', + email: 'joe@example.com', currency: 'ZAR' } @@ -38,7 +38,7 @@ def test_successful_purchase_with_more_options def test_successful_purchase_with_3ds_params options = { - eci: "ThreeDSecure", + eci: 'ThreeDSecure', xid: SecureRandom.hex(14), cavv: SecureRandom.hex(14) } diff --git a/test/remote/gateways/remote_jetpay_test.rb b/test/remote/gateways/remote_jetpay_test.rb index 48ef90770f5..29f0c40b01b 100644 --- a/test/remote/gateways/remote_jetpay_test.rb +++ b/test/remote/gateways/remote_jetpay_test.rb @@ -21,23 +21,23 @@ def setup def test_successful_purchase assert response = @gateway.purchase(9900, @credit_card, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert_not_nil response.authorization - assert_not_nil response.params["approval"] + assert_not_nil response.params['approval'] end def test_unsuccessful_purchase assert response = @gateway.purchase(5205, @declined_card, @options) assert_failure response - assert_equal "Do not honor.", response.message + assert_equal 'Do not honor.', response.message end def test_successful_purchase_with_origin assert response = @gateway.purchase(9900, @credit_card, {:origin => 'RECURRING'}) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert_not_nil response.authorization - assert_not_nil response.params["approval"] + assert_not_nil response.params['approval'] end def test_authorize_and_capture @@ -45,7 +45,7 @@ def test_authorize_and_capture assert_success auth assert_equal 'APPROVED', auth.message assert_not_nil auth.authorization - assert_not_nil auth.params["approval"] + assert_not_nil auth.params['approval'] assert capture = @gateway.capture(9900, auth.authorization) assert_success capture @@ -56,14 +56,14 @@ def test_partial_capture assert_success auth assert_equal 'APPROVED', auth.message assert_not_nil auth.authorization - assert_not_nil auth.params["approval"] + assert_not_nil auth.params['approval'] assert capture = @gateway.capture(4400, auth.authorization) assert_success capture end def test_ud_fields_on_purchase - assert response = @gateway.purchase(9900, @credit_card, @options.merge(ud_field_1: "Value1", ud_field_2: "Value2", ud_field3: "Value3")) + assert response = @gateway.purchase(9900, @credit_card, @options.merge(ud_field_1: 'Value1', ud_field_2: 'Value2', ud_field3: 'Value3')) assert_success response end @@ -71,7 +71,7 @@ def test_ud_fields_on_capture assert auth = @gateway.authorize(9900, @credit_card, @options) assert_success auth - assert capture = @gateway.capture(9900, auth.authorization, @options.merge(ud_field_1: "Value1", ud_field_2: "Value2", ud_field3: "Value3")) + assert capture = @gateway.capture(9900, auth.authorization, @options.merge(ud_field_1: 'Value1', ud_field_2: 'Value2', ud_field3: 'Value3')) assert_success capture end @@ -82,7 +82,7 @@ def test_void assert_success auth assert_equal 'APPROVED', auth.message assert_not_nil auth.authorization - assert_not_nil auth.params["approval"] + assert_not_nil auth.params['approval'] assert void = @gateway.void(auth.authorization) @@ -92,16 +92,16 @@ def test_void def test_purchase_refund_with_token assert response = @gateway.purchase(9900, @credit_card, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert_not_nil response.authorization - assert_not_nil response.params["approval"] + assert_not_nil response.params['approval'] # linked to a specific transaction_id assert credit = @gateway.refund(9900, response.authorization) assert_success credit assert_not_nil(credit.authorization) - assert_not_nil(response.params["approval"]) - assert_equal [response.params['transaction_id'], response.params["approval"], 9900, response.params["token"]].join(";"), response.authorization + assert_not_nil(response.params['approval']) + assert_equal [response.params['transaction_id'], response.params['approval'], 9900, response.params['token']].join(';'), response.authorization end def test_capture_refund_with_token @@ -109,18 +109,18 @@ def test_capture_refund_with_token assert_success auth assert_equal 'APPROVED', auth.message assert_not_nil auth.authorization - assert_not_nil auth.params["approval"] - assert_equal [auth.params['transaction_id'], auth.params["approval"], 9900, auth.params["token"]].join(";"), auth.authorization + assert_not_nil auth.params['approval'] + assert_equal [auth.params['transaction_id'], auth.params['approval'], 9900, auth.params['token']].join(';'), auth.authorization assert capture = @gateway.capture(9900, auth.authorization) assert_success capture - assert_equal [capture.params['transaction_id'], capture.params["approval"], 9900, auth.params["token"]].join(";"), capture.authorization + assert_equal [capture.params['transaction_id'], capture.params['approval'], 9900, auth.params['token']].join(';'), capture.authorization # linked to a specific transaction_id assert refund = @gateway.refund(9900, capture.authorization) assert_success refund assert_not_nil(refund.authorization) - assert_not_nil(refund.params["approval"]) + assert_not_nil(refund.params['approval']) end def test_refund_backwards_compatible @@ -129,18 +129,18 @@ def test_refund_backwards_compatible assert response = @gateway.purchase(9900, card, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert_not_nil response.authorization - assert_not_nil response.params["approval"] + assert_not_nil response.params['approval'] - old_authorization = [response.params['transaction_id'], response.params["approval"], 9900].join(";") + old_authorization = [response.params['transaction_id'], response.params['approval'], 9900].join(';') # linked to a specific transaction_id assert credit = @gateway.refund(9900, old_authorization, :credit_card => card) assert_success credit assert_not_nil(credit.authorization) - assert_not_nil(response.params["approval"]) - assert_equal [response.params['transaction_id'], response.params["approval"], 9900, response.params["token"]].join(";"), response.authorization + assert_not_nil(response.params['approval']) + assert_equal [response.params['transaction_id'], response.params['approval'], 9900, response.params['token']].join(';'), response.authorization end def test_credit @@ -151,7 +151,7 @@ def test_credit assert credit = @gateway.credit(9900, card) assert_success credit assert_not_nil(credit.authorization) - assert_not_nil(credit.params["approval"]) + assert_not_nil(credit.params['approval']) end def test_failed_capture @@ -178,7 +178,7 @@ def test_missing_login def test_transcript_scrubbing @amount = 9900 - @credit_card.verification_value = "421" + @credit_card.verification_value = '421' transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) end diff --git a/test/remote/gateways/remote_jetpay_v2_certification_test.rb b/test/remote/gateways/remote_jetpay_v2_certification_test.rb index 4aef90a5de4..4916dd08435 100644 --- a/test/remote/gateways/remote_jetpay_v2_certification_test.rb +++ b/test/remote/gateways/remote_jetpay_v2_certification_test.rb @@ -23,299 +23,299 @@ def teardown end def test_certification_cnp1_authorize_mastercard - @options[:order_id] = "CNP1" + @options[:order_id] = 'CNP1' amount = 1000 master = credit_card('5111111111111118', :month => 12, :year => 2017, :brand => 'master', :verification_value => '121') assert response = @gateway.authorize(amount, master, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] end def test_certification_cnp2_authorize_visa - @options[:order_id] = "CNP2" + @options[:order_id] = 'CNP2' amount = 1105 visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '121') assert response = @gateway.authorize(amount, visa, @options) assert_failure response - assert_equal "Do not honor.", response.message + assert_equal 'Do not honor.', response.message @unique_id = response.params['unique_id'] end def test_certification_cnp3_cnp4_authorize_and_capture_amex - @options[:order_id] = "CNP3" + @options[:order_id] = 'CNP3' amount = 1200 amex = credit_card('378282246310005', :month => 12, :year => 2017, :brand => 'american_express', :verification_value => '1221') assert response = @gateway.authorize(amount, amex, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] puts "\n#{@options[:order_id]}: #{@unique_id}" - @options[:order_id] = "CNP4" + @options[:order_id] = 'CNP4' assert response = @gateway.capture(amount, response.authorization, @options) assert_success response @unique_id = response.params['unique_id'] end def test_certification_cnp5_purchase_discover - @options[:order_id] = "CNP5" + @options[:order_id] = 'CNP5' amount = 1300 discover = credit_card('6011111111111117', :month => 12, :year => 2017, :brand => 'discover', :verification_value => '121') assert response = @gateway.purchase(amount, discover, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] end def test_certification_cnp6_purchase_visa - @options[:order_id] = "CNP6" + @options[:order_id] = 'CNP6' amount = 1405 visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '120') assert response = @gateway.purchase(amount, visa, @options) assert_failure response - assert_equal "Do not honor.", response.message + assert_equal 'Do not honor.', response.message @unique_id = response.params['unique_id'] end def test_certification_cnp7_authorize_mastercard - @options[:order_id] = "CNP7" + @options[:order_id] = 'CNP7' amount = 1500 master = credit_card('5111111111111118', :month => 12, :year => 2017, :brand => 'master', :verification_value => '120') assert response = @gateway.authorize(amount, master, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] end def test_certification_cnp8_authorize_visa - @options[:order_id] = "CNP8" + @options[:order_id] = 'CNP8' amount = 1605 visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '120') assert response = @gateway.authorize(amount, visa, @options) assert_failure response - assert_equal "Do not honor.", response.message + assert_equal 'Do not honor.', response.message @unique_id = response.params['unique_id'] end def test_certification_cnp9_cnp10_authorize_and_capture_amex - @options[:order_id] = "CNP9" + @options[:order_id] = 'CNP9' amount = 1700 amex = credit_card('378282246310005', :month => 12, :year => 2017, :brand => 'american_express', :verification_value => '1220') assert response = @gateway.authorize(amount, amex, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] puts "\n#{@options[:order_id]}: #{@unique_id}" - @options[:order_id] = "CNP10" + @options[:order_id] = 'CNP10' assert response = @gateway.capture(amount, response.authorization, @options) assert_success response @unique_id = response.params['unique_id'] end def test_certification_cnp11_purchase_discover - @options[:order_id] = "CNP11" + @options[:order_id] = 'CNP11' amount = 1800 discover = credit_card('6011111111111117', :month => 12, :year => 2017, :brand => 'discover', :verification_value => '120') assert response = @gateway.purchase(amount, discover, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] end def test_certification_rec01_recurring_mastercard - @options[:order_id] = "REC01" - @options[:origin] = "RECURRING" + @options[:order_id] = 'REC01' + @options[:origin] = 'RECURRING' @options[:billing_address] = nil @options[:shipping_address] = nil amount = 2000 master = credit_card('5111111111111118', :month => 12, :year => 2017, :brand => 'master', :verification_value => '120') assert response = @gateway.purchase(amount, master, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] end def test_certification_rec02_recurring_visa - @options[:order_id] = "REC02" - @options[:origin] = "RECURRING" + @options[:order_id] = 'REC02' + @options[:origin] = 'RECURRING' amount = 2100 visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '') assert response = @gateway.purchase(amount, visa, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] end def test_certification_rec03_recurring_amex - @options[:order_id] = "REC03" - @options[:origin] = "RECURRING" + @options[:order_id] = 'REC03' + @options[:origin] = 'RECURRING' amount = 2200 amex = credit_card('378282246310005', :month => 12, :year => 2017, :brand => 'american_express', :verification_value => '1221') assert response = @gateway.purchase(amount, amex, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] end def test_certification_corp07_corp08_authorize_and_capture_discover - @options[:order_id] = "CORP07" + @options[:order_id] = 'CORP07' amount = 2500 discover = credit_card('6011111111111117', :month => 12, :year => 2018, :brand => 'discover', :verification_value => '120') assert response = @gateway.authorize(amount, discover, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] puts "\n#{@options[:order_id]}: #{@unique_id}" - @options[:order_id] = "CORP08" - assert response = @gateway.capture(amount, response.authorization, @options.merge(:tax_amount => "200")) + @options[:order_id] = 'CORP08' + assert response = @gateway.capture(amount, response.authorization, @options.merge(:tax_amount => '200')) assert_success response @unique_id = response.params['unique_id'] end def test_certification_corp09_corp10_authorize_and_capture_visa - @options[:order_id] = "CORP09" + @options[:order_id] = 'CORP09' amount = 5000 visa = credit_card('4111111111111111', :month => 12, :year => 2018, :brand => 'visa', :verification_value => '120') assert response = @gateway.authorize(amount, visa, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] puts "\n#{@options[:order_id]}: #{@unique_id}" - @options[:order_id] = "CORP10" - assert response = @gateway.capture(amount, response.authorization, @options.merge(:tax_amount => "0", :tax_exempt => "true")) + @options[:order_id] = 'CORP10' + assert response = @gateway.capture(amount, response.authorization, @options.merge(:tax_amount => '0', :tax_exempt => 'true')) assert_success response @unique_id = response.params['unique_id'] end def test_certification_corp11_corp12_authorize_and_capture_mastercard - @options[:order_id] = "CORP11" + @options[:order_id] = 'CORP11' amount = 7500 master = credit_card('5111111111111118', :month => 12, :year => 2018, :brand => 'master', :verification_value => '120') assert response = @gateway.authorize(amount, master, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] puts "\n#{@options[:order_id]}: #{@unique_id}" - @options[:order_id] = "CORP12" - assert response = @gateway.capture(amount, response.authorization, @options.merge(:tax_amount => "0", :tax_exempt => "false", :purchase_order => '456456')) + @options[:order_id] = 'CORP12' + assert response = @gateway.capture(amount, response.authorization, @options.merge(:tax_amount => '0', :tax_exempt => 'false', :purchase_order => '456456')) assert_success response @unique_id = response.params['unique_id'] end def test_certification_cred02_credit_visa - @options[:order_id] = "CRED02" + @options[:order_id] = 'CRED02' amount = 100 visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '120') assert response = @gateway.credit(amount, visa, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] end def test_certification_cred03_credit_amex - @options[:order_id] = "CRED03" + @options[:order_id] = 'CRED03' amount = 200 amex = credit_card('378282246310005', :month => 12, :year => 2017, :brand => 'american_express', :verification_value => '1220') assert response = @gateway.credit(amount, amex, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] end def test_certification_void03_void04_purchase_void_visa - @options[:order_id] = "VOID03" + @options[:order_id] = 'VOID03' amount = 300 visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '120') assert response = @gateway.purchase(amount, visa, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] puts "\n#{@options[:order_id]}: #{@unique_id}" - @options[:order_id] = "VOID04" - transaction_id, approval, amount, token = response.authorization.split(";") + @options[:order_id] = 'VOID04' + transaction_id, approval, amount, token = response.authorization.split(';') amount = 500 - authorization = [transaction_id, approval, amount, token].join(";") + authorization = [transaction_id, approval, amount, token].join(';') assert response = @gateway.void(authorization, @options) assert_failure response @unique_id = response.params['unique_id'] end def test_certification_void07_void08_void09_authorize_capture_void_discover - @options[:order_id] = "VOID07" + @options[:order_id] = 'VOID07' amount = 400 discover = credit_card('6011111111111117', :month => 12, :year => 2017, :brand => 'discover', :verification_value => '120') assert response = @gateway.authorize(amount, discover, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] puts "\n#{@options[:order_id]}: #{@unique_id}" - @options[:order_id] = "VOID08" + @options[:order_id] = 'VOID08' amount = 600 assert response = @gateway.capture(amount, response.authorization, @options) assert_success response @unique_id = response.params['unique_id'] puts "\n#{@options[:order_id]}: #{@unique_id}" - @options[:order_id] = "VOID09" + @options[:order_id] = 'VOID09' assert response = @gateway.void(response.authorization, @options) assert_success response @unique_id = response.params['unique_id'] end def test_certification_void12_void13_credit_void_visa - @options[:order_id] = "VOID12" + @options[:order_id] = 'VOID12' amount = 800 visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '120') assert response = @gateway.credit(amount, visa, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] puts "\n#{@options[:order_id]}: #{@unique_id}" - @options[:order_id] = "VOID13" + @options[:order_id] = 'VOID13' assert response = @gateway.void(response.authorization, @options) assert_success response @unique_id = response.params['unique_id'] end def test_certification_tok15_tokenize_mastercard - @options[:order_id] = "TOK15" + @options[:order_id] = 'TOK15' master = credit_card('5111111111111118', :month => 12, :year => 2017, :brand => 'master', :verification_value => '101') assert response = @gateway.store(master, @options) assert_success response - assert_equal "APPROVED", response.message - assert_equal "TOKENIZED", response.params["response_text"] + assert_equal 'APPROVED', response.message + assert_equal 'TOKENIZED', response.params['response_text'] @unique_id = response.params['unique_id'] end def test_certification_tok16_authorize_with_token_request_visa - @options[:order_id] = "TOK16" + @options[:order_id] = 'TOK16' amount = 3100 visa = credit_card('4111111111111111', :month => 12, :year => 2017, :brand => 'visa', :verification_value => '101') assert response = @gateway.authorize(amount, visa, @options) assert_success response - assert_equal "APPROVED", response.message - transaction_id, approval, amount, token = response.authorization.split(";") - assert_equal token, response.params["token"] + assert_equal 'APPROVED', response.message + transaction_id, approval, amount, token = response.authorization.split(';') + assert_equal token, response.params['token'] @unique_id = response.params['unique_id'] end def test_certification_tok17_purchase_with_token_request_amex - @options[:order_id] = "TOK17" + @options[:order_id] = 'TOK17' amount = 3200 amex = credit_card('378282246310005', :month => 12, :year => 2017, :brand => 'american_express', :verification_value => '1001') assert response = @gateway.purchase(amount, amex, @options) assert_success response - assert_equal "APPROVED", response.message - transaction_id, approval, amount, token = response.authorization.split(";") - assert_equal token, response.params["token"] + assert_equal 'APPROVED', response.message + transaction_id, approval, amount, token = response.authorization.split(';') + assert_equal token, response.params['token'] @unique_id = response.params['unique_id'] end @@ -324,11 +324,11 @@ def test_certification_tok18_authorize_using_token_mastercard assert response = @gateway.store(master, @options) assert_success response - @options[:order_id] = "TOK18" + @options[:order_id] = 'TOK18' amount = 3300 assert response = @gateway.authorize(amount, response.authorization, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] end @@ -337,11 +337,11 @@ def test_certification_tok19_purchase_using_token_visa assert response = @gateway.store(visa, @options) assert_success response - @options[:order_id] = "TOK19" + @options[:order_id] = 'TOK19' amount = 3400 assert response = @gateway.purchase(amount, response.authorization, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message @unique_id = response.params['unique_id'] end diff --git a/test/remote/gateways/remote_jetpay_v2_test.rb b/test/remote/gateways/remote_jetpay_v2_test.rb index 9e35bd228f6..aa01fb19c6b 100644 --- a/test/remote/gateways/remote_jetpay_v2_test.rb +++ b/test/remote/gateways/remote_jetpay_v2_test.rb @@ -25,30 +25,30 @@ def setup def test_successful_purchase assert response = @gateway.purchase(@amount_approved, @credit_card, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert_not_nil response.authorization - assert_not_nil response.params["approval"] + assert_not_nil response.params['approval'] end def test_failed_purchase assert response = @gateway.purchase(@amount_declined, @credit_card, @options) assert_failure response - assert_equal "Do not honor.", response.message + assert_equal 'Do not honor.', response.message end def test_successful_purchase_with_minimal_options assert response = @gateway.purchase(@amount_approved, @credit_card, {:device => 'spreedly', :application => 'spreedly'}) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert_not_nil response.authorization - assert_not_nil response.params["approval"] + assert_not_nil response.params['approval'] end def test_successful_purchase_with_additional_options options = @options.merge( - ud_field_1: "Value1", - ud_field_2: "Value2", - ud_field_3: "Value3" + ud_field_1: 'Value1', + ud_field_2: 'Value2', + ud_field_3: 'Value3' ) assert response = @gateway.purchase(@amount_approved, @credit_card, options) assert_success response @@ -59,7 +59,7 @@ def test_successful_authorize_and_capture assert_success auth assert_equal 'APPROVED', auth.message assert_not_nil auth.authorization - assert_not_nil auth.params["approval"] + assert_not_nil auth.params['approval'] assert capture = @gateway.capture(@amount_approved, auth.authorization, @options) assert_success capture @@ -70,7 +70,7 @@ def test_successful_authorize_and_capture_with_tax assert_success auth assert_equal 'APPROVED', auth.message assert_not_nil auth.authorization - assert_not_nil auth.params["approval"] + assert_not_nil auth.params['approval'] assert capture = @gateway.capture(@amount_approved, auth.authorization, @options.merge(:tax_amount => '990', :purchase_order => 'ABC12345')) assert_success capture @@ -81,7 +81,7 @@ def test_successful_partial_capture assert_success auth assert_equal 'APPROVED', auth.message assert_not_nil auth.authorization - assert_not_nil auth.params["approval"] + assert_not_nil auth.params['approval'] assert capture = @gateway.capture(4400, auth.authorization, @options) assert_success capture @@ -98,7 +98,7 @@ def test_successful_void assert_success auth assert_equal 'APPROVED', auth.message assert_not_nil auth.authorization - assert_not_nil auth.params["approval"] + assert_not_nil auth.params['approval'] assert void = @gateway.void(auth.authorization, @options) @@ -113,15 +113,15 @@ def test_failed_void def test_successful_purchase_refund assert response = @gateway.purchase(@amount_approved, @credit_card, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert_not_nil response.authorization - assert_not_nil response.params["approval"] + assert_not_nil response.params['approval'] assert refund = @gateway.refund(@amount_approved, response.authorization, @options) assert_success refund assert_not_nil(refund.authorization) - assert_not_nil(response.params["approval"]) - assert_equal [response.params['transaction_id'], response.params["approval"], @amount_approved, response.params["token"]].join(";"), response.authorization + assert_not_nil(response.params['approval']) + assert_equal [response.params['transaction_id'], response.params['approval'], @amount_approved, response.params['token']].join(';'), response.authorization end def test_successful_capture_refund @@ -129,17 +129,17 @@ def test_successful_capture_refund assert_success auth assert_equal 'APPROVED', auth.message assert_not_nil auth.authorization - assert_not_nil auth.params["approval"] - assert_equal [auth.params['transaction_id'], auth.params["approval"], @amount_approved, auth.params["token"]].join(";"), auth.authorization + assert_not_nil auth.params['approval'] + assert_equal [auth.params['transaction_id'], auth.params['approval'], @amount_approved, auth.params['token']].join(';'), auth.authorization assert capture = @gateway.capture(@amount_approved, auth.authorization, @options) assert_success capture - assert_equal [capture.params['transaction_id'], capture.params["approval"], @amount_approved, auth.params["token"]].join(";"), capture.authorization + assert_equal [capture.params['transaction_id'], capture.params['approval'], @amount_approved, auth.params['token']].join(';'), capture.authorization assert refund = @gateway.refund(@amount_approved, capture.authorization, @options) assert_success refund assert_not_nil(refund.authorization) - assert_not_nil(refund.params["approval"]) + assert_not_nil(refund.params['approval']) end def test_failed_refund @@ -153,7 +153,7 @@ def test_successful_credit assert credit = @gateway.credit(@amount_approved, card, @options) assert_success credit assert_not_nil(credit.authorization) - assert_not_nil(credit.params["approval"]) + assert_not_nil(credit.params['approval']) end def test_failed_credit @@ -194,7 +194,7 @@ def test_missing_login end def test_transcript_scrubbing - @credit_card.verification_value = "421" + @credit_card.verification_value = '421' transcript = capture_transcript(@gateway) do @gateway.purchase(@amount_approved, @credit_card, @options) end diff --git a/test/remote/gateways/remote_komoju_test.rb b/test/remote/gateways/remote_komoju_test.rb index 1d5a22dc0d2..5214eb01fbf 100644 --- a/test/remote/gateways/remote_komoju_test.rb +++ b/test/remote/gateways/remote_komoju_test.rb @@ -14,10 +14,10 @@ def setup :order_id => generate_unique_id, :description => 'Store Purchase', :tax => '10.0', - :ip => "192.168.0.1", - :email => "valid@email.com", - :browser_language => "en", - :browser_user_agent => "user_agent" + :ip => '192.168.0.1', + :email => 'valid@email.com', + :browser_language => 'en', + :browser_user_agent => 'user_agent' } end @@ -27,7 +27,7 @@ def test_successful_credit_card_purchase assert response.authorization.present? assert_equal 'Transaction succeeded', response.message assert_equal 100, response.params['amount'] - assert_equal "1111", response.params['payment_details']['last_four_digits'] + assert_equal '1111', response.params['payment_details']['last_four_digits'] assert_equal true, response.params['captured_at'].present? end @@ -37,7 +37,7 @@ def test_successful_credit_card_purchase_with_minimal_options assert response.authorization.present? assert_equal 'Transaction succeeded', response.message assert_equal 100, response.params['amount'] - assert_equal "1111", response.params['payment_details']['last_four_digits'] + assert_equal '1111', response.params['payment_details']['last_four_digits'] assert_equal true, response.params['captured_at'].present? end diff --git a/test/remote/gateways/remote_kushki_test.rb b/test/remote/gateways/remote_kushki_test.rb index 1fae5d77b8c..b4eb060de00 100644 --- a/test/remote/gateways/remote_kushki_test.rb +++ b/test/remote/gateways/remote_kushki_test.rb @@ -4,7 +4,7 @@ class RemoteKushkiTest < Test::Unit::TestCase def setup @gateway = KushkiGateway.new(fixtures(:kushki)) @amount = 100 - @credit_card = credit_card('4000100011112224', verification_value: "777") + @credit_card = credit_card('4000100011112224', verification_value: '777') @declined_card = credit_card('4000300011112220') end @@ -17,12 +17,12 @@ def test_successful_purchase def test_successful_purchase_with_options options = { - currency: "USD", + currency: 'USD', amount: { - subtotal_iva_0: "4.95", - subtotal_iva: "10", - iva: "1.54", - ice: "3.50" + subtotal_iva_0: '4.95', + subtotal_iva: '10', + iva: '1.54', + ice: '3.50' } } @@ -42,7 +42,7 @@ def test_successful_purchase_with_options def test_failed_purchase options = { amount: { - subtotal_iva: "200" + subtotal_iva: '200' } } @@ -79,7 +79,7 @@ def test_successful_void end def test_failed_void - response = @gateway.void("000") + response = @gateway.void('000') assert_failure response assert_equal 'El monto de la transacción es requerido', response.message end diff --git a/test/remote/gateways/remote_latitude19_test.rb b/test/remote/gateways/remote_latitude19_test.rb index c3be83d3013..ac977badebc 100644 --- a/test/remote/gateways/remote_latitude19_test.rb +++ b/test/remote/gateways/remote_latitude19_test.rb @@ -1,12 +1,12 @@ -require "test_helper" +require 'test_helper' class RemoteLatitude19Test < Test::Unit::TestCase def setup @gateway = Latitude19Gateway.new(fixtures(:latitude19)) @amount = 100 - @credit_card = credit_card("4000100011112224", verification_value: "747") - @declined_card = credit_card("0000000000000000") + @credit_card = credit_card('4000100011112224', verification_value: '747') + @declined_card = credit_card('0000000000000000') @options = { order_id: generate_unique_id, @@ -15,7 +15,7 @@ def setup end def test_invalid_login - gateway = Latitude19Gateway.new(account_number: "", configuration_id: "", secret: "") + gateway = Latitude19Gateway.new(account_number: '', configuration_id: '', secret: '') response = gateway.purchase(@amount, @credit_card, @options) assert_failure response end @@ -23,7 +23,7 @@ def test_invalid_login def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert response.test? end @@ -36,12 +36,12 @@ def test_successful_purchase def test_successful_authorize_and_capture response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_match %r(^auth\|\w+$), response.authorization capture = @gateway.capture(@amount, response.authorization, @options) assert_success capture - assert_equal "Approved", capture.message + assert_equal 'Approved', capture.message end # def test_failed_authorize @@ -52,11 +52,11 @@ def test_successful_authorize_and_capture # end def test_failed_capture - authorization = "auth" + "|" + SecureRandom.hex(6) + authorization = 'auth' + '|' + SecureRandom.hex(6) response = @gateway.capture(@amount, authorization, @options) assert_failure response - assert_equal "Not submitted", response.message - assert_equal "400", response.error_code + assert_equal 'Not submitted', response.message + assert_equal '400', response.error_code end def test_successful_void @@ -65,7 +65,7 @@ def test_successful_void void = @gateway.void(auth.authorization, @options) assert_success void - assert_equal "Approved", void.message + assert_equal 'Approved', void.message # response = @gateway.authorize(@amount, @credit_card, @options) # assert_success response @@ -84,25 +84,25 @@ def test_successful_void void = @gateway.void(purchase.authorization, @options) assert_success void - assert_equal "Approved", void.message + assert_equal 'Approved', void.message end def test_failed_void auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - authorization = auth.authorization[0..9] + "XX" + authorization = auth.authorization[0..9] + 'XX' response = @gateway.void(authorization, @options) assert_failure response - assert_equal "Not submitted", response.message - assert_equal "400", response.error_code + assert_equal 'Not submitted', response.message + assert_equal '400', response.error_code end def test_successful_credit response = @gateway.credit(@amount, @credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end # def test_failed_credit @@ -114,7 +114,7 @@ def test_successful_credit def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end # def test_failed_verify @@ -127,19 +127,19 @@ def test_successful_verify def test_successful_store store = @gateway.store(@credit_card, @options) assert_success store - assert_equal "Approved", store.message + assert_equal 'Approved', store.message purchase = @gateway.purchase(@amount, store.authorization, @options) assert_success purchase - assert_equal "Approved", purchase.message + assert_equal 'Approved', purchase.message credit = @gateway.credit(@amount, store.authorization, @options) assert_success credit - assert_equal "Approved", credit.message + assert_equal 'Approved', credit.message verify = @gateway.verify(store.authorization, @options) assert_success verify - assert_equal "Approved", verify.message + assert_equal 'Approved', verify.message end # def test_failed_store diff --git a/test/remote/gateways/remote_linkpoint_test.rb b/test/remote/gateways/remote_linkpoint_test.rb index 8ad9a942e6f..d7a14b214f7 100644 --- a/test/remote/gateways/remote_linkpoint_test.rb +++ b/test/remote/gateways/remote_linkpoint_test.rb @@ -44,7 +44,7 @@ def test_successful_authorization assert_instance_of Response, response assert_success response - assert_equal "APPROVED", response.params["approved"] + assert_equal 'APPROVED', response.params['approved'] end def test_successful_authorization_and_capture @@ -62,15 +62,15 @@ def test_successful_purchase_without_cvv2_code assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "APPROVED", response.params["approved"] - assert_equal 'NNN', response.params["avs"] + assert_equal 'APPROVED', response.params['approved'] + assert_equal 'NNN', response.params['avs'] end def test_successful_purchase_with_cvv2_code assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "APPROVED", response.params["approved"] - assert_equal 'NNNM', response.params["avs"] + assert_equal 'APPROVED', response.params['approved'] + assert_equal 'NNNM', response.params['avs'] end def test_successful_purchase_and_void @@ -91,9 +91,9 @@ def test_successfull_purchase_and_credit def test_successfull_purchase_with_item_entity @options.merge!({:line_items => [ - {:id => '123456', :description => "Logo T-Shirt", :price => "12.00", :quantity => '1', :options => - [{:name => "Color", :value => "Red"}, {:name => "Size", :value => "XL"}]}, - {:id => '111', :description => "keychain", :price => "3.00", :quantity => '1'}]}) + {:id => '123456', :description => 'Logo T-Shirt', :price => '12.00', :quantity => '1', :options => + [{:name => 'Color', :value => 'Red'}, {:name => 'Size', :value => 'XL'}]}, + {:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'}]}) assert purchase = @gateway.purchase(1500, @credit_card, @options) assert_success purchase @@ -103,20 +103,20 @@ def test_successful_recurring_payment assert response = @gateway.recurring(2400, @credit_card, :order_id => generate_unique_id, :installments => 12, - :startdate => "immediate", + :startdate => 'immediate', :periodicity => :monthly, :billing_address => address ) assert_success response - assert_equal "APPROVED", response.params["approved"] + assert_equal 'APPROVED', response.params['approved'] end def test_declined_purchase_with_invalid_credit_card @credit_card.number = '1111111111111111' assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "DECLINED", response.params["approved"] + assert_equal 'DECLINED', response.params['approved'] end def test_cleans_whitespace_from_pem diff --git a/test/remote/gateways/remote_litle_certification_test.rb b/test/remote/gateways/remote_litle_certification_test.rb index 23bd7fafd13..94ed48e24e9 100644 --- a/test/remote/gateways/remote_litle_certification_test.rb +++ b/test/remote/gateways/remote_litle_certification_test.rb @@ -4,7 +4,7 @@ class RemoteLitleCertification < Test::Unit::TestCase def setup Base.mode = :test @gateway = LitleGateway.new(fixtures(:litle)) - @gateway.test_url = "https://payments.vantivprelive.com/vap/communicator/online" + @gateway.test_url = 'https://payments.vantivprelive.com/vap/communicator/online' end def test1 @@ -28,11 +28,11 @@ def test1 } } - auth_assertions(10100, credit_card, options, :avs => "X", :cvv => "M") + auth_assertions(10100, credit_card, options, :avs => 'X', :cvv => 'M') - authorize_avs_assertions(credit_card, options, :avs => "X", :cvv => "M") + authorize_avs_assertions(credit_card, options, :avs => 'X', :cvv => 'M') - sale_assertions(10100, credit_card, options, :avs => "X", :cvv => "M") + sale_assertions(10100, credit_card, options, :avs => 'X', :cvv => 'M') end def test2 @@ -53,11 +53,11 @@ def test2 } } - auth_assertions(10100, credit_card, options, :avs => "Z", :cvv => "M") + auth_assertions(10100, credit_card, options, :avs => 'Z', :cvv => 'M') - authorize_avs_assertions(credit_card, options, :avs => "Z", :cvv => "M") + authorize_avs_assertions(credit_card, options, :avs => 'Z', :cvv => 'M') - sale_assertions(10100, credit_card, options, :avs => "Z", :cvv => "M") + sale_assertions(10100, credit_card, options, :avs => 'Z', :cvv => 'M') end def test3 @@ -80,11 +80,11 @@ def test3 :country => 'US' } } - auth_assertions(10100, credit_card, options, :avs => "Z", :cvv => "M") + auth_assertions(10100, credit_card, options, :avs => 'Z', :cvv => 'M') - authorize_avs_assertions(credit_card, options, :avs => "Z", :cvv => "M") + authorize_avs_assertions(credit_card, options, :avs => 'Z', :cvv => 'M') - sale_assertions(10100, credit_card, options, :avs => "Z", :cvv => "M") + sale_assertions(10100, credit_card, options, :avs => 'Z', :cvv => 'M') end def test4 @@ -107,11 +107,11 @@ def test4 } } - auth_assertions(10100, credit_card, options, :avs => "A", :cvv => nil) + auth_assertions(10100, credit_card, options, :avs => 'A', :cvv => nil) - authorize_avs_assertions(credit_card, options, :avs => "A") + authorize_avs_assertions(credit_card, options, :avs => 'A') - sale_assertions(10100, credit_card, options, :avs => "A", :cvv => nil) + sale_assertions(10100, credit_card, options, :avs => 'A', :cvv => nil) end def test5 @@ -128,11 +128,11 @@ def test5 :order_id => '5' } - auth_assertions(10100, credit_card, options, :avs => "U", :cvv => "M") + auth_assertions(10100, credit_card, options, :avs => 'U', :cvv => 'M') - authorize_avs_assertions(credit_card, options, :avs => "U", :cvv => "M") + authorize_avs_assertions(credit_card, options, :avs => 'U', :cvv => 'M') - sale_assertions(10100, credit_card, options, :avs => "U", :cvv => "M") + sale_assertions(10100, credit_card, options, :avs => 'U', :cvv => 'M') end def test6 @@ -157,8 +157,8 @@ def test6 assert !response.success? assert_equal '110', response.params['response'] assert_equal 'Insufficient Funds', response.message - assert_equal "I", response.avs_result["code"] - assert_equal "P", response.cvv_result["code"] + assert_equal 'I', response.avs_result['code'] + assert_equal 'P', response.cvv_result['code'] puts "Test #{options[:order_id]} Authorize: #{txn_id(response)}" # 6. sale @@ -166,8 +166,8 @@ def test6 assert !response.success? assert_equal '110', response.params['response'] assert_equal 'Insufficient Funds', response.message - assert_equal "I", response.avs_result["code"] - assert_equal "P", response.cvv_result["code"] + assert_equal 'I', response.avs_result['code'] + assert_equal 'P', response.cvv_result['code'] puts "Test #{options[:order_id]} Sale: #{txn_id(response)}" @@ -201,20 +201,20 @@ def test7 assert !response.success? assert_equal '301', response.params['response'] assert_equal 'Invalid Account Number', response.message - assert_equal "I", response.avs_result["code"] - assert_equal "N", response.cvv_result["code"] + assert_equal 'I', response.avs_result['code'] + assert_equal 'N', response.cvv_result['code'] puts "Test #{options[:order_id]} Authorize: #{txn_id(response)}" # 7: authorize avs - authorize_avs_assertions(credit_card, options, :avs => "I", :cvv => "N", :message => "Invalid Account Number", :success => false) + authorize_avs_assertions(credit_card, options, :avs => 'I', :cvv => 'N', :message => 'Invalid Account Number', :success => false) # 7. sale assert response = @gateway.purchase(10100, credit_card, options) assert !response.success? assert_equal '301', response.params['response'] assert_equal 'Invalid Account Number', response.message - assert_equal "I", response.avs_result["code"] - assert_equal "N", response.cvv_result["code"] + assert_equal 'I', response.avs_result['code'] + assert_equal 'N', response.cvv_result['code'] puts "Test #{options[:order_id]} Sale: #{txn_id(response)}" end @@ -240,20 +240,20 @@ def test8 assert !response.success? assert_equal '123', response.params['response'] assert_equal 'Call Discover', response.message - assert_equal "I", response.avs_result["code"] - assert_equal "P", response.cvv_result["code"] + assert_equal 'I', response.avs_result['code'] + assert_equal 'P', response.cvv_result['code'] puts "Test #{options[:order_id]} Authorize: #{txn_id(response)}" # 8: authorize avs - authorize_avs_assertions(credit_card, options, :avs => "I", :cvv => "P", :message => "Call Discover", :success => false) + authorize_avs_assertions(credit_card, options, :avs => 'I', :cvv => 'P', :message => 'Call Discover', :success => false) # 8: sale assert response = @gateway.purchase(80080, credit_card, options) assert !response.success? assert_equal '123', response.params['response'] assert_equal 'Call Discover', response.message - assert_equal "I", response.avs_result["code"] - assert_equal "P", response.cvv_result["code"] + assert_equal 'I', response.avs_result['code'] + assert_equal 'P', response.cvv_result['code'] puts "Test #{options[:order_id]} Sale: #{txn_id(response)}" end @@ -279,18 +279,18 @@ def test9 assert !response.success? assert_equal '303', response.params['response'] assert_equal 'Pick Up Card', response.message - assert_equal "I", response.avs_result["code"] + assert_equal 'I', response.avs_result['code'] puts "Test #{options[:order_id]} Authorize: #{txn_id(response)}" # 9: authorize avs - authorize_avs_assertions(credit_card, options, :avs => "I", :message => "Pick Up Card", :success => false) + authorize_avs_assertions(credit_card, options, :avs => 'I', :message => 'Pick Up Card', :success => false) # 9: sale assert response = @gateway.purchase(10100, credit_card, options) assert !response.success? assert_equal '303', response.params['response'] assert_equal 'Pick Up Card', response.message - assert_equal "I", response.avs_result["code"] + assert_equal 'I', response.avs_result['code'] puts "Test #{options[:order_id]} Sale: #{txn_id(response)}" end @@ -402,7 +402,7 @@ def test35 assert auth_response = @gateway.authorize(10100, credit_card, options) assert_success auth_response assert_equal '44444 ', auth_response.params['authCode'] - assert_equal 'A', auth_response.avs_result["code"] + assert_equal 'A', auth_response.avs_result['code'] puts "Test #{options[:order_id]}: #{txn_id(auth_response)}" assert capture_response = @gateway.capture(5050, auth_response.authorization, options) @@ -1056,9 +1056,9 @@ def test_apple_pay_purchase { month: '01', year: '2021', - brand: "visa", - number: "4457000300000007", - payment_cryptogram: "BwABBJQ1AgAAAAAgJDUCAAAAAAA=" + brand: 'visa', + number: '4457000300000007', + payment_cryptogram: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=' }) assert response = @gateway.purchase(10010, decrypted_apple_pay, options) @@ -1075,9 +1075,9 @@ def test_android_pay_purchase source: :android_pay, month: '01', year: '2021', - brand: "visa", - number: "4457000300000007", - payment_cryptogram: "BwABBJQ1AgAAAAAgJDUCAAAAAAA=" + brand: 'visa', + number: '4457000300000007', + payment_cryptogram: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=' }) assert response = @gateway.purchase(10010, decrypted_android_pay, options) @@ -1168,8 +1168,8 @@ def auth_assertions(amount, card, options, assertions={}) assert response = @gateway.authorize(amount, card, options) assert_success response assert_equal 'Approved', response.message - assert_equal assertions[:avs], response.avs_result["code"] if assertions[:avs] - assert_equal assertions[:cvv], response.cvv_result["code"] if assertions[:cvv] + assert_equal assertions[:avs], response.avs_result['code'] if assertions[:avs] + assert_equal assertions[:cvv], response.cvv_result['code'] if assertions[:cvv] assert_equal auth_code(options[:order_id]), response.params['authCode'] puts "Test #{options[:order_id]} Authorize: #{txn_id(response)}" @@ -1193,8 +1193,8 @@ def authorize_avs_assertions(credit_card, options, assertions={}) assert response = @gateway.authorize(000, credit_card, options) assert_equal assertions.key?(:success) ? assertions[:success] : true, response.success? assert_equal assertions[:message] || 'Approved', response.message - assert_equal assertions[:avs], response.avs_result["code"], caller.inspect - assert_equal assertions[:cvv], response.cvv_result["code"], caller.inspect if assertions[:cvv] + assert_equal assertions[:avs], response.avs_result['code'], caller.inspect + assert_equal assertions[:cvv], response.cvv_result['code'], caller.inspect if assertions[:cvv] puts "Test #{options[:order_id]} AVS Only: #{txn_id(response)}" end @@ -1203,8 +1203,8 @@ def sale_assertions(amount, card, options, assertions={}) assert response = @gateway.purchase(amount, card, options) assert_success response assert_equal 'Approved', response.message - assert_equal assertions[:avs], response.avs_result["code"] if assertions[:avs] - assert_equal assertions[:cvv], response.cvv_result["code"] if assertions[:cvv] + assert_equal assertions[:avs], response.avs_result['code'] if assertions[:avs] + assert_equal assertions[:cvv], response.cvv_result['code'] if assertions[:cvv] assert_equal auth_code(options[:order_id]), response.params['authCode'] puts "Test #{options[:order_id]} Sale: #{txn_id(response)}" @@ -1225,8 +1225,8 @@ def auth_assertions(amount, card, options, assertions={}) assert response = @gateway.authorize(amount, card, options) assert_success response assert_equal 'Approved', response.message - assert_equal assertions[:avs], response.avs_result["code"] if assertions[:avs] - assert_equal assertions[:cvv], response.cvv_result["code"] if assertions[:cvv] + assert_equal assertions[:avs], response.avs_result['code'] if assertions[:avs] + assert_equal assertions[:cvv], response.cvv_result['code'] if assertions[:cvv] assert_equal auth_code(options[:order_id]), response.params['authCode'] # 1A: capture @@ -1246,8 +1246,8 @@ def authorize_avs_assertions(credit_card, options, assertions={}) assert response = @gateway.authorize(000, credit_card, options) assert_equal assertions.key?(:success) ? assertions[:success] : true, response.success? assert_equal assertions[:message] || 'Approved', response.message - assert_equal assertions[:avs], response.avs_result["code"], caller.inspect - assert_equal assertions[:cvv], response.cvv_result["code"], caller.inspect if assertions[:cvv] + assert_equal assertions[:avs], response.avs_result['code'], caller.inspect + assert_equal assertions[:cvv], response.cvv_result['code'], caller.inspect if assertions[:cvv] end def sale_assertions(amount, card, options, assertions={}) @@ -1255,8 +1255,8 @@ def sale_assertions(amount, card, options, assertions={}) assert response = @gateway.purchase(amount, card, options) assert_success response assert_equal 'Approved', response.message - assert_equal assertions[:avs], response.avs_result["code"] if assertions[:avs] - assert_equal assertions[:cvv], response.cvv_result["code"] if assertions[:cvv] + assert_equal assertions[:avs], response.avs_result['code'] if assertions[:avs] + assert_equal assertions[:cvv], response.cvv_result['code'] if assertions[:cvv] # assert_equal auth_code(options[:order_id]), response.params['authCode'] # 1B: credit @@ -1302,6 +1302,6 @@ def auth_code(order_id) end def txn_id(response) - response.authorization.split(";")[0] + response.authorization.split(';')[0] end end diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb index 014cbdd8afe..966acfc125e 100644 --- a/test/remote/gateways/remote_litle_test.rb +++ b/test/remote/gateways/remote_litle_test.rb @@ -29,39 +29,39 @@ def setup @credit_card1 = CreditCard.new(@credit_card_hash) @credit_card2 = CreditCard.new( - first_name: "Joe", - last_name: "Green", - month: "06", - year: "2012", - brand: "visa", - number: "4457010100000008", - verification_value: "992" + first_name: 'Joe', + last_name: 'Green', + month: '06', + year: '2012', + brand: 'visa', + number: '4457010100000008', + verification_value: '992' ) @credit_card_nsf = CreditCard.new( - first_name: "Joe", - last_name: "Green", - month: "06", - year: "2012", - brand: "visa", - number: "4488282659650110", - verification_value: "992" + first_name: 'Joe', + last_name: 'Green', + month: '06', + year: '2012', + brand: 'visa', + number: '4488282659650110', + verification_value: '992' ) @decrypted_apple_pay = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new( { month: '01', year: '2012', - brand: "visa", - number: "44444444400009", - payment_cryptogram: "BwABBJQ1AgAAAAAgJDUCAAAAAAA=" + brand: 'visa', + number: '44444444400009', + payment_cryptogram: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=' }) @decrypted_android_pay = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new( { source: :android_pay, month: '01', year: '2021', - brand: "visa", - number: "4457000300000007", - payment_cryptogram: "BwABBJQ1AgAAAAAgJDUCAAAAAAA=" + brand: 'visa', + number: '4457000300000007', + payment_cryptogram: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=' }) @check = check( name: 'Tom Black', @@ -108,8 +108,8 @@ def test_successful_authorization_with_echeck def test_avs_and_cvv_result assert response = @gateway.authorize(10010, @credit_card1, @options) - assert_equal "X", response.avs_result["code"] - assert_equal "M", response.cvv_result["code"] + assert_equal 'X', response.avs_result['code'] + assert_equal 'M', response.cvv_result['code'] end def test_unsuccessful_authorization @@ -253,7 +253,7 @@ def test_void_authorization end def test_unsuccessful_void - assert void = @gateway.void("123456789012345360;authorization;100") + assert void = @gateway.void('123456789012345360;authorization;100') assert_failure void assert_equal 'No transaction found with specified litleTxnId', void.message end @@ -339,7 +339,7 @@ def test_store_successful end def test_store_with_paypage_registration_id_successful - paypage_registration_id = "cDZJcmd1VjNlYXNaSlRMTGpocVZQY1NNlYE4ZW5UTko4NU9KK3p1L1p1VzE4ZWVPQVlSUHNITG1JN2I0NzlyTg=" + paypage_registration_id = 'cDZJcmd1VjNlYXNaSlRMTGpocVZQY1NNlYE4ZW5UTko4NU9KK3p1L1p1VzE4ZWVPQVlSUHNITG1JN2I0NzlyTg=' assert store_response = @gateway.store(paypage_registration_id, :order_id => '50') assert_success store_response @@ -387,7 +387,7 @@ def test_successful_verify assert response = @gateway.verify(@credit_card1, @options) assert_success response assert_equal 'Approved', response.message - assert_success response.responses.last, "The void should succeed" + assert_success response.responses.last, 'The void should succeed' end def test_unsuccessful_verify @@ -398,8 +398,8 @@ def test_unsuccessful_verify def test_successful_purchase_with_dynamic_descriptors assert response = @gateway.purchase(10010, @credit_card1, @options.merge( - descriptor_name: "SuperCompany", - descriptor_phone: "9193341121", + descriptor_name: 'SuperCompany', + descriptor_phone: '9193341121', )) assert_success response assert_equal 'Approved', response.message diff --git a/test/remote/gateways/remote_maxipago_test.rb b/test/remote/gateways/remote_maxipago_test.rb index 9ac1d94c2b5..4e6c852937a 100644 --- a/test/remote/gateways/remote_maxipago_test.rb +++ b/test/remote/gateways/remote_maxipago_test.rb @@ -20,13 +20,13 @@ def setup def test_successful_authorize assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "AUTHORIZED", response.message + assert_equal 'AUTHORIZED', response.message end def test_failed_authorize assert response = @gateway.authorize(@amount, @invalid_card, @options) assert_failure response - assert_equal "The transaction has an expired credit card.", response.message + assert_equal 'The transaction has an expired credit card.', response.message end def test_successful_authorize_and_capture @@ -49,7 +49,7 @@ def test_successful_purchase_sans_options end def test_successful_purchase_with_currency - assert response = @gateway.purchase(@amount, @credit_card, @options.merge(currency: "CLP")) + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(currency: 'CLP')) assert_success response end @@ -69,13 +69,13 @@ def test_successful_void void = @gateway.void(auth.authorization) assert_success void - assert_equal "VOIDED", void.message + assert_equal 'VOIDED', void.message end def test_failed_void - response = @gateway.void("NOAUTH|0000000") + response = @gateway.void('NOAUTH|0000000') assert_failure response - assert_equal "Unable to validate, original void transaction not found", response.message + assert_equal 'Unable to validate, original void transaction not found', response.message end def test_successful_refund @@ -84,7 +84,7 @@ def test_successful_refund refund = @gateway.refund(@amount, purchase.authorization, @options) assert_success refund - assert_equal "CAPTURED", refund.message + assert_equal 'CAPTURED', refund.message end def test_failed_refund @@ -94,19 +94,19 @@ def test_failed_refund refund_amount = @amount + 10 refund = @gateway.refund(refund_amount, purchase.authorization, @options) assert_failure refund - assert_equal "The Return amount is greater than the amount that can be returned.", refund.message + assert_equal 'The Return amount is greater than the amount that can be returned.', refund.message end def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "AUTHORIZED", response.message + assert_equal 'AUTHORIZED', response.message end def test_failed_verify response = @gateway.verify(@invalid_card, @options) assert_failure response - assert_equal "The transaction has an expired credit card.", response.message + assert_equal 'The transaction has an expired credit card.', response.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_mercado_pago_test.rb b/test/remote/gateways/remote_mercado_pago_test.rb index 415de94fbb2..aeda0a15172 100644 --- a/test/remote/gateways/remote_mercado_pago_test.rb +++ b/test/remote/gateways/remote_mercado_pago_test.rb @@ -10,7 +10,7 @@ def setup @options = { billing_address: address, shipping_address: address, - email: "user+br@example.com", + email: 'user+br@example.com', description: 'Store Purchase' } end @@ -39,7 +39,7 @@ def test_successful_purchase_with_american_express def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "rejected", response.error_code + assert_equal 'rejected', response.error_code assert_equal 'cc_rejected_other_reason', response.message end diff --git a/test/remote/gateways/remote_merchant_e_solutions_test.rb b/test/remote/gateways/remote_merchant_e_solutions_test.rb index 8e60553c49a..a9504dac516 100644 --- a/test/remote/gateways/remote_merchant_e_solutions_test.rb +++ b/test/remote/gateways/remote_merchant_e_solutions_test.rb @@ -44,7 +44,7 @@ def test_unsuccessful_purchase end def test_purchase_with_long_order_id - options = {order_id: "thisislongerthan17characters"} + options = {order_id: 'thisislongerthan17characters'} assert response = @gateway.purchase(@amount, @credit_card, options) assert_success response assert_equal 'This transaction has been approved', response.message diff --git a/test/remote/gateways/remote_merchant_partners_test.rb b/test/remote/gateways/remote_merchant_partners_test.rb index f398ae39112..846415b674b 100644 --- a/test/remote/gateways/remote_merchant_partners_test.rb +++ b/test/remote/gateways/remote_merchant_partners_test.rb @@ -1,24 +1,24 @@ -require "test_helper" +require 'test_helper' class RemoteMerchantPartnersTest < Test::Unit::TestCase def setup @gateway = MerchantPartnersGateway.new(fixtures(:merchant_partners)) @amount = 100 - @credit_card = credit_card("4003000123456781") - @declined_card = credit_card("4003000123456782") + @credit_card = credit_card('4003000123456781') + @declined_card = credit_card('4003000123456782') @options = { order_id: generate_unique_id, billing_address: address, - description: "Store Purchase" + description: 'Store Purchase' } end def test_invalid_login gateway = MerchantPartnersGateway.new( - account_id: "TEST0", - merchant_pin: "1" + account_id: 'TEST0', + merchant_pin: '1' ) response = gateway.purchase(@amount, @credit_card, @options) assert_failure response @@ -27,39 +27,39 @@ def test_invalid_login def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response assert_match(/Invalid account/, response.message) - assert response.params["result"].start_with?("DECLINED") + assert response.params['result'].start_with?('DECLINED') end def test_successful_authorize_and_capture response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^\d+), response.authorization capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response assert_match(/Invalid account/, response.message) - assert response.params["result"].start_with?("DECLINED") + assert response.params['result'].start_with?('DECLINED') end def test_failed_capture - response = @gateway.capture(@amount, "BAD") + response = @gateway.capture(@amount, 'BAD') assert_failure response - assert_equal "Missing account number", response.message - assert response.params["result"].start_with?("DECLINED") + assert_equal 'Missing account number', response.message + assert response.params['result'].start_with?('DECLINED') end def test_successful_void @@ -68,14 +68,14 @@ def test_successful_void void = @gateway.void(response.authorization) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end def test_failed_void - response = @gateway.void("") + response = @gateway.void('') assert_failure response - assert_equal "Invalid acct type", response.message - assert response.params["result"].start_with?("DECLINED") + assert_equal 'Invalid acct type', response.message + assert response.params['result'].start_with?('DECLINED') end def test_successful_refund @@ -84,27 +84,27 @@ def test_successful_refund refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "Succeeded", refund.message + assert_equal 'Succeeded', refund.message end def test_failed_refund - response = @gateway.refund(nil, "") + response = @gateway.refund(nil, '') assert_failure response - assert_equal "Missing account number", response.message - assert response.params["result"].start_with?("DECLINED") + assert_equal 'Missing account number', response.message + assert response.params['result'].start_with?('DECLINED') end def test_successful_credit response = @gateway.credit(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_credit response = @gateway.credit(@amount, @declined_card, @options) assert_failure response assert_match(/Invalid account/, response.message) - assert response.params["result"].start_with?("DECLINED") + assert response.params['result'].start_with?('DECLINED') end def test_successful_verify @@ -117,27 +117,27 @@ def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response assert_match(/Invalid account/, response.message) - assert response.params["result"].start_with?("DECLINED") + assert response.params['result'].start_with?('DECLINED') end def test_successful_store_and_purchase response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message purchase = @gateway.purchase(@amount, response.authorization, @options) assert_success purchase - assert_equal "Succeeded", purchase.message + assert_equal 'Succeeded', purchase.message end def test_successful_store_and_credit response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message credit = @gateway.credit(@amount, response.authorization, @options) assert_success credit - assert_equal "Succeeded", credit.message + assert_equal 'Succeeded', credit.message end def test_failed_store diff --git a/test/remote/gateways/remote_merchant_ware_test.rb b/test/remote/gateways/remote_merchant_ware_test.rb index 399f0552ce6..71c812e730a 100644 --- a/test/remote/gateways/remote_merchant_ware_test.rb +++ b/test/remote/gateways/remote_merchant_ware_test.rb @@ -21,7 +21,7 @@ def test_successful_authorization end def test_unsuccessful_authorization - @credit_card.number = "1234567890123" + @credit_card.number = '1234567890123' assert response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response end @@ -33,7 +33,7 @@ def test_successful_purchase end def test_unsuccessful_purchase - @credit_card.number = "1234567890123" + @credit_card.number = '1234567890123' assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response end diff --git a/test/remote/gateways/remote_merchant_ware_version_four_test.rb b/test/remote/gateways/remote_merchant_ware_version_four_test.rb index 61ca4d2866b..f1c538cc470 100644 --- a/test/remote/gateways/remote_merchant_ware_version_four_test.rb +++ b/test/remote/gateways/remote_merchant_ware_version_four_test.rb @@ -24,7 +24,7 @@ def test_successful_authorization end def test_unsuccessful_authorization - @credit_card.number = "1234567890123" + @credit_card.number = '1234567890123' assert response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response end @@ -36,7 +36,7 @@ def test_successful_purchase end def test_unsuccessful_purchase - @credit_card.number = "1234567890123" + @credit_card.number = '1234567890123' assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response end diff --git a/test/remote/gateways/remote_merchant_warrior_test.rb b/test/remote/gateways/remote_merchant_warrior_test.rb index ade8d20e594..d9c5e826c4a 100644 --- a/test/remote/gateways/remote_merchant_warrior_test.rb +++ b/test/remote/gateways/remote_merchant_warrior_test.rb @@ -32,13 +32,13 @@ def test_successful_authorize assert auth = @gateway.authorize(@success_amount, @credit_card, @options) assert_success auth assert_equal 'Transaction approved', auth.message - assert_not_nil auth.params["transaction_id"] - assert_equal auth.params["transaction_id"], auth.authorization + assert_not_nil auth.params['transaction_id'] + assert_equal auth.params['transaction_id'], auth.authorization assert capture = @gateway.capture(@success_amount, auth.authorization) assert_success capture - assert_not_nil capture.params["transaction_id"] - assert_equal capture.params["transaction_id"], capture.authorization + assert_not_nil capture.params['transaction_id'] + assert_equal capture.params['transaction_id'], capture.authorization assert_not_equal auth.authorization, capture.authorization end @@ -46,16 +46,16 @@ def test_successful_purchase assert purchase = @gateway.purchase(@success_amount, @credit_card, @options) assert_equal 'Transaction approved', purchase.message assert_success purchase - assert_not_nil purchase.params["transaction_id"] - assert_equal purchase.params["transaction_id"], purchase.authorization + assert_not_nil purchase.params['transaction_id'] + assert_equal purchase.params['transaction_id'], purchase.authorization end def test_failed_purchase assert purchase = @gateway.purchase(@failure_amount, @credit_card, @options) assert_equal 'Transaction declined', purchase.message assert_failure purchase - assert_not_nil purchase.params["transaction_id"] - assert_equal purchase.params["transaction_id"], purchase.authorization + assert_not_nil purchase.params['transaction_id'] + assert_equal purchase.params['transaction_id'], purchase.authorization end def test_successful_refund @@ -105,9 +105,9 @@ def test_token_auth end def test_successful_purchase_with_funky_names - @credit_card.first_name = "Phillips & Sons" + @credit_card.first_name = 'Phillips & Sons' @credit_card.last_name = "Other-Things; MW. doesn't like" - @options[:billing_address][:name] = "Merchant Warrior wants % alphanumerics" + @options[:billing_address][:name] = 'Merchant Warrior wants % alphanumerics' assert purchase = @gateway.purchase(@success_amount, @credit_card, @options) assert_equal 'Transaction approved', purchase.message diff --git a/test/remote/gateways/remote_mercury_certification_test.rb b/test/remote/gateways/remote_mercury_certification_test.rb index 9020387e86c..f019b3ad045 100644 --- a/test/remote/gateways/remote_mercury_certification_test.rb +++ b/test/remote/gateways/remote_mercury_certification_test.rb @@ -1,5 +1,5 @@ require 'test_helper' -require "support/mercury_helper" +require 'support/mercury_helper' class RemoteMercuryCertificationTest < Test::Unit::TestCase include MercuryHelper @@ -9,130 +9,130 @@ class RemoteMercuryCertificationTest < Test::Unit::TestCase def test_sale_and_reversal close_batch(tokenization_gateway) - sale = tokenization_gateway.purchase(101, visa, options("1")) + sale = tokenization_gateway.purchase(101, visa, options('1')) assert_success sale - assert_equal "AP", sale.params["text_response"] + assert_equal 'AP', sale.params['text_response'] reversal = tokenization_gateway.void(sale.authorization, options.merge(:try_reversal => true)) assert_success reversal - assert_equal "REVERSED", reversal.params["text_response"] + assert_equal 'REVERSED', reversal.params['text_response'] end def test_sale_and_void close_batch(tokenization_gateway) - sale = tokenization_gateway.purchase(103, visa, options("1")) + sale = tokenization_gateway.purchase(103, visa, options('1')) assert_success sale - assert_equal "AP", sale.params["text_response"] + assert_equal 'AP', sale.params['text_response'] void = tokenization_gateway.void(sale.authorization, options) assert_success void - assert_equal "AP", void.params["text_response"] + assert_equal 'AP', void.params['text_response'] end def test_preauth_capture_and_reversal close_batch(tokenization_gateway) cc = credit_card( - "4005550000000480", - :brand => "visa", - :month => "12", - :year => "15", - :verification_value => "123" + '4005550000000480', + :brand => 'visa', + :month => '12', + :year => '15', + :verification_value => '123' ) - preauth = tokenization_gateway.authorize(106, cc, options("1")) + preauth = tokenization_gateway.authorize(106, cc, options('1')) assert_success preauth - assert_equal "AP", preauth.params["text_response"] + assert_equal 'AP', preauth.params['text_response'] capture = tokenization_gateway.capture(106, preauth.authorization, options) assert_success capture - assert_equal "AP", capture.params["text_response"] + assert_equal 'AP', capture.params['text_response'] reversal = tokenization_gateway.void(capture.authorization, options.merge(:try_reversal => true)) assert_success reversal - assert_equal "REVERSED", reversal.params["text_response"] + assert_equal 'REVERSED', reversal.params['text_response'] end def test_return close_batch(tokenization_gateway) - credit = tokenization_gateway.credit(109, visa, options("1")) + credit = tokenization_gateway.credit(109, visa, options('1')) assert_success credit - assert_equal "AP", credit.params["text_response"] + assert_equal 'AP', credit.params['text_response'] end def test_preauth_and_reversal close_batch(tokenization_gateway) - preauth = tokenization_gateway.authorize(113, disc, options("1")) + preauth = tokenization_gateway.authorize(113, disc, options('1')) assert_success preauth - assert_equal "AP", preauth.params["text_response"] + assert_equal 'AP', preauth.params['text_response'] reversal = tokenization_gateway.void(preauth.authorization, options.merge(:try_reversal => true)) assert_success reversal - assert_equal "REVERSED", reversal.params["text_response"] + assert_equal 'REVERSED', reversal.params['text_response'] end def test_preauth_capture_and_reversal close_batch(tokenization_gateway) - preauth = tokenization_gateway.authorize(106, visa, options("1")) + preauth = tokenization_gateway.authorize(106, visa, options('1')) assert_success preauth - assert_equal "AP", preauth.params["text_response"] + assert_equal 'AP', preauth.params['text_response'] capture = tokenization_gateway.capture(206, preauth.authorization, options) assert_success capture - assert_equal "AP", capture.params["text_response"] + assert_equal 'AP', capture.params['text_response'] void = tokenization_gateway.void(capture.authorization, options) assert_success void - assert_equal "AP", void.params["text_response"] + assert_equal 'AP', void.params['text_response'] end private def tokenization_gateway @tokenization_gateway ||= MercuryGateway.new( - :login => "023358150511666", - :password => "xyz" + :login => '023358150511666', + :password => 'xyz' ) end def visa @visa ||= credit_card( - "4003000123456781", - :brand => "visa", - :month => "12", - :year => "15", - :verification_value => "123" + '4003000123456781', + :brand => 'visa', + :month => '12', + :year => '15', + :verification_value => '123' ) end def disc @disc ||= credit_card( - "6011000997235373", - :brand => "discover", - :month => "12", - :year => "15", - :verification_value => "362" + '6011000997235373', + :brand => 'discover', + :month => '12', + :year => '15', + :verification_value => '362' ) end def mc @mc ||= credit_card( - "5439750001500248", - :brand => "master", - :month => "12", - :year => "15", - :verification_value => "123" + '5439750001500248', + :brand => 'master', + :month => '12', + :year => '15', + :verification_value => '123' ) end def options(order_id=nil, other={}) { :order_id => order_id, - :description => "ActiveMerchant", + :description => 'ActiveMerchant', }.merge(other) end end diff --git a/test/remote/gateways/remote_mercury_test.rb b/test/remote/gateways/remote_mercury_test.rb index b2fb7157cd3..4dd1a95b80c 100644 --- a/test/remote/gateways/remote_mercury_test.rb +++ b/test/remote/gateways/remote_mercury_test.rb @@ -1,5 +1,5 @@ require 'test_helper' -require "support/mercury_helper" +require 'support/mercury_helper' class RemoteMercuryTest < Test::Unit::TestCase include MercuryHelper @@ -9,14 +9,14 @@ def setup @amount = 100 - @credit_card = credit_card("4003000123456781", :brand => "visa", :month => "12", :year => "18") + @credit_card = credit_card('4003000123456781', :brand => 'visa', :month => '12', :year => '18') - @track_1_data = "%B4003000123456781^LONGSEN/L. ^18121200000000000000**123******?*" - @track_2_data = ";5413330089010608=2512101097750213?" + @track_1_data = '%B4003000123456781^LONGSEN/L. ^18121200000000000000**123******?*' + @track_2_data = ';5413330089010608=2512101097750213?' @options = { - :order_id => "c111111111.1", - :description => "ActiveMerchant" + :order_id => 'c111111111.1', + :description => 'ActiveMerchant' } @options_with_billing = @options.merge( :merchant => '999', @@ -27,9 +27,9 @@ def setup ) @full_options = @options_with_billing.merge( :ip => '123.123.123.123', - :merchant => "Open Dining", - :customer => "Tim", - :tax => "5" + :merchant => 'Open Dining', + :customer => 'Tim', + :tax => '5' ) close_batch @@ -48,7 +48,7 @@ def test_successful_authorize_and_capture def test_failed_authorize response = @gateway.authorize(1100, @credit_card, @options) assert_failure response - assert_equal "DECLINE", response.message + assert_equal 'DECLINE', response.message end def test_purchase_and_void @@ -63,14 +63,14 @@ def test_successful_purchase response = @gateway.purchase(50, @credit_card, @options) assert_success response - assert_equal "0.50", response.params["purchase"] + assert_equal '0.50', response.params['purchase'] end def test_store response = @gateway.store(@credit_card, @options) assert_success response - assert response.params.has_key?("record_no") + assert response.params.has_key?('record_no') assert response.params['record_no'] != '' end @@ -78,13 +78,13 @@ def test_credit response = @gateway.credit(50, @credit_card, @options) assert_success response - assert_equal "0.50", response.params["purchase"], response.inspect + assert_equal '0.50', response.params['purchase'], response.inspect end def test_failed_purchase response = @gateway.purchase(1100, @credit_card, @options) assert_failure response - assert_equal "DECLINE", response.message + assert_equal 'DECLINE', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code end @@ -94,14 +94,14 @@ def test_avs_and_cvv_results assert_success response assert_equal( { - "code" => "Y", - "postal_match" => "Y", - "street_match" => "Y", - "message" => "Street address and 5-digit postal code match." + 'code' => 'Y', + 'postal_match' => 'Y', + 'street_match' => 'Y', + 'message' => 'Street address and 5-digit postal code match.' }, response.avs_result ) - assert_equal({"code"=>"M", "message"=>"CVV matches"}, response.cvv_result) + assert_equal({'code'=>'M', 'message'=>'CVV matches'}, response.cvv_result) end def test_avs_and_cvv_results_with_track_data @@ -111,18 +111,18 @@ def test_avs_and_cvv_results_with_track_data assert_success response assert_equal( { - "code" => nil, - "postal_match" => nil, - "street_match" => nil, - "message" => nil + 'code' => nil, + 'postal_match' => nil, + 'street_match' => nil, + 'message' => nil }, response.avs_result ) - assert_equal({"code"=>'P', "message"=>'CVV not processed'}, response.cvv_result) + assert_equal({'code'=>'P', 'message'=>'CVV not processed'}, response.cvv_result) end def test_partial_capture - visa_partial_card = credit_card("4005550000000480") + visa_partial_card = credit_card('4005550000000480') response = @gateway.authorize(2354, visa_partial_card, @options) @@ -140,11 +140,11 @@ def test_authorize_with_bad_expiration_date @credit_card.year = 2001 response = @gateway.authorize(575, @credit_card, @options_with_billing) assert_failure response - assert_equal "INVLD EXP DATE", response.message + assert_equal 'INVLD EXP DATE', response.message end def test_mastercard_authorize_and_capture_with_refund - mc = credit_card("5499990123456781", :brand => "master") + mc = credit_card('5499990123456781', :brand => 'master') response = @gateway.authorize(200, mc, @options) assert_success response @@ -161,7 +161,7 @@ def test_mastercard_authorize_and_capture_with_refund end def test_amex_authorize_and_capture_with_refund - amex = credit_card("373953244361001", :brand => "american_express", :verification_value => "1234") + amex = credit_card('373953244361001', :brand => 'american_express', :verification_value => '1234') response = @gateway.authorize(201, amex, @options) assert_success response @@ -177,7 +177,7 @@ def test_amex_authorize_and_capture_with_refund end def test_discover_authorize_and_capture - discover = credit_card("6011000997235373", :brand => "discover") + discover = credit_card('6011000997235373', :brand => 'discover') response = @gateway.authorize(225, discover, @options_with_billing) assert_success response diff --git a/test/remote/gateways/remote_metrics_global_test.rb b/test/remote/gateways/remote_metrics_global_test.rb index 4748cdc23c3..b1d19387559 100644 --- a/test/remote/gateways/remote_metrics_global_test.rb +++ b/test/remote/gateways/remote_metrics_global_test.rb @@ -64,12 +64,12 @@ def test_bad_login assert response = gateway.purchase(@amount, @credit_card) assert_equal Response, response.class - assert_equal ["avs_result_code", - "card_code", - "response_code", - "response_reason_code", - "response_reason_text", - "transaction_id"], response.params.keys.sort + assert_equal ['avs_result_code', + 'card_code', + 'response_code', + 'response_reason_code', + 'response_reason_text', + 'transaction_id'], response.params.keys.sort assert_match(/Authentication Failed/, response.message) @@ -85,12 +85,12 @@ def test_using_test_request assert response = gateway.purchase(@amount, @credit_card) assert_equal Response, response.class - assert_equal ["avs_result_code", - "card_code", - "response_code", - "response_reason_code", - "response_reason_text", - "transaction_id"], response.params.keys.sort + assert_equal ['avs_result_code', + 'card_code', + 'response_code', + 'response_reason_code', + 'response_reason_text', + 'transaction_id'], response.params.keys.sort assert_match(/Authentication Failed/, response.message) diff --git a/test/remote/gateways/remote_micropayment_test.rb b/test/remote/gateways/remote_micropayment_test.rb index 8d8075f8278..29b3a3fdcd1 100644 --- a/test/remote/gateways/remote_micropayment_test.rb +++ b/test/remote/gateways/remote_micropayment_test.rb @@ -5,109 +5,109 @@ def setup @gateway = MicropaymentGateway.new(fixtures(:micropayment)) @amount = 250 - @credit_card = credit_card("4111111111111111", verification_value: "666") - @declined_card = credit_card("4111111111111111") + @credit_card = credit_card('4111111111111111', verification_value: '666') + @declined_card = credit_card('4111111111111111') @options = { order_id: generate_unique_id, - description: "Eggcellent", + description: 'Eggcellent', billing_address: address } end def test_invalid_login - gateway = MicropaymentGateway.new(access_key: "invalid", api_key:"invalid") + gateway = MicropaymentGateway.new(access_key: 'invalid', api_key:'invalid') response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Authorization failed - Reason: api accesskey wrong", response.message + assert_equal 'Authorization failed - Reason: api accesskey wrong', response.message end def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "AS stellt falsches Routing fest", response.message + assert_equal 'AS stellt falsches Routing fest', response.message end def test_successful_authorize_and_capture response = @gateway.authorize(@amount, @credit_card) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^\w+\|.+$), response.authorization capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_successful_authorize_and_capture_with_recurring - @credit_card.verification_value = "" + @credit_card.verification_value = '' response = @gateway.authorize(@amount, @credit_card, @options.merge(recurring: true)) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^\w+\|.+$), response.authorization capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_partial_capture response = @gateway.authorize(@amount, @credit_card, @options) capture = @gateway.capture(100, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal "AS stellt falsches Routing fest", response.message - assert_equal "ipg92", response.params["transactionResultCode"] + assert_equal 'AS stellt falsches Routing fest', response.message + assert_equal 'ipg92', response.params['transactionResultCode'] end def test_failed_capture - response = @gateway.capture(@amount, "1|2") + response = @gateway.capture(@amount, '1|2') assert_failure response - assert_equal "\"sessionId\" with the value \"1\" does not exist", response.message - assert_equal "3110", response.params["error"] + assert_equal '"sessionId" with the value "1" does not exist', response.message + assert_equal '3110', response.params['error'] end def test_successful_void_for_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message void = @gateway.void(response.authorization) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end def test_successful_authorize_and_capture_and_refund response = @gateway.authorize(@amount, @credit_card, @options.merge(recurring: false)) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^\w+\|.+$), response.authorization capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message refund = @gateway.refund(@amount, capture.authorization) assert_success refund - assert_equal "Succeeded", refund.message + assert_equal 'Succeeded', refund.message end def test_failed_void - response = @gateway.void("") + response = @gateway.void('') assert_failure response - assert_equal "\"transactionId\" is empty", response.message - assert_equal "3101", response.params["error"] + assert_equal '"transactionId" is empty', response.message + assert_equal '3101', response.params['error'] end def test_successful_refund @@ -116,26 +116,26 @@ def test_successful_refund refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "Succeeded", refund.message + assert_equal 'Succeeded', refund.message end def test_failed_refund - response = @gateway.refund(nil, "") + response = @gateway.refund(nil, '') assert_failure response - assert_equal "\"transactionId\" is empty", response.message - assert_equal "3101", response.params["error"] + assert_equal '"transactionId" is empty', response.message + assert_equal '3101', response.params['error'] end def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_match "Succeeded", response.message + assert_match 'Succeeded', response.message end def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "AS stellt falsches Routing fest", response.message + assert_equal 'AS stellt falsches Routing fest', response.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_modern_payments_cim_test.rb b/test/remote/gateways/remote_modern_payments_cim_test.rb index efd3bec9c6f..a6afc2b97fe 100644 --- a/test/remote/gateways/remote_modern_payments_cim_test.rb +++ b/test/remote/gateways/remote_modern_payments_cim_test.rb @@ -19,25 +19,25 @@ def setup def test_successful_create_customer response = @gateway.create_customer(@options) assert_success response - assert !response.params["create_customer_result"].blank? + assert !response.params['create_customer_result'].blank? end def test_successful_modify_customer_credit_card customer = @gateway.create_customer(@options) assert_success customer - customer_id = customer.params["create_customer_result"] + customer_id = customer.params['create_customer_result'] credit_card = @gateway.modify_customer_credit_card(customer_id, @credit_card) assert_success credit_card - assert !credit_card.params["modify_customer_credit_card_result"].blank? + assert !credit_card.params['modify_customer_credit_card_result'].blank? end def test_succsessful_authorize_credit_card_payment customer = @gateway.create_customer(@options) assert_success customer - customer_id = customer.params["create_customer_result"] + customer_id = customer.params['create_customer_result'] credit_card = @gateway.modify_customer_credit_card(customer_id, @credit_card) assert_success credit_card diff --git a/test/remote/gateways/remote_modern_payments_test.rb b/test/remote/gateways/remote_modern_payments_test.rb index b4b5822a149..c0ec1040d63 100644 --- a/test/remote/gateways/remote_modern_payments_test.rb +++ b/test/remote/gateways/remote_modern_payments_test.rb @@ -22,14 +22,14 @@ def test_successful_purchase # Test mode seems to not return "approved = true" assert_failure response - assert_match %r{RESPONSECODE=A}, response.params["auth_string"] + assert_match %r{RESPONSECODE=A}, response.params['auth_string'] assert_equal ModernPaymentsCimGateway::FAILURE_MESSAGE, response.message end def test_unsuccessful_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_match %r{RESPONSECODE=D}, response.params["auth_string"] + assert_match %r{RESPONSECODE=D}, response.params['auth_string'] assert_equal ModernPaymentsCimGateway::FAILURE_MESSAGE, response.message end diff --git a/test/remote/gateways/remote_moneris_test.rb b/test/remote/gateways/remote_moneris_test.rb index 59be37db9eb..6cd0cd8e993 100644 --- a/test/remote/gateways/remote_moneris_test.rb +++ b/test/remote/gateways/remote_moneris_test.rb @@ -23,7 +23,7 @@ def test_successful_purchase def test_successful_purchase_with_network_tokenization @credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', verification_value: nil ) assert response = @gateway.purchase(@amount, @credit_card, @options) @@ -34,7 +34,7 @@ def test_successful_purchase_with_network_tokenization def test_successful_purchase_with_network_tokenization_apple_pay_source @credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', verification_value: nil, source: :apple_pay ) @@ -87,7 +87,7 @@ def test_successful_authorization_and_void def test_successful_authorization_with_network_tokenization @credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', verification_value: nil ) assert response = @gateway.authorize(@amount, @credit_card, @options) @@ -129,38 +129,38 @@ def test_failed_purchase_from_error def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_match "Approved", response.message + assert_match 'Approved', response.message end def test_successful_store assert response = @gateway.store(@credit_card) assert_success response - assert_equal "Successfully registered cc details", response.message - assert response.params["data_key"].present? - @data_key = response.params["data_key"] + assert_equal 'Successfully registered cc details', response.message + assert response.params['data_key'].present? + @data_key = response.params['data_key'] end def test_successful_unstore test_successful_store assert response = @gateway.unstore(@data_key) assert_success response - assert_equal "Successfully deleted cc details", response.message - assert response.params["data_key"].present? + assert_equal 'Successfully deleted cc details', response.message + assert response.params['data_key'].present? end def test_update test_successful_store assert response = @gateway.update(@data_key, @credit_card) assert_success response - assert_equal "Successfully updated cc details", response.message - assert response.params["data_key"].present? + assert_equal 'Successfully updated cc details', response.message + assert response.params['data_key'].present? end def test_successful_purchase_with_vault test_successful_store assert response = @gateway.purchase(@amount, @data_key, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_false response.authorization.blank? end diff --git a/test/remote/gateways/remote_moneris_us_test.rb b/test/remote/gateways/remote_moneris_us_test.rb index 0692e831db8..75bbf7cf52d 100644 --- a/test/remote/gateways/remote_moneris_us_test.rb +++ b/test/remote/gateways/remote_moneris_us_test.rb @@ -50,7 +50,7 @@ def test_successful_authorization def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert response.authorization end @@ -118,56 +118,56 @@ def test_failed_purchase_from_error def test_successful_store assert response = @gateway.store(@credit_card) assert_success response - assert_equal "Successfully registered cc details", response.message - assert response.params["data_key"].present? - @data_key = response.params["data_key"] + assert_equal 'Successfully registered cc details', response.message + assert response.params['data_key'].present? + @data_key = response.params['data_key'] end def test_successful_echeck_store assert response = @gateway.store(@check) assert_success response - assert_equal "Successfully registered ach details", response.message - assert response.params["data_key"].present? - @data_key_echeck = response.params["data_key"] + assert_equal 'Successfully registered ach details', response.message + assert response.params['data_key'].present? + @data_key_echeck = response.params['data_key'] end def test_successful_unstore test_successful_store assert response = @gateway.unstore(@data_key) assert_success response - assert_equal "Successfully deleted cc details", response.message - assert response.params["data_key"].present? + assert_equal 'Successfully deleted cc details', response.message + assert response.params['data_key'].present? end def test_successful_echeck_unstore test_successful_echeck_store assert response = @gateway.unstore(@data_key_echeck) assert_success response - assert_equal "Successfully deleted ach details", response.message - assert response.params["data_key"].present? + assert_equal 'Successfully deleted ach details', response.message + assert response.params['data_key'].present? end def test_update test_successful_store assert response = @gateway.update(@data_key, @credit_card) assert_success response - assert_equal "Successfully updated cc details", response.message - assert response.params["data_key"].present? + assert_equal 'Successfully updated cc details', response.message + assert response.params['data_key'].present? end def test_echeck_update test_successful_echeck_store assert response = @gateway.update(@data_key_echeck, @check) assert_success response - assert_equal "Successfully updated ach details", response.message - assert response.params["data_key"].present? + assert_equal 'Successfully updated ach details', response.message + assert response.params['data_key'].present? end def test_successful_purchase_with_vault test_successful_store assert response = @gateway.purchase(@amount, @data_key, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_false response.authorization.blank? end diff --git a/test/remote/gateways/remote_money_movers_test.rb b/test/remote/gateways/remote_money_movers_test.rb index 963cc775f54..64165cb50d8 100644 --- a/test/remote/gateways/remote_money_movers_test.rb +++ b/test/remote/gateways/remote_money_movers_test.rb @@ -19,54 +19,54 @@ def setup def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message end def test_unsuccessful_purchase assert response = @gateway.purchase(@declined_amount, @credit_card, @options) assert_failure response - assert_equal "Transaction Declined", response.message + assert_equal 'Transaction Declined', response.message end def test_successful_authorization assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message end def test_failed_capture assert response = @gateway.capture(@amount, '') assert_failure response - assert_equal "Error in transaction data or system error", response.message + assert_equal 'Error in transaction data or system error', response.message end def test_purchase_and_refund assert auth = @gateway.purchase(@amount, @credit_card, @options) assert_success auth - assert_equal "Transaction Approved", auth.message + assert_equal 'Transaction Approved', auth.message assert auth.authorization assert capture = @gateway.refund(@amount, auth.authorization) - assert_equal "Transaction Approved", capture.message + assert_equal 'Transaction Approved', capture.message assert_success capture end def test_authorize_and_void assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert_equal "Transaction Approved", auth.message + assert_equal 'Transaction Approved', auth.message assert auth.authorization assert capture = @gateway.void(auth.authorization) - assert_equal "Transaction Approved", capture.message + assert_equal 'Transaction Approved', capture.message assert_success capture end def test_authorize_and_capture assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert_equal "Transaction Approved", auth.message + assert_equal 'Transaction Approved', auth.message assert auth.authorization assert capture = @gateway.capture(@amount, auth.authorization) - assert_equal "Transaction Approved", capture.message + assert_equal 'Transaction Approved', capture.message assert_success capture end @@ -77,6 +77,6 @@ def test_invalid_login ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Error in transaction data or system error", response.message + assert_equal 'Error in transaction data or system error', response.message end end diff --git a/test/remote/gateways/remote_nab_transact_test.rb b/test/remote/gateways/remote_nab_transact_test.rb index 4892a5a47de..71cfe58cdb2 100644 --- a/test/remote/gateways/remote_nab_transact_test.rb +++ b/test/remote/gateways/remote_nab_transact_test.rb @@ -222,7 +222,7 @@ def test_unstore assert card_id = response.authorization assert unstore_response = @gateway.unstore(card_id) assert_success unstore_response - assert_equal "Successful", unstore_response.message + assert_equal 'Successful', unstore_response.message end def test_successful_purchase_using_stored_card @@ -246,7 +246,7 @@ def test_failure_trigger_purchase purchase_response = @gateway.purchase(trigger_amount, gateway_id) - assert gateway_id = purchase_response.params["crn"] + assert gateway_id = purchase_response.params['crn'] assert_failure purchase_response assert_equal 'Invalid Amount', purchase_response.message end diff --git a/test/remote/gateways/remote_netaxept_test.rb b/test/remote/gateways/remote_netaxept_test.rb index a7ea2c36715..5219b4144bc 100644 --- a/test/remote/gateways/remote_netaxept_test.rb +++ b/test/remote/gateways/remote_netaxept_test.rb @@ -37,7 +37,7 @@ def test_authorize_and_capture def test_failed_capture assert response = @gateway.capture(@amount, '') assert_failure response - assert_equal "Unable to find transaction", response.message + assert_equal 'Unable to find transaction', response.message end def test_successful_refund @@ -54,7 +54,7 @@ def test_failed_refund response = @gateway.refund(@amount+100, response.authorization) assert_failure response - assert_equal "Unable to credit more than captured amount", response.message + assert_equal 'Unable to credit more than captured amount', response.message end def test_successful_void @@ -71,7 +71,7 @@ def test_failed_void response = @gateway.void(response.authorization) assert_failure response - assert_equal "Unable to annul, wrong state", response.message + assert_equal 'Unable to annul, wrong state', response.message end def test_successful_amex_purchase @@ -111,7 +111,7 @@ def test_successful_master_purchase def test_error_in_payment_details assert response = @gateway.purchase(@amount, credit_card(''), @options) assert_failure response - assert_equal "Cardnumber:Required", response.message + assert_equal 'Cardnumber:Required', response.message end def test_amount_is_not_required_again_when_capturing_authorization @@ -119,11 +119,11 @@ def test_amount_is_not_required_again_when_capturing_authorization assert_success response assert response = @gateway.capture(nil, response.authorization) - assert_equal "OK", response.message + assert_equal 'OK', response.message end def test_query_fails - query = @gateway.send(:query_transaction, "bogus", @options) + query = @gateway.send(:query_transaction, 'bogus', @options) assert_failure query assert_match(/unable to find/i, query.message) end diff --git a/test/remote/gateways/remote_netbanx_test.rb b/test/remote/gateways/remote_netbanx_test.rb index 5d28ce15ce5..19b4faddd5c 100644 --- a/test/remote/gateways/remote_netbanx_test.rb +++ b/test/remote/gateways/remote_netbanx_test.rb @@ -23,9 +23,9 @@ def test_successful_purchase def test_successful_purchase_with_more_options options = { order_id: SecureRandom.uuid, - ip: "127.0.0.1", + ip: '127.0.0.1', billing_address: address, - email: "joe@example.com" + email: 'joe@example.com' } response = @gateway.purchase(@amount, @credit_card, options) @@ -172,20 +172,20 @@ def test_transcript_scrubbing def test_successful_store merchant_customer_id = SecureRandom.hex - assert response = @gateway.store(@credit_card, locale: 'en_GB', merchant_customer_id: merchant_customer_id, email: "email@example.com") + assert response = @gateway.store(@credit_card, locale: 'en_GB', merchant_customer_id: merchant_customer_id, email: 'email@example.com') assert_success response - assert_equal merchant_customer_id, response.params["merchantCustomerId"] - first_card = response.params["cards"].first - assert_equal @credit_card.last_digits, first_card["lastDigits"] + assert_equal merchant_customer_id, response.params['merchantCustomerId'] + first_card = response.params['cards'].first + assert_equal @credit_card.last_digits, first_card['lastDigits'] end def test_successful_unstore merchant_customer_id = SecureRandom.hex - assert response = @gateway.store(@credit_card, locale: 'en_GB', merchant_customer_id: merchant_customer_id, email: "email@example.com") + assert response = @gateway.store(@credit_card, locale: 'en_GB', merchant_customer_id: merchant_customer_id, email: 'email@example.com') assert_success response - assert_equal merchant_customer_id, response.params["merchantCustomerId"] - first_card = response.params["cards"].first - assert_equal @credit_card.last_digits, first_card["lastDigits"] + assert_equal merchant_customer_id, response.params['merchantCustomerId'] + first_card = response.params['cards'].first + assert_equal @credit_card.last_digits, first_card['lastDigits'] identification = "#{response.params['id']}|#{first_card['id']}" assert unstore_card = @gateway.unstore(identification) assert_success unstore_card @@ -200,6 +200,6 @@ def test_successful_purchase_using_stored_card assert response = @gateway.purchase(@amount, store.authorization.split('|').last) assert_success response - assert_equal "OK", response.message + assert_equal 'OK', response.message end end diff --git a/test/remote/gateways/remote_network_merchants_test.rb b/test/remote/gateways/remote_network_merchants_test.rb index 020c6f1a676..290a0cad4c6 100644 --- a/test/remote/gateways/remote_network_merchants_test.rb +++ b/test/remote/gateways/remote_network_merchants_test.rb @@ -7,7 +7,7 @@ def setup @amount = 100 @decline_amount = 1 @credit_card = credit_card('4111111111111111') - @credit_card_with_track_data = credit_card_with_track_data("4111111111111111") + @credit_card_with_track_data = credit_card_with_track_data('4111111111111111') @check = check @options = { @@ -83,7 +83,7 @@ def test_void assert response = @gateway.void(purchase.authorization) assert_success response - assert_equal "Transaction Void Successful", response.message + assert_equal 'Transaction Void Successful', response.message end def test_refund @@ -93,7 +93,7 @@ def test_refund assert response = @gateway.refund(50, purchase.authorization) assert_success response - assert_equal "SUCCESS", response.message + assert_equal 'SUCCESS', response.message assert response.authorization end @@ -104,7 +104,7 @@ def test_refund_with_track_data assert response = @gateway.refund(50, purchase.authorization) assert_success response - assert_equal "SUCCESS", response.message + assert_equal 'SUCCESS', response.message assert response.authorization end @@ -123,7 +123,7 @@ def test_store_check end def test_store_failure - @credit_card.number = "123" + @credit_card.number = '123' assert store = @gateway.store(@credit_card, @options) assert_failure store assert store.message.include?('Invalid Credit Card Number') @@ -138,7 +138,7 @@ def test_unstore assert unstore = @gateway.unstore(store.params['customer_vault_id']) assert_success unstore - assert_equal "Customer Deleted", unstore.message + assert_equal 'Customer Deleted', unstore.message end def test_purchase_on_stored_card @@ -148,7 +148,7 @@ def test_purchase_on_stored_card assert purchase = @gateway.purchase(@amount, store.params['customer_vault_id'], @options) assert_success purchase - assert_equal "SUCCESS", purchase.message + assert_equal 'SUCCESS', purchase.message end def test_invalid_login diff --git a/test/remote/gateways/remote_nmi_test.rb b/test/remote/gateways/remote_nmi_test.rb index acf13461d44..c98b29dcaac 100644 --- a/test/remote/gateways/remote_nmi_test.rb +++ b/test/remote/gateways/remote_nmi_test.rb @@ -10,12 +10,12 @@ def setup :account_number => '123123123' ) @apple_pay_card = network_tokenization_credit_card('4111111111111111', - :payment_cryptogram => "EHuWW9PiBkWvqE5juRwDzAUFBAk=", - :month => "01", - :year => "2024", + :payment_cryptogram => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', + :month => '01', + :year => '2024', :source => :apple_pay, - :eci => "5", - :transaction_id => "123456789" + :eci => '5', + :transaction_id => '123456789' ) @options = { :order_id => generate_unique_id, @@ -25,10 +25,10 @@ def setup end def test_invalid_login - @gateway = NmiGateway.new(login: "invalid", password: "no") + @gateway = NmiGateway.new(login: 'invalid', password: 'no') assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Authentication Failed", response.message + assert_equal 'Authentication Failed', response.message end def test_successful_purchase @@ -110,7 +110,7 @@ def test_authorization_and_capture end def test_failed_capture - assert capture = @gateway.capture(@amount, "badauth") + assert capture = @gateway.capture(@amount, 'badauth') assert_failure capture end @@ -124,7 +124,7 @@ def test_authorization_and_void end def test_failed_void - assert void = @gateway.void("badauth") + assert void = @gateway.void('badauth') assert_failure void end @@ -147,7 +147,7 @@ def test_successful_refund end def test_failed_refund - assert response = @gateway.refund(@amount, "badauth") + assert response = @gateway.refund(@amount, 'badauth') assert_failure response end @@ -164,7 +164,7 @@ def test_successful_refund_with_echeck def test_successful_credit response = @gateway.credit(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_credit @@ -176,56 +176,56 @@ def test_failed_credit def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_match "Succeeded", response.message + assert_match 'Succeeded', response.message end def test_failed_verify card = credit_card(year: 2010) response = @gateway.verify(card, @options) assert_failure response - assert_match "Invalid Credit Card", response.message + assert_match 'Invalid Credit Card', response.message end def test_successful_store response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "Succeeded", response.message - assert response.params["customer_vault_id"] + assert_equal 'Succeeded', response.message + assert response.params['customer_vault_id'] end def test_failed_store card = credit_card(year: 2010) response = @gateway.store(card, @options) assert_failure response - assert_nil response.params["customer_vault_id"] + assert_nil response.params['customer_vault_id'] end def test_successful_store_with_echeck response = @gateway.store(@check, @options) assert_success response - assert_equal "Succeeded", response.message - assert response.params["customer_vault_id"] + assert_equal 'Succeeded', response.message + assert response.params['customer_vault_id'] end def test_successful_store_and_purchase - vault_id = @gateway.store(@credit_card, @options).params["customer_vault_id"] + vault_id = @gateway.store(@credit_card, @options).params['customer_vault_id'] purchase = @gateway.purchase(@amount, vault_id, @options) assert_success purchase - assert_equal "Succeeded", purchase.message + assert_equal 'Succeeded', purchase.message end def test_successful_store_and_auth - vault_id = @gateway.store(@credit_card, @options).params["customer_vault_id"] + vault_id = @gateway.store(@credit_card, @options).params['customer_vault_id'] auth = @gateway.authorize(@amount, vault_id, @options) assert_success auth - assert_equal "Succeeded", auth.message + assert_equal 'Succeeded', auth.message end def test_successful_store_and_credit - vault_id = @gateway.store(@credit_card, @options).params["customer_vault_id"] + vault_id = @gateway.store(@credit_card, @options).params['customer_vault_id'] credit = @gateway.credit(@amount, vault_id, @options) assert_success credit - assert_equal "Succeeded", credit.message + assert_equal 'Succeeded', credit.message end def test_merchant_defined_fields diff --git a/test/remote/gateways/remote_ogone_test.rb b/test/remote/gateways/remote_ogone_test.rb index 8dd7ae9264e..6f62cd8f0ce 100644 --- a/test/remote/gateways/remote_ogone_test.rb +++ b/test/remote/gateways/remote_ogone_test.rb @@ -7,7 +7,7 @@ def setup @gateway = OgoneGateway.new(fixtures(:ogone)) @amount = 100 @credit_card = credit_card('4000100011112224') - @mastercard = credit_card('5399999999999999', :brand => "mastercard") + @mastercard = credit_card('5399999999999999', :brand => 'mastercard') @declined_card = credit_card('1111111111111111') @credit_card_d3d = credit_card('4000000000000002', :verification_value => '111') @options = { @@ -27,13 +27,13 @@ def test_successful_purchase end def test_successful_purchase_with_utf8_encoding_1 - assert response = @gateway.purchase(@amount, credit_card('4000100011112224', :first_name => "Rémy", :last_name => "Fröåïør"), @options) + assert response = @gateway.purchase(@amount, credit_card('4000100011112224', :first_name => 'Rémy', :last_name => 'Fröåïør'), @options) assert_success response assert_equal OgoneGateway::SUCCESS_MESSAGE, response.message end def test_successful_purchase_with_utf8_encoding_2 - assert response = @gateway.purchase(@amount, credit_card('4000100011112224', :first_name => "ワタシ", :last_name => "ёжзийклмнопрсуфхцч"), @options) + assert response = @gateway.purchase(@amount, credit_card('4000100011112224', :first_name => 'ワタシ', :last_name => 'ёжзийклмнопрсуфхцч'), @options) assert_success response assert_equal OgoneGateway::SUCCESS_MESSAGE, response.message end @@ -71,9 +71,9 @@ def test_successful_purchase_with_signature_encryptor_to_sha512 def test_successful_purchase_with_3d_secure assert response = @gateway.purchase(@amount, @credit_card_d3d, @options.merge(:d3d => true)) assert_success response - assert_equal '46', response.params["STATUS"] + assert_equal '46', response.params['STATUS'] assert_equal OgoneGateway::SUCCESS_MESSAGE, response.message - assert response.params["HTML_ANSWER"] + assert response.params['HTML_ANSWER'] end def test_successful_with_non_numeric_order_id @@ -209,24 +209,24 @@ def test_successful_credit def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "The transaction was successful", response.message + assert_equal 'The transaction was successful', response.message end def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "No brand", response.message + assert_equal 'No brand', response.message end def test_reference_transactions # Setting an alias - assert response = @gateway.purchase(@amount, credit_card('4000100011112224'), @options.merge(:billing_id => "awesomeman", :order_id=>Time.now.to_i.to_s+"1")) + assert response = @gateway.purchase(@amount, credit_card('4000100011112224'), @options.merge(:billing_id => 'awesomeman', :order_id=>Time.now.to_i.to_s+'1')) assert_success response # Updating an alias - assert response = @gateway.purchase(@amount, credit_card('4111111111111111'), @options.merge(:billing_id => "awesomeman", :order_id=>Time.now.to_i.to_s+"2")) + assert response = @gateway.purchase(@amount, credit_card('4111111111111111'), @options.merge(:billing_id => 'awesomeman', :order_id=>Time.now.to_i.to_s+'2')) assert_success response # Using an alias (i.e. don't provide the credit card) - assert response = @gateway.purchase(@amount, "awesomeman", @options.merge(:order_id => Time.now.to_i.to_s + "3")) + assert response = @gateway.purchase(@amount, 'awesomeman', @options.merge(:order_id => Time.now.to_i.to_s + '3')) assert_success response end diff --git a/test/remote/gateways/remote_openpay_test.rb b/test/remote/gateways/remote_openpay_test.rb index 279531ef37b..54db72973a2 100644 --- a/test/remote/gateways/remote_openpay_test.rb +++ b/test/remote/gateways/remote_openpay_test.rb @@ -200,7 +200,7 @@ def test_nil_cvv_scrubbing end def test_empty_string_cvv_scrubbing - @credit_card.verification_value = "" + @credit_card.verification_value = '' transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) end @@ -210,7 +210,7 @@ def test_empty_string_cvv_scrubbing end def test_whitespace_string_cvv_scrubbing - @credit_card.verification_value = " " + @credit_card.verification_value = ' ' transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) end diff --git a/test/remote/gateways/remote_opp_test.rb b/test/remote/gateways/remote_opp_test.rb index 5b96b7a5c4f..2652c756ad4 100644 --- a/test/remote/gateways/remote_opp_test.rb +++ b/test/remote/gateways/remote_opp_test.rb @@ -6,9 +6,9 @@ def setup @gateway = OppGateway.new(fixtures(:opp)) @amount = 100 - @valid_card = credit_card("4200000000000000", month: 05, year: 2018) - @invalid_card = credit_card("4444444444444444", month: 05, year: 2018) - @amex_card = credit_card("377777777777770 ", month: 05, year: 2018, brand: 'amex', verification_value: '1234') + @valid_card = credit_card('4200000000000000', month: 05, year: 2018) + @invalid_card = credit_card('4444444444444444', month: 05, year: 2018) + @amex_card = credit_card('377777777777770 ', month: 05, year: 2018, brand: 'amex', verification_value: '1234') request_type = 'complete' # 'minimal' || 'complete' time = Time.now.to_i @@ -37,7 +37,7 @@ def setup country: 'DE', }, customer: { - merchant_customer_id: "your merchant/customer id", + merchant_customer_id: 'your merchant/customer id', givenName: 'Jane', surname: 'Jones', birthDate: '1965-05-01', @@ -59,9 +59,9 @@ def setup @complete_request_options['customParameters[SHOPPER_test124TestName009]'] = 'customParameters_test' @complete_request_options['customParameters[SHOPPER_otherCustomerParameter]'] = 'otherCustomerParameter_test' - @test_success_id = "8a82944a4e008ca9014e1273e0696122" - @test_failure_id = "8a8294494e0078a6014e12b371fb6a8e" - @test_wrong_reference_id = "8a8444494a0033a6014e12b371fb6a1e" + @test_success_id = '8a82944a4e008ca9014e1273e0696122' + @test_failure_id = '8a8294494e0078a6014e12b371fb6a8e' + @test_wrong_reference_id = '8a8444494a0033a6014e12b371fb6a1e' @options = @minimal_request_options if request_type == 'minimal' @options = @complete_request_options if request_type == 'complete' @@ -72,7 +72,7 @@ def test_successful_purchase @options[:description] = __method__ response = @gateway.purchase(@amount, @valid_card, @options) - assert_success response, "Failed purchase" + assert_success response, 'Failed purchase' assert_match %r{Request successfully processed}, response.message assert response.test? @@ -90,7 +90,7 @@ def test_successful_authorize @options[:description] = __method__ response = @gateway.authorize(@amount, @valid_card, @options) - assert_success response, "Authorization Failed" + assert_success response, 'Authorization Failed' assert_match %r{Request successfully processed}, response.message assert response.test? @@ -99,11 +99,11 @@ def test_successful_authorize def test_successful_capture @options[:description] = __method__ auth = @gateway.authorize(@amount, @valid_card, @options) - assert_success auth, "Authorization Failed" + assert_success auth, 'Authorization Failed' assert auth.test? capt = @gateway.capture(@amount, auth.authorization, @options) - assert_success capt, "Capture failed" + assert_success capt, 'Capture failed' assert_match %r{Request successfully processed}, capt.message assert capt.test? @@ -112,11 +112,11 @@ def test_successful_capture def test_successful_refund @options[:description] = __method__ purchase = @gateway.purchase(@amount, @valid_card, @options) - assert_success purchase, "Purchase failed" + assert_success purchase, 'Purchase failed' assert purchase.test? refund = @gateway.refund(@amount, purchase.authorization, @options) - assert_success refund, "Refund failed" + assert_success refund, 'Refund failed' assert_match %r{Request successfully processed}, refund.message assert refund.test? @@ -125,11 +125,11 @@ def test_successful_refund def test_successful_void @options[:description] = __method__ purchase = @gateway.purchase(@amount, @valid_card, @options) - assert_success purchase, "Purchase failed" + assert_success purchase, 'Purchase failed' assert purchase.test? void = @gateway.void(purchase.authorization, @options) - assert_success void, "Void failed" + assert_success void, 'Void failed' assert_match %r{Request successfully processed}, void.message assert void.test? diff --git a/test/remote/gateways/remote_optimal_payment_test.rb b/test/remote/gateways/remote_optimal_payment_test.rb index 20f56fbd196..f42849579d9 100644 --- a/test/remote/gateways/remote_optimal_payment_test.rb +++ b/test/remote/gateways/remote_optimal_payment_test.rb @@ -31,8 +31,8 @@ def test_unsuccessful_purchase_with_shipping_address end def test_successful_great_britain - @options[:billing_address][:country] = "GB" - @options[:billing_address][:state] = "North West England" + @options[:billing_address][:country] = 'GB' + @options[:billing_address][:state] = 'North West England' assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal 'no_error', response.message diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb index c608bdd823f..20b1b018431 100644 --- a/test/remote/gateways/remote_orbital_test.rb +++ b/test/remote/gateways/remote_orbital_test.rb @@ -1,4 +1,4 @@ -require "test_helper.rb" +require 'test_helper.rb' class RemoteOrbitalGatewayTest < Test::Unit::TestCase def setup @@ -16,16 +16,16 @@ def setup } @cards = { - :visa => "4788250000028291", - :mc => "5454545454545454", - :amex => "371449635398431", - :ds => "6011000995500000", - :diners => "36438999960016", - :jcb => "3566002020140006"} + :visa => '4788250000028291', + :mc => '5454545454545454', + :amex => '371449635398431', + :ds => '6011000995500000', + :diners => '36438999960016', + :jcb => '3566002020140006'} @level_2_options = { - tax_indicator: "1", - tax: "75", + tax_indicator: '1', + tax: '75', advice_addendum_1: 'taa1 - test', advice_addendum_2: 'taa2 - test', advice_addendum_3: 'taa3 - test', @@ -80,8 +80,8 @@ def test_successful_purchase_with_level_2_data def test_successful_purchase_with_visa_network_tokenization_credit_card_with_eci network_card = network_tokenization_credit_card('4788250000028291', - payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", - transaction_id: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', + transaction_id: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', verification_value: '111', brand: 'visa', eci: '5' @@ -94,8 +94,8 @@ def test_successful_purchase_with_visa_network_tokenization_credit_card_with_eci def test_successful_purchase_with_master_card_network_tokenization_credit_card network_card = network_tokenization_credit_card('4788250000028291', - payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", - transaction_id: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', + transaction_id: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', verification_value: '111', brand: 'master' ) @@ -107,8 +107,8 @@ def test_successful_purchase_with_master_card_network_tokenization_credit_card def test_successful_purchase_with_american_express_network_tokenization_credit_card network_card = network_tokenization_credit_card('4788250000028291', - payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", - transaction_id: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', + transaction_id: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', verification_value: '111', brand: 'american_express' ) @@ -120,8 +120,8 @@ def test_successful_purchase_with_american_express_network_tokenization_credit_c def test_successful_purchase_with_discover_network_tokenization_credit_card network_card = network_tokenization_credit_card('4788250000028291', - payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", - transaction_id: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', + transaction_id: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', verification_value: '111', brand: 'discover' ) @@ -151,7 +151,7 @@ def test_authorize_and_capture def test_successful_authorize_and_capture_with_level_2_data auth = @gateway.authorize(@amount, @credit_card, @options.merge(level_2_data: @level_2_options)) assert_success auth - assert_equal "Approved", auth.message + assert_equal 'Approved', auth.message capture = @gateway.capture(@amount, auth.authorization, @options.merge(level_2_data: @level_2_options)) assert_success capture diff --git a/test/remote/gateways/remote_pac_net_raven_test.rb b/test/remote/gateways/remote_pac_net_raven_test.rb index 3d5e9dffe37..a1473031fbc 100644 --- a/test/remote/gateways/remote_pac_net_raven_test.rb +++ b/test/remote/gateways/remote_pac_net_raven_test.rb @@ -34,7 +34,7 @@ def test_invalid_credit_card_number_purchese assert_equal 'invalid:cardNumber', purchase.params['ErrorCode'] assert_equal 'Invalid:CardNumber', purchase.params['Status'] assert_equal 'ok', purchase.params['RequestResult'] - assert_equal "Error processing transaction because CardNumber \"0000\" is not between 12 and 19 in length.", purchase.params['Message'] + assert_equal 'Error processing transaction because CardNumber "0000" is not between 12 and 19 in length.', purchase.params['Message'] end def test_expired_credit_card_purchese @@ -47,7 +47,7 @@ def test_expired_credit_card_purchese assert_equal 'invalid:CustomerCardExpiryDate', purchase.params['ErrorCode'] assert_equal 'Invalid:CustomerCardExpiryDate', purchase.params['Status'] assert_equal 'ok', purchase.params['RequestResult'] - assert_equal "Invalid because the card expiry date (mmyy) \"0912\" is not a date in the future", purchase.params['Message'] + assert_equal 'Invalid because the card expiry date (mmyy) "0912" is not a date in the future', purchase.params['Message'] end def test_declined_purchase @@ -77,7 +77,7 @@ def test_invalid_credit_card_number_authorization assert_equal 'invalid:cardNumber', auth.params['ErrorCode'] assert_equal 'Invalid:CardNumber', auth.params['Status'] assert_equal 'ok', auth.params['RequestResult'] - assert_equal "Error processing transaction because CardNumber \"0000\" is not between 12 and 19 in length.", auth.params['Message'] + assert_equal 'Error processing transaction because CardNumber "0000" is not between 12 and 19 in length.', auth.params['Message'] end def test_expired_credit_card_authorization @@ -90,7 +90,7 @@ def test_expired_credit_card_authorization assert_equal 'invalid:CustomerCardExpiryDate', auth.params['ErrorCode'] assert_equal 'Invalid:CustomerCardExpiryDate', auth.params['Status'] assert_equal 'ok', auth.params['RequestResult'] - assert_equal "Invalid because the card expiry date (mmyy) \"0912\" is not a date in the future", auth.params['Message'] + assert_equal 'Invalid because the card expiry date (mmyy) "0912" is not a date in the future', auth.params['Message'] end def test_declined_authorization @@ -123,7 +123,7 @@ def test_amount_greater_than_original_amount_refund assert_equal 'invalid:RefundAmountGreaterThanOriginalAmount', refund.params['ErrorCode'] assert_equal 'Invalid:RefundAmountGreaterThanOriginalAmount', refund.params['Status'] assert_equal 'ok', refund.params['RequestResult'] - assert_equal "Invalid because the payment amount cannot be greater than the original charge.", refund.params['Message'] + assert_equal 'Invalid because the payment amount cannot be greater than the original charge.', refund.params['Message'] assert_equal 'Invalid because the payment amount cannot be greater than the original charge.', refund.message end @@ -137,7 +137,7 @@ def test_purchase_and_void assert_equal 'ok', void.params['RequestResult'] assert_nil void.params['Message'] assert_equal 'Voided', void.params['Status'] - assert_equal "This transaction has been voided", void.message + assert_equal 'This transaction has been voided', void.message end def test_authorize_and_void @@ -150,7 +150,7 @@ def test_authorize_and_void assert_equal 'ok', void.params['RequestResult'] assert_nil void.params['Message'] assert_equal 'Voided', void.params['Status'] - assert_equal "This transaction has been voided", void.message + assert_equal 'This transaction has been voided', void.message end def test_authorize_capture_and_void @@ -164,7 +164,7 @@ def test_authorize_capture_and_void assert_equal 'ok', void.params['RequestResult'] assert_nil void.params['Message'] assert_equal 'Voided', void.params['Status'] - assert_equal "This transaction has been voided", void.message + assert_equal 'This transaction has been voided', void.message end def test_successful_capture diff --git a/test/remote/gateways/remote_pagarme_test.rb b/test/remote/gateways/remote_pagarme_test.rb index 27f6f465fb9..868ff0a48c3 100644 --- a/test/remote/gateways/remote_pagarme_test.rb +++ b/test/remote/gateways/remote_pagarme_test.rb @@ -29,7 +29,7 @@ def test_successful_purchase assert_equal 'Transação aprovada', response.message # Assert metadata - assert_equal response.params["metadata"]["description"], @options[:description] + assert_equal response.params['metadata']['description'], @options[:description] end def test_successful_purchase_with_more_options @@ -49,13 +49,13 @@ def test_successful_purchase_with_more_options assert_equal 'Transação aprovada', response.message # Assert metadata - assert_equal response.params["metadata"]["order_id"], options[:order_id] - assert_equal response.params["metadata"]["ip"], options[:ip] - assert_equal response.params["metadata"]["customer"], options[:customer] - assert_equal response.params["metadata"]["invoice"], options[:invoice] - assert_equal response.params["metadata"]["merchant"], options[:merchant] - assert_equal response.params["metadata"]["description"], options[:description] - assert_equal response.params["metadata"]["email"], options[:email] + assert_equal response.params['metadata']['order_id'], options[:order_id] + assert_equal response.params['metadata']['ip'], options[:ip] + assert_equal response.params['metadata']['customer'], options[:customer] + assert_equal response.params['metadata']['invoice'], options[:invoice] + assert_equal response.params['metadata']['merchant'], options[:merchant] + assert_equal response.params['metadata']['description'], options[:description] + assert_equal response.params['metadata']['email'], options[:email] end def test_successful_purchase_without_options diff --git a/test/remote/gateways/remote_pago_facil_test.rb b/test/remote/gateways/remote_pago_facil_test.rb index 03404228d02..254ebd33dec 100644 --- a/test/remote/gateways/remote_pago_facil_test.rb +++ b/test/remote/gateways/remote_pago_facil_test.rb @@ -87,7 +87,7 @@ def successful_response_to if random_response.success? return random_response elsif(attempts > 2) - raise "Unable to get a successful response" + raise 'Unable to get a successful response' else assert_equal 'Declined_(General).', random_response.params.fetch('error') attempts += 1 diff --git a/test/remote/gateways/remote_pay_conex_test.rb b/test/remote/gateways/remote_pay_conex_test.rb index 43c4f0b4e6b..0299a43c0f0 100644 --- a/test/remote/gateways/remote_pay_conex_test.rb +++ b/test/remote/gateways/remote_pay_conex_test.rb @@ -13,12 +13,12 @@ def setup order_id: '1', billing_address: address, description: 'Store Purchase', - email: "joe@example.com" + email: 'joe@example.com' } end def test_transcript_scrubbing - @credit_card.verification_value = "447" + @credit_card.verification_value = '447' transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) end @@ -32,29 +32,29 @@ def test_transcript_scrubbing def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message end def test_failed_purchase response = @gateway.purchase(@failed_amount, @credit_card, @options) assert_failure response - assert_equal "DECLINED", response.message + assert_equal 'DECLINED', response.message end def test_successful_authorize_and_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert_equal "APPROVED", auth.message + assert_equal 'APPROVED', auth.message assert capture = @gateway.capture(@amount, auth.authorization) assert_success capture - assert_equal "CAPTURED", capture.message + assert_equal 'CAPTURED', capture.message end def test_failed_authorize response = @gateway.authorize(@failed_amount, @credit_card, @options) assert_failure response - assert_equal "DECLINED", response.message + assert_equal 'DECLINED', response.message end def test_partial_capture @@ -63,13 +63,13 @@ def test_partial_capture assert capture = @gateway.capture(@amount-1, auth.authorization) assert_success capture - assert_equal "CAPTURED", capture.message + assert_equal 'CAPTURED', capture.message end def test_failed_capture response = @gateway.capture(@amount, 'UnknownAuth') assert_failure response - assert_equal "Invalid token_id", response.message + assert_equal 'Invalid token_id', response.message end def test_successful_refund @@ -78,7 +78,7 @@ def test_successful_refund assert refund = @gateway.refund(@amount, purchase.authorization) assert_success refund - assert_equal "VOID", refund.message + assert_equal 'VOID', refund.message end def test_partial_refund @@ -87,7 +87,7 @@ def test_partial_refund assert refund = @gateway.refund(@amount-1, purchase.authorization) assert_success refund - assert_equal "REFUND", refund.message + assert_equal 'REFUND', refund.message end def test_failed_refund @@ -96,7 +96,7 @@ def test_failed_refund response = @gateway.refund(@amount + 400, purchase.authorization) assert_failure response - assert_equal "INVALID REFUND AMOUNT", response.message + assert_equal 'INVALID REFUND AMOUNT', response.message end def test_successful_void @@ -105,7 +105,7 @@ def test_successful_void assert void = @gateway.void(auth.authorization) assert_success void - assert_equal "APPROVED", void.message + assert_equal 'APPROVED', void.message end def test_failed_void @@ -117,32 +117,32 @@ def test_failed_void response = @gateway.void(auth.authorization) assert_failure response - assert_equal "TRANSACTION ID ALREADY REVERSED", response.message + assert_equal 'TRANSACTION ID ALREADY REVERSED', response.message end def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message end def test_failed_verify - response = @gateway.verify(credit_card("BogusCard"), @options) + response = @gateway.verify(credit_card('BogusCard'), @options) assert_failure response - assert_equal "INVALID CARD NUMBER", response.message + assert_equal 'INVALID CARD NUMBER', response.message end def test_successful_store assert response = @gateway.store(@credit_card) assert_success response assert response.authorization - assert_equal "2224", response.params["last4"] + assert_equal '2224', response.params['last4'] end def test_failed_store - assert response = @gateway.store(credit_card("141241")) + assert response = @gateway.store(credit_card('141241')) assert_failure response - assert_equal "CARD DATA UNREADABLE", response.message + assert_equal 'CARD DATA UNREADABLE', response.message end def test_purchase_using_stored_card @@ -151,32 +151,32 @@ def test_purchase_using_stored_card response = @gateway.purchase(@amount, response.authorization, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message end def test_successful_credit response = @gateway.credit(@amount, @credit_card, @options) assert_success response - assert_equal "CREDIT", response.message + assert_equal 'CREDIT', response.message end def test_failed_credit - response = @gateway.credit(@amount, credit_card("12321"), @options) + response = @gateway.credit(@amount, credit_card('12321'), @options) assert_failure response - assert_equal "CARD DATA UNREADABLE", response.message + assert_equal 'CARD DATA UNREADABLE', response.message end def test_successful_card_present_purchase response = @gateway.purchase(@amount, credit_card_with_track_data('4000100011112224'), @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message end def test_failed_card_present_purchase card = CreditCard.new(track_data: '%B37826310005^LOB^17001130504392?') response = @gateway.purchase(@amount, card, @options) assert_failure response - assert_equal "CARD DATA UNREADABLE", response.message + assert_equal 'CARD DATA UNREADABLE', response.message end def test_successful_echeck_purchase @@ -188,7 +188,7 @@ def test_successful_echeck_purchase end def test_failed_echeck_purchase - response = @gateway.purchase(@amount, check(routing_number: "23433"), @options) + response = @gateway.purchase(@amount, check(routing_number: '23433'), @options) assert_failure response assert_equal 'Invalid bank_routing_number', response.message end @@ -197,6 +197,6 @@ def test_invalid_login gateway = PayConexGateway.new(account_id: 'Unknown', api_accesskey: 'Incorrect') response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Invalid account_id", response.message + assert_equal 'Invalid account_id', response.message end end diff --git a/test/remote/gateways/remote_pay_gate_xml_test.rb b/test/remote/gateways/remote_pay_gate_xml_test.rb index 35b257c48ef..b16cedb0678 100644 --- a/test/remote/gateways/remote_pay_gate_xml_test.rb +++ b/test/remote/gateways/remote_pay_gate_xml_test.rb @@ -26,7 +26,7 @@ def test_successful_purchase def test_unsuccessful_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "Declined", response.message + assert_equal 'Declined', response.message end def test_authorize_and_capture diff --git a/test/remote/gateways/remote_pay_hub_test.rb b/test/remote/gateways/remote_pay_hub_test.rb index ff5191474c0..e57fe048e4a 100644 --- a/test/remote/gateways/remote_pay_hub_test.rb +++ b/test/remote/gateways/remote_pay_hub_test.rb @@ -4,8 +4,8 @@ class RemotePayHubTest < Test::Unit::TestCase def setup @gateway = PayHubGateway.new(fixtures(:pay_hub)) @amount = 100 - @credit_card = credit_card('5466410004374507', verification_value: "998") - @invalid_card = credit_card('371449635398431', verification_value: "9997") + @credit_card = credit_card('5466410004374507', verification_value: '998') + @invalid_card = credit_card('371449635398431', verification_value: '9997') @options = { :first_name => 'Garrya', :last_name => 'Barrya', @@ -47,7 +47,7 @@ def test_unsuccessful_auth end def test_unsuccessful_capture - assert_failure @gateway.capture(@amount, "bogus") + assert_failure @gateway.capture(@amount, 'bogus') end def test_partial_capture @@ -69,7 +69,7 @@ def test_successful_refund end def test_unsuccessful_refund - assert_failure @gateway.refund(@amount, "bogus") + assert_failure @gateway.refund(@amount, 'bogus') end def test_successful_verify @@ -77,6 +77,6 @@ def test_successful_verify end def test_failed_verify - assert_failure @gateway.verify(credit_card("4111111111111111")) + assert_failure @gateway.verify(credit_card('4111111111111111')) end end diff --git a/test/remote/gateways/remote_pay_junction_test.rb b/test/remote/gateways/remote_pay_junction_test.rb index 4744ea59995..bd0ff583733 100644 --- a/test/remote/gateways/remote_pay_junction_test.rb +++ b/test/remote/gateways/remote_pay_junction_test.rb @@ -37,8 +37,8 @@ def setup def test_successful_purchase assert response = @gateway.purchase(AMOUNT, @credit_card, @options) assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message - assert_equal 'capture', response.params["posture"], 'Should be captured funds' - assert_equal 'charge', response.params["transaction_action"] + assert_equal 'capture', response.params['posture'], 'Should be captured funds' + assert_equal 'charge', response.params['transaction_action'] assert_success response assert response.test? end @@ -48,8 +48,8 @@ def test_successful_purchase_with_cvv assert response = @gateway.purchase(AMOUNT, @credit_card, @options) assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message - assert_equal 'capture', response.params["posture"], 'Should be captured funds' - assert_equal 'charge', response.params["transaction_action"] + assert_equal 'capture', response.params['posture'], 'Should be captured funds' + assert_equal 'charge', response.params['transaction_action'] assert_success response end @@ -58,8 +58,8 @@ def test_successful_authorize assert response = @gateway.authorize( AMOUNT, @credit_card, @options) assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message - assert_equal 'hold', response.params["posture"], 'Should be a held charge' - assert_equal 'charge', response.params["transaction_action"] + assert_equal 'hold', response.params['posture'], 'Should be a held charge' + assert_equal 'charge', response.params['transaction_action'] assert_success response end @@ -70,9 +70,9 @@ def test_successful_capture response = @gateway.capture(AMOUNT, auth.authorization, @options) assert_success response - assert_equal 'capture', response.params["posture"], 'Should be a capture' + assert_equal 'capture', response.params['posture'], 'Should be a capture' assert_equal auth.authorization, response.authorization, - "Should maintain transaction ID across request" + 'Should maintain transaction ID across request' end def test_successful_credit @@ -80,7 +80,7 @@ def test_successful_credit assert_success purchase assert response = @gateway.credit(success_price, purchase.authorization) - assert_equal 'refund', response.params["transaction_action"] + assert_equal 'refund', response.params['transaction_action'] assert_success response end @@ -92,9 +92,9 @@ def test_successful_void assert response = @gateway.void(purchase.authorization, :order_id => order_id) assert_success response - assert_equal 'void', response.params["posture"], 'Should be a capture' + assert_equal 'void', response.params['posture'], 'Should be a capture' assert_equal purchase.authorization, response.authorization, - "Should maintain transaction ID across request" + 'Should maintain transaction ID across request' end def test_successful_instant_purchase @@ -108,8 +108,8 @@ def test_successful_instant_purchase assert response = @gateway.purchase(AMOUNT, purchase.authorization, :order_id => generate_unique_id) assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message - assert_equal 'capture', response.params["posture"], 'Should be captured funds' - assert_equal 'charge', response.params["transaction_action"] + assert_equal 'capture', response.params['posture'], 'Should be captured funds' + assert_equal 'charge', response.params['transaction_action'] assert_not_equal purchase.authorization, response.authorization, 'Should have recieved new transaction ID' @@ -124,7 +124,7 @@ def test_successful_recurring ) assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message - assert_equal 'charge', response.params["transaction_action"] + assert_equal 'charge', response.params['transaction_action'] assert_success response end @@ -132,7 +132,7 @@ def test_should_send_invoice response = @gateway.purchase(AMOUNT, @credit_card, @options) assert_success response - assert_equal @options[:order_id], response.params["invoice_number"], 'Should have set invoice' + assert_equal @options[:order_id], response.params['invoice_number'], 'Should have set invoice' end private diff --git a/test/remote/gateways/remote_pay_junction_v2_test.rb b/test/remote/gateways/remote_pay_junction_v2_test.rb index 99bfac7792c..62954ff4496 100644 --- a/test/remote/gateways/remote_pay_junction_v2_test.rb +++ b/test/remote/gateways/remote_pay_junction_v2_test.rb @@ -12,7 +12,7 @@ def setup end def test_invalid_login - gateway = PayJunctionV2Gateway.new(api_login: "", api_password: "", api_key: "") + gateway = PayJunctionV2Gateway.new(api_login: '', api_password: '', api_key: '') response = gateway.purchase(@amount, @credit_card, @options) assert_failure response @@ -62,7 +62,7 @@ def test_partial_capture assert capture = @gateway.capture(@amount-1, auth.authorization) assert_success capture - assert_equal sprintf("%.2f", (@amount-1).to_f / 100), capture.params["amountTotal"] + assert_equal sprintf('%.2f', (@amount-1).to_f / 100), capture.params['amountTotal'] end def test_failed_capture @@ -87,7 +87,7 @@ def test_partial_refund assert refund = @gateway.refund(@amount-50, purchase.authorization) assert_success refund assert_equal 'Approved', refund.message - assert_equal sprintf("%.2f", (@amount-50).to_f / 100), refund.params["amountTotal"] + assert_equal sprintf('%.2f', (@amount-50).to_f / 100), refund.params['amountTotal'] end def test_failed_refund @@ -99,14 +99,14 @@ def test_failed_refund def test_successful_credit response = @gateway.credit(@amount, @credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_failed_credit amount = 0 response = @gateway.credit(amount, @credit_card, @options) assert_failure response - assert_equal "Amount Base must be greater than 0.|", response.message + assert_equal 'Amount Base must be greater than 0.|', response.message end def test_successful_void @@ -127,7 +127,7 @@ def test_failed_void def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_failed_verify @@ -141,7 +141,7 @@ def test_successful_store_and_purchase response = @gateway.store(@credit_card, @options) assert_success response assert response.authorization - assert_equal "Approved", response.message + assert_equal 'Approved', response.message response = @gateway.purchase(@amount, response.authorization, @options) assert_success response diff --git a/test/remote/gateways/remote_paybox_direct_test.rb b/test/remote/gateways/remote_paybox_direct_test.rb index a76d61ab23d..e1d718056bb 100644 --- a/test/remote/gateways/remote_paybox_direct_test.rb +++ b/test/remote/gateways/remote_paybox_direct_test.rb @@ -54,7 +54,7 @@ def test_purchase_and_void def test_failed_capture assert response = @gateway.capture(@amount, '', :order_id => '1') assert_failure response - assert_equal "Invalid data", response.message + assert_equal 'Invalid data', response.message end def test_purchase_and_partial_credit @@ -97,7 +97,7 @@ def test_invalid_login ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Non autorise", response.message + assert_equal 'Non autorise', response.message end def test_invalid_login_without_rang @@ -107,6 +107,6 @@ def test_invalid_login_without_rang ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Non autorise", response.message + assert_equal 'Non autorise', response.message end end diff --git a/test/remote/gateways/remote_payeezy_test.rb b/test/remote/gateways/remote_payeezy_test.rb index 155991fc847..497332317ac 100644 --- a/test/remote/gateways/remote_payeezy_test.rb +++ b/test/remote/gateways/remote_payeezy_test.rb @@ -14,15 +14,15 @@ def setup } @options_mdd = { soft_descriptors: { - dba_name: "Caddyshack", - street: "1234 Any Street", - city: "Durham", - region: "North Carolina", - mid: "mid_1234", - mcc: "mcc_5678", - postal_code: "27701", - country_code: "US", - merchant_contact_info: "8885551212" + dba_name: 'Caddyshack', + street: '1234 Any Street', + city: 'Durham', + region: 'North Carolina', + mid: 'mid_1234', + mcc: 'mcc_5678', + postal_code: '27701', + country_code: 'US', + merchant_contact_info: '8885551212' } } end @@ -55,7 +55,7 @@ def test_successful_purchase end def test_successful_purchase_with_echeck - options = @options.merge({customer_id_type: "1", customer_id_number: "1", client_email: "test@example.com"}) + options = @options.merge({customer_id_type: '1', customer_id_number: '1', client_email: 'test@example.com'}) assert response = @gateway.purchase(@amount, @check, options) assert_match(/Transaction Normal/, response.message) assert_success response @@ -163,7 +163,7 @@ def test_failed_refund assert_match(/Transaction Normal/, purchase.message) assert_success purchase - assert response = @gateway.refund(50, "bad-authorization") + assert response = @gateway.refund(50, 'bad-authorization') assert_failure response assert_match(/The transaction tag is not provided/, response.message) assert response.authorization @@ -211,11 +211,11 @@ def test_failed_verify def test_bad_creditcard_number assert response = @gateway.purchase(@amount, @bad_credit_card, @options) assert_failure response - assert_equal response.error_code, "invalid_card_number" + assert_equal response.error_code, 'invalid_card_number' end def test_invalid_login - gateway = PayeezyGateway.new(apikey: "NotARealUser", apisecret: "NotARealPassword", token: "token") + gateway = PayeezyGateway.new(apikey: 'NotARealUser', apisecret: 'NotARealPassword', token: 'token') assert response = gateway.purchase(@amount, @credit_card, @options) assert_match %r{Invalid Api Key}, response.message assert_failure response @@ -224,8 +224,8 @@ def test_invalid_login def test_response_contains_cvv_and_avs_results response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal 'M', response.cvv_result["code"] - assert_equal '4', response.avs_result["code"] + assert_equal 'M', response.cvv_result['code'] + assert_equal '4', response.avs_result['code'] end def test_trans_error @@ -234,7 +234,7 @@ def test_trans_error assert response = @gateway.purchase(@amount, @credit_card, @options ) assert_match(/Server Error/, response.message) # 42 is 'unable to send trans' assert_failure response - assert_equal "500", response.error_code + assert_equal '500', response.error_code end def test_transcript_scrubbing_store diff --git a/test/remote/gateways/remote_payex_test.rb b/test/remote/gateways/remote_payex_test.rb index a66385b6927..fd37ddb6164 100644 --- a/test/remote/gateways/remote_payex_test.rb +++ b/test/remote/gateways/remote_payex_test.rb @@ -54,7 +54,7 @@ def test_authorization_and_void end def test_unsuccessful_void - assert response = @gateway.void("1") + assert response = @gateway.void('1') assert_failure response assert_not_equal 'OK', response.message assert_match %r{1}, response.message @@ -69,7 +69,7 @@ def test_successful_refund end def test_unsuccessful_refund - assert response = @gateway.refund(@amount, "1", order_id: '123') + assert response = @gateway.refund(@amount, '1', order_id: '123') assert_failure response assert_not_equal 'OK', response.message assert_match %r{1}, response.message diff --git a/test/remote/gateways/remote_payflow_express_test.rb b/test/remote/gateways/remote_payflow_express_test.rb index cbe24df044b..c2a2cbfe2c0 100644 --- a/test/remote/gateways/remote_payflow_express_test.rb +++ b/test/remote/gateways/remote_payflow_express_test.rb @@ -50,20 +50,20 @@ def test_set_express_purchase def test_setup_authorization_discount_taxes_included_free_shipping amount = 2518 - options = {:ip=>"127.0.0.1", - :return_url=>"http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1", - :cancel_return_url=>"http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1", - :customer=>"test6@test.com", - :email=>"test6@test.com", - :order_id=>"#1092", - :currency=>"USD", + options = {:ip=>'127.0.0.1', + :return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1', + :cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1', + :customer=>'test6@test.com', + :email=>'test6@test.com', + :order_id=>'#1092', + :currency=>'USD', :subtotal=>2798, :items => [ - {:name => "test4", - :description => "test4", + {:name => 'test4', + :description => 'test4', :quantity=>2 , :amount=> 1399 , - :url=>"http://localhost:3000/products/test4"}], + :url=>'http://localhost:3000/products/test4'}], :discount=>280, :no_shipping=>true} response = @gateway.setup_authorization(amount, options) @@ -72,20 +72,20 @@ def test_setup_authorization_discount_taxes_included_free_shipping def test_setup_authorization_with_discount_taxes_additional amount = 2518 - options = {:ip=>"127.0.0.1", - :return_url=>"http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1", - :cancel_return_url=>"http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1", - :customer=>"test6@test.com", - :email=>"test6@test.com", - :order_id=>"#1092", - :currency=>"USD", + options = {:ip=>'127.0.0.1', + :return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1', + :cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1', + :customer=>'test6@test.com', + :email=>'test6@test.com', + :order_id=>'#1092', + :currency=>'USD', :subtotal=>2798, :items => [ - {:name => "test4", - :description => "test4", + {:name => 'test4', + :description => 'test4', :quantity=>2 , :amount=> 1399 , - :url=>"http://localhost:3000/products/test4"}], + :url=>'http://localhost:3000/products/test4'}], :discount=>280, :no_shipping=>true} response = @gateway.setup_authorization(amount, options) @@ -94,20 +94,20 @@ def test_setup_authorization_with_discount_taxes_additional def test_setup_authorization_with_discount_taxes_and_shipping_addtiional amount = 2518 - options = {:ip=>"127.0.0.1", - :return_url=>"http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1", - :cancel_return_url=>"http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1", - :customer=>"test6@test.com", - :email=>"test6@test.com", - :order_id=>"#1092", - :currency=>"USD", + options = {:ip=>'127.0.0.1', + :return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1', + :cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1', + :customer=>'test6@test.com', + :email=>'test6@test.com', + :order_id=>'#1092', + :currency=>'USD', :subtotal=>2798, :items => [ - {:name => "test4", - :description => "test4", + {:name => 'test4', + :description => 'test4', :quantity=>2 , :amount=> 1399 , - :url=>"http://localhost:3000/products/test4"}], + :url=>'http://localhost:3000/products/test4'}], :discount=>280, :no_shipping=>false} response = @gateway.setup_authorization(amount, options) @@ -123,20 +123,20 @@ def setup def test_setup_authorization_discount_taxes_included_free_shipping amount = 2518 - options = {:ip=>"127.0.0.1", - :return_url=>"http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1", - :cancel_return_url=>"http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1", - :customer=>"test6@test.com", - :email=>"test6@test.com", - :order_id=>"#1092", - :currency=>"GBP", + options = {:ip=>'127.0.0.1', + :return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1', + :cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1', + :customer=>'test6@test.com', + :email=>'test6@test.com', + :order_id=>'#1092', + :currency=>'GBP', :subtotal=>2798, :items=> [ - {:name=>"test4", - :description=>"test4", + {:name=>'test4', + :description=>'test4', :quantity=>2, :amount=>1399, - :url=>"http://localhost:3000/products/test4"}, + :url=>'http://localhost:3000/products/test4'}, ], :discount=>280, :no_shipping=>true} @@ -146,20 +146,20 @@ def test_setup_authorization_discount_taxes_included_free_shipping def test_setup_authorization_with_discount_taxes_additional amount = 2518 - options = {:ip=>"127.0.0.1", - :return_url=>"http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1", - :cancel_return_url=>"http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1", - :customer=>"test6@test.com", - :email=>"test6@test.com", - :order_id=>"#1092", - :currency=>"GBP", + options = {:ip=>'127.0.0.1', + :return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1', + :cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1', + :customer=>'test6@test.com', + :email=>'test6@test.com', + :order_id=>'#1092', + :currency=>'GBP', :subtotal=>2798, :items=> [ - {:name=>"test4", - :description=>"test4", + {:name=>'test4', + :description=>'test4', :quantity=>2, :amount=>1399, - :url=>"http://localhost:3000/products/test4"}, + :url=>'http://localhost:3000/products/test4'}, ], :discount=>280, :no_shipping=>true} @@ -169,20 +169,20 @@ def test_setup_authorization_with_discount_taxes_additional def test_setup_authorization_with_discount_taxes_and_shipping_addtiional amount = 2518 - options = {:ip=>"127.0.0.1", - :return_url=>"http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1", - :cancel_return_url=>"http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1", - :customer=>"test6@test.com", - :email=>"test6@test.com", - :order_id=>"#1092", - :currency=>"GBP", + options = {:ip=>'127.0.0.1', + :return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1', + :cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1', + :customer=>'test6@test.com', + :email=>'test6@test.com', + :order_id=>'#1092', + :currency=>'GBP', :subtotal=>2798, :items=> [ - {:name=>"test4", - :description=>"test4", + {:name=>'test4', + :description=>'test4', :quantity=>2, :amount=>1399, - :url=>"http://localhost:3000/products/test4"}, + :url=>'http://localhost:3000/products/test4'}, ], :discount=>280, :no_shipping=>false} diff --git a/test/remote/gateways/remote_payflow_test.rb b/test/remote/gateways/remote_payflow_test.rb index 021ec914a54..23b7a13f37b 100644 --- a/test/remote/gateways/remote_payflow_test.rb +++ b/test/remote/gateways/remote_payflow_test.rb @@ -18,11 +18,11 @@ def setup } @extra_options = { - :order_id => "123", - :description => "Description string", - :order_desc => "OrderDesc string", - :comment => "Comment string", - :comment2 => "Comment2 string" + :order_id => '123', + :description => 'Description string', + :order_desc => 'OrderDesc string', + :comment => 'Comment string', + :comment2 => 'Comment2 string' } @check = check( @@ -33,7 +33,7 @@ def setup def test_successful_purchase assert response = @gateway.purchase(100000, @credit_card, @options) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? assert_not_nil response.authorization @@ -42,7 +42,7 @@ def test_successful_purchase def test_successful_purchase_with_extra_options assert response = @gateway.purchase(100000, @credit_card, @options.merge(@extra_options)) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? assert_not_nil response.authorization @@ -61,10 +61,10 @@ def test_successful_purchase_with_extra_options def test_successful_purchase_with_fraud_review assert response = @gateway.purchase( 100000, - credit_card("5555555555554444", verification_value: "") + credit_card('5555555555554444', verification_value: '') ) - assert_success response, "This is probably failing due to your Payflow test account not being set up for fraud filters." - assert_equal "126", response.params["result"] + assert_success response, 'This is probably failing due to your Payflow test account not being set up for fraud filters.' + assert_equal '126', response.params['result'] assert response.fraud_review? end @@ -83,8 +83,8 @@ def test_declined_purchase # This can be accomplished by sending an email to payflow-support@paypal.com with your Merchant Login. def test_successful_ach_purchase assert response = @gateway.purchase(50, @check) - assert_success response, "This is probably failing due to your Payflow test account not being set up for ACH." - assert_equal "Approved", response.message + assert_success response, 'This is probably failing due to your Payflow test account not being set up for ACH.' + assert_equal 'Approved', response.message assert response.test? assert_not_nil response.authorization end @@ -101,7 +101,7 @@ def test_ach_purchase_and_refund def test_successful_authorization assert response = @gateway.authorize(100, @credit_card, @options) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? assert_not_nil response.authorization @@ -153,7 +153,7 @@ def test_authorize_and_void def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Verified", response.message + assert_equal 'Verified', response.message end def test_successful_verify_amex @@ -163,13 +163,13 @@ def test_successful_verify_amex ) assert response = @gateway.verify(@amex_credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_failed_verify - assert response = @gateway.verify(credit_card("4000056655665556"), @options) + assert response = @gateway.verify(credit_card('4000056655665556'), @options) assert_failure response - assert_equal "Declined", response.message + assert_equal 'Declined', response.message end def test_invalid_login @@ -235,13 +235,13 @@ def test_full_feature_set_for_recurring_profiles :periodicity => :weekly, :payments => '12', :starting_at => Time.now + 1.day, - :comment => "Test Profile" + :comment => 'Test Profile' ) response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do @gateway.recurring(100, @credit_card, @options) end - assert_equal "Approved", response.params['message'] - assert_equal "0", response.params['result'] + assert_equal 'Approved', response.params['message'] + assert_equal '0', response.params['result'] assert_success response assert response.test? assert !response.params['profile_id'].blank? @@ -257,8 +257,8 @@ def test_full_feature_set_for_recurring_profiles response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do @gateway.recurring(400, @credit_card, @options) end - assert_equal "Approved", response.params['message'] - assert_equal "0", response.params['result'] + assert_equal 'Approved', response.params['message'] + assert_equal '0', response.params['result'] assert_success response assert response.test? @@ -266,7 +266,7 @@ def test_full_feature_set_for_recurring_profiles response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do @gateway.recurring_inquiry(@recurring_profile_id) end - assert_equal "0", response.params['result'] + assert_equal '0', response.params['result'] assert_success response assert response.test? @@ -282,8 +282,8 @@ def test_full_feature_set_for_recurring_profiles response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do @gateway.cancel_recurring(@recurring_profile_id) end - assert_equal "Approved", response.params['message'] - assert_equal "0", response.params['result'] + assert_equal 'Approved', response.params['message'] + assert_equal '0', response.params['result'] assert_success response assert response.test? end @@ -291,14 +291,14 @@ def test_full_feature_set_for_recurring_profiles # Note that this test will only work if you enable reference transactions!! def test_reference_purchase assert response = @gateway.purchase(10000, @credit_card, @options) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? assert_not_nil pn_ref = response.authorization # now another purchase, by reference assert response = @gateway.purchase(10000, pn_ref) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? end @@ -334,7 +334,7 @@ def test_purchase_and_refund def test_verify_credentials assert @gateway.verify_credentials - gateway = PayflowGateway.new(login: "unknown_login", password: "unknown_password", partner: "PayPal") + gateway = PayflowGateway.new(login: 'unknown_login', password: 'unknown_password', partner: 'PayPal') assert !gateway.verify_credentials end @@ -357,13 +357,13 @@ def test_purchase_and_refund_with_three_d_secure_option # check) unless Allow non-referenced credits = Yes in PayPal manager def test_purchase_and_credit assert credit = @gateway.credit(100, @credit_card, @options) - assert_success credit, "This is probably failing due to your Payflow test account not being set up to allow non-referenced credits." + assert_success credit, 'This is probably failing due to your Payflow test account not being set up to allow non-referenced credits.' end def test_successful_ach_credit assert response = @gateway.credit(50, @check) - assert_success response, "This is probably failing due to your Payflow test account not being set up for ACH." - assert_equal "Approved", response.message + assert_success response, 'This is probably failing due to your Payflow test account not being set up for ACH.' + assert_equal 'Approved', response.message assert response.test? assert_not_nil response.authorization end diff --git a/test/remote/gateways/remote_payflow_uk_test.rb b/test/remote/gateways/remote_payflow_uk_test.rb index 86d532693c0..ae2eafd0caa 100644 --- a/test/remote/gateways/remote_payflow_uk_test.rb +++ b/test/remote/gateways/remote_payflow_uk_test.rb @@ -18,19 +18,19 @@ def setup ) @solo = CreditCard.new( - :brand => "solo", - :number => "6334900000000005", + :brand => 'solo', + :number => '6334900000000005', :month => Time.now.month, :year => Time.now.year + 1, - :first_name => "Test", - :last_name => "Mensch", + :first_name => 'Test', + :last_name => 'Mensch', :issue_number => '01' ) @switch = CreditCard.new( - :brand => "switch", - :number => "5641820000000005", - :verification_value => "000", + :brand => 'switch', + :number => '5641820000000005', + :verification_value => '000', :month => 1, :year => 2008, :first_name => 'Fred', @@ -53,7 +53,7 @@ def setup def test_successful_purchase assert response = @gateway.purchase(100000, @creditcard, @options) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? assert_not_nil response.authorization @@ -68,7 +68,7 @@ def test_declined_purchase def test_successful_purchase_solo assert response = @gateway.purchase(100000, @solo, @options) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? assert_not_nil response.authorization @@ -78,7 +78,7 @@ def test_no_card_issue_or_card_start_with_switch assert response = @gateway.purchase(100000, @switch, @options) assert_failure response - assert_equal "Field format error: CARDSTART or CARDISSUE must be present", response.message + assert_equal 'Field format error: CARDSTART or CARDISSUE must be present', response.message assert_failure response assert response.test? end @@ -86,7 +86,7 @@ def test_no_card_issue_or_card_start_with_switch def test_successful_purchase_switch_with_issue_number @switch.issue_number = '01' assert response = @gateway.purchase(100000, @switch, @options) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? assert_not_nil response.authorization @@ -96,7 +96,7 @@ def test_successful_purchase_switch_with_start_date @switch.start_month = 12 @switch.start_year = 1999 assert response = @gateway.purchase(100000, @switch, @options) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? assert_not_nil response.authorization @@ -107,7 +107,7 @@ def test_successful_purchase_switch_with_start_date_and_issue_number @switch.start_month = 12 @switch.start_year = 1999 assert response = @gateway.purchase(100000, @switch, @options) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? assert_not_nil response.authorization @@ -115,7 +115,7 @@ def test_successful_purchase_switch_with_start_date_and_issue_number def test_successful_authorization assert response = @gateway.authorize(100, @creditcard, @options) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? assert_not_nil response.authorization diff --git a/test/remote/gateways/remote_payment_express_test.rb b/test/remote/gateways/remote_payment_express_test.rb index cc18a63de57..8fb5bfc22b7 100644 --- a/test/remote/gateways/remote_payment_express_test.rb +++ b/test/remote/gateways/remote_payment_express_test.rb @@ -20,26 +20,26 @@ def setup def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "The Transaction was approved", response.message + assert_equal 'The Transaction was approved', response.message assert_not_nil response.authorization end def test_successful_purchase_with_reference_id assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal "The Transaction was approved", response.message + assert_equal 'The Transaction was approved', response.message assert_success response assert_not_nil response.authorization end def test_declined_purchase - assert response = @gateway.purchase(@amount, credit_card("5431111111111228"), @options) + assert response = @gateway.purchase(@amount, credit_card('5431111111111228'), @options) assert_match %r{declined}i, response.message assert_failure response end def test_successful_authorization assert response = @gateway.authorize(@amount, @credit_card, @options) - assert_equal "The Transaction was approved", response.message + assert_equal 'The Transaction was approved', response.message assert_success response assert_not_nil response.authorization end @@ -59,7 +59,7 @@ def test_purchase_and_refund assert_success purchase assert_equal 'The Transaction was approved', purchase.message assert !purchase.authorization.blank? - assert refund = @gateway.refund(amount, purchase.authorization, :description => "Giving a refund") + assert refund = @gateway.refund(amount, purchase.authorization, :description => 'Giving a refund') assert_success refund end @@ -82,7 +82,7 @@ def test_invalid_login def test_store_credit_card assert response = @gateway.store(@credit_card) assert_success response - assert_equal "The Transaction was approved", response.message + assert_equal 'The Transaction was approved', response.message assert_not_nil token = response.authorization assert_equal token, response.token end @@ -91,7 +91,7 @@ def test_store_with_custom_token token = Time.now.to_i.to_s #hehe assert response = @gateway.store(@credit_card, :billing_id => token) assert_success response - assert_equal "The Transaction was approved", response.message + assert_equal 'The Transaction was approved', response.message assert_not_nil response.authorization assert_equal token, response.authorization end @@ -107,11 +107,11 @@ def test_store_invalid_credit_card def test_store_and_charge assert response = @gateway.store(@credit_card) assert_success response - assert_equal "The Transaction was approved", response.message + assert_equal 'The Transaction was approved', response.message assert (token = response.authorization) assert purchase = @gateway.purchase( @amount, token) - assert_equal "The Transaction was approved", purchase.message + assert_equal 'The Transaction was approved', purchase.message assert_success purchase assert_not_nil purchase.authorization end @@ -119,7 +119,7 @@ def test_store_and_charge def test_store_and_authorize_and_capture assert response = @gateway.store(@credit_card) assert_success response - assert_equal "The Transaction was approved", response.message + assert_equal 'The Transaction was approved', response.message assert (token = response.authorization) assert auth = @gateway.authorize(@amount, token, @options) diff --git a/test/remote/gateways/remote_paymill_test.rb b/test/remote/gateways/remote_paymill_test.rb index 66750bf524d..880f346a47d 100644 --- a/test/remote/gateways/remote_paymill_test.rb +++ b/test/remote/gateways/remote_paymill_test.rb @@ -124,7 +124,7 @@ def test_failed_refund end def test_invalid_login - gateway = PaymillGateway.new(public_key: fixtures(:paymill)[:public_key], private_key: "SomeBogusValue") + gateway = PaymillGateway.new(public_key: fixtures(:paymill)[:public_key], private_key: 'SomeBogusValue') response = gateway.purchase(@amount, @credit_card) assert_failure response assert_equal 'Access Denied', response.message @@ -168,7 +168,7 @@ def test_transcript_scrubbing def test_verify_credentials assert @gateway.verify_credentials - gateway = PaymillGateway.new(public_key: "unknown_key", private_key: "unknown_key") + gateway = PaymillGateway.new(public_key: 'unknown_key', private_key: 'unknown_key') assert !gateway.verify_credentials end diff --git a/test/remote/gateways/remote_paypal_test.rb b/test/remote/gateways/remote_paypal_test.rb index af3696d45ef..0e07e911d9f 100644 --- a/test/remote/gateways/remote_paypal_test.rb +++ b/test/remote/gateways/remote_paypal_test.rb @@ -4,7 +4,7 @@ class PaypalTest < Test::Unit::TestCase def setup @gateway = PaypalGateway.new(fixtures(:paypal_signature)) - @credit_card = credit_card("4381258770269608") # Use a generated CC from the paypal Sandbox + @credit_card = credit_card('4381258770269608') # Use a generated CC from the paypal Sandbox @declined_card = credit_card('234234234234') @params = { @@ -58,7 +58,7 @@ def test_successful_purchase_sans_cvv end def test_successful_purchase_with_descriptors - response = @gateway.purchase(@amount, @credit_card, @params.merge(soft_descriptor: "Active Merchant TXN", soft_descriptor_city: "800-883-3931")) + response = @gateway.purchase(@amount, @credit_card, @params.merge(soft_descriptor: 'Active Merchant TXN', soft_descriptor_city: '800-883-3931')) assert_success response assert response.params['transaction_id'] end @@ -116,7 +116,7 @@ def test_successful_capture def test_successful_incomplete_captures auth = @gateway.authorize(100, @credit_card, @params) assert_success auth - response = @gateway.capture(60, auth.authorization, {:complete_type => "NotComplete"}) + response = @gateway.capture(60, auth.authorization, {:complete_type => 'NotComplete'}) assert_success response assert response.params['transaction_id'] assert_equal '0.60', response.params['gross_amount'] @@ -166,7 +166,7 @@ def test_failed_voiding def test_successful_verify assert response = @gateway.verify(@credit_card, @params) assert_success response - assert_equal "0.00", response.params['amount'] + assert_equal '0.00', response.params['amount'] assert_match %r{This card authorization verification is not a payment transaction}, response.message end @@ -180,9 +180,9 @@ def test_successful_verify_non_visa_mc amex_card = credit_card('371449635398431', brand: nil, verification_value: '1234') assert response = @gateway.verify(amex_card, @params) assert_success response - assert_equal "1.00", response.params['amount'] + assert_equal '1.00', response.params['amount'] assert_match %r{Success}, response.message - assert_success response.responses.last, "The void should succeed" + assert_success response.responses.last, 'The void should succeed' end def test_successful_transfer diff --git a/test/remote/gateways/remote_payscout_test.rb b/test/remote/gateways/remote_payscout_test.rb index e3ad29ce708..d212f32845b 100644 --- a/test/remote/gateways/remote_payscout_test.rb +++ b/test/remote/gateways/remote_payscout_test.rb @@ -98,26 +98,26 @@ def test_approved_refund purchase = @gateway.purchase(@amount, @credit_card, @options) assert refund = @gateway.refund(@amount, purchase.authorization) assert_success refund - assert_equal "The transaction has been approved", refund.message + assert_equal 'The transaction has been approved', refund.message end def test_not_found_transaction_id_refund assert refund = @gateway.refund(@amount, '1234567890') assert_failure refund - assert_match "Transaction not found", refund.message + assert_match 'Transaction not found', refund.message end def test_invalid_transaction_id_refund assert refund = @gateway.refund(@amount, '') assert_failure refund - assert_match "Invalid Transaction ID", refund.message + assert_match 'Invalid Transaction ID', refund.message end def test_invalid_amount_refund purchase = @gateway.purchase(@amount, @credit_card, @options) assert refund = @gateway.refund(200, purchase.authorization) assert_failure refund - assert_match "Refund amount may not exceed the transaction balance", refund.message + assert_match 'Refund amount may not exceed the transaction balance', refund.message end ########## Void ########## @@ -126,26 +126,26 @@ def test_approved_void_purchase purchase = @gateway.purchase(@amount, @credit_card, @options) assert void = @gateway.void(purchase.authorization) assert_success void - assert_equal "The transaction has been approved", void.message + assert_equal 'The transaction has been approved', void.message end def test_approved_void_authorization auth = @gateway.authorize(@amount, @credit_card, @options) assert void = @gateway.void(auth.authorization) assert_success void - assert_equal "The transaction has been approved", void.message + assert_equal 'The transaction has been approved', void.message end def test_invalid_transaction_id_void assert void = @gateway.void('') assert_failure void - assert_match "Invalid Transaction ID", void.message + assert_match 'Invalid Transaction ID', void.message end def test_not_found_transaction_id_void assert void = @gateway.void('1234567890') assert_failure void - assert_match "Transaction not found", void.message + assert_match 'Transaction not found', void.message end def test_invalid_credentials diff --git a/test/remote/gateways/remote_paystation_test.rb b/test/remote/gateways/remote_paystation_test.rb index a66abd7e4ef..0225ee25e4c 100644 --- a/test/remote/gateways/remote_paystation_test.rb +++ b/test/remote/gateways/remote_paystation_test.rb @@ -27,7 +27,7 @@ def test_successful_purchase end def test_successful_purchase_in_gbp - assert response = @gateway.purchase(@successful_amount, @credit_card, @options.merge(:currency => "GBP")) + assert response = @gateway.purchase(@successful_amount, @credit_card, @options.merge(:currency => 'GBP')) assert_success response assert_equal 'Transaction successful', response.message @@ -35,10 +35,10 @@ def test_successful_purchase_in_gbp def test_failed_purchases [ - ["insufficient_funds", @insufficient_funds_amount, "Insufficient Funds"], - ["invalid_transaction", @invalid_transaction_amount, "Transaction Type Not Supported"], - ["expired_card", @expired_card_amount, "Expired Card"], - ["bank_error", @bank_error_amount, "Error Communicating with Bank"] + ['insufficient_funds', @insufficient_funds_amount, 'Insufficient Funds'], + ['invalid_transaction', @invalid_transaction_amount, 'Transaction Type Not Supported'], + ['expired_card', @expired_card_amount, 'Expired Card'], + ['bank_error', @bank_error_amount, 'Error Communicating with Bank'] ].each do |name, amount, message| assert response = @gateway.purchase(amount, @credit_card, @options) @@ -53,7 +53,7 @@ def test_storing_token assert response = @gateway.store(@credit_card, @options.merge(:token => "justatest#{time}")) assert_success response - assert_equal "Future Payment Saved Ok", response.message + assert_equal 'Future Payment Saved Ok', response.message assert_equal "justatest#{time}", response.token end @@ -63,7 +63,7 @@ def test_billing_stored_token assert charge_response = @gateway.purchase(@successful_amount, store_response.token, @options) assert_success charge_response - assert_equal "Transaction successful", charge_response.message + assert_equal 'Transaction successful', charge_response.message end def test_authorize_and_capture @@ -85,7 +85,7 @@ def test_capture_without_cvv assert capture = @gateway.capture(@successful_amount, auth.authorization, @options) assert_failure capture - assert_equal "Card Security Code (CVV/CSC) Required", capture.message + assert_equal 'Card Security Code (CVV/CSC) Required', capture.message end def test_invalid_login @@ -101,13 +101,13 @@ def test_successful_refund assert_success response refund = @gateway.refund(@successful_amount, response.authorization, @options) assert_success refund - assert_equal "Transaction successful", refund.message + assert_equal 'Transaction successful', refund.message end def test_failed_refund - response = @gateway.refund(nil, "", @options) + response = @gateway.refund(nil, '', @options) assert_failure response - assert_equal "Error 11:", response.params["strong"] + assert_equal 'Error 11:', response.params['strong'] end def test_successful_verify diff --git a/test/remote/gateways/remote_payu_in_test.rb b/test/remote/gateways/remote_payu_in_test.rb index f8929893e05..182c3a1cc17 100644 --- a/test/remote/gateways/remote_payu_in_test.rb +++ b/test/remote/gateways/remote_payu_in_test.rb @@ -23,27 +23,27 @@ def test_successful_purchase_with_full_options @amount, @credit_card, order_id: generate_unique_id, - description: "Awesome!", - email: "jim@example.com", + description: 'Awesome!', + email: 'jim@example.com', billing_address: { - name: "Jim Smith", - address1: "123 Road", - address2: "Suite 123", - city: "Somewhere", - state: "ZZ", - country: "US", - zip: "12345", - phone: "12223334444" + name: 'Jim Smith', + address1: '123 Road', + address2: 'Suite 123', + city: 'Somewhere', + state: 'ZZ', + country: 'US', + zip: '12345', + phone: '12223334444' }, shipping_address: { - name: "Joe Bob", - address1: "987 Street", - address2: "Suite 987", - city: "Anyplace", - state: "AA", - country: "IN", - zip: "98765", - phone: "98887776666" + name: 'Joe Bob', + address1: '987 Street', + address2: 'Suite 987', + city: 'Anyplace', + state: 'AA', + country: 'IN', + zip: '98765', + phone: '98887776666' } ) @@ -78,9 +78,9 @@ def test_failed_refund end def test_3ds_enrolled_card_fails - response = @gateway.purchase(@amount, credit_card("4012001037141112"), @options) + response = @gateway.purchase(@amount, credit_card('4012001037141112'), @options) assert_failure response - assert_equal "3D-secure enrolled cards are not supported.", response.message + assert_equal '3D-secure enrolled cards are not supported.', response.message =begin # This is handy for testing that 3DS is working with PayU @@ -115,7 +115,7 @@ def test_transcript_scrubbing transcript = @gateway.scrub(transcript) assert_scrubbed(@credit_card.number, transcript) - refute_match %r{[^\d]#{@credit_card.verification_value}(?:[^\d]|$)}, "Expected CVV to be scrubbed out of transcript" + refute_match %r{[^\d]#{@credit_card.verification_value}(?:[^\d]|$)}, 'Expected CVV to be scrubbed out of transcript' end def test_invalid_login diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index e6edb50f82f..a33a22558dd 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -1,34 +1,34 @@ -require "test_helper" +require 'test_helper' class RemotePayuLatamTest < Test::Unit::TestCase def setup @gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(payment_country: 'AR')) @amount = 4000 - @credit_card = credit_card("4097440000000004", verification_value: "444", first_name: "APPROVED", last_name: "") - @declined_card = credit_card("4097440000000004", verification_value: "444", first_name: "REJECTED", last_name: "") - @pending_card = credit_card("4097440000000004", verification_value: "444", first_name: "PENDING", last_name: "") + @credit_card = credit_card('4097440000000004', verification_value: '444', first_name: 'APPROVED', last_name: '') + @declined_card = credit_card('4097440000000004', verification_value: '444', first_name: 'REJECTED', last_name: '') + @pending_card = credit_card('4097440000000004', verification_value: '444', first_name: 'PENDING', last_name: '') @options = { dni_number: '5415668464654', - currency: "ARS", + currency: 'ARS', order_id: generate_unique_id, - description: "Active Merchant Transaction", + description: 'Active Merchant Transaction', installments_number: 1, tax: 0, - email: "username@domain.com", - ip: "127.0.0.1", + email: 'username@domain.com', + ip: '127.0.0.1', device_session_id: 'vghs6tvkcle931686k1900o6e1', cookie: 'pt1t38347bs6jc9ruv2ecpv7o2', user_agent: 'Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0', billing_address: address( - address1: "Viamonte", - address2: "1366", - city: "Plata", - state: "Buenos Aires", - country: "AR", - zip: "64000", - phone: "7563126" + address1: 'Viamonte', + address2: '1366', + city: 'Plata', + state: 'Buenos Aires', + country: 'AR', + zip: '64000', + phone: '7563126' ) } end @@ -37,7 +37,7 @@ def setup # supports auth and purchase transactions only def test_invalid_login - gateway = PayuLatamGateway.new(merchant_id: "", account_id: "", api_login: "U", api_key: "U", payment_country: "AR") + gateway = PayuLatamGateway.new(merchant_id: '', account_id: '', api_login: 'U', api_key: 'U', payment_country: 'AR') response = gateway.purchase(@amount, @credit_card, @options) assert_failure response end @@ -45,39 +45,39 @@ def test_invalid_login def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end def test_successful_purchase_with_specified_language response = @gateway.purchase(@amount, @credit_card, @options.merge(language: 'es')) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end def test_successul_purchase_with_buyer - gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512327", payment_country: "BR")) + gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => '512327', payment_country: 'BR')) options_buyer = { - currency: "BRL", + currency: 'BRL', billing_address: address( - address1: "Calle 100", - address2: "BL4", - city: "Sao Paulo", - state: "SP", - country: "BR", - zip: "09210710", - phone: "(11)756312633" + address1: 'Calle 100', + address2: 'BL4', + city: 'Sao Paulo', + state: 'SP', + country: 'BR', + zip: '09210710', + phone: '(11)756312633' ), shipping_address: address( - address1: "Calle 200", - address2: "N107", - city: "Sao Paulo", - state: "SP", - country: "BR", - zip: "01019-030", - phone: "(11)756312633" + address1: 'Calle 200', + address2: 'N107', + city: 'Sao Paulo', + state: 'SP', + country: 'BR', + zip: '01019-030', + phone: '(11)756312633' ), buyer: { name: 'Jorge Borges', @@ -90,109 +90,109 @@ def test_successul_purchase_with_buyer response = gateway.purchase(@amount, @credit_card, @options.update(options_buyer)) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end def test_successful_purchase_brazil - gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512327", payment_country: "BR")) + gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => '512327', payment_country: 'BR')) options_brazil = { - payment_country: "BR", - currency: "BRL", + payment_country: 'BR', + currency: 'BRL', billing_address: address( - address1: "Calle 100", - address2: "BL4", - city: "Sao Paulo", - state: "SP", - country: "BR", - zip: "09210710", - phone: "(11)756312633" + address1: 'Calle 100', + address2: 'BL4', + city: 'Sao Paulo', + state: 'SP', + country: 'BR', + zip: '09210710', + phone: '(11)756312633' ), shipping_address: address( - address1: "Calle 200", - address2: "N107", - city: "Sao Paulo", - state: "SP", - country: "BR", - zip: "01019-030", - phone: "(11)756312633" + address1: 'Calle 200', + address2: 'N107', + city: 'Sao Paulo', + state: 'SP', + country: 'BR', + zip: '01019-030', + phone: '(11)756312633' ), buyer:{ - cnpj: "32593371000110" + cnpj: '32593371000110' } } response = gateway.purchase(@amount, @credit_card, @options.update(options_brazil)) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end def test_successful_purchase_colombia - gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512321", payment_country: "CO")) + gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => '512321', payment_country: 'CO')) options_colombia = { - payment_country: "CO", - currency: "COP", + payment_country: 'CO', + currency: 'COP', billing_address: address( - address1: "Calle 100", - address2: "BL4", - city: "Bogota", - state: "Bogota DC", - country: "CO", - zip: "09210710", - phone: "(11)756312633" + address1: 'Calle 100', + address2: 'BL4', + city: 'Bogota', + state: 'Bogota DC', + country: 'CO', + zip: '09210710', + phone: '(11)756312633' ), shipping_address: address( - address1: "Calle 200", - address2: "N107", - city: "Bogota", - state: "Bogota DC", - country: "CO", - zip: "01019-030", - phone: "(11)756312633" + address1: 'Calle 200', + address2: 'N107', + city: 'Bogota', + state: 'Bogota DC', + country: 'CO', + zip: '01019-030', + phone: '(11)756312633' ), - tax: "3193", - tax_return_base: "16806" + tax: '3193', + tax_return_base: '16806' } response = gateway.purchase(2000000, @credit_card, @options.update(options_colombia)) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end def test_successful_purchase_mexico - gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => "512324", payment_country: "MX")) + gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => '512324', payment_country: 'MX')) options_mexico = { - payment_country: "MX", - currency: "MXN", + payment_country: 'MX', + currency: 'MXN', billing_address: address( - address1: "Calle 100", - address2: "BL4", - city: "Guadalajara", - state: "Jalisco", - country: "MX", - zip: "09210710", - phone: "(11)756312633" + address1: 'Calle 100', + address2: 'BL4', + city: 'Guadalajara', + state: 'Jalisco', + country: 'MX', + zip: '09210710', + phone: '(11)756312633' ), shipping_address: address( - address1: "Calle 200", - address2: "N107", - city: "Guadalajara", - state: "Jalisco", - country: "MX", - zip: "01019-030", - phone: "(11)756312633" + address1: 'Calle 200', + address2: 'N107', + city: 'Guadalajara', + state: 'Jalisco', + country: 'MX', + zip: '01019-030', + phone: '(11)756312633' ), birth_date: '1985-05-25' } response = gateway.purchase(@amount, @credit_card, @options.update(options_mexico)) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end @@ -201,54 +201,54 @@ def test_successful_purchase_no_description options.delete(:description) response = @gateway.purchase(@amount, @credit_card, options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "DECLINED", response.params["transactionResponse"]["state"] + assert_equal 'DECLINED', response.params['transactionResponse']['state'] end def test_failed_purchase_with_no_options response = @gateway.purchase(@amount, @declined_card, {}) assert_failure response - assert_equal "DECLINED", response.params["transactionResponse"]["state"] + assert_equal 'DECLINED', response.params['transactionResponse']['state'] end def test_failed_purchase_with_specified_language - gateway = PayuLatamGateway.new(merchant_id: "", account_id: "", api_login: "U", api_key: "U", payment_country: "AR") + gateway = PayuLatamGateway.new(merchant_id: '', account_id: '', api_login: 'U', api_key: 'U', payment_country: 'AR') response = gateway.purchase(@amount, @declined_card, @options.merge(language: 'es')) assert_failure response - assert_equal "Credenciales inválidas", response.message + assert_equal 'Credenciales inválidas', response.message end def test_successful_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert_match %r(^\d+\|(\w|-)+$), response.authorization end def test_successful_authorize_with_specified_language response = @gateway.authorize(@amount, @credit_card, @options.merge(language: 'es')) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert_match %r(^\d+\|(\w|-)+$), response.authorization end def test_failed_authorize response = @gateway.authorize(@amount, @pending_card, @options) assert_failure response - assert_equal "DECLINED", response.params["transactionResponse"]["state"] + assert_equal 'DECLINED', response.params['transactionResponse']['state'] end def test_failed_authorize_with_specified_language - gateway = PayuLatamGateway.new(merchant_id: "", account_id: "", api_login: "U", api_key: "U", payment_country: "AR") + gateway = PayuLatamGateway.new(merchant_id: '', account_id: '', api_login: 'U', api_key: 'U', payment_country: 'AR') response = gateway.authorize(@amount, @pending_card, @options.merge(language: 'es')) assert_failure response - assert_equal "Credenciales inválidas", response.message + assert_equal 'Credenciales inválidas', response.message end def test_well_formed_refund_fails_as_expected @@ -256,7 +256,7 @@ def test_well_formed_refund_fails_as_expected assert_success purchase assert refund = @gateway.refund(@amount, purchase.authorization, @options) - assert_equal "The payment plan id cannot be empty", refund.message + assert_equal 'The payment plan id cannot be empty', refund.message end def test_failed_refund @@ -278,7 +278,7 @@ def test_unsupported_test_void_fails_as_expected assert void = @gateway.void(auth.authorization) assert_failure void - assert_equal "Internal payment provider error. ", void.message + assert_equal 'Internal payment provider error. ', void.message end def test_failed_void @@ -312,7 +312,7 @@ def test_failed_capture def test_verify_credentials assert @gateway.verify_credentials - gateway = PayuLatamGateway.new(merchant_id: "X", account_id: "512322", api_login: "X", api_key: "X", payment_country: "AR") + gateway = PayuLatamGateway.new(merchant_id: 'X', account_id: '512322', api_login: 'X', api_key: 'X', payment_country: 'AR') assert !gateway.verify_credentials end @@ -320,35 +320,35 @@ def test_successful_verify verify = @gateway.verify(@credit_card, @options) assert_success verify - assert_equal "APPROVED", verify.message + assert_equal 'APPROVED', verify.message end def test_successful_verify_with_specified_amount verify = @gateway.verify(@credit_card, @options.merge(verify_amount: 5100)) assert_success verify - assert_equal "APPROVED", verify.message + assert_equal 'APPROVED', verify.message end def test_successful_verify_with_specified_language verify = @gateway.verify(@credit_card, @options.merge(language: 'es')) assert_success verify - assert_equal "APPROVED", verify.message + assert_equal 'APPROVED', verify.message end def test_failed_verify_with_specified_amount verify = @gateway.verify(@credit_card, @options.merge(verify_amount: 1699)) assert_failure verify - assert_equal "The order value is less than minimum allowed. Minimum value allowed 17 ARS", verify.message + assert_equal 'The order value is less than minimum allowed. Minimum value allowed 17 ARS', verify.message end def test_failed_verify_with_specified_language verify = @gateway.verify(@credit_card, @options.merge(verify_amount: 1699, language: 'es')) assert_failure verify - assert_equal "The order value is less than minimum allowed. Minimum value allowed 17 ARS", verify.message + assert_equal 'The order value is less than minimum allowed. Minimum value allowed 17 ARS', verify.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_payway_test.rb b/test/remote/gateways/remote_payway_test.rb index a0dc5e6b086..9d900c8528b 100644 --- a/test/remote/gateways/remote_payway_test.rb +++ b/test/remote/gateways/remote_payway_test.rb @@ -8,42 +8,42 @@ def setup @gateway = ActiveMerchant::Billing::PaywayGateway.new(fixtures(:payway)) - @visa = credit_card("4564710000000004", + @visa = credit_card('4564710000000004', :month => 2, :year => 2019, - :verification_value => "847" + :verification_value => '847' ) - @mastercard = credit_card("5163200000000008", + @mastercard = credit_card('5163200000000008', :month => 8, :year => 2020, - :verification_value => "070", - :brand => "master" + :verification_value => '070', + :brand => 'master' ) - @expired = credit_card("4564710000000012", + @expired = credit_card('4564710000000012', :month => 2, :year => 2005, - :verification_value => "963" + :verification_value => '963' ) - @low = credit_card("4564710000000020", + @low = credit_card('4564710000000020', :month => 5, :year => 2020, - :verification_value => "234" + :verification_value => '234' ) - @stolen_mastercard = credit_card("5163200000000016", + @stolen_mastercard = credit_card('5163200000000016', :month => 12, :year => 2019, - :verification_value => "728", - :brand => "master" + :verification_value => '728', + :brand => 'master' ) - @invalid = credit_card("4564720000000037", + @invalid = credit_card('4564720000000037', :month => 9, :year => 2019, - :verification_value => "030" + :verification_value => '030' ) end diff --git a/test/remote/gateways/remote_pin_test.rb b/test/remote/gateways/remote_pin_test.rb index 88d41346671..010830cf89b 100644 --- a/test/remote/gateways/remote_pin_test.rb +++ b/test/remote/gateways/remote_pin_test.rb @@ -54,7 +54,7 @@ def test_failed_authorize end def test_failed_capture_due_to_invalid_token - response = @gateway.capture(@amount, "bogus", @options) + response = @gateway.capture(@amount, 'bogus', @options) assert_failure response end @@ -84,8 +84,8 @@ def test_unsuccessful_purchase # falls outside of active merchant def test_store_and_charge_with_pinjs_card_token headers = { - "Content-Type" => "application/json", - "Authorization" => "Basic #{Base64.strict_encode64(@gateway.options[:api_key] + ':').strip}" + 'Content-Type' => 'application/json', + 'Authorization' => "Basic #{Base64.strict_encode64(@gateway.options[:api_key] + ':').strip}" } # Get a token equivalent to what is returned by Pin.js card_attrs = { @@ -94,17 +94,17 @@ def test_store_and_charge_with_pinjs_card_token :expiry_year => @credit_card.year, :cvc => @credit_card.verification_value, :name => "#{@credit_card.first_name} #{@credit_card.last_name}", - :address_line1 => "42 Sevenoaks St", - :address_city => "Lathlain", - :address_postcode => "6454", - :address_start => "WA", - :address_country => "Australia" + :address_line1 => '42 Sevenoaks St', + :address_city => 'Lathlain', + :address_postcode => '6454', + :address_start => 'WA', + :address_country => 'Australia' } - url = @gateway.test_url + "/cards" + url = @gateway.test_url + '/cards' body = JSON.parse(@gateway.ssl_post(url, card_attrs.to_json, headers)) - card_token = body["response"]["token"] + card_token = body['response']['token'] store = @gateway.store(card_token, @options) assert_success store diff --git a/test/remote/gateways/remote_plugnpay_test.rb b/test/remote/gateways/remote_plugnpay_test.rb index 1c57a5ec65d..f05f4dc7701 100644 --- a/test/remote/gateways/remote_plugnpay_test.rb +++ b/test/remote/gateways/remote_plugnpay_test.rb @@ -3,7 +3,7 @@ class PlugnpayTest < Test::Unit::TestCase def setup @gateway = PlugnpayGateway.new(fixtures(:plugnpay)) - @good_card = credit_card("4111111111111111", first_name: 'cardtest') + @good_card = credit_card('4111111111111111', first_name: 'cardtest') @bad_card = credit_card('1234123412341234') @options = { :billing_address => address, @@ -47,7 +47,7 @@ def test_authorization_and_capture assert capture = @gateway.capture(@amount, authorization.authorization) assert_success capture - assert capture.params['aux_msg'].include? "has been successfully marked for settlement." + assert capture.params['aux_msg'].include? 'has been successfully marked for settlement.' assert_equal 'Success', capture.message end @@ -57,7 +57,7 @@ def test_authorization_and_partial_capture assert capture = @gateway.capture(@amount - 1, authorization.authorization) assert_success capture - assert capture.params['aux_msg'].include? "has been successfully reauthed for usd 0.99" + assert capture.params['aux_msg'].include? 'has been successfully reauthed for usd 0.99' assert_equal 'Success', capture.message end diff --git a/test/remote/gateways/remote_pro_pay_test.rb b/test/remote/gateways/remote_pro_pay_test.rb index f08bd6e9176..5a99435ed6b 100644 --- a/test/remote/gateways/remote_pro_pay_test.rb +++ b/test/remote/gateways/remote_pro_pay_test.rb @@ -10,7 +10,7 @@ def setup @credit_card_without_cvv = credit_card('4747474747474747', verification_value: nil) @options = { billing_address: address, - account_num: "32287391" + account_num: '32287391' } end @@ -23,9 +23,9 @@ def test_successful_purchase def test_successful_purchase_with_more_options options = { order_id: '1', - ip: "127.0.0.1", - email: "joe@example.com", - account_num: "32287391" + ip: '127.0.0.1', + email: 'joe@example.com', + account_num: '32287391' } response = @gateway.purchase(@amount, @credit_card, options) @@ -130,7 +130,7 @@ def test_failed_credit def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_match "Success", response.message + assert_match 'Success', response.message end def test_failed_verify diff --git a/test/remote/gateways/remote_psl_card_test.rb b/test/remote/gateways/remote_psl_card_test.rb index 36af7abf443..a5ea5c9d6ed 100644 --- a/test/remote/gateways/remote_psl_card_test.rb +++ b/test/remote/gateways/remote_psl_card_test.rb @@ -41,7 +41,7 @@ def test_successful_visa_debit_purchase # Fix regression discovered in production def test_visa_debit_purchase_should_not_send_debit_info_if_present - @visa_debit.start_month = "07" + @visa_debit.start_month = '07' response = @gateway.purchase(@accept_amount, @visa_debit, :billing_address => @visa_debit_address ) diff --git a/test/remote/gateways/remote_qbms_test.rb b/test/remote/gateways/remote_qbms_test.rb index d97be9f3b2d..017ebd1fc95 100644 --- a/test/remote/gateways/remote_qbms_test.rb +++ b/test/remote/gateways/remote_qbms_test.rb @@ -66,26 +66,26 @@ def test_successful_credit end def test_invalid_ticket - gateway = QbmsGateway.new(@gateway_options.merge(:ticket => "test123")) + gateway = QbmsGateway.new(@gateway_options.merge(:ticket => 'test123')) assert response = gateway.authorize(@amount, @card, @options) assert_instance_of Response, response assert_failure response - assert_equal "Application agent not found test123", response.message + assert_equal 'Application agent not found test123', response.message end def test_invalid_card_number assert response = @gateway.authorize(@amount, error_card('10301_ccinvalid'), @options) assert_instance_of Response, response assert_failure response - assert_equal "This credit card number is invalid.", response.message + assert_equal 'This credit card number is invalid.', response.message end def test_decline assert response = @gateway.authorize(@amount, error_card('10401_decline'), @options) assert_instance_of Response, response assert_failure response - assert_equal "The request to process this transaction has been declined.", response.message + assert_equal 'The request to process this transaction has been declined.', response.message end def test_transcript_scrubbing @@ -102,6 +102,6 @@ def test_transcript_scrubbing private def error_card(config_id) - credit_card('4111111111111111', :first_name => "configid=#{config_id}", :last_name => "") + credit_card('4111111111111111', :first_name => "configid=#{config_id}", :last_name => '') end end diff --git a/test/remote/gateways/remote_quickbooks_test.rb b/test/remote/gateways/remote_quickbooks_test.rb index e1f061c6e04..c9e95c959c8 100644 --- a/test/remote/gateways/remote_quickbooks_test.rb +++ b/test/remote/gateways/remote_quickbooks_test.rb @@ -28,7 +28,7 @@ def test_successful_purchase def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "cardNumber is invalid.", response.message + assert_equal 'cardNumber is invalid.', response.message end def test_successful_authorize_and_capture @@ -49,7 +49,7 @@ def test_partial_capture assert_success auth assert capture = @gateway.capture(@partial_amount, auth.authorization) - assert_equal capture.params['captureDetail']['amount'], sprintf("%.2f", @partial_amount.to_f / 100) + assert_equal capture.params['captureDetail']['amount'], sprintf('%.2f', @partial_amount.to_f / 100) assert_success capture end @@ -71,7 +71,7 @@ def test_partial_refund assert_success purchase assert refund = @gateway.refund(@partial_amount, purchase.authorization) - assert_equal refund.params['amount'], sprintf("%.2f", @partial_amount.to_f / 100) + assert_equal refund.params['amount'], sprintf('%.2f', @partial_amount.to_f / 100) assert_success refund end diff --git a/test/remote/gateways/remote_quickpay_test.rb b/test/remote/gateways/remote_quickpay_test.rb index 2733ee7eac3..c7c9c22cc1f 100644 --- a/test/remote/gateways/remote_quickpay_test.rb +++ b/test/remote/gateways/remote_quickpay_test.rb @@ -174,16 +174,16 @@ def test_successful_purchase_and_credit end def test_successful_store_and_reference_purchase - assert store = @gateway.store(@visa, @options.merge(:description => "New subscription")) + assert store = @gateway.store(@visa, @options.merge(:description => 'New subscription')) assert_success store assert purchase = @gateway.purchase(@amount, store.authorization, @options.merge(:order_id => generate_unique_id[0...10])) assert_success purchase end def test_failed_store - assert store = @gateway.store(credit_card('4'), @options.merge(:description => "New subscription")) + assert store = @gateway.store(credit_card('4'), @options.merge(:description => 'New subscription')) assert_failure store - assert_equal "Error in field: cardnumber", store.message + assert_equal 'Error in field: cardnumber', store.message end def test_invalid_login diff --git a/test/remote/gateways/remote_quickpay_v10_test.rb b/test/remote/gateways/remote_quickpay_v10_test.rb index 0d887c8ae93..d10e107fa09 100644 --- a/test/remote/gateways/remote_quickpay_v10_test.rb +++ b/test/remote/gateways/remote_quickpay_v10_test.rb @@ -68,13 +68,13 @@ def test_successful_usd_purchase end def test_successful_purchase_with_acquirers - assert response = @gateway.purchase(@amount, @valid_card, @options.update(:acquirer => "nets")) + assert response = @gateway.purchase(@amount, @valid_card, @options.update(:acquirer => 'nets')) assert_equal 'OK', response.message assert_success response end def test_unsuccessful_purchase_with_invalid_acquirers - assert response = @gateway.purchase(@amount, @valid_card, @options.update(:acquirer => "invalid")) + assert response = @gateway.purchase(@amount, @valid_card, @options.update(:acquirer => 'invalid')) assert_failure response assert_equal 'Validation error', response.message end @@ -165,7 +165,7 @@ def test_successful_verify def test_failed_verify response = @gateway.verify(@invalid_card, @options) assert_failure response - assert_equal "Rejected test operation", response.message + assert_equal 'Rejected test operation', response.message end def test_successful_store diff --git a/test/remote/gateways/remote_quickpay_v4_test.rb b/test/remote/gateways/remote_quickpay_v4_test.rb index a17b1a15c12..06fab13d6e8 100644 --- a/test/remote/gateways/remote_quickpay_v4_test.rb +++ b/test/remote/gateways/remote_quickpay_v4_test.rb @@ -39,10 +39,10 @@ def test_successful_purchase_with_all_fraud_parameters @options[:fraud_http_referer] = 'http://www.excample.com' @options[:fraud_remote_addr] = '127.0.0.1' @options[:fraud_http_accept] = 'foo' - @options[:fraud_http_accept_language] = "DK" - @options[:fraud_http_accept_encoding] = "UFT8" - @options[:fraud_http_accept_charset] = "Latin" - @options[:fraud_http_user_agent] = "Safari" + @options[:fraud_http_accept_language] = 'DK' + @options[:fraud_http_accept_encoding] = 'UFT8' + @options[:fraud_http_accept_charset] = 'Latin' + @options[:fraud_http_user_agent] = 'Safari' assert response = @gateway.purchase(@amount, @visa, @options) assert_equal 'OK', response.message @@ -191,7 +191,7 @@ def test_successful_purchase_and_credit end def test_successful_store_and_reference_purchase - assert store = @gateway.store(@visa, @options.merge(:description => "New subscription")) + assert store = @gateway.store(@visa, @options.merge(:description => 'New subscription')) assert_success store assert purchase = @gateway.purchase(@amount, store.authorization, @options.merge(:order_id => generate_unique_id[0...10])) assert_success purchase diff --git a/test/remote/gateways/remote_quickpay_v5_test.rb b/test/remote/gateways/remote_quickpay_v5_test.rb index 4b4c3795ad8..4d458e47a66 100644 --- a/test/remote/gateways/remote_quickpay_v5_test.rb +++ b/test/remote/gateways/remote_quickpay_v5_test.rb @@ -39,10 +39,10 @@ def test_successful_purchase_with_all_fraud_parameters @options[:fraud_http_referer] = 'http://www.excample.com' @options[:fraud_remote_addr] = '127.0.0.1' @options[:fraud_http_accept] = 'foo' - @options[:fraud_http_accept_language] = "DK" - @options[:fraud_http_accept_encoding] = "UFT8" - @options[:fraud_http_accept_charset] = "Latin" - @options[:fraud_http_user_agent] = "Safari" + @options[:fraud_http_accept_language] = 'DK' + @options[:fraud_http_accept_encoding] = 'UFT8' + @options[:fraud_http_accept_charset] = 'Latin' + @options[:fraud_http_user_agent] = 'Safari' assert response = @gateway.purchase(@amount, @visa, @options) assert_equal 'OK', response.message @@ -191,7 +191,7 @@ def test_successful_purchase_and_credit end def test_successful_store_and_reference_purchase - assert store = @gateway.store(@visa, @options.merge(:description => "New subscription")) + assert store = @gateway.store(@visa, @options.merge(:description => 'New subscription')) assert_success store assert purchase = @gateway.purchase(@amount, store.authorization, @options.merge(:order_id => generate_unique_id[0...10])) assert_success purchase diff --git a/test/remote/gateways/remote_quickpay_v6_test.rb b/test/remote/gateways/remote_quickpay_v6_test.rb index 817cdef9bdd..7e4d31cde22 100644 --- a/test/remote/gateways/remote_quickpay_v6_test.rb +++ b/test/remote/gateways/remote_quickpay_v6_test.rb @@ -39,10 +39,10 @@ def test_successful_purchase_with_all_fraud_parameters @options[:fraud_http_referer] = 'http://www.excample.com' @options[:fraud_remote_addr] = '127.0.0.1' @options[:fraud_http_accept] = 'foo' - @options[:fraud_http_accept_language] = "DK" - @options[:fraud_http_accept_encoding] = "UFT8" - @options[:fraud_http_accept_charset] = "Latin" - @options[:fraud_http_user_agent] = "Safari" + @options[:fraud_http_accept_language] = 'DK' + @options[:fraud_http_accept_encoding] = 'UFT8' + @options[:fraud_http_accept_charset] = 'Latin' + @options[:fraud_http_user_agent] = 'Safari' assert response = @gateway.purchase(@amount, @visa, @options) assert_equal 'OK', response.message @@ -191,7 +191,7 @@ def test_successful_purchase_and_credit end def test_successful_store_and_reference_purchase - assert store = @gateway.store(@visa, @options.merge(:description => "New subscription")) + assert store = @gateway.store(@visa, @options.merge(:description => 'New subscription')) assert_success store assert purchase = @gateway.purchase(@amount, store.authorization, @options.merge(:order_id => generate_unique_id[0...10])) assert_success purchase diff --git a/test/remote/gateways/remote_quickpay_v7_test.rb b/test/remote/gateways/remote_quickpay_v7_test.rb index 8af4cc14267..9edfc2189b2 100644 --- a/test/remote/gateways/remote_quickpay_v7_test.rb +++ b/test/remote/gateways/remote_quickpay_v7_test.rb @@ -39,10 +39,10 @@ def test_successful_purchase_with_all_fraud_parameters @options[:ip] = '127.0.0.1' # will set :fraud_remote_addr @options[:fraud_http_referer] = 'http://www.excample.com' @options[:fraud_http_accept] = 'foo' - @options[:fraud_http_accept_language] = "DK" - @options[:fraud_http_accept_encoding] = "UFT8" - @options[:fraud_http_accept_charset] = "Latin" - @options[:fraud_http_user_agent] = "Safari" + @options[:fraud_http_accept_language] = 'DK' + @options[:fraud_http_accept_encoding] = 'UFT8' + @options[:fraud_http_accept_charset] = 'Latin' + @options[:fraud_http_user_agent] = 'Safari' assert response = @gateway.purchase(@amount, @visa, @options) assert_equal 'OK', response.message @@ -60,13 +60,13 @@ def test_successful_usd_purchase end def test_successful_purchase_with_acquirers - assert response = @gateway.purchase(@amount, @visa, @options.update(:acquirers => "nets")) + assert response = @gateway.purchase(@amount, @visa, @options.update(:acquirers => 'nets')) assert_equal 'OK', response.message assert_success response end def test_unsuccessful_purchase_with_invalid_acquirers - assert response = @gateway.purchase(@amount, @visa, @options.update(:acquirers => "invalid")) + assert response = @gateway.purchase(@amount, @visa, @options.update(:acquirers => 'invalid')) assert_equal 'Error in field: acquirers', response.message assert_failure response end @@ -201,19 +201,19 @@ def test_successful_purchase_and_credit end def test_successful_store_and_reference_purchase - assert store = @gateway.store(@visa, @options.merge(:description => "New subscription")) + assert store = @gateway.store(@visa, @options.merge(:description => 'New subscription')) assert_success store assert purchase = @gateway.purchase(@amount, store.authorization, @options.merge(:order_id => generate_unique_id[0...10])) assert_success purchase end def test_successful_store_with_acquirers - assert store = @gateway.store(@visa, @options.merge(:description => "New subscription", :acquirers => "nets")) + assert store = @gateway.store(@visa, @options.merge(:description => 'New subscription', :acquirers => 'nets')) assert_success store end def test_successful_store_sans_description - assert store = @gateway.store(@visa, @options.merge(:acquirers => "nets")) + assert store = @gateway.store(@visa, @options.merge(:acquirers => 'nets')) assert_success store end diff --git a/test/remote/gateways/remote_qvalent_test.rb b/test/remote/gateways/remote_qvalent_test.rb index 875bc081ee8..9c21e25b889 100644 --- a/test/remote/gateways/remote_qvalent_test.rb +++ b/test/remote/gateways/remote_qvalent_test.rb @@ -1,28 +1,28 @@ -require "test_helper" +require 'test_helper' class RemoteQvalentTest < Test::Unit::TestCase def setup @gateway = QvalentGateway.new(fixtures(:qvalent)) @amount = 100 - @credit_card = credit_card("4000100011112224") - @declined_card = credit_card("4000000000000000") - @expired_card = credit_card("4111111113444494") + @credit_card = credit_card('4000100011112224') + @declined_card = credit_card('4000000000000000') + @expired_card = credit_card('4111111113444494') @options = { order_id: generate_unique_id, billing_address: address, - description: "Store Purchase" + description: 'Store Purchase' } end def test_invalid_login gateway = QvalentGateway.new( - username: "bad", - password: "bad", - merchant: "101", - pem: "bad", - pem_password: "bad" + username: 'bad', + password: 'bad', + merchant: '101', + pem: 'bad', + pem_password: 'bad' ) assert_raise ActiveMerchant::ClientCertificateError do @@ -33,65 +33,65 @@ def test_invalid_login def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_purchase_with_soft_descriptors options = { order_id: generate_unique_id, billing_address: address, - description: "Store Purchase", - customer_merchant_name: "Some Merchant", - customer_merchant_street_address: "42 Wallaby Way", - customer_merchant_location: "Sydney", - customer_merchant_country: "AU", - customer_merchant_post_code: "2060", - customer_merchant_state: "NSW" + description: 'Store Purchase', + customer_merchant_name: 'Some Merchant', + customer_merchant_street_address: '42 Wallaby Way', + customer_merchant_location: 'Sydney', + customer_merchant_country: 'AU', + customer_merchant_post_code: '2060', + customer_merchant_state: 'NSW' } response = @gateway.purchase(@amount, @credit_card, options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_purchase_with_3d_secure options = { order_id: generate_unique_id, billing_address: address, - description: "Store Purchase", - xid: "123", - cavv: "456", - eci: "5" + description: 'Store Purchase', + xid: '123', + cavv: '456', + eci: '5' } response = @gateway.purchase(@amount, @credit_card, options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "Invalid card number (no such number)", response.message + assert_equal 'Invalid card number (no such number)', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code end def test_successful_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal "Invalid card number (no such number)", response.message + assert_equal 'Invalid card number (no such number)', response.message end def test_successful_capture assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert_equal "Succeeded", auth.message + assert_equal 'Succeeded', auth.message assert_not_nil auth.authorization assert capture = @gateway.capture(@amount, auth.authorization, @options.merge({ order_id: generate_unique_id })) @@ -101,7 +101,7 @@ def test_successful_capture def test_failed_capture assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert_equal "Succeeded", auth.message + assert_equal 'Succeeded', auth.message assert_not_nil auth.authorization assert capture = @gateway.capture(@amount, '', @options.merge({ order_id: generate_unique_id })) @@ -111,7 +111,7 @@ def test_failed_capture def test_successful_partial_capture assert auth = @gateway.authorize(200, @credit_card, @options) assert_success auth - assert_equal "Succeeded", auth.message + assert_equal 'Succeeded', auth.message assert_not_nil auth.authorization assert capture = @gateway.capture(100, auth.authorization, @options.merge({ order_id: generate_unique_id })) @@ -121,7 +121,7 @@ def test_successful_partial_capture def test_successful_void assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert_equal "Succeeded", auth.message + assert_equal 'Succeeded', auth.message assert_not_nil auth.authorization assert void = @gateway.void(auth.authorization, @options.merge({ order_id: generate_unique_id })) @@ -131,7 +131,7 @@ def test_successful_void def test_failed_void assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert_equal "Succeeded", auth.message + assert_equal 'Succeeded', auth.message assert_not_nil auth.authorization assert void = @gateway.void('', @options.merge({ order_id: generate_unique_id })) @@ -144,11 +144,11 @@ def test_successful_refund assert refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "Succeeded", refund.message + assert_equal 'Succeeded', refund.message end def test_failed_refund - response = @gateway.refund(nil, "") + response = @gateway.refund(nil, '') assert_failure response assert_match %r{Invalid card number}, response.message assert_equal Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code @@ -157,25 +157,25 @@ def test_failed_refund def test_successful_credit response = @gateway.credit(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_credit response = @gateway.credit(@amount, @declined_card, @options) assert_failure response - assert_equal "Invalid card number (no such number)", response.message + assert_equal 'Invalid card number (no such number)', response.message end def test_successful_store response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_store response = @gateway.store(@declined_card, @options) assert_failure response - assert_equal "Invalid card number (no such number)", response.message + assert_equal 'Invalid card number (no such number)', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code end diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb index 3efc19866f5..0e9c466fbc3 100644 --- a/test/remote/gateways/remote_realex_test.rb +++ b/test/remote/gateways/remote_realex_test.rb @@ -19,14 +19,14 @@ def setup @mastercard_coms_error = card_fixtures(:realex_mastercard_coms_error) @apple_pay = credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', verification_value: nil, eci: '05', source: :apple_pay ) @declined_apple_pay = credit_card = network_tokenization_credit_card('4000120000001154', - payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', verification_value: nil, eci: '05', source: :apple_pay @@ -53,7 +53,7 @@ def test_realex_purchase assert_success response assert response.test? assert response.authorization.length > 0 - assert_equal "Successful", response.message + assert_equal 'Successful', response.message end end @@ -190,12 +190,12 @@ def test_realex_expiry_year_error assert_failure response assert_equal '509', response.params['result'] - assert_equal "Expiry date invalid", response.message + assert_equal 'Expiry date invalid', response.message end def test_invalid_credit_card_name - @visa.first_name = "" - @visa.last_name = "" + @visa.first_name = '' + @visa.last_name = '' response = @gateway.purchase(@amount, @visa, :order_id => generate_unique_id, @@ -210,7 +210,7 @@ def test_invalid_credit_card_name def test_cvn @visa_cvn = @visa.clone - @visa_cvn.verification_value = "111" + @visa_cvn.verification_value = '111' response = @gateway.purchase(@amount, @visa_cvn, :order_id => generate_unique_id, :description => 'test_cvn' @@ -349,8 +349,8 @@ def test_maps_avs_and_cvv_response_codes ) assert_not_nil response assert_success response - assert_equal "M", response.avs_result["code"] - assert_equal "M", response.cvv_result["code"] + assert_equal 'M', response.avs_result['code'] + assert_equal 'M', response.cvv_result['code'] end end diff --git a/test/remote/gateways/remote_redsys_sha256_test.rb b/test/remote/gateways/remote_redsys_sha256_test.rb index 93e94cb7dce..28e95aad071 100644 --- a/test/remote/gateways/remote_redsys_sha256_test.rb +++ b/test/remote/gateways/remote_redsys_sha256_test.rb @@ -13,33 +13,33 @@ def setup def test_successful_purchase response = @gateway.purchase(100, @credit_card, @options) assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message end def test_purchase_with_invalid_order_id response = @gateway.purchase(100, @credit_card, order_id: "a%4#{generate_order_id}") assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message end def test_successful_purchase_using_vault_id response = @gateway.purchase(100, @credit_card, @options.merge(store: true)) assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message - credit_card_token = response.params["ds_merchant_identifier"] + credit_card_token = response.params['ds_merchant_identifier'] assert_not_nil credit_card_token @options[:order_id] = generate_order_id response = @gateway.purchase(100, credit_card_token, @options) assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message end def test_failed_purchase response = @gateway.purchase(100, @declined_card, @options) assert_failure response - assert_equal "SIS0093 ERROR", response.message + assert_equal 'SIS0093 ERROR', response.message end def test_purchase_and_refund @@ -53,13 +53,13 @@ def test_purchase_and_refund def test_purchase_and_refund_with_currency response = @gateway.purchase(600, @credit_card, @options.merge(:currency => 'PEN')) assert_failure response - assert_equal "SIS0027 ERROR", response.message + assert_equal 'SIS0027 ERROR', response.message end def test_successful_authorise_and_capture authorize = @gateway.authorize(100, @credit_card, @options) assert_success authorize - assert_equal "Transaction Approved", authorize.message + assert_equal 'Transaction Approved', authorize.message assert_not_nil authorize.authorization capture = @gateway.capture(100, authorize.authorization) @@ -70,23 +70,23 @@ def test_successful_authorise_and_capture def test_successful_authorise_using_vault_id authorize = @gateway.authorize(100, @credit_card, @options.merge(store: true)) assert_success authorize - assert_equal "Transaction Approved", authorize.message + assert_equal 'Transaction Approved', authorize.message assert_not_nil authorize.authorization - credit_card_token = authorize.params["ds_merchant_identifier"] + credit_card_token = authorize.params['ds_merchant_identifier'] assert_not_nil credit_card_token @options[:order_id] = generate_order_id authorize = @gateway.authorize(100, credit_card_token, @options) assert_success authorize - assert_equal "Transaction Approved", authorize.message + assert_equal 'Transaction Approved', authorize.message assert_not_nil authorize.authorization end def test_failed_authorize response = @gateway.authorize(100, @declined_card, @options) assert_failure response - assert_equal "SIS0093 ERROR", response.message + assert_equal 'SIS0093 ERROR', response.message end def test_successful_void @@ -95,8 +95,8 @@ def test_successful_void void = @gateway.void(authorize.authorization) assert_success void - assert_equal "100", void.params["ds_amount"] - assert_equal "Cancellation Accepted", void.message + assert_equal '100', void.params['ds_amount'] + assert_equal 'Cancellation Accepted', void.message end def test_failed_void @@ -108,22 +108,22 @@ def test_failed_void another_void = @gateway.void(authorize.authorization) assert_failure another_void - assert_equal "SIS0222 ERROR", another_void.message + assert_equal 'SIS0222 ERROR', another_void.message end def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Transaction Approved", response.message - assert_success response.responses.last, "The void should succeed" - assert_equal "Cancellation Accepted", response.responses.last.message + assert_equal 'Transaction Approved', response.message + assert_success response.responses.last, 'The void should succeed' + assert_equal 'Cancellation Accepted', response.responses.last.message end def test_unsuccessful_verify assert response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "SIS0093 ERROR", response.message + assert_equal 'SIS0093 ERROR', response.message end def test_transcript_scrubbing @@ -155,27 +155,27 @@ def test_nil_cvv_transcript_scrubbing end clean_transcript = @gateway.scrub(transcript) - assert_equal clean_transcript.include?("[BLANK]"), true + assert_equal clean_transcript.include?('[BLANK]'), true end def test_empty_string_cvv_transcript_scrubbing - @credit_card.verification_value = "" + @credit_card.verification_value = '' transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) end clean_transcript = @gateway.scrub(transcript) - assert_equal clean_transcript.include?("[BLANK]"), true + assert_equal clean_transcript.include?('[BLANK]'), true end def test_whitespace_string_cvv_transcript_scrubbing - @credit_card.verification_value = " " + @credit_card.verification_value = ' ' transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) end clean_transcript = @gateway.scrub(transcript) - assert_equal clean_transcript.include?("[BLANK]"), true + assert_equal clean_transcript.include?('[BLANK]'), true end private diff --git a/test/remote/gateways/remote_redsys_test.rb b/test/remote/gateways/remote_redsys_test.rb index d05e234ae6a..5cc9ae08273 100644 --- a/test/remote/gateways/remote_redsys_test.rb +++ b/test/remote/gateways/remote_redsys_test.rb @@ -15,33 +15,33 @@ def setup def test_successful_purchase response = @gateway.purchase(100, @credit_card, @options) assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message end def test_purchase_with_invalid_order_id response = @gateway.purchase(100, @credit_card, order_id: "a%4#{generate_order_id}") assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message end def test_successful_purchase_using_vault_id response = @gateway.purchase(100, @credit_card, @options.merge(store: true)) assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message - credit_card_token = response.params["ds_merchant_identifier"] + credit_card_token = response.params['ds_merchant_identifier'] assert_not_nil credit_card_token @options[:order_id] = generate_order_id response = @gateway.purchase(100, credit_card_token, @options) assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message end def test_failed_purchase response = @gateway.purchase(100, @declined_card, @options) assert_failure response - assert_equal "SIS0093 ERROR", response.message + assert_equal 'SIS0093 ERROR', response.message end def test_purchase_and_refund @@ -55,13 +55,13 @@ def test_purchase_and_refund def test_purchase_and_refund_with_currency response = @gateway.purchase(600, @credit_card, @options.merge(:currency => 'PEN')) assert_failure response - assert_equal "SIS0027 ERROR", response.message + assert_equal 'SIS0027 ERROR', response.message end def test_successful_authorise_and_capture authorize = @gateway.authorize(100, @credit_card, @options) assert_success authorize - assert_equal "Transaction Approved", authorize.message + assert_equal 'Transaction Approved', authorize.message assert_not_nil authorize.authorization capture = @gateway.capture(100, authorize.authorization) @@ -72,23 +72,23 @@ def test_successful_authorise_and_capture def test_successful_authorise_using_vault_id authorize = @gateway.authorize(100, @credit_card, @options.merge(store: true)) assert_success authorize - assert_equal "Transaction Approved", authorize.message + assert_equal 'Transaction Approved', authorize.message assert_not_nil authorize.authorization - credit_card_token = authorize.params["ds_merchant_identifier"] + credit_card_token = authorize.params['ds_merchant_identifier'] assert_not_nil credit_card_token @options[:order_id] = generate_order_id authorize = @gateway.authorize(100, credit_card_token, @options) assert_success authorize - assert_equal "Transaction Approved", authorize.message + assert_equal 'Transaction Approved', authorize.message assert_not_nil authorize.authorization end def test_failed_authorize response = @gateway.authorize(100, @declined_card, @options) assert_failure response - assert_equal "SIS0093 ERROR", response.message + assert_equal 'SIS0093 ERROR', response.message end def test_successful_void @@ -97,8 +97,8 @@ def test_successful_void void = @gateway.void(authorize.authorization) assert_success void - assert_equal "100", void.params["ds_amount"] - assert_equal "Cancellation Accepted", void.message + assert_equal '100', void.params['ds_amount'] + assert_equal 'Cancellation Accepted', void.message end def test_failed_void @@ -110,22 +110,22 @@ def test_failed_void another_void = @gateway.void(authorize.authorization) assert_failure another_void - assert_equal "SIS0222 ERROR", another_void.message + assert_equal 'SIS0222 ERROR', another_void.message end def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Transaction Approved", response.message - assert_success response.responses.last, "The void should succeed" - assert_equal "Cancellation Accepted", response.responses.last.message + assert_equal 'Transaction Approved', response.message + assert_success response.responses.last, 'The void should succeed' + assert_equal 'Cancellation Accepted', response.responses.last.message end def test_unsuccessful_verify assert response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "SIS0093 ERROR", response.message + assert_equal 'SIS0093 ERROR', response.message end def test_transcript_scrubbing @@ -157,27 +157,27 @@ def test_nil_cvv_transcript_scrubbing end clean_transcript = @gateway.scrub(transcript) - assert_equal clean_transcript.include?("[BLANK]"), true + assert_equal clean_transcript.include?('[BLANK]'), true end def test_empty_string_cvv_transcript_scrubbing - @credit_card.verification_value = "" + @credit_card.verification_value = '' transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) end clean_transcript = @gateway.scrub(transcript) - assert_equal clean_transcript.include?("[BLANK]"), true + assert_equal clean_transcript.include?('[BLANK]'), true end def test_whitespace_string_cvv_transcript_scrubbing - @credit_card.verification_value = " " + @credit_card.verification_value = ' ' transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) end clean_transcript = @gateway.scrub(transcript) - assert_equal clean_transcript.include?("[BLANK]"), true + assert_equal clean_transcript.include?('[BLANK]'), true end private diff --git a/test/remote/gateways/remote_s5_test.rb b/test/remote/gateways/remote_s5_test.rb index 8ecb3dfa530..1c9f31bf0ab 100644 --- a/test/remote/gateways/remote_s5_test.rb +++ b/test/remote/gateways/remote_s5_test.rb @@ -54,7 +54,7 @@ def test_successful_purchase_without_address end def test_failed_purchase - @options[:memo] = "800.100.151" + @options[:memo] = '800.100.151' response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response assert_equal 'transaction declined (invalid card)', response.message @@ -81,7 +81,7 @@ def test_successful_authorize_and_capture end def test_failed_authorize - @options[:memo] = "100.400.080" + @options[:memo] = '100.400.080' response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response end @@ -140,7 +140,7 @@ def test_successful_verify end def test_failed_verify - @options[:memo] = "100.400.080" + @options[:memo] = '100.400.080' response = @gateway.verify(@declined_card, @options) assert_failure response assert_match %r{authorization failure}, response.message diff --git a/test/remote/gateways/remote_safe_charge_test.rb b/test/remote/gateways/remote_safe_charge_test.rb index 221f8ab13b7..fc64bacb1c1 100644 --- a/test/remote/gateways/remote_safe_charge_test.rb +++ b/test/remote/gateways/remote_safe_charge_test.rb @@ -11,7 +11,7 @@ def setup order_id: generate_unique_id, billing_address: address, description: 'Store Purchase', - currency: "EUR" + currency: 'EUR' } @three_ds_options = @options.merge(three_d_secure: true) @@ -24,29 +24,29 @@ def setup def test_successful_3ds_purchase response = @three_ds_gateway.purchase(@amount, @three_ds_enrolled_card, @three_ds_options) assert_success response - assert !response.params["acsurl"].blank? - assert !response.params["pareq"].blank? - assert !response.params["xid"].blank? + assert !response.params['acsurl'].blank? + assert !response.params['pareq'].blank? + assert !response.params['xid'].blank? assert_equal 'Success', response.message end def test_successful_regular_purchase_through_3ds_flow_with_non_enrolled_card response = @three_ds_gateway.purchase(@amount, @three_ds_non_enrolled_card, @three_ds_options) assert_success response - assert response.params["acsurl"].blank? - assert response.params["pareq"].blank? - assert response.params["xid"].blank? - assert response.params["threedflow"] = 1 + assert response.params['acsurl'].blank? + assert response.params['pareq'].blank? + assert response.params['xid'].blank? + assert response.params['threedflow'] = 1 assert_equal 'Success', response.message end def test_successful_regular_purchase_through_3ds_flow_with_invalid_pa_res response = @three_ds_gateway.purchase(@amount, @three_ds_invalid_pa_res_card, @three_ds_options) assert_success response - assert !response.params["acsurl"].blank? - assert !response.params["pareq"].blank? - assert !response.params["xid"].blank? - assert response.params["threedflow"] = 1 + assert !response.params['acsurl'].blank? + assert !response.params['pareq'].blank? + assert !response.params['xid'].blank? + assert response.params['threedflow'] = 1 assert_equal 'Success', response.message end @@ -59,8 +59,8 @@ def test_successful_purchase def test_successful_purchase_with_more_options options = { order_id: '1', - ip: "127.0.0.1", - email: "joe@example.com", + ip: '127.0.0.1', + email: 'joe@example.com', user_id: '123', auth_type: '2', expected_fulfillment_count: '3', @@ -93,8 +93,8 @@ def test_successful_authorize_and_capture def test_successful_authorize_and_capture_with_more_options extra = { order_id: '1', - ip: "127.0.0.1", - email: "joe@example.com", + ip: '127.0.0.1', + email: 'joe@example.com', user_id: '123', auth_type: '2', expected_fulfillment_count: '3', @@ -163,8 +163,8 @@ def test_successful_credit def test_successful_credit_with_extra_options extra = { order_id: '1', - ip: "127.0.0.1", - email: "joe@example.com", + ip: '127.0.0.1', + email: 'joe@example.com', user_id: '123', auth_type: '2', expected_fulfillment_count: '3', diff --git a/test/remote/gateways/remote_sage_pay_test.rb b/test/remote/gateways/remote_sage_pay_test.rb index 7826d0074e4..d4450ecda49 100644 --- a/test/remote/gateways/remote_sage_pay_test.rb +++ b/test/remote/gateways/remote_sage_pay_test.rb @@ -78,7 +78,7 @@ def setup :name => 'Tekin Suleyman', :address1 => 'Flat 10 Lapwing Court', :address2 => 'West Didsbury', - :city => "Manchester", + :city => 'Manchester', :county => 'Greater Manchester', :country => 'GB', :zip => 'M20 2PS' @@ -86,7 +86,7 @@ def setup :shipping_address => { :name => 'Tekin Suleyman', :address1 => '120 Grosvenor St', - :city => "Manchester", + :city => 'Manchester', :county => 'Greater Manchester', :country => 'GB', :zip => 'M1 7QW' @@ -189,15 +189,15 @@ def test_successful_electron_purchase def test_successful_purchase_with_overly_long_fields options = { - description: "SagePay transactions fail if the description is more than 100 characters. Therefore, we truncate it to 100 characters.", + description: 'SagePay transactions fail if the description is more than 100 characters. Therefore, we truncate it to 100 characters.', order_id: "#{generate_unique_id} SagePay order_id cannot be more than 40 characters.", billing_address: { name: 'FirstNameCannotBeMoreThanTwentyChars SurnameCannotBeMoreThanTwenty', address1: 'The Billing Address 1 Cannot Be More Than One Hundred Characters if it is it will fail. Therefore, we truncate it.', address2: 'The Billing Address 2 Cannot Be More Than One Hundred Characters if it is it will fail. Therefore, we truncate it.', - phone: "111222333444555666777888999", - city: "TheCityCannotBeMoreThanFortyCharactersReally", - state: "NCStateIsTwoChars", + phone: '111222333444555666777888999', + city: 'TheCityCannotBeMoreThanFortyCharactersReally', + state: 'NCStateIsTwoChars', country: 'USMustBeTwoChars', zip: 'PostalCodeCannotExceedTenChars' }, @@ -205,16 +205,16 @@ def test_successful_purchase_with_overly_long_fields name: 'FirstNameCannotBeMoreThanTwentyChars SurnameCannotBeMoreThanTwenty', address1: 'The Shipping Address 1 Cannot Be More Than One Hundred Characters if it is it will fail. Therefore, we truncate it.', address2: 'The Shipping Address 2 Cannot Be More Than One Hundred Characters if it is it will fail. Therefore, we truncate it.', - phone: "111222333444555666777888999", - city: "TheCityCannotBeMoreThanFortyCharactersReally", - state: "NCStateIsTwoChars", + phone: '111222333444555666777888999', + city: 'TheCityCannotBeMoreThanFortyCharactersReally', + state: 'NCStateIsTwoChars', country: 'USMustBeTwoChars', zip: 'PostalCodeCannotExceedTenChars' } } - @visa.first_name = "FullNameOnACardMustBeLessThanFiftyCharacters" - @visa.last_name = "OtherwiseSagePayFailsIt" + @visa.first_name = 'FullNameOnACardMustBeLessThanFiftyCharacters' + @visa.last_name = 'OtherwiseSagePayFailsIt' assert response = @gateway.purchase(@amount, @visa, options) assert_success response @@ -236,7 +236,7 @@ def test_successful_purchase_with_apply_avscv2_field @options[:apply_avscv2] = 1 response = @gateway.purchase(@amount, @visa, @options) assert_success response - assert_equal "Y", response.cvv_result['code'] + assert_equal 'Y', response.cvv_result['code'] end def test_successful_purchase_with_pay_pal_callback_url @@ -386,7 +386,7 @@ def test_successful_unstore def test_successful_verify response = @gateway.verify(@visa, @options) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message end def test_failed_verify diff --git a/test/remote/gateways/remote_sage_test.rb b/test/remote/gateways/remote_sage_test.rb index f68f0767829..fbab6a0417a 100644 --- a/test/remote/gateways/remote_sage_test.rb +++ b/test/remote/gateways/remote_sage_test.rb @@ -7,11 +7,11 @@ def setup @amount = 100 - @visa = credit_card("4111111111111111") + @visa = credit_card('4111111111111111') @check = check - @mastercard = credit_card("5499740000000057") - @discover = credit_card("6011000993026909") - @amex = credit_card("371449635392376") + @mastercard = credit_card('5499740000000057') + @discover = credit_card('6011000993026909') + @amex = credit_card('371449635392376') @declined_card = credit_card('4000') @@ -81,7 +81,7 @@ def test_successful_with_minimal_options end def test_successful_purchase_with_blank_state - assert response = @gateway.purchase(@amount, @visa, billing_address: address(state: "")) + assert response = @gateway.purchase(@amount, @visa, billing_address: address(state: '')) assert_success response assert response.test? assert_false response.authorization.blank? @@ -141,16 +141,16 @@ def test_visa_refund assert refund = @gateway.refund(@amount, purchase.authorization, @options) assert_success refund - assert_equal "APPROVED", refund.message + assert_equal 'APPROVED', refund.message end def test_visa_failed_refund purchase = @gateway.purchase(@amount, @visa, @options) assert_success purchase - response = @gateway.refund(@amount, "UnknownReference", @options) + response = @gateway.refund(@amount, 'UnknownReference', @options) assert_failure response - assert_equal "INVALID T_REFERENCE", response.message + assert_equal 'INVALID T_REFERENCE', response.message end def test_partial_refund @@ -159,14 +159,14 @@ def test_partial_refund assert refund = @gateway.refund(@amount-1, purchase.authorization, @options) assert_success refund - assert_equal "APPROVED", refund.message + assert_equal 'APPROVED', refund.message end def test_store_visa assert response = @gateway.store(@visa, @options) assert_success response assert auth = response.authorization, - "Store card authorization should not be nil" + 'Store card authorization should not be nil' assert_not_nil response.message end @@ -178,14 +178,14 @@ def test_failed_store def test_unstore_visa assert auth = @gateway.store(@visa, @options).authorization, - "Unstore card authorization should not be nil" + 'Unstore card authorization should not be nil' assert response = @gateway.unstore(auth, @options) assert_success response end def test_failed_unstore_visa assert auth = @gateway.store(@visa, @options).authorization, - "Unstore card authorization should not be nil" + 'Unstore card authorization should not be nil' assert response = @gateway.unstore(auth, @options) assert_success response end diff --git a/test/remote/gateways/remote_secure_net_test.rb b/test/remote/gateways/remote_secure_net_test.rb index 784c7d42d4d..fc92a5276e1 100644 --- a/test/remote/gateways/remote_secure_net_test.rb +++ b/test/remote/gateways/remote_secure_net_test.rb @@ -97,7 +97,7 @@ def test_unsuccessful_capture def test_unsuccessful_purchase assert response = @gateway.purchase(@amount, @bad_card_number, @options) assert_failure response - assert_equal "CARD TYPE COULD NOT BE IDENTIFIED", response.message + assert_equal 'CARD TYPE COULD NOT BE IDENTIFIED', response.message end def test_unsuccessful_purchase_and_credit @@ -113,8 +113,8 @@ def test_unsuccessful_purchase_and_credit def test_invoice_description_and_number options = @options.merge({ - invoice_description: "TheInvoiceDescriptions", - invoice_number: "TheInvoiceNumber" + invoice_description: 'TheInvoiceDescriptions', + invoice_number: 'TheInvoiceNumber' }) assert auth = @gateway.authorize(@amount, @credit_card, options) diff --git a/test/remote/gateways/remote_secure_pay_au_test.rb b/test/remote/gateways/remote_secure_pay_au_test.rb index 5f340c19f7c..56958b29afd 100644 --- a/test/remote/gateways/remote_secure_pay_au_test.rb +++ b/test/remote/gateways/remote_secure_pay_au_test.rb @@ -181,7 +181,7 @@ def test_invalid_login ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Invalid merchant ID", response.message + assert_equal 'Invalid merchant ID', response.message end def test_purchase_scrubbing diff --git a/test/remote/gateways/remote_securion_pay_test.rb b/test/remote/gateways/remote_securion_pay_test.rb index 7cae9189157..d6b66c7ad0b 100644 --- a/test/remote/gateways/remote_securion_pay_test.rb +++ b/test/remote/gateways/remote_securion_pay_test.rb @@ -24,23 +24,23 @@ def test_successful_store response = @gateway.store(@credit_card, @options) assert_success response assert_match %r(^cust_\w+$), response.authorization - assert_equal "customer", response.params["objectType"] - assert_match %r(^card_\w+$), response.params["cards"][0]["id"] - assert_equal "card", response.params["cards"][0]["objectType"] + assert_equal 'customer', response.params['objectType'] + assert_match %r(^card_\w+$), response.params['cards'][0]['id'] + assert_equal 'card', response.params['cards'][0]['objectType'] @options[:customer_id] = response.authorization response = @gateway.store(@new_credit_card, @options) assert_success response - assert_match %r(^card_\w+$), response.params["card"]["id"] - assert_equal @options[:customer_id], response.params["card"]["customerId"] + assert_match %r(^card_\w+$), response.params['card']['id'] + assert_equal @options[:customer_id], response.params['card']['customerId'] response = @gateway.customer(@options) assert_success response - assert_equal @options[:customer_id], response.params["id"] - assert_equal "401288", response.params["cards"][0]["first6"] - assert_equal "1881", response.params["cards"][0]["last4"] - assert_equal "424242", response.params["cards"][1]["first6"] - assert_equal "4242", response.params["cards"][1]["last4"] + assert_equal @options[:customer_id], response.params['id'] + assert_equal '401288', response.params['cards'][0]['first6'] + assert_equal '1881', response.params['cards'][0]['last4'] + assert_equal '424242', response.params['cards'][1]['first6'] + assert_equal '4242', response.params['cards'][1]['last4'] end # def test_dump_transcript @@ -61,8 +61,8 @@ def test_transcript_scrubbing def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Transaction approved", response.message - assert_equal "foo@example.com", response.params["metadata"]["email"] + assert_equal 'Transaction approved', response.message + assert_equal 'foo@example.com', response.params['metadata']['email'] assert_match CHARGE_ID_REGEX, response.authorization end @@ -76,9 +76,9 @@ def test_unsuccessful_purchase def test_authorization_and_capture authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization - assert !authorization.params["captured"] - assert_equal @options[:description], authorization.params["description"] - assert_equal @options[:email], authorization.params["metadata"]["email"] + assert !authorization.params['captured'] + assert_equal @options[:description], authorization.params['description'] + assert_equal @options[:email], authorization.params['metadata']['email'] response = @gateway.capture(@amount, authorization.authorization) assert_success response @@ -103,10 +103,10 @@ def test_successful_full_refund refund = @gateway.refund(@amount, purchase.authorization) assert_success refund - assert refund.params["refunded"] - assert_equal 0, refund.params["amount"] - assert_equal 1, refund.params["refunds"].size - assert_equal @amount, refund.params["refunds"].map{|r| r["amount"]}.sum + assert refund.params['refunded'] + assert_equal 0, refund.params['amount'] + assert_equal 1, refund.params['refunds'].size + assert_equal @amount, refund.params['refunds'].map{|r| r['amount']}.sum assert refund.authorization end @@ -121,10 +121,10 @@ def test_successful_partially_refund second_refund = @gateway.refund(@refund_amount, purchase.authorization) assert_success second_refund - assert second_refund.params["refunded"] - assert_equal @amount - 2 * @refund_amount, second_refund.params["amount"] - assert_equal 2, second_refund.params["refunds"].size - assert_equal 2 * @refund_amount, second_refund.params["refunds"].map{|r| r["amount"]}.sum + assert second_refund.params['refunded'] + assert_equal @amount - 2 * @refund_amount, second_refund.params['amount'] + assert_equal 2, second_refund.params['refunds'].size + assert_equal 2 * @refund_amount, second_refund.params['refunds'].map{|r| r['amount']}.sum assert second_refund.authorization end @@ -147,14 +147,14 @@ def test_unsuccessful_refund def test_successful_void authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization - assert !authorization.params["captured"] + assert !authorization.params['captured'] void = @gateway.void(authorization.authorization, @options) assert_success void - assert void.params["refunded"] - assert_equal 0, void.params["amount"] - assert_equal 1, void.params["refunds"].size - assert_equal @amount, void.params["refunds"].map{|r| r["amount"]}.sum + assert void.params['refunded'] + assert_equal 0, void.params['amount'] + assert_equal 1, void.params['refunds'].size + assert_equal @amount, void.params['refunds'].map{|r| r['amount']}.sum assert void.authorization end @@ -188,7 +188,7 @@ def test_invalid_login gateway = SecurionPayGateway.new(secret_key: 'active_merchant_test') response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_match "Provided API key is invalid", response.message + assert_match 'Provided API key is invalid', response.message end def test_invalid_number_for_purchase diff --git a/test/remote/gateways/remote_skipjack_test.rb b/test/remote/gateways/remote_skipjack_test.rb index 9c339063b54..2c8d070dcbf 100644 --- a/test/remote/gateways/remote_skipjack_test.rb +++ b/test/remote/gateways/remote_skipjack_test.rb @@ -61,7 +61,7 @@ def test_successful_authorization_and_partial_capture capture = @gateway.capture(1000, authorization.authorization) assert_success capture - assert_equal "1000", capture.params["TransactionAmount"] + assert_equal '1000', capture.params['TransactionAmount'] end def test_authorization_and_void diff --git a/test/remote/gateways/remote_stripe_android_pay_test.rb b/test/remote/gateways/remote_stripe_android_pay_test.rb index 3061f01997e..10631d08d2c 100644 --- a/test/remote/gateways/remote_stripe_android_pay_test.rb +++ b/test/remote/gateways/remote_stripe_android_pay_test.rb @@ -8,7 +8,7 @@ def setup @amount = 100 @options = { - :currency => "USD", + :currency => 'USD', :description => 'ActiveMerchant Test Purchase', :email => 'wow@example.com' } @@ -16,33 +16,33 @@ def setup def test_successful_purchase_with_android_pay_raw_cryptogram credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', verification_value: nil, eci: '05', source: :android_pay ) assert response = @gateway.purchase(@amount, credit_card, @options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] - assert_equal "ActiveMerchant Test Purchase", response.params["description"] - assert_equal "wow@example.com", response.params["metadata"]["email"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] + assert_equal 'ActiveMerchant Test Purchase', response.params['description'] + assert_equal 'wow@example.com', response.params['metadata']['email'] assert_match CHARGE_ID_REGEX, response.authorization end def test_successful_auth_with_android_pay_raw_cryptogram credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', verification_value: nil, eci: '05', source: :android_pay ) assert response = @gateway.authorize(@amount, credit_card, @options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] - assert_equal "ActiveMerchant Test Purchase", response.params["description"] - assert_equal "wow@example.com", response.params["metadata"]["email"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] + assert_equal 'ActiveMerchant Test Purchase', response.params['description'] + assert_equal 'wow@example.com', response.params['metadata']['email'] assert_match CHARGE_ID_REGEX, response.authorization end end \ No newline at end of file diff --git a/test/remote/gateways/remote_stripe_apple_pay_test.rb b/test/remote/gateways/remote_stripe_apple_pay_test.rb index 821b36ee6fc..d7d966ddb45 100644 --- a/test/remote/gateways/remote_stripe_apple_pay_test.rb +++ b/test/remote/gateways/remote_stripe_apple_pay_test.rb @@ -8,7 +8,7 @@ def setup @amount = 100 @options = { - :currency => "USD", + :currency => 'USD', :description => 'ActiveMerchant Test Purchase', :email => 'wow@example.com' } @@ -18,19 +18,19 @@ def setup def test_successful_purchase_with_apple_pay_payment_token assert response = @gateway.purchase(@amount, @apple_pay_payment_token, @options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] - assert_equal "ActiveMerchant Test Purchase", response.params["description"] - assert_equal "wow@example.com", response.params["metadata"]["email"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] + assert_equal 'ActiveMerchant Test Purchase', response.params['description'] + assert_equal 'wow@example.com', response.params['metadata']['email'] assert_match CHARGE_ID_REGEX, response.authorization end def test_authorization_and_capture_with_apple_pay_payment_token assert authorization = @gateway.authorize(@amount, @apple_pay_payment_token, @options) assert_success authorization - refute authorization.params["captured"] - assert_equal "ActiveMerchant Test Purchase", authorization.params["description"] - assert_equal "wow@example.com", authorization.params["metadata"]["email"] + refute authorization.params['captured'] + assert_equal 'ActiveMerchant Test Purchase', authorization.params['description'] + assert_equal 'wow@example.com', authorization.params['metadata']['email'] assert capture = @gateway.capture(@amount, authorization.authorization) assert_success capture @@ -39,7 +39,7 @@ def test_authorization_and_capture_with_apple_pay_payment_token def test_authorization_and_void_with_apple_pay_payment_token assert authorization = @gateway.authorize(@amount, @apple_pay_payment_token, @options) assert_success authorization - refute authorization.params["captured"] + refute authorization.params['captured'] assert void = @gateway.void(authorization.authorization) assert_success void @@ -54,45 +54,45 @@ def test_successful_void_with_apple_pay_payment_token end def test_successful_store_with_apple_pay_payment_token - assert response = @gateway.store(@apple_pay_payment_token, {:description => "Active Merchant Test Customer", :email => "email@example.com"}) + assert response = @gateway.store(@apple_pay_payment_token, {:description => 'Active Merchant Test Customer', :email => 'email@example.com'}) assert_success response - assert_equal "customer", response.params["object"] - assert_equal "Active Merchant Test Customer", response.params["description"] - assert_equal "email@example.com", response.params["email"] - first_card = response.params["cards"]["data"].first - assert_equal response.params["default_card"], first_card["id"] - assert_equal "4242", first_card["dynamic_last4"] # when stripe is in test mode, token exchanged will return a test card with dynamic_last4 4242 - assert_equal "0000", first_card["last4"] # last4 is 0000 when using an apple pay token + assert_equal 'customer', response.params['object'] + assert_equal 'Active Merchant Test Customer', response.params['description'] + assert_equal 'email@example.com', response.params['email'] + first_card = response.params['cards']['data'].first + assert_equal response.params['default_card'], first_card['id'] + assert_equal '4242', first_card['dynamic_last4'] # when stripe is in test mode, token exchanged will return a test card with dynamic_last4 4242 + assert_equal '0000', first_card['last4'] # last4 is 0000 when using an apple pay token end def test_successful_store_with_existing_customer_and_apple_pay_payment_token - assert response = @gateway.store(@credit_card, {:description => "Active Merchant Test Customer"}) + assert response = @gateway.store(@credit_card, {:description => 'Active Merchant Test Customer'}) assert_success response - assert response = @gateway.store(@apple_pay_payment_token, {:customer => response.params['id'], :description => "Active Merchant Test Customer", :email => "email@example.com"}) + assert response = @gateway.store(@apple_pay_payment_token, {:customer => response.params['id'], :description => 'Active Merchant Test Customer', :email => 'email@example.com'}) assert_success response assert_equal 2, response.responses.size card_response = response.responses[0] - assert_equal "card", card_response.params["object"] - assert_equal "4242", card_response.params["dynamic_last4"] # when stripe is in test mode, token exchanged will return a test card with dynamic_last4 4242 - assert_equal "0000", card_response.params["last4"] # last4 is 0000 when using an apple pay token + assert_equal 'card', card_response.params['object'] + assert_equal '4242', card_response.params['dynamic_last4'] # when stripe is in test mode, token exchanged will return a test card with dynamic_last4 4242 + assert_equal '0000', card_response.params['last4'] # last4 is 0000 when using an apple pay token customer_response = response.responses[1] - assert_equal "customer", customer_response.params["object"] - assert_equal "Active Merchant Test Customer", customer_response.params["description"] - assert_equal "email@example.com", customer_response.params["email"] - assert_equal 2, customer_response.params["cards"]["count"] + assert_equal 'customer', customer_response.params['object'] + assert_equal 'Active Merchant Test Customer', customer_response.params['description'] + assert_equal 'email@example.com', customer_response.params['email'] + assert_equal 2, customer_response.params['cards']['count'] end def test_successful_recurring_with_apple_pay_payment_token - assert response = @gateway.store(@apple_pay_payment_token, {:description => "Active Merchant Test Customer", :email => "email@example.com"}) + assert response = @gateway.store(@apple_pay_payment_token, {:description => 'Active Merchant Test Customer', :email => 'email@example.com'}) assert_success response - assert recharge_options = @options.merge(:customer => response.params["id"]) + assert recharge_options = @options.merge(:customer => response.params['id']) assert response = @gateway.purchase(@amount, nil, recharge_options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] end def test_purchase_with_unsuccessful_apple_pay_token_exchange @@ -102,63 +102,63 @@ def test_purchase_with_unsuccessful_apple_pay_token_exchange def test_successful_purchase_with_apple_pay_raw_cryptogram_with_eci credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', verification_value: nil, eci: '05', source: :apple_pay ) assert response = @gateway.purchase(@amount, credit_card, @options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] - assert_equal "ActiveMerchant Test Purchase", response.params["description"] - assert_equal "wow@example.com", response.params["metadata"]["email"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] + assert_equal 'ActiveMerchant Test Purchase', response.params['description'] + assert_equal 'wow@example.com', response.params['metadata']['email'] assert_match CHARGE_ID_REGEX, response.authorization end def test_successful_purchase_with_apple_pay_raw_cryptogram_without_eci credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', verification_value: nil, source: :apple_pay ) assert response = @gateway.purchase(@amount, credit_card, @options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] - assert_equal "ActiveMerchant Test Purchase", response.params["description"] - assert_equal "wow@example.com", response.params["metadata"]["email"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] + assert_equal 'ActiveMerchant Test Purchase', response.params['description'] + assert_equal 'wow@example.com', response.params['metadata']['email'] assert_match CHARGE_ID_REGEX, response.authorization end def test_successful_auth_with_apple_pay_raw_cryptogram_with_eci credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', verification_value: nil, eci: '05', source: :apple_pay ) assert response = @gateway.authorize(@amount, credit_card, @options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] - assert_equal "ActiveMerchant Test Purchase", response.params["description"] - assert_equal "wow@example.com", response.params["metadata"]["email"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] + assert_equal 'ActiveMerchant Test Purchase', response.params['description'] + assert_equal 'wow@example.com', response.params['metadata']['email'] assert_match CHARGE_ID_REGEX, response.authorization end def test_successful_auth_with_apple_pay_raw_cryptogram_without_eci credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", + payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', verification_value: nil, source: :apple_pay ) assert response = @gateway.authorize(@amount, credit_card, @options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] - assert_equal "ActiveMerchant Test Purchase", response.params["description"] - assert_equal "wow@example.com", response.params["metadata"]["email"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] + assert_equal 'ActiveMerchant Test Purchase', response.params['description'] + assert_equal 'wow@example.com', response.params['metadata']['email'] assert_match CHARGE_ID_REGEX, response.authorization end diff --git a/test/remote/gateways/remote_stripe_connect_test.rb b/test/remote/gateways/remote_stripe_connect_test.rb index 2117eb43b92..a8cd4664f36 100644 --- a/test/remote/gateways/remote_stripe_connect_test.rb +++ b/test/remote/gateways/remote_stripe_connect_test.rb @@ -10,7 +10,7 @@ def setup @new_credit_card = credit_card('5105105105105100') @options = { - :currency => "USD", + :currency => 'USD', :description => 'ActiveMerchant Test Purchase', :email => 'wow@example.com', :stripe_account => fixtures(:stripe_destination)[:stripe_user_id] @@ -31,30 +31,30 @@ def test_successful_refund_with_application_fee fetch_fee_id = @gateway.send(:fetch_application_fee, response.authorization, @options) fee_id = @gateway.send(:application_fee_from_response, fetch_fee_id) refund_check = @gateway.send(:refund_application_fee, 10, fee_id, @options) - assert_equal "Application fee could not be refunded: Refund amount ($0.10) is greater than unrefunded amount on fee ($0.00)", refund_check.message + assert_equal 'Application fee could not be refunded: Refund amount ($0.10) is greater than unrefunded amount on fee ($0.00)', refund_check.message end def test_refund_partial_application_fee assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:application_fee => 12)) - assert refund = @gateway.refund(@amount-20, response.authorization, @options.merge(:refund_fee_amount => "10")) + assert refund = @gateway.refund(@amount-20, response.authorization, @options.merge(:refund_fee_amount => '10')) assert_success refund # Verify the application fee is partially refunded fetch_fee_id = @gateway.send(:fetch_application_fee, response.authorization, @options) fee_id = @gateway.send(:application_fee_from_response, fetch_fee_id) refund_check = @gateway.send(:refund_application_fee, 10, fee_id, @options) - assert_equal "Application fee could not be refunded: Refund amount ($0.10) is greater than unrefunded amount on fee ($0.02)", refund_check.message + assert_equal 'Application fee could not be refunded: Refund amount ($0.10) is greater than unrefunded amount on fee ($0.02)', refund_check.message end def test_refund_application_fee_amount_zero assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:application_fee => 12)) - assert refund = @gateway.refund(@amount-20, response.authorization, @options.merge(:refund_fee_amount => "0")) + assert refund = @gateway.refund(@amount-20, response.authorization, @options.merge(:refund_fee_amount => '0')) assert_success refund # Verify the application fee is not refunded fetch_fee_id = @gateway.send(:fetch_application_fee, response.authorization, @options) fee_id = @gateway.send(:application_fee_from_response, fetch_fee_id) refund_check = @gateway.send(:refund_application_fee, 14, fee_id, @options) - assert_equal "Application fee could not be refunded: Refund amount ($0.14) is greater than fee amount ($0.12)", refund_check.message + assert_equal 'Application fee could not be refunded: Refund amount ($0.14) is greater than fee amount ($0.12)', refund_check.message end end diff --git a/test/remote/gateways/remote_stripe_emv_test.rb b/test/remote/gateways/remote_stripe_emv_test.rb index 1db4b4f53af..929d05d2cc2 100644 --- a/test/remote/gateways/remote_stripe_emv_test.rb +++ b/test/remote/gateways/remote_stripe_emv_test.rb @@ -14,7 +14,7 @@ def setup } @options = { - :currency => "USD", + :currency => 'USD', :description => 'ActiveMerchant Test Purchase', :email => 'wow@example.com' } @@ -22,7 +22,7 @@ def setup # This capture hex says that the payload is a transaction cryptogram (TC) but does not # provide the actual cryptogram. This will only work in test mode and would cause real # cards to be declined. - @capture_options = { icc_data: "9F270140" } + @capture_options = { icc_data: '9F270140' } end # for EMV contact transactions, it's advised to do a separate auth + capture @@ -31,8 +31,8 @@ def setup def test_successful_purchase_with_emv_credit_card_in_uk assert response = @gateway.purchase(@amount, @emv_credit_cards[:uk], @options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] assert_match CHARGE_ID_REGEX, response.authorization end @@ -41,8 +41,8 @@ def test_successful_purchase_with_emv_credit_card_in_uk def test_successful_purchase_with_emv_credit_card_in_us assert response = @gateway.purchase(@amount, @emv_credit_cards[:us], @options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] assert_match CHARGE_ID_REGEX, response.authorization end @@ -51,9 +51,9 @@ def test_successful_purchase_with_quickchip_credit_card_in_us credit_card.read_method = 'contact_quickchip' assert response = @gateway.purchase(@amount, credit_card, @options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["captured"] - assert response.params["paid"] + assert_equal 'charge', response.params['object'] + assert response.params['captured'] + assert response.params['paid'] assert_match CHARGE_ID_REGEX, response.authorization end @@ -64,53 +64,53 @@ def test_successful_purchase_with_emv_contactless_credit_card emv_credit_card.read_method = 'contactless' assert response = @gateway.purchase(@amount, emv_credit_card, @options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] assert_match CHARGE_ID_REGEX, response.authorization end def test_authorization_and_capture_with_emv_credit_card_in_uk assert authorization = @gateway.authorize(@amount, @emv_credit_cards[:uk], @options) assert_success authorization - assert authorization.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" - refute authorization.params["captured"] + assert authorization.emv_authorization, 'Authorization should contain emv_authorization containing the EMV ARPC' + refute authorization.params['captured'] assert capture = @gateway.capture(@amount, authorization.authorization, @capture_options) assert_success capture - assert capture.emv_authorization, "Capture should contain emv_authorization containing the EMV TC" + assert capture.emv_authorization, 'Capture should contain emv_authorization containing the EMV TC' end def test_authorization_and_capture_with_emv_credit_card_in_us assert authorization = @gateway.authorize(@amount, @emv_credit_cards[:us], @options) assert_success authorization - assert authorization.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" - refute authorization.params["captured"] + assert authorization.emv_authorization, 'Authorization should contain emv_authorization containing the EMV ARPC' + refute authorization.params['captured'] assert capture = @gateway.capture(@amount, authorization.authorization, @capture_options) assert_success capture - assert capture.emv_authorization, "Capture should contain emv_authorization containing the EMV TC" + assert capture.emv_authorization, 'Capture should contain emv_authorization containing the EMV TC' end def test_authorization_and_capture_of_online_pin_with_emv_credit_card_in_us emv_credit_card = @emv_credit_cards[:us] - emv_credit_card.encrypted_pin_cryptogram = "8b68af72199529b8" - emv_credit_card.encrypted_pin_ksn = "ffff0102628d12000001" + emv_credit_card.encrypted_pin_cryptogram = '8b68af72199529b8' + emv_credit_card.encrypted_pin_ksn = 'ffff0102628d12000001' assert authorization = @gateway.authorize(@amount, emv_credit_card, @options) assert_success authorization - assert authorization.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" - refute authorization.params["captured"] + assert authorization.emv_authorization, 'Authorization should contain emv_authorization containing the EMV ARPC' + refute authorization.params['captured'] assert capture = @gateway.capture(@amount, authorization.authorization, @capture_options) assert_success capture - assert capture.emv_authorization, "Capture should contain emv_authorization containing the EMV TC" + assert capture.emv_authorization, 'Capture should contain emv_authorization containing the EMV TC' end def test_authorization_and_void_with_emv_credit_card_in_us assert authorization = @gateway.authorize(@amount, @emv_credit_cards[:us], @options) assert_success authorization - assert authorization.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" - refute authorization.params["captured"] + assert authorization.emv_authorization, 'Authorization should contain emv_authorization containing the EMV ARPC' + refute authorization.params['captured'] assert void = @gateway.void(authorization.authorization) assert_success void @@ -119,8 +119,8 @@ def test_authorization_and_void_with_emv_credit_card_in_us def test_authorization_and_void_with_emv_credit_card_in_uk assert authorization = @gateway.authorize(@amount, @emv_credit_cards[:uk], @options) assert_success authorization - assert authorization.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" - refute authorization.params["captured"] + assert authorization.emv_authorization, 'Authorization should contain emv_authorization containing the EMV ARPC' + refute authorization.params['captured'] assert void = @gateway.void(authorization.authorization) assert_success void @@ -131,16 +131,16 @@ def test_purchase_and_void_with_emv_contactless_credit_card emv_credit_card.read_method = 'contactless' assert purchase = @gateway.purchase(@amount, emv_credit_card, @options) assert_success purchase - assert purchase.emv_authorization, "Authorization should contain emv_authorization containing the EMV ARPC" - assert purchase.params["captured"] - assert purchase.params["paid"] + assert purchase.emv_authorization, 'Authorization should contain emv_authorization containing the EMV ARPC' + assert purchase.params['captured'] + assert purchase.params['paid'] assert void = @gateway.void(purchase.authorization) assert_success void end def test_authorization_emv_credit_card_in_us_with_metadata - assert authorization = @gateway.authorize(@amount, @emv_credit_cards[:us], @options.merge({:metadata => {:this_is_a_random_key_name => 'with a random value', :i_made_up_this_key_too => 'canyoutell'}, :order_id => "42", :email => "foo@wonderfullyfakedomain.com"})) + assert authorization = @gateway.authorize(@amount, @emv_credit_cards[:us], @options.merge({:metadata => {:this_is_a_random_key_name => 'with a random value', :i_made_up_this_key_too => 'canyoutell'}, :order_id => '42', :email => 'foo@wonderfullyfakedomain.com'})) assert_success authorization end end diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb index b93cc05b795..3d34ae2c75a 100644 --- a/test/remote/gateways/remote_stripe_test.rb +++ b/test/remote/gateways/remote_stripe_test.rb @@ -11,14 +11,14 @@ def setup @debit_card = credit_card('4000056655665556') @check = check({ - bank_name: "STRIPE TEST BANK", - account_number: "000123456789", - routing_number: "110000000", + bank_name: 'STRIPE TEST BANK', + account_number: '000123456789', + routing_number: '110000000', }) @verified_bank_account = fixtures(:stripe_verified_bank_account) @options = { - :currency => "USD", + :currency => 'USD', :description => 'ActiveMerchant Test Purchase', :email => 'wow@example.com' } @@ -38,32 +38,32 @@ def test_transcript_scrubbing def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "charge", response.params["object"] - assert_equal response.authorization, response.params["id"] - assert response.params["paid"] - assert_equal "ActiveMerchant Test Purchase", response.params["description"] - assert_equal "wow@example.com", response.params["metadata"]["email"] + assert_equal 'charge', response.params['object'] + assert_equal response.authorization, response.params['id'] + assert response.params['paid'] + assert_equal 'ActiveMerchant Test Purchase', response.params['description'] + assert_equal 'wow@example.com', response.params['metadata']['email'] end def test_successful_purchase_with_blank_referer - options = @options.merge({referrer: ""}) + options = @options.merge({referrer: ''}) assert response = @gateway.purchase(@amount, @credit_card, options) assert_success response - assert_equal "charge", response.params["object"] - assert_equal response.authorization, response.params["id"] - assert response.params["paid"] - assert_equal "ActiveMerchant Test Purchase", response.params["description"] - assert_equal "wow@example.com", response.params["metadata"]["email"] + assert_equal 'charge', response.params['object'] + assert_equal response.authorization, response.params['id'] + assert response.params['paid'] + assert_equal 'ActiveMerchant Test Purchase', response.params['description'] + assert_equal 'wow@example.com', response.params['metadata']['email'] end def test_successful_purchase_with_recurring_flag custom_options = @options.merge(:eci => 'recurring') assert response = @gateway.purchase(@amount, @credit_card, custom_options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] - assert_equal "ActiveMerchant Test Purchase", response.params["description"] - assert_equal "wow@example.com", response.params["metadata"]["email"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] + assert_equal 'ActiveMerchant Test Purchase', response.params['description'] + assert_equal 'wow@example.com', response.params['metadata']['email'] end def test_successful_purchase_with_destination @@ -71,11 +71,11 @@ def test_successful_purchase_with_destination custom_options = @options.merge(:destination => destination) assert response = @gateway.purchase(@amount, @credit_card, custom_options) assert_success response - assert_equal "charge", response.params["object"] - assert_equal destination, response.params["destination"] - assert response.params["paid"] - assert_equal "ActiveMerchant Test Purchase", response.params["description"] - assert_equal "wow@example.com", response.params["metadata"]["email"] + assert_equal 'charge', response.params['object'] + assert_equal destination, response.params['destination'] + assert response.params['paid'] + assert_equal 'ActiveMerchant Test Purchase', response.params['description'] + assert_equal 'wow@example.com', response.params['metadata']['email'] end def test_successful_purchase_with_destination_and_amount @@ -83,11 +83,11 @@ def test_successful_purchase_with_destination_and_amount custom_options = @options.merge(:destination => destination, :destination_amount => @amount - 20) assert response = @gateway.purchase(@amount, @credit_card, custom_options) assert_success response - assert_equal "charge", response.params["object"] - assert_equal destination, response.params["destination"] - assert response.params["paid"] - assert_equal "ActiveMerchant Test Purchase", response.params["description"] - assert_equal "wow@example.com", response.params["metadata"]["email"] + assert_equal 'charge', response.params['object'] + assert_equal destination, response.params['destination'] + assert response.params['paid'] + assert_equal 'ActiveMerchant Test Purchase', response.params['description'] + assert_equal 'wow@example.com', response.params['metadata']['email'] end def test_unsuccessful_purchase @@ -115,21 +115,21 @@ def test_successful_echeck_purchase_with_verified_account response = @gateway.purchase(@amount, payment, @options) assert_success response assert response.test? - assert_equal "Transaction approved", response.message + assert_equal 'Transaction approved', response.message end def test_unsuccessful_direct_bank_account_purchase response = @gateway.purchase(@amount, @check, @options) assert_failure response - assert_equal "Direct bank account transactions are not supported. Bank accounts must be stored and verified before use.", response.message + assert_equal 'Direct bank account transactions are not supported. Bank accounts must be stored and verified before use.', response.message end def test_authorization_and_capture assert authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization - refute authorization.params["captured"] - assert_equal "ActiveMerchant Test Purchase", authorization.params["description"] - assert_equal "wow@example.com", authorization.params["metadata"]["email"] + refute authorization.params['captured'] + assert_equal 'ActiveMerchant Test Purchase', authorization.params['description'] + assert_equal 'wow@example.com', authorization.params['metadata']['email'] assert capture = @gateway.capture(@amount, authorization.authorization) assert_success capture @@ -141,10 +141,10 @@ def test_authorization_and_capture_with_destination assert authorization = @gateway.authorize(@amount, @credit_card, custom_options) assert_success authorization - refute authorization.params["captured"] - assert_equal destination, authorization.params["destination"] - assert_equal "ActiveMerchant Test Purchase", authorization.params["description"] - assert_equal "wow@example.com", authorization.params["metadata"]["email"] + refute authorization.params['captured'] + assert_equal destination, authorization.params['destination'] + assert_equal 'ActiveMerchant Test Purchase', authorization.params['description'] + assert_equal 'wow@example.com', authorization.params['metadata']['email'] assert capture = @gateway.capture(@amount, authorization.authorization) assert_success capture @@ -156,10 +156,10 @@ def test_authorization_and_capture_with_destination_and_amount assert authorization = @gateway.authorize(@amount, @credit_card, custom_options) assert_success authorization - refute authorization.params["captured"] - assert_equal destination, authorization.params["destination"] - assert_equal "ActiveMerchant Test Purchase", authorization.params["description"] - assert_equal "wow@example.com", authorization.params["metadata"]["email"] + refute authorization.params['captured'] + assert_equal destination, authorization.params['destination'] + assert_equal 'ActiveMerchant Test Purchase', authorization.params['description'] + assert_equal 'wow@example.com', authorization.params['metadata']['email'] assert capture = @gateway.capture(@amount, authorization.authorization) assert_success capture @@ -168,7 +168,7 @@ def test_authorization_and_capture_with_destination_and_amount def test_authorization_and_void assert authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization - refute authorization.params["captured"] + refute authorization.params['captured'] assert void = @gateway.void(authorization.authorization) assert_success void @@ -191,11 +191,11 @@ def test_successful_void_with_metadata assert void = @gateway.void(response.authorization, metadata: { test_metadata: 123 }) assert void.test? assert_success void - assert_equal "123", void.params["metadata"]["test_metadata"] + assert_equal '123', void.params['metadata']['test_metadata'] end def test_unsuccessful_void - assert void = @gateway.void("active_merchant_fake_charge") + assert void = @gateway.void('active_merchant_fake_charge') assert_failure void assert_match %r{active_merchant_fake_charge}, void.message end @@ -206,7 +206,7 @@ def test_successful_refund assert response.authorization assert refund = @gateway.refund(@amount - 20, response.authorization) assert refund.test? - refund_id = refund.params["id"] + refund_id = refund.params['id'] assert_equal refund.authorization, refund_id assert_success refund end @@ -222,7 +222,7 @@ def test_successful_refund_on_verified_bank_account refund = @gateway.refund(@amount, purchase.authorization) assert_success refund assert refund.test? - refund_id = refund.params["id"] + refund_id = refund.params['id'] assert_equal refund.authorization, refund_id end @@ -233,11 +233,11 @@ def test_refund_with_reverse_transfer assert refund = @gateway.refund(@amount - 20, response.authorization, reverse_transfer: true) assert_success refund - assert_equal "Transaction approved", refund.message + assert_equal 'Transaction approved', refund.message end def test_unsuccessful_refund - assert refund = @gateway.refund(@amount, "active_merchant_fake_charge") + assert refund = @gateway.refund(@amount, 'active_merchant_fake_charge') assert_failure refund assert_match %r{active_merchant_fake_charge}, refund.message end @@ -246,95 +246,95 @@ def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Transaction approved", response.message - assert_equal "wow@example.com", response.params["metadata"]["email"] - assert_equal "charge", response.params["object"] - assert_success response.responses.last, "The void should succeed" - assert_equal "refund", response.responses.last.params["object"] + assert_equal 'Transaction approved', response.message + assert_equal 'wow@example.com', response.params['metadata']['email'] + assert_equal 'charge', response.params['object'] + assert_success response.responses.last, 'The void should succeed' + assert_equal 'refund', response.responses.last.params['object'] end def test_successful_verify_cad - assert response = @gateway.verify(@credit_card, @options.merge(currency: "cad")) + assert response = @gateway.verify(@credit_card, @options.merge(currency: 'cad')) assert_success response - assert_equal 100, response.params["amount"] - assert_equal "cad", response.params["currency"] + assert_equal 100, response.params['amount'] + assert_equal 'cad', response.params['currency'] end def test_successful_verify_gbp - assert response = @gateway.verify(@credit_card, @options.merge(currency: "gbp")) + assert response = @gateway.verify(@credit_card, @options.merge(currency: 'gbp')) assert_success response - assert_equal 60, response.params["amount"] - assert_equal "gbp", response.params["currency"] + assert_equal 60, response.params['amount'] + assert_equal 'gbp', response.params['currency'] end def test_successful_verify_eur - assert response = @gateway.verify(@credit_card, @options.merge(currency: "eur")) + assert response = @gateway.verify(@credit_card, @options.merge(currency: 'eur')) assert_success response - assert_equal 100, response.params["amount"] - assert_equal "eur", response.params["currency"] + assert_equal 100, response.params['amount'] + assert_equal 'eur', response.params['currency'] end def test_successful_verify_dkk - assert response = @gateway.verify(@credit_card, @options.merge(currency: "dkk")) + assert response = @gateway.verify(@credit_card, @options.merge(currency: 'dkk')) assert_success response - assert_equal 500, response.params["amount"] - assert_equal "dkk", response.params["currency"] + assert_equal 500, response.params['amount'] + assert_equal 'dkk', response.params['currency'] end def test_successful_verify_nok - assert response = @gateway.verify(@credit_card, @options.merge(currency: "nok")) + assert response = @gateway.verify(@credit_card, @options.merge(currency: 'nok')) assert_success response - assert_equal 600, response.params["amount"] - assert_equal "nok", response.params["currency"] + assert_equal 600, response.params['amount'] + assert_equal 'nok', response.params['currency'] end def test_successful_verify_sek - assert response = @gateway.verify(@credit_card, @options.merge(currency: "sek")) + assert response = @gateway.verify(@credit_card, @options.merge(currency: 'sek')) assert_success response - assert_equal 600, response.params["amount"] - assert_equal "sek", response.params["currency"] + assert_equal 600, response.params['amount'] + assert_equal 'sek', response.params['currency'] end def test_successful_verify_chf - assert response = @gateway.verify(@credit_card, @options.merge(currency: "chf")) + assert response = @gateway.verify(@credit_card, @options.merge(currency: 'chf')) assert_success response - assert_equal 100, response.params["amount"] - assert_equal "chf", response.params["currency"] + assert_equal 100, response.params['amount'] + assert_equal 'chf', response.params['currency'] end def test_successful_verify_aud - assert response = @gateway.verify(@credit_card, @options.merge(currency: "aud")) + assert response = @gateway.verify(@credit_card, @options.merge(currency: 'aud')) assert_success response - assert_equal 100, response.params["amount"] - assert_equal "aud", response.params["currency"] + assert_equal 100, response.params['amount'] + assert_equal 'aud', response.params['currency'] end def test_successful_verify_jpy - assert response = @gateway.verify(@credit_card, @options.merge(currency: "jpy")) + assert response = @gateway.verify(@credit_card, @options.merge(currency: 'jpy')) assert_success response - assert_equal 100, response.params["amount"] - assert_equal "jpy", response.params["currency"] + assert_equal 100, response.params['amount'] + assert_equal 'jpy', response.params['currency'] end def test_successful_verify_mxn - assert response = @gateway.verify(@credit_card, @options.merge(currency: "mxn")) + assert response = @gateway.verify(@credit_card, @options.merge(currency: 'mxn')) assert_success response - assert_equal 2000, response.params["amount"] - assert_equal "mxn", response.params["currency"] + assert_equal 2000, response.params['amount'] + assert_equal 'mxn', response.params['currency'] end def test_successful_verify_sgd - assert response = @gateway.verify(@credit_card, @options.merge(currency: "sgd")) + assert response = @gateway.verify(@credit_card, @options.merge(currency: 'sgd')) assert_success response - assert_equal 100, response.params["amount"] - assert_equal "sgd", response.params["currency"] + assert_equal 100, response.params['amount'] + assert_equal 'sgd', response.params['currency'] end def test_successful_verify_hkd - assert response = @gateway.verify(@credit_card, @options.merge(currency: "hkd")) + assert response = @gateway.verify(@credit_card, @options.merge(currency: 'hkd')) assert_success response - assert_equal 800, response.params["amount"] - assert_equal "hkd", response.params["currency"] + assert_equal 800, response.params['amount'] + assert_equal 'hkd', response.params['currency'] end def test_unsuccessful_verify @@ -344,39 +344,39 @@ def test_unsuccessful_verify end def test_successful_store - assert response = @gateway.store(@credit_card, description: "TheDescription", email: "email@example.com") + assert response = @gateway.store(@credit_card, description: 'TheDescription', email: 'email@example.com') assert_success response - assert_equal "customer", response.params["object"] - assert_equal "TheDescription", response.params["description"] - assert_equal "email@example.com", response.params["email"] - first_card = response.params["sources"]["data"].first - assert_equal response.params["default_source"], first_card["id"] - assert_equal @credit_card.last_digits, first_card["last4"] + assert_equal 'customer', response.params['object'] + assert_equal 'TheDescription', response.params['description'] + assert_equal 'email@example.com', response.params['email'] + first_card = response.params['sources']['data'].first + assert_equal response.params['default_source'], first_card['id'] + assert_equal @credit_card.last_digits, first_card['last4'] end def test_successful_store_with_validate_false assert response = @gateway.store(@credit_card, validate: false) assert_success response - assert_equal "customer", response.params["object"] + assert_equal 'customer', response.params['object'] end def test_successful_store_with_existing_customer assert response = @gateway.store(@credit_card) assert_success response - assert response = @gateway.store(@new_credit_card, customer: response.params['id'], email: "email@example.com", description: "TheDesc") + assert response = @gateway.store(@new_credit_card, customer: response.params['id'], email: 'email@example.com', description: 'TheDesc') assert_success response assert_equal 2, response.responses.size card_response = response.responses[0] - assert_equal "card", card_response.params["object"] - assert_equal @new_credit_card.last_digits, card_response.params["last4"] + assert_equal 'card', card_response.params['object'] + assert_equal @new_credit_card.last_digits, card_response.params['last4'] customer_response = response.responses[1] - assert_equal "customer", customer_response.params["object"] - assert_equal "TheDesc", customer_response.params["description"] - assert_equal "email@example.com", customer_response.params["email"] - assert_equal 2, customer_response.params["sources"]["total_count"] + assert_equal 'customer', customer_response.params['object'] + assert_equal 'TheDesc', customer_response.params['description'] + assert_equal 'email@example.com', customer_response.params['email'] + assert_equal 2, customer_response.params['sources']['total_count'] end def test_successful_store_with_existing_account @@ -384,7 +384,7 @@ def test_successful_store_with_existing_account assert response = @gateway.store(@debit_card, account: account) assert_success response - assert_equal "card", response.params["object"] + assert_equal 'card', response.params['object'] end def test_successful_purchase_using_stored_card @@ -393,10 +393,10 @@ def test_successful_purchase_using_stored_card assert response = @gateway.purchase(@amount, store.authorization) assert_success response - assert_equal "Transaction approved", response.message + assert_equal 'Transaction approved', response.message - assert response.params["paid"] - assert_equal "4242", response.params["source"]["last4"] + assert response.params['paid'] + assert_equal '4242', response.params['source']['last4'] end def test_successful_purchase_using_stored_card_on_existing_customer @@ -408,36 +408,36 @@ def test_successful_purchase_using_stored_card_on_existing_customer assert response = @gateway.purchase(@amount, second_store_response.authorization) assert_success response - assert_equal "5100", response.params["source"]["last4"] + assert_equal '5100', response.params['source']['last4'] end def test_successful_purchase_using_stored_card_and_deprecated_api assert store = @gateway.store(@credit_card) assert_success store - recharge_options = @options.merge(:customer => store.params["id"]) + recharge_options = @options.merge(:customer => store.params['id']) assert_deprecation_warning do response = @gateway.purchase(@amount, nil, recharge_options) assert_success response - assert_equal "4242", response.params["source"]["last4"] + assert_equal '4242', response.params['source']['last4'] end end def test_successful_unstore - creation = @gateway.store(@credit_card, {:description => "Active Merchant Unstore Customer"}) + creation = @gateway.store(@credit_card, {:description => 'Active Merchant Unstore Customer'}) card_id = creation.params['sources']['data'].first['id'] assert response = @gateway.unstore(creation.authorization) assert_success response assert_equal card_id, response.params['id'] assert_equal true, response.params['deleted'] - assert_equal "Transaction approved", response.message + assert_equal 'Transaction approved', response.message end def test_successful_unstore_using_deprecated_api - creation = @gateway.store(@credit_card, {:description => "Active Merchant Unstore Customer"}) + creation = @gateway.store(@credit_card, {:description => 'Active Merchant Unstore Customer'}) card_id = creation.params['sources']['data'].first['id'] - customer_id = creation.params["id"] + customer_id = creation.params['id'] assert_deprecation_warning do response = @gateway.unstore(customer_id, card_id) @@ -472,7 +472,7 @@ def test_successful_purchase_from_stored_and_verified_bank_account customer_id, bank_account_id = store.authorization.split('|') verify_url = "customers/#{customer_id}/sources/#{bank_account_id}/verify" verify_response = @gateway.send(:api_request, :post, verify_url, { amounts: [32, 45] }) - assert_match "verified", verify_response["status"] + assert_match 'verified', verify_response['status'] purchase = @gateway.purchase(@amount, store.authorization, @options) assert_success purchase @@ -482,7 +482,7 @@ def test_invalid_login gateway = StripeGateway.new(:login => 'active_merchant_test') assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_match "Invalid API Key provided", response.message + assert_match 'Invalid API Key provided', response.message end # These "track data present" tests fail with invalid expiration dates. The @@ -491,15 +491,15 @@ def test_card_present_purchase @credit_card.track_data = '%B378282246310005^LONGSON/LONGBOB^2205101130504392?' assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] end def test_card_present_authorize_and_capture @credit_card.track_data = '%B378282246310005^LONGSON/LONGBOB^2205101130504392?' assert authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization - refute authorization.params["captured"] + refute authorization.params['captured'] assert capture = @gateway.capture(@amount, authorization.authorization) assert_success capture @@ -508,8 +508,8 @@ def test_card_present_authorize_and_capture def test_creditcard_purchase_with_customer assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:customer => '1234')) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] end def test_expanding_objects @@ -520,19 +520,19 @@ def test_expanding_objects end def test_successful_update - creation = @gateway.store(@credit_card, {:description => "Active Merchant Update Credit Card"}) + creation = @gateway.store(@credit_card, {:description => 'Active Merchant Update Credit Card'}) customer_id = creation.params['id'] card_id = creation.params['sources']['data'].first['id'] - assert response = @gateway.update(customer_id, card_id, { :name => "John Doe", :address_line1 => "123 Main Street", :address_city => "Pleasantville", :address_state => "NY", :address_zip => "12345", :exp_year => Time.now.year + 2, :exp_month => 6 }) + assert response = @gateway.update(customer_id, card_id, { :name => 'John Doe', :address_line1 => '123 Main Street', :address_city => 'Pleasantville', :address_state => 'NY', :address_zip => '12345', :exp_year => Time.now.year + 2, :exp_month => 6 }) assert_success response - assert_equal "John Doe", response.params["name"] - assert_equal "123 Main Street", response.params["address_line1"] - assert_equal "Pleasantville", response.params["address_city"] - assert_equal "NY", response.params["address_state"] - assert_equal "12345", response.params["address_zip"] - assert_equal Time.now.year + 2, response.params["exp_year"] - assert_equal 6, response.params["exp_month"] + assert_equal 'John Doe', response.params['name'] + assert_equal '123 Main Street', response.params['address_line1'] + assert_equal 'Pleasantville', response.params['address_city'] + assert_equal 'NY', response.params['address_state'] + assert_equal '12345', response.params['address_zip'] + assert_equal Time.now.year + 2, response.params['exp_year'] + assert_equal 6, response.params['exp_month'] end def test_incorrect_number_for_purchase @@ -592,9 +592,9 @@ def test_processing_error end def test_statement_description - assert response = @gateway.purchase(@amount, @credit_card, statement_description: "Eggcellent Description") + assert response = @gateway.purchase(@amount, @credit_card, statement_description: 'Eggcellent Description') assert_success response - assert_equal "Eggcellent Description", response.params["statement_descriptor"] + assert_equal 'Eggcellent Description', response.params['statement_descriptor'] end def test_stripe_account_header diff --git a/test/remote/gateways/remote_telr_test.rb b/test/remote/gateways/remote_telr_test.rb index 4ce3d2871e8..bf0477ac36f 100644 --- a/test/remote/gateways/remote_telr_test.rb +++ b/test/remote/gateways/remote_telr_test.rb @@ -1,45 +1,45 @@ -require "test_helper" +require 'test_helper' class RemoteTelrTest < Test::Unit::TestCase def setup @gateway = TelrGateway.new(fixtures(:telr)) @amount = 100 - @credit_card = credit_card("5105105105105100") - @declined_card = credit_card("5105105105105100", verification_value: "031") + @credit_card = credit_card('5105105105105100') + @declined_card = credit_card('5105105105105100', verification_value: '031') @options = { order_id: generate_unique_id, billing_address: address, - description: "Test transaction", - email: "email@address.com" + description: 'Test transaction', + email: 'email@address.com' } end def test_invalid_login - gateway = TelrGateway.new(merchant_id: "", api_key: "") + gateway = TelrGateway.new(merchant_id: '', api_key: '') response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Invalid request", response.message + assert_equal 'Invalid request', response.message end def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_purchase_sans_options response = @gateway.purchase(@amount, @credit_card) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "Not authorised", response.message - assert_equal "31", response.error_code + assert_equal 'Not authorised', response.message + assert_equal '31', response.error_code end def test_successful_reference_purchase @@ -62,14 +62,14 @@ def test_successful_authorize_and_capture def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal "Not authorised", response.message + assert_equal 'Not authorised', response.message end def test_failed_capture - response = @gateway.capture(@amount, "") + response = @gateway.capture(@amount, '') assert_failure response - assert_equal "Invalid transaction reference", response.message - assert_equal "22", response.error_code + assert_equal 'Invalid transaction reference', response.message + assert_equal '22', response.error_code end def test_successful_void @@ -77,14 +77,14 @@ def test_successful_void assert_success response void = @gateway.void(response.authorization) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end def test_failed_void - response = @gateway.void("") + response = @gateway.void('') assert_failure response - assert_equal "Transaction cost or currency not valid", response.message - assert_equal "05", response.error_code + assert_equal 'Transaction cost or currency not valid', response.message + assert_equal '05', response.error_code end def test_successful_refund @@ -104,10 +104,10 @@ def test_partial_refund end def test_failed_refund - response = @gateway.refund(@amount, "0") + response = @gateway.refund(@amount, '0') assert_failure response - assert_equal "Invalid transaction reference", response.message - assert_equal "22", response.error_code + assert_equal 'Invalid transaction reference', response.message + assert_equal '22', response.error_code end def test_excess_refund @@ -116,8 +116,8 @@ def test_excess_refund refund = @gateway.refund(200, response.authorization) assert_failure refund - assert_equal "Amount greater than available balance", refund.message - assert_equal "29", refund.error_code + assert_equal 'Amount greater than available balance', refund.message + assert_equal '29', refund.error_code end def test_successful_verify @@ -129,8 +129,8 @@ def test_successful_verify def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "Not authorised", response.message - assert_equal "31", response.error_code + assert_equal 'Not authorised', response.message + assert_equal '31', response.error_code end def test_verify_credentials @@ -145,13 +145,13 @@ def test_verify_credentials def test_cvv_result response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "M", response.cvv_result["code"] + assert_equal 'M', response.cvv_result['code'] end def test_avs_result response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "I", response.avs_result["code"] + assert_equal 'I', response.avs_result['code'] end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_tns_test.rb b/test/remote/gateways/remote_tns_test.rb index c3262f15193..cc1aa80efa1 100644 --- a/test/remote/gateways/remote_tns_test.rb +++ b/test/remote/gateways/remote_tns_test.rb @@ -25,55 +25,55 @@ def teardown def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_purchase_sans_options assert response = @gateway.purchase(@amount, @credit_card) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_purchase_with_more_options more_options = @options.merge({ - ip: "127.0.0.1", - email: "joe@example.com", + ip: '127.0.0.1', + email: 'joe@example.com', }) assert response = @gateway.purchase(@amount, @credit_card, @options.merge(more_options)) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_purchase_with_region @gateway = TnsGateway.new(fixtures(:tns_ap).merge(region: 'asia_pacific')) - assert response = @gateway.purchase(@amount, @ap_credit_card, @options.merge(currency: "AUD")) + assert response = @gateway.purchase(@amount, @ap_credit_card, @options.merge(currency: 'AUD')) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal "FAILURE - DECLINED", response.message + assert_equal 'FAILURE - DECLINED', response.message end def test_successful_authorize_and_capture assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^.+\|\d+$), response.authorization assert capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_failed_authorize assert response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal "FAILURE - DECLINED", response.message + assert_equal 'FAILURE - DECLINED', response.message end def test_successful_refund @@ -82,7 +82,7 @@ def test_successful_refund assert refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "Succeeded", refund.message + assert_equal 'Succeeded', refund.message end def test_successful_void @@ -96,10 +96,10 @@ def test_successful_void def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message - assert_success response.responses.last, "The void should succeed" - assert_equal "SUCCESS", response.responses.last.params["result"] + assert_success response.responses.last, 'The void should succeed' + assert_equal 'SUCCESS', response.responses.last.params['result'] end def test_invalid_login @@ -109,11 +109,11 @@ def test_invalid_login ) response = gateway.authorize(@amount, @credit_card, @options) assert_failure response - assert_equal "ERROR - INVALID_REQUEST - Invalid credentials.", response.message + assert_equal 'ERROR - INVALID_REQUEST - Invalid credentials.', response.message end def test_transcript_scrubbing - card = credit_card("5123456789012346", verification_value: "834") + card = credit_card('5123456789012346', verification_value: '834') transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, card, @options) end diff --git a/test/remote/gateways/remote_trans_first_test.rb b/test/remote/gateways/remote_trans_first_test.rb index a6036eacf10..3b19be25327 100644 --- a/test/remote/gateways/remote_trans_first_test.rb +++ b/test/remote/gateways/remote_trans_first_test.rb @@ -35,7 +35,7 @@ def test_successful_purchase_no_address end def test_successful_purchase_sans_cvv - @credit_card.verification_value = "" + @credit_card.verification_value = '' assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response end diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb index 2f4488d9823..ed32f7e9f1d 100644 --- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb +++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb @@ -1,4 +1,4 @@ -require "test_helper" +require 'test_helper' class RemoteTransFirstTransactionExpressTest < Test::Unit::TestCase @@ -7,31 +7,31 @@ def setup @amount = 100 @declined_amount = 21 - @credit_card = credit_card("4485896261017708") + @credit_card = credit_card('4485896261017708') @check = check billing_address = address({ - address1: "450 Main", - address2: "Suite 100", - city: "Broomfield", - state: "CO", - zip: "85284", - phone: "(333) 444-5555", + address1: '450 Main', + address2: 'Suite 100', + city: 'Broomfield', + state: 'CO', + zip: '85284', + phone: '(333) 444-5555', }) @options = { order_id: generate_unique_id, - company_name: "Acme", - title: "QA Manager", + company_name: 'Acme', + title: 'QA Manager', billing_address: billing_address, shipping_address: billing_address, - email: "example@example.com", - description: "Store Purchase" + email: 'example@example.com', + description: 'Store Purchase' } end def test_invalid_login - gateway = TransFirstTransactionExpressGateway.new(gateway_id: "", reg_key: "") + gateway = TransFirstTransactionExpressGateway.new(gateway_id: '', reg_key: '') response = gateway.purchase(@amount, @credit_card, @options) assert_failure response end @@ -39,11 +39,11 @@ def test_invalid_login def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_not_nil response.avs_result assert_not_nil response.cvv_result - assert_equal "Street address does not match, but 5-digit postal code matches.", response.avs_result["message"] - assert_equal "CVV matches", response.cvv_result["message"] + assert_equal 'Street address does not match, but 5-digit postal code matches.', response.avs_result['message'] + assert_equal 'CVV matches', response.cvv_result['message'] end def test_successful_purchase_no_avs @@ -58,22 +58,22 @@ def test_successful_purchase_with_only_required # Test the purchase with only the required billing and shipping information options = @options.dup options[:shipping_address] = { - address1: "450 Main", - zip: "85284", + address1: '450 Main', + zip: '85284', } options[:billing_address] = { - address1: "450 Main", - zip: "85284", + address1: '450 Main', + zip: '85284', } response = @gateway.purchase(@amount, @credit_card, options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_not_nil response.avs_result assert_not_nil response.cvv_result - assert_equal "Street address does not match, but 5-digit postal code matches.", response.avs_result["message"] - assert_equal "CVV matches", response.cvv_result["message"] + assert_equal 'Street address does not match, but 5-digit postal code matches.', response.avs_result['message'] + assert_equal 'CVV matches', response.cvv_result['message'] end @@ -90,7 +90,7 @@ def test_successful_purchase_without_cvv credit_card = CreditCard.new(credit_card_opts) response = @gateway.purchase(@amount, credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_purchase_with_empty_string_cvv @@ -107,7 +107,7 @@ def test_successful_purchase_with_empty_string_cvv credit_card = CreditCard.new(credit_card_opts) response = @gateway.purchase(@amount, credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_successful_purchase_with_echeck @@ -119,12 +119,12 @@ def test_successful_purchase_with_echeck def test_failed_purchase response = @gateway.purchase(@declined_amount, @credit_card, @options) assert_failure response - assert_equal "Not sufficient funds", response.message - assert_equal "51", response.params["rspCode"] + assert_equal 'Not sufficient funds', response.message + assert_equal '51', response.params['rspCode'] end def test_failed_purchase_with_echeck - assert response = @gateway.purchase(@amount, check(routing_number: "121042883"), @options) + assert response = @gateway.purchase(@amount, check(routing_number: '121042883'), @options) assert_failure response assert_equal 'Error. Bank routing number validation negative (ABA).', response.message end @@ -132,19 +132,19 @@ def test_failed_purchase_with_echeck def test_successful_authorize_and_capture response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^authorize\|\d+$), response.authorization capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_failed_authorize response = @gateway.authorize(@declined_amount, @credit_card, @options) assert_failure response - assert_equal "Not sufficient funds", response.message - assert_equal "51", response.error_code + assert_equal 'Not sufficient funds', response.message + assert_equal '51', response.error_code end def test_failed_capture @@ -153,8 +153,8 @@ def test_failed_capture response = @gateway.capture(@amount, authorize.authorization) assert_failure response - assert_equal "Invalid transaction", response.message - assert_equal "12", response.error_code + assert_equal 'Invalid transaction', response.message + assert_equal '12', response.error_code end def test_successful_purchase_void @@ -163,7 +163,7 @@ def test_successful_purchase_void void = @gateway.void(response.authorization) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end def test_successful_authorization_void @@ -172,7 +172,7 @@ def test_successful_authorization_void void = @gateway.void(authorize.authorization) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end def test_successful_capture_void @@ -184,14 +184,14 @@ def test_successful_capture_void void = @gateway.void(capture.authorization, void_type: :void_capture) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end def test_failed_void - response = @gateway.void("purchase|000015212561") + response = @gateway.void('purchase|000015212561') assert_failure response - assert_equal "Invalid transaction", response.message - assert_equal "12", response.error_code + assert_equal 'Invalid transaction', response.message + assert_equal '12', response.error_code end def test_successful_echeck_purchase_void @@ -200,7 +200,7 @@ def test_successful_echeck_purchase_void void = @gateway.void(response.authorization) assert_success void - assert_equal "Succeeded", void.message + assert_equal 'Succeeded', void.message end # gateway does not settle fast enough to test refunds @@ -220,14 +220,14 @@ def test_helpful_message_when_refunding_unsettled_purchase refund = @gateway.refund(@amount, purchase.authorization) assert_failure refund - assert_equal "Invalid transaction. Declined Post – Credit linked to unextracted settle transaction", refund.message + assert_equal 'Invalid transaction. Declined Post – Credit linked to unextracted settle transaction', refund.message end def test_failed_refund - response = @gateway.refund(nil, "") + response = @gateway.refund(nil, '') assert_failure response - assert_equal "Validation Failure", response.message - assert_equal "50011", response.error_code + assert_equal 'Validation Failure', response.message + assert_equal '50011', response.error_code end def test_successful_refund_with_echeck @@ -242,7 +242,7 @@ def test_successful_refund_with_echeck def test_failed_refund_with_echeck refund = @gateway.refund(@amount, 'purchase_echeck|000028706091') assert_failure refund - assert_equal "Invalid transaction", refund.message + assert_equal 'Invalid transaction', refund.message end # Credit is only supported with specific approval from Transaction Express @@ -255,34 +255,34 @@ def test_failed_refund_with_echeck def test_failed_credit response = @gateway.credit(0, @credit_card, @options) assert_failure response - assert_equal "51334", response.error_code - assert_equal "Validation Error", response.message + assert_equal '51334', response.error_code + assert_equal 'Validation Error', response.message end def test_successful_verify - visa = credit_card("4485896261017708") - amex = credit_card("371449635392376", verification_value: 1234) - mastercard = credit_card("5499740000000057") - discover = credit_card("6011000991001201") + visa = credit_card('4485896261017708') + amex = credit_card('371449635392376', verification_value: 1234) + mastercard = credit_card('5499740000000057') + discover = credit_card('6011000991001201') [visa, amex, mastercard, discover].each do |credit_card| response = @gateway.verify(credit_card, @options) assert_success response - assert_match "Succeeded", response.message + assert_match 'Succeeded', response.message end end def test_failed_verify - response = @gateway.verify(credit_card(""), @options) + response = @gateway.verify(credit_card(''), @options) assert_failure response - assert_equal "Validation Failure", response.message - assert_equal "51308", response.error_code + assert_equal 'Validation Failure', response.message + assert_equal '51308', response.error_code end def test_successful_store response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert response.authorization end @@ -292,7 +292,7 @@ def test_successful_authorize_using_stored_card response = @gateway.authorize(@amount, response.authorization, @options) assert_success response - assert_match "Succeeded", response.message + assert_match 'Succeeded', response.message end def test_failed_authorize_using_stored_card @@ -301,7 +301,7 @@ def test_failed_authorize_using_stored_card response = @gateway.authorize(@declined_amount, response.authorization, @options) assert_failure response - assert_match "Not sufficient funds", response.message + assert_match 'Not sufficient funds', response.message end def test_successful_purchase_using_stored_card @@ -310,7 +310,7 @@ def test_successful_purchase_using_stored_card response = @gateway.purchase(@amount, response.authorization, @options) assert_success response - assert_match "Succeeded", response.message + assert_match 'Succeeded', response.message end def test_failed_purchase_using_stored_card @@ -319,14 +319,14 @@ def test_failed_purchase_using_stored_card response = @gateway.purchase(@declined_amount, response.authorization, @options) assert_failure response - assert_match "Not sufficient funds", response.message + assert_match 'Not sufficient funds', response.message end def test_failed_store - response = @gateway.store(credit_card("123"), @options) + response = @gateway.store(credit_card('123'), @options) assert_failure response - assert_equal "Validation Failure", response.message - assert_equal "51308", response.error_code + assert_equal 'Validation Failure', response.message + assert_equal '51308', response.error_code end # def test_dump_transcript diff --git a/test/remote/gateways/remote_transact_pro_test.rb b/test/remote/gateways/remote_transact_pro_test.rb index b89f99b3ab8..5e5c428ae29 100644 --- a/test/remote/gateways/remote_transact_pro_test.rb +++ b/test/remote/gateways/remote_transact_pro_test.rb @@ -64,7 +64,7 @@ def test_partial_capture def test_failed_capture response = @gateway.capture(nil, 'bogus|100') assert_failure response - assert_equal "bogus|100", response.authorization + assert_equal 'bogus|100', response.authorization end def test_successful_refund diff --git a/test/remote/gateways/remote_transax_test.rb b/test/remote/gateways/remote_transax_test.rb index efd0339925d..1e7bbc00399 100644 --- a/test/remote/gateways/remote_transax_test.rb +++ b/test/remote/gateways/remote_transax_test.rb @@ -20,7 +20,7 @@ def setup def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "This transaction has been approved", response.message + assert_equal 'This transaction has been approved', response.message end def test_unsuccessful_purchase @@ -32,7 +32,7 @@ def test_unsuccessful_purchase def test_authorize_and_capture assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert_equal "This transaction has been approved", auth.message + assert_equal 'This transaction has been approved', auth.message assert auth.authorization assert capture = @gateway.capture(@amount, auth.authorization) assert_success capture @@ -41,20 +41,20 @@ def test_authorize_and_capture def test_authorize_and_void assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert_equal "This transaction has been approved", auth.message + assert_equal 'This transaction has been approved', auth.message assert auth.authorization assert void = @gateway.void(auth.authorization) - assert_equal "Transaction Void Successful", void.message + assert_equal 'Transaction Void Successful', void.message assert_success void end def test_purchase_and_refund assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "This transaction has been approved", response.message + assert_equal 'This transaction has been approved', response.message assert response.authorization assert refund = @gateway.refund(nil, response.authorization) - assert_equal "This transaction has been approved", refund.message + assert_equal 'This transaction has been approved', refund.message assert_success refund end @@ -68,16 +68,16 @@ def test_credit assert response = @gateway.credit(@amount, @credit_card, @options) assert_success response assert response.authorization - assert_equal "This transaction has been approved", response.message + assert_equal 'This transaction has been approved', response.message end def test_purchase_and_update assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "This transaction has been approved", response.message + assert_equal 'This transaction has been approved', response.message assert response.authorization assert update = @gateway.amend(response.authorization, :shipping_carrier => 'usps') - assert_equal "This transaction has been approved", update.message + assert_equal 'This transaction has been approved', update.message assert_success update end @@ -85,7 +85,7 @@ def test_successful_purchase_with_sku @options['product_sku_#']='123456' assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "This transaction has been approved", response.message + assert_equal 'This transaction has been approved', response.message end def test_store_credit_card @@ -103,7 +103,7 @@ def test_store_check def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "This transaction has been approved", response.message + assert_equal 'This transaction has been approved', response.message end def test_failed_verify @@ -120,6 +120,6 @@ def test_invalid_login ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Invalid Username", response.message + assert_equal 'Invalid Username', response.message end end diff --git a/test/remote/gateways/remote_trexle_test.rb b/test/remote/gateways/remote_trexle_test.rb index c0d3fcf09cf..cd8f5360315 100644 --- a/test/remote/gateways/remote_trexle_test.rb +++ b/test/remote/gateways/remote_trexle_test.rb @@ -40,7 +40,7 @@ def test_failed_authorize end def test_failed_capture_due_to_invalid_token - response = @gateway.capture(@amount, "bogus", @options) + response = @gateway.capture(@amount, 'bogus', @options) assert_failure response end @@ -70,8 +70,8 @@ def test_unsuccessful_purchase # falls outside of active merchant def test_store_and_charge_with_trexle_js_card_token headers = { - "Content-Type" => "application/json", - "Authorization" => "Basic #{Base64.strict_encode64(@gateway.options[:api_key] + ':').strip}" + 'Content-Type' => 'application/json', + 'Authorization' => "Basic #{Base64.strict_encode64(@gateway.options[:api_key] + ':').strip}" } # Get a token equivalent to what is returned by trexle.js card_attrs = { @@ -80,18 +80,18 @@ def test_store_and_charge_with_trexle_js_card_token expiry_year: @credit_card.year, cvc: @credit_card.verification_value, name: "#{@credit_card.first_name} #{@credit_card.last_name}", - address_line1: "321 Shoreline Park", - address_line2: "suite #7", - address_city: "Mountain View", - address_postcode: "94043", - address_state: "CA", - address_country: "United States" + address_line1: '321 Shoreline Park', + address_line2: 'suite #7', + address_city: 'Mountain View', + address_postcode: '94043', + address_state: 'CA', + address_country: 'United States' } - url = @gateway.test_url + "/tokens" + url = @gateway.test_url + '/tokens' body = JSON.parse(@gateway.ssl_post(url, card_attrs.to_json, headers)) - card_token = body["response"]["token"] + card_token = body['response']['token'] store = @gateway.store(card_token, @options) assert_success store diff --git a/test/remote/gateways/remote_trust_commerce_test.rb b/test/remote/gateways/remote_trust_commerce_test.rb index 7131cbe1c17..8fd3215f4f1 100644 --- a/test/remote/gateways/remote_trust_commerce_test.rb +++ b/test/remote/gateways/remote_trust_commerce_test.rb @@ -41,9 +41,9 @@ def test_bad_login assert response = @gateway.purchase(@amount, @credit_card, @options) assert_equal Response, response.class - assert_equal ["error", - "offenders", - "status"], response.params.keys.sort + assert_equal ['error', + 'offenders', + 'status'], response.params.keys.sort assert_match %r{A field was improperly formatted, such as non-digit characters in a number field}, response.message @@ -70,7 +70,7 @@ def test_unsuccessful_purchase_with_invalid_cvv def test_purchase_with_avs_for_invalid_address assert response = @gateway.purchase(@amount, @credit_card, @options.update(:billing_address => @invalid_address)) - assert_equal "N", response.params["avs"] + assert_equal 'N', response.params['avs'] assert_match %r{The transaction was successful}, response.message assert_success response end @@ -78,7 +78,7 @@ def test_purchase_with_avs_for_invalid_address def test_successful_authorize_with_avs assert response = @gateway.authorize(@amount, @credit_card, :billing_address => @valid_address) - assert_equal "Y", response.avs_result["code"] + assert_equal 'Y', response.avs_result['code'] assert_match %r{The transaction was successful}, response.message assert_success response @@ -94,7 +94,7 @@ def test_unsuccessful_authorize_with_invalid_cvv def test_authorization_with_avs_for_invalid_address assert response = @gateway.authorize(@amount, @credit_card, @options.update(:billing_address => @invalid_address)) - assert_equal "N", response.params["avs"] + assert_equal 'N', response.params['avs'] assert_match %r{The transaction was successful}, response.message assert_success response end diff --git a/test/remote/gateways/remote_usa_epay_advanced_test.rb b/test/remote/gateways/remote_usa_epay_advanced_test.rb index de314da965b..2f7bc1fc264 100644 --- a/test/remote/gateways/remote_usa_epay_advanced_test.rb +++ b/test/remote/gateways/remote_usa_epay_advanced_test.rb @@ -13,8 +13,8 @@ def setup :year => Time.now.year + 1, :brand => 'visa', :verification_value => '123', - :first_name => "Fred", - :last_name => "Flintstone" + :first_name => 'Fred', + :last_name => 'Flintstone' ) @bad_credit_card = ActiveMerchant::Billing::CreditCard.new( @@ -23,21 +23,21 @@ def setup :year => 14, :brand => 'visa', :verification_value => '999', - :first_name => "Fred", - :last_name => "Flintstone" + :first_name => 'Fred', + :last_name => 'Flintstone' ) @check = ActiveMerchant::Billing::Check.new( :account_number => '123456789', :routing_number => '120450780', :account_type => 'checking', - :first_name => "Fred", - :last_name => "Flintstone" + :first_name => 'Fred', + :last_name => 'Flintstone' ) cc_method = [ - {:name => "My CC", :sort => 5, :method => @credit_card}, - {:name => "Other CC", :sort => 12, :method => @credit_card} + {:name => 'My CC', :sort => 5, :method => @credit_card}, + {:name => 'Other CC', :sort => 12, :method => @credit_card} ] @options = { @@ -52,20 +52,20 @@ def setup @customer_options = { :id => 123, - :notes => "Customer note.", - :data => "complex data", - :url => "somesite.com", + :notes => 'Customer note.', + :data => 'complex data', + :url => 'somesite.com', :payment_methods => cc_method } @update_customer_options = { - :notes => "NEW NOTE!" + :notes => 'NEW NOTE!' } @add_payment_options = { :make_default => true, :payment_method => { - :name => "My new card.", + :name => 'My new card.', :sort => 10, :method => @credit_card } @@ -95,12 +95,12 @@ def setup payment_methods = [ { - :name => "My Visa", # optional + :name => 'My Visa', # optional :sort => 2, # optional :method => @credit_card }, { - :name => "My Checking", + :name => 'My Checking', :method => @check } ] @@ -241,7 +241,7 @@ def test_update_customer_payment_method payment_method_id = response.params['add_customer_payment_method_return'] update_payment_options = @add_payment_options[:payment_method].merge(:method_id => payment_method_id, - :name => "Updated Card.") + :name => 'Updated Card.') response = @gateway.update_customer_payment_method(update_payment_options) assert response.params['update_customer_payment_method_return'] @@ -272,7 +272,7 @@ def test_run_customer_transaction customer_number = response.params['add_customer_return'] response = @gateway.run_customer_transaction(:customer_number => customer_number,# :method_id => 0, # optional - :command => "Sale", :amount => 3000) + :command => 'Sale', :amount => 3000) assert response.params['run_customer_transaction_return'] end @@ -365,7 +365,7 @@ def test_override_transaction response = @gateway.run_check_sale(options) reference_number = response.params['run_check_sale_return']['ref_num'] - response = @gateway.override_transaction(:reference_number => reference_number, :reason => "Because I said so") + response = @gateway.override_transaction(:reference_number => reference_number, :reason => 'Because I said so') assert response.params['faultstring'] end diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb index 3acc16cd62b..ac553b144de 100644 --- a/test/remote/gateways/remote_usa_epay_transaction_test.rb +++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb @@ -7,7 +7,7 @@ def setup @declined_card = credit_card('4000300011112220') @credit_card_with_track_data = credit_card_with_track_data('4000100011112224') @check = check - @options = { :billing_address => address(:zip => "27614", :state => "NC"), :shipping_address => address } + @options = { :billing_address => address(:zip => '27614', :state => 'NC'), :shipping_address => address } @amount = 100 end @@ -44,7 +44,7 @@ def test_successful_purchase_with_manual_entry end def test_successful_purchase_with_extra_details - assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:order_id => generate_unique_id, :description => "socool")) + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:order_id => generate_unique_id, :description => 'socool')) assert_equal 'Success', response.message assert_success response end @@ -111,7 +111,7 @@ def test_successful_refund_of_echeck end def test_unsuccessful_refund - assert refund = @gateway.refund(@amount - 20, "unknown_authorization") + assert refund = @gateway.refund(@amount - 20, 'unknown_authorization') assert_failure refund assert_match(/Unable to find original transaction/, refund.message) end @@ -133,7 +133,7 @@ def test_successful_void_with_echeck end def test_unsuccessful_void - assert void = @gateway.void("unknown_authorization") + assert void = @gateway.void('unknown_authorization') assert_failure void assert_match(/Unable to locate transaction/, void.message) end @@ -155,7 +155,7 @@ def test_successful_void_release_with_echeck end def test_unsuccessful_void_release - assert void = @gateway.void("unknown_authorization", void_mode: :void_release) + assert void = @gateway.void('unknown_authorization', void_mode: :void_release) assert_failure void assert_match(/Unable to locate transaction/, void.message) end @@ -170,14 +170,14 @@ def test_invalid_key def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Success", response.message - assert_success response.responses.last, "The void should succeed" + assert_equal 'Success', response.message + assert_success response.responses.last, 'The void should succeed' end def test_failed_verify assert response = @gateway.verify(@declined_card, @options) assert_failure response - assert_match "Card Declined (00)", response.message + assert_match 'Card Declined (00)', response.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_vanco_test.rb b/test/remote/gateways/remote_vanco_test.rb index af1bd190e3a..077b9b1a248 100644 --- a/test/remote/gateways/remote_vanco_test.rb +++ b/test/remote/gateways/remote_vanco_test.rb @@ -11,7 +11,7 @@ def setup @options = { order_id: '1', - billing_address: address(country: "US", state: "NC", zip: "06085"), + billing_address: address(country: 'US', state: 'NC', zip: '06085'), description: 'Store Purchase' } end @@ -19,32 +19,32 @@ def setup def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message end def test_successful_purchase_with_fund_id - response = @gateway.purchase(@amount, @credit_card, @options.merge(fund_id: "TheFund")) + response = @gateway.purchase(@amount, @credit_card, @options.merge(fund_id: 'TheFund')) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message end def test_successful_purchase_with_ip_address - response = @gateway.purchase(@amount, @credit_card, @options.merge(ip: "192.168.19.123")) + response = @gateway.purchase(@amount, @credit_card, @options.merge(ip: '192.168.19.123')) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message end def test_successful_purchase_sans_minimal_options response = @gateway.purchase(@amount, @credit_card) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message end def test_failed_purchase response = @gateway.purchase(@amount, @declined_card) assert_failure response - assert_equal("Invalid Expiration Date", response.message) - assert_equal("183", response.params["error_codes"]) + assert_equal('Invalid Expiration Date', response.message) + assert_equal('183', response.params['error_codes']) end def test_successful_echeck_purchase @@ -55,7 +55,7 @@ def test_successful_echeck_purchase end def test_failed_echeck_purchase - response = @gateway.purchase(@amount, check(routing_number: "121042883"), @options) + response = @gateway.purchase(@amount, check(routing_number: '121042883'), @options) assert_failure response assert_equal 'Invalid Routing Number', response.message end @@ -66,7 +66,7 @@ def test_successful_refund refund = @gateway.refund(@amount, purchase.authorization) assert_success refund - assert_equal "Success", refund.message + assert_equal 'Success', refund.message end def test_partial_refund @@ -105,6 +105,6 @@ def test_invalid_login ) response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Invalid Login Key", response.message + assert_equal 'Invalid Login Key', response.message end end diff --git a/test/remote/gateways/remote_verifi_test.rb b/test/remote/gateways/remote_verifi_test.rb index 9580810e574..d9579c15752 100644 --- a/test/remote/gateways/remote_verifi_test.rb +++ b/test/remote/gateways/remote_verifi_test.rb @@ -11,7 +11,7 @@ def setup # Replace with your login and password for the Verifi test environment @options = { :order_id => '37', - :email => "test@example.com", + :email => 'test@example.com', :billing_address => address } diff --git a/test/remote/gateways/remote_viaklix_test.rb b/test/remote/gateways/remote_viaklix_test.rb index 319914004dc..02b2bf06df8 100644 --- a/test/remote/gateways/remote_viaklix_test.rb +++ b/test/remote/gateways/remote_viaklix_test.rb @@ -9,7 +9,7 @@ def setup @options = { :order_id => '#1000.1', - :email => "paul@domain.com", + :email => 'paul@domain.com', :description => 'Test Transaction', :billing_address => address } diff --git a/test/remote/gateways/remote_visanet_peru_test.rb b/test/remote/gateways/remote_visanet_peru_test.rb index b5402d4dad9..ff1b0160c76 100644 --- a/test/remote/gateways/remote_visanet_peru_test.rb +++ b/test/remote/gateways/remote_visanet_peru_test.rb @@ -1,22 +1,22 @@ -require "test_helper" +require 'test_helper' class RemoteVisanetPeruTest < Test::Unit::TestCase def setup @gateway = VisanetPeruGateway.new(fixtures(:visanet_peru)) @amount = 100 - @credit_card = credit_card("4500340090000016", verification_value: "377") - @declined_card = credit_card("4111111111111111") + @credit_card = credit_card('4500340090000016', verification_value: '377') + @declined_card = credit_card('4111111111111111') @options = { billing_address: address, order_id: generate_unique_id, - email: "visanetperutest@mailinator.com" + email: 'visanetperutest@mailinator.com' } end def test_invalid_login - gateway = VisanetPeruGateway.new(access_key_id: "", secret_access_key: "", merchant_id: "") + gateway = VisanetPeruGateway.new(access_key_id: '', secret_access_key: '', merchant_id: '') response = gateway.purchase(@amount, @credit_card, @options) assert_failure response end @@ -24,70 +24,70 @@ def test_invalid_login def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "OK", response.message + assert_equal 'OK', response.message assert response.authorization - assert_equal @options[:order_id], response.params["externalTransactionId"] + assert_equal @options[:order_id], response.params['externalTransactionId'] assert response.test? end def test_successful_purchase_with_merchant_define_data - options = @options.merge(merchant_define_data: { field3: "movil", field91: "101266802", field92: "TheMerchant" }) + options = @options.merge(merchant_define_data: { field3: 'movil', field91: '101266802', field92: 'TheMerchant' }) response = @gateway.purchase(@amount, @credit_card, options) assert_success response - assert_equal "OK", response.message + assert_equal 'OK', response.message end def test_successful_purchase_sans_options response = @gateway.purchase(@amount, @credit_card) assert_success response - assert_equal "OK", response.message + assert_equal 'OK', response.message end def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response assert_equal 400, response.error_code - assert_equal "Operacion Denegada.", response.message + assert_equal 'Operacion Denegada.', response.message end def test_successful_authorize_and_capture response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "OK", response.message + assert_equal 'OK', response.message assert response.authorization - assert_equal @options[:order_id], response.params["externalTransactionId"] - assert_equal "1.00", response.params["data"]["IMP_AUTORIZADO"] + assert_equal @options[:order_id], response.params['externalTransactionId'] + assert_equal '1.00', response.params['data']['IMP_AUTORIZADO'] capture = @gateway.capture(response.authorization, @options) assert_success capture - assert_equal "OK", capture.message + assert_equal 'OK', capture.message assert capture.authorization - assert_equal @options[:order_id], capture.params["externalTransactionId"] + assert_equal @options[:order_id], capture.params['externalTransactionId'] end def test_successful_authorize_fractional_amount amount = 199 response = @gateway.authorize(amount, @credit_card) assert_success response - assert_equal "OK", response.message - assert_equal "1.99", response.params["data"]["IMP_AUTORIZADO"] + assert_equal 'OK', response.message + assert_equal '1.99', response.params['data']['IMP_AUTORIZADO'] end def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response assert_equal 400, response.error_code - assert_equal "Operacion Denegada.", response.message + assert_equal 'Operacion Denegada.', response.message - @options[:email] = "cybersource@reject.com" + @options[:email] = 'cybersource@reject.com' response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response assert_equal 400, response.error_code - assert_equal "REJECT", response.message + assert_equal 'REJECT', response.message end def test_failed_capture - response = @gateway.capture("900000044") + response = @gateway.capture('900000044') assert_failure response assert_match /NUMORDEN 900000044 no se encuentra registrado/, response.message assert_equal 400, response.error_code @@ -99,7 +99,7 @@ def test_successful_refund refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "OK", refund.message + assert_equal 'OK', refund.message end def test_successful_refund_unsettled @@ -114,7 +114,7 @@ def test_successful_refund_unsettled end def test_failed_refund - response = @gateway.refund(@amount, "900000044" ) + response = @gateway.refund(@amount, '900000044' ) assert_failure response assert_match /NUMORDEN 900000044 no se encuentra registrado/, response.message assert_equal 400, response.error_code @@ -126,11 +126,11 @@ def test_successful_void void = @gateway.void(response.authorization) assert_success void - assert_equal "OK", void.message + assert_equal 'OK', void.message end def test_failed_void - response = @gateway.void("900000044") + response = @gateway.void('900000044') assert_failure response assert_match /NUMORDEN no se encuentra registrado/, response.message assert_equal 400, response.error_code @@ -139,15 +139,15 @@ def test_failed_void def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "OK", response.message - assert_equal @options[:order_id], response.params["externalTransactionId"] + assert_equal 'OK', response.message + assert_equal @options[:order_id], response.params['externalTransactionId'] end def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response assert_equal 400, response.error_code - assert_equal "Operacion Denegada.", response.message + assert_equal 'Operacion Denegada.', response.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_webpay_test.rb b/test/remote/gateways/remote_webpay_test.rb index aced3b29797..26e084f49e0 100644 --- a/test/remote/gateways/remote_webpay_test.rb +++ b/test/remote/gateways/remote_webpay_test.rb @@ -21,25 +21,25 @@ def setup def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "charge", response.params["object"] - assert response.params["paid"] + assert_equal 'charge', response.params['object'] + assert response.params['paid'] end def test_appropriate_purchase_amount assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal @amount / 100, response.params["amount"] + assert_equal @amount / 100, response.params['amount'] end def test_purchase_description - assert response = @gateway.purchase(@amount, @credit_card, { :description => "TheDescription", :email => "email@example.com" }) - assert_equal "TheDescription", response.params["description"], "Use the description if it's specified." + assert response = @gateway.purchase(@amount, @credit_card, { :description => 'TheDescription', :email => 'email@example.com' }) + assert_equal 'TheDescription', response.params['description'], "Use the description if it's specified." - assert response = @gateway.purchase(@amount, @credit_card, { :email => "email@example.com" }) - assert_equal "email@example.com", response.params["description"], "Use the email if no description is specified." + assert response = @gateway.purchase(@amount, @credit_card, { :email => 'email@example.com' }) + assert_equal 'email@example.com', response.params['description'], 'Use the email if no description is specified.' assert response = @gateway.purchase(@amount, @credit_card, { }) - assert_nil response.params["description"], "No description or email specified." + assert_nil response.params['description'], 'No description or email specified.' end def test_unsuccessful_purchase @@ -51,7 +51,7 @@ def test_unsuccessful_purchase def test_authorization_and_capture assert authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization - assert !authorization.params["captured"] + assert !authorization.params['captured'] assert capture = @gateway.capture(@amount, authorization.authorization) assert_success capture @@ -60,7 +60,7 @@ def test_authorization_and_capture def test_authorization_and_void assert authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization - assert !authorization.params["captured"] + assert !authorization.params['captured'] assert void = @gateway.void(authorization.authorization) assert_success void @@ -75,7 +75,7 @@ def test_successful_void end def test_unsuccessful_void - assert void = @gateway.void("active_merchant_fake_charge") + assert void = @gateway.void('active_merchant_fake_charge') assert_failure void assert_match 'No such charge', void.message end @@ -94,44 +94,44 @@ def test_appropriate_refund_amount assert response.authorization assert void = @gateway.refund(@refund_amount, response.authorization) assert_success void - assert_equal @refund_amount / 100, void.params["amount_refunded"] + assert_equal @refund_amount / 100, void.params['amount_refunded'] end def test_unsuccessful_refund - assert refund = @gateway.refund(@amount, "active_merchant_fake_charge") + assert refund = @gateway.refund(@amount, 'active_merchant_fake_charge') assert_failure refund assert_match 'No such charge', refund.message end def test_successful_store - assert response = @gateway.store(@credit_card, {:description => "Active Merchant Test Customer", :email => "email@example.com"}) + assert response = @gateway.store(@credit_card, {:description => 'Active Merchant Test Customer', :email => 'email@example.com'}) assert_success response - assert_equal "customer", response.params["object"] - assert_equal "Active Merchant Test Customer", response.params["description"] - assert_equal "email@example.com", response.params["email"] - assert_equal @credit_card.last_digits, response.params["active_card"]["last4"] + assert_equal 'customer', response.params['object'] + assert_equal 'Active Merchant Test Customer', response.params['description'] + assert_equal 'email@example.com', response.params['email'] + assert_equal @credit_card.last_digits, response.params['active_card']['last4'] end def test_successful_update - creation = @gateway.store(@credit_card, {:description => "Active Merchant Update Customer"}) + creation = @gateway.store(@credit_card, {:description => 'Active Merchant Update Customer'}) assert response = @gateway.update(creation.params['id'], @new_credit_card) assert_success response - assert_equal "Active Merchant Update Customer", response.params["description"] - assert_equal @new_credit_card.last_digits, response.params["active_card"]["last4"] + assert_equal 'Active Merchant Update Customer', response.params['description'] + assert_equal @new_credit_card.last_digits, response.params['active_card']['last4'] end def test_successful_unstore - creation = @gateway.store(@credit_card, {:description => "Active Merchant Unstore Customer"}) + creation = @gateway.store(@credit_card, {:description => 'Active Merchant Unstore Customer'}) assert response = @gateway.unstore(creation.params['id']) assert_success response - assert_equal true, response.params["deleted"] + assert_equal true, response.params['deleted'] end def test_invalid_login gateway = WebpayGateway.new(:login => 'active_merchant_test') assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Invalid API key provided. Check your API key is correct.", response.message + assert_equal 'Invalid API key provided. Check your API key is correct.', response.message end end diff --git a/test/remote/gateways/remote_wepay_test.rb b/test/remote/gateways/remote_wepay_test.rb index ee7fe151b30..4a1b01f061d 100644 --- a/test/remote/gateways/remote_wepay_test.rb +++ b/test/remote/gateways/remote_wepay_test.rb @@ -12,7 +12,7 @@ def setup @options = { billing_address: address, - email: "test@example.com" + email: 'test@example.com' } end @@ -53,7 +53,7 @@ def test_successful_purchase_sans_cvv end def test_successful_purchase_with_few_options - options = { address: { zip: "27701" }, email: "test@example.com" } + options = { address: { zip: '27701' }, email: 'test@example.com' } response = @gateway.purchase(@amount, @credit_card, options) assert_success response assert_equal 'Success', response.message @@ -66,12 +66,12 @@ def test_failed_purchase_sans_ccv end def test_failed_purchase_with_token - response = @gateway.purchase(@amount, "12345", @options) + response = @gateway.purchase(@amount, '12345', @options) assert_failure response end def test_successful_purchase_with_fee - response = @gateway.purchase(@amount, @credit_card, @options.merge(application_fee: 3, fee_payer: "payee")) + response = @gateway.purchase(@amount, @credit_card, @options.merge(application_fee: 3, fee_payer: 'payee')) assert_success response assert_equal 'Success', response.message end @@ -83,7 +83,7 @@ def test_successful_purchase_with_unique_id end def test_successful_purchase_with_ip_and_risk_token - response = @gateway.purchase(@amount, @credit_card, @options.merge(ip: "100.166.99.123", risk_token: "123e4567-e89b-12d3-a456-426655440000")) + response = @gateway.purchase(@amount, @credit_card, @options.merge(ip: '100.166.99.123', risk_token: '123e4567-e89b-12d3-a456-426655440000')) assert_success response assert_equal 'Success', response.message end @@ -178,7 +178,7 @@ def test_authorize_and_void authorize = @gateway.authorize(@amount, @credit_card, @options) assert_success authorize - void = @gateway.void(authorize.authorization, cancel_reason: "Cancel") + void = @gateway.void(authorize.authorization, cancel_reason: 'Cancel') assert_success void end diff --git a/test/remote/gateways/remote_wirecard_test.rb b/test/remote/gateways/remote_wirecard_test.rb index a345caa255f..f47eff22762 100644 --- a/test/remote/gateways/remote_wirecard_test.rb +++ b/test/remote/gateways/remote_wirecard_test.rb @@ -89,7 +89,7 @@ def test_successful_purchase end def test_successful_purchase_with_commerce_type - assert response = @gateway.purchase(@amount, @credit_card, @options.merge(commerce_type: "MOTO")) + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(commerce_type: 'MOTO')) assert_success response assert_match %r{THIS IS A DEMO}, response.message end @@ -105,7 +105,7 @@ def test_successful_reference_purchase end def test_utf8_description_does_not_blow_up - assert response = @gateway.purchase(@amount, @credit_card, @options.merge(description: "Habitación")) + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(description: 'Habitación')) assert_success response assert_match %r{THIS IS A DEMO}, response.message end @@ -132,11 +132,11 @@ def test_successful_purchase_with_german_address_and_valid_phone end def test_successful_cvv_result - @credit_card.verification_value = "666" # Magic Value = "Matched (correct) CVC-2" + @credit_card.verification_value = '666' # Magic Value = "Matched (correct) CVC-2" assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "M", response.cvv_result["code"] + assert_equal 'M', response.cvv_result['code'] end def test_successful_visa_avs_result @@ -151,7 +151,7 @@ def test_successful_visa_avs_result assert response = @gateway.purchase(@amount, @credit_card, @options.merge(billing_address: m_address)) assert_success response - assert_equal "M", response.avs_result["code"] + assert_equal 'M', response.avs_result['code'] end def test_successful_amex_avs_result @@ -165,7 +165,7 @@ def test_successful_amex_avs_result assert response = @gateway.purchase(@amount, @amex_card, @options.merge(billing_address: a_address)) assert_success response - assert_equal "U", response.avs_result["code"] + assert_equal 'U', response.avs_result['code'] end def test_successful_store @@ -189,13 +189,13 @@ def test_successful_store_then_purchase_by_reference end def test_successful_authorization_as_recurring_transaction_type_initial - assert response = @gateway.authorize(@amount, @credit_card, @options.merge(:recurring => "Initial")) + assert response = @gateway.authorize(@amount, @credit_card, @options.merge(:recurring => 'Initial')) assert_success response assert response.authorization end def test_successful_purchase_as_recurring_transaction_type_initial - assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:recurring => "Initial")) + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:recurring => 'Initial')) assert_success response assert response.authorization end @@ -213,21 +213,21 @@ def test_wrong_creditcard_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert response.test? assert_failure response - assert response.message[ /Credit card number not allowed in demo mode/ ], "Got wrong response message" - assert_equal "24997", response.params['ErrorCode'] + assert response.message[ /Credit card number not allowed in demo mode/ ], 'Got wrong response message' + assert_equal '24997', response.params['ErrorCode'] end def test_wrong_creditcard_store assert response = @gateway.store(@declined_card, @options) assert response.test? assert_failure response - assert response.message[ /Credit card number not allowed in demo mode/ ], "Got wrong response message" + assert response.message[ /Credit card number not allowed in demo mode/ ], 'Got wrong response message' end def test_unauthorized_capture - assert response = @gateway.capture(@amount, "1234567890123456789012") + assert response = @gateway.capture(@amount, '1234567890123456789012') assert_failure response - assert_equal "Could not find referenced transaction for GuWID 1234567890123456789012.", response.message + assert_equal 'Could not find referenced transaction for GuWID 1234567890123456789012.', response.message end def test_failed_refund @@ -243,16 +243,16 @@ def test_failed_void end def test_unauthorized_purchase - assert response = @gateway.purchase(@amount, "1234567890123456789012") + assert response = @gateway.purchase(@amount, '1234567890123456789012') assert_failure response - assert_equal "Could not find referenced transaction for GuWID 1234567890123456789012.", response.message + assert_equal 'Could not find referenced transaction for GuWID 1234567890123456789012.', response.message end def test_invalid_login gateway = WirecardGateway.new(login: '', password: '', signature: '') assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Invalid Login", response.message + assert_equal 'Invalid Login', response.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_world_net_test.rb b/test/remote/gateways/remote_world_net_test.rb index 530212fe10a..ece5f935926 100644 --- a/test/remote/gateways/remote_world_net_test.rb +++ b/test/remote/gateways/remote_world_net_test.rb @@ -25,10 +25,10 @@ def test_successful_purchase def test_successful_purchase_with_more_options options = { order_id: generate_order_id, - email: "joe@example.com", + email: 'joe@example.com', billing_address: address, description: 'Store Purchase', - ip: "127.0.0.1", + ip: '127.0.0.1', } response = @gateway.purchase(@amount, @credit_card, options) diff --git a/test/remote/gateways/remote_worldpay_online_payments_test.rb b/test/remote/gateways/remote_worldpay_online_payments_test.rb index 17d965a1716..4f0b2ff05c2 100644 --- a/test/remote/gateways/remote_worldpay_online_payments_test.rb +++ b/test/remote/gateways/remote_worldpay_online_payments_test.rb @@ -154,8 +154,8 @@ def test_failed_verify def test_invalid_login badgateway = WorldpayOnlinePaymentsGateway.new( - client_key: "T_C_NOT_VALID", - service_key: "T_S_NOT_VALID" + client_key: 'T_C_NOT_VALID', + service_key: 'T_S_NOT_VALID' ) response = badgateway.purchase(@amount, @credit_card, @options) assert_failure response diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index 5180f0b7fc6..e1cb7f3cb64 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -11,7 +11,7 @@ def setup @declined_card = credit_card('4111111111111111', :first_name => nil, :last_name => 'REFUSED') @threeDS_card = credit_card('4111111111111111', :first_name => nil, :last_name => '3D') - @options = {order_id: generate_unique_id, email: "wow@example.com"} + @options = {order_id: generate_unique_id, email: 'wow@example.com'} end def test_successful_purchase @@ -22,9 +22,9 @@ def test_successful_purchase def test_successful_purchase_with_hcg_additional_data @options.merge!(hcg_additional_data: { - key1: "value1", - key2: "value2", - key3: "value3" + key1: 'value1', + key2: 'value2', + key3: 'value3' }) assert response = @gateway.purchase(@amount, @credit_card, @options) @@ -141,41 +141,41 @@ def test_partial_address end def test_ip_address - assert_success @gateway.authorize(@amount, @credit_card, @options.merge(ip: "192.18.123.12")) + assert_success @gateway.authorize(@amount, @credit_card, @options.merge(ip: '192.18.123.12')) end def test_void assert_success(response = @gateway.authorize(@amount, @credit_card, @options)) sleep(40) assert_success (void = @gateway.void(response.authorization)) - assert_equal "SUCCESS", void.message - assert void.params["cancel_received_order_code"] + assert_equal 'SUCCESS', void.message + assert void.params['cancel_received_order_code'] end def test_void_nonexistent_transaction assert_failure response = @gateway.void('non_existent_authorization') - assert_equal "Could not find payment for order", response.message + assert_equal 'Could not find payment for order', response.message end def test_authorize_fractional_currency assert_success(result = @gateway.authorize(1234, @credit_card, @options.merge(:currency => 'USD'))) - assert_equal "USD", result.params['amount_currency_code'] - assert_equal "1234", result.params['amount_value'] - assert_equal "2", result.params['amount_exponent'] + assert_equal 'USD', result.params['amount_currency_code'] + assert_equal '1234', result.params['amount_value'] + assert_equal '2', result.params['amount_exponent'] end def test_authorize_nonfractional_currency assert_success(result = @gateway.authorize(1234, @credit_card, @options.merge(:currency => 'IDR'))) - assert_equal "IDR", result.params['amount_currency_code'] - assert_equal "12", result.params['amount_value'] - assert_equal "0", result.params['amount_exponent'] + assert_equal 'IDR', result.params['amount_currency_code'] + assert_equal '12', result.params['amount_value'] + assert_equal '0', result.params['amount_exponent'] end def test_authorize_three_decimal_currency assert_success(result = @gateway.authorize(1234, @credit_card, @options.merge(:currency => 'OMR'))) - assert_equal "OMR", result.params['amount_currency_code'] - assert_equal "1234", result.params['amount_value'] - assert_equal "3", result.params['amount_exponent'] + assert_equal 'OMR', result.params['amount_currency_code'] + assert_equal '1234', result.params['amount_value'] + assert_equal '3', result.params['amount_exponent'] end def test_reference_transaction @@ -200,8 +200,8 @@ def test_refund_fails_unless_status_is_captured end def test_refund_nonexistent_transaction - assert_failure response = @gateway.refund(@amount, "non_existent_authorization") - assert_equal "Could not find payment for order", response.message + assert_failure response = @gateway.refund(@amount, 'non_existent_authorization') + assert_equal 'Could not find payment for order', response.message end def test_successful_verify @@ -219,7 +219,7 @@ def test_failed_verify def test_successful_credit_on_cft_gateway credit = @cftgateway.credit(@amount, @credit_card, @options) assert_success credit - assert_equal "SUCCESS", credit.message + assert_equal 'SUCCESS', credit.message end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_worldpay_us_test.rb b/test/remote/gateways/remote_worldpay_us_test.rb index db2adc37c01..a0e50945fa6 100644 --- a/test/remote/gateways/remote_worldpay_us_test.rb +++ b/test/remote/gateways/remote_worldpay_us_test.rb @@ -42,7 +42,7 @@ def test_successful_echeck_purchase end def test_failed_echeck_purchase - response = @gateway.purchase(@amount, check(routing_number: "23433"), @options) + response = @gateway.purchase(@amount, check(routing_number: '23433'), @options) assert_failure response assert response.message =~ /DECLINED/ end @@ -50,12 +50,12 @@ def test_failed_echeck_purchase def test_successful_authorize_and_capture assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert_match %r(^\d+\|.+$), response.authorization assert capture = @gateway.capture(@amount, response.authorization) assert_success capture - assert_equal "Succeeded", capture.message + assert_equal 'Succeeded', capture.message end def test_failed_authorize @@ -70,7 +70,7 @@ def test_successful_refund assert refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "Succeeded", refund.message + assert_equal 'Succeeded', refund.message end def test_successful_void @@ -89,8 +89,8 @@ def test_failed_void def test_successful_verify assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Succeeded", response.message - assert_success response.responses.last, "The void should succeed" + assert_equal 'Succeeded', response.message + assert_success response.responses.last, 'The void should succeed' end def test_failed_verify @@ -107,9 +107,9 @@ def test_passing_billing_address def test_invalid_login gateway = WorldpayUsGateway.new( - :acctid => "", - :subid => "", - :merchantpin => "" + :acctid => '', + :subid => '', + :merchantpin => '' ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response diff --git a/test/support/mercury_helper.rb b/test/support/mercury_helper.rb index e52ad7bb800..a8afafa25e5 100644 --- a/test/support/mercury_helper.rb +++ b/test/support/mercury_helper.rb @@ -2,43 +2,43 @@ module MercuryHelper module BatchClosing def close_batch xml = Builder::XmlMarkup.new - xml.tag! "TStream" do - xml.tag! "Admin" do + xml.tag! 'TStream' do + xml.tag! 'Admin' do xml.tag! 'MerchantID', @options[:login] - xml.tag! 'TranCode', "BatchSummary" + xml.tag! 'TranCode', 'BatchSummary' end end xml = xml.target! - response = commit("BatchSummary", xml) + response = commit('BatchSummary', xml) xml = Builder::XmlMarkup.new - xml.tag! "TStream" do - xml.tag! "Admin" do + xml.tag! 'TStream' do + xml.tag! 'Admin' do xml.tag! 'MerchantID', @options[:login] - xml.tag! 'OperatorID', response.params["operator_id"] - xml.tag! 'TranCode', "BatchClose" - xml.tag! 'BatchNo', response.params["batch_no"] - xml.tag! 'BatchItemCount', response.params["batch_item_count"] - xml.tag! 'NetBatchTotal', response.params["net_batch_total"] - xml.tag! 'CreditPurchaseCount', response.params["credit_purchase_count"] - xml.tag! 'CreditPurchaseAmount', response.params["credit_purchase_amount"] - xml.tag! 'CreditReturnCount', response.params["credit_return_count"] - xml.tag! 'CreditReturnAmount', response.params["credit_return_amount"] - xml.tag! 'DebitPurchaseCount', response.params["debit_purchase_count"] - xml.tag! 'DebitPurchaseAmount', response.params["debit_purchase_amount"] - xml.tag! 'DebitReturnCount', response.params["debit_return_count"] - xml.tag! 'DebitReturnAmount', response.params["debit_return_amount"] + xml.tag! 'OperatorID', response.params['operator_id'] + xml.tag! 'TranCode', 'BatchClose' + xml.tag! 'BatchNo', response.params['batch_no'] + xml.tag! 'BatchItemCount', response.params['batch_item_count'] + xml.tag! 'NetBatchTotal', response.params['net_batch_total'] + xml.tag! 'CreditPurchaseCount', response.params['credit_purchase_count'] + xml.tag! 'CreditPurchaseAmount', response.params['credit_purchase_amount'] + xml.tag! 'CreditReturnCount', response.params['credit_return_count'] + xml.tag! 'CreditReturnAmount', response.params['credit_return_amount'] + xml.tag! 'DebitPurchaseCount', response.params['debit_purchase_count'] + xml.tag! 'DebitPurchaseAmount', response.params['debit_purchase_amount'] + xml.tag! 'DebitReturnCount', response.params['debit_return_count'] + xml.tag! 'DebitReturnAmount', response.params['debit_return_amount'] end end xml = xml.target! - commit("BatchClose", xml) + commit('BatchClose', xml) end def hashify_xml!(xml, response) super doc = REXML::Document.new(xml) - doc.elements.each("//BatchSummary/*") do |node| + doc.elements.each('//BatchSummary/*') do |node| response[node.name.underscore.to_sym] = node.text end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 4dec213f209..e26efecf87d 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -86,7 +86,7 @@ def assert_valid(model, message=nil) errors = model.validate clean_backtrace do - assert_equal({}, errors, (message || "Expected to be valid")) + assert_equal({}, errors, (message || 'Expected to be valid')) end errors @@ -96,7 +96,7 @@ def assert_not_valid(model) errors = model.validate clean_backtrace do - assert_not_equal({}, errors, "Expected to not be valid") + assert_not_equal({}, errors, 'Expected to not be valid') end errors @@ -123,7 +123,7 @@ def assert_no_deprecation_warning def assert_scrubbed(unexpected_value, transcript) regexp = (Regexp === unexpected_value ? unexpected_value : Regexp.new(Regexp.quote(unexpected_value.to_s))) - refute_match regexp, transcript, "Expected the value to be scrubbed out of the transcript" + refute_match regexp, transcript, 'Expected the value to be scrubbed out of the transcript' end private @@ -164,7 +164,7 @@ def credit_card(number = '4242424242424242', options = {}) end def credit_card_with_track_data(number = '4242424242424242', options = {}) - exp_date = default_expiration_date.strftime("%y%m") + exp_date = default_expiration_date.strftime('%y%m') defaults = { :track_data => "%B#{number}^LONGSEN/L. ^#{exp_date}1200000000000000**123******?", @@ -207,9 +207,9 @@ def apple_pay_payment_token(options = {}) apple_pay_json_raw = '{"version":"EC_v1","data":"","signature":""}' defaults = { payment_data: ActiveSupport::JSON.decode(apple_pay_json_raw), - payment_instrument_name: "Visa 2424", - payment_network: "Visa", - transaction_identifier: "uniqueidentifier123" + payment_instrument_name: 'Visa 2424', + payment_network: 'Visa', + transaction_identifier: 'uniqueidentifier123' }.update(options) ActiveMerchant::Billing::ApplePayPaymentToken.new(defaults[:payment_data], @@ -296,8 +296,8 @@ def dump_transcript_and_fail(gateway, amount, credit_card, params) gateway.purchase(amount, credit_card, params) end - File.open("transcript.log", "w") { |f| f.write(transcript) } - assert false, "A purchase transcript has been written to transcript.log for you to test scrubbing with." + File.open('transcript.log', 'w') { |f| f.write(transcript) } + assert false, 'A purchase transcript has been written to transcript.log for you to test scrubbing with.' end end @@ -335,15 +335,15 @@ class MockResponse attr_reader :code, :body, :message attr_accessor :headers - def self.succeeded(body, message="") + def self.succeeded(body, message='') MockResponse.new(200, body, message) end - def self.failed(body, http_status_code=422, message="") + def self.failed(body, http_status_code=422, message='') MockResponse.new(http_status_code, body, message) end - def initialize(code, body, message="", headers={}) + def initialize(code, body, message='', headers={}) @code, @body, @message, @headers = code, body, message, headers end diff --git a/test/unit/check_test.rb b/test/unit/check_test.rb index f828b434bbc..e5908553ab9 100644 --- a/test/unit/check_test.rb +++ b/test/unit/check_test.rb @@ -22,7 +22,7 @@ def test_nil_name check = Check.new(:name => nil) assert_nil check.first_name assert_nil check.last_name - assert_equal "", check.name + assert_equal '', check.name end def test_valid @@ -41,12 +41,12 @@ def test_credit_card? def test_invalid_routing_number errors = assert_not_valid Check.new(:routing_number => INVALID_ABA) - assert_equal ["is invalid"], errors[:routing_number] + assert_equal ['is invalid'], errors[:routing_number] end def test_malformed_routing_number errors = assert_not_valid Check.new(:routing_number => MALFORMED_ABA) - assert_equal ["is invalid"], errors[:routing_number] + assert_equal ['is invalid'], errors[:routing_number] end def test_account_holder_type @@ -73,7 +73,7 @@ def test_account_type assert !c.validate[:account_type] c.account_type = 'moo' - assert_equal ["must be checking or savings"], c.validate[:account_type] + assert_equal ['must be checking or savings'], c.validate[:account_type] c.account_type = nil assert !c.validate[:account_type] diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index 58f4b411b89..df2f07f2ed9 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -22,7 +22,7 @@ def test_connection_endpoint_accepts_uri def test_connection_endpoint_raises_uri_error assert_raises URI::InvalidURIError do - ActiveMerchant::Connection.new("not a URI") + ActiveMerchant::Connection.new('not a URI') end end @@ -35,19 +35,19 @@ def test_connection_passes_env_proxy_by_default end def test_connection_does_pass_requested_proxy - @connection.proxy_address = "proxy.example.com" + @connection.proxy_address = 'proxy.example.com' @connection.proxy_port = 8080 spy = Net::HTTP.new('example.com', 443) - Net::HTTP.expects(:new).with('example.com', 443, "proxy.example.com", 8080).returns(spy) + Net::HTTP.expects(:new).with('example.com', 443, 'proxy.example.com', 8080).returns(spy) spy.expects(:start).returns(true) spy.expects(:get).with('/tx.php', {'connection' => 'close'}).returns(@ok) @connection.request(:get, nil, {}) end def test_connection_does_not_mutate_headers_argument - headers = { "Content-Type" => "text/xml" }.freeze + headers = { 'Content-Type' => 'text/xml' }.freeze @connection.request(:get, nil, headers) - assert_equal({ "Content-Type" => "text/xml" }, headers) + assert_equal({ 'Content-Type' => 'text/xml' }, headers) end def test_successful_get_request @@ -161,9 +161,9 @@ def test_default_ca_file end def test_override_ca_file - @connection.ca_file = "/bogus" - assert_equal "/bogus", @connection.ca_file - assert_equal "/bogus", @connection.send(:http).ca_file + @connection.ca_file = '/bogus' + assert_equal '/bogus', @connection.ca_file + assert_equal '/bogus', @connection.send(:http).ca_file end def test_default_ca_path @@ -172,9 +172,9 @@ def test_default_ca_path end def test_override_ca_path - @connection.ca_path = "/bogus" - assert_equal "/bogus", @connection.ca_path - assert_equal "/bogus", @connection.send(:http).ca_path + @connection.ca_path = '/bogus' + assert_equal '/bogus', @connection.ca_path + assert_equal '/bogus', @connection.send(:http).ca_path end def test_unrecoverable_exception diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb index 2e99504a258..0854a059065 100644 --- a/test/unit/credit_card_methods_test.rb +++ b/test/unit/credit_card_methods_test.rb @@ -47,11 +47,11 @@ def test_should_be_able_to_identify_valid_start_years end def test_valid_start_year_can_handle_strings - assert valid_start_year?("2009") + assert valid_start_year?('2009') end def test_valid_month_can_handle_strings - assert valid_month?("1") + assert valid_month?('1') end def test_valid_expiry_year_can_handle_strings @@ -195,8 +195,8 @@ def test_matching_discover_card end def test_matching_invalid_card - assert_nil CreditCard.brand?("XXXXXXXXXXXX0000") - assert_false CreditCard.valid_number?("XXXXXXXXXXXX0000") + assert_nil CreditCard.brand?('XXXXXXXXXXXX0000') + assert_false CreditCard.valid_number?('XXXXXXXXXXXX0000') end def test_16_digit_maestro_uk diff --git a/test/unit/credit_card_test.rb b/test/unit/credit_card_test.rb index 154e1c72ee6..b39600376c9 100644 --- a/test/unit/credit_card_test.rb +++ b/test/unit/credit_card_test.rb @@ -3,8 +3,8 @@ class CreditCardTest < Test::Unit::TestCase def setup CreditCard.require_verification_value = false - @visa = credit_card("4779139500118580", :brand => "visa") - @solo = credit_card("676700000000000000", :brand => "solo", :issue_number => '01') + @visa = credit_card('4779139500118580', :brand => 'visa') + @solo = credit_card('676700000000000000', :brand => 'solo', :issue_number => '01') end def teardown @@ -14,11 +14,11 @@ def teardown def test_constructor_should_properly_assign_values c = credit_card - assert_equal "4242424242424242", c.number + assert_equal '4242424242424242', c.number assert_equal 9, c.month assert_equal Time.now.year + 1, c.year - assert_equal "Longbob Longsen", c.name - assert_equal "visa", c.brand + assert_equal 'Longbob Longsen', c.name + assert_equal 'visa', c.brand assert_valid c end @@ -55,19 +55,19 @@ def test_should_be_able_to_identify_invalid_card_numbers @visa.number = nil assert_not_valid @visa - @visa.number = "11112222333344ff" + @visa.number = '11112222333344ff' errors = assert_not_valid @visa assert !errors[:type] assert !errors[:brand] assert errors[:number] - @visa.number = "111122223333444" + @visa.number = '111122223333444' errors = assert_not_valid @visa assert !errors[:type] assert !errors[:brand] assert errors[:number] - @visa.number = "11112222333344444" + @visa.number = '11112222333344444' errors = assert_not_valid @visa assert !errors[:type] assert !errors[:brand] @@ -80,7 +80,7 @@ def test_should_have_errors_with_invalid_card_brand_for_otherwise_correct_number errors = assert_not_valid @visa assert !errors[:number] assert errors[:brand] - assert_equal ["does not match the card number"], errors[:brand] + assert_equal ['does not match the card number'], errors[:brand] end def test_should_be_invalid_when_brand_cannot_be_detected @@ -93,13 +93,13 @@ def test_should_be_invalid_when_brand_cannot_be_detected assert errors[:number] assert_equal ['is required'], errors[:number] - @visa.number = "11112222333344ff" + @visa.number = '11112222333344ff' errors = assert_not_valid @visa assert !errors[:type] assert !errors[:brand] assert errors[:number] - @visa.number = "11112222333344444" + @visa.number = '11112222333344444' errors = assert_not_valid @visa assert !errors[:brand] assert !errors[:type] @@ -107,7 +107,7 @@ def test_should_be_invalid_when_brand_cannot_be_detected end def test_should_be_a_valid_card_number - @visa.number = "4242424242424242" + @visa.number = '4242424242424242' assert_valid @visa end @@ -264,40 +264,40 @@ def test_should_require_a_valid_issue_number_for_solo_or_switch errors = assert_not_valid @solo assert errors[:start_month] - assert_equal ["cannot be empty"], errors[:issue_number] + assert_equal ['cannot be empty'], errors[:issue_number] @solo.issue_number = 3 assert_valid @solo end def test_should_require_a_validate_non_empty_issue_number_for_solo_or_switch - @solo.issue_number = "invalid" + @solo.issue_number = 'invalid' errors = assert_not_valid @solo - assert_equal ["is invalid"], errors[:issue_number] + assert_equal ['is invalid'], errors[:issue_number] @solo.issue_number = 3 assert_valid @solo end def test_should_return_last_four_digits_of_card_number - ccn = CreditCard.new(:number => "4779139500118580") - assert_equal "8580", ccn.last_digits + ccn = CreditCard.new(:number => '4779139500118580') + assert_equal '8580', ccn.last_digits end def test_bogus_last_digits - ccn = CreditCard.new(:number => "1") - assert_equal "1", ccn.last_digits + ccn = CreditCard.new(:number => '1') + assert_equal '1', ccn.last_digits end def test_should_return_first_four_digits_of_card_number - ccn = CreditCard.new(:number => "4779139500118580") - assert_equal "477913", ccn.first_digits + ccn = CreditCard.new(:number => '4779139500118580') + assert_equal '477913', ccn.first_digits end def test_should_return_first_bogus_digit_of_card_number - ccn = CreditCard.new(:number => "1") - assert_equal "1", ccn.first_digits + ccn = CreditCard.new(:number => '1') + assert_equal '1', ccn.first_digits end def test_should_be_true_when_credit_card_has_a_first_name @@ -327,42 +327,42 @@ def test_should_test_for_a_full_name def test_should_handle_full_name_when_first_or_last_is_missing c = CreditCard.new(:first_name => 'James') assert c.name? - assert_equal "James", c.name + assert_equal 'James', c.name c = CreditCard.new(:last_name => 'Herdman') assert c.name? - assert_equal "Herdman", c.name + assert_equal 'Herdman', c.name end def test_should_assign_a_full_name - c = CreditCard.new :name => "James Herdman" - assert_equal "James", c.first_name - assert_equal "Herdman", c.last_name + c = CreditCard.new :name => 'James Herdman' + assert_equal 'James', c.first_name + assert_equal 'Herdman', c.last_name - c = CreditCard.new :name => "Rocket J. Squirrel" - assert_equal "Rocket J.", c.first_name - assert_equal "Squirrel", c.last_name + c = CreditCard.new :name => 'Rocket J. Squirrel' + assert_equal 'Rocket J.', c.first_name + assert_equal 'Squirrel', c.last_name - c = CreditCard.new :name => "Twiggy" - assert_equal "", c.first_name - assert_equal "Twiggy", c.last_name - assert_equal "Twiggy", c.name + c = CreditCard.new :name => 'Twiggy' + assert_equal '', c.first_name + assert_equal 'Twiggy', c.last_name + assert_equal 'Twiggy', c.name end def test_should_remove_trailing_whitespace_on_name c = CreditCard.new(:last_name => 'Herdman') - assert_equal "Herdman", c.name + assert_equal 'Herdman', c.name c = CreditCard.new(:last_name => 'Herdman', first_name: '') - assert_equal "Herdman", c.name + assert_equal 'Herdman', c.name end def test_should_remove_leading_whitespace_on_name c = CreditCard.new(:first_name => 'James') - assert_equal "James", c.name + assert_equal 'James', c.name c = CreditCard.new(:last_name => '', first_name: 'James') - assert_equal "James", c.name + assert_equal 'James', c.name end # The following is a regression for a bug that raised an exception when @@ -411,7 +411,7 @@ def test_mask_number def test_strip_non_digit_characters card = credit_card('4242-4242 %%%%%%4242......4242') assert_valid card - assert_equal "4242424242424242", card.number + assert_equal '4242424242424242', card.number end def test_validate_handles_blank_number @@ -433,10 +433,10 @@ def test_rails_methods_are_deprecated end def test_brand_is_aliased_as_type - assert_deprecation_warning("CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead.") do + assert_deprecation_warning('CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead.') do assert_equal @visa.type, @visa.brand end - assert_deprecation_warning("CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead.") do + assert_deprecation_warning('CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead.') do assert_equal @solo.type, @solo.brand end end @@ -444,14 +444,14 @@ def test_brand_is_aliased_as_type def test_month_and_year_are_immediately_converted_to_integers card = CreditCard.new - card.month = "1" + card.month = '1' assert_equal 1, card.month - card.year = "1" + card.year = '1' assert_equal 1, card.year - card.month = "" + card.month = '' assert_nil card.month - card.year = "" + card.year = '' assert_nil card.year card.month = nil @@ -459,14 +459,14 @@ def test_month_and_year_are_immediately_converted_to_integers card.year = nil assert_nil card.year - card.start_month = "1" + card.start_month = '1' assert_equal 1, card.start_month - card.start_year = "1" + card.start_year = '1' assert_equal 1, card.start_year end def test_should_report_as_emv_if_icc_data_present - assert CreditCard.new(icc_data: "E480").emv? + assert CreditCard.new(icc_data: 'E480').emv? end def test_should_not_report_as_emv_if_icc_data_not_present diff --git a/test/unit/expiry_date_test.rb b/test/unit/expiry_date_test.rb index 9be4b731afc..0306b339447 100644 --- a/test/unit/expiry_date_test.rb +++ b/test/unit/expiry_date_test.rb @@ -25,7 +25,7 @@ def test_invalid_date end def test_month_and_year_coerced_to_integer - expiry = CreditCard::ExpiryDate.new("13", "2009") + expiry = CreditCard::ExpiryDate.new('13', '2009') assert_equal 13, expiry.month assert_equal 2009, expiry.year end diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index 958d063e729..c0e0f69b3d5 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -20,9 +20,9 @@ def setup ) @apple_pay_card = network_tokenization_credit_card('4111111111111111', - :payment_cryptogram => "YwAAAAAABaYcCMX/OhNRQAAAAAA=", - :month => "08", - :year => "2018", + :payment_cryptogram => 'YwAAAAAABaYcCMX/OhNRQAAAAAA=', + :month => '08', + :year => '2018', :source => :apple_pay, :verification_value => nil ) @@ -31,7 +31,7 @@ def setup @options = { billing_address: address(), - shopper_reference: "John Smith", + shopper_reference: 'John Smith', order_id: '345123', installments: 2 } @@ -159,7 +159,7 @@ def test_successful_store @gateway.expects(:ssl_post).returns(successful_store_response) response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "#8835205392522157#8315202663743702", response.authorization + assert_equal '#8835205392522157#8315202663743702', response.authorization end def test_failed_store @@ -224,8 +224,8 @@ def test_authorize_with_network_tokenization_credit_card response = stub_comms do @gateway.authorize(@amount, @apple_pay_card, @options) end.check_request do |endpoint, data, headers| - assert_equal "YwAAAAAABaYcCMX/OhNRQAAAAAA=", JSON.parse(data)['mpiData']['cavv'] - assert_equal "07", JSON.parse(data)['mpiData']['eci'] + assert_equal 'YwAAAAAABaYcCMX/OhNRQAAAAAA=', JSON.parse(data)['mpiData']['cavv'] + assert_equal '07', JSON.parse(data)['mpiData']['eci'] end.respond_with(successful_authorize_response) assert_success response end diff --git a/test/unit/gateways/allied_wallet_test.rb b/test/unit/gateways/allied_wallet_test.rb index 687322093ca..c3d1d390fd9 100644 --- a/test/unit/gateways/allied_wallet_test.rb +++ b/test/unit/gateways/allied_wallet_test.rb @@ -5,9 +5,9 @@ class AlliedWalletTest < Test::Unit::TestCase def setup @gateway = AlliedWalletGateway.new( - site_id: "1234", - merchant_id: "1234", - token: "token" + site_id: '1234', + merchant_id: '1234', + token: 'token' ) @credit_card = credit_card @@ -21,7 +21,7 @@ def test_successful_purchase assert_success response - assert_equal "123456", response.authorization + assert_equal '123456', response.authorization assert response.test? end @@ -31,7 +31,7 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "Declined", response.message + assert_equal 'Declined', response.message assert response.test? end @@ -41,7 +41,7 @@ def test_successful_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "123456", response.authorization + assert_equal '123456', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -56,13 +56,13 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Declined", response.message + assert_equal 'Declined', response.message assert response.test? end def test_failed_capture response = stub_comms do - @gateway.capture(100, "") + @gateway.capture(100, '') end.respond_with(failed_capture_response) assert_failure response @@ -74,7 +74,7 @@ def test_successful_void end.respond_with(successful_authorize_response) assert_success response - assert_equal "123456", response.authorization + assert_equal '123456', response.authorization void = stub_comms do @gateway.void(response.authorization) @@ -87,7 +87,7 @@ def test_successful_void def test_failed_void response = stub_comms do - @gateway.void("5d53a33d960c46d00f5dc061947d998c") + @gateway.void('5d53a33d960c46d00f5dc061947d998c') end.check_request do |endpoint, data, headers| assert_match(/5d53a33d960c46d00f5dc061947d998c/, data) end.respond_with(failed_void_response) @@ -101,7 +101,7 @@ def test_successful_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "123456", response.authorization + assert_equal '123456', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -114,7 +114,7 @@ def test_successful_refund def test_failed_refund response = stub_comms do - @gateway.refund(nil, "") + @gateway.refund(nil, '') end.respond_with(failed_refund_response) assert_failure response @@ -125,7 +125,7 @@ def test_successful_verify @gateway.verify(@credit_card) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_verify @@ -133,7 +133,7 @@ def test_failed_verify @gateway.verify(@credit_card) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "Declined", response.message + assert_equal 'Declined', response.message end def test_empty_response_fails @@ -142,7 +142,7 @@ def test_empty_response_fails end.respond_with(empty_purchase_response) assert_failure response - assert_equal "Error", response.message + assert_equal 'Error', response.message end def test_invalid_json diff --git a/test/unit/gateways/authorize_net_arb_test.rb b/test/unit/gateways/authorize_net_arb_test.rb index 8472ba1a138..1757c7c74b6 100644 --- a/test/unit/gateways/authorize_net_arb_test.rb +++ b/test/unit/gateways/authorize_net_arb_test.rb @@ -4,7 +4,7 @@ class AuthorizeNetArbTest < Test::Unit::TestCase include CommStub def setup - ActiveMerchant.expects(:deprecated).with("ARB functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it.") + ActiveMerchant.expects(:deprecated).with('ARB functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it.') @gateway = AuthorizeNetArbGateway.new( :login => 'X', :password => 'Y' @@ -25,7 +25,7 @@ def test_successful_recurring :unit => :days }, :duration => { - :start_date => Time.now.strftime("%Y-%m-%d"), + :start_date => Time.now.strftime('%Y-%m-%d'), :occurrences => 30 } ) @@ -69,8 +69,8 @@ def test_successful_status_recurring end def test_expdate_formatting - assert_equal '2009-09', @gateway.send(:expdate, credit_card('4111111111111111', :month => "9", :year => "2009")) - assert_equal '2013-11', @gateway.send(:expdate, credit_card('4111111111111111', :month => "11", :year => "2013")) + assert_equal '2009-09', @gateway.send(:expdate, credit_card('4111111111111111', :month => '9', :year => '2009')) + assert_equal '2013-11', @gateway.send(:expdate, credit_card('4111111111111111', :month => '11', :year => '2013')) end private diff --git a/test/unit/gateways/authorize_net_cim_test.rb b/test/unit/gateways/authorize_net_cim_test.rb index 472a5878d2a..64f09efd42f 100644 --- a/test/unit/gateways/authorize_net_cim_test.rb +++ b/test/unit/gateways/authorize_net_cim_test.rb @@ -46,8 +46,8 @@ def setup end def test_expdate_formatting - assert_equal '2009-09', @gateway.send(:expdate, credit_card('4111111111111111', :month => "9", :year => "2009")) - assert_equal '2013-11', @gateway.send(:expdate, credit_card('4111111111111111', :month => "11", :year => "2013")) + assert_equal '2009-09', @gateway.send(:expdate, credit_card('4111111111111111', :month => '9', :year => '2009')) + assert_equal '2013-11', @gateway.send(:expdate, credit_card('4111111111111111', :month => '11', :year => '2013')) assert_equal 'XXXX', @gateway.send(:expdate, credit_card('XXXX1234', :month => nil, :year => nil)) end @@ -58,7 +58,7 @@ def test_should_create_customer_profile_request assert_instance_of Response, response assert_success response assert_equal @customer_profile_id, response.authorization - assert_equal "Successful.", response.message + assert_equal 'Successful.', response.message end def test_should_create_customer_payment_profile_request @@ -76,7 +76,7 @@ def test_should_create_customer_payment_profile_request assert_instance_of Response, response assert_success response assert_equal @customer_payment_profile_id, response.params['customer_payment_profile_id'] - assert_equal "This output is only present if the ValidationMode input parameter is passed with a value of testMode or liveMode", response.params['validation_direct_response'] + assert_equal 'This output is only present if the ValidationMode input parameter is passed with a value of testMode or liveMode', response.params['validation_direct_response'] end def test_should_create_customer_shipping_address_request @@ -420,15 +420,15 @@ def test_should_update_customer_payment_profile_request end def test_should_update_customer_payment_profile_request_with_last_four_digits - last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => "4242") #Credit card with only last four digits + last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => '4242') #Credit card with only last four digits response = stub_comms do @gateway.update_customer_payment_profile( :customer_profile_id => @customer_profile_id, :payment_profile => { :customer_payment_profile_id => @customer_payment_profile_id, - :bill_to => address(:address1 => "345 Avenue B", - :address2 => "Apt 101"), + :bill_to => address(:address1 => '345 Avenue B', + :address2 => 'Apt 101'), :payment => { :credit_card => last_four_credit_card } @@ -510,7 +510,7 @@ def test_should_create_customer_profile_transaction_auth_capture_and_then_refund assert_failure response assert_equal 'The referenced transaction does not meet the criteria for issuing a credit.', response.params['direct_response']['message'] assert_equal 'The transaction was unsuccessful.', response.message - assert_equal "E00027", response.error_code + assert_equal 'E00027', response.error_code return response end @@ -575,8 +575,8 @@ def test_should_create_customer_profile_transaction_for_refund_request assert response = @gateway.create_customer_profile_transaction_for_refund( :transaction => { :trans_id => 1, - :amount => "1.00", - :credit_card_number_masked => "XXXX1234" + :amount => '1.00', + :credit_card_number_masked => 'XXXX1234' } ) assert_instance_of Response, response diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index ac9e793554f..9b3516bb25d 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -32,18 +32,18 @@ def setup @additional_options = { line_items: [ { - item_id: "1", - name: "mug", - description: "coffee", - quantity: "100", - unit_price: "10" + item_id: '1', + name: 'mug', + description: 'coffee', + quantity: '100', + unit_price: '10' }, { - item_id: "2", - name: "vase", - description: "floral", - quantity: "200", - unit_price: "20" + item_id: '2', + name: 'vase', + description: 'floral', + quantity: '200', + unit_price: '20' } ] } @@ -57,7 +57,7 @@ def test_add_swipe_data_with_bad_data parse(data) do |doc| assert_nil doc.at_xpath('//track1') assert_nil doc.at_xpath('//track2') - assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + assert_equal '1.00', doc.at_xpath('//transactionRequest/amount').content end end.respond_with(successful_purchase_response) end @@ -70,7 +70,7 @@ def test_add_swipe_data_with_track_1 parse(data) do |doc| assert_equal '%B378282246310005^LONGSON/LONGBOB^1705101130504392?', doc.at_xpath('//track1').content assert_nil doc.at_xpath('//track2') - assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + assert_equal '1.00', doc.at_xpath('//transactionRequest/amount').content end end.respond_with(successful_purchase_response) end @@ -83,7 +83,7 @@ def test_add_swipe_data_with_track_2 parse(data) do |doc| assert_nil doc.at_xpath('//track1') assert_equal ';4111111111111111=1803101000020000831?', doc.at_xpath('//track2').content - assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + assert_equal '1.00', doc.at_xpath('//transactionRequest/amount').content end end.respond_with(successful_purchase_response) end @@ -107,8 +107,8 @@ def test_retail_market_type_device_type_included_in_swipe_transactions_with_vali end.check_request do |endpoint, data, headers| parse(data) do |doc| assert_not_nil doc.at_xpath('//retail') - assert_equal "2", doc.at_xpath('//retail/marketType').content - assert_equal "7", doc.at_xpath('//retail/deviceType').content + assert_equal '2', doc.at_xpath('//retail/marketType').content + assert_equal '7', doc.at_xpath('//retail/deviceType').content end end.respond_with(successful_purchase_response) end @@ -122,8 +122,8 @@ def test_device_type_used_from_options_if_included_with_valid_track_data end.check_request do |endpoint, data, headers| parse(data) do |doc| assert_not_nil doc.at_xpath('//retail') - assert_equal "2", doc.at_xpath('//retail/marketType').content - assert_equal "1", doc.at_xpath('//retail/deviceType').content + assert_equal '2', doc.at_xpath('//retail/marketType').content + assert_equal '1', doc.at_xpath('//retail/deviceType').content end end.respond_with(successful_purchase_response) end @@ -148,7 +148,7 @@ def test_moto_market_type_included_when_card_is_entered_manually end.check_request do |endpoint, data, headers| parse(data) do |doc| assert_not_nil doc.at_xpath('//retail') - assert_equal "1", doc.at_xpath('//retail/marketType').content + assert_equal '1', doc.at_xpath('//retail/marketType').content end end.respond_with(successful_purchase_response) end @@ -158,7 +158,7 @@ def test_market_type_can_be_specified @gateway.purchase(@amount, @credit_card, market_type: 0) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "0", doc.at_xpath('//retail/marketType').content + assert_equal '0', doc.at_xpath('//retail/marketType').content end end.respond_with(successful_purchase_response) end @@ -168,13 +168,13 @@ def test_successful_echeck_authorization @gateway.authorize(@amount, @check) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_not_nil doc.at_xpath("//payment/bankAccount") - assert_equal "244183602", doc.at_xpath("//routingNumber").content - assert_equal "15378535", doc.at_xpath("//accountNumber").content - assert_equal "Bank of Elbonia", doc.at_xpath("//bankName").content - assert_equal "Jim Smith", doc.at_xpath("//nameOnAccount").content - assert_equal "1", doc.at_xpath("//checkNumber").content - assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + assert_not_nil doc.at_xpath('//payment/bankAccount') + assert_equal '244183602', doc.at_xpath('//routingNumber').content + assert_equal '15378535', doc.at_xpath('//accountNumber').content + assert_equal 'Bank of Elbonia', doc.at_xpath('//bankName').content + assert_equal 'Jim Smith', doc.at_xpath('//nameOnAccount').content + assert_equal '1', doc.at_xpath('//checkNumber').content + assert_equal '1.00', doc.at_xpath('//transactionRequest/amount').content end end.respond_with(successful_authorize_response) @@ -189,13 +189,13 @@ def test_successful_echeck_purchase @gateway.purchase(@amount, @check) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_not_nil doc.at_xpath("//payment/bankAccount") - assert_equal "244183602", doc.at_xpath("//routingNumber").content - assert_equal "15378535", doc.at_xpath("//accountNumber").content - assert_equal "Bank of Elbonia", doc.at_xpath("//bankName").content - assert_equal "Jim Smith", doc.at_xpath("//nameOnAccount").content - assert_equal "1", doc.at_xpath("//checkNumber").content - assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + assert_not_nil doc.at_xpath('//payment/bankAccount') + assert_equal '244183602', doc.at_xpath('//routingNumber').content + assert_equal '15378535', doc.at_xpath('//accountNumber').content + assert_equal 'Bank of Elbonia', doc.at_xpath('//bankName').content + assert_equal 'Jim Smith', doc.at_xpath('//nameOnAccount').content + assert_equal '1', doc.at_xpath('//checkNumber').content + assert_equal '1.00', doc.at_xpath('//transactionRequest/amount').content end end.respond_with(successful_purchase_response) @@ -209,7 +209,7 @@ def test_echeck_passing_recurring_flag response = stub_comms do @gateway.purchase(@amount, @check, recurring: true) end.check_request do |endpoint, data, headers| - assert_equal settings_from_doc(parse(data))["recurringBilling"], "true" + assert_equal settings_from_doc(parse(data))['recurringBilling'], 'true' end.respond_with(successful_purchase_response) assert_success response @@ -227,8 +227,8 @@ def test_successful_apple_pay_authorization @gateway.authorize(@amount, @apple_pay_payment_token) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal @gateway.class::APPLE_PAY_DATA_DESCRIPTOR, doc.at_xpath("//opaqueData/dataDescriptor").content - assert_equal Base64.strict_encode64(@apple_pay_payment_token.payment_data.to_json), doc.at_xpath("//opaqueData/dataValue").content + assert_equal @gateway.class::APPLE_PAY_DATA_DESCRIPTOR, doc.at_xpath('//opaqueData/dataDescriptor').content + assert_equal Base64.strict_encode64(@apple_pay_payment_token.payment_data.to_json), doc.at_xpath('//opaqueData/dataValue').content end end.respond_with(successful_authorize_response) @@ -243,8 +243,8 @@ def test_successful_apple_pay_purchase @gateway.purchase(@amount, @apple_pay_payment_token) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal @gateway.class::APPLE_PAY_DATA_DESCRIPTOR, doc.at_xpath("//opaqueData/dataDescriptor").content - assert_equal Base64.strict_encode64(@apple_pay_payment_token.payment_data.to_json), doc.at_xpath("//opaqueData/dataValue").content + assert_equal @gateway.class::APPLE_PAY_DATA_DESCRIPTOR, doc.at_xpath('//opaqueData/dataDescriptor').content + assert_equal Base64.strict_encode64(@apple_pay_payment_token.payment_data.to_json), doc.at_xpath('//opaqueData/dataValue').content end end.respond_with(successful_purchase_response) @@ -318,7 +318,7 @@ def test_passes_email_customer def test_passes_header_email_receipt stub_comms do - @gateway.purchase(@amount, credit_card, header_email_receipt: "yet another field") + @gateway.purchase(@amount, credit_card, header_email_receipt: 'yet another field') end.check_request do |endpoint, data, headers| assert_match(/<settingName>headerEmailReceipt<\/settingName>/, data) assert_match(/<settingValue>yet another field<\/settingValue>/, data) @@ -373,7 +373,7 @@ def test_live_gateway_cannot_use_test_mode_on_auth_dot_net_server real_gateway.stubs(:ssl_post).returns(successful_purchase_response_test_mode) response = real_gateway.purchase(@amount, @credit_card) assert_failure response - assert_equal "Using a live Authorize.net account in Test Mode is not permitted.", response.message + assert_equal 'Using a live Authorize.net account in Test Mode is not permitted.', response.message end def test_successful_purchase_using_stored_card @@ -402,8 +402,8 @@ def test_failed_purchase_using_stored_card response = @gateway.purchase(@amount, store.authorization) assert_failure response - assert_equal "The credit card number is invalid.", response.message - assert_equal "6", response.params["response_reason_code"] + assert_equal 'The credit card number is invalid.', response.message + assert_equal '6', response.params['response_reason_code'] end def test_failed_authorize @@ -421,13 +421,13 @@ def test_successful_authorize_and_capture_using_stored_card @gateway.expects(:ssl_post).returns(successful_authorize_using_stored_card_response) auth = @gateway.authorize(@amount, store.authorization) assert_success auth - assert_equal "This transaction has been approved.", auth.message + assert_equal 'This transaction has been approved.', auth.message @gateway.expects(:ssl_post).returns(successful_capture_using_stored_card_response) capture = @gateway.capture(@amount, auth.authorization) assert_success capture - assert_equal "This transaction has been approved.", capture.message + assert_equal 'This transaction has been approved.', capture.message end def test_failed_authorize_using_stored_card @@ -437,8 +437,8 @@ def test_failed_authorize_using_stored_card @gateway.expects(:ssl_post).returns(failed_authorize_using_stored_card_response) response = @gateway.authorize(@amount, store.authorization) assert_failure response - assert_equal "The credit card number is invalid.", response.message - assert_equal "6", response.params["response_reason_code"] + assert_equal 'The credit card number is invalid.', response.message + assert_equal '6', response.params['response_reason_code'] end def test_successful_capture @@ -501,7 +501,7 @@ def test_successful_void_using_stored_card @gateway.expects(:ssl_post).returns(successful_void_using_stored_card_response) void = @gateway.void(auth.authorization) assert_success void - assert_equal "This transaction has been approved.", void.message + assert_equal 'This transaction has been approved.', void.message end def test_failed_void_using_stored_card @@ -514,7 +514,7 @@ def test_failed_void_using_stored_card @gateway.expects(:ssl_post).returns(failed_void_using_stored_card_response) void = @gateway.void(auth.authorization) assert_failure void - assert_equal "This transaction has already been voided.", void.message + assert_equal 'This transaction has already been voided.', void.message end def test_successful_verify @@ -553,7 +553,7 @@ def test_failed_refund_using_stored_card @gateway.expects(:ssl_post).returns(failed_refund_using_stored_card_response) refund = @gateway.refund(@amount, purchase.authorization) assert_failure refund - assert_equal "The record cannot be found", refund.message + assert_equal 'The record cannot be found', refund.message end def test_failed_refund_due_to_unsettled_payment @@ -584,9 +584,9 @@ def test_successful_store store = @gateway.store(@credit_card, @options) assert_success store - assert_equal "Successful", store.message - assert_equal "35959426", store.params["customer_profile_id"] - assert_equal "32506918", store.params["customer_payment_profile_id"] + assert_equal 'Successful', store.message + assert_equal '35959426', store.params['customer_profile_id'] + assert_equal '32506918', store.params['customer_payment_profile_id'] end def test_failed_store @@ -595,7 +595,7 @@ def test_failed_store store = @gateway.store(@credit_card, @options) assert_failure store assert_match(/The field length is invalid/, store.message) - assert_equal("15", store.params["message_code"]) + assert_equal('15', store.params['message_code']) end def test_successful_unstore @@ -603,11 +603,11 @@ def test_successful_unstore @gateway.unstore('35959426#32506918#cim_store') end.check_request do |endpoint, data, headers| doc = parse(data) - assert_equal "35959426", doc.at_xpath("//deleteCustomerProfileRequest/customerProfileId").content + assert_equal '35959426', doc.at_xpath('//deleteCustomerProfileRequest/customerProfileId').content end.respond_with(successful_unstore_response) assert_success response - assert_equal "Successful", response.message + assert_equal 'Successful', response.message end def test_failed_unstore @@ -616,7 +616,7 @@ def test_failed_unstore unstore = @gateway.unstore('35959426#32506918#cim_store') assert_failure unstore assert_match(/The record cannot be found/, unstore.message) - assert_equal("40", unstore.params["message_code"]) + assert_equal('40', unstore.params['message_code']) end def test_successful_store_new_payment_profile @@ -624,9 +624,9 @@ def test_successful_store_new_payment_profile store = @gateway.store(@credit_card, @options) assert_success store - assert_equal "Successful", store.message - assert_equal "38392170", store.params["customer_profile_id"] - assert_equal "34896759", store.params["customer_payment_profile_id"] + assert_equal 'Successful', store.message + assert_equal '38392170', store.params['customer_profile_id'] + assert_equal '34896759', store.params['customer_payment_profile_id'] end def test_failed_store_new_payment_profile @@ -634,9 +634,9 @@ def test_failed_store_new_payment_profile store = @gateway.store(@credit_card, @options) assert_failure store - assert_equal "A duplicate customer payment profile already exists", store.message - assert_equal "38392767", store.params["customer_profile_id"] - assert_equal "34897359", store.params["customer_payment_profile_id"] + assert_equal 'A duplicate customer payment profile already exists', store.message + assert_equal '38392767', store.params['customer_profile_id'] + assert_equal '34897359', store.params['customer_payment_profile_id'] end def test_address @@ -644,11 +644,11 @@ def test_address @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', country: 'US', state: 'CO', phone: '(555)555-5555', fax: '(555)555-4444'}) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "CO", doc.at_xpath("//billTo/state").content, data - assert_equal "164 Waverley Street", doc.at_xpath("//billTo/address").content, data - assert_equal "US", doc.at_xpath("//billTo/country").content, data - assert_equal "(555)555-5555", doc.at_xpath("//billTo/phoneNumber").content - assert_equal "(555)555-4444", doc.at_xpath("//billTo/faxNumber").content + assert_equal 'CO', doc.at_xpath('//billTo/state').content, data + assert_equal '164 Waverley Street', doc.at_xpath('//billTo/address').content, data + assert_equal 'US', doc.at_xpath('//billTo/country').content, data + assert_equal '(555)555-5555', doc.at_xpath('//billTo/phoneNumber').content + assert_equal '(555)555-4444', doc.at_xpath('//billTo/faxNumber').content end end.respond_with(successful_authorize_response) end @@ -658,11 +658,11 @@ def test_address_with_empty_billing_address @gateway.authorize(@amount, @credit_card) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "", doc.at_xpath("//billTo/address").content, data - assert_equal "", doc.at_xpath("//billTo/city").content, data - assert_equal "n/a", doc.at_xpath("//billTo/state").content, data - assert_equal "", doc.at_xpath("//billTo/zip").content, data - assert_equal "", doc.at_xpath("//billTo/country").content, data + assert_equal '', doc.at_xpath('//billTo/address').content, data + assert_equal '', doc.at_xpath('//billTo/city').content, data + assert_equal 'n/a', doc.at_xpath('//billTo/state').content, data + assert_equal '', doc.at_xpath('//billTo/zip').content, data + assert_equal '', doc.at_xpath('//billTo/country').content, data end end.respond_with(successful_authorize_response) end @@ -672,11 +672,11 @@ def test_address_with_address2_present @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', address2: 'Apt 1234', country: 'US', state: 'CO', phone: '(555)555-5555', fax: '(555)555-4444'}) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "CO", doc.at_xpath("//billTo/state").content, data - assert_equal "164 Waverley Street Apt 1234", doc.at_xpath("//billTo/address").content, data - assert_equal "US", doc.at_xpath("//billTo/country").content, data - assert_equal "(555)555-5555", doc.at_xpath("//billTo/phoneNumber").content - assert_equal "(555)555-4444", doc.at_xpath("//billTo/faxNumber").content + assert_equal 'CO', doc.at_xpath('//billTo/state').content, data + assert_equal '164 Waverley Street Apt 1234', doc.at_xpath('//billTo/address').content, data + assert_equal 'US', doc.at_xpath('//billTo/country').content, data + assert_equal '(555)555-5555', doc.at_xpath('//billTo/phoneNumber').content + assert_equal '(555)555-4444', doc.at_xpath('//billTo/faxNumber').content end end.respond_with(successful_authorize_response) end @@ -686,9 +686,9 @@ def test_address_north_america_with_defaults @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', country: 'US'}) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "NC", doc.at_xpath("//billTo/state").content, data - assert_equal "164 Waverley Street", doc.at_xpath("//billTo/address").content, data - assert_equal "US", doc.at_xpath("//billTo/country").content, data + assert_equal 'NC', doc.at_xpath('//billTo/state').content, data + assert_equal '164 Waverley Street', doc.at_xpath('//billTo/address').content, data + assert_equal 'US', doc.at_xpath('//billTo/country').content, data end end.respond_with(successful_authorize_response) end @@ -698,9 +698,9 @@ def test_address_outsite_north_america @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', country: 'DE'}) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "n/a", doc.at_xpath("//billTo/state").content, data - assert_equal "164 Waverley Street", doc.at_xpath("//billTo/address").content, data - assert_equal "DE", doc.at_xpath("//billTo/country").content, data + assert_equal 'n/a', doc.at_xpath('//billTo/state').content, data + assert_equal '164 Waverley Street', doc.at_xpath('//billTo/address').content, data + assert_equal 'DE', doc.at_xpath('//billTo/country').content, data end end.respond_with(successful_authorize_response) end @@ -710,9 +710,9 @@ def test_address_outsite_north_america_with_address2_present @gateway.authorize(@amount, @credit_card, billing_address: {address1: '164 Waverley Street', address2: 'Apt 1234', country: 'DE'}) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "n/a", doc.at_xpath("//billTo/state").content, data - assert_equal "164 Waverley Street Apt 1234", doc.at_xpath("//billTo/address").content, data - assert_equal "DE", doc.at_xpath("//billTo/country").content, data + assert_equal 'n/a', doc.at_xpath('//billTo/state').content, data + assert_equal '164 Waverley Street Apt 1234', doc.at_xpath('//billTo/address').content, data + assert_equal 'DE', doc.at_xpath('//billTo/country').content, data end end.respond_with(successful_authorize_response) end @@ -721,13 +721,13 @@ def test_duplicate_window stub_comms do @gateway.purchase(@amount, @credit_card, duplicate_window: 0) end.check_request do |endpoint, data, headers| - assert_equal settings_from_doc(parse(data))["duplicateWindow"], "0" + assert_equal settings_from_doc(parse(data))['duplicateWindow'], '0' end.respond_with(successful_purchase_response) end def test_duplicate_window_class_attribute_deprecated @gateway.class.duplicate_window = 0 - assert_deprecation_warning("Using the duplicate_window class_attribute is deprecated. Use the transaction options hash instead.") do + assert_deprecation_warning('Using the duplicate_window class_attribute is deprecated. Use the transaction options hash instead.') do stub_comms do @gateway.purchase(@amount, @credit_card) end.respond_with(successful_purchase_response) @@ -738,12 +738,12 @@ def test_duplicate_window_class_attribute_deprecated def test_add_cardholder_authentication_value stub_comms do - @gateway.purchase(@amount, @credit_card, cardholder_authentication_value: 'E0Mvq8AAABEiMwARIjNEVWZ3iJk=', authentication_indicator: "2") + @gateway.purchase(@amount, @credit_card, cardholder_authentication_value: 'E0Mvq8AAABEiMwARIjNEVWZ3iJk=', authentication_indicator: '2') end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "E0Mvq8AAABEiMwARIjNEVWZ3iJk=", doc.at_xpath("//cardholderAuthentication/cardholderAuthenticationValue").content - assert_equal "2", doc.at_xpath("//cardholderAuthentication/authenticationIndicator").content - assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + assert_equal 'E0Mvq8AAABEiMwARIjNEVWZ3iJk=', doc.at_xpath('//cardholderAuthentication/cardholderAuthenticationValue').content + assert_equal '2', doc.at_xpath('//cardholderAuthentication/authenticationIndicator').content + assert_equal '1.00', doc.at_xpath('//transactionRequest/amount').content end end.respond_with(successful_purchase_response) end @@ -754,9 +754,9 @@ def test_alternative_three_d_secure_options @gateway.purchase(@amount, @credit_card, three_d_secure: three_d_secure_opts) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "E0Mvq8AAABEiMwARIjNEVWZ3iJk=", doc.at_xpath("//cardholderAuthentication/cardholderAuthenticationValue").content - assert_equal "2", doc.at_xpath("//cardholderAuthentication/authenticationIndicator").content - assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + assert_equal 'E0Mvq8AAABEiMwARIjNEVWZ3iJk=', doc.at_xpath('//cardholderAuthentication/cardholderAuthenticationValue').content + assert_equal '2', doc.at_xpath('//cardholderAuthentication/authenticationIndicator').content + assert_equal '1.00', doc.at_xpath('//transactionRequest/amount').content end end.respond_with(successful_purchase_response) end @@ -768,27 +768,27 @@ def test_prioritize_authentication_value_params @amount, @credit_card, cardholder_authentication_value: 'E0Mvq8AAABEiMwARIjNEVWZ3iJk=', - authentication_indicator: "2", + authentication_indicator: '2', three_d_secure: three_d_secure_opts ) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "E0Mvq8AAABEiMwARIjNEVWZ3iJk=", doc.at_xpath("//cardholderAuthentication/cardholderAuthenticationValue").content - assert_equal "2", doc.at_xpath("//cardholderAuthentication/authenticationIndicator").content - assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + assert_equal 'E0Mvq8AAABEiMwARIjNEVWZ3iJk=', doc.at_xpath('//cardholderAuthentication/cardholderAuthenticationValue').content + assert_equal '2', doc.at_xpath('//cardholderAuthentication/authenticationIndicator').content + assert_equal '1.00', doc.at_xpath('//transactionRequest/amount').content end end.respond_with(successful_purchase_response) end def test_capture_passing_extra_info response = stub_comms do - @gateway.capture(50, '123456789', description: "Yo", order_id: "Sweetness") + @gateway.capture(50, '123456789', description: 'Yo', order_id: 'Sweetness') end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_not_nil doc.at_xpath("//order/description"), data - assert_equal "Yo", doc.at_xpath("//order/description").content, data - assert_equal "Sweetness", doc.at_xpath("//order/invoiceNumber").content, data - assert_equal "0.50", doc.at_xpath("//transactionRequest/amount").content + assert_not_nil doc.at_xpath('//order/description'), data + assert_equal 'Yo', doc.at_xpath('//order/description').content, data + assert_equal 'Sweetness', doc.at_xpath('//order/invoiceNumber').content, data + assert_equal '0.50', doc.at_xpath('//transactionRequest/amount').content end end.respond_with(successful_capture_response) assert_success response @@ -805,15 +805,15 @@ def test_successful_refund def test_refund_passing_extra_info response = stub_comms do - @gateway.refund(50, '123456789', card_number: @credit_card.number, first_name: "Bob", last_name: "Smith", zip: "12345", order_id: "1", description: "Refund for order 1") + @gateway.refund(50, '123456789', card_number: @credit_card.number, first_name: 'Bob', last_name: 'Smith', zip: '12345', order_id: '1', description: 'Refund for order 1') end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "Bob", doc.at_xpath("//billTo/firstName").content, data - assert_equal "Smith", doc.at_xpath("//billTo/lastName").content, data - assert_equal "12345", doc.at_xpath("//billTo/zip").content, data - assert_equal "0.50", doc.at_xpath("//transactionRequest/amount").content - assert_equal "1", doc.at_xpath("//transactionRequest/order/invoiceNumber").content - assert_equal "Refund for order 1", doc.at_xpath("//transactionRequest/order/description").content + assert_equal 'Bob', doc.at_xpath('//billTo/firstName').content, data + assert_equal 'Smith', doc.at_xpath('//billTo/lastName').content, data + assert_equal '12345', doc.at_xpath('//billTo/zip').content, data + assert_equal '0.50', doc.at_xpath('//transactionRequest/amount').content + assert_equal '1', doc.at_xpath('//transactionRequest/order/invoiceNumber').content + assert_equal 'Refund for order 1', doc.at_xpath('//transactionRequest/order/description').content end end.respond_with(successful_purchase_response) assert_success response @@ -835,7 +835,7 @@ def test_successful_credit assert_success response assert_equal '2230004436', response.authorization.split('#')[0] - assert_equal "This transaction has been approved", response.message + assert_equal 'This transaction has been approved', response.message end def test_failed_credit @@ -843,7 +843,7 @@ def test_failed_credit response = @gateway.credit(@amount, @credit_card) assert_failure response - assert_equal "The credit card number is invalid", response.message + assert_equal 'The credit card number is invalid', response.message end def test_supported_countries @@ -858,7 +858,7 @@ def test_failure_without_response_reason_text response = stub_comms do @gateway.purchase(@amount, @credit_card) end.respond_with(no_message_response) - assert_equal "", response.message + assert_equal '', response.message end def test_response_under_review_by_fraud_service @@ -867,7 +867,7 @@ def test_response_under_review_by_fraud_service response = @gateway.purchase(@amount, @credit_card) assert_success response assert response.fraud_review? - assert_equal "Thank you! For security reasons your order is currently being reviewed", response.message + assert_equal 'Thank you! For security reasons your order is currently being reviewed', response.message end def test_avs_result @@ -898,17 +898,17 @@ def test_message response = stub_comms do @gateway.purchase(@amount, @credit_card) end.respond_with(no_match_cvv_response) - assert_equal "CVV does not match", response.message + assert_equal 'CVV does not match', response.message response = stub_comms do @gateway.purchase(@amount, @credit_card) end.respond_with(no_match_avs_response) - assert_equal "Street address matches, but 5-digit and 9-digit postal code do not match.", response.message + assert_equal 'Street address matches, but 5-digit and 9-digit postal code do not match.', response.message response = stub_comms do @gateway.purchase(@amount, @credit_card) end.respond_with(failed_purchase_response) - assert_equal "The credit card number is invalid", response.message + assert_equal 'The credit card number is invalid', response.message end def test_solution_id_is_added_to_post_data_parameters @@ -917,8 +917,8 @@ def test_solution_id_is_added_to_post_data_parameters @gateway.authorize(@amount, @credit_card) end.check_request do |endpoint, data, headers| doc = parse(data) - assert_equal "A1000000", fields_from_doc(doc)["x_solution_id"], data - assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + assert_equal 'A1000000', fields_from_doc(doc)['x_solution_id'], data + assert_equal '1.00', doc.at_xpath('//transactionRequest/amount').content end.respond_with(successful_authorize_response) ensure @gateway.class.application_id = nil @@ -927,7 +927,7 @@ def test_solution_id_is_added_to_post_data_parameters def test_alternate_currency @gateway.expects(:ssl_post).returns(successful_purchase_response) - response = @gateway.purchase(@amount, @credit_card, currency: "GBP") + response = @gateway.purchase(@amount, @credit_card, currency: 'GBP') assert_success response end @@ -937,81 +937,81 @@ def assert_no_has_customer_id(data) def test_include_cust_id_for_numeric_values stub_comms do - @gateway.purchase(@amount, @credit_card, customer: "123") + @gateway.purchase(@amount, @credit_card, customer: '123') end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_not_nil doc.at_xpath("//customer/id"), data - assert_equal "123", doc.at_xpath("//customer/id").content, data - assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + assert_not_nil doc.at_xpath('//customer/id'), data + assert_equal '123', doc.at_xpath('//customer/id').content, data + assert_equal '1.00', doc.at_xpath('//transactionRequest/amount').content end end.respond_with(successful_authorize_response) end def test_include_cust_id_for_word_character_values stub_comms do - @gateway.purchase(@amount, @credit_card, customer: "4840_TT") + @gateway.purchase(@amount, @credit_card, customer: '4840_TT') end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_not_nil doc.at_xpath("//customer/id"), data - assert_equal "4840_TT", doc.at_xpath("//customer/id").content, data - assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + assert_not_nil doc.at_xpath('//customer/id'), data + assert_equal '4840_TT', doc.at_xpath('//customer/id').content, data + assert_equal '1.00', doc.at_xpath('//transactionRequest/amount').content end end.respond_with(successful_authorize_response) end def test_dont_include_cust_id_for_email_addresses stub_comms do - @gateway.purchase(@amount, @credit_card, customer: "bob@test.com") + @gateway.purchase(@amount, @credit_card, customer: 'bob@test.com') end.check_request do |endpoint, data, headers| doc = parse(data) - assert !doc.at_xpath("//customer/id"), data - assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + assert !doc.at_xpath('//customer/id'), data + assert_equal '1.00', doc.at_xpath('//transactionRequest/amount').content end.respond_with(successful_authorize_response) end def test_dont_include_cust_id_for_phone_numbers stub_comms do - @gateway.purchase(@amount, @credit_card, customer: "111-123-1231") + @gateway.purchase(@amount, @credit_card, customer: '111-123-1231') end.check_request do |endpoint, data, headers| doc = parse(data) - assert !doc.at_xpath("//customer/id"), data - assert_equal "1.00", doc.at_xpath("//transactionRequest/amount").content + assert !doc.at_xpath('//customer/id'), data + assert_equal '1.00', doc.at_xpath('//transactionRequest/amount').content end.respond_with(successful_authorize_response) end def test_includes_shipping_name_when_different_from_billing_name card = credit_card('4242424242424242', - first_name: "billing", - last_name: "name") + first_name: 'billing', + last_name: 'name') options = { - order_id: "a" * 21, - billing_address: address(name: "billing name"), - shipping_address: address(name: "shipping lastname") + order_id: 'a' * 21, + billing_address: address(name: 'billing name'), + shipping_address: address(name: 'shipping lastname') } stub_comms do @gateway.purchase(@amount, card, options) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "billing", doc.at_xpath("//billTo/firstName").text - assert_equal "name", doc.at_xpath("//billTo/lastName").text - assert_equal "shipping", doc.at_xpath("//shipTo/firstName").text - assert_equal "lastname", doc.at_xpath("//shipTo/lastName").text + assert_equal 'billing', doc.at_xpath('//billTo/firstName').text + assert_equal 'name', doc.at_xpath('//billTo/lastName').text + assert_equal 'shipping', doc.at_xpath('//shipTo/firstName').text + assert_equal 'lastname', doc.at_xpath('//shipTo/lastName').text end end.respond_with(successful_purchase_response) end def test_includes_shipping_name_when_passed_as_options card = credit_card('4242424242424242', - first_name: "billing", - last_name: "name") + first_name: 'billing', + last_name: 'name') - shipping_address = address(first_name: "shipping", last_name: "lastname") + shipping_address = address(first_name: 'shipping', last_name: 'lastname') shipping_address.delete(:name) options = { - order_id: "a" * 21, - billing_address: address(name: "billing name"), + order_id: 'a' * 21, + billing_address: address(name: 'billing name'), shipping_address: shipping_address } @@ -1019,55 +1019,55 @@ def test_includes_shipping_name_when_passed_as_options @gateway.purchase(@amount, card, options) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "billing", doc.at_xpath("//billTo/firstName").text - assert_equal "name", doc.at_xpath("//billTo/lastName").text - assert_equal "shipping", doc.at_xpath("//shipTo/firstName").text - assert_equal "lastname", doc.at_xpath("//shipTo/lastName").text + assert_equal 'billing', doc.at_xpath('//billTo/firstName').text + assert_equal 'name', doc.at_xpath('//billTo/lastName').text + assert_equal 'shipping', doc.at_xpath('//shipTo/firstName').text + assert_equal 'lastname', doc.at_xpath('//shipTo/lastName').text end end.respond_with(successful_purchase_response) end def test_truncation card = credit_card('4242424242424242', - first_name: "a" * 51, - last_name: "a" * 51, + first_name: 'a' * 51, + last_name: 'a' * 51, ) options = { - order_id: "a" * 21, - description: "a" * 256, + order_id: 'a' * 21, + description: 'a' * 256, billing_address: address( - company: "a" * 51, - address1: "a" * 61, - city: "a" * 41, - state: "a" * 41, - zip: "a" * 21, - country: "a" * 61, + company: 'a' * 51, + address1: 'a' * 61, + city: 'a' * 41, + state: 'a' * 41, + zip: 'a' * 21, + country: 'a' * 61, ), shipping_address: address( - name: ["a" * 51, "a" * 51].join(" "), - company: "a" * 51, - address1: "a" * 61, - city: "a" * 41, - state: "a" * 41, - zip: "a" * 21, - country: "a" * 61, + name: ['a' * 51, 'a' * 51].join(' '), + company: 'a' * 51, + address1: 'a' * 61, + city: 'a' * 41, + state: 'a' * 41, + zip: 'a' * 21, + country: 'a' * 61, ) } stub_comms do @gateway.purchase(@amount, card, options) end.check_request do |endpoint, data, headers| - assert_truncated(data, 20, "//refId") - assert_truncated(data, 255, "//description") - assert_address_truncated(data, 50, "firstName") - assert_address_truncated(data, 50, "lastName") - assert_address_truncated(data, 50, "company") - assert_address_truncated(data, 60, "address") - assert_address_truncated(data, 40, "city") - assert_address_truncated(data, 40, "state") - assert_address_truncated(data, 20, "zip") - assert_address_truncated(data, 60, "country") + assert_truncated(data, 20, '//refId') + assert_truncated(data, 255, '//description') + assert_address_truncated(data, 50, 'firstName') + assert_address_truncated(data, 50, 'lastName') + assert_address_truncated(data, 50, 'company') + assert_address_truncated(data, 60, 'address') + assert_address_truncated(data, 40, 'city') + assert_address_truncated(data, 40, 'state') + assert_address_truncated(data, 20, 'zip') + assert_address_truncated(data, 60, 'country') end.respond_with(successful_purchase_response) end @@ -1104,15 +1104,15 @@ def test_supports_scrubbing? def test_successful_apple_pay_authorization_with_network_tokenization credit_card = network_tokenization_credit_card('4242424242424242', - :payment_cryptogram => "111111111100cryptogram" + :payment_cryptogram => '111111111100cryptogram' ) response = stub_comms do @gateway.authorize(@amount, credit_card) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal credit_card.payment_cryptogram, doc.at_xpath("//creditCard/cryptogram").content - assert_equal credit_card.number, doc.at_xpath("//creditCard/cardNumber").content + assert_equal credit_card.payment_cryptogram, doc.at_xpath('//creditCard/cryptogram').content + assert_equal credit_card.number, doc.at_xpath('//creditCard/cardNumber').content end end.respond_with(successful_authorize_response) @@ -1124,15 +1124,15 @@ def test_successful_apple_pay_authorization_with_network_tokenization def test_failed_apple_pay_authorization_with_network_tokenization_not_supported credit_card = network_tokenization_credit_card('4242424242424242', - :payment_cryptogram => "111111111100cryptogram" + :payment_cryptogram => '111111111100cryptogram' ) response = stub_comms do @gateway.authorize(@amount, credit_card) end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal credit_card.payment_cryptogram, doc.at_xpath("//creditCard/cryptogram").content - assert_equal credit_card.number, doc.at_xpath("//creditCard/cardNumber").content + assert_equal credit_card.payment_cryptogram, doc.at_xpath('//creditCard/cryptogram').content + assert_equal credit_card.number, doc.at_xpath('//creditCard/cardNumber').content end end.respond_with(network_tokenization_not_supported_response) @@ -1144,10 +1144,10 @@ def test_supports_network_tokenization_true @gateway.supports_network_tokenization? end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "authOnlyTransaction", doc.at_xpath("//transactionType").content - assert_equal "0.01", doc.at_xpath("//amount").content - assert_equal "EHuWW9PiBkWvqE5juRwDzAUFBAk=", doc.at_xpath("//creditCard/cryptogram").content - assert_equal "4111111111111111", doc.at_xpath("//creditCard/cardNumber").content + assert_equal 'authOnlyTransaction', doc.at_xpath('//transactionType').content + assert_equal '0.01', doc.at_xpath('//amount').content + assert_equal 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', doc.at_xpath('//creditCard/cryptogram').content + assert_equal '4111111111111111', doc.at_xpath('//creditCard/cardNumber').content end end.respond_with(successful_authorize_response) @@ -1159,10 +1159,10 @@ def test_supports_network_tokenization_false @gateway.supports_network_tokenization? end.check_request do |endpoint, data, headers| parse(data) do |doc| - assert_equal "authOnlyTransaction", doc.at_xpath("//transactionType").content - assert_equal "0.01", doc.at_xpath("//amount").content - assert_equal "EHuWW9PiBkWvqE5juRwDzAUFBAk=", doc.at_xpath("//creditCard/cryptogram").content - assert_equal "4111111111111111", doc.at_xpath("//creditCard/cardNumber").content + assert_equal 'authOnlyTransaction', doc.at_xpath('//transactionType').content + assert_equal '0.01', doc.at_xpath('//amount').content + assert_equal 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', doc.at_xpath('//creditCard/cryptogram').content + assert_equal '4111111111111111', doc.at_xpath('//creditCard/cardNumber').content end end.respond_with(network_tokenization_not_supported_response) @@ -1245,23 +1245,23 @@ def parse(data) end def fields_from_doc(doc) - assert_not_nil doc.at_xpath("//userFields/userField/name") - doc.xpath("//userFields/userField").inject({}) do |hash, element| - hash[element.at_xpath("name").content] = element.at_xpath("value").content + assert_not_nil doc.at_xpath('//userFields/userField/name') + doc.xpath('//userFields/userField').inject({}) do |hash, element| + hash[element.at_xpath('name').content] = element.at_xpath('value').content hash end end def settings_from_doc(doc) - assert_not_nil doc.at_xpath("//transactionSettings/setting/settingName") - doc.xpath("//transactionSettings/setting").inject({}) do |hash, element| - hash[element.at_xpath("settingName").content] = element.at_xpath("settingValue").content + assert_not_nil doc.at_xpath('//transactionSettings/setting/settingName') + doc.xpath('//transactionSettings/setting').inject({}) do |hash, element| + hash[element.at_xpath('settingName').content] = element.at_xpath('settingValue').content hash end end def assert_truncated(data, expected_size, field) - assert_equal ("a" * expected_size), parse(data).at_xpath(field).text, data + assert_equal ('a' * expected_size), parse(data).at_xpath(field).text, data end def assert_address_truncated(data, expected_size, field) diff --git a/test/unit/gateways/axcessms_test.rb b/test/unit/gateways/axcessms_test.rb index 62174c6e493..e87a092498b 100644 --- a/test/unit/gateways/axcessms_test.rb +++ b/test/unit/gateways/axcessms_test.rb @@ -10,23 +10,23 @@ def setup @gateway = AxcessmsGateway.new(fixtures(:axcessms)) @amount = 1500 - @credit_card = credit_card("4200000000000000", month: 05, year: 2022) - @declined_card = credit_card("4444444444444444", month: 05, year: 2022) - @mode = "CONNECTOR_TEST" + @credit_card = credit_card('4200000000000000', month: 05, year: 2022) + @declined_card = credit_card('4444444444444444', month: 05, year: 2022) + @mode = 'CONNECTOR_TEST' @options = { order_id: generate_unique_id, - email: "customer@example.com", + email: 'customer@example.com', description: "Order Number #{Time.now.to_f.divmod(2473)[1]}", - ip: "0.0.0.0", + ip: '0.0.0.0', mode: @mode, billing_address: { - :address1 => "10 Marklar St", - :address2 => "Musselburgh", - :city => "Dunedin", - :zip => "9013", - :state => "Otago", - :country => "NZ" + :address1 => '10 Marklar St', + :address2 => 'Musselburgh', + :city => 'Dunedin', + :zip => '9013', + :state => 'Otago', + :country => 'NZ' } } end @@ -71,75 +71,75 @@ def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) response = @gateway.capture(@amount, TEST_AUTHORIZATION, @options) assert_success response - assert response.params["reference_id"], TEST_AUTHORIZATION + assert response.params['reference_id'], TEST_AUTHORIZATION end def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) response = @gateway.refund(@amount - 30, TEST_PURCHASE, @options) assert_success response - assert response.params["reference_id"], TEST_PURCHASE + assert response.params['reference_id'], TEST_PURCHASE end def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) response = @gateway.void(TEST_AUTHORIZATION, @options) assert_success response - assert response.params["reference_id"], TEST_AUTHORIZATION + assert response.params['reference_id'], TEST_AUTHORIZATION end def test_unauthorized_capture @gateway.expects(:ssl_post).returns(failed_capture_response) - response = @gateway.capture(@amount, "authorization", @options) + response = @gateway.capture(@amount, 'authorization', @options) assert_failure response - assert_equal "Reference Error - capture needs at least one successful transaction of type (PA)", response.message + assert_equal 'Reference Error - capture needs at least one successful transaction of type (PA)', response.message end def test_failed_refund @gateway.expects(:ssl_post).returns(failed_refund_response) - response = @gateway.refund(@amount - 30, "authorization", @options) + response = @gateway.refund(@amount - 30, 'authorization', @options) assert_failure response - assert_equal "Configuration Validation - Invalid payment data. You are not configured for this currency or sub type (country or brand)", response.message + assert_equal 'Configuration Validation - Invalid payment data. You are not configured for this currency or sub type (country or brand)', response.message end def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) - response = @gateway.refund(@amount - 30, "authorization", @options) + response = @gateway.refund(@amount - 30, 'authorization', @options) assert_failure response - assert_equal "Reference Error - reversal needs at least one successful transaction of type (CP or DB or RB or PA)", response.message + assert_equal 'Reference Error - reversal needs at least one successful transaction of type (CP or DB or RB or PA)', response.message end def test_authorize_using_reference_sets_proper_elements stub_comms do - @gateway.authorize(@amount, "MY_AUTHORIZE_VALUE", @options) + @gateway.authorize(@amount, 'MY_AUTHORIZE_VALUE', @options) end.check_request do |endpoint, body, headers| - assert_xpath_text(body, "//ReferenceID", "MY_AUTHORIZE_VALUE") + assert_xpath_text(body, '//ReferenceID', 'MY_AUTHORIZE_VALUE') assert_no_match(/<Account>/, body) end.respond_with(successful_authorize_response) end def test_purchase_using_reference_sets_proper_elements stub_comms do - @gateway.purchase(@amount, "MY_AUTHORIZE_VALUE", @options) + @gateway.purchase(@amount, 'MY_AUTHORIZE_VALUE', @options) end.check_request do |endpoint, body, headers| - assert_xpath_text(body, "//ReferenceID", "MY_AUTHORIZE_VALUE") + assert_xpath_text(body, '//ReferenceID', 'MY_AUTHORIZE_VALUE') assert_no_match(/<Account>/, body) end.respond_with(successful_authorize_response) end def test_setting_mode_sets_proper_element stub_comms do - @gateway.purchase(@amount, "MY_AUTHORIZE_VALUE", {mode: "CRAZY_TEST_MODE"}) + @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") + assert_xpath_text(body, '//Transaction/@mode', 'CRAZY_TEST_MODE') end.respond_with(successful_authorize_response) end def test_defaults_to_integrator_test stub_comms do - @gateway.purchase(@amount, "MY_AUTHORIZE_VALUE", {}) + @gateway.purchase(@amount, 'MY_AUTHORIZE_VALUE', {}) end.check_request do |endpoint, body, headers| - assert_xpath_text(body, "//Transaction/@mode", "INTEGRATOR_TEST") + assert_xpath_text(body, '//Transaction/@mode', 'INTEGRATOR_TEST') end.respond_with(successful_authorize_response) end @@ -167,10 +167,10 @@ def test_failed_verify private def assert_xpath_text(xml, xpath, expected_text) - xml = CGI.unescape(xml.gsub("load=", "")) + xml = CGI.unescape(xml.gsub('load=', '')) root = REXML::Document.new(xml).root element = REXML::XPath.first(root, xpath) - actual_text = xpath.include?("@") ? element.value : element.text + actual_text = xpath.include?('@') ? element.value : element.text assert_equal expected_text, actual_text, %{Expected to find the text "#{expected_text}" within the XML element with path "#{xpath}", but instead found the text "#{actual_text}" in the following XML:\n#{xml}} end diff --git a/test/unit/gateways/balanced_test.rb b/test/unit/gateways/balanced_test.rb index 396af8a95d6..652b27fd084 100644 --- a/test/unit/gateways/balanced_test.rb +++ b/test/unit/gateways/balanced_test.rb @@ -32,9 +32,9 @@ def test_successful_purchase def test_successful_purchase_with_outside_token response = stub_comms(@gateway, :ssl_request) do - @gateway.purchase(@amount, "/cards/CCVOX2d7Ar6Ze5TOxHsebeH", @options) + @gateway.purchase(@amount, '/cards/CCVOX2d7Ar6Ze5TOxHsebeH', @options) end.check_request do |method, endpoint, data, headers| - assert_equal("https://api.balancedpayments.com/cards/CCVOX2d7Ar6Ze5TOxHsebeH/debits", endpoint) + assert_equal('https://api.balancedpayments.com/cards/CCVOX2d7Ar6Ze5TOxHsebeH/debits', endpoint) end.respond_with(debits_response) assert_success response @@ -80,11 +80,11 @@ def test_passing_appears_on_statement ).then.returns( appears_on_response ) - options = @options.merge(appears_on_statement_as: "Homer Electric") + options = @options.merge(appears_on_statement_as: 'Homer Electric') assert response = @gateway.purchase(@amount, @credit_card, options) assert_success response - assert_equal "BAL*Homer Electric", response.params['debits'][0]['appears_on_statement_as'] + assert_equal 'BAL*Homer Electric', response.params['debits'][0]['appears_on_statement_as'] end def test_authorize_and_capture @@ -146,10 +146,10 @@ def test_void_authorization amount = @amount assert auth = @gateway.authorize(amount, @credit_card, @options) assert_success auth - number = auth.params["card_holds"][0]["href"] + number = auth.params['card_holds'][0]['href'] assert void = @gateway.void(number) assert_success void - assert void.params["card_holds"][0]['voided_at'] + assert void.params['card_holds'][0]['voided_at'] end def test_refund_purchase @@ -200,7 +200,7 @@ def test_refund_pending_status assert refund = @gateway.refund(@amount, debit.authorization) assert_success refund - assert_equal "pending", refund.params['refunds'][0]['status'] + assert_equal 'pending', refund.params['refunds'][0]['status'] assert_equal @amount, refund.params['refunds'][0]['amount'] end @@ -222,7 +222,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| - assert_equal("https://api.balancedpayments.com/cards/CC7m1Mtqk6rVJo5tcD1qitAC/debits", endpoint) + assert_equal('https://api.balancedpayments.com/cards/CC7m1Mtqk6rVJo5tcD1qitAC/debits', endpoint) end.respond_with(debits_response) assert_success response @@ -231,42 +231,42 @@ def test_successful_purchase_with_legacy_outside_token end def test_capturing_legacy_authorizations - v1_authorization = "/v1/marketplaces/TEST-MP73SaFdpQePv9dOaG5wXOGO/holds/HL7dYMhpVBcqAYqxLF5mZtQ5" - v11_authorization = "/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5/debits||/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5" + v1_authorization = '/v1/marketplaces/TEST-MP73SaFdpQePv9dOaG5wXOGO/holds/HL7dYMhpVBcqAYqxLF5mZtQ5' + v11_authorization = '/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5/debits||/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5' [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| - assert_equal("https://api.balancedpayments.com/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5/debits", endpoint) + assert_equal('https://api.balancedpayments.com/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5/debits', endpoint) end.respond_with(authorized_debits_response) end end def test_voiding_legacy_authorizations - v1_authorization = "/v1/marketplaces/TEST-MP73SaFdpQePv9dOaG5wXOGO/holds/HL7dYMhpVBcqAYqxLF5mZtQ5" - v11_authorization = "/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5/debits||/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5" + v1_authorization = '/v1/marketplaces/TEST-MP73SaFdpQePv9dOaG5wXOGO/holds/HL7dYMhpVBcqAYqxLF5mZtQ5' + v11_authorization = '/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5/debits||/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5' [v1_authorization, v11_authorization].each do |authorization| stub_comms(@gateway, :ssl_request) do @gateway.void(authorization) end.check_request do |method, endpoint, data, headers| assert_equal :put, method - assert_equal("https://api.balancedpayments.com/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5", endpoint) + assert_equal('https://api.balancedpayments.com/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5', endpoint) assert_match %r{\bis_void=true\b}, data end.respond_with(voided_hold_response) end end def test_refunding_legacy_purchases - v1_authorization = "/v1/marketplaces/TEST-MP73SaFdpQePv9dOaG5wXOGO/debits/WD2x6vLS7RzHYEcdymqRyNAO" - v11_authorization = "|/debits/WD2x6vLS7RzHYEcdymqRyNAO/refunds|" + v1_authorization = '/v1/marketplaces/TEST-MP73SaFdpQePv9dOaG5wXOGO/debits/WD2x6vLS7RzHYEcdymqRyNAO' + v11_authorization = '|/debits/WD2x6vLS7RzHYEcdymqRyNAO/refunds|' [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| - assert_equal("https://api.balancedpayments.com/debits/WD2x6vLS7RzHYEcdymqRyNAO/refunds", endpoint) + assert_equal('https://api.balancedpayments.com/debits/WD2x6vLS7RzHYEcdymqRyNAO/refunds', endpoint) end.respond_with(refunds_response) end end @@ -302,7 +302,7 @@ 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: " ")) + @gateway.purchase(@amount, @credit_card, address: address(zip: ' ')) end.check_request do |method, endpoint, data, headers| next if endpoint =~ /debits/ assert_no_match(%r{address}, data) diff --git a/test/unit/gateways/banwire_test.rb b/test/unit/gateways/banwire_test.rb index f943718a62c..e7466ba51bc 100644 --- a/test/unit/gateways/banwire_test.rb +++ b/test/unit/gateways/banwire_test.rb @@ -24,8 +24,8 @@ def setup @amex_credit_card = credit_card('375932134599999', :month => 3, :year => 2017, - :first_name => "Banwire", - :last_name => "Test Card") + :first_name => 'Banwire', + :last_name => 'Test Card') @amex_options = { :order_id => '2', :email => 'test@email.com', diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb index 5f69651ea59..08d4f38efb0 100644 --- a/test/unit/gateways/barclaycard_smartpay_test.rb +++ b/test/unit/gateways/barclaycard_smartpay_test.rb @@ -292,7 +292,7 @@ def test_unsuccessful_verify response = @gateway.verify(@credit_card, @options) assert_failure response - assert_equal "Refused", response.message + assert_equal 'Refused', response.message end def test_authorize_nonfractional_currency @@ -337,7 +337,7 @@ def test_avs_result response = @gateway.authorize(@amount, @credit_card, @avs_address) assert_failure response - assert_equal "N", response.avs_result['code'] + assert_equal 'N', response.avs_result['code'] assert response.test? end @@ -352,7 +352,7 @@ def successful_authorize_response end def successful_authorize_with_3ds_response - "pspReference=8815161318854998&resultCode=RedirectShopper&issuerUrl=https%3A%2F%2Ftest.adyen.com%2Fhpp%2F3d%2Fvalidate.shtml&md=WIFa2sF3CuPyN53Txjt3U%2F%2BDuCsddzywiY5NLgEAdUAXPksHUzXL5E%2BsfvdpolkGWR8b1oh%2FNA3jNaUP9UCgfjhXqRslGFy9OGqcZ1ITMz54HHm%2FlsCKN9bTftKnYA4F7GqvOgcIIrinUZjbMvW9doGifwzSqYLo6ASOm6bARL5n7cIFV8IWtA2yPlO%2FztKSTRJt1glN4s8sMcpE57z4soWKMuycbdXdpp6d4ZRSa%2F1TPF0MnJF0zNaSAAkw9JpXqGMOz5sFF2Smpc38HXJzM%2FV%2B1mmoDhhWmXXOb5YQ0QSCS7DXKIcr8ZtuGuGmFp0QOfZiO41%2B2I2N7VhONVx8xSn%2BLu4m6vaDIg5qsnd9saxaWwbJpl9okKm6pB2MJap9ScuBCcvI496BPCrjQ2LHxvDWhk6M3Exemtv942NQIGlsiPaW0KXoC2dQvBsxWh0K&paRequest=eNpVUtuOgjAQ%2FRXj%2B1KKoIWMTVgxWR%2B8RNkPaMpEycrFUlb8%2B20B190%2BnXPm0pnTQnpRiMkJZauQwxabRpxxkmfLacQYDeiczihjgR%2BGbMrhEB%2FxxuEbVZNXJaeO63hAntSUK3kRpeYg5O19s%2BPUm%2FnBHMhIoUC1SXiKjT4URSxvba5QARlkKEWB%2FFSbgbLr41QIpXFVFUB6HWTVllo9OPNMwyeBVl35Reu6iQi53%2B9OM5Y7sipMVqmF1G9tA8QmAnlNeGgtakzjLs%2F4Pjl3u3TtbdNtZzDdJV%2FBPu7PEojNgExo5J5LmUvpfELDyPcjPwDS6yAKOxFffx4nxhXXrDwIUNt74oFQG%2FgrgLFdYSkfPFwws9WTAXZ1VaLJMPb%2BYiCvoVcf1mSpjW%2B%2BN9i8YKFr0MLa3Qdsl9yYREM37NtYAsSWkvElyfjiBv37CT9ySbE1" + 'pspReference=8815161318854998&resultCode=RedirectShopper&issuerUrl=https%3A%2F%2Ftest.adyen.com%2Fhpp%2F3d%2Fvalidate.shtml&md=WIFa2sF3CuPyN53Txjt3U%2F%2BDuCsddzywiY5NLgEAdUAXPksHUzXL5E%2BsfvdpolkGWR8b1oh%2FNA3jNaUP9UCgfjhXqRslGFy9OGqcZ1ITMz54HHm%2FlsCKN9bTftKnYA4F7GqvOgcIIrinUZjbMvW9doGifwzSqYLo6ASOm6bARL5n7cIFV8IWtA2yPlO%2FztKSTRJt1glN4s8sMcpE57z4soWKMuycbdXdpp6d4ZRSa%2F1TPF0MnJF0zNaSAAkw9JpXqGMOz5sFF2Smpc38HXJzM%2FV%2B1mmoDhhWmXXOb5YQ0QSCS7DXKIcr8ZtuGuGmFp0QOfZiO41%2B2I2N7VhONVx8xSn%2BLu4m6vaDIg5qsnd9saxaWwbJpl9okKm6pB2MJap9ScuBCcvI496BPCrjQ2LHxvDWhk6M3Exemtv942NQIGlsiPaW0KXoC2dQvBsxWh0K&paRequest=eNpVUtuOgjAQ%2FRXj%2B1KKoIWMTVgxWR%2B8RNkPaMpEycrFUlb8%2B20B190%2BnXPm0pnTQnpRiMkJZauQwxabRpxxkmfLacQYDeiczihjgR%2BGbMrhEB%2FxxuEbVZNXJaeO63hAntSUK3kRpeYg5O19s%2BPUm%2FnBHMhIoUC1SXiKjT4URSxvba5QARlkKEWB%2FFSbgbLr41QIpXFVFUB6HWTVllo9OPNMwyeBVl35Reu6iQi53%2B9OM5Y7sipMVqmF1G9tA8QmAnlNeGgtakzjLs%2F4Pjl3u3TtbdNtZzDdJV%2FBPu7PEojNgExo5J5LmUvpfELDyPcjPwDS6yAKOxFffx4nxhXXrDwIUNt74oFQG%2FgrgLFdYSkfPFwws9WTAXZ1VaLJMPb%2BYiCvoVcf1mSpjW%2B%2BN9i8YKFr0MLa3Qdsl9yYREM37NtYAsSWkvElyfjiBv37CT9ySbE1' end def failed_authorize_response diff --git a/test/unit/gateways/barclays_epdq_extra_plus_test.rb b/test/unit/gateways/barclays_epdq_extra_plus_test.rb index b1f2cb61c61..2155d23a374 100644 --- a/test/unit/gateways/barclays_epdq_extra_plus_test.rb +++ b/test/unit/gateways/barclays_epdq_extra_plus_test.rb @@ -9,10 +9,10 @@ def setup :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" + @identification = '3014726' + @billing_id = 'myalias' @options = { :order_id => '1', :billing_address => address, @@ -31,7 +31,7 @@ def setup @parameters_d3d = { 'FLAG3D' => 'Y', 'WIN3DS' => 'MAINW', - 'HTTP_ACCEPT' => "*/*" + 'HTTP_ACCEPT' => '*/*' } end @@ -133,7 +133,7 @@ def test_successful_authorize_with_3dsecure def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - assert response = @gateway.capture(@amount, "3048326") + assert response = @gateway.capture(@amount, '3048326') assert_success response assert_equal '3048326;SAL', response.authorization assert response.test? @@ -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? @@ -149,7 +149,7 @@ def test_successful_capture_with_action_option def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) - assert response = @gateway.void("3048606") + assert response = @gateway.void('3048606') assert_success response assert_equal '3048606;DES', response.authorization assert response.test? @@ -158,7 +158,7 @@ def test_successful_void def test_deprecated_credit @gateway.expects(:ssl_post).returns(successful_referenced_credit_response) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - assert response = @gateway.credit(@amount, "3049652;SAL") + assert response = @gateway.credit(@amount, '3049652;SAL') assert_success response assert_equal '3049652;RFD', response.authorization assert response.test? @@ -169,13 +169,13 @@ def test_successful_unreferenced_credit @gateway.expects(:ssl_post).returns(successful_unreferenced_credit_response) assert response = @gateway.credit(@amount, @credit_card) assert_success response - assert_equal "3049654;RFD", response.authorization + assert_equal '3049654;RFD', response.authorization assert response.test? end def test_successful_refund @gateway.expects(:ssl_post).returns(successful_referenced_credit_response) - assert response = @gateway.refund(@amount, "3049652") + assert response = @gateway.refund(@amount, '3049652') assert_success response assert_equal '3049652;RFD', response.authorization assert response.test? @@ -217,7 +217,7 @@ def test_create_readable_error_message_upon_failure assert_failure response assert response.test? - assert_equal "Unknown order", response.message + assert_equal 'Unknown order', response.message end def test_supported_countries @@ -294,19 +294,19 @@ def test_test_mode def test_format_error_message_with_slash_separator @gateway.expects(:ssl_post).returns('<ncresponse NCERRORPLUS="unknown order/1/i/67.192.100.64" STATUS="0" />') assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal "Unknown order", response.message + assert_equal 'Unknown order', response.message end def test_format_error_message_with_pipe_separator @gateway.expects(:ssl_post).returns('<ncresponse NCERRORPLUS=" no card no|no exp date|no brand" STATUS="0" />') assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal "No card no, no exp date, no brand", response.message + assert_equal 'No card no, no exp date, no brand', response.message end def test_format_error_message_with_no_separator @gateway.expects(:ssl_post).returns('<ncresponse NCERRORPLUS=" unknown order " STATUS="0" />') assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal "Unknown order", response.message + assert_equal 'Unknown order', response.message end def test_without_signature @@ -316,7 +316,7 @@ def test_without_signature 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) @@ -326,7 +326,7 @@ def test_without_signature def test_signature_for_accounts_created_before_10_may_20101 gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(:signature_encryptor => nil)) assert signature = gateway.send(:add_signature, @parameters) - assert_equal Digest::SHA1.hexdigest("1100EUR4111111111111111MrPSPIDRES2mynicesig").upcase, signature + assert_equal Digest::SHA1.hexdigest('1100EUR4111111111111111MrPSPIDRES2mynicesig').upcase, signature end def test_signature_for_accounts_with_signature_encryptor_to_sha1 @@ -360,13 +360,13 @@ def test_3dsecure_win_3ds_option gateway = BarclaysEpdqExtraPlusGateway.new(@credentials) gateway.send(:add_d3d, post, { :win_3ds => :pop_up }) - assert 'POPUP', post["WIN3DS"] + assert 'POPUP', post['WIN3DS'] gateway.send(:add_d3d, post, { :win_3ds => :pop_ix }) - assert 'POPIX', post["WIN3DS"] + assert 'POPIX', post['WIN3DS'] gateway.send(:add_d3d, post, { :win_3ds => :invalid }) - assert 'MAINW', post["WIN3DS"] + assert 'MAINW', post['WIN3DS'] end def test_3dsecure_additional_options @@ -374,8 +374,8 @@ 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)", + :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', @@ -383,8 +383,8 @@ def test_3dsecure_additional_options :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)" + assert 'HTTP_ACCEPT', 'text/html' + assert 'HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)' assert 'ACCEPTURL', 'https://accept_url' assert 'DECLINEURL', 'https://decline_url' assert 'EXCEPTIONURL', 'https://exception_url' @@ -414,16 +414,16 @@ def test_transcript_scrubbing private def string_to_digest - "ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig"+ - "CN=Client NamemynicesigCURRENCY=EURmynicesigOPERATION=RESmynicesig"+ - "ORDERID=1mynicesigPSPID=MrPSPIDmynicesig" + 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'+ + 'CN=Client NamemynicesigCURRENCY=EURmynicesigOPERATION=RESmynicesig'+ + 'ORDERID=1mynicesigPSPID=MrPSPIDmynicesig' end def d3d_string_to_digest - "ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig"+ - "CN=Client NamemynicesigCURRENCY=EURmynicesigFLAG3D=Ymynicesig"+ - "HTTP_ACCEPT=*/*mynicesigOPERATION=RESmynicesigORDERID=1mynicesig"+ - "PSPID=MrPSPIDmynicesigWIN3DS=MAINWmynicesig" + 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'+ + 'CN=Client NamemynicesigCURRENCY=EURmynicesigFLAG3D=Ymynicesig'+ + 'HTTP_ACCEPT=*/*mynicesigOPERATION=RESmynicesigORDERID=1mynicesig'+ + 'PSPID=MrPSPIDmynicesigWIN3DS=MAINWmynicesig' end def successful_authorize_response diff --git a/test/unit/gateways/be2bill_test.rb b/test/unit/gateways/be2bill_test.rb index 26d9625bd02..d83f42e42b5 100644 --- a/test/unit/gateways/be2bill_test.rb +++ b/test/unit/gateways/be2bill_test.rb @@ -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 d7659f76326..c1158396746 100644 --- a/test/unit/gateways/beanstream_interac_test.rb +++ b/test/unit/gateways/beanstream_interac_test.rb @@ -21,9 +21,9 @@ def test_successful_purchase response = @gateway.purchase(@amount, @options) assert_success response - assert_equal "R", response.params["responseType"] - assert response.params["pageContents"] - assert_equal response.params["pageContents"], response.redirect + assert_equal 'R', response.params['responseType'] + assert response.params['pageContents'] + assert_equal response.params['pageContents'], response.redirect end def test_successful_confirmation @@ -31,21 +31,21 @@ def test_successful_confirmation response = @gateway.confirm(successful_return_from_interac_online) assert response.success? - assert_equal "Approved", response.message - assert_equal "10000029;5.00;P", response.authorization + assert_equal 'Approved', response.message + assert_equal '10000029;5.00;P', response.authorization end private def successful_purchase_response - "responseType=R&pageContents=%3CHTML%3E%3CHEAD%3E%3C%2FHEAD%3E%3CBODY%3E%3CFORM%20action%3D%22https%3A%2F%2Fpayments%2Ebeanstream%2Ecom%2FiOnlineEmulator%2Fgateway%2Easp%22%20method%3DPOST%20id%3DfrmIOnline%20name%3DfrmIOnline%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHNUM%22%20%20value%3D%2210010162199999%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FAMOUNT%22%20%20value%3D%221500%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FTERMID%22%20value%3D%2262199999%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FCURRENCY%22%20value%3D%22CAD%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FINVOICE%22%20value%3D%221be7db7a129b07ac5f7e%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHDATA%22%20value%3D%226CE36AF7%2D5013%2D4B94%2DB740153714A41962%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FFUNDEDURL%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%5Fauth%2Easp%3F%26funded%3D1%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FNOTFUNDEDURL%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%5Fauth%2Easp%3F%26funded%3D0%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22merchant%5Fname%22%20value%3D%22Cody%20Fauser%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%2Easp%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost2%22%20value%3D%22https%3A%2F%2Fwww%2Ecatnrose%2Ecom%2Fioxml%2Easp%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost3%22%20value%3D%22%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHLANG%22%20value%3D%22en%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FVERSION%22%20value%3D%221%22%3E%3C%2FFORM%3E%3CSCRIPT%20language%3D%22JavaScript%22%3Edocument%2EfrmIOnline%2Esubmit%28%29%3B%3C%2FSCRIPT%3E%3C%2FBODY%3E%3C%2FHTML%3E" + 'responseType=R&pageContents=%3CHTML%3E%3CHEAD%3E%3C%2FHEAD%3E%3CBODY%3E%3CFORM%20action%3D%22https%3A%2F%2Fpayments%2Ebeanstream%2Ecom%2FiOnlineEmulator%2Fgateway%2Easp%22%20method%3DPOST%20id%3DfrmIOnline%20name%3DfrmIOnline%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHNUM%22%20%20value%3D%2210010162199999%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FAMOUNT%22%20%20value%3D%221500%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FTERMID%22%20value%3D%2262199999%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FCURRENCY%22%20value%3D%22CAD%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FINVOICE%22%20value%3D%221be7db7a129b07ac5f7e%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHDATA%22%20value%3D%226CE36AF7%2D5013%2D4B94%2DB740153714A41962%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FFUNDEDURL%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%5Fauth%2Easp%3F%26funded%3D1%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FNOTFUNDEDURL%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%5Fauth%2Easp%3F%26funded%3D0%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22merchant%5Fname%22%20value%3D%22Cody%20Fauser%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%2Easp%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost2%22%20value%3D%22https%3A%2F%2Fwww%2Ecatnrose%2Ecom%2Fioxml%2Easp%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost3%22%20value%3D%22%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHLANG%22%20value%3D%22en%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FVERSION%22%20value%3D%221%22%3E%3C%2FFORM%3E%3CSCRIPT%20language%3D%22JavaScript%22%3Edocument%2EfrmIOnline%2Esubmit%28%29%3B%3C%2FSCRIPT%3E%3C%2FBODY%3E%3C%2FHTML%3E' end def successful_return_from_interac_online - "bank_choice=1&merchant_name=Billing+Boss+IO+SB&confirmValue=&headerText=&IDEBIT_MERCHDATA=C4B50A48-6E11-4C21-A31EF4A602BC0099&IDEBIT_INVOICE=18face21593b59c7bb7e&IDEBIT_AMOUNT=1500&IDEBIT_FUNDEDURL=http%3A%2F%2Febay.massapparel.com%3A8000%2Finterac%2Ffunded%3Ffunded%3D1&IDEBIT_NOTFUNDEDURL=http%3A%2F%2Febay.massapparel.com%3A8000%2Finterac%2Fnotfunded%3Ffunded%3D0&IDEBIT_ISSLANG=en&IDEBIT_TRACK2=3728024906540591214%3D12010123456789XYZ&IDEBIT_ISSCONF=CONF%23TEST&IDEBIT_ISSNAME=TestBank1&IDEBIT_VERSION=1&accountType=Chequing" + 'bank_choice=1&merchant_name=Billing+Boss+IO+SB&confirmValue=&headerText=&IDEBIT_MERCHDATA=C4B50A48-6E11-4C21-A31EF4A602BC0099&IDEBIT_INVOICE=18face21593b59c7bb7e&IDEBIT_AMOUNT=1500&IDEBIT_FUNDEDURL=http%3A%2F%2Febay.massapparel.com%3A8000%2Finterac%2Ffunded%3Ffunded%3D1&IDEBIT_NOTFUNDEDURL=http%3A%2F%2Febay.massapparel.com%3A8000%2Finterac%2Fnotfunded%3Ffunded%3D0&IDEBIT_ISSLANG=en&IDEBIT_TRACK2=3728024906540591214%3D12010123456789XYZ&IDEBIT_ISSCONF=CONF%23TEST&IDEBIT_ISSNAME=TestBank1&IDEBIT_VERSION=1&accountType=Chequing' end def successful_confirmation_response - "trnApproved=1&trnId=10000029&messageId=1&messageText=Approved&trnOrderNumber=f29d2406b49b239b6dfb5db1f642b2&authCode=TEST&errorType=N&errorFields=&responseType=T&trnAmount=5%2E00&trnDate=6%2F8%2F2008+3%3A17%3A12+PM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+for+this+transaction%2E&trnType=P&paymentMethod=IO&ioConfCode=CONF%23TEST&ioInstName=TestBank1&ref1=reference+one&ref2=&ref3=&ref4=&ref5=" + 'trnApproved=1&trnId=10000029&messageId=1&messageText=Approved&trnOrderNumber=f29d2406b49b239b6dfb5db1f642b2&authCode=TEST&errorType=N&errorFields=&responseType=T&trnAmount=5%2E00&trnDate=6%2F8%2F2008+3%3A17%3A12+PM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+for+this+transaction%2E&trnType=P&paymentMethod=IO&ioConfCode=CONF%23TEST&ioInstName=TestBank1&ref1=reference+one&ref2=&ref3=&ref4=&ref5=' end end diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb index a97990ba636..be07b0c9e4a 100644 --- a/test/unit/gateways/beanstream_test.rb +++ b/test/unit/gateways/beanstream_test.rb @@ -15,13 +15,13 @@ def setup @credit_card = credit_card @decrypted_credit_card = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new( - month: "01", - year: "2012", - brand: "visa", - number: "4030000010001234", - payment_cryptogram: "cryptogram goes here", - eci: "an ECI value", - transaction_id: "transaction ID", + month: '01', + year: '2012', + brand: 'visa', + number: '4030000010001234', + payment_cryptogram: 'cryptogram goes here', + eci: 'an ECI value', + transaction_id: 'transaction ID', ) @check = check( @@ -150,7 +150,7 @@ def test_successful_verify @gateway.verify(@credit_card) end.respond_with(successful_authorize_response, unsuccessful_void_response) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_failed_verify @@ -158,7 +158,7 @@ def test_failed_verify @gateway.verify(@credit_card) end.respond_with(unsuccessful_authorize_response, successful_void_response) assert_failure response - assert_equal "DECLINE", response.message + assert_equal 'DECLINE', response.message end @@ -210,10 +210,10 @@ 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 + assert_equal 'Request successful', response.message end def test_successful_cancel_recurring @@ -228,10 +228,10 @@ 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 + assert_equal 'Request successful', response.message end def test_ip_is_being_sent @@ -239,7 +239,7 @@ def test_ip_is_being_sent data =~ /customerIp=123\.123\.123\.123/ end.returns(successful_purchase_response) - @options[:ip] = "123.123.123.123" + @options[:ip] = '123.123.123.123' @gateway.purchase(@amount, @credit_card, @options) end @@ -256,7 +256,7 @@ def test_includes_network_tokenization_fields end def test_defaults_state_and_zip_with_country - address = { country: "AF" } + address = { country: 'AF' } @options[:billing_address] = address @options[:shipping_address] = address response = stub_comms(@gateway, :ssl_request) do @@ -290,7 +290,7 @@ def test_no_state_and_zip_default_with_missing_country def test_sends_email_without_addresses @options[:billing_address] = nil @options[:shipping_address] = nil - @options[:shipping_email] = "ship@mail.com" + @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| @@ -308,35 +308,35 @@ def test_transcript_scrubbing private def successful_purchase_response - "cvdId=1&trnType=P&trnApproved=1&trnId=10000028&messageId=1&messageText=Approved&trnOrderNumber=df5e88232a61dc1d0058a20d5b5c0e&authCode=TEST&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=6%2F5%2F2008+5%3A26%3A53+AM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+f" + 'cvdId=1&trnType=P&trnApproved=1&trnId=10000028&messageId=1&messageText=Approved&trnOrderNumber=df5e88232a61dc1d0058a20d5b5c0e&authCode=TEST&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=6%2F5%2F2008+5%3A26%3A53+AM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+f' end def successful_test_purchase_response - "merchant_id=100200000&trnId=11011067&authCode=TEST&trnApproved=1&avsId=M&cvdId=1&messageId=1&messageText=Approved&trnOrderNumber=1234" + 'merchant_id=100200000&trnId=11011067&authCode=TEST&trnApproved=1&avsId=M&cvdId=1&messageId=1&messageText=Approved&trnOrderNumber=1234' end def unsuccessful_purchase_response - "merchant_id=100200000&trnId=11011069&authCode=&trnApproved=0&avsId=0&cvdId=6&messageId=16&messageText=Duplicate+transaction&trnOrderNumber=1234" + 'merchant_id=100200000&trnId=11011069&authCode=&trnApproved=0&avsId=0&cvdId=6&messageId=16&messageText=Duplicate+transaction&trnOrderNumber=1234' end def successful_check_purchase_response - "trnApproved=1&trnId=10000072&messageId=1&messageText=Approved&trnOrderNumber=5d9f511363a0f35d37de53b4d74f5b&authCode=&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=6%2F4%2F2008+6%3A33%3A55+PM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+for+this+transaction%2E&trnType=D&paymentMethod=EFT&ref1=reference+one&ref2=&ref3=&ref4=&ref5=" + 'trnApproved=1&trnId=10000072&messageId=1&messageText=Approved&trnOrderNumber=5d9f511363a0f35d37de53b4d74f5b&authCode=&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=6%2F4%2F2008+6%3A33%3A55+PM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+for+this+transaction%2E&trnType=D&paymentMethod=EFT&ref1=reference+one&ref2=&ref3=&ref4=&ref5=' end def successful_authorize_response - "trnApproved=1&trnId=10100560&messageId=1&messageText=Approved&trnOrderNumber=0b936c13208677aaa00be509c541e7&authCode=TEST&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=9%2F9%2F2015+10%3A10%3A28+AM&avsProcessed=1&avsId=N&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Street+address+and+Postal%2FZIP+do+not+match%2E&cvdId=1&cardType=VI&trnType=PA&paymentMethod=CC&ref1=reference+one&ref2=&ref3=&ref4=&ref5=" + 'trnApproved=1&trnId=10100560&messageId=1&messageText=Approved&trnOrderNumber=0b936c13208677aaa00be509c541e7&authCode=TEST&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=9%2F9%2F2015+10%3A10%3A28+AM&avsProcessed=1&avsId=N&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Street+address+and+Postal%2FZIP+do+not+match%2E&cvdId=1&cardType=VI&trnType=PA&paymentMethod=CC&ref1=reference+one&ref2=&ref3=&ref4=&ref5=' end def unsuccessful_authorize_response - "trnApproved=0&trnId=10100561&messageId=7&messageText=DECLINE&trnOrderNumber=7eef9f25c6f123572f193bee4a1aa0&authCode=&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=9%2F9%2F2015+10%3A11%3A22+AM&avsProcessed=1&avsId=N&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Street+address+and+Postal%2FZIP+do+not+match%2E&cvdId=2&cardType=AM&trnType=PA&paymentMethod=CC&ref1=reference+one&ref2=&ref3=&ref4=&ref5=" + 'trnApproved=0&trnId=10100561&messageId=7&messageText=DECLINE&trnOrderNumber=7eef9f25c6f123572f193bee4a1aa0&authCode=&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=9%2F9%2F2015+10%3A11%3A22+AM&avsProcessed=1&avsId=N&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Street+address+and+Postal%2FZIP+do+not+match%2E&cvdId=2&cardType=AM&trnType=PA&paymentMethod=CC&ref1=reference+one&ref2=&ref3=&ref4=&ref5=' end def successful_void_response - "trnApproved=1&trnId=10100563&messageId=1&messageText=Approved&trnOrderNumber=6ca476d1a29da81a5f2d5d2c92ddeb&authCode=TEST&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=9%2F9%2F2015+10%3A13%3A12+AM&avsProcessed=0&avsId=U&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+information+is+unavailable%2E&cvdId=2&cardType=VI&trnType=VP&paymentMethod=CC&ref1=reference+one&ref2=&ref3=&ref4=&ref5=" + 'trnApproved=1&trnId=10100563&messageId=1&messageText=Approved&trnOrderNumber=6ca476d1a29da81a5f2d5d2c92ddeb&authCode=TEST&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=9%2F9%2F2015+10%3A13%3A12+AM&avsProcessed=0&avsId=U&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+information+is+unavailable%2E&cvdId=2&cardType=VI&trnType=VP&paymentMethod=CC&ref1=reference+one&ref2=&ref3=&ref4=&ref5=' end def unsuccessful_void_response - "trnApproved=0&trnId=0&messageId=0&messageText=%3CLI%3EAdjustment+id+must+be+less+than+8+characters%3Cbr%3E&trnOrderNumber=&authCode=&errorType=U&errorFields=adjId&responseType=T&trnAmount=&trnDate=9%2F9%2F2015+10%3A15%3A20+AM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+for+this+transaction%2E&cardType=&trnType=VP&paymentMethod=CC&ref1=&ref2=&ref3=&ref4=&ref5=" + 'trnApproved=0&trnId=0&messageId=0&messageText=%3CLI%3EAdjustment+id+must+be+less+than+8+characters%3Cbr%3E&trnOrderNumber=&authCode=&errorType=U&errorFields=adjId&responseType=T&trnAmount=&trnDate=9%2F9%2F2015+10%3A15%3A20+AM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+for+this+transaction%2E&cardType=&trnType=VP&paymentMethod=CC&ref1=&ref2=&ref3=&ref4=&ref5=' end def brazilian_address_params_without_zip_and_state @@ -352,23 +352,23 @@ def next_year end def successful_recurring_response - "trnApproved=1&trnId=10000072&messageId=1&messageText=Approved&trnOrderNumber=5d9f511363a0f35d37de53b4d74f5b&authCode=&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=6%2F4%2F2008+6%3A33%3A55+PM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+for+this+transaction%2E&trnType=D&paymentMethod=EFT&ref1=reference+one&ref2=&ref3=&ref4=&ref5=" + 'trnApproved=1&trnId=10000072&messageId=1&messageText=Approved&trnOrderNumber=5d9f511363a0f35d37de53b4d74f5b&authCode=&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=6%2F4%2F2008+6%3A33%3A55+PM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+for+this+transaction%2E&trnType=D&paymentMethod=EFT&ref1=reference+one&ref2=&ref3=&ref4=&ref5=' end def successful_update_recurring_response - "<response><code>1</code><message>Request successful</message></response>" + '<response><code>1</code><message>Request successful</message></response>' end def successful_cancel_recurring_response - "<response><code>1</code><message>Request successful</message></response>" + '<response><code>1</code><message>Request successful</message></response>' end def transcript - "ref1=reference+one&trnCardOwner=Longbob+Longsen&trnCardNumber=4030000010001234&trnExpMonth=09&trnExpYear=16&trnCardCvd=123&ordName=xiaobo+zzz&ordEmailAddress=xiaobozzz%40example.com&username=awesomesauce&password=sp00nz%21%21" + 'ref1=reference+one&trnCardOwner=Longbob+Longsen&trnCardNumber=4030000010001234&trnExpMonth=09&trnExpYear=16&trnCardCvd=123&ordName=xiaobo+zzz&ordEmailAddress=xiaobozzz%40example.com&username=awesomesauce&password=sp00nz%21%21' end 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]" + '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 3a13b0fe71b..ce498445007 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 @@ -53,7 +53,7 @@ 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 + assert_equal ['ADDR1', 'ADDR2', 'CITY', 'COMPANY_NAME', 'COUNTRY', 'PHONE', 'STATE', 'ZIP'], result.stringify_keys.keys.sort assert_equal 'n/a', result[:STATE] assert_equal '123 Test St.', result[:ADDR1] assert_equal 'DE', result[:COUNTRY] @@ -64,7 +64,7 @@ def test_add_address @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 ['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] @@ -95,7 +95,7 @@ def test_add_description def test_purchase_meets_minimum_requirements params = { - :amount => "1.01", + :amount => '1.01', } @gateway.send(:add_creditcard, params, @credit_card) @@ -115,7 +115,7 @@ def test_successful_refund def test_refund_passing_extra_info response = stub_comms do - @gateway.refund(50, '123456789', :card_number => @credit_card.number, :first_name => "Bob", :last_name => "Smith", :zip => "12345") + @gateway.refund(50, '123456789', :card_number => @credit_card.number, :first_name => 'Bob', :last_name => 'Smith', :zip => '12345') end.check_request do |endpoint, data, headers| assert_match(/NAME1=Bob/, data) assert_match(/NAME2=Smith/, data) @@ -133,7 +133,7 @@ def test_failed_refund def test_deprecated_credit @gateway.expects(:ssl_post).returns(successful_purchase_response) - assert_deprecation_warning("credit should only be used to credit a payment method") do + assert_deprecation_warning('credit should only be used to credit a payment method') do assert response = @gateway.credit(@amount, '123456789', :card_number => @credit_card.number) assert_success response assert_equal 'This transaction has been approved', response.message @@ -150,15 +150,15 @@ def test_supported_card_types def test_parser_extracts_exactly_the_keys_in_gateway_response assert_nothing_raised do - response = @gateway.send(:parse, "NEW_IMPORTANT_FIELD=value_on_fire") + response = @gateway.send(:parse, 'NEW_IMPORTANT_FIELD=value_on_fire') assert_equal response.params.keys, ['NEW_IMPORTANT_FIELD'] - assert_equal response.params['NEW_IMPORTANT_FIELD'], "value_on_fire" + assert_equal response.params['NEW_IMPORTANT_FIELD'], 'value_on_fire' end end def test_failure_without_response_reason_text assert_nothing_raised do - assert_equal '', @gateway.send(:parse, "MESSAGE=").message + assert_equal '', @gateway.send(:parse, 'MESSAGE=').message end end @@ -181,8 +181,8 @@ def test_message_from def get_msg(query) @gateway.send(:parse, query).message end - assert_equal "CVV does not match", get_msg('STATUS=2&CVV2=N&AVS=A&MESSAGE=FAILURE') - assert_equal "Street address matches, but 5-digit and 9-digit postal code do not match.", + assert_equal 'CVV does not match', get_msg('STATUS=2&CVV2=N&AVS=A&MESSAGE=FAILURE') + assert_equal 'Street address matches, but 5-digit and 9-digit postal code do not match.', get_msg('STATUS=2&CVV2=M&AVS=A&MESSAGE=FAILURE') end @@ -245,9 +245,9 @@ def test_successful_status_recurring end def test_solution_id_is_added_to_post_data_parameters - assert !@gateway.send(:post_data, 'AUTH_ONLY').include?("solution_ID=A1000000") + assert !@gateway.send(:post_data, 'AUTH_ONLY').include?('solution_ID=A1000000') ActiveMerchant::Billing::BluePayGateway.application_id = 'A1000000' - assert @gateway.send(:post_data, 'AUTH_ONLY').include?("solution_ID=A1000000") + assert @gateway.send(:post_data, 'AUTH_ONLY').include?('solution_ID=A1000000') ensure ActiveMerchant::Billing::BluePayGateway.application_id = nil end @@ -263,7 +263,7 @@ def minimum_requirements end def successful_refund_response - "AUTH_CODE=GFOCD&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=CREDIT&REBID=&STATUS=1&AVS=_&TRANS_ID=100134230412&CVV2=_&MESSAGE=Approved%20Credit" + 'AUTH_CODE=GFOCD&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=CREDIT&REBID=&STATUS=1&AVS=_&TRANS_ID=100134230412&CVV2=_&MESSAGE=Approved%20Credit' end def failed_refund_response @@ -271,15 +271,15 @@ def failed_refund_response end def successful_authorization_response - "AUTH_CODE=RSWUC&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=AUTH&REBID=&STATUS=1&AVS=_&TRANS_ID=100134229528&CVV2=_&MESSAGE=Approved%20Auth" + 'AUTH_CODE=RSWUC&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=AUTH&REBID=&STATUS=1&AVS=_&TRANS_ID=100134229528&CVV2=_&MESSAGE=Approved%20Auth' end def successful_purchase_response - "AUTH_CODE=KHJMY&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=SALE&REBID=&STATUS=1&AVS=_&TRANS_ID=100134229668&CVV2=_&MESSAGE=Approved%20Sale" + 'AUTH_CODE=KHJMY&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=SALE&REBID=&STATUS=1&AVS=_&TRANS_ID=100134229668&CVV2=_&MESSAGE=Approved%20Sale' end def failed_authorization_response - "AUTH_CODE=&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=AUTH&REBID=&STATUS=0&AVS=_&TRANS_ID=100134229728&CVV2=_&MESSAGE=Declined%20Auth" + 'AUTH_CODE=&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=AUTH&REBID=&STATUS=0&AVS=_&TRANS_ID=100134229728&CVV2=_&MESSAGE=Declined%20Auth' end def successful_recurring_response @@ -299,10 +299,10 @@ def successful_status_recurring_response end def transcript - "card_num=4111111111111111&exp_date=1212&MASTER_ID=&PAYMENT_TYPE=CREDIT&PAYMENT_ACCOUNT=4242424242424242&CARD_CVV2=123&CARD_EXPIRE=0916&NAME1=Longbob&NAME2=Longsen&ORDER_ID=78c40687dd55dbdc140df777b0e8ece3&INVOICE_ID=&invoice_num=78c40687dd55dbdc140df777b0e8ece3&EMAIL=&CUSTOM_ID=&DUPLICATE_OVERRIDE=&TRANS_TYPE=SALE&AMOUNT=1.00&MODE=TEST&ACCOUNT_ID=100096218902&TAMPER_PROOF_SEAL=55624458ce3e15fa8e33e6f2d784bbcb" + 'card_num=4111111111111111&exp_date=1212&MASTER_ID=&PAYMENT_TYPE=CREDIT&PAYMENT_ACCOUNT=4242424242424242&CARD_CVV2=123&CARD_EXPIRE=0916&NAME1=Longbob&NAME2=Longsen&ORDER_ID=78c40687dd55dbdc140df777b0e8ece3&INVOICE_ID=&invoice_num=78c40687dd55dbdc140df777b0e8ece3&EMAIL=&CUSTOM_ID=&DUPLICATE_OVERRIDE=&TRANS_TYPE=SALE&AMOUNT=1.00&MODE=TEST&ACCOUNT_ID=100096218902&TAMPER_PROOF_SEAL=55624458ce3e15fa8e33e6f2d784bbcb' end def scrubbed_transcript - "card_num=[FILTERED]&exp_date=1212&MASTER_ID=&PAYMENT_TYPE=CREDIT&PAYMENT_ACCOUNT=[FILTERED]&CARD_CVV2=[FILTERED]&CARD_EXPIRE=0916&NAME1=Longbob&NAME2=Longsen&ORDER_ID=78c40687dd55dbdc140df777b0e8ece3&INVOICE_ID=&invoice_num=78c40687dd55dbdc140df777b0e8ece3&EMAIL=&CUSTOM_ID=&DUPLICATE_OVERRIDE=&TRANS_TYPE=SALE&AMOUNT=1.00&MODE=TEST&ACCOUNT_ID=100096218902&TAMPER_PROOF_SEAL=[FILTERED]" + 'card_num=[FILTERED]&exp_date=1212&MASTER_ID=&PAYMENT_TYPE=CREDIT&PAYMENT_ACCOUNT=[FILTERED]&CARD_CVV2=[FILTERED]&CARD_EXPIRE=0916&NAME1=Longbob&NAME2=Longsen&ORDER_ID=78c40687dd55dbdc140df777b0e8ece3&INVOICE_ID=&invoice_num=78c40687dd55dbdc140df777b0e8ece3&EMAIL=&CUSTOM_ID=&DUPLICATE_OVERRIDE=&TRANS_TYPE=SALE&AMOUNT=1.00&MODE=TEST&ACCOUNT_ID=100096218902&TAMPER_PROOF_SEAL=[FILTERED]' end end diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb index 2355fc81389..dffaf3d9565 100644 --- a/test/unit/gateways/blue_snap_test.rb +++ b/test/unit/gateways/blue_snap_test.rb @@ -23,7 +23,7 @@ def test_failed_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "14002", response.error_code + assert_equal '14002', response.error_code end def test_successful_authorize @@ -39,55 +39,55 @@ def test_failed_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response - assert_equal "14002", response.error_code + assert_equal '14002', response.error_code end def test_successful_capture @gateway.expects(:raw_ssl_request).returns(successful_capture_response) - response = @gateway.capture(@amount, "Authorization") + response = @gateway.capture(@amount, 'Authorization') assert_success response - assert_equal "1012082881", response.authorization + assert_equal '1012082881', response.authorization end def test_failed_capture @gateway.expects(:raw_ssl_request).returns(failed_capture_response) - response = @gateway.capture(@amount, "Authorization") + response = @gateway.capture(@amount, 'Authorization') assert_failure response - assert_equal "20008", response.error_code + assert_equal '20008', response.error_code end def test_successful_refund @gateway.expects(:raw_ssl_request).returns(successful_refund_response) - response = @gateway.refund(@amount, "Authorization") + response = @gateway.refund(@amount, 'Authorization') assert_success response - assert_equal "1012082907", response.authorization + assert_equal '1012082907', response.authorization end def test_failed_refund @gateway.expects(:raw_ssl_request).returns(failed_refund_response) - response = @gateway.refund(@amount, "Authorization") + response = @gateway.refund(@amount, 'Authorization') assert_failure response - assert_equal "20008", response.error_code + assert_equal '20008', response.error_code end def test_successful_void @gateway.expects(:raw_ssl_request).returns(successful_void_response) - response = @gateway.void("Authorization") + response = @gateway.void('Authorization') assert_success response - assert_equal "1012082919", response.authorization + assert_equal '1012082919', response.authorization end def test_failed_void @gateway.expects(:raw_ssl_request).returns(failed_void_response) - response = @gateway.void("Authorization") + response = @gateway.void('Authorization') assert_failure response - assert_equal "20008", response.error_code + assert_equal '20008', response.error_code end def test_successful_verify @@ -95,7 +95,7 @@ def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "1012082929", response.authorization + assert_equal '1012082929', response.authorization end def test_failed_verify @@ -103,7 +103,7 @@ def test_failed_verify response = @gateway.verify(@credit_card, @options) assert_failure response - assert_equal "14002", response.error_code + assert_equal '14002', response.error_code end def test_successful_store @@ -111,7 +111,7 @@ def test_successful_store response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "20936441", response.authorization + assert_equal '20936441', response.authorization end def test_failed_store @@ -119,7 +119,7 @@ def test_failed_store response = @gateway.store(@credit_card, @options) assert_failure response - assert_equal "14002", response.error_code + assert_equal '14002', response.error_code end def test_currency_added_correctly @@ -498,7 +498,7 @@ def successful_store_response </vaulted-shopper> XML - response.headers = { "content-location" => "https://sandbox.bluesnap.com/services/2/vaulted-shoppers/20936441" } + response.headers = { 'content-location' => 'https://sandbox.bluesnap.com/services/2/vaulted-shoppers/20936441' } response end @@ -517,7 +517,7 @@ def failed_store_response end def credentials_are_legit_response - MockResponse.new(400, "<xml>Server Error</xml>") + MockResponse.new(400, '<xml>Server Error</xml>') end def credentials_are_bogus_response diff --git a/test/unit/gateways/bogus_test.rb b/test/unit/gateways/bogus_test.rb index 25323865538..64da3842489 100644 --- a/test/unit/gateways/bogus_test.rb +++ b/test/unit/gateways/bogus_test.rb @@ -14,7 +14,7 @@ def setup @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 @@ -25,7 +25,7 @@ def test_authorize e = assert_raises(ActiveMerchant::Billing::Error) do @gateway.authorize(1000, credit_card('123')) end - assert_equal("Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error", e.message) + assert_equal('Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error', e.message) end def test_purchase @@ -36,12 +36,12 @@ def test_purchase e = assert_raises(ActiveMerchant::Billing::Error) do @gateway.purchase(1000, credit_card('123')) end - assert_equal("Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error", e.message) + assert_equal('Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error', e.message) end def test_capture assert @gateway.capture(1000, '1337').success? - assert @gateway.capture(1000, @response.params["transid"]).success? + assert @gateway.capture(1000, @response.params['transid']).success? response = @gateway.capture(1000, CC_FAILURE_PLACEHOLDER) refute response.success? assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code @@ -58,12 +58,12 @@ def test_credit e = assert_raises(ActiveMerchant::Billing::Error) do @gateway.credit(1000, credit_card('123')) end - assert_equal("Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error", e.message) + assert_equal('Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error', e.message) end def test_refund assert @gateway.refund(1000, '1337').success? - assert @gateway.refund(1000, @response.params["transid"]).success? + assert @gateway.refund(1000, @response.params['transid']).success? response = @gateway.refund(1000, CC_FAILURE_PLACEHOLDER) refute response.success? assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code @@ -82,7 +82,7 @@ def test_credit_uses_refund def test_void assert @gateway.void('1337').success? - assert @gateway.void(@response.params["transid"]).success? + assert @gateway.void(@response.params['transid']).success? response = @gateway.void(CC_FAILURE_PLACEHOLDER) refute response.success? assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code @@ -99,7 +99,7 @@ def test_store e = assert_raises(ActiveMerchant::Billing::Error) do @gateway.store(credit_card('123')) end - assert_equal("Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error", e.message) + assert_equal('Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error', e.message) end def test_unstore @@ -125,7 +125,7 @@ def test_authorize_with_check e = assert_raises(ActiveMerchant::Billing::Error) do @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) + 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 @@ -138,7 +138,7 @@ def test_purchase_with_check e = assert_raises(ActiveMerchant::Billing::Error) do @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) + 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 @@ -147,7 +147,7 @@ def test_store_with_check e = assert_raises(ActiveMerchant::Billing::Error) do @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) + 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 @@ -156,7 +156,7 @@ def test_credit_with_check e = assert_raises(ActiveMerchant::Billing::Error) do @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) + 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 @@ -175,7 +175,7 @@ def test_authorize_emv e = assert_raises(ActiveMerchant::Billing::Error) do @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) + 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 @@ -186,6 +186,6 @@ def test_purchase_emv e = assert_raises(ActiveMerchant::Billing::Error) do @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) + assert_equal('Bogus Gateway: Use amount ending in 00 for success, 05 for failure and anything else for exception', e.message) end end diff --git a/test/unit/gateways/borgun_test.rb b/test/unit/gateways/borgun_test.rb index 6925d0c5c68..bd38587664a 100644 --- a/test/unit/gateways/borgun_test.rb +++ b/test/unit/gateways/borgun_test.rb @@ -28,7 +28,7 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "140216103700|11|15|WC0000000001|123456|1|000000012300|978", response.authorization + assert_equal '140216103700|11|15|WC0000000001|123456|1|000000012300|978', response.authorization assert response.test? end @@ -45,7 +45,7 @@ def test_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "140601083732|11|18|WC0000000001|123456|5|000000012300|978", response.authorization + assert_equal '140601083732|11|18|WC0000000001|123456|5|000000012300|978', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -62,7 +62,7 @@ def test_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "140216103700|11|15|WC0000000001|123456|1|000000012300|978", response.authorization + assert_equal '140216103700|11|15|WC0000000001|123456|1|000000012300|978', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -79,7 +79,7 @@ def test_void end.respond_with(successful_purchase_response) assert_success response - assert_equal "140216103700|11|15|WC0000000001|123456|1|000000012300|978", response.authorization + assert_equal '140216103700|11|15|WC0000000001|123456|1|000000012300|978', response.authorization refund = stub_comms do @gateway.void(response.authorization) diff --git a/test/unit/gateways/bpoint_test.rb b/test/unit/gateways/bpoint_test.rb index 1c7dafe14c6..acdad65c45d 100644 --- a/test/unit/gateways/bpoint_test.rb +++ b/test/unit/gateways/bpoint_test.rb @@ -46,7 +46,7 @@ def test_failed_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Declined", response.message + assert_equal 'Declined', response.message end def test_successful_authorize diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index 8b9f7dcdedd..ff67f2dc983 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -20,22 +20,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")) + returns(braintree_result(:id => 'refund_transaction_id')) response = @gateway.refund('transaction_id', :test => true) - assert_equal "refund_transaction_id", response.authorization + 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")) + returns(braintree_result(:id => 'refund_transaction_id')) response = @gateway.refund(1000, 'transaction_id', :test => true) - assert_equal "refund_transaction_id", response.authorization + 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', {}) @@ -45,7 +45,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 }) @@ -55,7 +55,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(has_entries(:payment_method_nonce => 'present')). returns(braintree_result) assert response = @gateway.purchase(10, 'present', { payment_method_nonce: true }) @@ -66,10 +66,10 @@ def test_transaction_uses_payment_method_nonce_when_option 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', :test => true) - assert_equal "void_transaction_id", response.authorization + assert_equal 'void_transaction_id', response.authorization end def test_verify_good_credentials @@ -99,10 +99,10 @@ def test_merchant_account_id_present_when_provided_on_gateway_initialization ) 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")) + @gateway.authorize(100, credit_card('41111111111111111111')) end def test_merchant_account_id_on_transaction_takes_precedence @@ -114,26 +114,26 @@ def test_merchant_account_id_on_transaction_takes_precedence ) 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 @@ -141,7 +141,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 @@ -149,7 +149,7 @@ def test_merchant_account_id_absent_if_not_provided not params.has_key?(:merchant_account_id) end.returns(braintree_result) - @gateway.authorize(100, credit_card("41111111111111111111")) + @gateway.authorize(100, credit_card('41111111111111111111')) end def test_verification_merchant_account_id_exists_when_verify_card_and_merchant_account_id @@ -212,31 +212,31 @@ def test_store_with_verify_card_true 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] - assert_equal "Longbob Longsen", params[:credit_card][:cardholder_name] + assert_equal 'Longbob Longsen', params[:credit_card][:cardholder_name] params end.returns(result) - 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 + 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", + :email => 'bob@example.com', :phone => '321-654-0987', :first_name => 'John', :last_name => 'Smith', - id: "123" + id: '123' ) result = Braintree::SuccessfulResult.new(:customer => customer) Braintree::CustomerGateway.any_instance.expects(:create).with do |params| - assert_equal "bob@example.com", params[:email] + 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 @@ -247,7 +247,7 @@ def test_scrubs_invalid_email :phone => '321-654-0987', :first_name => 'John', :last_name => 'Smith', - :id => "123" + :id => '123' ) result = Braintree::SuccessfulResult.new(:customer => customer) Braintree::CustomerGateway.any_instance.expects(:create).with do |params| @@ -255,7 +255,7 @@ def test_scrubs_invalid_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 @@ -275,9 +275,9 @@ def test_store_with_verify_card_false params end.returns(result) - 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 + 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 @@ -289,12 +289,12 @@ def test_store_with_billing_address_options :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') @@ -307,7 +307,7 @@ def test_store_with_billing_address_options 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 @@ -319,19 +319,19 @@ def test_store_with_credit_card_token ) customer.stubs(:id).returns('123') - braintree_credit_card = stub_everything(token: "cctoken") + braintree_credit_card = stub_everything(token: 'cctoken') customer.stubs(:credit_cards).returns([braintree_credit_card]) result = Braintree::SuccessfulResult.new(:customer => customer) Braintree::CustomerGateway.any_instance.expects(:create).with do |params| - assert_equal "cctoken", params[:credit_card][:token] + 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"] + assert_equal 'cctoken', response.params['braintree_customer']['credit_cards'][0]['token'] + assert_equal 'cctoken', response.params['credit_card_token'] end def test_store_with_customer_id @@ -342,62 +342,62 @@ def test_store_with_customer_id :last_name => 'Smith', :credit_cards => [stub_everything] ) - customer.stubs(:id).returns("customerid") + customer.stubs(:id).returns('customerid') result = Braintree::SuccessfulResult.new(:customer => customer) Braintree::CustomerGateway.any_instance.expects(:find). - with("customerid"). + with('customerid'). raises(Braintree::NotFoundError) Braintree::CustomerGateway.any_instance.expects(:create).with do |params| - assert_equal "customerid", params[:id] + assert_equal 'customerid', params[: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"] + assert_equal 'customerid', response.params['braintree_customer']['id'] end def test_store_with_existing_customer_id credit_card = stub( - customer_id: "customerid", - token: "cctoken" + customer_id: 'customerid', + token: 'cctoken' ) result = Braintree::SuccessfulResult.new(credit_card: credit_card) - Braintree::CustomerGateway.any_instance.expects(:find).with("customerid") + Braintree::CustomerGateway.any_instance.expects(:find).with('customerid') Braintree::CreditCardGateway.any_instance.expects(:create).with do |params| - assert_equal "customerid", params[:customer_id] - assert_equal "41111111111111111111", params[:number] - assert_equal "Longbob Longsen", params[:cardholder_name] + assert_equal 'customerid', params[:customer_id] + assert_equal '41111111111111111111', params[:number] + assert_equal 'Longbob Longsen', params[:cardholder_name] params end.returns(result) - response = @gateway.store(credit_card("41111111111111111111"), customer: "customerid") + response = @gateway.store(credit_card('41111111111111111111'), customer: 'customerid') assert_success response - assert_nil response.params["braintree_customer"] - assert_equal "customerid", response.params["customer_vault_id"] - assert_equal "cctoken", response.params["credit_card_token"] + assert_nil response.params['braintree_customer'] + assert_equal 'customerid', response.params['customer_vault_id'] + assert_equal 'cctoken', response.params['credit_card_token'] end def test_update_with_cvv - stored_credit_card = mock(:token => "token", :default? => true) + 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) 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] + 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) + 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) @@ -408,7 +408,7 @@ def test_update_with_verify_card_true [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 @@ -429,11 +429,11 @@ def test_merge_credit_card_options_handles_nil_credit_card 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} @@ -441,13 +441,13 @@ def test_merge_credit_card_options_handles_billing_address :first_name => 'John', :credit_card => { :billing_address => { - :street_address => "1 E Main St", + :street_address => '1 E Main St', :extended_address => nil, :company => nil, - :locality => "Chicago", - :region => "Illinois", - :postal_code => "60622", - :country_code_alpha2 => "US" + :locality => 'Chicago', + :region => 'Illinois', + :postal_code => '60622', + :country_code_alpha2 => 'US' }, :options => {} } @@ -469,48 +469,48 @@ def test_merge_credit_card_options_only_includes_billing_address_when_present def test_address_country_handling Braintree::TransactionGateway.any_instance.expects(:sale).with do |params| - (params[:billing][:country_code_alpha2] == "US") + (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") + (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") + (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") + (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") + (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") + (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 @@ -518,13 +518,13 @@ def test_three_d_secure_pass_thru_handling any_instance. expects(:sale). with(has_entries(three_d_secure_pass_thru: { - cavv: "cavv", - eci_flag: "eci", - xid: "xid", + cavv: 'cavv', + eci_flag: 'eci', + 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_passes_recurring_flag @@ -539,13 +539,13 @@ def test_passes_recurring_flag with(has_entries(:recurring => true)). 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))). returns(braintree_result) - @gateway.purchase(100, credit_card("41111111111111111111")) + @gateway.purchase(100, credit_card('41111111111111111111')) end def test_configured_logger_has_a_default @@ -597,12 +597,12 @@ def test_that_setting_a_wiredump_device_on_the_gateway_sets_the_braintree_logger end def test_solution_id_is_added_to_create_transaction_parameters - assert_nil @gateway.send(:create_transaction_parameters, 100, credit_card("41111111111111111111"),{})[:channel] + assert_nil @gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'),{})[:channel] ActiveMerchant::Billing::BraintreeBlueGateway.application_id = 'ABC123' - assert_equal @gateway.send(:create_transaction_parameters, 100, credit_card("41111111111111111111"),{})[:channel], "ABC123" + assert_equal @gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'),{})[:channel], 'ABC123' - gateway = BraintreeBlueGateway.new(:merchant_id => 'test', :public_key => 'test', :private_key => 'test', channel: "overidden-channel") - assert_equal gateway.send(:create_transaction_parameters, 100, credit_card("41111111111111111111"),{})[:channel], "overidden-channel" + 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 end @@ -613,7 +613,7 @@ def test_successful_purchase_with_descriptor (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') + @gateway.purchase(100, credit_card('41111111111111111111'), descriptor_name: 'wow*productname', descriptor_phone: '4443331112', descriptor_url: 'wow.com') end def test_apple_pay_card @@ -634,17 +634,17 @@ def test_apple_pay_card :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" + :transaction_id => '123', + :eci => '05', + :payment_cryptogram => '111111111100cryptogram' ) response = @gateway.authorize(100, credit_card, :test => true, :order_id => '1') - assert_equal "transaction_id", response.authorization + assert_equal 'transaction_id', response.authorization end def test_android_pay_card @@ -662,23 +662,23 @@ def test_android_pay_card :expiration_year => (Time.now.year + 1).to_s, :cryptogram => '111111111100cryptogram', :google_transaction_id => '1234567890', - :source_card_type => "visa", - :source_card_last_four => "1111", + :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", + :eci => '05', + :payment_cryptogram => '111111111100cryptogram', :source => :android_pay, :transaction_id => '1234567890' ) response = @gateway.authorize(100, credit_card, :test => true, :order_id => '1') - assert_equal "transaction_id", response.authorization + assert_equal 'transaction_id', response.authorization end def test_supports_network_tokenization @@ -687,7 +687,7 @@ def test_supports_network_tokenization def test_unsuccessful_transaction_returns_id_when_available Braintree::TransactionGateway.any_instance.expects(:sale).returns(braintree_error_result(transaction: {id: 'transaction_id'})) - assert response = @gateway.purchase(100, credit_card("41111111111111111111")) + assert response = @gateway.purchase(100, credit_card('41111111111111111111')) refute response.success? assert response.authorization.present? end @@ -696,7 +696,7 @@ def test_unsuccessful_transaction_returns_message_when_available Braintree::TransactionGateway.any_instance. expects(:sale). returns(braintree_error_result(message: 'Some error message')) - assert response = @gateway.purchase(100, credit_card("41111111111111111111")) + assert response = @gateway.purchase(100, credit_card('41111111111111111111')) refute response.success? assert_equal response.message, 'Some error message' end @@ -704,7 +704,7 @@ def test_unsuccessful_transaction_returns_message_when_available def test_refund_unsettled_payment Braintree::TransactionGateway.any_instance. expects(:refund). - returns(braintree_error_result(message: "Cannot refund a transaction unless it is settled. (91506)")) + returns(braintree_error_result(message: 'Cannot refund a transaction unless it is settled. (91506)')) Braintree::TransactionGateway.any_instance. expects(:void). @@ -717,7 +717,7 @@ def test_refund_unsettled_payment def test_refund_unsettled_payment_forces_void_on_full_refund Braintree::TransactionGateway.any_instance. expects(:refund). - returns(braintree_error_result(message: "Cannot refund a transaction unless it is settled. (91506)")) + returns(braintree_error_result(message: 'Cannot refund a transaction unless it is settled. (91506)')) Braintree::TransactionGateway.any_instance. expects(:void). @@ -730,7 +730,7 @@ def test_refund_unsettled_payment_forces_void_on_full_refund 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 = {}) diff --git a/test/unit/gateways/braintree_orange_test.rb b/test/unit/gateways/braintree_orange_test.rb index 6ed0d3481e5..80eebb19dfc 100644 --- a/test/unit/gateways/braintree_orange_test.rb +++ b/test/unit/gateways/braintree_orange_test.rb @@ -40,15 +40,15 @@ def test_successful_store assert response = @gateway.store(@credit_card, @options) assert_instance_of Response, response assert_success response - assert_equal "853162645", response.authorization - assert_equal response.authorization, response.params["customer_vault_id"] + assert_equal '853162645', response.authorization + assert_equal response.authorization, response.params['customer_vault_id'] end def test_add_processor result = {} @gateway.send(:add_processor, result, {:processor => 'ccprocessorb'} ) - assert_equal ["processor_id"], result.stringify_keys.keys.sort + assert_equal ['processor_id'], result.stringify_keys.keys.sort assert_equal 'ccprocessorb', result[:processor_id] end @@ -87,27 +87,27 @@ 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 - assert_equal 'CO', result["state"] - assert_equal '164 Waverley Street', result["address1"] - assert_equal 'US', result["country"] + assert_equal ['address1', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort + assert_equal 'CO', result['state'] + assert_equal '164 Waverley Street', result['address1'] + assert_equal 'US', result['country'] end 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 - assert_equal 'CO', result["shipping_state"] - assert_equal '164 Waverley Street', result["shipping_address1"] - assert_equal 'US', result["shipping_country"] + @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'},'shipping' ) + assert_equal ['shipping_address1', 'shipping_city', 'shipping_company', 'shipping_country', 'shipping_phone', 'shipping_state', 'shipping_zip'], result.stringify_keys.keys.sort + assert_equal 'CO', result['shipping_state'] + assert_equal '164 Waverley Street', result['shipping_address1'] + assert_equal 'US', result['shipping_country'] end 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 + assert_equal ['ccexp', 'ccnumber', 'customer_vault', 'cvv', 'firstname', 'lastname'], result.stringify_keys.keys.sort assert_equal 'add_customer', result[:customer_vault] end @@ -115,7 +115,7 @@ 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 ['ccexp', 'ccnumber', 'cvv', 'firstname', 'lastname'], result.stringify_keys.keys.sort assert_nil result[:customer_vault] end @@ -189,14 +189,14 @@ def failed_void_response end def successful_store_response - "response=1&responsetext=Customer Added&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=853162645" + 'response=1&responsetext=Customer Added&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=853162645' end def transcript - "username=demo&password=password&type=sale&orderid=8267b7f890aac7699f6ebc93c7c94d96&ccnumber=4111111111111111&cvv=123&ccexp=0916&firstname=Longbob&lastname=Longsen&address1=456+My+Street&address2=Apt+1&company=Widgets+Inc&phone=%28555%29555-5555&zip=K1C2N6&city=Ottawa&country=CA&state=ON&currency=USD&tax=&amount=77.70" + 'username=demo&password=password&type=sale&orderid=8267b7f890aac7699f6ebc93c7c94d96&ccnumber=4111111111111111&cvv=123&ccexp=0916&firstname=Longbob&lastname=Longsen&address1=456+My+Street&address2=Apt+1&company=Widgets+Inc&phone=%28555%29555-5555&zip=K1C2N6&city=Ottawa&country=CA&state=ON&currency=USD&tax=&amount=77.70' end def scrubbed_transcript - "username=demo&password=password&type=sale&orderid=8267b7f890aac7699f6ebc93c7c94d96&ccnumber=[FILTERED]&cvv=[FILTERED]&ccexp=0916&firstname=Longbob&lastname=Longsen&address1=456+My+Street&address2=Apt+1&company=Widgets+Inc&phone=%28555%29555-5555&zip=K1C2N6&city=Ottawa&country=CA&state=ON&currency=USD&tax=&amount=77.70" + 'username=demo&password=password&type=sale&orderid=8267b7f890aac7699f6ebc93c7c94d96&ccnumber=[FILTERED]&cvv=[FILTERED]&ccexp=0916&firstname=Longbob&lastname=Longsen&address1=456+My+Street&address2=Apt+1&company=Widgets+Inc&phone=%28555%29555-5555&zip=K1C2N6&city=Ottawa&country=CA&state=ON&currency=USD&tax=&amount=77.70' end end diff --git a/test/unit/gateways/braintree_test.rb b/test/unit/gateways/braintree_test.rb index 07b8922305b..7cff9f6512f 100644 --- a/test/unit/gateways/braintree_test.rb +++ b/test/unit/gateways/braintree_test.rb @@ -20,11 +20,11 @@ def test_new_with_merchant_id_creates_braintree_blue end def test_should_have_display_name_of_just_braintree - assert_equal "Braintree", BraintreeGateway.display_name + assert_equal 'Braintree', BraintreeGateway.display_name end def test_should_have_homepage_url - assert_equal "http://www.braintreepaymentsolutions.com", BraintreeGateway.homepage_url + assert_equal 'http://www.braintreepaymentsolutions.com', BraintreeGateway.homepage_url end def test_should_have_supported_credit_card_types @@ -32,6 +32,6 @@ def test_should_have_supported_credit_card_types end def test_should_have_default_currency - assert_equal "USD", BraintreeGateway.default_currency + assert_equal 'USD', BraintreeGateway.default_currency end end diff --git a/test/unit/gateways/bridge_pay_test.rb b/test/unit/gateways/bridge_pay_test.rb index 5a0e640a08b..ce60e3e05f9 100644 --- a/test/unit/gateways/bridge_pay_test.rb +++ b/test/unit/gateways/bridge_pay_test.rb @@ -59,7 +59,7 @@ def test_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "OK2657|838662", response.authorization + assert_equal 'OK2657|838662', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -76,7 +76,7 @@ def test_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "OK9757|837495", response.authorization + assert_equal 'OK9757|837495', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -93,7 +93,7 @@ def test_void end.respond_with(successful_purchase_response) assert_success response - assert_equal "OK9757|837495", response.authorization + assert_equal 'OK9757|837495', response.authorization refund = stub_comms do @gateway.void(response.authorization) @@ -110,14 +110,14 @@ def test_store_and_purchase_with_token end.respond_with(successful_store_response) assert_success store - assert_equal "Success", store.message + assert_equal 'Success', store.message purchase = stub_comms do @gateway.purchase(@amount, store.authorization) end.respond_with(successful_purchase_response) assert_success purchase - assert_equal "Approved", purchase.message + assert_equal 'Approved', purchase.message end def test_passing_cvv @@ -142,7 +142,7 @@ def test_successful_verify @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, successful_void_response) assert_success response - assert_equal "OK2657", response.params["authcode"] + assert_equal 'OK2657', response.params['authcode'] end def test_successful_verify_with_failed_void @@ -150,7 +150,7 @@ def test_successful_verify_with_failed_void @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_unsuccessful_verify @@ -158,7 +158,7 @@ def test_unsuccessful_verify @gateway.verify(@credit_card, @options) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "Invalid Account Number", response.message + assert_equal 'Invalid Account Number', response.message end def test_scrub diff --git a/test/unit/gateways/cams_test.rb b/test/unit/gateways/cams_test.rb index d9edc5e56bb..23102e41c39 100644 --- a/test/unit/gateways/cams_test.rb +++ b/test/unit/gateways/cams_test.rb @@ -50,7 +50,7 @@ def test_failed_authorize end def test_successful_capture - authorization = "12345678#54321" + authorization = '12345678#54321' @gateway.expects(:ssl_post).returns(successful_capture_response) assert capture = @gateway.capture(@amount, authorization) @@ -65,7 +65,7 @@ def test_failed_capture end def test_successful_refund - authorization = "12345678#54321" + authorization = '12345678#54321' @gateway.expects(:ssl_post).returns(successful_refund_response) assert refund = @gateway.refund(nil, authorization) @@ -80,7 +80,7 @@ def test_failed_refund end def test_successful_void - authorization = "12345678#54321" + authorization = '12345678#54321' @gateway.expects(:ssl_post).returns(successful_void_response) assert void = @gateway.void(authorization) diff --git a/test/unit/gateways/card_connect_test.rb b/test/unit/gateways/card_connect_test.rb index 2bc560d4e1d..704a89ec6ef 100644 --- a/test/unit/gateways/card_connect_test.rb +++ b/test/unit/gateways/card_connect_test.rb @@ -163,7 +163,7 @@ def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_equal "Insufficient funds", response.message + assert_equal 'Insufficient funds', response.message end def test_successful_store @@ -251,75 +251,75 @@ def post_scrubbed end def successful_purchase_response - "{\"amount\":\"1.00\",\"resptext\":\"Approval\",\"commcard\":\" C \",\"cvvresp\":\"M\",\"batchid\":\"1900941444\",\"avsresp\":\" \",\"respcode\":\"00\",\"merchid\":\"496160873888\",\"token\":\"9405701444882224\",\"authcode\":\"PPS500\",\"respproc\":\"FNOR\",\"retref\":\"363652261392\",\"respstat\":\"A\",\"account\":\"9405701444882224\"}" + '{"amount":"1.00","resptext":"Approval","commcard":" C ","cvvresp":"M","batchid":"1900941444","avsresp":" ","respcode":"00","merchid":"496160873888","token":"9405701444882224","authcode":"PPS500","respproc":"FNOR","retref":"363652261392","respstat":"A","account":"9405701444882224"}' end def successful_echeck_purchase_response - "{\"amount\":\"1.00\",\"resptext\":\"Success\",\"cvvresp\":\"U\",\"batchid\":\"1900940633\",\"avsresp\":\"U\",\"respcode\":\"00\",\"merchid\":\"542041\",\"token\":\"9051769384108535\",\"authcode\":\"GF7PBR\",\"respproc\":\"PSTR\",\"retref\":\"010136262668\",\"respstat\":\"A\",\"account\":\"9051769384108535\"}" + '{"amount":"1.00","resptext":"Success","cvvresp":"U","batchid":"1900940633","avsresp":"U","respcode":"00","merchid":"542041","token":"9051769384108535","authcode":"GF7PBR","respproc":"PSTR","retref":"010136262668","respstat":"A","account":"9051769384108535"}' end def failed_echeck_purchase_response - "{\"respproc\":\"PPS\",\"amount\":\"0.00\",\"resptext\":\"Invalid card\",\"cardproc\":\"PSTR\",\"retref\":\"010108164081\",\"respstat\":\"C\",\"respcode\":\"11\",\"account\":\"9235405400368535\",\"merchid\":\"542041\",\"token\":\"9235405400368535\"}" + '{"respproc":"PPS","amount":"0.00","resptext":"Invalid card","cardproc":"PSTR","retref":"010108164081","respstat":"C","respcode":"11","account":"9235405400368535","merchid":"542041","token":"9235405400368535"}' end def failed_purchase_response - "{\"respproc\":\"FNOR\",\"amount\":\"0.00\",\"resptext\":\"Insufficient funds\",\"cardproc\":\"FNOR\",\"commcard\":\" C \",\"retref\":\"005533134378\",\"respstat\":\"C\",\"respcode\":\"NU\",\"account\":\"9435885049491053\",\"merchid\":\"496160873888\",\"token\":\"9435885049491053\"}" + '{"respproc":"FNOR","amount":"0.00","resptext":"Insufficient funds","cardproc":"FNOR","commcard":" C ","retref":"005533134378","respstat":"C","respcode":"NU","account":"9435885049491053","merchid":"496160873888","token":"9435885049491053"}' end def successful_authorize_response - "{\"amount\":\"1.00\",\"resptext\":\"Approval\",\"commcard\":\" C \",\"cvvresp\":\"M\",\"avsresp\":\" \",\"respcode\":\"00\",\"merchid\":\"496160873888\",\"token\":\"9405701444882224\",\"authcode\":\"PPS454\",\"respproc\":\"FNOR\",\"retref\":\"363168161558\",\"respstat\":\"A\",\"account\":\"9405701444882224\"}" + '{"amount":"1.00","resptext":"Approval","commcard":" C ","cvvresp":"M","avsresp":" ","respcode":"00","merchid":"496160873888","token":"9405701444882224","authcode":"PPS454","respproc":"FNOR","retref":"363168161558","respstat":"A","account":"9405701444882224"}' end def failed_authorize_response - "{\"respproc\":\"FNOR\",\"amount\":\"0.00\",\"resptext\":\"Insufficient funds\",\"cardproc\":\"FNOR\",\"commcard\":\" C \",\"retref\":\"005737235263\",\"respstat\":\"C\",\"respcode\":\"NU\",\"account\":\"9435885049491053\",\"merchid\":\"496160873888\",\"token\":\"9435885049491053\"}" + '{"respproc":"FNOR","amount":"0.00","resptext":"Insufficient funds","cardproc":"FNOR","commcard":" C ","retref":"005737235263","respstat":"C","respcode":"NU","account":"9435885049491053","merchid":"496160873888","token":"9435885049491053"}' end def successful_capture_response - "{\"respproc\":\"FNOR\",\"amount\":\"1.00\",\"resptext\":\"Approval\",\"setlstat\":\"Queued for Capture\",\"commcard\":\" C \",\"retref\":\"363168161558\",\"respstat\":\"A\",\"respcode\":\"00\",\"batchid\":\"1900941444\",\"account\":\"9405701444882224\",\"merchid\":\"496160873888\",\"token\":\"9405701444882224\"}" + '{"respproc":"FNOR","amount":"1.00","resptext":"Approval","setlstat":"Queued for Capture","commcard":" C ","retref":"363168161558","respstat":"A","respcode":"00","batchid":"1900941444","account":"9405701444882224","merchid":"496160873888","token":"9405701444882224"}' end def failed_capture_response - "{\"respproc\":\"PPS\",\"resptext\":\"Txn not found\",\"retref\":\"23221\",\"respstat\":\"C\",\"respcode\":\"29\",\"batchid\":\"-1\",\"account\":\"\"}" + '{"respproc":"PPS","resptext":"Txn not found","retref":"23221","respstat":"C","respcode":"29","batchid":"-1","account":""}' end def successful_refund_response - "{\"respproc\":\"PPS\",\"amount\":\"1.00\",\"resptext\":\"Approval\",\"retref\":\"363661261786\",\"respstat\":\"A\",\"respcode\":\"00\",\"merchid\":\"496160873888\"}" + '{"respproc":"PPS","amount":"1.00","resptext":"Approval","retref":"363661261786","respstat":"A","respcode":"00","merchid":"496160873888"}' end def failed_refund_response - "{\"respproc\":\"PPS\",\"resptext\":\"Txn not found\",\"retref\":\"23221\",\"respcode\":\"29\",\"respstat\":\"C\"}" + '{"respproc":"PPS","resptext":"Txn not found","retref":"23221","respcode":"29","respstat":"C"}' end def successful_void_response - "{\"authcode\":\"REVERS\",\"respproc\":\"FNOR\",\"amount\":\"0.00\",\"resptext\":\"Approval\",\"currency\":\"USD\",\"retref\":\"363664261982\",\"respstat\":\"A\",\"respcode\":\"00\",\"merchid\":\"496160873888\"}" + '{"authcode":"REVERS","respproc":"FNOR","amount":"0.00","resptext":"Approval","currency":"USD","retref":"363664261982","respstat":"A","respcode":"00","merchid":"496160873888"}' end def failed_void_response - "{\"respproc\":\"PPS\",\"resptext\":\"Txn not found\",\"retref\":\"23221\",\"respcode\":\"29\",\"respstat\":\"C\"}" + '{"respproc":"PPS","resptext":"Txn not found","retref":"23221","respcode":"29","respstat":"C"}' end def successful_verify_response - "{\"amount\":\"0.00\",\"resptext\":\"Approval\",\"commcard\":\" C \",\"cvvresp\":\"M\",\"avsresp\":\" \",\"respcode\":\"00\",\"merchid\":\"496160873888\",\"token\":\"9405701444882224\",\"authcode\":\"PPS585\",\"respproc\":\"FNOR\",\"retref\":\"363272166977\",\"respstat\":\"A\",\"account\":\"9405701444882224\"}" + '{"amount":"0.00","resptext":"Approval","commcard":" C ","cvvresp":"M","avsresp":" ","respcode":"00","merchid":"496160873888","token":"9405701444882224","authcode":"PPS585","respproc":"FNOR","retref":"363272166977","respstat":"A","account":"9405701444882224"}' end def failed_verify_response - "{\"respproc\":\"FNOR\",\"amount\":\"0.00\",\"resptext\":\"Insufficient funds\",\"cardproc\":\"FNOR\",\"commcard\":\" C \",\"retref\":\"005101240599\",\"respstat\":\"C\",\"respcode\":\"NU\",\"account\":\"9435885049491053\",\"merchid\":\"496160873888\",\"token\":\"9435885049491053\"}" + '{"respproc":"FNOR","amount":"0.00","resptext":"Insufficient funds","cardproc":"FNOR","commcard":" C ","retref":"005101240599","respstat":"C","respcode":"NU","account":"9435885049491053","merchid":"496160873888","token":"9435885049491053"}' end def successful_store_response - "{\"country\":\"CA\",\"gsacard\":\"N\",\"address\":\"456 My Street Apt 1\",\"resptext\":\"Profile Saved\",\"city\":\"Ottawa\",\"acctid\":\"1\",\"respcode\":\"09\",\"defaultacct\":\"Y\",\"accttype\":\"VISA\",\"token\":\"9477709629051443\",\"respproc\":\"PPS\",\"phone\":\"(555)555-555\",\"profileid\":\"16700875781344019340\",\"name\":\"Longbob Longsen\",\"auoptout\":\"N\",\"postal\":\"K1C2N6\",\"expiry\":\"0919\",\"region\":\"ON\",\"respstat\":\"A\"}" + '{"country":"CA","gsacard":"N","address":"456 My Street Apt 1","resptext":"Profile Saved","city":"Ottawa","acctid":"1","respcode":"09","defaultacct":"Y","accttype":"VISA","token":"9477709629051443","respproc":"PPS","phone":"(555)555-555","profileid":"16700875781344019340","name":"Longbob Longsen","auoptout":"N","postal":"K1C2N6","expiry":"0919","region":"ON","respstat":"A"}' end def successful_unstore_response - "{\"respproc\":\"PPS\",\"resptext\":\"Profile Deleted\",\"respstat\":\"A\",\"respcode\":\"08\"}" + '{"respproc":"PPS","resptext":"Profile Deleted","respstat":"A","respcode":"08"}' end def failed_store_response # Best-guess based on documentation - "{\"country\":\"CA\",\"gsacard\":\"N\",\"address\":\"456 My Street Apt 1\",\"resptext\":\"Profile Saved\",\"city\":\"Ottawa\",\"acctid\":\"1\",\"respcode\":\"09\",\"defaultacct\":\"Y\",\"accttype\":\"VISA\",\"token\":\"9477709629051443\",\"respproc\":\"PPS\",\"phone\":\"(555)555-555\",\"profileid\":\"16700875781344019340\",\"name\":\"Longbob Longsen\",\"auoptout\":\"N\",\"postal\":\"K1C2N6\",\"expiry\":\"0919\",\"region\":\"ON\",\"respstat\":\"C\"}" + '{"country":"CA","gsacard":"N","address":"456 My Street Apt 1","resptext":"Profile Saved","city":"Ottawa","acctid":"1","respcode":"09","defaultacct":"Y","accttype":"VISA","token":"9477709629051443","respproc":"PPS","phone":"(555)555-555","profileid":"16700875781344019340","name":"Longbob Longsen","auoptout":"N","postal":"K1C2N6","expiry":"0919","region":"ON","respstat":"C"}' end def failed_unstore_response - "{\"respproc\":\"PPS\",\"resptext\":\"Profile not found\",\"respstat\":\"C\",\"respcode\":\"96\"}" + '{"respproc":"PPS","resptext":"Profile not found","respstat":"C","respcode":"96"}' end end diff --git a/test/unit/gateways/card_save_test.rb b/test/unit/gateways/card_save_test.rb index 8377581dd45..bb19495a1f1 100644 --- a/test/unit/gateways/card_save_test.rb +++ b/test/unit/gateways/card_save_test.rb @@ -59,7 +59,7 @@ def test_successful_authorize def test_successful_capture @gateway.expects(:ssl_post).returns(capture_successful) - assert response = @gateway.capture(1111, "1;110706124418747501702211;702211") + assert response = @gateway.capture(1111, '1;110706124418747501702211;702211') assert_success response assert_equal('110706124418747501702211', response.authorization) assert response.test? diff --git a/test/unit/gateways/card_stream_test.rb b/test/unit/gateways/card_stream_test.rb index c92b6459075..8eab0ad4030 100644 --- a/test/unit/gateways/card_stream_test.rb +++ b/test/unit/gateways/card_stream_test.rb @@ -18,10 +18,10 @@ def setup @visacredit_options = { :billing_address => { - :address1 => "Flat 6, Primrose Rise", - :address2 => "347 Lavender Road", - :city => "", - :state => "Northampton", + :address1 => 'Flat 6, Primrose Rise', + :address2 => '347 Lavender Road', + :city => '', + :state => 'Northampton', :zip => 'NN17 8YG ' }, :order_id => generate_unique_id, @@ -30,10 +30,10 @@ def setup @visacredit_descriptor_options = { :billing_address => { - :address1 => "Flat 6, Primrose Rise", - :address2 => "347 Lavender Road", - :city => "", - :state => "Northampton", + :address1 => 'Flat 6, Primrose Rise', + :address2 => '347 Lavender Road', + :city => '', + :state => 'Northampton', :zip => 'NN17 8YG ' }, :merchant_name => 'merchant', @@ -62,13 +62,13 @@ def test_successful_avs_and_cvv_results assert response = @gateway.authorize(142, @visacreditcard, @visacredit_options) assert_success response assert response.avs_result - assert_equal "M", response.avs_result['code'] - assert_equal "Street address and postal code match.", response.avs_result['message'] - assert_equal "Y", response.avs_result['street_match'] - assert_equal "Y", response.avs_result['postal_match'] + assert_equal 'M', response.avs_result['code'] + assert_equal 'Street address and postal code match.', response.avs_result['message'] + assert_equal 'Y', response.avs_result['street_match'] + assert_equal 'Y', response.avs_result['postal_match'] assert response.cvv_result - assert_equal "M", response.cvv_result['code'] + assert_equal 'M', response.cvv_result['code'] end def test_successful_visacreditcard_capture @@ -83,7 +83,7 @@ def test_successful_visacreditcard_capture def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - assert responseRefund = @gateway.refund(142, "authorization", @visacredit_options) + assert responseRefund = @gateway.refund(142, 'authorization', @visacredit_options) assert_equal 'APPROVED', responseRefund.message assert_success responseRefund assert responseRefund.test? @@ -103,7 +103,7 @@ def test_successful_refund_due_to_unsettled_payment_forces_void def test_failed_refund_due_to_unsettled_payment @gateway.expects(:ssl_post).returns(failed_refund_for_unsettled_payment_response) - assert refund = @gateway.refund(142, "authorization", @visacredit_options) + assert refund = @gateway.refund(142, 'authorization', @visacredit_options) assert_equal 'Can not REFUND this SALE transaction', refund.message assert_failure refund assert refund.test? @@ -112,7 +112,7 @@ def test_failed_refund_due_to_unsettled_payment def test_successful_visacreditcard_void @gateway.expects(:ssl_post).returns(successful_void_response) - assert responseRefund = @gateway.void("authorization", @visacredit_options) + assert responseRefund = @gateway.void('authorization', @visacredit_options) assert_equal 'APPROVED', responseRefund.message assert_success responseRefund assert responseRefund.test? @@ -184,7 +184,7 @@ def test_successful_verify @gateway.verify(@visacreditcard, @visacredit_options) end.respond_with(successful_authorization_response, failed_void_response) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message end def test_failed_verify @@ -192,7 +192,7 @@ def test_failed_verify @gateway.verify(@declined_card, @visacredit_options) end.respond_with(failed_authorization_response, successful_void_response) assert_failure response - assert_equal "CARD DECLINED", response.message + assert_equal 'CARD DECLINED', response.message end def test_purchase_options @@ -215,7 +215,7 @@ def test_purchase_options assert_success purchase purchase = stub_comms do - @gateway.purchase(142, @visacreditcard, @visacredit_options.merge(currency: "PEN")) + @gateway.purchase(142, @visacreditcard, @visacredit_options.merge(currency: 'PEN')) end.check_request do |endpoint, data, headers| assert_match(/currencyCode=604/, data) end.respond_with(successful_purchase_response) @@ -225,7 +225,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 @@ -254,9 +254,9 @@ def test_3ds_response end.respond_with(successful_purchase_response_with_3dsecure) assert_failure purchase # 3DS required means purchase not _yet_ successful - assert_equal "UDNLRVk6eHJlZj0xNTA4MDYxNVJaMThSSjE1Uko2NFlWWg==", purchase.params["threeDSMD"] - assert_equal "eJxVUttuwjAM/ZWKD2iaQrnJjVQGA7TBGFSTeMxSC8rohTRd2d8vKe0YD5F8jh37\r\n+CQQHiXidIeilMhghUXBD2jFkd/xPNHtCz747EaCdhhsgi1eGHyjLOIsZdR2bBdI\r\nC/VVKY48VQy4uEyWa+YN6LDbA9JASFAup2zk9Tx3pOkbhJQnyHa5FhGdf6wQC2UF\r\nQmRlqizdvc5CDeUPG7p9IC2AUp7ZUam8GBNSVZUtuIwKJZEntsgSAsQUALnr2pQm\r\nKnTDaxyx1TSoHs/BW5/2zlsofCCmAiKukLkO9Zyh07dob0yHYzoAUvPAE6OEzScb\r\ni7q2o9U2DORmUHAD1DWZ/wxoqyWmot2nRYDXPEtRV+gLfzFEWAgWrCxlrMmbFbQG\r\nQwO57/S0MM4LpU1dxM/hrJx9zU8f6/3WuZxGL6/vle+bt6gLzKhYe6h3u80yAIhp\r\nQZpnJs1X0NHDF/kFvj+6mg==", purchase.params["threeDSPaReq"] - assert_equal "https://dropit.3dsecure.net:9443/PIT/ACS", purchase.params["threeDSACSURL"] + assert_equal 'UDNLRVk6eHJlZj0xNTA4MDYxNVJaMThSSjE1Uko2NFlWWg==', purchase.params['threeDSMD'] + assert_equal "eJxVUttuwjAM/ZWKD2iaQrnJjVQGA7TBGFSTeMxSC8rohTRd2d8vKe0YD5F8jh37\r\n+CQQHiXidIeilMhghUXBD2jFkd/xPNHtCz747EaCdhhsgi1eGHyjLOIsZdR2bBdI\r\nC/VVKY48VQy4uEyWa+YN6LDbA9JASFAup2zk9Tx3pOkbhJQnyHa5FhGdf6wQC2UF\r\nQmRlqizdvc5CDeUPG7p9IC2AUp7ZUam8GBNSVZUtuIwKJZEntsgSAsQUALnr2pQm\r\nKnTDaxyx1TSoHs/BW5/2zlsofCCmAiKukLkO9Zyh07dob0yHYzoAUvPAE6OEzScb\r\ni7q2o9U2DORmUHAD1DWZ/wxoqyWmot2nRYDXPEtRV+gLfzFEWAgWrCxlrMmbFbQG\r\nQwO57/S0MM4LpU1dxM/hrJx9zU8f6/3WuZxGL6/vle+bt6gLzKhYe6h3u80yAIhp\r\nQZpnJs1X0NHDF/kFvj+6mg==", purchase.params['threeDSPaReq'] + assert_equal 'https://dropit.3dsecure.net:9443/PIT/ACS', purchase.params['threeDSACSURL'] end def test_deprecated_3ds_required @@ -289,55 +289,55 @@ def test_transcript_scrubbing private def successful_authorization_response - "merchantID=0000000&threeDSEnabled=Y&merchantDescription=General+test+account+with+AVS%2FCV2+checking&amount=142&currencyCode=826&transactionUnique=fadc4985c51fc55ca349c45a79136ade&orderRef=AM+test+purchase&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostCode=NN17+8YG+&action=PREAUTH&type=1&countryCode=826&merchantAlias=0000992&remoteAddress=80.229.33.63&responseCode=0&responseMessage=AUTHCODE%3AD24577&xref=13021914RV01VR56LR16FNF&threeDSEnrolled=U&threeDSXID=00000000000004717472&transactionID=4717472&transactionPreviousID=0&timestamp=2013-02-19+14%3A02%3A19&amountReceived=142&avscv2ResponseCode=222100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&cv2Check=matched&addressCheck=2&postcodeCheck=2&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A0821&cardTypeCode=VC&cardType=Visa+Credit&threeDSErrorCode=-1&threeDSErrorDescription=Error+while+attempting+to+send+the+request+to%3A+https%3A%2F%2F3dstest.universalpaymentgateway.com%3A4343%2FAPI%0A%0DPlease+make+sure+that+ActiveMerchant+server+is+running+and+the+URL+is+valid.+ERROR_INTERNET_CANNOT_CONNECT%3A+The+attempt+to+connect+to+the+server+failed.&threeDSMerchantPref=PROCEED&threeDSVETimestamp=2013-02-19+14%3A01%3A56&currencyExponent=2&responseStatus=0&merchantName=CARDSTREAM+TEST&merchantID2=100001" + 'merchantID=0000000&threeDSEnabled=Y&merchantDescription=General+test+account+with+AVS%2FCV2+checking&amount=142&currencyCode=826&transactionUnique=fadc4985c51fc55ca349c45a79136ade&orderRef=AM+test+purchase&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostCode=NN17+8YG+&action=PREAUTH&type=1&countryCode=826&merchantAlias=0000992&remoteAddress=80.229.33.63&responseCode=0&responseMessage=AUTHCODE%3AD24577&xref=13021914RV01VR56LR16FNF&threeDSEnrolled=U&threeDSXID=00000000000004717472&transactionID=4717472&transactionPreviousID=0&timestamp=2013-02-19+14%3A02%3A19&amountReceived=142&avscv2ResponseCode=222100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&cv2Check=matched&addressCheck=2&postcodeCheck=2&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A0821&cardTypeCode=VC&cardType=Visa+Credit&threeDSErrorCode=-1&threeDSErrorDescription=Error+while+attempting+to+send+the+request+to%3A+https%3A%2F%2F3dstest.universalpaymentgateway.com%3A4343%2FAPI%0A%0DPlease+make+sure+that+ActiveMerchant+server+is+running+and+the+URL+is+valid.+ERROR_INTERNET_CANNOT_CONNECT%3A+The+attempt+to+connect+to+the+server+failed.&threeDSMerchantPref=PROCEED&threeDSVETimestamp=2013-02-19+14%3A01%3A56&currencyExponent=2&responseStatus=0&merchantName=CARDSTREAM+TEST&merchantID2=100001' end def successful_capture_response - "merchantID=0000000&threeDSEnabled=Y&merchantDescription=General+test+account+with+AVS%2FCV2+checking&xref=13021914XW02YJ20MQ37RMT&amount=142&currencyCode=826&action=SALE&type=1&countryCode=826&merchantAlias=0000992&remoteAddress=80.229.33.63&responseCode=0&responseMessage=AUTHCODE%3A39657X&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostCode=NN17+8YG+&transactionUnique=fadc4985c51fc55ca349c45a79136ade&orderRef=AM+test+purchase&amountReceived=142&avscv2ResponseCode=422100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&cv2Check=not+matched&addressCheck=matched&postcodeCheck=matched&threeDSXID=00000000000004717475&threeDSEnrolled=U&threeDSErrorCode=-1&threeDSErrorDescription=Error+while+attempting+to+send+the+request+to%3A+https%3A%2F%2F3dstest.universalpaymentgateway.com%3A4343%2FAPI%0A%0DPlease+make+sure+that+ActiveMerchant+server+is+running+and+the+URL+is+valid.+ERROR_INTERNET_CANNOT_CONNECT%3A+The+attempt+to+connect+to+the+server+failed.&threeDSMerchantPref=PROCEED&threeDSVETimestamp=2013-02-19+14%3A02%3A20&cardTypeCode=VC&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A0821&transactionID=4717475&transactionPreviousID=4717472&timestamp=2013-02-19+14%3A02%3A44&cardType=Visa+Credit&currencyExponent=2&responseStatus=0&merchantName=CARDSTREAM+TEST&merchantID2=100001" + 'merchantID=0000000&threeDSEnabled=Y&merchantDescription=General+test+account+with+AVS%2FCV2+checking&xref=13021914XW02YJ20MQ37RMT&amount=142&currencyCode=826&action=SALE&type=1&countryCode=826&merchantAlias=0000992&remoteAddress=80.229.33.63&responseCode=0&responseMessage=AUTHCODE%3A39657X&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostCode=NN17+8YG+&transactionUnique=fadc4985c51fc55ca349c45a79136ade&orderRef=AM+test+purchase&amountReceived=142&avscv2ResponseCode=422100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&cv2Check=not+matched&addressCheck=matched&postcodeCheck=matched&threeDSXID=00000000000004717475&threeDSEnrolled=U&threeDSErrorCode=-1&threeDSErrorDescription=Error+while+attempting+to+send+the+request+to%3A+https%3A%2F%2F3dstest.universalpaymentgateway.com%3A4343%2FAPI%0A%0DPlease+make+sure+that+ActiveMerchant+server+is+running+and+the+URL+is+valid.+ERROR_INTERNET_CANNOT_CONNECT%3A+The+attempt+to+connect+to+the+server+failed.&threeDSMerchantPref=PROCEED&threeDSVETimestamp=2013-02-19+14%3A02%3A20&cardTypeCode=VC&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A0821&transactionID=4717475&transactionPreviousID=4717472&timestamp=2013-02-19+14%3A02%3A44&cardType=Visa+Credit&currencyExponent=2&responseStatus=0&merchantName=CARDSTREAM+TEST&merchantID2=100001' end def successful_refund_response - "merchantID=0000000&threeDSEnabled=Y&merchantDescription=General+test+account+with+AVS%2FCV2+checking&xref=13021914NT06BM21GJ15VJH&amount=142&currencyCode=826&action=REFUND&type=1&countryCode=826&merchantAlias=0000992&remoteAddress=80.229.33.63&responseCode=0&responseMessage=REFUNDACCEPTED&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostCode=NN17+8YG+&transactionUnique=c7981d78d217cf3cfda6559921e31c4a&orderRef=AM+test+purchase&amountReceived=142&avscv2ResponseCode=222100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&cv2Check=matched&addressCheck=matched&postcodeCheck=matched&threeDSXID=00000000000004717488&threeDSEnrolled=U&threeDSErrorCode=-1&threeDSErrorDescription=Error+while+attempting+to+send+the+request+to%3A+https%3A%2F%2F3dstest.universalpaymentgateway.com%3A4343%2FAPI%0A%0DPlease+make+sure+that+ActiveMerchant+server+is+running+and+the+URL+is+valid.+ERROR_INTERNET_CANNOT_CONNECT%3A+The+attempt+to+connect+to+the+server+failed.&threeDSMerchantPref=PROCEED&threeDSVETimestamp=2013-02-19+14%3A05%3A58&cardTypeCode=VC&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A0821&threeDSRequired=N&transactionID=4717490&transactionPreviousID=4717488&timestamp=2013-02-19+14%3A06%3A21&cardType=Visa+Credit&currencyExponent=2&responseStatus=0&merchantName=CARDSTREAM+TEST&merchantID2=100001" + 'merchantID=0000000&threeDSEnabled=Y&merchantDescription=General+test+account+with+AVS%2FCV2+checking&xref=13021914NT06BM21GJ15VJH&amount=142&currencyCode=826&action=REFUND&type=1&countryCode=826&merchantAlias=0000992&remoteAddress=80.229.33.63&responseCode=0&responseMessage=REFUNDACCEPTED&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostCode=NN17+8YG+&transactionUnique=c7981d78d217cf3cfda6559921e31c4a&orderRef=AM+test+purchase&amountReceived=142&avscv2ResponseCode=222100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&cv2Check=matched&addressCheck=matched&postcodeCheck=matched&threeDSXID=00000000000004717488&threeDSEnrolled=U&threeDSErrorCode=-1&threeDSErrorDescription=Error+while+attempting+to+send+the+request+to%3A+https%3A%2F%2F3dstest.universalpaymentgateway.com%3A4343%2FAPI%0A%0DPlease+make+sure+that+ActiveMerchant+server+is+running+and+the+URL+is+valid.+ERROR_INTERNET_CANNOT_CONNECT%3A+The+attempt+to+connect+to+the+server+failed.&threeDSMerchantPref=PROCEED&threeDSVETimestamp=2013-02-19+14%3A05%3A58&cardTypeCode=VC&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A0821&threeDSRequired=N&transactionID=4717490&transactionPreviousID=4717488&timestamp=2013-02-19+14%3A06%3A21&cardType=Visa+Credit&currencyExponent=2&responseStatus=0&merchantName=CARDSTREAM+TEST&merchantID2=100001' end def failed_refund_for_unsettled_payment_response - "responseCode=65541&responseMessage=Can+not+REFUND+this+SALE+transaction&responseStatus=2&xref=18032714RP14KM21FX11YHT&amount=142&currencyCode=826&remoteAddress=1.1.1.1&countryCode=GB&merchantID=103191&action=REFUND_SALE&requestID=5aba43ad1481e&state=finished&requestMerchantID=103191&processMerchantID=103191&transactionID=25814232&timestamp=2018-03-27+14%3A14%3A21&vcsResponseCode=0&vcsResponseMessage=Success+-+no+velocity+check+rules+applied&signature=b56640b215510a04ebfaa095b63705cda08cca318a7ccb2b2b48caec75adc187d9cae5082eb1dc71d258813ee9d879721e48af04966a489171f435bfa67b6d92" + 'responseCode=65541&responseMessage=Can+not+REFUND+this+SALE+transaction&responseStatus=2&xref=18032714RP14KM21FX11YHT&amount=142&currencyCode=826&remoteAddress=1.1.1.1&countryCode=GB&merchantID=103191&action=REFUND_SALE&requestID=5aba43ad1481e&state=finished&requestMerchantID=103191&processMerchantID=103191&transactionID=25814232&timestamp=2018-03-27+14%3A14%3A21&vcsResponseCode=0&vcsResponseMessage=Success+-+no+velocity+check+rules+applied&signature=b56640b215510a04ebfaa095b63705cda08cca318a7ccb2b2b48caec75adc187d9cae5082eb1dc71d258813ee9d879721e48af04966a489171f435bfa67b6d92' end def successful_void_response - "merchantID=103191&threeDSEnabled=Y&avscv2CheckEnabled=N&eReceiptsEnabled=N&transactionID=11132605&xref=16050316NZ51LT53FP70BMZ&state=canceled&captureDelay=-1&remoteAddress=107.15.253.186&action=CANCEL%3ASALE&type=1&currencyCode=826&countryCode=826&amount=284&orderRef=AM+test+purchase&transactionUnique=2240526ccaa7d41af63a94aab843e683&cardTypeCode=VC&cardNumberMask=492942%2A%2A%2A%2A%2A%2A0821&cardExpiryDate=1214&cardExpiryMonth=12&cardExpiryYear=14&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostcode=NN17+8YG&eReceiptsStoreID=1&customerReceiptsRequired=N&cv2Check=matched&addressCheck=matched&postcodeCheck=matched&avscv2ResponseCode=222100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&addressCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&postcodeCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&threeDSRequired=N&threeDSCheckPref=authenticated&authorisationCode=084609&amountReceived=0&responseCode=0&responseMessage=Transaction+cancelled.&cardCVVMandatory=N&responseStatus=0&timestamp=2016-05-03+16%3A51%3A54&cardType=Visa+Credit&cardScheme=Visa+&cardSchemeCode=VC&cardIssuer=BARCLAYS+BANK+PLC&cardIssuerCountry=United+Kingdom&cardIssuerCountryCode=GBR&signature=73cf5ec5470f6a1b3abce4e2a4b64adc2da0cb7103e8d362b40ab101d2ff339961a593869f289f7660a286e8c92c22fd5dec4330cf7e7e0ca8651cd8c0a8d966" + 'merchantID=103191&threeDSEnabled=Y&avscv2CheckEnabled=N&eReceiptsEnabled=N&transactionID=11132605&xref=16050316NZ51LT53FP70BMZ&state=canceled&captureDelay=-1&remoteAddress=107.15.253.186&action=CANCEL%3ASALE&type=1&currencyCode=826&countryCode=826&amount=284&orderRef=AM+test+purchase&transactionUnique=2240526ccaa7d41af63a94aab843e683&cardTypeCode=VC&cardNumberMask=492942%2A%2A%2A%2A%2A%2A0821&cardExpiryDate=1214&cardExpiryMonth=12&cardExpiryYear=14&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostcode=NN17+8YG&eReceiptsStoreID=1&customerReceiptsRequired=N&cv2Check=matched&addressCheck=matched&postcodeCheck=matched&avscv2ResponseCode=222100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&addressCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&postcodeCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&threeDSRequired=N&threeDSCheckPref=authenticated&authorisationCode=084609&amountReceived=0&responseCode=0&responseMessage=Transaction+cancelled.&cardCVVMandatory=N&responseStatus=0&timestamp=2016-05-03+16%3A51%3A54&cardType=Visa+Credit&cardScheme=Visa+&cardSchemeCode=VC&cardIssuer=BARCLAYS+BANK+PLC&cardIssuerCountry=United+Kingdom&cardIssuerCountryCode=GBR&signature=73cf5ec5470f6a1b3abce4e2a4b64adc2da0cb7103e8d362b40ab101d2ff339961a593869f289f7660a286e8c92c22fd5dec4330cf7e7e0ca8651cd8c0a8d966' end def successful_purchase_response - "merchantID=0000000&threeDSEnabled=Y&merchantDescription=General+test+account+with+AVS%2FCV2+checking&amount=142&currencyCode=826&transactionUnique=27a594210e27846c8e9102647f210586&orderRef=AM+test+purchase&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostCode=NN17+8YG+&action=SALE&type=1&countryCode=826&merchantAlias=0000992&remoteAddress=80.229.33.63&responseCode=0&responseMessage=AUTHCODE%3A635959&xref=13021914LS06DW22NW22LVJ&threeDSEnrolled=U&threeDSXID=00000000000004717491&transactionID=4717491&transactionPreviousID=0&timestamp=2013-02-19+14%3A06%3A44&amountReceived=142&avscv2ResponseCode=222100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&cv2Check=matched&addressCheck=matched&postcodeCheck=matched&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A0821&cardTypeCode=VC&cardType=Visa+Credit&threeDSErrorCode=-1&threeDSErrorDescription=Error+while+attempting+to+send+the+request+to%3A+https%3A%2F%2F3dstest.universalpaymentgateway.com%3A4343%2FAPI%0A%0DPlease+make+sure+that+ActiveMerchant+server+is+running+and+the+URL+is+valid.+ERROR_INTERNET_CANNOT_CONNECT%3A+The+attempt+to+connect+to+the+server+failed.&threeDSMerchantPref=PROCEED&threeDSVETimestamp=2013-02-19+14%3A06%3A22&currencyExponent=2&responseStatus=0&merchantName=CARDSTREAM+TEST&merchantID2=100001" + 'merchantID=0000000&threeDSEnabled=Y&merchantDescription=General+test+account+with+AVS%2FCV2+checking&amount=142&currencyCode=826&transactionUnique=27a594210e27846c8e9102647f210586&orderRef=AM+test+purchase&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostCode=NN17+8YG+&action=SALE&type=1&countryCode=826&merchantAlias=0000992&remoteAddress=80.229.33.63&responseCode=0&responseMessage=AUTHCODE%3A635959&xref=13021914LS06DW22NW22LVJ&threeDSEnrolled=U&threeDSXID=00000000000004717491&transactionID=4717491&transactionPreviousID=0&timestamp=2013-02-19+14%3A06%3A44&amountReceived=142&avscv2ResponseCode=222100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&cv2Check=matched&addressCheck=matched&postcodeCheck=matched&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A0821&cardTypeCode=VC&cardType=Visa+Credit&threeDSErrorCode=-1&threeDSErrorDescription=Error+while+attempting+to+send+the+request+to%3A+https%3A%2F%2F3dstest.universalpaymentgateway.com%3A4343%2FAPI%0A%0DPlease+make+sure+that+ActiveMerchant+server+is+running+and+the+URL+is+valid.+ERROR_INTERNET_CANNOT_CONNECT%3A+The+attempt+to+connect+to+the+server+failed.&threeDSMerchantPref=PROCEED&threeDSVETimestamp=2013-02-19+14%3A06%3A22&currencyExponent=2&responseStatus=0&merchantName=CARDSTREAM+TEST&merchantID2=100001' end def successful_purchase_response_with_3dsecure - "responseCode=65802&responseMessage=3DS+AUTHENTICATION+REQUIRED&responseStatus=2&merchantID=103191&threeDSEnabled=Y&threeDSCheckPref=not+known%2Cnot+checked%2Cauthenticated%2Cnot+authenticated%2Cattempted+authentication&avscv2CheckEnabled=N&cv2CheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&addressCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&postcodeCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&cardCVVMandatory=Y&customerID=1749&eReceiptsEnabled=N&eReceiptsStoreID=1&amount=1202&currencyCode=826&transactionUnique=42e13d06ce4d5f5e3eb4868d29baa8bb&orderRef=AM+test+purchase&threeDSRequired=Y&customerName=Longbob+Longsen&customerAddress=25+The+Larches&customerPostCode=LE10+2RT&action=SALE&type=1&countryCode=826&customerPostcode=LE10+2RT&customerReceiptsRequired=N&state=finished&remoteAddress=45.37.180.92&requestMerchantID=103191&processMerchantID=103191&xref=15080615RZ18RJ15RJ64YVZ&cardExpiryDate=1220&threeDSXID=MDAwMDAwMDAwMDAwMDg5NjY0OTc%3D&threeDSEnrolled=Y&transactionID=8966497&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A1112&cardType=Visa+Credit&cardTypeCode=VC&cardScheme=Visa+&cardSchemeCode=VC&cardIssuer=Unknown&cardIssuerCountry=Unknown&cardIssuerCountryCode=XXX&threeDSPaReq=eJxVUttuwjAM%2FZWKD2iaQrnJjVQGA7TBGFSTeMxSC8rohTRd2d8vKe0YD5F8jh37%0D%0A%2BCQQHiXidIeilMhghUXBD2jFkd%2FxPNHtCz747EaCdhhsgi1eGHyjLOIsZdR2bBdI%0D%0AC%2FVVKY48VQy4uEyWa%2BYN6LDbA9JASFAup2zk9Tx3pOkbhJQnyHa5FhGdf6wQC2UF%0D%0AQmRlqizdvc5CDeUPG7p9IC2AUp7ZUam8GBNSVZUtuIwKJZEntsgSAsQUALnr2pQm%0D%0AKnTDaxyx1TSoHs%2FBW5%2F2zlsofCCmAiKukLkO9Zyh07dob0yHYzoAUvPAE6OEzScb%0D%0Ai7q2o9U2DORmUHAD1DWZ%2FwxoqyWmot2nRYDXPEtRV%2BgLfzFEWAgWrCxlrMmbFbQG%0D%0AQwO57%2FS0MM4LpU1dxM%2FhrJx9zU8f6%2F3WuZxGL6%2Fvle%2Bbt6gLzKhYe6h3u80yAIhp%0D%0AQZpnJs1X0NHDF%2FkFvj%2B6mg%3D%3D&threeDSACSURL=https%3A%2F%2Fdropit.3dsecure.net%3A9443%2FPIT%2FACS&threeDSVETimestamp=2015-08-06+15%3A18%3A15&threeDSCheck=not+checked&vcsResponseCode=0&vcsResponseMessage=Success+-+no+velocity+check+rules+applied&currencyExponent=2&threeDSMD=UDNLRVk6eHJlZj0xNTA4MDYxNVJaMThSSjE1Uko2NFlWWg%3D%3D&timestamp=2015-08-06+15%3A18%3A17&threeDSResponseCode=65802&threeDSResponseMessage=3DS+AUTHENTICATION+REQUIRED&signature=8551e3f1c77b6cfa78e154d99ffb05fdeabbae48a7ce723a3464047731ad98a1c4bfe0b7dfdf46de7ff3dab66b3e2e365025fc9ff3a74d86ae4378c8cc985d88" + 'responseCode=65802&responseMessage=3DS+AUTHENTICATION+REQUIRED&responseStatus=2&merchantID=103191&threeDSEnabled=Y&threeDSCheckPref=not+known%2Cnot+checked%2Cauthenticated%2Cnot+authenticated%2Cattempted+authentication&avscv2CheckEnabled=N&cv2CheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&addressCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&postcodeCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&cardCVVMandatory=Y&customerID=1749&eReceiptsEnabled=N&eReceiptsStoreID=1&amount=1202&currencyCode=826&transactionUnique=42e13d06ce4d5f5e3eb4868d29baa8bb&orderRef=AM+test+purchase&threeDSRequired=Y&customerName=Longbob+Longsen&customerAddress=25+The+Larches&customerPostCode=LE10+2RT&action=SALE&type=1&countryCode=826&customerPostcode=LE10+2RT&customerReceiptsRequired=N&state=finished&remoteAddress=45.37.180.92&requestMerchantID=103191&processMerchantID=103191&xref=15080615RZ18RJ15RJ64YVZ&cardExpiryDate=1220&threeDSXID=MDAwMDAwMDAwMDAwMDg5NjY0OTc%3D&threeDSEnrolled=Y&transactionID=8966497&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A1112&cardType=Visa+Credit&cardTypeCode=VC&cardScheme=Visa+&cardSchemeCode=VC&cardIssuer=Unknown&cardIssuerCountry=Unknown&cardIssuerCountryCode=XXX&threeDSPaReq=eJxVUttuwjAM%2FZWKD2iaQrnJjVQGA7TBGFSTeMxSC8rohTRd2d8vKe0YD5F8jh37%0D%0A%2BCQQHiXidIeilMhghUXBD2jFkd%2FxPNHtCz747EaCdhhsgi1eGHyjLOIsZdR2bBdI%0D%0AC%2FVVKY48VQy4uEyWa%2BYN6LDbA9JASFAup2zk9Tx3pOkbhJQnyHa5FhGdf6wQC2UF%0D%0AQmRlqizdvc5CDeUPG7p9IC2AUp7ZUam8GBNSVZUtuIwKJZEntsgSAsQUALnr2pQm%0D%0AKnTDaxyx1TSoHs%2FBW5%2F2zlsofCCmAiKukLkO9Zyh07dob0yHYzoAUvPAE6OEzScb%0D%0Ai7q2o9U2DORmUHAD1DWZ%2FwxoqyWmot2nRYDXPEtRV%2BgLfzFEWAgWrCxlrMmbFbQG%0D%0AQwO57%2FS0MM4LpU1dxM%2FhrJx9zU8f6%2F3WuZxGL6%2Fvle%2Bbt6gLzKhYe6h3u80yAIhp%0D%0AQZpnJs1X0NHDF%2FkFvj%2B6mg%3D%3D&threeDSACSURL=https%3A%2F%2Fdropit.3dsecure.net%3A9443%2FPIT%2FACS&threeDSVETimestamp=2015-08-06+15%3A18%3A15&threeDSCheck=not+checked&vcsResponseCode=0&vcsResponseMessage=Success+-+no+velocity+check+rules+applied&currencyExponent=2&threeDSMD=UDNLRVk6eHJlZj0xNTA4MDYxNVJaMThSSjE1Uko2NFlWWg%3D%3D&timestamp=2015-08-06+15%3A18%3A17&threeDSResponseCode=65802&threeDSResponseMessage=3DS+AUTHENTICATION+REQUIRED&signature=8551e3f1c77b6cfa78e154d99ffb05fdeabbae48a7ce723a3464047731ad98a1c4bfe0b7dfdf46de7ff3dab66b3e2e365025fc9ff3a74d86ae4378c8cc985d88' end def successful_purchase_response_with_descriptors - "merchantID=103191&threeDSEnabled=Y&threeDSCheckPref=authenticated&avscv2CheckEnabled=N&cv2CheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&addressCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&postcodeCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&cardCVVMandatory=Y&customerReceiptsRequired=N&eReceiptsEnabled=N&eReceiptsStoreID=1&captureDelay=0&amount=284&currencyCode=826&statementNarrative1=merchant&statementNarrative2=product&type=1&threeDSRequired=N&customerName=Longbob+Longsen&cardExpiryMonth=12&cardExpiryYear=14&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostCode=NN17+8YG&countryCode=826&action=SALE&customerPostcode=NN17+8YG&requestID=586aae8406720&responseCode=0&responseMessage=AUTHCODE%3A684787&state=captured&requestMerchantID=103191&processMerchantID=103191&xref=17010219YV48VW21QH25TKS&paymentMethod=card&cardExpiryDate=1214&authorisationCode=684787&transactionID=13843073&responseStatus=0&timestamp=2017-01-02+19%3A48%3A21&amountReceived=284&avscv2ResponseCode=222100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&cv2Check=matched&addressCheck=matched&postcodeCheck=matched&cardNumberMask=492942%2A%2A%2A%2A%2A%2A0821&cardType=Visa+Credit&cardTypeCode=VC&cardScheme=Visa+&cardSchemeCode=VC&cardIssuer=BARCLAYS+BANK+PLC&cardIssuerCountry=United+Kingdom&cardIssuerCountryCode=GBR&vcsResponseCode=0&vcsResponseMessage=Success+-+no+velocity+check+rules+applied&currencyExponent=2&signature=d47c9253d2d9ff6e9464a782b798b3fa699f6ed085eb03d5f87c4cf1f0994efab0c3145236df2163ea2b48fc0232bed25626b7ac331f0c98473ef4b551099eef" + 'merchantID=103191&threeDSEnabled=Y&threeDSCheckPref=authenticated&avscv2CheckEnabled=N&cv2CheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&addressCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&postcodeCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&cardCVVMandatory=Y&customerReceiptsRequired=N&eReceiptsEnabled=N&eReceiptsStoreID=1&captureDelay=0&amount=284&currencyCode=826&statementNarrative1=merchant&statementNarrative2=product&type=1&threeDSRequired=N&customerName=Longbob+Longsen&cardExpiryMonth=12&cardExpiryYear=14&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostCode=NN17+8YG&countryCode=826&action=SALE&customerPostcode=NN17+8YG&requestID=586aae8406720&responseCode=0&responseMessage=AUTHCODE%3A684787&state=captured&requestMerchantID=103191&processMerchantID=103191&xref=17010219YV48VW21QH25TKS&paymentMethod=card&cardExpiryDate=1214&authorisationCode=684787&transactionID=13843073&responseStatus=0&timestamp=2017-01-02+19%3A48%3A21&amountReceived=284&avscv2ResponseCode=222100&avscv2ResponseMessage=ALL+MATCH&avscv2AuthEntity=merchant+host&cv2Check=matched&addressCheck=matched&postcodeCheck=matched&cardNumberMask=492942%2A%2A%2A%2A%2A%2A0821&cardType=Visa+Credit&cardTypeCode=VC&cardScheme=Visa+&cardSchemeCode=VC&cardIssuer=BARCLAYS+BANK+PLC&cardIssuerCountry=United+Kingdom&cardIssuerCountryCode=GBR&vcsResponseCode=0&vcsResponseMessage=Success+-+no+velocity+check+rules+applied&currencyExponent=2&signature=d47c9253d2d9ff6e9464a782b798b3fa699f6ed085eb03d5f87c4cf1f0994efab0c3145236df2163ea2b48fc0232bed25626b7ac331f0c98473ef4b551099eef' end def failed_purchase_card_declined_response - "merchantID=0000000&threeDSEnabled=Y&merchantDescription=General+test+account+with+AVS%2FCV2+checking&amount=10000&currencyCode=826&transactionUnique=7385df1d9c5484142bb6be1e932cd2df&orderRef=AM+test+purchase&customerName=Longbob+Longsen&customerAddress=25+The+Larches+&customerPostCode=LE10+2RT&action=SALE&type=1&countryCode=826&merchantAlias=0000992&remoteAddress=80.229.33.63&responseCode=5&responseMessage=CARD+DECLINED&xref=13021914RQ07HK55HG29KPH&threeDSEnrolled=U&threeDSXID=00000000000004717495&transactionID=4717495&transactionPreviousID=0&timestamp=2013-02-19+14%3A08%3A18&amountReceived=0&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A0191&cardTypeCode=MC&cardType=Mastercard&threeDSErrorCode=-1&threeDSErrorDescription=Error+while+attempting+to+send+the+request+to%3A+https%3A%2F%2F3dstest.universalpaymentgateway.com%3A4343%2FAPI%0A%0DPlease+make+sure+that+ActiveMerchant+server+is+running+and+the+URL+is+valid.+ERROR_INTERNET_CANNOT_CONNECT%3A+The+attempt+to+connect+to+the+server+failed.&threeDSMerchantPref=PROCEED&threeDSVETimestamp=2013-02-19+14%3A07%3A55&currencyExponent=2&responseStatus=1&merchantName=CARDSTREAM+TEST&merchantID2=100001" + 'merchantID=0000000&threeDSEnabled=Y&merchantDescription=General+test+account+with+AVS%2FCV2+checking&amount=10000&currencyCode=826&transactionUnique=7385df1d9c5484142bb6be1e932cd2df&orderRef=AM+test+purchase&customerName=Longbob+Longsen&customerAddress=25+The+Larches+&customerPostCode=LE10+2RT&action=SALE&type=1&countryCode=826&merchantAlias=0000992&remoteAddress=80.229.33.63&responseCode=5&responseMessage=CARD+DECLINED&xref=13021914RQ07HK55HG29KPH&threeDSEnrolled=U&threeDSXID=00000000000004717495&transactionID=4717495&transactionPreviousID=0&timestamp=2013-02-19+14%3A08%3A18&amountReceived=0&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A0191&cardTypeCode=MC&cardType=Mastercard&threeDSErrorCode=-1&threeDSErrorDescription=Error+while+attempting+to+send+the+request+to%3A+https%3A%2F%2F3dstest.universalpaymentgateway.com%3A4343%2FAPI%0A%0DPlease+make+sure+that+ActiveMerchant+server+is+running+and+the+URL+is+valid.+ERROR_INTERNET_CANNOT_CONNECT%3A+The+attempt+to+connect+to+the+server+failed.&threeDSMerchantPref=PROCEED&threeDSVETimestamp=2013-02-19+14%3A07%3A55&currencyExponent=2&responseStatus=1&merchantName=CARDSTREAM+TEST&merchantID2=100001' end def failed_authorization_response - "merchantID=0000000&threeDSEnabled=Y&merchantDescription=General+test+account+with+AVS%2FCV2+checking&amount=10000&currencyCode=826&transactionUnique=7385df1d9c5484142bb6be1e932cd2df&orderRef=AM+test+purchase&customerName=Longbob+Longsen&customerAddress=25+The+Larches+&customerPostCode=LE10+2RT&action=SALE&type=1&countryCode=826&merchantAlias=0000992&remoteAddress=80.229.33.63&responseCode=5&responseMessage=CARD+DECLINED&xref=13021914RQ07HK55HG29KPH&threeDSEnrolled=U&threeDSXID=00000000000004717495&transactionID=4717495&transactionPreviousID=0&timestamp=2013-02-19+14%3A08%3A18&amountReceived=0&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A0191&cardTypeCode=MC&cardType=Mastercard&threeDSErrorCode=-1&threeDSErrorDescription=Error+while+attempting+to+send+the+request+to%3A+https%3A%2F%2F3dstest.universalpaymentgateway.com%3A4343%2FAPI%0A%0DPlease+make+sure+that+ActiveMerchant+server+is+running+and+the+URL+is+valid.+ERROR_INTERNET_CANNOT_CONNECT%3A+The+attempt+to+connect+to+the+server+failed.&threeDSMerchantPref=PROCEED&threeDSVETimestamp=2013-02-19+14%3A07%3A55&currencyExponent=2&responseStatus=1&merchantName=CARDSTREAM+TEST&merchantID2=100001" + 'merchantID=0000000&threeDSEnabled=Y&merchantDescription=General+test+account+with+AVS%2FCV2+checking&amount=10000&currencyCode=826&transactionUnique=7385df1d9c5484142bb6be1e932cd2df&orderRef=AM+test+purchase&customerName=Longbob+Longsen&customerAddress=25+The+Larches+&customerPostCode=LE10+2RT&action=SALE&type=1&countryCode=826&merchantAlias=0000992&remoteAddress=80.229.33.63&responseCode=5&responseMessage=CARD+DECLINED&xref=13021914RQ07HK55HG29KPH&threeDSEnrolled=U&threeDSXID=00000000000004717495&transactionID=4717495&transactionPreviousID=0&timestamp=2013-02-19+14%3A08%3A18&amountReceived=0&cardNumberMask=%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A0191&cardTypeCode=MC&cardType=Mastercard&threeDSErrorCode=-1&threeDSErrorDescription=Error+while+attempting+to+send+the+request+to%3A+https%3A%2F%2F3dstest.universalpaymentgateway.com%3A4343%2FAPI%0A%0DPlease+make+sure+that+ActiveMerchant+server+is+running+and+the+URL+is+valid.+ERROR_INTERNET_CANNOT_CONNECT%3A+The+attempt+to+connect+to+the+server+failed.&threeDSMerchantPref=PROCEED&threeDSVETimestamp=2013-02-19+14%3A07%3A55&currencyExponent=2&responseStatus=1&merchantName=CARDSTREAM+TEST&merchantID2=100001' end def failed_void_response - "responseCode=65548&responseMessage=DB+ERROR&responseStatus=2&xref=16050317BX02HT10NH49ZRS&merchantID=103191&action=CANCEL&state=finished&remoteAddress=107.15.253.186&requestMerchantID=103191&processMerchantID=103191&timestamp=2016-05-03+17%3A02%3A10&signature=73d3ea59f106208fdf3b0fd1bc09a21c8bb66bbf481a7b6769959b1b3b2cbc18fbce434f2ea7f648a4dbdbf180003b0cc77036410be7f246e827ace0ed459d9b" + 'responseCode=65548&responseMessage=DB+ERROR&responseStatus=2&xref=16050317BX02HT10NH49ZRS&merchantID=103191&action=CANCEL&state=finished&remoteAddress=107.15.253.186&requestMerchantID=103191&processMerchantID=103191&timestamp=2016-05-03+17%3A02%3A10&signature=73d3ea59f106208fdf3b0fd1bc09a21c8bb66bbf481a7b6769959b1b3b2cbc18fbce434f2ea7f648a4dbdbf180003b0cc77036410be7f246e827ace0ed459d9b' end def successful_reference_purchase_response - "merchantID=103191&threeDSEnabled=Y&threeDSCheckPref=authenticated&avscv2CheckEnabled=N&addressCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&postcodeCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&customerReceiptsRequired=N&eReceiptsEnabled=N&eReceiptsStoreID=1&amount=142&currencyCode=826&transactionUnique=1f21b6d2fdf1f13378705707bc7e24bd&orderRef=AM+test+purchase&type=1&threeDSRequired=N&countryCode=826&action=SALE&responseCode=0&responseMessage=AUTHCODE%3A300382&state=captured&remoteAddress=107.15.253.186&requestMerchantID=103191&processMerchantID=103191&cardNumberMask=492942%2A%2A%2A%2A%2A%2A0821&cardExpiryMonth=12&cardExpiryYear=14&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostcode=NN17+8YG&previousID=10886746&cardCVVMandatory=N&xref=16040515PS17RG20GT73SBF&cardExpiryDate=1214&authorisationCode=300382&transactionID=10886747&responseStatus=0&timestamp=2016-04-05+15%3A17%3A20&amountReceived=142&avscv2ResponseCode=422100&avscv2ResponseMessage=ADDRESS+MATCH+ONLY&avscv2AuthEntity=merchant+host&cv2Check=not+matched&addressCheck=matched&postcodeCheck=matched&cardType=Visa+Credit&cardTypeCode=VC&cardScheme=Visa+&cardSchemeCode=VC&cardIssuer=BARCLAYS+BANK+PLC&cardIssuerCountry=United+Kingdom&cardIssuerCountryCode=GBR&vcsResponseCode=0&vcsResponseMessage=Success+-+no+velocity+check+rules+applied&currencyExponent=2&signature=9e13f5ffd9cf94215225ab60f80915879a242dcf8c30c7f39a0265acf0f3f7186cbea656d53fcce249e54f522050efd32e677726fc7d5aa1f7b6ee746e040956" + 'merchantID=103191&threeDSEnabled=Y&threeDSCheckPref=authenticated&avscv2CheckEnabled=N&addressCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&postcodeCheckPref=not+known%2Cnot+checked%2Cmatched%2Cnot+matched%2Cpartially+matched&customerReceiptsRequired=N&eReceiptsEnabled=N&eReceiptsStoreID=1&amount=142&currencyCode=826&transactionUnique=1f21b6d2fdf1f13378705707bc7e24bd&orderRef=AM+test+purchase&type=1&threeDSRequired=N&countryCode=826&action=SALE&responseCode=0&responseMessage=AUTHCODE%3A300382&state=captured&remoteAddress=107.15.253.186&requestMerchantID=103191&processMerchantID=103191&cardNumberMask=492942%2A%2A%2A%2A%2A%2A0821&cardExpiryMonth=12&cardExpiryYear=14&customerName=Longbob+Longsen&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostcode=NN17+8YG&previousID=10886746&cardCVVMandatory=N&xref=16040515PS17RG20GT73SBF&cardExpiryDate=1214&authorisationCode=300382&transactionID=10886747&responseStatus=0&timestamp=2016-04-05+15%3A17%3A20&amountReceived=142&avscv2ResponseCode=422100&avscv2ResponseMessage=ADDRESS+MATCH+ONLY&avscv2AuthEntity=merchant+host&cv2Check=not+matched&addressCheck=matched&postcodeCheck=matched&cardType=Visa+Credit&cardTypeCode=VC&cardScheme=Visa+&cardSchemeCode=VC&cardIssuer=BARCLAYS+BANK+PLC&cardIssuerCountry=United+Kingdom&cardIssuerCountryCode=GBR&vcsResponseCode=0&vcsResponseMessage=Success+-+no+velocity+check+rules+applied&currencyExponent=2&signature=9e13f5ffd9cf94215225ab60f80915879a242dcf8c30c7f39a0265acf0f3f7186cbea656d53fcce249e54f522050efd32e677726fc7d5aa1f7b6ee746e040956' end def failed_reference_purchase_response - "responseCode=65548&responseMessage=DB+ERROR&responseStatus=2&amount=142&currencyCode=826&transactionUnique=740290de68c10d18acabe9fb0a52bd92&orderRef=AM+test+purchase&type=1&threeDSRequired=N&xref=16040515NM21GM43SF71MMR&countryCode=GB&merchantID=103191&action=SALE&state=finished&remoteAddress=107.15.253.186&requestMerchantID=103191&processMerchantID=103191&transactionID=10886787&timestamp=2016-04-05+15%3A21%3A43&vcsResponseCode=0&vcsResponseMessage=Success+-+no+velocity+check+rules+applied&signature=311f2bfd94c3807fae4fbeff13801c37d81c3e1082c5d3c5893281f18d7152b96420fa7b45285eb692b09b576b3b85d894ee35ff9e31cd06ace54019b806550f" + 'responseCode=65548&responseMessage=DB+ERROR&responseStatus=2&amount=142&currencyCode=826&transactionUnique=740290de68c10d18acabe9fb0a52bd92&orderRef=AM+test+purchase&type=1&threeDSRequired=N&xref=16040515NM21GM43SF71MMR&countryCode=GB&merchantID=103191&action=SALE&state=finished&remoteAddress=107.15.253.186&requestMerchantID=103191&processMerchantID=103191&transactionID=10886787&timestamp=2016-04-05+15%3A21%3A43&vcsResponseCode=0&vcsResponseMessage=Success+-+no+velocity+check+rules+applied&signature=311f2bfd94c3807fae4fbeff13801c37d81c3e1082c5d3c5893281f18d7152b96420fa7b45285eb692b09b576b3b85d894ee35ff9e31cd06ace54019b806550f' end def transcript diff --git a/test/unit/gateways/cardknox_test.rb b/test/unit/gateways/cardknox_test.rb index fef7402a53a..e4270ba97b2 100644 --- a/test/unit/gateways/cardknox_test.rb +++ b/test/unit/gateways/cardknox_test.rb @@ -15,7 +15,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")) + @gateway.purchase(@amount, @credit_card, @options.merge(order_id: '1337', description: 'socool')) end.check_request do |endpoint, data, headers| assert_match(/xOrderID=1337/, data) assert_match(/xDescription=socool/, data) @@ -38,10 +38,10 @@ def test_cvv_result end def test_add_track_data_with_creditcard - @credit_card.track_data = "data" + @credit_card.track_data = 'data' @gateway.expects(:ssl_post).with do |_, body| - body.include?("xMagstripe=data") + body.include?('xMagstripe=data') end.returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) @@ -49,11 +49,11 @@ def test_add_track_data_with_creditcard end def test_add_track_data_with_empty_data - ["", nil].each do |data| + ['', nil].each do |data| @credit_card.track_data = data @gateway.expects(:ssl_post).with do |_, body| - refute body.include? "xMagstripe=" + refute body.include? 'xMagstripe=' body end.returns(successful_purchase_response) @@ -81,7 +81,7 @@ def test_ip_is_being_sent # failed data =~ /xIP=123.123.123.123/ end.returns(successful_purchase_response) - @options[:ip] = "123.123.123.123" + @options[:ip] = '123.123.123.123' @gateway.purchase(@amount, @credit_card, @options) end @@ -203,54 +203,54 @@ def test_scrub private def purchase_request - "xKey=api_key&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=4242424242424242&xCVV=123&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6" + 'xKey=api_key&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=4242424242424242&xCVV=123&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6' end def successful_purchase_response # passed avs and cvv - "xResult=A&xStatus=Approved&xError=&xRefNum=16268727&xAuthCode=230809&xBatch=347&xAvsResultCode=YYY&xAvsResult=Address%3a+Match+%26+5+Digit+Zip%3a+Match&xCvvResultCode=M&xCvvResult=Match&xAuthAmount=4.38&xToken=f0b84a5b181749b4b0d77f6291a753ab&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen" + 'xResult=A&xStatus=Approved&xError=&xRefNum=16268727&xAuthCode=230809&xBatch=347&xAvsResultCode=YYY&xAvsResult=Address%3a+Match+%26+5+Digit+Zip%3a+Match&xCvvResultCode=M&xCvvResult=Match&xAuthAmount=4.38&xToken=f0b84a5b181749b4b0d77f6291a753ab&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen' end def failed_purchase_response - "xResult=D&xStatus=Declined&xError=Invalid+CVV&xRefNum=15307128&xAuthCode=&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xToken=8138747e41894071a353318541d2ee8c" + 'xResult=D&xStatus=Declined&xError=Invalid+CVV&xRefNum=15307128&xAuthCode=&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xToken=8138747e41894071a353318541d2ee8c' end def successful_authorize_response - "xResult=A&xStatus=Approved&xError=&xRefNum=15312316&xAuthCode=630421&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xAuthAmount=2.06&xToken=62d4fd9aebd240659d68ffaa156d1788&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen" + 'xResult=A&xStatus=Approved&xError=&xRefNum=15312316&xAuthCode=630421&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xAuthAmount=2.06&xToken=62d4fd9aebd240659d68ffaa156d1788&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen' end def failed_authorize_response - "xResult=D&xStatus=Declined&xError=Invalid+CVV&xRefNum=15307290&xAuthCode=&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xToken=065751a8a28e468a8d79cb98c04cf350" + 'xResult=D&xStatus=Declined&xError=Invalid+CVV&xRefNum=15307290&xAuthCode=&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xToken=065751a8a28e468a8d79cb98c04cf350' end def successful_capture_response - "xResult=A&xStatus=Approved&xError=&xRefNum=15312316&xRefNumCurrent=15312319&xAuthCode=&xBatch=321&xAvsResultCode=&xAvsResult=Unmapped+AVS+response&xCvvResultCode=&xCvvResult=No+CVV+data+available&xAuthAmount=2.06&xToken=f9097326fb1c4976a6da75ccb872f28a&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen" + 'xResult=A&xStatus=Approved&xError=&xRefNum=15312316&xRefNumCurrent=15312319&xAuthCode=&xBatch=321&xAvsResultCode=&xAvsResult=Unmapped+AVS+response&xCvvResultCode=&xCvvResult=No+CVV+data+available&xAuthAmount=2.06&xToken=f9097326fb1c4976a6da75ccb872f28a&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen' end def failed_capture_response - "xResult=E&xStatus=Error&xAuthCode=000000&xError=Original+transaction+not+specified&xRefNum=15307619&xErrorCode=00000" + 'xResult=E&xStatus=Error&xAuthCode=000000&xError=Original+transaction+not+specified&xRefNum=15307619&xErrorCode=00000' end def successful_credit_card_refund_response end def failed_credit_card_refund_response - "xResult=D&xStatus=Declined&xError=UNSUPPORTED+CARD+TYPE&xRefNum=15308026&xAuthCode=&xBatch=&xAvsResultCode=&xAvsResult=Unmapped+AVS+response&xCvvResultCode=&xCvvResult=No+CVV+data+available" + 'xResult=D&xStatus=Declined&xError=UNSUPPORTED+CARD+TYPE&xRefNum=15308026&xAuthCode=&xBatch=&xAvsResultCode=&xAvsResult=Unmapped+AVS+response&xCvvResultCode=&xCvvResult=No+CVV+data+available' end def successful_check_refund_response - "xResult=A&xStatus=Approved&xError=&xRefNum=16274604" + 'xResult=A&xStatus=Approved&xError=&xRefNum=16274604' end def failed_check_refund_response - "xResult=D&xStatus=Declined&xError=&xRefNum=16274604" + 'xResult=D&xStatus=Declined&xError=&xRefNum=16274604' end def successful_void_response - "xResult=A&xStatus=Approved&xError=&xRefNum=15308171&xRefNumCurrent=15308172&xAuthCode=912013&xBatch=&xAvsResultCode=&xAvsResult=Unmapped+AVS+response&xCvvResultCode=&xCvvResult=No+CVV+data+available&xAuthAmount=2.33&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen" + 'xResult=A&xStatus=Approved&xError=&xRefNum=15308171&xRefNumCurrent=15308172&xAuthCode=912013&xBatch=&xAvsResultCode=&xAvsResult=Unmapped+AVS+response&xCvvResultCode=&xCvvResult=No+CVV+data+available&xAuthAmount=2.33&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen' end def failed_void_response - "xResult=E&xStatus=Error&xAuthCode=000000&xError=Original+transaction+not+specified&xRefNum=15308297&xErrorCode=00000" + 'xResult=E&xStatus=Error&xAuthCode=000000&xError=Original+transaction+not+specified&xRefNum=15308297&xErrorCode=00000' end def successful_check_refund_void @@ -258,18 +258,18 @@ def successful_check_refund_void end def successful_verify_response - "xResult=A&xStatus=Approved&xError=&xRefNum=15314566&xAuthCode=608755&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xAuthAmount=1.00&xToken=09dc51aceb98440fbf0847cad2941d45&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen" + 'xResult=A&xStatus=Approved&xError=&xRefNum=15314566&xAuthCode=608755&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xAuthAmount=1.00&xToken=09dc51aceb98440fbf0847cad2941d45&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen' end def failed_verify_response - "xResult=D&xStatus=Declined&xError=Invalid+CVV&xRefNum=15310681&xAuthCode=&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xToken=748df69e22f142d4aab296328d4f2653" + 'xResult=D&xStatus=Declined&xError=Invalid+CVV&xRefNum=15310681&xAuthCode=&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xToken=748df69e22f142d4aab296328d4f2653' end def pre_scrubbed - "xKey=api_key&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=4242424242424242&xCVV=123&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6" + 'xKey=api_key&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=4242424242424242&xCVV=123&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6' end def post_scrubbed - "xKey=[FILTERED]&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=[FILTERED]&xCVV=[FILTERED]&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6" + 'xKey=[FILTERED]&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=[FILTERED]&xCVV=[FILTERED]&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6' end end diff --git a/test/unit/gateways/cardprocess_test.rb b/test/unit/gateways/cardprocess_test.rb index 29abcdef429..5377cd16c73 100644 --- a/test/unit/gateways/cardprocess_test.rb +++ b/test/unit/gateways/cardprocess_test.rb @@ -239,7 +239,7 @@ def successful_purchase_response end def failed_purchase_response - "{\"id\":\"8a82944a5fe827040160030a3308412d\",\"paymentType\":\"DB\",\"paymentBrand\":\"VISA\",\"result\":{\"code\":\"100.100.101\",\"description\":\"invalid creditcard, bank account number or bank name\"},\"card\":{\"bin\":\"420000\",\"last4Digits\":\"0001\",\"holder\":\"Longbob Longsen\",\"expiryMonth\":\"09\",\"expiryYear\":\"2018\"},\"billing\":{\"street1\":\"456 My Street\",\"street2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"postcode\":\"K1C2N6\",\"country\":\"CA\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 14:31:28+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_43d463600f8d429ea6ac09cf25fd9f24\"}" + '{"id":"8a82944a5fe827040160030a3308412d","paymentType":"DB","paymentBrand":"VISA","result":{"code":"100.100.101","description":"invalid creditcard, bank account number or bank name"},"card":{"bin":"420000","last4Digits":"0001","holder":"Longbob Longsen","expiryMonth":"09","expiryYear":"2018"},"billing":{"street1":"456 My Street","street2":"Apt 1","city":"Ottawa","state":"ON","postcode":"K1C2N6","country":"CA"},"buildNumber":"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000","timestamp":"2017-11-28 14:31:28+0000","ndc":"8a8294174e735d0c014e78beb6b9154b_43d463600f8d429ea6ac09cf25fd9f24"}' end def successful_authorize_response @@ -247,7 +247,7 @@ def successful_authorize_response end def failed_authorize_response - "{\"paymentType\":\"PA\",\"paymentBrand\":\"VISA\",\"result\":{\"code\":\"800.100.151\",\"description\":\"transaction declined (invalid card)\"},\"card\":{\"bin\":\"420000\",\"last4Digits\":\"0000\",\"holder\":\"Longbob Longsen\",\"expiryMonth\":\"09\",\"expiryYear\":\"2018\"},\"billing\":{\"street1\":\"456 My Street\",\"street2\":\"Apt 1\",\"city\":\"Ottawa\",\"state\":\"ON\",\"postcode\":\"K1C2N6\",\"country\":\"CA\"},\"customParameters\":{\"forceResultCode\":\"800.100.151\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 13:50:31+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_1077c67bc41048ff887da9ab9ee8b89d\"}" + '{"paymentType":"PA","paymentBrand":"VISA","result":{"code":"800.100.151","description":"transaction declined (invalid card)"},"card":{"bin":"420000","last4Digits":"0000","holder":"Longbob Longsen","expiryMonth":"09","expiryYear":"2018"},"billing":{"street1":"456 My Street","street2":"Apt 1","city":"Ottawa","state":"ON","postcode":"K1C2N6","country":"CA"},"customParameters":{"forceResultCode":"800.100.151"},"buildNumber":"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000","timestamp":"2017-11-28 13:50:31+0000","ndc":"8a8294174e735d0c014e78beb6b9154b_1077c67bc41048ff887da9ab9ee8b89d"}' end def successful_capture_response @@ -255,7 +255,7 @@ def successful_capture_response end def failed_capture_response - "{\"id\":\"8a82944a5fe8270401600313d3965bca\",\"paymentType\":\"CP\",\"result\":{\"code\":\"700.400.510\",\"description\":\"capture needs at least one successful transaction of type (PA)\"},\"risk\":{\"score\":\"0\"},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 14:41:59+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_8abfd898a6cd406f94181d9096607aea\"}" + '{"id":"8a82944a5fe8270401600313d3965bca","paymentType":"CP","result":{"code":"700.400.510","description":"capture needs at least one successful transaction of type (PA)"},"risk":{"score":"0"},"buildNumber":"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000","timestamp":"2017-11-28 14:41:59+0000","ndc":"8a8294174e735d0c014e78beb6b9154b_8abfd898a6cd406f94181d9096607aea"}' end def successful_refund_response @@ -263,7 +263,7 @@ def successful_refund_response end def failed_refund_response - "{\"result\":{\"code\":\"200.300.404\",\"description\":\"invalid or missing parameter\",\"parameterErrors\":[{\"name\":\"paymentType\",\"value\":\"RF\",\"message\":\"must be one of [PA, DB, CD, PA.CP]\"},{\"name\":\"paymentBrand\",\"value\":null,\"message\":\"card properties must be set\"}]},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 14:33:31+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_febee8f6863b4392b064b23602f3f382\"}" + '{"result":{"code":"200.300.404","description":"invalid or missing parameter","parameterErrors":[{"name":"paymentType","value":"RF","message":"must be one of [PA, DB, CD, PA.CP]"},{"name":"paymentBrand","value":null,"message":"card properties must be set"}]},"buildNumber":"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000","timestamp":"2017-11-28 14:33:31+0000","ndc":"8a8294174e735d0c014e78beb6b9154b_febee8f6863b4392b064b23602f3f382"}' end def successful_void_response @@ -271,7 +271,7 @@ def successful_void_response end def failed_void_response - "{\"result\":{\"code\":\"200.300.404\",\"description\":\"invalid or missing parameter\",\"parameterErrors\":[{\"name\":\"paymentBrand\",\"value\":null,\"message\":\"card properties must be set\"},{\"name\":\"paymentType\",\"value\":\"RV\",\"message\":\"must be one of [PA, DB, CD, PA.CP]\"},{\"name\":\"amount\",\"value\":null,\"message\":\"may not be empty\"},{\"name\":\"currency\",\"value\":null,\"message\":\"may not be empty\"}]},\"buildNumber\":\"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000\",\"timestamp\":\"2017-11-28 14:34:50+0000\",\"ndc\":\"8a8294174e735d0c014e78beb6b9154b_4a909e0b99214eb9b155b46a2c67df30\"}" + '{"result":{"code":"200.300.404","description":"invalid or missing parameter","parameterErrors":[{"name":"paymentBrand","value":null,"message":"card properties must be set"},{"name":"paymentType","value":"RV","message":"must be one of [PA, DB, CD, PA.CP]"},{"name":"amount","value":null,"message":"may not be empty"},{"name":"currency","value":null,"message":"may not be empty"}]},"buildNumber":"a89317e58e01406de09ff75de6c962f2365f66e9@2017-11-27 15:38:09 +0000","timestamp":"2017-11-28 14:34:50+0000","ndc":"8a8294174e735d0c014e78beb6b9154b_4a909e0b99214eb9b155b46a2c67df30"}' end def successful_credit_response diff --git a/test/unit/gateways/cashnet_test.rb b/test/unit/gateways/cashnet_test.rb index a5f1cbc7efb..a3e00477a0e 100644 --- a/test/unit/gateways/cashnet_test.rb +++ b/test/unit/gateways/cashnet_test.rb @@ -78,7 +78,7 @@ def test_add_address @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 ['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) @@ -124,7 +124,7 @@ def test_invalid_response end def test_passes_custcode_from_credentials - gateway = CashnetGateway.new(merchant: 'X', operator: 'X', password: 'test123', merchant_gateway_name: 'X', custcode: "TheCustCode") + 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| @@ -133,9 +133,9 @@ def test_passes_custcode_from_credentials end def test_allows_custcode_override - gateway = CashnetGateway.new(merchant: 'X', operator: 'X', password: 'test123', merchant_gateway_name: 'X', custcode: "TheCustCode") + 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") + gateway.purchase(@amount, @credit_card, custcode: 'OveriddenCustCode') end.check_request do |method, endpoint, data, headers| assert_match(/custcode=OveriddenCustCode/, data) end.respond_with(successful_purchase_response) @@ -156,23 +156,23 @@ def minimum_requirements end def successful_refund_response - "<cngateway>result=0&respmessage=Success&tx=1234</cngateway>" + '<cngateway>result=0&respmessage=Success&tx=1234</cngateway>' end def failed_refund_response - "<cngateway>result=305&respmessage=Failed</cngateway>" + '<cngateway>result=305&respmessage=Failed</cngateway>' end def successful_purchase_response - "<cngateway>result=0&respmessage=Success&tx=1234</cngateway>" + '<cngateway>result=0&respmessage=Success&tx=1234</cngateway>' end def failed_purchase_response - "<cngateway>result=7&respmessage=Failed</cngateway>" + '<cngateway>result=7&respmessage=Failed</cngateway>' end def invalid_response - "A String without a cngateway tag" + 'A String without a cngateway tag' end def pre_scrubbed diff --git a/test/unit/gateways/cecabank_test.rb b/test/unit/gateways/cecabank_test.rb index 3a762329b8d..e21446ea95e 100644 --- a/test/unit/gateways/cecabank_test.rb +++ b/test/unit/gateways/cecabank_test.rb @@ -42,9 +42,9 @@ 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) + @gateway.purchase(@amount, credit_card('4242424242424242', month: 1, year: 2014), @options) end.check_request do |endpoint, data, headers| - assert_match(/Caducidad=201401&/, data, "Expected expiration date format is yyyymm") + assert_match(/Caducidad=201401&/, data, 'Expected expiration date format is yyyymm') end.respond_with(successful_purchase_response) end @@ -59,7 +59,7 @@ def test_unsuccessful_request def test_successful_refund_request @gateway.expects(:ssl_post).returns(successful_refund_response) - assert response = @gateway.refund(@amount, "reference", @options) + assert response = @gateway.refund(@amount, 'reference', @options) assert_instance_of Response, response assert_success response assert response.test? @@ -68,7 +68,7 @@ def test_successful_refund_request def test_unsuccessful_refund_request @gateway.expects(:ssl_post).returns(failed_refund_response) - assert response = @gateway.refund(@amount, "reference", @options) + assert response = @gateway.refund(@amount, 'reference', @options) assert_failure response assert response.test? end diff --git a/test/unit/gateways/cenpos_test.rb b/test/unit/gateways/cenpos_test.rb index 0c9f93643c1..e43caa1a1a4 100644 --- a/test/unit/gateways/cenpos_test.rb +++ b/test/unit/gateways/cenpos_test.rb @@ -1,13 +1,13 @@ -require "test_helper" +require 'test_helper' class CenposTest < Test::Unit::TestCase include CommStub 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 @@ -21,7 +21,7 @@ def test_successful_purchase assert_success response - assert_equal "1609995363|4242|1.00", response.authorization + assert_equal '1609995363|4242|1.00', response.authorization assert response.test? end @@ -31,7 +31,7 @@ def test_successful_purchase_cvv_result end.respond_with(successful_purchase_response) cvv_result = response.cvv_result - assert_equal "M", cvv_result["code"] + assert_equal 'M', cvv_result['code'] end def test_successful_purchase_avs_result @@ -40,7 +40,7 @@ def test_successful_purchase_avs_result end.respond_with(successful_purchase_response) avs_result = response.avs_result - assert_equal "D", avs_result["code"] + assert_equal 'D', avs_result['code'] end def test_failed_purchase @@ -49,7 +49,7 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "Decline transaction", response.message + assert_equal 'Decline transaction', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code assert response.test? end @@ -60,7 +60,7 @@ def test_missing_cvv_result end.respond_with(failed_purchase_response) cvv_result = response.cvv_result - assert_equal nil, cvv_result["code"] + assert_equal nil, cvv_result['code'] end def test_failed_purchase_avs_result @@ -69,7 +69,7 @@ def test_failed_purchase_avs_result end.respond_with(failed_purchase_response) avs_result = response.avs_result - assert_equal nil, avs_result["code"] + assert_equal nil, avs_result['code'] end def test_unmatched_cvv_result @@ -78,7 +78,7 @@ def test_unmatched_cvv_result end.respond_with(cvv_no_match_response) cvv_result = response.cvv_result - assert_equal "N", cvv_result["code"] + assert_equal 'N', cvv_result['code'] end def test_avs_result_unmatched_zip @@ -86,7 +86,7 @@ def test_avs_result_unmatched_zip @gateway.purchase(@amount, @credit_card) end.respond_with(avs_zip_no_match_response) - assert_equal "B", response.avs_result["code"] + assert_equal 'B', response.avs_result['code'] end def test_avs_result_unmatched_address @@ -94,7 +94,7 @@ def test_avs_result_unmatched_address @gateway.purchase(@amount, @credit_card) end.respond_with(avs_billing_no_match_response) - assert_equal "P", response.avs_result["code"] + assert_equal 'P', response.avs_result['code'] end def test_avs_result_unmatched_address_and_zip @@ -102,7 +102,7 @@ def test_avs_result_unmatched_address_and_zip @gateway.purchase(@amount, @credit_card) end.respond_with(avs_billing_and_zip_no_match_response) - assert_equal "C", response.avs_result["code"] + assert_equal 'C', response.avs_result['code'] end def test_successful_authorize_and_capture @@ -111,7 +111,7 @@ def test_successful_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "1760035844|4242|1.00", response.authorization + assert_equal '1760035844|4242|1.00', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -128,14 +128,14 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Decline transaction", response.message + assert_equal 'Decline transaction', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code assert response.test? end def test_failed_capture response = stub_comms do - @gateway.capture(100, "") + @gateway.capture(100, '') end.respond_with(failed_capture_response) assert_failure response @@ -147,7 +147,7 @@ def test_successful_void end.respond_with(successful_authorize_response) assert_success response - assert_equal "1760035844|4242|1.00", response.authorization + assert_equal '1760035844|4242|1.00', response.authorization void = stub_comms do @gateway.void(response.authorization) @@ -160,7 +160,7 @@ def test_successful_void def test_failed_void response = stub_comms do - @gateway.void("1758584451|4242|1.00") + @gateway.void('1758584451|4242|1.00') end.check_request do |endpoint, data, headers| assert_match(/1758584451/, data) end.respond_with(failed_void_response) @@ -174,7 +174,7 @@ def test_successful_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "1609995363|4242|1.00", response.authorization + assert_equal '1609995363|4242|1.00', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -187,7 +187,7 @@ def test_successful_refund def test_failed_refund response = stub_comms do - @gateway.refund(nil, "") + @gateway.refund(nil, '') end.respond_with(failed_refund_response) assert_failure response @@ -200,7 +200,7 @@ def test_successful_credit assert_success response - assert_equal "1609996211|4242|1.00", response.authorization + assert_equal '1609996211|4242|1.00', response.authorization assert response.test? end @@ -210,7 +210,7 @@ def test_failed_credit end.respond_with(failed_credit_response) assert_failure response - assert_equal "Invalid card number", response.message + assert_equal 'Invalid card number', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code assert response.test? end @@ -220,7 +220,7 @@ def test_successful_verify @gateway.verify(@credit_card) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_verify @@ -228,7 +228,7 @@ def test_failed_verify @gateway.verify(@credit_card) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "Decline transaction", response.message + assert_equal 'Decline transaction', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code end @@ -238,7 +238,7 @@ def test_empty_response_fails end.respond_with(empty_purchase_response) assert_failure response - assert_equal "Unable to read error message", response.message + assert_equal 'Unable to read error message', response.message end def test_transcript_scrubbing diff --git a/test/unit/gateways/checkout_test.rb b/test/unit/gateways/checkout_test.rb index ca39016cd0f..bc12cd16476 100644 --- a/test/unit/gateways/checkout_test.rb +++ b/test/unit/gateways/checkout_test.rb @@ -57,7 +57,7 @@ def test_unsuccessful_capture assert response = @gateway.capture(100, '||||' , @options) assert_failure response - assert_equal 'EGP00173', response.params["error_code_tag"] + assert_equal 'EGP00173', response.params['error_code_tag'] assert response.test? end @@ -73,7 +73,7 @@ def test_unsuccessful_purchase def test_passes_correct_currency stub_comms do @gateway.purchase(100, credit_card, @options.merge( - currency: "EUR" + currency: 'EUR' )) end.check_request do |endpoint, data, headers| assert_match(/<bill_currencycode>EUR<\/bill_currencycode>/, data) @@ -83,8 +83,8 @@ def test_passes_correct_currency def test_passes_descriptors stub_comms do @gateway.purchase(100, credit_card, @options.merge( - descriptor_name: "ZahName", - descriptor_city: "Oakland" + descriptor_name: 'ZahName', + descriptor_city: 'Oakland' )) end.check_request do |endpoint, data, headers| assert_match(/<descriptor_name>ZahName<\/descriptor_name>/, data) @@ -137,7 +137,7 @@ def test_successful_verify @gateway.verify(credit_card, @options) end.respond_with(successful_authorize_response, successful_void_response) assert_success response - assert_equal "33024417", response.params['tranid'] + assert_equal '33024417', response.params['tranid'] end def test_successful_verify_with_failed_void @@ -145,7 +145,7 @@ def test_successful_verify_with_failed_void @gateway.verify(credit_card, @options) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Successful", response.message + assert_equal 'Successful', response.message end def test_unsuccessful_verify @@ -153,7 +153,7 @@ def test_unsuccessful_verify @gateway.verify(credit_card, @options) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "Not Successful", response.message + assert_equal 'Not Successful', response.message end private diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb index 8505d2936ea..d6189454c5f 100644 --- a/test/unit/gateways/checkout_v2_test.rb +++ b/test/unit/gateways/checkout_v2_test.rb @@ -27,10 +27,10 @@ def test_successful_purchase_includes_avs_result @gateway.purchase(@amount, @credit_card) end.respond_with(successful_purchase_response) - assert_equal 'S', response.avs_result["code"] - assert_equal 'U.S.-issuing bank does not support AVS.', response.avs_result["message"] - assert_equal 'X', response.avs_result["postal_match"] - assert_equal 'X', response.avs_result["street_match"] + assert_equal 'S', response.avs_result['code'] + assert_equal 'U.S.-issuing bank does not support AVS.', response.avs_result['message'] + assert_equal 'X', response.avs_result['postal_match'] + assert_equal 'X', response.avs_result['street_match'] end def test_successful_purchase_includes_cvv_result @@ -38,7 +38,7 @@ def test_successful_purchase_includes_cvv_result @gateway.purchase(@amount, @credit_card) end.respond_with(successful_purchase_response) - assert_equal 'Y', response.cvv_result["code"] + assert_equal 'Y', response.cvv_result['code'] end def test_successful_authorize_includes_avs_result @@ -46,10 +46,10 @@ def test_successful_authorize_includes_avs_result @gateway.authorize(@amount, @credit_card) end.respond_with(successful_authorize_response) - assert_equal 'S', response.avs_result["code"] - assert_equal 'U.S.-issuing bank does not support AVS.', response.avs_result["message"] - assert_equal 'X', response.avs_result["postal_match"] - assert_equal 'X', response.avs_result["street_match"] + assert_equal 'S', response.avs_result['code'] + assert_equal 'U.S.-issuing bank does not support AVS.', response.avs_result['message'] + assert_equal 'X', response.avs_result['postal_match'] + assert_equal 'X', response.avs_result['street_match'] end def test_successful_authorize_includes_cvv_result @@ -57,12 +57,12 @@ def test_successful_authorize_includes_cvv_result @gateway.authorize(@amount, @credit_card) end.respond_with(successful_authorize_response) - assert_equal 'Y', response.cvv_result["code"] + assert_equal 'Y', response.cvv_result['code'] end def test_purchase_with_additional_fields response = stub_comms do - @gateway.purchase(@amount, @credit_card, {descriptor_city: "london", descriptor_name: "sherlock"}) + @gateway.purchase(@amount, @credit_card, {descriptor_city: 'london', descriptor_name: 'sherlock'}) end.check_request do |endpoint, data, headers| assert_match(/"descriptor\":{\"name\":\"sherlock\",\"city\":\"london\"}/, data) end.respond_with(successful_purchase_response) @@ -84,7 +84,7 @@ def test_successful_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "charge_test_AF1A29AD350Q748C7EA8", response.authorization + assert_equal 'charge_test_AF1A29AD350Q748C7EA8', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -98,7 +98,7 @@ def test_successful_authorize_and_capture_with_additional_options options = { card_on_file: true, transaction_indicator: 2, - previous_charge_id: "charge_123" + previous_charge_id: 'charge_123' } @gateway.authorize(@amount, @credit_card, options) end.check_request do |endpoint, data, headers| @@ -108,7 +108,7 @@ def test_successful_authorize_and_capture_with_additional_options end.respond_with(successful_authorize_response) assert_success response - assert_equal "charge_test_AF1A29AD350Q748C7EA8", response.authorization + assert_equal 'charge_test_AF1A29AD350Q748C7EA8', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -123,13 +123,13 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Invalid Card Number", response.message + assert_equal 'Invalid Card Number', response.message assert response.test? end def test_failed_capture response = stub_comms do - @gateway.capture(100, "") + @gateway.capture(100, '') end.respond_with(failed_capture_response) assert_failure response @@ -141,7 +141,7 @@ def test_successful_void end.respond_with(successful_authorize_response) assert_success response - assert_equal "charge_test_AF1A29AD350Q748C7EA8", response.authorization + assert_equal 'charge_test_AF1A29AD350Q748C7EA8', response.authorization void = stub_comms do @gateway.void(response.authorization) @@ -152,7 +152,7 @@ def test_successful_void def test_failed_void response = stub_comms do - @gateway.void("5d53a33d960c46d00f5dc061947d998c") + @gateway.void('5d53a33d960c46d00f5dc061947d998c') end.respond_with(failed_void_response) assert_failure response @@ -164,7 +164,7 @@ def test_successful_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "charge_test_941CA9CE174U76BD29C8", response.authorization + assert_equal 'charge_test_941CA9CE174U76BD29C8', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -175,7 +175,7 @@ def test_successful_refund def test_failed_refund response = stub_comms do - @gateway.refund(nil, "") + @gateway.refund(nil, '') end.respond_with(failed_refund_response) assert_failure response @@ -186,7 +186,7 @@ def test_successful_verify @gateway.verify(@credit_card) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_verify @@ -194,7 +194,7 @@ def test_failed_verify @gateway.verify(@credit_card) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "Invalid Card Number", response.message + assert_equal 'Invalid Card Number', response.message end def test_transcript_scrubbing diff --git a/test/unit/gateways/citrus_pay_test.rb b/test/unit/gateways/citrus_pay_test.rb index 97b2ba02a55..40b126e3782 100644 --- a/test/unit/gateways/citrus_pay_test.rb +++ b/test/unit/gateways/citrus_pay_test.rb @@ -91,7 +91,7 @@ def test_void def test_passing_alpha3_country_code stub_comms(@gateway, :ssl_request) do - @gateway.authorize(@amount, @credit_card, :billing_address => {country: "US"}) + @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) @@ -99,7 +99,7 @@ def test_passing_alpha3_country_code def test_non_existent_country stub_comms(@gateway, :ssl_request) do - @gateway.authorize(@amount, @credit_card, :billing_address => {country: "Blah"}) + @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) @@ -138,7 +138,7 @@ def test_successful_verify @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, successful_void_response) assert_success response - assert_equal "91debbeb-d88f-42e9-a6ce-9b62c99d656b", response.params['order']['id'] + assert_equal '91debbeb-d88f-42e9-a6ce-9b62c99d656b', response.params['order']['id'] end def test_successful_verify_with_failed_void @@ -146,7 +146,7 @@ def test_successful_verify_with_failed_void @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_unsuccessful_verify @@ -154,7 +154,7 @@ def test_unsuccessful_verify @gateway.verify(@credit_card, @options) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "FAILURE - DECLINED", response.message + assert_equal 'FAILURE - DECLINED', response.message end def test_north_america_region_url diff --git a/test/unit/gateways/clearhaus_test.rb b/test/unit/gateways/clearhaus_test.rb index 68741fb1bdf..a30a5b3894c 100644 --- a/test/unit/gateways/clearhaus_test.rb +++ b/test/unit/gateways/clearhaus_test.rb @@ -14,7 +14,7 @@ def setup description: 'Store Purchase' } - @test_signing_key = "7e51b92e-ca7e-48e3-8a96-7d66cf1f2da2" + @test_signing_key = '7e51b92e-ca7e-48e3-8a96-7d66cf1f2da2' end def test_successful_purchase @@ -77,7 +77,7 @@ def test_additional_params def test_successful_authorize_with_card stub_comms do - response = @gateway.authorize(@amount, "4110", @options) + response = @gateway.authorize(@amount, '4110', @options) assert_success response assert_equal '84412a34-fa29-4369-a098-0165a80e8fda', response.authorization @@ -223,9 +223,9 @@ def test_signing_request assert_equal '84412a34-fa29-4369-a098-0165a80e8fda', response.authorization assert response.test? end.check_request do |method, endpoint, data, headers| - assert headers["Signature"] - assert_match %r{7e51b92e-ca7e-48e3-8a96-7d66cf1f2da2 RS256-hex}, headers["Signature"] - assert_match %r{02f56ed1f6c60cdefd$}, headers["Signature"] + assert headers['Signature'] + assert_match %r{7e51b92e-ca7e-48e3-8a96-7d66cf1f2da2 RS256-hex}, headers['Signature'] + assert_match %r{02f56ed1f6c60cdefd$}, headers['Signature'] end.respond_with(successful_authorize_response) end @@ -242,20 +242,20 @@ 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| - assert headers["Signature"] - assert_match %r{7e51b92e-ca7e-48e3-8a96-7d66cf1f2da2 RS256-hex}, headers["Signature"] - assert_match %r{02f56ed1f6c60cdefd$}, headers["Signature"] + assert headers['Signature'] + assert_match %r{7e51b92e-ca7e-48e3-8a96-7d66cf1f2da2 RS256-hex}, headers['Signature'] + assert_match %r{02f56ed1f6c60cdefd$}, headers['Signature'] end.respond_with(successful_authorize_response) 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) - card = credit_card("4111111111111111", month: "06", year: "2018", verification_value: "123") - options = { currency: "EUR", ip: "1.1.1.1" } + card = credit_card('4111111111111111', month: '06', year: '2018', verification_value: '123') + options = { currency: 'EUR', ip: '1.1.1.1' } response = gateway.authorize(2050, card, options) assert_failure response @@ -364,13 +364,13 @@ def failed_purchase_response def successful_authorize_response { - "id" => "84412a34-fa29-4369-a098-0165a80e8fda", - "status" => { - "code" => 20000 + 'id' => '84412a34-fa29-4369-a098-0165a80e8fda', + 'status' => { + 'code' => 20000 }, - "processed_at" => "2014-07-09T09:53:41+00:00", - "_links" => { - "captures" => { "href" => "/authorizations/84412a34-fa29-4369-a098-0165a80e8fda/captures" } + 'processed_at' => '2014-07-09T09:53:41+00:00', + '_links' => { + 'captures' => { 'href' => '/authorizations/84412a34-fa29-4369-a098-0165a80e8fda/captures' } } }.to_json end @@ -381,18 +381,18 @@ 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 @@ -404,14 +404,14 @@ def failed_capture_response def successful_refund_response { - "id" => "f04c0872-47ce-4683-8d8c-e154221bba14", - "status" => { - "code" => 20000 + 'id' => 'f04c0872-47ce-4683-8d8c-e154221bba14', + 'status' => { + 'code' => 20000 }, - "processed_at" => "2014-07-09T11:57:58+00:00", - "amount" => 500, - "_links" => { - "authorization" => { "href" => "/authorizations/84412a34-fa29-4369-a098-0165a80e8fda" } + 'processed_at' => '2014-07-09T11:57:58+00:00', + 'amount' => 500, + '_links' => { + 'authorization' => { 'href' => '/authorizations/84412a34-fa29-4369-a098-0165a80e8fda' } } }.to_json end @@ -422,23 +422,23 @@ def failed_refund_response def successful_void_response { - "id" => "77d08c40-cfa9-42e3-993d-795f772b70a4", - "status" => { - "code" => 20000 + 'id' => '77d08c40-cfa9-42e3-993d-795f772b70a4', + 'status' => { + 'code' => 20000 }, - "processed_at" => "2015-08-21T16:44:48+00:00", - "_links" => { - "self" => { - "href" => "/authorizations/77d08c40-cfa9-42e3-993d-795f772b70a4" + 'processed_at' => '2015-08-21T16:44:48+00:00', + '_links' => { + 'self' => { + 'href' => '/authorizations/77d08c40-cfa9-42e3-993d-795f772b70a4' }, - "card" => { - "href" => "/cards/27127636-0748-4df5-97fe-e58a0c29b618" + 'card' => { + 'href' => '/cards/27127636-0748-4df5-97fe-e58a0c29b618' }, - "captures" => { - "href" => "/authorizations/77d08c40-cfa9-42e3-993d-795f772b70a4/captures" + '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 @@ -449,16 +449,16 @@ def failed_void_response def successful_store_response { - "id" => "58dabba0-e9ea-4133-8c38-bfa1028c1ed2", - "status" => { - "code"=> 20000 + 'id' => '58dabba0-e9ea-4133-8c38-bfa1028c1ed2', + 'status' => { + '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" } + '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' } } }.to_json end @@ -468,7 +468,7 @@ 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/commercegate_test.rb b/test/unit/gateways/commercegate_test.rb index dc2d894741e..5fe0e065ba0 100644 --- a/test/unit/gateways/commercegate_test.rb +++ b/test/unit/gateways/commercegate_test.rb @@ -24,8 +24,8 @@ def test_successful_authorize assert_instance_of Response, response assert_success response assert_equal '100130291387', response.authorization - assert_equal 'U', response.avs_result["code"] - assert_equal 'S', response.cvv_result["code"] + assert_equal 'U', response.avs_result['code'] + assert_equal 'S', response.cvv_result['code'] end def test_successful_capture @@ -44,8 +44,8 @@ def test_successful_purchase assert_instance_of Response, response assert_success response assert_equal '100130291412', response.authorization - assert_equal 'U', response.avs_result["code"] - assert_equal 'S', response.cvv_result["code"] + assert_equal 'U', response.avs_result['code'] + assert_equal 'S', response.cvv_result['code'] assert_equal 'rdkhkRXjPVCXf5jU2Zz5NCcXBihGuaNz', response.params['token'] end @@ -97,34 +97,34 @@ def test_unsuccessful_capture_trans_id_not_found private def failed_request_response - "returnCode=-125&returnText=Invalid+operation" + 'returnCode=-125&returnText=Invalid+operation' end def successful_purchase_response - "action=SALE&returnCode=0&returnText=Success&authCode=040404&avsCode=U&cvvCode=S&amount=10.00&currencyCode=EUR&transID=100130291412&token=rdkhkRXjPVCXf5jU2Zz5NCcXBihGuaNz" + 'action=SALE&returnCode=0&returnText=Success&authCode=040404&avsCode=U&cvvCode=S&amount=10.00&currencyCode=EUR&transID=100130291412&token=rdkhkRXjPVCXf5jU2Zz5NCcXBihGuaNz' end def successful_authorize_response - "action=AUTH&returnCode=0&returnText=Success&authCode=726293&avsCode=U&cvvCode=S&amount=10.00&currencyCode=EUR&transID=100130291387&token=Hf4lDYcKdJsdX92WJ2CpNlEUdh05utsI" + 'action=AUTH&returnCode=0&returnText=Success&authCode=726293&avsCode=U&cvvCode=S&amount=10.00&currencyCode=EUR&transID=100130291387&token=Hf4lDYcKdJsdX92WJ2CpNlEUdh05utsI' end def failed_authorize_response_invalid_country - "action=AUTH&returnCode=-103&returnText=Invalid+country" + 'action=AUTH&returnCode=-103&returnText=Invalid+country' end def successful_capture_response - "action=CAPTURE&returnCode=0&returnText=Success&amount=10.00&currencyCode=EUR&transID=100130291402" + 'action=CAPTURE&returnCode=0&returnText=Success&amount=10.00&currencyCode=EUR&transID=100130291402' end def failed_capture_response_invalid_trans_id - "action=CAPTURE&returnCode=-121&returnText=Previous+transaction+not+found" + 'action=CAPTURE&returnCode=-121&returnText=Previous+transaction+not+found' end def successful_refund_response - "action=REFUND&returnCode=0&returnText=Success&amount=10.00&currencyCode=EUR&transID=100130291425" + 'action=REFUND&returnCode=0&returnText=Success&amount=10.00&currencyCode=EUR&transID=100130291425' end def successful_void_response - "action=VOID_AUTH&returnCode=0&returnText=Success&amount=10.00&currencyCode=EUR&transID=100130425094" + 'action=VOID_AUTH&returnCode=0&returnText=Success&amount=10.00&currencyCode=EUR&transID=100130425094' end end diff --git a/test/unit/gateways/conekta_test.rb b/test/unit/gateways/conekta_test.rb index 13bc272a7a5..31b0319cb3b 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", + :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" + :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 @@ -80,7 +80,7 @@ def test_successful_purchase_with_installments def test_unsuccessful_refund @gateway.expects(:ssl_request).returns(failed_refund_response) - assert response = @gateway.refund(@amount, "1", @options) + assert response = @gateway.refund(@amount, '1', @options) assert_failure response assert response.test? end @@ -133,7 +133,7 @@ def test_unsuccessful_authorize def test_unsuccessful_capture @gateway.expects(:ssl_request).returns(failed_purchase_response) - assert response = @gateway.capture(@amount, "1", @options) + assert response = @gateway.capture(@amount, '1', @options) assert_failure response assert response.test? end @@ -386,10 +386,10 @@ def failed_login_response end def transcript - "card%5Baddress%5D%5Bzip%5D=5555&card%5Bcvc%5D=183&card%5Bexp_month%5D=01&card%5Bexp_year%5D=18&card%5Bname%5D=Mario+F.+Moreno+Reyes&card%5Bnumber%5D=4242424242424242&currency=mxn&description=Blue+clip&details%5Bbilling_address%5D%5Bcity%5D=Guerrero" + 'card%5Baddress%5D%5Bzip%5D=5555&card%5Bcvc%5D=183&card%5Bexp_month%5D=01&card%5Bexp_year%5D=18&card%5Bname%5D=Mario+F.+Moreno+Reyes&card%5Bnumber%5D=4242424242424242&currency=mxn&description=Blue+clip&details%5Bbilling_address%5D%5Bcity%5D=Guerrero' end def scrubbed_transcript - "card%5Baddress%5D%5Bzip%5D=5555&card%5Bcvc%5D=[FILTERED]&card%5Bexp_month%5D=01&card%5Bexp_year%5D=18&card%5Bname%5D=Mario+F.+Moreno+Reyes&card%5Bnumber%5D=[FILTERED]&currency=mxn&description=Blue+clip&details%5Bbilling_address%5D%5Bcity%5D=Guerrero" + 'card%5Baddress%5D%5Bzip%5D=5555&card%5Bcvc%5D=[FILTERED]&card%5Bexp_month%5D=01&card%5Bexp_year%5D=18&card%5Bname%5D=Mario+F.+Moreno+Reyes&card%5Bnumber%5D=[FILTERED]&currency=mxn&description=Blue+clip&details%5Bbilling_address%5D%5Bcity%5D=Guerrero' end end diff --git a/test/unit/gateways/creditcall_test.rb b/test/unit/gateways/creditcall_test.rb index e0bf6105673..146606ff742 100644 --- a/test/unit/gateways/creditcall_test.rb +++ b/test/unit/gateways/creditcall_test.rb @@ -49,42 +49,42 @@ def test_failed_authorize def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - response = @gateway.capture(@amount, "bc8e3abe-b842-e511-b302-00505692354f", @options) + response = @gateway.capture(@amount, 'bc8e3abe-b842-e511-b302-00505692354f', @options) assert_success response end def test_failed_capture @gateway.expects(:ssl_post).returns(failed_capture_response) - response = @gateway.capture(@amount, "", @options) + response = @gateway.capture(@amount, '', @options) assert_failure response end def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - response = @gateway.refund(@amount, "77e55712-ba42-e511-b302-00505692354f", @options) + response = @gateway.refund(@amount, '77e55712-ba42-e511-b302-00505692354f', @options) assert_success response end def test_failed_refund @gateway.expects(:ssl_post).returns(failed_refund_response) - response = @gateway.refund(@amount, "", @options) + response = @gateway.refund(@amount, '', @options) assert_failure response end def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) - response = @gateway.void("e5b1b672-ba42-e511-b302-00505692354f", @options) + response = @gateway.void('e5b1b672-ba42-e511-b302-00505692354f', @options) assert_success response end def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) - response = @gateway.void("", @options) + response = @gateway.void('', @options) assert_failure response end @@ -118,7 +118,7 @@ def test_verification_value_sent end def test_verification_value_not_sent - @credit_card.verification_value = " " + @credit_card.verification_value = ' ' stub_comms do @gateway.authorize(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| diff --git a/test/unit/gateways/credorax_test.rb b/test/unit/gateways/credorax_test.rb index a5e2f009913..8c588c3f108 100644 --- a/test/unit/gateways/credorax_test.rb +++ b/test/unit/gateways/credorax_test.rb @@ -23,7 +23,7 @@ def test_successful_purchase assert_success response - assert_equal "8a82944a5351570601535955efeb513c;006596;02617cf5f02ccaed239b6521748298c5;purchase", response.authorization + assert_equal '8a82944a5351570601535955efeb513c;006596;02617cf5f02ccaed239b6521748298c5;purchase', response.authorization assert response.test? end @@ -33,7 +33,7 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message + assert_equal 'Transaction not allowed for cardholder', response.message assert response.test? end @@ -43,7 +43,7 @@ def test_successful_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "8a829449535154bc0153595952a2517a;006597;90f7449d555f7bed0a2c5d780475f0bf;authorize", response.authorization + assert_equal '8a829449535154bc0153595952a2517a;006597;90f7449d555f7bed0a2c5d780475f0bf;authorize', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -60,13 +60,13 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message + assert_equal 'Transaction not allowed for cardholder', response.message assert response.test? end def test_failed_capture response = stub_comms do - @gateway.capture(100, "") + @gateway.capture(100, '') end.respond_with(failed_capture_response) assert_failure response @@ -78,7 +78,7 @@ def test_successful_void end.respond_with(successful_authorize_response) assert_success response - assert_equal "8a829449535154bc0153595952a2517a;006597;90f7449d555f7bed0a2c5d780475f0bf;purchase", response.authorization + assert_equal '8a829449535154bc0153595952a2517a;006597;90f7449d555f7bed0a2c5d780475f0bf;purchase', response.authorization void = stub_comms do @gateway.void(response.authorization) @@ -91,7 +91,7 @@ def test_successful_void def test_failed_void response = stub_comms do - @gateway.void("5d53a33d960c46d00f5dc061947d998c") + @gateway.void('5d53a33d960c46d00f5dc061947d998c') end.check_request do |endpoint, data, headers| assert_match(/5d53a33d960c46d00f5dc061947d998c/, data) end.respond_with(failed_void_response) @@ -105,7 +105,7 @@ def test_successful_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "8a82944a5351570601535955efeb513c;006596;02617cf5f02ccaed239b6521748298c5;purchase", response.authorization + assert_equal '8a82944a5351570601535955efeb513c;006596;02617cf5f02ccaed239b6521748298c5;purchase', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -118,7 +118,7 @@ def test_successful_refund def test_failed_refund response = stub_comms do - @gateway.refund(nil, "") + @gateway.refund(nil, '') end.respond_with(failed_refund_response) assert_failure response @@ -131,7 +131,7 @@ def test_successful_credit assert_success response - assert_equal "8a82944a53515706015359604c135301;;868f8b942fae639d28e27e8933d575d4;credit", response.authorization + assert_equal '8a82944a53515706015359604c135301;;868f8b942fae639d28e27e8933d575d4;credit', response.authorization assert response.test? end @@ -141,7 +141,7 @@ def test_failed_credit end.respond_with(failed_credit_response) assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message + assert_equal 'Transaction not allowed for cardholder', response.message assert response.test? end @@ -150,7 +150,7 @@ def test_successful_verify @gateway.verify(@credit_card) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_verify @@ -158,7 +158,7 @@ def test_failed_verify @gateway.verify(@credit_card) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "Transaction not allowed for cardholder", response.message + assert_equal 'Transaction not allowed for cardholder', response.message end def test_empty_response_fails @@ -167,7 +167,7 @@ def test_empty_response_fails end.respond_with(empty_purchase_response) assert_failure response - assert_equal "Unable to read error message", response.message + assert_equal 'Unable to read error message', response.message end def test_transcript_scrubbing @@ -175,7 +175,7 @@ def test_transcript_scrubbing end def test_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.purchase(@amount, @credit_card, options_with_3ds) @@ -185,12 +185,12 @@ def test_adds_3d_secure_fields assert_success response - assert_equal "8a82944a5351570601535955efeb513c;006596;02617cf5f02ccaed239b6521748298c5;purchase", response.authorization + assert_equal '8a82944a5351570601535955efeb513c;006596;02617cf5f02ccaed239b6521748298c5;purchase', response.authorization assert response.test? 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) @@ -200,7 +200,7 @@ def test_defaults_3d_secure_cavv_field_to_none_if_not_present assert_success response - assert_equal "8a82944a5351570601535955efeb513c;006596;02617cf5f02ccaed239b6521748298c5;purchase", response.authorization + assert_equal '8a82944a5351570601535955efeb513c;006596;02617cf5f02ccaed239b6521748298c5;purchase', response.authorization assert response.test? end @@ -215,7 +215,7 @@ def test_adds_a9_field end def test_supports_billing_descriptor - @options.merge!({ billing_descriptor: "abcdefghijkl"}) + @options.merge!({ billing_descriptor: 'abcdefghijkl'}) stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| @@ -226,51 +226,51 @@ def test_supports_billing_descriptor private def successful_purchase_response - "M=SPREE978&O=1&T=03%2F09%2F2016+03%3A05%3A16&V=413&a1=02617cf5f02ccaed239b6521748298c5&a2=2&a4=100&a9=6&z1=8a82944a5351570601535955efeb513c&z13=606944188282&z14=U&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006596&z5=0&z6=00&z9=X&K=057e123af2fba5a37b4df76a7cb5cfb6" + 'M=SPREE978&O=1&T=03%2F09%2F2016+03%3A05%3A16&V=413&a1=02617cf5f02ccaed239b6521748298c5&a2=2&a4=100&a9=6&z1=8a82944a5351570601535955efeb513c&z13=606944188282&z14=U&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006596&z5=0&z6=00&z9=X&K=057e123af2fba5a37b4df76a7cb5cfb6' end def failed_purchase_response - "M=SPREE978&O=1&T=03%2F09%2F2016+03%3A05%3A47&V=413&a1=92176aca194ceafdb4a679389b77f207&a2=2&a4=100&a9=6&z1=8a82944a535157060153595668fd5162&z13=606944188283&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=2d44820a5a907ff820f928696e460ce1" + 'M=SPREE978&O=1&T=03%2F09%2F2016+03%3A05%3A47&V=413&a1=92176aca194ceafdb4a679389b77f207&a2=2&a4=100&a9=6&z1=8a82944a535157060153595668fd5162&z13=606944188283&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=2d44820a5a907ff820f928696e460ce1' end def successful_authorize_response - "M=SPREE978&O=2&T=03%2F09%2F2016+03%3A08%3A58&V=413&a1=90f7449d555f7bed0a2c5d780475f0bf&a2=2&a4=100&a9=6&z1=8a829449535154bc0153595952a2517a&z13=606944188284&z14=U&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006597&z5=0&z6=00&z9=X&K=00effd2c80ab7ecd45b499c0bbea3d20" + 'M=SPREE978&O=2&T=03%2F09%2F2016+03%3A08%3A58&V=413&a1=90f7449d555f7bed0a2c5d780475f0bf&a2=2&a4=100&a9=6&z1=8a829449535154bc0153595952a2517a&z13=606944188284&z14=U&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006597&z5=0&z6=00&z9=X&K=00effd2c80ab7ecd45b499c0bbea3d20' end def failed_authorize_response - "M=SPREE978&O=2&T=03%2F09%2F2016+03%3A10%3A02&V=413&a1=9bd85e23639ffcd5206f8e7fe4e3d365&a2=2&a4=100&a9=6&z1=8a829449535154bc0153595a4bb051ac&z13=606944188285&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=2fe3ee6b975d1e4ba542c1e7549056f6" + 'M=SPREE978&O=2&T=03%2F09%2F2016+03%3A10%3A02&V=413&a1=9bd85e23639ffcd5206f8e7fe4e3d365&a2=2&a4=100&a9=6&z1=8a829449535154bc0153595a4bb051ac&z13=606944188285&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=2fe3ee6b975d1e4ba542c1e7549056f6' end def successful_capture_response - "M=SPREE978&O=3&T=03%2F09%2F2016+03%3A09%3A03&V=413&a1=2a349969e0ed61fb0db59fc9f32d2fb3&a2=2&a4=100&g2=8a829449535154bc0153595952a2517a&g3=006597&g4=90f7449d555f7bed0a2c5d780475f0bf&z1=8a82944a535157060153595966ba51f9&z13=606944188284&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006597&z5=0&z6=00&K=4ad979199490a8d000302735220edfa6" + 'M=SPREE978&O=3&T=03%2F09%2F2016+03%3A09%3A03&V=413&a1=2a349969e0ed61fb0db59fc9f32d2fb3&a2=2&a4=100&g2=8a829449535154bc0153595952a2517a&g3=006597&g4=90f7449d555f7bed0a2c5d780475f0bf&z1=8a82944a535157060153595966ba51f9&z13=606944188284&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006597&z5=0&z6=00&K=4ad979199490a8d000302735220edfa6' end def failed_capture_response - "M=SPREE978&O=3&T=03%2F09%2F2016+03%3A10%3A33&V=413&a1=eed7c896e1355dc4007c0c8df44d5852&a2=2&a4=100&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=8d1d8f2f9feeb7909aa3e6c428903d57" + 'M=SPREE978&O=3&T=03%2F09%2F2016+03%3A10%3A33&V=413&a1=eed7c896e1355dc4007c0c8df44d5852&a2=2&a4=100&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=8d1d8f2f9feeb7909aa3e6c428903d57' end def successful_void_response - "M=SPREE978&O=4&T=03%2F09%2F2016+03%3A11%3A11&V=413&a1=&a2=2&a4=100&g2=8a82944a535157060153595b484a524d&g3=006598&g4=0d600bf50198059dbe61979f8c28aab2&z1=8a829449535154bc0153595b57c351d2&z13=606944188287&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006598&z5=0&z6=00&K=e643b9e88b35fd69d5421b59c611a6c9" + 'M=SPREE978&O=4&T=03%2F09%2F2016+03%3A11%3A11&V=413&a1=&a2=2&a4=100&g2=8a82944a535157060153595b484a524d&g3=006598&g4=0d600bf50198059dbe61979f8c28aab2&z1=8a829449535154bc0153595b57c351d2&z13=606944188287&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006598&z5=0&z6=00&K=e643b9e88b35fd69d5421b59c611a6c9' end def failed_void_response - "M=SPREE978&O=4&T=03%2F09%2F2016+03%3A11%3A37&V=413&a1=-&a2=2&a4=-&a5=-&b1=-&z1=1A-1&z2=-9&z3=2.+At+least+one+of+input+parameters+is+malformed.%3A+Parameter+%5Bg4%5D+cannot+be+empty.&K=1e6683cd7b1d01712f12ce7bfc9a5ad2" + 'M=SPREE978&O=4&T=03%2F09%2F2016+03%3A11%3A37&V=413&a1=-&a2=2&a4=-&a5=-&b1=-&z1=1A-1&z2=-9&z3=2.+At+least+one+of+input+parameters+is+malformed.%3A+Parameter+%5Bg4%5D+cannot+be+empty.&K=1e6683cd7b1d01712f12ce7bfc9a5ad2' end def successful_refund_response - "M=SPREE978&O=5&T=03%2F09%2F2016+03%3A15%3A32&V=413&a1=b449bb41af3eb09fd483e7629eb2266f&a2=2&a4=100&g2=8a82944a535157060153595f3ea352c2&g3=006600&g4=78141b277cfadba072a0bcb90745faef&z1=8a82944a535157060153595f553a52de&z13=606944188288&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006600&z5=0&z6=00&K=bfdfd8b0dcee974c07c3c85cfea753fe" + 'M=SPREE978&O=5&T=03%2F09%2F2016+03%3A15%3A32&V=413&a1=b449bb41af3eb09fd483e7629eb2266f&a2=2&a4=100&g2=8a82944a535157060153595f3ea352c2&g3=006600&g4=78141b277cfadba072a0bcb90745faef&z1=8a82944a535157060153595f553a52de&z13=606944188288&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z4=006600&z5=0&z6=00&K=bfdfd8b0dcee974c07c3c85cfea753fe' end 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" + '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_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" + '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 def failed_credit_response - "M=SPREE978&O=6&T=03%2F09%2F2016+03%3A16%3A59&V=413&a1=ff28246cfc811b1c686a52d08d075d9c&a2=2&a4=100&z1=8a829449535154bc01535960a962524f&z13=606944188290&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=cf34816d5c25dc007ef3525505c4c610" + 'M=SPREE978&O=6&T=03%2F09%2F2016+03%3A16%3A59&V=413&a1=ff28246cfc811b1c686a52d08d075d9c&a2=2&a4=100&z1=8a829449535154bc01535960a962524f&z13=606944188290&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=cf34816d5c25dc007ef3525505c4c610' end def empty_purchase_response diff --git a/test/unit/gateways/culqi_test.rb b/test/unit/gateways/culqi_test.rb index be13543b0f4..0cd74341733 100644 --- a/test/unit/gateways/culqi_test.rb +++ b/test/unit/gateways/culqi_test.rb @@ -5,7 +5,7 @@ def setup @gateway = CulqiGateway.new(merchant_id: 'merchant', terminal_id: 'terminal', secret_key: 'password') @amount = 1000 - @credit_card = credit_card("4111111111111111") + @credit_card = credit_card('4111111111111111') @options = { order_id: generate_unique_id, @@ -56,7 +56,7 @@ def test_failed_authorize def test_failed_capture @gateway.expects(:ssl_post).returns(failed_capture_response) - response = @gateway.capture(@amount, "0") + response = @gateway.capture(@amount, '0') assert_failure response assert_match %r{Transaction not found}, response.message end @@ -77,7 +77,7 @@ def test_successful_refund def test_failed_refund @gateway.expects(:ssl_post).returns(failed_refund_response) - response = @gateway.refund(@amount, "0") + response = @gateway.refund(@amount, '0') assert_failure response assert_match %r{Transaction not found}, response.message end @@ -98,7 +98,7 @@ def test_successful_void def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) - response = @gateway.void("0", @options) + response = @gateway.void('0', @options) assert_failure response assert_match %r{Transaction not found}, response.message end diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index e0a4351e4d2..318fc9931f9 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -44,7 +44,7 @@ def setup :credit_card => @credit_card, :setup_fee => 100, :subscription => { - :frequency => "weekly", + :frequency => 'weekly', :start_date => Date.today.next_week, :occurrences => 4, :automatic_renew => true, @@ -67,14 +67,14 @@ def test_purchase_includes_customer_ip customer_ip_regexp = /<ipAddress>#{@customer_ip}<\// @gateway.expects(:ssl_post). with(anything, regexp_matches(customer_ip_regexp), anything). - returns("") + returns('') @gateway.expects(:parse).returns({}) @gateway.purchase(@amount, @credit_card, @options) end def test_purchase_includes_mdd_fields stub_comms do - @gateway.purchase(100, @credit_card, order_id: "1", mdd_field_2: "CustomValue2", mdd_field_3: "CustomValue3") + @gateway.purchase(100, @credit_card, order_id: '1', mdd_field_2: 'CustomValue2', mdd_field_3: 'CustomValue3') end.check_request do |endpoint, data, headers| assert_match(/field2>CustomValue2.*field3>CustomValue3</m, data) end.respond_with(successful_purchase_response) @@ -82,7 +82,7 @@ def test_purchase_includes_mdd_fields 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") + @gateway.authorize(100, @credit_card, order_id: '1', mdd_field_2: 'CustomValue2', mdd_field_3: 'CustomValue3') end.check_request do |endpoint, data, headers| assert_match(/field2>CustomValue2.*field3>CustomValue3</m, data) end.respond_with(successful_authorization_response) @@ -308,7 +308,7 @@ def test_successful_credit_request def test_successful_void_capture_request @gateway.stubs(:ssl_post).returns(successful_capture_response, successful_auth_reversal_response) - assert response_capture = @gateway.capture(@amount, "1846925324700976124593") + assert response_capture = @gateway.capture(@amount, '1846925324700976124593') assert response_capture.success? assert response_capture.test? assert response_auth_reversal = @gateway.void(response_capture.authorization, @options) @@ -351,15 +351,15 @@ def test_unsuccessful_verify @gateway.verify(@credit_card, @options) end.respond_with(unsuccessful_authorization_response) assert_failure response - assert_equal "Invalid account number", response.message + assert_equal 'Invalid account number', response.message end 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" + :transaction_id => '123', + :eci => '05', + :payment_cryptogram => '111111111100cryptogram' ) response = stub_comms do @@ -375,9 +375,9 @@ 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" + :transaction_id => '123', + :eci => '05', + :payment_cryptogram => '111111111100cryptogram' ) response = stub_comms do @@ -399,9 +399,9 @@ def test_successful_auth_with_network_tokenization_for_mastercard credit_card = network_tokenization_credit_card('5555555555554444', :brand => 'mastercard', - :transaction_id => "123", - :eci => "05", - :payment_cryptogram => "111111111100cryptogram" + :transaction_id => '123', + :eci => '05', + :payment_cryptogram => '111111111100cryptogram' ) assert response = @gateway.authorize(@amount, credit_card, @options) @@ -417,9 +417,9 @@ def test_successful_auth_with_network_tokenization_for_amex credit_card = network_tokenization_credit_card('378282246310005', :brand => 'american_express', - :transaction_id => "123", - :eci => "05", - :payment_cryptogram => Base64.encode64("111111111100cryptogram") + :transaction_id => '123', + :eci => '05', + :payment_cryptogram => Base64.encode64('111111111100cryptogram') ) assert response = @gateway.authorize(@amount, credit_card, @options) @@ -433,7 +433,7 @@ def test_nonfractional_currency_handling true end.returns(successful_nonfractional_authorization_response) - assert response = @gateway.authorize(100, @credit_card, @options.merge(currency: "JPY")) + assert response = @gateway.authorize(100, @credit_card, @options.merge(currency: 'JPY')) assert_success response end @@ -454,9 +454,9 @@ def test_3ds_enroll_response end.respond_with(threedeesecure_purchase_response) assert_failure purchase - assert_equal "YTJycDdLR3RIVnpmMXNFejJyazA=", purchase.params["xid"] - assert_equal "eNpVUe9PwjAQ/d6/ghA/r2tBYMvRBEUFFEKQEP1Yu1Om7gfdJoy/3nZsgk2a3Lveu757B+utRhw/oyo0CphjlskPbIXBsC25TvuPD/lkc3xn2d2R6y+3LWA5WuFOwA/qLExiwRzX4UAbSEwLrbYyzgVItbuZLkS353HWA1pDAhHq6Vgw3ule9/pAT5BALCMUqnwznZJCKwRaZQiopIhzXYpB1wXaAAKF/hbbPE8zn9L9fu9cUB2VREBtAQF6FrQsbJSZOQ9hIF7Xs1KNg6dVZzXdxGk0f1nc4+eslMfREKitIBDIHAV3WZ+Z2+Ku3/F8bjRXeQIysmrEFeOOa0yoIYHUfjQ6Icbt02XGTFRojbFqRmoQATykSYymxlD+YjPDWfntxBqrcusg8wbmWGcrXNFD4w3z2IkfVkZRy6H13mi9YhP9W/0vhyyqPw==", purchase.params["paReq"] - assert_equal "https://0eafstag.cardinalcommerce.com/EAFService/jsp/v1/redirect", purchase.params["acsURL"] + assert_equal 'YTJycDdLR3RIVnpmMXNFejJyazA=', purchase.params['xid'] + assert_equal 'eNpVUe9PwjAQ/d6/ghA/r2tBYMvRBEUFFEKQEP1Yu1Om7gfdJoy/3nZsgk2a3Lveu757B+utRhw/oyo0CphjlskPbIXBsC25TvuPD/lkc3xn2d2R6y+3LWA5WuFOwA/qLExiwRzX4UAbSEwLrbYyzgVItbuZLkS353HWA1pDAhHq6Vgw3ule9/pAT5BALCMUqnwznZJCKwRaZQiopIhzXYpB1wXaAAKF/hbbPE8zn9L9fu9cUB2VREBtAQF6FrQsbJSZOQ9hIF7Xs1KNg6dVZzXdxGk0f1nc4+eslMfREKitIBDIHAV3WZ+Z2+Ku3/F8bjRXeQIysmrEFeOOa0yoIYHUfjQ6Icbt02XGTFRojbFqRmoQATykSYymxlD+YjPDWfntxBqrcusg8wbmWGcrXNFD4w3z2IkfVkZRy6H13mi9YhP9W/0vhyyqPw==', purchase.params['paReq'] + assert_equal 'https://0eafstag.cardinalcommerce.com/EAFService/jsp/v1/redirect', purchase.params['acsURL'] end def test_3ds_validate_response diff --git a/test/unit/gateways/data_cash_test.rb b/test/unit/gateways/data_cash_test.rb index ad933feb72a..58049ea6724 100644 --- a/test/unit/gateways/data_cash_test.rb +++ b/test/unit/gateways/data_cash_test.rb @@ -48,14 +48,14 @@ def test_credit def test_deprecated_credit @gateway.expects(:ssl_post).with(anything, regexp_matches(/<method>txn_refund<\/method>/)).returns(successful_purchase_response) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - @gateway.credit(@amount, "transaction_id", @options) + @gateway.credit(@amount, 'transaction_id', @options) end end def test_refund @gateway.expects(:ssl_post).with(anything, regexp_matches(/<method>txn_refund<\/method>/)).returns(successful_purchase_response) - @gateway.refund(@amount, "transaction_id", @options) + @gateway.refund(@amount, 'transaction_id', @options) end def test_unsuccessful_purchase @@ -101,7 +101,7 @@ def test_purchase_does_not_raise_exception_with_missing_billing_address def test_continuous_authority_purchase_with_missing_continuous_authority_reference assert_raise(ArgumentError) do - @gateway.authorize(100, "a;b;", @options) + @gateway.authorize(100, 'a;b;', @options) end end diff --git a/test/unit/gateways/dibs_test.rb b/test/unit/gateways/dibs_test.rb index 65865a7546f..af127ba0be8 100644 --- a/test/unit/gateways/dibs_test.rb +++ b/test/unit/gateways/dibs_test.rb @@ -5,8 +5,8 @@ class DibsTest < Test::Unit::TestCase def setup @gateway = DibsGateway.new( - merchant_id: "merchantId", - secret_key: "secretKey" + merchant_id: 'merchantId', + secret_key: 'secretKey' ) @credit_card = credit_card @@ -20,7 +20,7 @@ def test_successful_purchase assert_success response - assert_equal "1066662996", response.authorization + assert_equal '1066662996', response.authorization assert response.test? end @@ -30,7 +30,7 @@ def test_failed_purchase_due_to_failed_capture end.respond_with(successful_authorize_response, failed_capture_response) assert_failure response - assert_equal "DECLINE: 1", response.message + assert_equal 'DECLINE: 1', response.message assert response.test? end @@ -40,7 +40,7 @@ def test_failed_purchase_due_to_failed_auth end.respond_with(failed_authorize_response) assert_failure response - assert_equal "DECLINE: REJECTED_BY_ACQUIRER", response.message + assert_equal 'DECLINE: REJECTED_BY_ACQUIRER', response.message assert response.test? end @@ -49,7 +49,7 @@ def test_successful_authorize @gateway.authorize(@amount, @credit_card) end.respond_with(successful_authorize_response) assert_success response - assert_equal "1066662996", response.authorization + assert_equal '1066662996', response.authorization end def test_successful_authorize_and_capture @@ -58,7 +58,7 @@ def test_successful_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "1066662996", response.authorization + assert_equal '1066662996', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -75,13 +75,13 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "DECLINE: REJECTED_BY_ACQUIRER", response.message + assert_equal 'DECLINE: REJECTED_BY_ACQUIRER', response.message assert response.test? end def test_failed_capture response = stub_comms do - @gateway.capture(100, "") + @gateway.capture(100, '') end.respond_with(failed_capture_response) assert_failure response @@ -93,7 +93,7 @@ def test_successful_void end.respond_with(successful_authorize_response) assert_success response - assert_equal "1066662996", response.authorization + assert_equal '1066662996', response.authorization void = stub_comms do @gateway.void(response.authorization) @@ -106,7 +106,7 @@ def test_successful_void def test_failed_void response = stub_comms do - @gateway.void("5d53a33d960c46d00f5dc061947d998c") + @gateway.void('5d53a33d960c46d00f5dc061947d998c') end.check_request do |endpoint, data, headers| assert_match(/5d53a33d960c46d00f5dc061947d998c/, data) end.respond_with(failed_void_response) @@ -120,7 +120,7 @@ def test_successful_refund end.respond_with(successful_authorize_response, successful_capture_response) assert_success response - assert_equal "1066662996", response.authorization + assert_equal '1066662996', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -133,7 +133,7 @@ def test_successful_refund def test_failed_refund response = stub_comms do - @gateway.refund(nil, "") + @gateway.refund(nil, '') end.respond_with(failed_refund_response) assert_failure response @@ -144,7 +144,7 @@ def test_successful_verify @gateway.verify(@credit_card) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_verify @@ -152,7 +152,7 @@ def test_failed_verify @gateway.verify(@credit_card) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "DECLINE: REJECTED_BY_ACQUIRER", response.message + assert_equal 'DECLINE: REJECTED_BY_ACQUIRER', response.message end def test_successful_store @@ -162,7 +162,7 @@ def test_successful_store assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message assert response.test? end @@ -172,7 +172,7 @@ def test_failed_store end.respond_with(failed_store_response) assert_failure response - assert_equal "DECLINE: REJECTED_BY_ACQUIRER", response.message + assert_equal 'DECLINE: REJECTED_BY_ACQUIRER', response.message assert response.test? end @@ -232,7 +232,7 @@ def failed_store_response end def invalid_json_response - "{" + '{' end def transcript diff --git a/test/unit/gateways/digitzs_test.rb b/test/unit/gateways/digitzs_test.rb index 2218d909dae..ede14ff24f2 100644 --- a/test/unit/gateways/digitzs_test.rb +++ b/test/unit/gateways/digitzs_test.rb @@ -68,13 +68,13 @@ def test_failed_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "58", response.error_code + assert_equal '58', response.error_code end def test_successful_refund @gateway.expects(:ssl_post).times(2).returns(successful_app_token_response, successful_refund_response) - response = @gateway.refund(@amount, "authorization", @options) + response = @gateway.refund(@amount, 'authorization', @options) assert_success response assert_equal 'spreedly-susanswidg-32268973-2091076-148408385-127-148606617', response.authorization @@ -84,7 +84,7 @@ def test_successful_refund def test_failed_refund @gateway.expects(:ssl_post).times(2).returns(successful_app_token_response, failed_refund_response) - response = @gateway.refund(@amount, "", @options) + response = @gateway.refund(@amount, '', @options) assert_failure response assert_equal nil, response.authorization @@ -96,16 +96,16 @@ def test_successful_store response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "spreedly-susanswidg-32268973-2091076-148408385-2894006614343495-148710226|c0302d83-a694-4bec-9086-d1886b9eefd9-148710226", response.authorization + assert_equal 'spreedly-susanswidg-32268973-2091076-148408385-2894006614343495-148710226|c0302d83-a694-4bec-9086-d1886b9eefd9-148710226', response.authorization end 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 + assert_equal 'spreedly-susanswidg-32268973-2091076-148408385-2894006614343495-148710226|c0302d83-a694-4bec-9086-d1886b9eefd9-148710226', response.authorization end def test_scrub diff --git a/test/unit/gateways/ebanx_test.rb b/test/unit/gateways/ebanx_test.rb index 7504e9c8138..c5e93bc8e13 100644 --- a/test/unit/gateways/ebanx_test.rb +++ b/test/unit/gateways/ebanx_test.rb @@ -28,7 +28,7 @@ def test_failed_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "NOK", response.error_code + assert_equal 'NOK', response.error_code end def test_successful_authorize @@ -46,13 +46,13 @@ def test_failed_authorize response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "NOK", response.error_code + assert_equal 'NOK', response.error_code end def test_successful_capture @gateway.expects(:ssl_request).returns(successful_capture_response) - response = @gateway.capture(@amount, "authorization", @options) + response = @gateway.capture(@amount, 'authorization', @options) assert_success response assert_equal 'Sandbox - Test credit card, transaction captured', response.message @@ -62,15 +62,15 @@ def test_successful_capture def test_failed_capture @gateway.expects(:ssl_request).returns(failed_capture_response) - response = @gateway.capture(@amount, "", @options) + response = @gateway.capture(@amount, '', @options) assert_failure response - assert_equal "BP-CAP-1", response.error_code + assert_equal 'BP-CAP-1', response.error_code end def test_successful_refund @gateway.expects(:ssl_request).returns(successful_refund_response) - response = @gateway.refund(@amount, "authorization", @options) + response = @gateway.refund(@amount, 'authorization', @options) assert_success response assert_equal '59306246f2a0c5f327a15dd6492687e197aca7eda179da08', response.authorization @@ -80,15 +80,15 @@ def test_successful_refund def test_failed_refund @gateway.expects(:ssl_request).returns(failed_refund_response) - response = @gateway.refund(@amount, "", @options) + response = @gateway.refund(@amount, '', @options) assert_failure response - assert_equal "BP-REF-CAN-2", response.error_code + assert_equal 'BP-REF-CAN-2', response.error_code end def test_successful_void @gateway.expects(:ssl_request).returns(successful_void_response) - response = @gateway.void("authorization", @options) + response = @gateway.void('authorization', @options) assert_success response assert_equal '5930629dde0899dc53b3557ea9887aa8f3d264a91d115d40', response.authorization @@ -98,9 +98,9 @@ def test_successful_void def test_failed_void @gateway.expects(:ssl_request).returns(failed_void_response) - response = @gateway.void("", @options) + response = @gateway.void('', @options) assert_failure response - assert_equal "BP-CAN-1", response.error_code + assert_equal 'BP-CAN-1', response.error_code end def test_successful_verify @@ -124,7 +124,7 @@ def test_failed_verify response = @gateway.verify(@credit_card, @options) assert_failure response - assert_equal "NOK", response.error_code + assert_equal 'NOK', response.error_code end def test_successful_store_and_purchase @@ -145,7 +145,7 @@ def test_error_response_with_invalid_creds response = @gateway.store(@credit_card, @options) assert_failure response - assert_equal "Invalid integration key", response.message + assert_equal 'Invalid integration key', response.message end def test_scrub diff --git a/test/unit/gateways/efsnet_test.rb b/test/unit/gateways/efsnet_test.rb index efd5cc71ce0..1a3528186ef 100644 --- a/test/unit/gateways/efsnet_test.rb +++ b/test/unit/gateways/efsnet_test.rb @@ -36,29 +36,29 @@ def test_unsuccessful_purchase end def test_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/AccountNumber>#{@credit_card.number}<\/AccountNumber/), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/AccountNumber>#{@credit_card.number}<\/AccountNumber/), anything).returns('') @gateway.credit(@amount, @credit_card, :order_id => 5) end def test_deprecated_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/<OriginalTransactionID>transaction_id<\/OriginalTransactionID>/), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<OriginalTransactionID>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(/<OriginalTransactionID>transaction_id<\/OriginalTransactionID>/), anything).returns("") - @gateway.refund(@amount, "transaction_id", :order_id => 5) + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<OriginalTransactionID>transaction_id<\/OriginalTransactionID>/), anything).returns('') + @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) @@ -67,10 +67,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) diff --git a/test/unit/gateways/elavon_test.rb b/test/unit/gateways/elavon_test.rb index 48667573b57..a5456d577d4 100644 --- a/test/unit/gateways/elavon_test.rb +++ b/test/unit/gateways/elavon_test.rb @@ -37,7 +37,7 @@ def test_successful_authorization assert_success response assert_equal '123456;00000000-0000-0000-0000-00000000000', response.authorization - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end @@ -58,7 +58,7 @@ def test_successful_capture assert_success response assert_equal '123456;00000000-0000-0000-0000-00000000000', response.authorization - assert_equal "APPROVAL", response.message + assert_equal 'APPROVAL', response.message assert response.test? end @@ -71,7 +71,7 @@ def test_successful_capture_with_auth_code assert_success response assert_equal '123456;00000000-0000-0000-0000-00000000000', response.authorization - assert_equal "APPROVAL", response.message + assert_equal 'APPROVAL', response.message assert response.test? end @@ -89,7 +89,7 @@ def test_successful_capture_with_additional_options assert_success response assert_equal '123456;00000000-0000-0000-0000-00000000000', response.authorization - assert_equal "APPROVAL", response.message + assert_equal 'APPROVAL', response.message assert response.test? end @@ -176,7 +176,7 @@ def test_successful_verify_failed_void @gateway.verify(@credit_card, @options) end.respond_with(successful_authorization_response, failed_void_response) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message end def test_unsuccessful_verify @@ -184,7 +184,7 @@ def test_unsuccessful_verify @gateway.verify(@credit_card, @options) end.respond_with(failed_authorization_response, successful_void_response) assert_failure response - assert_equal "The Credit Card Number supplied in the authorization request appears to be invalid.", response.message + assert_equal 'The Credit Card Number supplied in the authorization request appears to be invalid.', response.message end def test_invalid_login @@ -218,7 +218,7 @@ def test_successful_store assert response = @gateway.store(@credit_card, @options) assert_success response - assert_equal '7595301425001111', response.params["token"] + assert_equal '7595301425001111', response.params['token'] assert response.test? end @@ -267,7 +267,7 @@ def test_zip_codes_with_letters_are_left_intact 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"})) + @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) diff --git a/test/unit/gateways/element_test.rb b/test/unit/gateways/element_test.rb index c032c360459..c731345435d 100644 --- a/test/unit/gateways/element_test.rb +++ b/test/unit/gateways/element_test.rb @@ -49,7 +49,7 @@ def test_failed_purchase_with_echeck def test_successful_purchase_with_payment_account_token @gateway.expects(:ssl_post).returns(successful_purchase_with_payment_account_token_response) - response = @gateway.purchase(@amount, "payment-account-token-id", @options) + response = @gateway.purchase(@amount, 'payment-account-token-id', @options) assert_success response assert_equal '2005838405|100', response.authorization @@ -58,7 +58,7 @@ def test_successful_purchase_with_payment_account_token def test_failed_purchase_with_payment_account_token @gateway.expects(:ssl_post).returns(failed_purchase_with_payment_account_token_response) - response = @gateway.purchase(@amount, "bad-payment-account-token-id", @options) + response = @gateway.purchase(@amount, 'bad-payment-account-token-id', @options) assert_failure response end def test_successful_authorize @@ -81,7 +81,7 @@ def test_failed_authorize def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - response = @gateway.capture(@amount, "trans-id") + response = @gateway.capture(@amount, 'trans-id') assert_success response assert_equal 'Success', response.message end @@ -89,7 +89,7 @@ def test_successful_capture def test_failed_capture @gateway.expects(:ssl_post).returns(failed_capture_response) - response = @gateway.capture(@amount, "bad-trans-id") + response = @gateway.capture(@amount, 'bad-trans-id') assert_failure response assert_equal 'TransactionID required', response.message end @@ -97,7 +97,7 @@ def test_failed_capture def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - response = @gateway.refund(@amount, "trans-id") + response = @gateway.refund(@amount, 'trans-id') assert_success response assert_equal 'Approved', response.message end @@ -105,7 +105,7 @@ def test_successful_refund def test_failed_refund @gateway.expects(:ssl_post).returns(failed_refund_response) - response = @gateway.refund(@amount, "bad-trans-id") + response = @gateway.refund(@amount, 'bad-trans-id') assert_failure response assert_equal 'TransactionID required', response.message end @@ -113,7 +113,7 @@ def test_failed_refund def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) - response = @gateway.void("trans-id") + response = @gateway.void('trans-id') assert_success response assert_equal 'Success', response.message end @@ -121,7 +121,7 @@ def test_successful_void def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) - response = @gateway.void("bad-trans-id") + response = @gateway.void('bad-trans-id') assert_failure response assert_equal 'TransactionAmount required', response.message end @@ -151,7 +151,7 @@ def test_handles_error_response @gateway.expects(:ssl_post).returns(error_response) response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal response.message, "TargetNamespace required" + assert_equal response.message, 'TargetNamespace required' assert_failure response end diff --git a/test/unit/gateways/eway_managed_test.rb b/test/unit/gateways/eway_managed_test.rb index 4586f4b9a88..5e8c914b611 100644 --- a/test/unit/gateways/eway_managed_test.rb +++ b/test/unit/gateways/eway_managed_test.rb @@ -76,10 +76,10 @@ def test_successful_purchase assert response = @gateway.purchase(@amount, @valid_customer_id, @options) assert_instance_of EwayManagedGateway::EwayResponse, response - assert_equal "00,Transaction Approved(Test Gateway)", response.message + assert_equal '00,Transaction Approved(Test Gateway)', response.message assert_success response - assert_equal "123456", response.authorization - assert_equal "123456", response.params['transaction_number'] + assert_equal '123456', response.authorization + assert_equal '123456', response.params['transaction_number'] assert response.test? end @@ -141,9 +141,9 @@ def test_successful_store assert response = @gateway.store(@credit_card, @options) assert_instance_of EwayManagedGateway::EwayResponse, response - assert_equal "OK", response.message + assert_equal 'OK', response.message assert_success response - assert_equal "1234567", response.token + assert_equal '1234567', response.token assert response.test? end @@ -230,7 +230,7 @@ def test_sucessful_update assert response = @gateway.store(@credit_card, @options) assert_instance_of EwayManagedGateway::EwayResponse, response - assert_equal "OK", response.message + assert_equal 'OK', response.message assert_success response assert response.test? end @@ -240,7 +240,7 @@ def test_successful_retrieve assert response = @gateway.retrieve(@valid_customer_id) assert_instance_of EwayManagedGateway::EwayResponse, response - assert_equal "OK", response.message + assert_equal 'OK', response.message assert_success response assert response.test? end diff --git a/test/unit/gateways/eway_rapid_test.rb b/test/unit/gateways/eway_rapid_test.rb index 2b2b4534346..41aed4196d0 100644 --- a/test/unit/gateways/eway_rapid_test.rb +++ b/test/unit/gateways/eway_rapid_test.rb @@ -1,4 +1,4 @@ -require "test_helper" +require 'test_helper' class EwayRapidTest < Test::Unit::TestCase include CommStub @@ -6,8 +6,8 @@ class EwayRapidTest < Test::Unit::TestCase def setup ActiveMerchant::Billing::EwayRapidGateway.partner_id = nil @gateway = EwayRapidGateway.new( - :login => "login", - :password => "password" + :login => 'login', + :password => 'password' ) @credit_card = credit_card @@ -20,7 +20,7 @@ def test_successful_purchase end.respond_with(successful_purchase_response) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message assert_equal 10440187, response.authorization assert response.test? end @@ -45,7 +45,7 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "Invalid Payment TotalAmount", response.message + assert_equal 'Invalid Payment TotalAmount', response.message assert_nil response.authorization assert response.test? end @@ -56,7 +56,7 @@ def test_failed_purchase_without_message end.respond_with(failed_purchase_response_without_message) assert_failure response - assert_equal "Do Not Honour", response.message + assert_equal 'Do Not Honour', response.message assert_nil response.authorization assert response.test? end @@ -67,7 +67,7 @@ def test_failed_purchase_with_multiple_messages end.respond_with(failed_purchase_response_multiple_messages) assert_failure response - assert_equal "Invalid Customer Phone,Invalid ShippingAddress Phone", response.message + assert_equal 'Invalid Customer Phone,Invalid ShippingAddress Phone', response.message assert_nil response.authorization assert response.test? end @@ -76,40 +76,40 @@ def test_purchase_with_all_options response = stub_comms do @gateway.purchase(200, @credit_card, :transaction_type => 'CustomTransactionType', - :redirect_url => "http://awesomesauce.com", - :ip => "0.0.0.0", - :application_id => "Woohoo", - :partner_id => "SomePartner", - :description => "The Really Long Description More Than Sixty Four Characters Gets Truncated", - :order_id => "orderid1", - :invoice => "I1234", - :currency => "INR", - :email => "jim@example.com", + :redirect_url => 'http://awesomesauce.com', + :ip => '0.0.0.0', + :application_id => 'Woohoo', + :partner_id => 'SomePartner', + :description => 'The Really Long Description More Than Sixty Four Characters Gets Truncated', + :order_id => 'orderid1', + :invoice => 'I1234', + :currency => 'INR', + :email => 'jim@example.com', :billing_address => { - :title => "Mr.", - :name => "Jim Awesome Smith", - :company => "Awesome Co", - :address1 => "1234 My Street", - :address2 => "Apt 1", - :city => "Ottawa", - :state => "ON", - :zip => "K1C2N6", - :country => "CA", - :phone => "(555)555-5555", - :fax => "(555)555-6666" + :title => 'Mr.', + :name => 'Jim Awesome Smith', + :company => 'Awesome Co', + :address1 => '1234 My Street', + :address2 => 'Apt 1', + :city => 'Ottawa', + :state => 'ON', + :zip => 'K1C2N6', + :country => 'CA', + :phone => '(555)555-5555', + :fax => '(555)555-6666' }, :shipping_address => { - :title => "Ms.", - :name => "Baker", - :company => "Elsewhere Inc.", - :address1 => "4321 Their St.", - :address2 => "Apt 2", - :city => "Chicago", - :state => "IL", - :zip => "60625", - :country => "US", - :phone => "1115555555", - :fax => "1115556666" + :title => 'Ms.', + :name => 'Baker', + :company => 'Elsewhere Inc.', + :address1 => '4321 Their St.', + :address2 => 'Apt 2', + :city => 'Chicago', + :state => 'IL', + :zip => '60625', + :country => 'US', + :phone => '1115555555', + :fax => '1115556666' } ) end.check_request do |endpoint, data, headers| @@ -185,7 +185,7 @@ def test_partner_id_is_omitted_when_not_set end def test_partner_id_truncates_to_50_characters - partner_string = "EWay Rapid PartnerID is capped at 50 characters and will truncate if it is too long." + partner_string = 'EWay Rapid PartnerID is capped at 50 characters and will truncate if it is too long.' stub_comms do @gateway.purchase(200, @credit_card, partner_id: partner_string) end.check_request do |endpoint, data, headers| @@ -199,17 +199,17 @@ def test_successful_authorize end.respond_with(successful_authorize_response) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message assert_equal 10774952, response.authorization end def test_successful_capture response = stub_comms do - @gateway.capture(nil, "auth") + @gateway.capture(nil, 'auth') end.respond_with(successful_capture_response) assert_success response - assert_equal "982541", response.message + assert_equal '982541', response.message assert_equal 10774953, response.authorization end @@ -219,61 +219,61 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Invalid Payment TotalAmount", response.message + assert_equal 'Invalid Payment TotalAmount', response.message assert_nil response.authorization end def test_failed_capture response = stub_comms do - @gateway.capture(@amount, "auth") + @gateway.capture(@amount, 'auth') end.respond_with(failed_capture_response) assert_failure response - assert_equal "Invalid Auth Transaction ID for Capture/Void", response.message + assert_equal 'Invalid Auth Transaction ID for Capture/Void', response.message assert_equal 0, response.authorization end def test_successful_void response = stub_comms do - @gateway.void("auth") + @gateway.void('auth') end.respond_with(successful_void_response) assert_success response - assert_equal "878060", response.message + assert_equal '878060', response.message assert_equal 10775041, response.authorization end def test_failed_void response = stub_comms do - @gateway.void(@amount, "auth") + @gateway.void(@amount, 'auth') end.respond_with(failed_void_response) assert_failure response - assert_equal "Invalid Auth Transaction ID for Capture/Void", response.message + assert_equal 'Invalid Auth Transaction ID for Capture/Void', response.message assert_equal 0, response.authorization end def test_successful_store response = stub_comms do @gateway.store(@credit_card, :billing_address => { - :title => "Mr.", - :name => "Jim Awesome Smith", - :company => "Awesome Co", - :address1 => "1234 My Street", - :address2 => "Apt 1", - :city => "Ottawa", - :state => "ON", - :zip => "K1C2N6", - :country => "CA", - :phone => "(555)555-5555", - :fax => "(555)555-6666" + :title => 'Mr.', + :name => 'Jim Awesome Smith', + :company => 'Awesome Co', + :address1 => '1234 My Street', + :address2 => 'Apt 1', + :city => 'Ottawa', + :state => 'ON', + :zip => 'K1C2N6', + :country => 'CA', + :phone => '(555)555-5555', + :fax => '(555)555-6666' }) end.check_request do |endpoint, data, headers| assert_match '"Method":"CreateTokenCustomer"', data end.respond_with(successful_store_response) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message assert_equal 917224224772, response.authorization assert response.test? end @@ -284,7 +284,7 @@ def test_failed_store end.respond_with(failed_store_response) assert_failure response - assert_equal "Customer CountryCode Required", response.message + assert_equal 'Customer CountryCode Required', response.message assert_nil response.authorization assert response.test? end @@ -297,7 +297,7 @@ def test_successful_update end.respond_with(successful_update_response) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message assert_equal 916161208398, response.authorization assert response.test? end @@ -313,7 +313,7 @@ def test_successful_refund end.respond_with(successful_refund_response) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message assert_equal 10488258, response.authorization assert response.test? end @@ -324,7 +324,7 @@ def test_failed_refund end.respond_with(failed_refund_response) assert_failure response - assert_equal "System Error", response.message + assert_equal 'System Error', response.message assert_nil response.authorization assert response.test? end @@ -338,7 +338,7 @@ def test_successful_stored_card_purchase end.respond_with(successful_store_purchase_response) assert_success response - assert_equal "Transaction Approved Successful", response.message + assert_equal 'Transaction Approved Successful', response.message assert_equal 10440234, response.authorization assert response.test? end @@ -346,27 +346,27 @@ def test_successful_stored_card_purchase def test_verification_results response = stub_comms do @gateway.purchase(100, @credit_card) - end.respond_with(successful_purchase_response(:verification_status => "Valid")) + end.respond_with(successful_purchase_response(:verification_status => 'Valid')) assert_success response - assert_equal "M", response.cvv_result["code"] - assert_equal "M", response.avs_result["code"] + assert_equal 'M', response.cvv_result['code'] + assert_equal 'M', response.avs_result['code'] response = stub_comms do @gateway.purchase(100, @credit_card) - end.respond_with(successful_purchase_response(:verification_status => "Invalid")) + end.respond_with(successful_purchase_response(:verification_status => 'Invalid')) assert_success response - assert_equal "N", response.cvv_result["code"] - assert_equal "N", response.avs_result["code"] + assert_equal 'N', response.cvv_result['code'] + assert_equal 'N', response.avs_result['code'] response = stub_comms do @gateway.purchase(100, @credit_card) - end.respond_with(successful_purchase_response(:verification_status => "Unchecked")) + end.respond_with(successful_purchase_response(:verification_status => 'Unchecked')) assert_success response - assert_equal "P", response.cvv_result["code"] - assert_equal "I", response.avs_result["code"] + assert_equal 'P', response.cvv_result['code'] + assert_equal 'I', response.avs_result['code'] end def test_transcript_scrubbing diff --git a/test/unit/gateways/exact_test.rb b/test/unit/gateways/exact_test.rb index be5dbb6ea8f..0c33fd415c3 100644 --- a/test/unit/gateways/exact_test.rb +++ b/test/unit/gateways/exact_test.rb @@ -2,8 +2,8 @@ class ExactTest < Test::Unit::TestCase def setup - @gateway = ExactGateway.new( :login => "A00427-01", - :password => "testus" ) + @gateway = ExactGateway.new( :login => 'A00427-01', + :password => 'testus' ) @credit_card = credit_card @amount = 100 @@ -27,7 +27,7 @@ def test_successful_purchase def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - assert response = @gateway.refund(@amount, "123") + assert response = @gateway.refund(@amount, '123') assert_success response end @@ -35,7 +35,7 @@ def test_deprecated_credit @gateway.expects(:ssl_post).returns(successful_refund_response) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - assert response = @gateway.credit(@amount, "123") + assert response = @gateway.credit(@amount, '123') assert_success response end end @@ -50,7 +50,7 @@ def test_failed_purchase def test_expdate - assert_equal( "%02d%s" % [ @credit_card.month, + assert_equal( '%02d%s' % [ @credit_card.month, @credit_card.year.to_s[-2..-1] ], @gateway.send(:expdate, @credit_card) ) end diff --git a/test/unit/gateways/ezic_test.rb b/test/unit/gateways/ezic_test.rb index 8f379901fac..5fa29b4004b 100644 --- a/test/unit/gateways/ezic_test.rb +++ b/test/unit/gateways/ezic_test.rb @@ -22,8 +22,8 @@ def test_successful_purchase assert_success response assert_equal '120741089764', response.authorization assert response.test? - assert_equal "Street address and 9-digit postal code match.", response.avs_result["message"] - assert_equal "CVV matches", response.cvv_result["message"] + assert_equal 'Street address and 9-digit postal code match.', response.avs_result['message'] + assert_equal 'CVV matches', response.cvv_result['message'] end def test_failed_purchase @@ -31,7 +31,7 @@ def test_failed_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "TEST DECLINED", response.message + assert_equal 'TEST DECLINED', response.message end def test_successful_authorize @@ -47,13 +47,13 @@ def test_failed_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response - assert_equal "TEST DECLINED", response.message + assert_equal 'TEST DECLINED', response.message end def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - response = @gateway.capture(@amount, "123312") + response = @gateway.capture(@amount, '123312') assert_success response assert_equal '120762306743', response.authorization end @@ -61,15 +61,15 @@ def test_successful_capture def test_failed_capture @gateway.expects(:raw_ssl_request).returns(failed_capture_response) - response = @gateway.capture(@amount, "2131212") + response = @gateway.capture(@amount, '2131212') assert_failure response - assert_equal "20105: Settlement amount cannot exceed authorized amount", response.message + assert_equal '20105: Settlement amount cannot exceed authorized amount', response.message end def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - response = @gateway.refund(@amount, "32432423", @options) + response = @gateway.refund(@amount, '32432423', @options) assert_success response assert_equal '120421340652', response.authorization end @@ -77,17 +77,17 @@ def test_successful_refund def test_failed_refund @gateway.expects(:raw_ssl_request).returns(failed_refund_response) - response = @gateway.refund(@amount, "5511231") + response = @gateway.refund(@amount, '5511231') assert_failure response - assert_equal "20183: Amount of refunds exceed original sale", response.message + assert_equal '20183: Amount of refunds exceed original sale', response.message end def test_failed_void @gateway.expects(:raw_ssl_request).returns(failed_void_response) - response = @gateway.void("5511231") + response = @gateway.void('5511231') assert_failure response - assert_equal "Processor/Network Error", response.message + assert_equal 'Processor/Network Error', response.message end def test_successful_verify @@ -103,7 +103,7 @@ def test_failed_verify @gateway.verify(@credit_card, @options) end.respond_with(failed_authorize_response, failed_void_response) assert_failure response - assert_equal "TEST DECLINED", response.message + assert_equal 'TEST DECLINED', response.message end def test_scrub @@ -128,39 +128,39 @@ def post_scrubbed end def successful_purchase_response - "avs_code=X&cvv2_code=M&status_code=1&processor=TEST&auth_code=999999&settle_amount=1.00&settle_currency=USD&trans_id=120741089764&auth_msg=TEST+APPROVED&auth_date=2015-04-23+15:27:28" + 'avs_code=X&cvv2_code=M&status_code=1&processor=TEST&auth_code=999999&settle_amount=1.00&settle_currency=USD&trans_id=120741089764&auth_msg=TEST+APPROVED&auth_date=2015-04-23+15:27:28' end def failed_purchase_response - "avs_code=Y&cvv2_code=M&status_code=0&processor=TEST&settle_currency=USD&settle_amount=190.88&trans_id=120740287652&auth_msg=TEST+DECLINED&auth_date=2015-04-23+15:31:30" + 'avs_code=Y&cvv2_code=M&status_code=0&processor=TEST&settle_currency=USD&settle_amount=190.88&trans_id=120740287652&auth_msg=TEST+DECLINED&auth_date=2015-04-23+15:31:30' end def successful_authorize_response - "avs_code=X&cvv2_code=M&status_code=T&processor=TEST&auth_code=999999&settle_amount=1.00&settle_currency=USD&trans_id=120762306743&auth_msg=TEST+APPROVED&ticket_code=XXXXXXXXXXXXXXX&auth_date=2015-04-23+17:24:37" + 'avs_code=X&cvv2_code=M&status_code=T&processor=TEST&auth_code=999999&settle_amount=1.00&settle_currency=USD&trans_id=120762306743&auth_msg=TEST+APPROVED&ticket_code=XXXXXXXXXXXXXXX&auth_date=2015-04-23+17:24:37' end def failed_authorize_response - "avs_code=Y&cvv2_code=M&status_code=0&processor=TEST&auth_code=999999&settle_currency=USD&settle_amount=190.88&trans_id=120761061862&auth_msg=TEST+DECLINED&ticket_code=XXXXXXXXXXXXXXX&auth_date=2015-04-23+17:25:35" + 'avs_code=Y&cvv2_code=M&status_code=0&processor=TEST&auth_code=999999&settle_currency=USD&settle_amount=190.88&trans_id=120761061862&auth_msg=TEST+DECLINED&ticket_code=XXXXXXXXXXXXXXX&auth_date=2015-04-23+17:25:35' end def successful_capture_response - "avs_code=X&cvv2_code=M&status_code=1&auth_code=999999&trans_id=120762306743&auth_msg=TEST+CAPTURED&ticket_code=XXXXXXXXXXXXXXX&auth_date=2015-04-23+17:24:37" + 'avs_code=X&cvv2_code=M&status_code=1&auth_code=999999&trans_id=120762306743&auth_msg=TEST+CAPTURED&ticket_code=XXXXXXXXXXXXXXX&auth_date=2015-04-23+17:24:37' end def failed_capture_response - MockResponse.failed("", 611, "20105: Settlement amount cannot exceed authorized amount") + MockResponse.failed('', 611, '20105: Settlement amount cannot exceed authorized amount') end def successful_refund_response - "status_code=1&processor=TEST&auth_code=RRRRRR&settle_amount=-1.00&settle_currency=USD&trans_id=120421340652&auth_msg=TEST+RETURNED&auth_date=2015-04-23+18:26:02" + 'status_code=1&processor=TEST&auth_code=RRRRRR&settle_amount=-1.00&settle_currency=USD&trans_id=120421340652&auth_msg=TEST+RETURNED&auth_date=2015-04-23+18:26:02' end def failed_refund_response - MockResponse.failed("", 611, "20183: Amount of refunds exceed original sale") + MockResponse.failed('', 611, '20183: Amount of refunds exceed original sale') end def failed_void_response - MockResponse.failed("", 611, "Processor/Network Error") + MockResponse.failed('', 611, 'Processor/Network Error') end def successful_authorize_raw_response diff --git a/test/unit/gateways/fat_zebra_test.rb b/test/unit/gateways/fat_zebra_test.rb index 3c62fe2edb9..2251655ff70 100644 --- a/test/unit/gateways/fat_zebra_test.rb +++ b/test/unit/gateways/fat_zebra_test.rb @@ -34,7 +34,7 @@ def test_successful_purchase_with_token body.match '"card_token":"e1q7dbj2"' }.returns(successful_purchase_response) - assert response = @gateway.purchase(@amount, "e1q7dbj2", @options) + assert response = @gateway.purchase(@amount, 'e1q7dbj2', @options) assert_success response assert_equal '001-P-12345AA', response.authorization @@ -46,7 +46,7 @@ def test_successful_purchase_with_token_string body.match '"card_token":"e1q7dbj2"' }.returns(successful_purchase_response) - assert response = @gateway.purchase(@amount, "e1q7dbj2", @options) + assert response = @gateway.purchase(@amount, 'e1q7dbj2', @options) assert_success response assert_equal '001-P-12345AA', response.authorization @@ -58,7 +58,7 @@ def test_successful_multi_currency_purchase body.match '"currency":"USD"' }.returns(successful_purchase_response) - assert response = @gateway.purchase(@amount, "e1q7dbj2", @options.merge(:currency => 'USD')) + assert response = @gateway.purchase(@amount, 'e1q7dbj2', @options.merge(:currency => 'USD')) assert_success response assert_equal '001-P-12345AA', response.authorization @@ -79,7 +79,7 @@ def test_successful_purchase_with_descriptor json['extra']['name'] == 'Merchant' && json['extra']['location'] == 'Location' }.returns(successful_purchase_response) - assert response = @gateway.purchase(@amount, "e1q7dbj2", @options.merge(:merchant => 'Merchant', :merchant_location => 'Location')) + assert response = @gateway.purchase(@amount, 'e1q7dbj2', @options.merge(:merchant => 'Merchant', :merchant_location => 'Location')) assert_success response assert_equal '001-P-12345AA', response.authorization @@ -91,7 +91,7 @@ def test_successful_authorization body.match '"capture":false' }.returns(successful_purchase_response) - assert response = @gateway.authorize(@amount, "e1q7dbj2", @options) + assert response = @gateway.authorize(@amount, 'e1q7dbj2', @options) assert_success response assert_equal '001-P-12345AA', response.authorization @@ -103,7 +103,7 @@ def test_successful_capture url =~ %r[purchases/e1q7dbj2/capture\z] }.returns(successful_purchase_response) - response = @gateway.capture(@amount, "e1q7dbj2", @options) + response = @gateway.capture(@amount, 'e1q7dbj2', @options) assert_success response assert_equal '001-P-12345AA', response.authorization assert response.test? @@ -128,7 +128,7 @@ def test_declined_purchase end def test_parse_error - @gateway.expects(:ssl_request).returns("{") # Some invalid JSON + @gateway.expects(:ssl_request).returns('{') # Some invalid JSON assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response assert_match %r{Invalid JSON response}, response.message @@ -147,7 +147,7 @@ def test_successful_tokenization assert response = @gateway.store(@credit_card) assert_success response - assert_equal "e1q7dbj2", response.authorization + assert_equal 'e1q7dbj2', response.authorization end def test_unsuccessful_tokenization @@ -160,7 +160,7 @@ def test_unsuccessful_tokenization def test_successful_refund @gateway.expects(:ssl_request).returns(successful_refund_response) - assert response = @gateway.refund(100, "TEST") + assert response = @gateway.refund(100, 'TEST') assert_success response assert_equal '003-R-7MNIUMY6', response.authorization assert response.test? @@ -169,7 +169,7 @@ def test_successful_refund def test_unsuccessful_refund @gateway.expects(:ssl_request).returns(unsuccessful_refund_response) - assert response = @gateway.refund(100, "TEST") + assert response = @gateway.refund(100, 'TEST') assert_failure response assert response.test? end @@ -241,16 +241,16 @@ def successful_purchase_response { :successful => true, :response => { - :authorization => "55355", - :id => "001-P-12345AA", - :card_number => "XXXXXXXXXXXX1111", - :card_holder => "John Smith", - :card_expiry => "10/2011", - :card_token => "a1bhj98j", + :authorization => '55355', + :id => '001-P-12345AA', + :card_number => 'XXXXXXXXXXXX1111', + :card_holder => 'John Smith', + :card_expiry => '10/2011', + :card_token => 'a1bhj98j', :amount => 349, :successful => true, - :reference => "ABC123", - :message => "Approved", + :reference => 'ABC123', + :message => 'Approved', }, :test => true, :errors => [] @@ -263,13 +263,13 @@ def declined_purchase_response :response => { :authorization_id => nil, :id => nil, - :card_number => "XXXXXXXXXXXX1111", - :card_holder => "John Smith", - :card_expiry => "10/2011", + :card_number => 'XXXXXXXXXXXX1111', + :card_holder => 'John Smith', + :card_expiry => '10/2011', :amount => 100, :authorized => false, - :reference => "ABC123", - :message => "Card Declined - check with issuer", + :reference => 'ABC123', + :message => 'Card Declined - check with issuer', }, :test => true, :errors => [] @@ -280,16 +280,16 @@ def successful_refund_response { :successful => true, :response => { - :authorization => "1339973263", - :id => "003-R-7MNIUMY6", + :authorization => '1339973263', + :id => '003-R-7MNIUMY6', :amount => -10, - :refunded => "Approved", - :message => "08 Approved", - :card_holder => "Harry Smith", - :card_number => "XXXXXXXXXXXX4444", - :card_expiry => "2013-05-31", - :card_type => "MasterCard", - :transaction_id => "003-R-7MNIUMY6", + :refunded => 'Approved', + :message => '08 Approved', + :card_holder => 'Harry Smith', + :card_number => 'XXXXXXXXXXXX4444', + :card_expiry => '2013-05-31', + :card_type => 'MasterCard', + :transaction_id => '003-R-7MNIUMY6', :successful => true }, :errors => [ @@ -308,10 +308,10 @@ def unsuccessful_refund_response :amount => nil, :refunded => nil, :message => nil, - :card_holder => "Matthew Savage", - :card_number => "XXXXXXXXXXXX4444", - :card_expiry => "2013-05-31", - :card_type => "MasterCard", + :card_holder => 'Matthew Savage', + :card_number => 'XXXXXXXXXXXX4444', + :card_expiry => '2013-05-31', + :card_type => 'MasterCard', :transaction_id => nil, :successful => false }, @@ -326,10 +326,10 @@ def successful_tokenize_response { :successful => true, :response => { - :token => "e1q7dbj2", - :card_holder => "Bob Smith", - :card_number => "XXXXXXXXXXXX2346", - :card_expiry => "2013-05-31T23:59:59+10:00", + :token => 'e1q7dbj2', + :card_holder => 'Bob Smith', + :card_number => 'XXXXXXXXXXXX2346', + :card_expiry => '2013-05-31T23:59:59+10:00', :authorized => true, :transaction_count => 0 }, @@ -343,8 +343,8 @@ def failed_tokenize_response :successful => false, :response => { :token => nil, - :card_holder => "Bob ", - :card_number => "512345XXXXXX2346", + :card_holder => 'Bob ', + :card_number => '512345XXXXXX2346', :card_expiry => nil, :authorized => false, :transaction_count => 10 @@ -362,7 +362,7 @@ def failed_purchase_response :successful => false, :response => {}, :test => true, - :errors => ["Invalid Card Number"] + :errors => ['Invalid Card Number'] }.to_json end @@ -371,7 +371,7 @@ def missing_data_response :successful => false, :response => {}, :test => true, - :errors => ["Card Number is required"] + :errors => ['Card Number is required'] }.to_json end end diff --git a/test/unit/gateways/federated_canada_test.rb b/test/unit/gateways/federated_canada_test.rb index bd5c2415124..2e7daeb5718 100644 --- a/test/unit/gateways/federated_canada_test.rb +++ b/test/unit/gateways/federated_canada_test.rb @@ -20,7 +20,7 @@ def setup def test_successful_authorization @gateway.expects(:ssl_post).returns(successful_authorization_response) - options = {:billing_address => {:address1 => '888', :address2 => "apt 13", :country => 'CA', :state => 'SK', :city => "Big Beaver", :zip => "77777"}} + options = {:billing_address => {:address1 => '888', :address2 => 'apt 13', :country => 'CA', :state => 'SK', :city => 'Big Beaver', :zip => '77777'}} assert response = @gateway.authorize(@amount, @credit_card, options) assert_instance_of Response, response assert_success response @@ -48,8 +48,8 @@ def test_unsuccessful_request def test_add_address result = {} - @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Happy Town Road', :address2 => "apt 13", :country => 'CA', :state => 'SK', :phone => '1234567890'} ) - assert_equal ["address1", "address2", "city", "company", "country", "phone", "state", "zip"], result.stringify_keys.keys.sort + @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Happy Town Road', :address2 => 'apt 13', :country => 'CA', :state => 'SK', :phone => '1234567890'} ) + assert_equal ['address1', 'address2', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort assert_equal 'SK', result[:state] assert_equal '123 Happy Town Road', result[:address1] assert_equal 'apt 13', result[:address2] @@ -58,7 +58,7 @@ def test_add_address def test_add_invoice result = {} - @gateway.send(:add_invoice, result, :order_id => '#1001', :description => "This is a great order") + @gateway.send(:add_invoice, result, :order_id => '#1001', :description => 'This is a great order') assert_equal '#1001', result[:orderid] assert_equal 'This is a great order', result[:orderdescription] end @@ -82,8 +82,8 @@ def test_purchase_meets_minimum_requirements end def test_expdate_formatting - assert_equal '0909', @gateway.send(:expdate, credit_card('4111111111111111', :month => "9", :year => "2009")) - assert_equal '0711', @gateway.send(:expdate, credit_card('4111111111111111', :month => "7", :year => "2011")) + assert_equal '0909', @gateway.send(:expdate, credit_card('4111111111111111', :month => '9', :year => '2009')) + assert_equal '0711', @gateway.send(:expdate, credit_card('4111111111111111', :month => '7', :year => '2011')) end def test_supported_countries @@ -117,7 +117,7 @@ def test_amount private def post_data_fixture - "password=password&type=auth&ccnumber=4111111111111111&username=demo&ccexp=1111&amount=100&cvv=999" + 'password=password&type=auth&ccnumber=4111111111111111&username=demo&ccexp=1111&amount=100&cvv=999' end def minimum_requirements @@ -126,16 +126,16 @@ def minimum_requirements # Raw successful authorization response def successful_authorization_response - "response=1&responsetext=SUCCESS&authcode=123456&transactionid=1355694937&avsresponse=Y&cvvresponse=M&orderid=&type=auth&response_code=100" + 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1355694937&avsresponse=Y&cvvresponse=M&orderid=&type=auth&response_code=100' end # Raw successful purchase response def successful_purchase_response - "response=1&responsetext=SUCCESS&authcode=123456&transactionid=1346648416&avsresponse=N&cvvresponse=N&orderid=&type=sale&response_code=100" + 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1346648416&avsresponse=N&cvvresponse=N&orderid=&type=sale&response_code=100' end # Raw failed sale response def failed_purchase_response - "response=2&responsetext=DECLINE&authcode=&transactionid=1346648595&avsresponse=N&cvvresponse=N&orderid=&type=sale&response_code=200" + 'response=2&responsetext=DECLINE&authcode=&transactionid=1346648595&avsresponse=N&cvvresponse=N&orderid=&type=sale&response_code=200' end end diff --git a/test/unit/gateways/first_giving_test.rb b/test/unit/gateways/first_giving_test.rb index c368b8d3562..1e9b7f0345b 100644 --- a/test/unit/gateways/first_giving_test.rb +++ b/test/unit/gateways/first_giving_test.rb @@ -3,9 +3,9 @@ class FirstGivingTest < Test::Unit::TestCase def setup @gateway = FirstGivingGateway.new( - application_key: "application_key", - security_token: "security_token", - charity_id: "charity_id" + application_key: 'application_key', + security_token: 'security_token', + charity_id: 'charity_id' ) @credit_card = credit_card @@ -20,8 +20,8 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "a-c71f5e0a25f96e48a3dc54", response.authorization - assert_equal "Success", response.message + assert_equal 'a-c71f5e0a25f96e48a3dc54', response.authorization + assert_equal 'Success', response.message end def test_unsuccessful_purchase @@ -29,7 +29,7 @@ def test_unsuccessful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Unfortunately, we were unable to perform credit card number validation. The credit card number validator responded with the following message ccNumber failed data validation for the following reasons : creditcardChecksum: 4457010000000000 seems to contain an invalid checksum.", response.message + assert_equal 'Unfortunately, we were unable to perform credit card number validation. The credit card number validator responded with the following message ccNumber failed data validation for the following reasons : creditcardChecksum: 4457010000000000 seems to contain an invalid checksum.', response.message end def test_successful_refund @@ -37,7 +37,7 @@ def test_successful_refund response = @gateway.refund(@amount, @options) assert_success response - assert_equal "a-a09bf64559e5824eb925f5", response.authorization + assert_equal 'a-a09bf64559e5824eb925f5', response.authorization end def test_unsuccessful_refund @@ -45,7 +45,7 @@ def test_unsuccessful_refund response = @gateway.refund(@amount, @options) assert_failure response - assert_equal "Bad JG_APPLICATIONKEY and JG_SECURITYTOKEN.", response.message + assert_equal 'Bad JG_APPLICATIONKEY and JG_SECURITYTOKEN.', response.message end private diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb index 284e2e952a8..eb01abdebbd 100755 --- a/test/unit/gateways/firstdata_e4_test.rb +++ b/test/unit/gateways/firstdata_e4_test.rb @@ -7,8 +7,8 @@ class FirstdataE4Test < Test::Unit::TestCase def setup @gateway = FirstdataE4Gateway.new( - :login => "A00427-01", - :password => "testus" + :login => 'A00427-01', + :password => 'testus' ) @credit_card = credit_card @@ -18,7 +18,7 @@ def setup :billing_address => address, :description => 'Store Purchase' } - @authorization = "ET1700;106625152;4738" + @authorization = 'ET1700;106625152;4738' end def test_invalid_credentials @@ -110,7 +110,7 @@ def test_failed_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response assert_failure response - assert_equal response.error_code, "invalid_expiry_date" + assert_equal response.error_code, 'invalid_expiry_date' end def test_successful_verify @@ -122,7 +122,7 @@ def test_successful_verify def test_expdate assert_equal( - "%02d%s" % [@credit_card.month, @credit_card.year.to_s[-2..-1]], + '%02d%s' % [@credit_card.month, @credit_card.year.to_s[-2..-1]], @gateway.send(:expdate, @credit_card) ) end @@ -161,24 +161,24 @@ def test_requests_include_verification_string stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| - assert_match "<VerificationStr1>456 My Street|K1C2N6|Ottawa|ON|CA</VerificationStr1>", data + assert_match '<VerificationStr1>456 My Street|K1C2N6|Ottawa|ON|CA</VerificationStr1>', data end.respond_with(successful_purchase_response) end def test_tax_fields_are_sent stub_comms do - @gateway.purchase(@amount, @credit_card, @options.merge(tax1_amount: 830, tax1_number: "Br59a")) + @gateway.purchase(@amount, @credit_card, @options.merge(tax1_amount: 830, tax1_number: 'Br59a')) end.check_request do |endpoint, data, headers| - assert_match "<Tax1Amount>830", data - assert_match "<Tax1Number>Br59a", data + assert_match '<Tax1Amount>830', data + assert_match '<Tax1Number>Br59a', data end.respond_with(successful_purchase_response) end def test_customer_ref_is_sent stub_comms do - @gateway.purchase(@amount, @credit_card, @options.merge(customer: "932")) + @gateway.purchase(@amount, @credit_card, @options.merge(customer: '932')) end.check_request do |endpoint, data, headers| - assert_match "<Customer_Ref>932", data + assert_match '<Customer_Ref>932', data end.respond_with(successful_purchase_response) end @@ -186,18 +186,18 @@ def test_eci_default_value stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| - assert_match "<Ecommerce_Flag>07</Ecommerce_Flag>", data + assert_match '<Ecommerce_Flag>07</Ecommerce_Flag>', data end.respond_with(successful_purchase_response) end def test_eci_numeric_padding @credit_card = network_tokenization_credit_card - @credit_card.eci = "5" + @credit_card.eci = '5' stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| - assert_match "<Ecommerce_Flag>05</Ecommerce_Flag>", data + assert_match '<Ecommerce_Flag>05</Ecommerce_Flag>', data end.respond_with(successful_purchase_response) @credit_card = network_tokenization_credit_card @@ -206,31 +206,31 @@ def test_eci_numeric_padding stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| - assert_match "<Ecommerce_Flag>05</Ecommerce_Flag>", data + assert_match '<Ecommerce_Flag>05</Ecommerce_Flag>', data end.respond_with(successful_purchase_response) end def test_eci_option_value stub_comms do - @gateway.purchase(@amount, @credit_card, @options.merge(eci: "05")) + @gateway.purchase(@amount, @credit_card, @options.merge(eci: '05')) end.check_request do |endpoint, data, headers| - assert_match "<Ecommerce_Flag>05</Ecommerce_Flag>", data + assert_match '<Ecommerce_Flag>05</Ecommerce_Flag>', data end.respond_with(successful_purchase_response) end def test_network_tokenization_requests_with_amex stub_comms do credit_card = network_tokenization_credit_card( - "378282246310005", - brand: "american_express", - transaction_id: "123", - eci: "05", - payment_cryptogram: "whatever_the_cryptogram_of_at_least_20_characters_is", + '378282246310005', + brand: 'american_express', + transaction_id: '123', + eci: '05', + payment_cryptogram: 'whatever_the_cryptogram_of_at_least_20_characters_is', ) @gateway.purchase(@amount, credit_card, @options) end.check_request do |_, data, _| - assert_match "<Ecommerce_Flag>05</Ecommerce_Flag>", data + assert_match '<Ecommerce_Flag>05</Ecommerce_Flag>', data assert_match "<XID>mrLdtHIWq2nLXq7IrA==\n</XID>", data assert_match "<CAVV>whateverthecryptogramofatlc=\n</CAVV>", data assert_xml_valid_to_wsdl(data) @@ -240,18 +240,18 @@ def test_network_tokenization_requests_with_amex def test_network_tokenization_requests_with_discover stub_comms do credit_card = network_tokenization_credit_card( - "6011111111111117", - brand: "discover", - transaction_id: "123", - eci: "05", - payment_cryptogram: "whatever_the_cryptogram_is", + '6011111111111117', + brand: 'discover', + transaction_id: '123', + eci: '05', + payment_cryptogram: 'whatever_the_cryptogram_is', ) @gateway.purchase(@amount, credit_card, @options) end.check_request do |_, data, _| - assert_match "<Ecommerce_Flag>04</Ecommerce_Flag>", data - assert_match "<XID>123</XID>", data - assert_match "<CAVV>whatever_the_cryptogram_is</CAVV>", data + assert_match '<Ecommerce_Flag>04</Ecommerce_Flag>', data + assert_match '<XID>123</XID>', data + assert_match '<CAVV>whatever_the_cryptogram_is</CAVV>', data assert_xml_valid_to_wsdl(data) end.respond_with(successful_purchase_response) end @@ -260,18 +260,18 @@ def test_network_tokenization_requests_with_other_brands %w(visa mastercard other).each do |brand| stub_comms do credit_card = network_tokenization_credit_card( - "378282246310005", + '378282246310005', brand: brand, - transaction_id: "123", - eci: "05", - payment_cryptogram: "whatever_the_cryptogram_is", + transaction_id: '123', + eci: '05', + payment_cryptogram: 'whatever_the_cryptogram_is', ) @gateway.purchase(@amount, credit_card, @options) end.check_request do |_, data, _| - assert_match "<Ecommerce_Flag>05</Ecommerce_Flag>", data - assert_match "<XID>123</XID>", data - assert_match "<CAVV>whatever_the_cryptogram_is</CAVV>", data + assert_match '<Ecommerce_Flag>05</Ecommerce_Flag>', data + assert_match '<XID>123</XID>', data + assert_match '<CAVV>whatever_the_cryptogram_is</CAVV>', data assert_xml_valid_to_wsdl(data) end.respond_with(successful_purchase_response) end @@ -279,18 +279,18 @@ def test_network_tokenization_requests_with_other_brands def test_requests_include_card_authentication_data authentication_hash = { - eci: "06", - cavv: "SAMPLECAVV", - xid: "SAMPLEXID" + eci: '06', + cavv: 'SAMPLECAVV', + xid: 'SAMPLEXID' } options_with_authentication_data = @options.merge(authentication_hash) stub_comms do @gateway.purchase(@amount, @credit_card, options_with_authentication_data) end.check_request do |endpoint, data, headers| - assert_match "<Ecommerce_Flag>06</Ecommerce_Flag>", data - assert_match "<CAVV>SAMPLECAVV</CAVV>", data - assert_match "<XID>SAMPLEXID</XID>", data + assert_match '<Ecommerce_Flag>06</Ecommerce_Flag>', data + assert_match '<CAVV>SAMPLECAVV</CAVV>', data + assert_match '<XID>SAMPLEXID</XID>', data assert_xml_valid_to_wsdl(data) end.respond_with(successful_purchase_response) end @@ -305,13 +305,13 @@ def test_card_type end def test_add_swipe_data_with_creditcard - @credit_card.track_data = "Track Data" + @credit_card.track_data = 'Track Data' stub_comms do @gateway.purchase(@amount, @credit_card) end.check_request do |endpoint, data, headers| - assert_match "<Track1>Track Data</Track1>", data - assert_match "<Ecommerce_Flag>R</Ecommerce_Flag>", data + assert_match '<Track1>Track Data</Track1>', data + assert_match '<Ecommerce_Flag>R</Ecommerce_Flag>', data end.respond_with(successful_purchase_response) end diff --git a/test/unit/gateways/flo2cash_simple_test.rb b/test/unit/gateways/flo2cash_simple_test.rb index 6037368c7f4..627f6782e29 100644 --- a/test/unit/gateways/flo2cash_simple_test.rb +++ b/test/unit/gateways/flo2cash_simple_test.rb @@ -18,14 +18,14 @@ def setup def test_successful_purchase response = stub_comms do - @gateway.purchase(@amount, @credit_card, order_id: "boom") + @gateway.purchase(@amount, @credit_card, order_id: 'boom') end.check_request do |endpoint, data, headers| assert_match(%r{<Reference>boom</Reference>}, data) end.respond_with(successful_purchase_response) assert_success response - assert_equal "P150200005007600", response.authorization + assert_equal 'P150200005007600', response.authorization assert response.test? end @@ -35,7 +35,7 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "Transaction Declined - Bank Error", response.message + assert_equal 'Transaction Declined - Bank Error', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code assert response.test? end @@ -46,7 +46,7 @@ def test_successful_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "P150200005007600", response.authorization + assert_equal 'P150200005007600', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -63,7 +63,7 @@ def test_empty_response_fails end.respond_with(empty_purchase_response) assert_failure response - assert_equal "Unable to read error message", response.message + assert_equal 'Unable to read error message', response.message end def test_transcript_scrubbing diff --git a/test/unit/gateways/flo2cash_test.rb b/test/unit/gateways/flo2cash_test.rb index ca01d04299f..4564114db64 100644 --- a/test/unit/gateways/flo2cash_test.rb +++ b/test/unit/gateways/flo2cash_test.rb @@ -18,14 +18,14 @@ def setup def test_successful_purchase response = stub_comms do - @gateway.purchase(@amount, @credit_card, order_id: "boom") + @gateway.purchase(@amount, @credit_card, order_id: 'boom') end.check_request do |endpoint, data, headers| assert_match(%r{<Reference>boom</Reference>}, data) end.respond_with(successful_authorize_response, successful_capture_response) assert_success response - assert_equal "P150100005006789", response.authorization + assert_equal 'P150100005006789', response.authorization assert response.test? end @@ -35,7 +35,7 @@ def test_failed_purchase end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Transaction Declined - Bank Error", response.message + assert_equal 'Transaction Declined - Bank Error', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.responses.first.error_code assert response.test? end @@ -46,7 +46,7 @@ def test_successful_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "P150100005006789", response.authorization + assert_equal 'P150100005006789', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -63,7 +63,7 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Transaction Declined - Bank Error", response.message + assert_equal 'Transaction Declined - Bank Error', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code assert response.test? end @@ -74,7 +74,7 @@ def test_successful_refund end.respond_with(successful_authorize_response, successful_capture_response) assert_success response - assert_equal "P150100005006789", response.authorization + assert_equal 'P150100005006789', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -91,7 +91,7 @@ def test_empty_response_fails end.respond_with(empty_purchase_response) assert_failure response - assert_equal "Unable to read error message", response.message + assert_equal 'Unable to read error message', response.message end def test_transcript_scrubbing diff --git a/test/unit/gateways/forte_test.rb b/test/unit/gateways/forte_test.rb index 053e0c7636f..124d2b3a17f 100644 --- a/test/unit/gateways/forte_test.rb +++ b/test/unit/gateways/forte_test.rb @@ -40,7 +40,7 @@ def test_failed_purchase @gateway.purchase(@amount, @credit_card, @options) end.respond_with(MockedResponse.new(failed_purchase_response)) assert_failure response - assert_equal "INVALID TRN", response.message + assert_equal 'INVALID TRN', response.message end def test_successful_purchase_with_echeck @@ -58,7 +58,7 @@ def test_failed_purchase_with_echeck @gateway.purchase(@amount, @credit_card, @options) end.respond_with(MockedResponse.new(failed_echeck_purchase_response)) assert_failure response - assert_equal "INVALID CREDIT CARD NUMBER", response.message + assert_equal 'INVALID CREDIT CARD NUMBER', response.message end def test_successful_authorize @@ -73,19 +73,19 @@ def test_failed_authorize @gateway.authorize(@amount, @credit_card, @options) end.respond_with(MockedResponse.new(failed_authorize_response)) assert_failure response - assert_equal "INVALID CREDIT CARD NUMBER", response.message + assert_equal 'INVALID CREDIT CARD NUMBER', response.message end def test_successful_capture response = stub_comms(@gateway, :raw_ssl_request) do - @gateway.capture(@amount, "authcode") + @gateway.capture(@amount, 'authcode') end.respond_with(MockedResponse.new(successful_capture_response)) assert_success response end def test_failed_capture response = stub_comms(@gateway, :raw_ssl_request) do - @gateway.capture(@amount, "authcode") + @gateway.capture(@amount, 'authcode') end.respond_with(MockedResponse.new(failed_capture_response)) assert_failure response end @@ -106,14 +106,14 @@ def test_failed_credit def test_successful_void response = stub_comms(@gateway, :raw_ssl_request) do - @gateway.void("authcode") + @gateway.void('authcode') end.respond_with(MockedResponse.new(successful_credit_response)) assert_success response end def test_failed_void response = stub_comms(@gateway, :raw_ssl_request) do - @gateway.void("authcode") + @gateway.void('authcode') end.respond_with(MockedResponse.new(failed_credit_response)) assert_failure response end @@ -141,14 +141,14 @@ def test_failed_verify def test_successful_refund response = stub_comms(@gateway, :raw_ssl_request) do - @gateway.refund(@amount, "authcode") + @gateway.refund(@amount, 'authcode') end.respond_with(MockedResponse.new(successful_refund_response)) assert_success response end def test_failed_refund response = stub_comms(@gateway, :raw_ssl_request) do - @gateway.refund(@amount, "authcode") + @gateway.refund(@amount, 'authcode') end.respond_with(MockedResponse.new(failed_refund_response)) assert_failure response end diff --git a/test/unit/gateways/gateway_test.rb b/test/unit/gateways/gateway_test.rb index a96c3c506c7..3334a916a07 100644 --- a/test/unit/gateways/gateway_test.rb +++ b/test/unit/gateways/gateway_test.rb @@ -29,7 +29,7 @@ def test_should_validate_supported_countries assert_nothing_raised do Gateway.supported_countries = all_country_codes assert Gateway.supported_countries == all_country_codes, - "List of supported countries not properly set" + 'List of supported countries not properly set' end end @@ -54,18 +54,18 @@ def test_amount_style end def test_card_brand - credit_card = stub(:brand => "visa") - assert_equal "visa", Gateway.card_brand(credit_card) + credit_card = stub(:brand => 'visa') + assert_equal 'visa', Gateway.card_brand(credit_card) end def test_card_brand_using_type - credit_card = stub(:type => "String") - assert_equal "string", Gateway.card_brand(credit_card) + credit_card = stub(:type => 'String') + assert_equal 'string', Gateway.card_brand(credit_card) end def test_setting_application_id_outside_the_class_definition assert_equal SimpleTestGateway.application_id, SubclassGateway.application_id - SimpleTestGateway.application_id = "New Application ID" + SimpleTestGateway.application_id = 'New Application ID' assert_equal SimpleTestGateway.application_id, SubclassGateway.application_id end @@ -103,17 +103,17 @@ def test_localized_amount_returns_three_decimal_places_for_three_decimal_currenc end def test_split_names - assert_equal ["Longbob", "Longsen"], @gateway.send(:split_names, "Longbob Longsen") + assert_equal ['Longbob', 'Longsen'], @gateway.send(:split_names, 'Longbob Longsen') end def test_split_names_with_single_name - assert_equal ["", "Prince"], @gateway.send(:split_names, "Prince") + assert_equal ['', 'Prince'], @gateway.send(:split_names, 'Prince') end def test_split_names_with_empty_names - assert_equal [nil, nil], @gateway.send(:split_names, "") + assert_equal [nil, nil], @gateway.send(:split_names, '') assert_equal [nil, nil], @gateway.send(:split_names, nil) - assert_equal [nil, nil], @gateway.send(:split_names, " ") + assert_equal [nil, nil], @gateway.send(:split_names, ' ') end @@ -127,7 +127,7 @@ def test_should_not_allow_scrubbing_if_unsupported refute gateway.supports_scrubbing? assert_raise(RuntimeError) do - gateway.scrub("hi") + gateway.scrub('hi') end end diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb index 6ed57284bd5..d7c9a81801b 100644 --- a/test/unit/gateways/global_collect_test.rb +++ b/test/unit/gateways/global_collect_test.rb @@ -4,9 +4,9 @@ class GlobalCollectTest < Test::Unit::TestCase include CommStub def setup - @gateway = GlobalCollectGateway.new(merchant_id: "1234", - api_key_id: "39u4193urng12", - secret_api_key: "109H/288H*50Y18W4/0G8571F245KA=") + @gateway = GlobalCollectGateway.new(merchant_id: '1234', + api_key_id: '39u4193urng12', + secret_api_key: '109H/288H*50Y18W4/0G8571F245KA=') @credit_card = credit_card('4567350000427977') @declined_card = credit_card('5424180279791732') @@ -24,7 +24,7 @@ def test_successful_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "000000142800000000920000100001", response.authorization + assert_equal '000000142800000000920000100001', response.authorization capture = stub_comms do @gateway.capture(@accepted_amount, response.authorization) @@ -41,7 +41,7 @@ def test_purchase_does_not_run_capture_if_authorize_auto_captured end.respond_with(successful_capture_response) assert_success response - assert_equal "CAPTURE_REQUESTED", response.params["payment"]["status"] + assert_equal 'CAPTURE_REQUESTED', response.params['payment']['status'] assert_equal 1, response.responses.size end @@ -68,12 +68,12 @@ def test_authorize_without_pre_authorization_flag def test_successful_authorization_with_extra_options options = @options.merge( { - order_id: "123", - ip: "127.0.0.1", + order_id: '123', + ip: '127.0.0.1', fraud_fields: { - "website" => "www.example.com", - "giftMessage" => "Happy Day!" + 'website' => 'www.example.com', + 'giftMessage' => 'Happy Day!' } } ) @@ -89,7 +89,7 @@ def test_successful_authorization_with_extra_options end def test_trucates_first_name_to_15_chars - credit_card = credit_card('4567350000427977', { first_name: "thisisaverylongfirstname" }) + credit_card = credit_card('4567350000427977', { first_name: 'thisisaverylongfirstname' }) response = stub_comms do @gateway.authorize(@accepted_amount, credit_card, @options) @@ -98,7 +98,7 @@ def test_trucates_first_name_to_15_chars end.respond_with(successful_authorize_response) assert_success response - assert_equal "000000142800000000920000100001", response.authorization + assert_equal '000000142800000000920000100001', response.authorization end def test_failed_authorize @@ -107,12 +107,12 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Not authorised", response.message + assert_equal 'Not authorised', response.message end def test_failed_capture response = stub_comms do - @gateway.capture(100, "", @options) + @gateway.capture(100, '', @options) end.respond_with(failed_capture_response) assert_failure response @@ -124,7 +124,7 @@ def test_successful_void end.respond_with(successful_capture_response) assert_success response - assert_equal "000000142800000000920000100001", response.authorization + assert_equal '000000142800000000920000100001', response.authorization void = stub_comms do @gateway.void(response.authorization) @@ -137,7 +137,7 @@ def test_successful_void def test_failed_void response = stub_comms do - @gateway.void("5d53a33d960c46d00f5dc061947d998c") + @gateway.void('5d53a33d960c46d00f5dc061947d998c') end.check_request do |endpoint, data, headers| assert_match(/5d53a33d960c46d00f5dc061947d998c/, endpoint) end.respond_with(failed_void_response) @@ -149,7 +149,7 @@ def test_successful_verify response = stub_comms do @gateway.verify(@credit_card, @options) end.respond_with(successful_verify_response) - assert_equal "000000142800000000920000100001", response.authorization + assert_equal '000000142800000000920000100001', response.authorization assert_success response end @@ -158,7 +158,7 @@ def test_failed_verify response = stub_comms do @gateway.verify(@credit_card, @options) end.respond_with(failed_verify_response) - assert_equal "cee09c50-5d9d-41b8-b740-8c7bf06d2c66", response.authorization + assert_equal 'cee09c50-5d9d-41b8-b740-8c7bf06d2c66', response.authorization assert_failure response end @@ -168,7 +168,7 @@ def test_successful_refund @gateway.authorize(@accepted_amount, @credit_card, @options) end.respond_with(successful_authorize_response) - assert_equal "000000142800000000920000100001", response.authorization + assert_equal '000000142800000000920000100001', response.authorization capture = stub_comms do @gateway.capture(@accepted_amount, response.authorization) @@ -193,7 +193,7 @@ def test_refund_passes_currency_code def test_failed_refund response = stub_comms do - @gateway.refund(nil, "") + @gateway.refund(nil, '') end.respond_with(failed_refund_response) assert_failure response @@ -205,8 +205,8 @@ def test_rejected_refund end.respond_with(rejected_refund_response) assert_failure response - assert_equal "1850", response.error_code - assert_equal "Status: REJECTED", response.message + assert_equal '1850', response.error_code + assert_equal 'Status: REJECTED', response.message end def test_scrub diff --git a/test/unit/gateways/global_transport_test.rb b/test/unit/gateways/global_transport_test.rb index bce3e7e4d28..b64fd765323 100644 --- a/test/unit/gateways/global_transport_test.rb +++ b/test/unit/gateways/global_transport_test.rb @@ -5,7 +5,7 @@ class GlobalTransportTest < Test::Unit::TestCase def setup Base.mode = :test - @gateway = GlobalTransportGateway.new(global_user_name: 'login', global_password: 'password', term_type: "ABC") + @gateway = GlobalTransportGateway.new(global_user_name: 'login', global_password: 'password', term_type: 'ABC') @options = { order_id: '1', @@ -20,8 +20,8 @@ def test_successful_purchase assert_success response assert_equal '3648838', response.authorization assert response.test? - assert_equal "CVV matches", response.cvv_result["message"] - assert_equal "Street address and postal code do not match.", response.avs_result["message"] + assert_equal 'CVV matches', response.cvv_result['message'] + assert_equal 'Street address and postal code do not match.', response.avs_result['message'] end def test_failed_purchase @@ -38,8 +38,8 @@ def test_successful_partial_purchase assert_success response assert_equal '8869188', response.authorization assert_equal 'Partial Approval', response.message - assert_equal '3.54', response.params["balance_due"] - assert_equal '20.00', response.params["approved_amount"] + assert_equal '3.54', response.params['balance_due'] + assert_equal '20.00', response.params['approved_amount'] end def test_successful_authorize_and_capture @@ -48,7 +48,7 @@ def test_successful_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "3648890", response.authorization + assert_equal '3648890', response.authorization capture = stub_comms do @gateway.capture(100, response.authorization) @@ -65,8 +65,8 @@ def test_successful_partial_authorize_and_capture end.respond_with(successful_partial_authorize_response) assert_success response - assert_equal "8869269", response.authorization - assert_equal "Partial Approval", response.message + assert_equal '8869269', response.authorization + assert_equal 'Partial Approval', response.message capture = stub_comms do @gateway.capture(150, response.authorization) @@ -86,7 +86,7 @@ def test_failed_authorize def test_failed_capture capture = stub_comms do - @gateway.capture(100, "Authorization") + @gateway.capture(100, 'Authorization') end.respond_with(failed_capture_response) assert_failure capture @@ -99,7 +99,7 @@ def test_successful_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "3648838", response.authorization + assert_equal '3648838', response.authorization refund = stub_comms do @gateway.refund(100, response.authorization) @@ -112,7 +112,7 @@ def test_successful_refund def test_failed_refund refund = stub_comms do - @gateway.refund(100, "PurchaseAuth") + @gateway.refund(100, 'PurchaseAuth') end.respond_with(failed_refund_response) assert_failure refund @@ -136,11 +136,11 @@ def test_successful_void def test_failed_void void = stub_comms do - @gateway.void("PurchaseAuth") + @gateway.void('PurchaseAuth') end.respond_with(failed_void_response) assert_failure void - assert_equal "Invalid PNRef", void.message + assert_equal 'Invalid PNRef', void.message end def test_successful_verify @@ -161,7 +161,7 @@ def test_failed_verify def test_truncation stub_comms do - @gateway.purchase(100, credit_card, order_id: "a" * 17) + @gateway.purchase(100, credit_card, order_id: 'a' * 17) end.check_request do |endpoint, data, headers| assert_match(/&InvNum=a{16}&/, data) end.respond_with(successful_purchase_response) diff --git a/test/unit/gateways/hdfc_test.rb b/test/unit/gateways/hdfc_test.rb index 9efff29568b..9913adedf19 100644 --- a/test/unit/gateways/hdfc_test.rb +++ b/test/unit/gateways/hdfc_test.rb @@ -22,7 +22,7 @@ def test_successful_purchase assert_success response - assert_equal "849768440022761|Longbob Longsen", response.authorization + assert_equal '849768440022761|Longbob Longsen', response.authorization assert response.test? end @@ -32,8 +32,8 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "Invalid Brand.", response.message - assert_equal "GW00160", response.params["error_code_tag"] + assert_equal 'Invalid Brand.', response.message + assert_equal 'GW00160', response.params['error_code_tag'] assert response.test? end @@ -43,7 +43,7 @@ def test_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "2441955352022771|Longbob Longsen", response.authorization + assert_equal '2441955352022771|Longbob Longsen', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -60,7 +60,7 @@ def test_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "849768440022761|Longbob Longsen", response.authorization + assert_equal '849768440022761|Longbob Longsen', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -81,7 +81,7 @@ def test_passing_cvv def test_passing_currency stub_comms do - @gateway.purchase(@amount, @credit_card, :currency => "INR") + @gateway.purchase(@amount, @credit_card, :currency => 'INR') end.check_request do |endpoint, data, headers| assert_match(/currencycode>356</, data) end.respond_with(successful_purchase_response) @@ -89,13 +89,13 @@ def test_passing_currency def test_passing_invalid_currency assert_raise(ArgumentError, 'Unsupported currency for HDFC: AOA') do - @gateway.purchase(@amount, @credit_card, :currency => "AOA") + @gateway.purchase(@amount, @credit_card, :currency => 'AOA') end end def test_passing_order_id stub_comms do - @gateway.purchase(@amount, @credit_card, :order_id => "932823723") + @gateway.purchase(@amount, @credit_card, :order_id => '932823723') end.check_request do |endpoint, data, headers| assert_match(/932823723/, data) end.respond_with(successful_purchase_response) @@ -103,7 +103,7 @@ def test_passing_order_id def test_passing_description stub_comms do - @gateway.purchase(@amount, @credit_card, :description => "Awesome Services By Us") + @gateway.purchase(@amount, @credit_card, :description => 'Awesome Services By Us') end.check_request do |endpoint, data, headers| assert_match(/Awesome Services By Us/, data) end.respond_with(successful_purchase_response) @@ -111,7 +111,7 @@ def test_passing_description def test_escaping stub_comms do - @gateway.purchase(@amount, @credit_card, :order_id => "a" * 41, :description => "This has 'Hack Characters' ~`!\#$%^=+|\\:'\",;<>{}[]() and non-Hack Characters -_@.") + @gateway.purchase(@amount, @credit_card, :order_id => 'a' * 41, :description => "This has 'Hack Characters' ~`!\#$%^=+|\\:'\",;<>{}[]() and non-Hack Characters -_@.") end.check_request do |endpoint, data, headers| assert_match(/>This has Hack Characters and non-Hack Characters -_@.</, data) assert_match(/>#{"a" * 40}</, data) @@ -156,7 +156,7 @@ def test_empty_response_fails end.respond_with(empty_purchase_response) assert_failure response - assert_equal "Unable to read error message", response.message + assert_equal 'Unable to read error message', response.message end def test_handling_bad_xml @@ -178,8 +178,8 @@ def test_handling_bad_xml )) assert_success response - assert_equal "&", response.params["unescaped"] - assert_equal "&\"'<>", response.params["escaped"] + assert_equal '&', response.params['unescaped'] + assert_equal "&\"'<>", response.params['escaped'] end private diff --git a/test/unit/gateways/hps_test.rb b/test/unit/gateways/hps_test.rb index 02112f260f3..f6371b26394 100644 --- a/test/unit/gateways/hps_test.rb +++ b/test/unit/gateways/hps_test.rb @@ -142,8 +142,8 @@ def test_failed_purchase_with_swipe_bad_track_data def test_successful_purchase_with_swipe_encryption_type_01 @gateway.expects(:ssl_post).returns(successful_swipe_purchase_response) - @options[:encryption_type] = "01" - @credit_card.track_data = "&lt;E1052711%B5473501000000014^MC TEST CARD^251200000000000000000000000000000000?|GVEY/MKaKXuqqjKRRueIdCHPPoj1gMccgNOtHC41ymz7bIvyJJVdD3LW8BbwvwoenI+|+++++++C4cI2zjMp|11;5473501000000014=25120000000000000000?|8XqYkQGMdGeiIsgM0pzdCbEGUDP|+++++++C4cI2zjMp|00|||/wECAQECAoFGAgEH2wYcShV78RZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0PX50qfj4dt0lu9oFBESQQNkpoxEVpCW3ZKmoIV3T93zphPS3XKP4+DiVlM8VIOOmAuRrpzxNi0TN/DWXWSjUC8m/PI2dACGdl/hVJ/imfqIs68wYDnp8j0ZfgvM26MlnDbTVRrSx68Nzj2QAgpBCHcaBb/FZm9T7pfMr2Mlh2YcAt6gGG1i2bJgiEJn8IiSDX5M2ybzqRT86PCbKle/XCTwFFe1X|&gt;" + @options[:encryption_type] = '01' + @credit_card.track_data = '&lt;E1052711%B5473501000000014^MC TEST CARD^251200000000000000000000000000000000?|GVEY/MKaKXuqqjKRRueIdCHPPoj1gMccgNOtHC41ymz7bIvyJJVdD3LW8BbwvwoenI+|+++++++C4cI2zjMp|11;5473501000000014=25120000000000000000?|8XqYkQGMdGeiIsgM0pzdCbEGUDP|+++++++C4cI2zjMp|00|||/wECAQECAoFGAgEH2wYcShV78RZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0PX50qfj4dt0lu9oFBESQQNkpoxEVpCW3ZKmoIV3T93zphPS3XKP4+DiVlM8VIOOmAuRrpzxNi0TN/DWXWSjUC8m/PI2dACGdl/hVJ/imfqIs68wYDnp8j0ZfgvM26MlnDbTVRrSx68Nzj2QAgpBCHcaBb/FZm9T7pfMr2Mlh2YcAt6gGG1i2bJgiEJn8IiSDX5M2ybzqRT86PCbKle/XCTwFFe1X|&gt;' response = @gateway.purchase(@amount,@credit_card,@options) assert_success response diff --git a/test/unit/gateways/iats_payments_test.rb b/test/unit/gateways/iats_payments_test.rb index e3aa2aab5a1..0a063e2d2b4 100644 --- a/test/unit/gateways/iats_payments_test.rb +++ b/test/unit/gateways/iats_payments_test.rb @@ -119,7 +119,7 @@ def test_successful_refund def test_successful_check_refund response = stub_comms do - @gateway.refund(@amount, "ref|check", @options) + @gateway.refund(@amount, 'ref|check', @options) end.check_request do |endpoint, data, headers| assert_match(/<ProcessACHEFTRefundWithTransactionIdV1/, data) assert_match(/<agentCode>login<\/agentCode>/, data) @@ -140,7 +140,7 @@ def test_successful_check_refund def test_failed_check_refund response = stub_comms do - @gateway.refund(@amount, "ref|check", @options) + @gateway.refund(@amount, 'ref|check', @options) end.respond_with(failed_check_refund_response) assert response @@ -192,7 +192,7 @@ def test_failed_store def test_successful_unstore response = stub_comms do - @gateway.unstore("TheAuthorization", @options) + @gateway.unstore('TheAuthorization', @options) end.check_request do |endpoint, data, headers| assert_match(%r{<customerCode>TheAuthorization</customerCode>}, data) end.respond_with(successful_unstore_response) diff --git a/test/unit/gateways/inspire_test.rb b/test/unit/gateways/inspire_test.rb index 6ce02c05717..1bb0ea565e8 100644 --- a/test/unit/gateways/inspire_test.rb +++ b/test/unit/gateways/inspire_test.rb @@ -32,7 +32,7 @@ def test_failed_purchase def test_successful_refund response = stub_comms do - @gateway.refund(nil, "identifier") + @gateway.refund(nil, 'identifier') end.check_request do |_, data, _| assert_match %r{identifier}, data assert_no_match %r{amount}, data @@ -42,7 +42,7 @@ def test_successful_refund def test_partial_refund response = stub_comms do - @gateway.refund(100, "identifier") + @gateway.refund(100, 'identifier') end.check_request do |_, data, _| assert_match %r{identifier}, data assert_match %r{amount}, data @@ -52,7 +52,7 @@ def test_partial_refund def test_failed_refund response = stub_comms do - @gateway.refund(nil, "identifier") + @gateway.refund(nil, 'identifier') end.respond_with(failed_refund_response) assert_failure response end @@ -61,7 +61,7 @@ def test_add_address result = {} @gateway.send(:add_address, result, nil, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} ) - assert_equal ["address1", "city", "company", "country", "phone", "state", "zip"], result.stringify_keys.keys.sort + assert_equal ['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] @@ -79,7 +79,7 @@ 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 + assert_equal ['ccexp', 'ccnumber', 'customer_vault', 'cvv', 'firstname', 'lastname'], result.stringify_keys.keys.sort assert_equal 'add_customer', result[:customer_vault] end @@ -87,7 +87,7 @@ 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 ['ccexp', 'ccnumber', 'cvv', 'firstname', 'lastname'], result.stringify_keys.keys.sort assert_nil result[:customer_vault] end @@ -133,11 +133,11 @@ def failed_purchase_response end def successful_refund_response - "response=1&responsetext=SUCCESS&authcode=&transactionid=2594884528&avsresponse=&cvvresponse=&orderid=&type=refund&response_code=100" + 'response=1&responsetext=SUCCESS&authcode=&transactionid=2594884528&avsresponse=&cvvresponse=&orderid=&type=refund&response_code=100' end def failed_refund_response - "response=3&responsetext=Invalid Transaction ID specified REFID:3150951931&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=refund&response_code=300" + 'response=3&responsetext=Invalid Transaction ID specified REFID:3150951931&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=refund&response_code=300' end end diff --git a/test/unit/gateways/instapay_test.rb b/test/unit/gateways/instapay_test.rb index 1e698357c52..2f8af425809 100644 --- a/test/unit/gateways/instapay_test.rb +++ b/test/unit/gateways/instapay_test.rb @@ -13,7 +13,7 @@ def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card) assert_instance_of Response, response assert_success response - assert_equal "118583850", response.authorization + assert_equal '118583850', response.authorization end def test_unsuccessful_purchase @@ -31,7 +31,7 @@ def test_successful_auth assert response = @gateway.authorize(@amount, @credit_card) assert_instance_of Response, response assert_success response - assert_equal "118583850", response.authorization + assert_equal '118583850', response.authorization end def test_unsuccessful_auth @@ -60,15 +60,15 @@ def test_cvv_result def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - response = @gateway.capture(100, "123456") + response = @gateway.capture(100, '123456') assert_equal InstapayGateway::SUCCESS_MESSAGE, response.message end def test_failed_capture @gateway.expects(:ssl_post).returns(failed_capture_response) - response = @gateway.capture(100, "123456") - assert_equal "Post amount exceeds Auth amount", response.message + response = @gateway.capture(100, '123456') + assert_equal 'Post amount exceeds Auth amount', response.message end private diff --git a/test/unit/gateways/ipp_test.rb b/test/unit/gateways/ipp_test.rb index 1c8add40662..f338efad9e8 100644 --- a/test/unit/gateways/ipp_test.rb +++ b/test/unit/gateways/ipp_test.rb @@ -31,7 +31,7 @@ def test_successful_purchase end.respond_with(successful_purchase_response) assert_success response - assert_equal "89435577", response.authorization + assert_equal '89435577', response.authorization end def test_failed_purchase @@ -40,9 +40,9 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "Do Not Honour", response.message + assert_equal 'Do Not Honour', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code - assert_equal "", response.authorization + assert_equal '', response.authorization end def test_successful_authorize @@ -55,12 +55,12 @@ def test_successful_authorize end.respond_with(successful_authorize_response) assert_success response - assert_equal "89435583", response.authorization + assert_equal '89435583', response.authorization end def test_successful_capture response = stub_comms do - @gateway.capture(@amount, "receipt") + @gateway.capture(@amount, 'receipt') end.check_request do |endpoint, data, headers| assert_match(%r{<SubmitSingleCapture }, data) assert_match(%r{<Receipt>receipt<}, data) @@ -72,7 +72,7 @@ def test_successful_capture def test_successful_refund response = stub_comms do - @gateway.refund(@amount, "receipt") + @gateway.refund(@amount, 'receipt') end.check_request do |endpoint, data, headers| assert_match(%r{<SubmitSingleRefund }, data) assert_match(%r{<Receipt>receipt<}, data) diff --git a/test/unit/gateways/iridium_test.rb b/test/unit/gateways/iridium_test.rb index 2c9baab308d..b772f91408e 100644 --- a/test/unit/gateways/iridium_test.rb +++ b/test/unit/gateways/iridium_test.rb @@ -50,7 +50,7 @@ def test_successful_authorize def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - assert response = @gateway.capture(1111, "1;100115172046327701460093;460093") + assert response = @gateway.capture(1111, '1;100115172046327701460093;460093') assert_success response assert_equal('100115172047506301812526', response.authorization) @@ -103,7 +103,7 @@ def test_do_not_depend_on_expiry_date_class def test_use_ducktyping_for_credit_card @gateway.expects(:ssl_post).returns(successful_purchase_response) - credit_card = stub(:number => '4242424242424242', :verification_value => '123', :name => "Hans Tester", :year => 2012, :month => 1) + credit_card = stub(:number => '4242424242424242', :verification_value => '123', :name => 'Hans Tester', :year => 2012, :month => 1) assert_nothing_raised do assert_success @gateway.purchase(@amount, credit_card, @options) diff --git a/test/unit/gateways/iveri_test.rb b/test/unit/gateways/iveri_test.rb index c48b6d60591..1269cd1ee53 100644 --- a/test/unit/gateways/iveri_test.rb +++ b/test/unit/gateways/iveri_test.rb @@ -19,7 +19,7 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "{F0568958-D10B-4093-A3BF-663168B06140}|{5CEF96FD-960E-4EA5-811F-D02CE6E36A96}|48b63446223ce91451fc3c1641a9ec03", response.authorization + assert_equal '{F0568958-D10B-4093-A3BF-663168B06140}|{5CEF96FD-960E-4EA5-811F-D02CE6E36A96}|48b63446223ce91451fc3c1641a9ec03', response.authorization assert response.test? end @@ -36,7 +36,7 @@ def test_successful_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "{B90D7CDB-C8E8-4477-BDF2-695F28137874}|{EF0DC64E-2D00-4B6C-BDA0-2AD265391317}|23b4125c3b8e2777bffee52e196a863b", response.authorization + assert_equal '{B90D7CDB-C8E8-4477-BDF2-695F28137874}|{EF0DC64E-2D00-4B6C-BDA0-2AD265391317}|23b4125c3b8e2777bffee52e196a863b', response.authorization assert response.test? end @@ -53,7 +53,7 @@ def test_successful_capture response = @gateway.capture(@amount, '{B90D7CDB-C8E8-4477-BDF2-695F28137874}|{EF0DC64E-2D00-4B6C-BDA0-2AD265391317}|23b4125c3b8e2777bffee52e196a863b') assert_success response - assert_equal "{7C91245F-607D-44AE-8958-C26E447BAEB7}|{EF0DC64E-2D00-4B6C-BDA0-2AD265391317}|23b4125c3b8e2777bffee52e196a863b", response.authorization + assert_equal '{7C91245F-607D-44AE-8958-C26E447BAEB7}|{EF0DC64E-2D00-4B6C-BDA0-2AD265391317}|23b4125c3b8e2777bffee52e196a863b', response.authorization assert response.test? end @@ -70,7 +70,7 @@ def test_successful_refund response = @gateway.refund(@amount, '{33C8274D-6811-409A-BF86-661F24084A2F}|{D50DB1B4-B6EC-4AF1-AFF7-71C2AA4A957B}|5be2c040bd46b7eebc70274659779acf') assert_success response - assert_equal "{097C55B5-D020-40AD-8949-F9F5E4102F1D}|{D50DB1B4-B6EC-4AF1-AFF7-71C2AA4A957B}|5be2c040bd46b7eebc70274659779acf", response.authorization + assert_equal '{097C55B5-D020-40AD-8949-F9F5E4102F1D}|{D50DB1B4-B6EC-4AF1-AFF7-71C2AA4A957B}|5be2c040bd46b7eebc70274659779acf', response.authorization assert response.test? end @@ -87,7 +87,7 @@ def test_successful_void response = @gateway.void('{230390C8-4A9E-4426-BDD3-15D072F135FE}|{3CC6E6A8-13E0-41A6-AB1E-71BE1AEEAE58}|1435f1a008137cd8508bf43751e07495') assert_success response - assert_equal "{0A1A3FFF-C2A3-4B91-85FD-10D1C25B765B}||", response.authorization + assert_equal '{0A1A3FFF-C2A3-4B91-85FD-10D1C25B765B}||', response.authorization assert response.test? end @@ -104,7 +104,7 @@ def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "{F4337D04-B526-4A7E-A400-2A6DEADDCF57}|{5D5F8BF7-2D9D-42C3-AF32-08C5E62CD45E}|c0006d1d739905afc9e70beaf4194ea3", response.authorization + assert_equal '{F4337D04-B526-4A7E-A400-2A6DEADDCF57}|{5D5F8BF7-2D9D-42C3-AF32-08C5E62CD45E}|c0006d1d739905afc9e70beaf4194ea3', response.authorization assert response.test? end diff --git a/test/unit/gateways/jetpay_test.rb b/test/unit/gateways/jetpay_test.rb index 279c77434e3..aafc7966e83 100644 --- a/test/unit/gateways/jetpay_test.rb +++ b/test/unit/gateways/jetpay_test.rb @@ -28,7 +28,7 @@ def test_successful_purchase assert_success response assert_equal '8afa688fd002821362;TEST97;100;KKLIHOJKKNKKHJKONJHOLHOL', response.authorization - assert_equal('TEST97', response.params["approval"]) + assert_equal('TEST97', response.params['approval']) assert response.test? end @@ -48,18 +48,18 @@ def test_successful_authorize assert_success response assert_equal('cbf902091334a0b1aa;TEST01;100;KKLIHOJKKNKKHJKONOHCLOIO', response.authorization) - assert_equal('TEST01', response.params["approval"]) + assert_equal('TEST01', response.params['approval']) assert response.test? end def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - assert response = @gateway.capture(1111, "010327153017T10018;502F7B;1111") + assert response = @gateway.capture(1111, '010327153017T10018;502F7B;1111') assert_success response assert_equal('010327153017T10018;502F6B;1111;', response.authorization) - assert_equal('502F6B', response.params["approval"]) + assert_equal('502F6B', response.params['approval']) assert response.test? end @@ -70,7 +70,7 @@ def test_successful_void assert_success response assert_equal('010327153x17T10418;502F7B;500;', response.authorization) - assert_equal('502F7B', response.params["approval"]) + assert_equal('502F7B', response.params['approval']) assert response.test? end diff --git a/test/unit/gateways/jetpay_v2_test.rb b/test/unit/gateways/jetpay_v2_test.rb index b1250dbdc55..d135ddc7f0a 100644 --- a/test/unit/gateways/jetpay_v2_test.rb +++ b/test/unit/gateways/jetpay_v2_test.rb @@ -27,7 +27,7 @@ def test_successful_purchase assert_success response assert_equal '8afa688fd002821362;TEST97;100;KKLIHOJKKNKKHJKONJHOLHOL', response.authorization - assert_equal('TEST97', response.params["approval"]) + assert_equal('TEST97', response.params['approval']) assert response.test? end @@ -47,18 +47,18 @@ def test_successful_authorize assert_success response assert_equal('cbf902091334a0b1aa;TEST01;100;KKLIHOJKKNKKHJKONOHCLOIO', response.authorization) - assert_equal('TEST01', response.params["approval"]) + assert_equal('TEST01', response.params['approval']) assert response.test? end def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - assert response = @gateway.capture(1111, "010327153017T10018;502F7B;1111", @options) + assert response = @gateway.capture(1111, '010327153017T10018;502F7B;1111', @options) assert_success response assert_equal('010327153017T10018;502F6B;1111;', response.authorization) - assert_equal('502F6B', response.params["approval"]) + assert_equal('502F6B', response.params['approval']) assert response.test? end @@ -77,7 +77,7 @@ def test_successful_void assert_success response assert_equal('010327153x17T10418;502F7B;500;', response.authorization) - assert_equal('502F7B', response.params["approval"]) + assert_equal('502F7B', response.params['approval']) assert response.test? end diff --git a/test/unit/gateways/komoju_test.rb b/test/unit/gateways/komoju_test.rb index 5ea948308b4..dc67d18686c 100644 --- a/test/unit/gateways/komoju_test.rb +++ b/test/unit/gateways/komoju_test.rb @@ -10,11 +10,11 @@ def setup @options = { :order_id => '1', :description => 'Store Purchase', - :tax => "10", - :ip => "192.168.0.1", - :email => "valid@email.com", - :browser_language => "en", - :browser_user_agent => "user_agent" + :tax => '10', + :ip => '192.168.0.1', + :email => 'valid@email.com', + :browser_language => 'en', + :browser_user_agent => 'user_agent' } end @@ -25,7 +25,7 @@ def test_successful_credit_card_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal successful_response["id"], response.authorization + assert_equal successful_response['id'], response.authorization assert response.test? end @@ -38,7 +38,7 @@ def test_failed_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "missing_parameter", response.error_code + assert_equal 'missing_parameter', response.error_code assert response.test? end @@ -51,7 +51,7 @@ def test_detected_fraud response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "fraudulent", response.error_code + assert_equal 'fraudulent', response.error_code assert response.test? end @@ -59,10 +59,10 @@ def test_successful_credit_card_refund successful_response = successful_credit_card_refund_response @gateway.expects(:ssl_post).returns(JSON.generate(successful_response)) - response = @gateway.refund(@amount, "7e8c55a54256ce23e387f2838c", @options) + response = @gateway.refund(@amount, '7e8c55a54256ce23e387f2838c', @options) assert_success response - assert_equal successful_response["id"], response.authorization + assert_equal successful_response['id'], response.authorization assert response.test? end @@ -70,76 +70,76 @@ def test_successful_credit_card_refund def successful_credit_card_purchase_response { - "id" => "7e8c55a54256ce23e387f2838c", - "resource" => "payment", - "status" => "captured", - "amount" => 100, - "tax" => 8, - "payment_deadline" => nil, - "payment_details" => { - "type" => "credit_card", - "brand" => "visa", - "last_four_digits" => "2220", - "month" => 9, - "year" => 2016 + 'id' => '7e8c55a54256ce23e387f2838c', + 'resource' => 'payment', + 'status' => 'captured', + 'amount' => 100, + 'tax' => 8, + 'payment_deadline' => nil, + 'payment_details' => { + 'type' => 'credit_card', + 'brand' => 'visa', + 'last_four_digits' => '2220', + 'month' => 9, + 'year' => 2016 }, - "payment_method_fee" => 0, - "total" => 108, - "currency" => "JPY", - "description" => "Store Purchase", - "subscription" => nil, - "captured_at" => "2015-03-20T04:51:48Z", - "metadata" => { - "order_id" => "262f2a92-542c-4b4e-a68b-5b6d54a438a8" + 'payment_method_fee' => 0, + 'total' => 108, + 'currency' => 'JPY', + 'description' => 'Store Purchase', + 'subscription' => nil, + 'captured_at' => '2015-03-20T04:51:48Z', + 'metadata' => { + 'order_id' => '262f2a92-542c-4b4e-a68b-5b6d54a438a8' }, - "created_at" => "2015-03-20T04:51:48Z" + 'created_at' => '2015-03-20T04:51:48Z' } end def successful_credit_card_refund_response { - "id" => "7e8c55a54256ce23e387f2838c", - "resource" => "payment", - "status" => "refunded", - "amount" => 100, - "tax" => 8, - "payment_deadline" => nil, - "payment_details" => { - "type" => "credit_card", - "brand" => "visa", - "last_four_digits" => "2220", - "month" => 9, - "year" => 2016 + 'id' => '7e8c55a54256ce23e387f2838c', + 'resource' => 'payment', + 'status' => 'refunded', + 'amount' => 100, + 'tax' => 8, + 'payment_deadline' => nil, + 'payment_details' => { + 'type' => 'credit_card', + 'brand' => 'visa', + 'last_four_digits' => '2220', + 'month' => 9, + 'year' => 2016 }, - "payment_method_fee" => 0, - "total" => 108, - "currency" => "JPY", - "description" => "Store Purchase", - "subscription" => nil, - "captured_at" => nil, - "metadata" => { - "order_id" => "262f2a92-542c-4b4e-a68b-5b6d54a438a8" + 'payment_method_fee' => 0, + 'total' => 108, + 'currency' => 'JPY', + 'description' => 'Store Purchase', + 'subscription' => nil, + 'captured_at' => nil, + 'metadata' => { + 'order_id' => '262f2a92-542c-4b4e-a68b-5b6d54a438a8' }, - "created_at" => "2015-03-20T04:51:48Z" + 'created_at' => '2015-03-20T04:51:48Z' } end def failed_purchase_response { - "error" => { - "code" => "missing_parameter", - "message" => "A required parameter (currency) is missing", - "param" => "currency" + 'error' => { + 'code' => 'missing_parameter', + 'message' => 'A required parameter (currency) is missing', + 'param' => 'currency' } } end def detected_fraud_response { - "error" => { - "code" => "fraudulent", - "message" => "The payment could not be completed.", - "param" => nil + 'error' => { + 'code' => 'fraudulent', + 'message' => 'The payment could not be completed.', + 'param' => nil } } end diff --git a/test/unit/gateways/kushki_test.rb b/test/unit/gateways/kushki_test.rb index c1fb7ded9c0..4020f3cbf6f 100644 --- a/test/unit/gateways/kushki_test.rb +++ b/test/unit/gateways/kushki_test.rb @@ -22,12 +22,12 @@ def test_successful_purchase def test_successful_purchase_with_options options = { - currency: "USD", + currency: 'USD', amount: { - subtotal_iva_0: "4.95", - subtotal_iva: "10", - iva: "1.54", - ice: "3.50" + subtotal_iva_0: '4.95', + subtotal_iva: '10', + iva: '1.54', + ice: '3.50' } } @@ -50,12 +50,12 @@ def test_successful_purchase_with_options def test_taxes_are_excluded_when_not_provided options = { - currency: "COP", + currency: 'COP', amount: { - subtotal_iva_0: "4.95", - subtotal_iva: "10", - iva: "1.54", - ice: "3.50" + subtotal_iva_0: '4.95', + subtotal_iva: '10', + iva: '1.54', + ice: '3.50' } } @@ -79,12 +79,12 @@ def test_taxes_are_excluded_when_not_provided def test_partial_taxes_do_not_error options = { - currency: "COP", + currency: 'COP', amount: { - subtotal_iva_0: "4.95", - subtotal_iva: "10", - iva: "1.54", - ice: "3.50", + subtotal_iva_0: '4.95', + subtotal_iva: '10', + iva: '1.54', + ice: '3.50', extra_taxes: { tasa_aeroportuaria: 0.2, iac: 0.4 @@ -114,12 +114,12 @@ def test_partial_taxes_do_not_error def test_taxes_are_included_when_provided options = { - currency: "COP", + currency: 'COP', amount: { - subtotal_iva_0: "4.95", - subtotal_iva: "10", - iva: "1.54", - ice: "3.50", + subtotal_iva_0: '4.95', + subtotal_iva: '10', + iva: '1.54', + ice: '3.50', extra_taxes: { propina: 0.1, tasa_aeroportuaria: 0.2, @@ -151,7 +151,7 @@ def test_taxes_are_included_when_provided def test_failed_purchase options = { amount: { - subtotal_iva: "200" + subtotal_iva: '200' } } @@ -210,7 +210,7 @@ def test_successful_void def test_failed_void @gateway.expects(:ssl_request).returns(failed_void_response) - response = @gateway.void("000") + response = @gateway.void('000') assert_failure response assert_equal 'Tipo de moneda no válida', response.message assert_equal '205', response.error_code diff --git a/test/unit/gateways/latitude19_test.rb b/test/unit/gateways/latitude19_test.rb index 0af67308a86..75f7b75cba8 100644 --- a/test/unit/gateways/latitude19_test.rb +++ b/test/unit/gateways/latitude19_test.rb @@ -5,8 +5,8 @@ def setup @gateway = Latitude19Gateway.new(fixtures(:latitude19)) @amount = 100 - @credit_card = credit_card("4000100011112224", verification_value: "747") - @declined_card = credit_card("0000000000000000") + @credit_card = credit_card('4000100011112224', verification_value: '747') + @declined_card = credit_card('0000000000000000') @options = { order_id: generate_unique_id, @@ -21,7 +21,7 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert response.test? end @@ -35,14 +35,14 @@ def test_successful_authorize_and_capture response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_match %r(^auth\|\w+$), response.authorization @gateway.expects(:ssl_post).returns(successful_capture_response) capture = @gateway.capture(@amount, response.authorization, @options) assert_success capture - assert_equal "Approved", capture.message + assert_equal 'Approved', capture.message end # def test_failed_authorize @@ -51,11 +51,11 @@ def test_successful_authorize_and_capture def test_failed_capture @gateway.expects(:ssl_post).returns(failed_capture_response) - authorization = "auth" + "|" + SecureRandom.hex(6) + authorization = 'auth' + '|' + SecureRandom.hex(6) response = @gateway.capture(@amount, authorization, @options) assert_failure response - assert_equal "Not submitted", response.message - assert_equal "400", response.error_code + assert_equal 'Not submitted', response.message + assert_equal '400', response.error_code end def test_successful_void @@ -70,7 +70,7 @@ def test_successful_void void = @gateway.void(auth.authorization, @options) assert_success void - assert_equal "Approved", void.message + assert_equal 'Approved', void.message # response = @gateway.authorize(@amount, @credit_card, @options) # assert_success response @@ -95,7 +95,7 @@ def test_successful_void void = @gateway.void(purchase.authorization, @options) assert_success void - assert_equal "Approved", void.message + assert_equal 'Approved', void.message end def test_failed_void @@ -108,12 +108,12 @@ def test_failed_void @gateway.expects(:ssl_post).returns(failed_reversal_response) - authorization = auth.authorization[0..9] + "XX" + authorization = auth.authorization[0..9] + 'XX' response = @gateway.void(authorization, @options) assert_failure response - assert_equal "Not submitted", response.message - assert_equal "400", response.error_code + assert_equal 'Not submitted', response.message + assert_equal '400', response.error_code end def test_successful_credit @@ -123,7 +123,7 @@ def test_successful_credit response = @gateway.credit(@amount, @credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end # def test_failed_credit @@ -136,7 +136,7 @@ def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end # def test_failed_verify @@ -149,13 +149,13 @@ def test_successful_store_and_purchase store = @gateway.store(@credit_card, @options) assert_success store - assert_equal "Approved", store.message + assert_equal 'Approved', store.message @gateway.expects(:ssl_post).returns(successful_purchase_response) purchase = @gateway.purchase(@amount, store.authorization, @options) assert_success purchase - assert_equal "Approved", purchase.message + assert_equal 'Approved', purchase.message end def test_scrub diff --git a/test/unit/gateways/linkpoint_test.rb b/test/unit/gateways/linkpoint_test.rb index 48312215e0a..71d5e683317 100644 --- a/test/unit/gateways/linkpoint_test.rb +++ b/test/unit/gateways/linkpoint_test.rb @@ -39,7 +39,7 @@ def test_successful_authorization def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - assert response = @gateway.capture(@amount, "token", @options) + assert response = @gateway.capture(@amount, 'token', @options) assert_instance_of Response, response assert_success response assert_equal '1000', response.authorization @@ -65,7 +65,7 @@ def test_recurring @gateway.expects(:ssl_post).returns(successful_recurring_response) response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do - @gateway.recurring(2400, @credit_card, :order_id => 1003, :installments => 12, :startdate => "immediate", :periodicity => :monthly) + @gateway.recurring(2400, @credit_card, :order_id => 1003, :installments => 12, :startdate => 'immediate', :periodicity => :monthly) end assert_success response end @@ -79,7 +79,7 @@ def test_amount_style end def test_purchase_is_valid_xml - @gateway.send(:parameters, 1000, @credit_card, :ordertype => "SALE", :order_id => 1004, + @gateway.send(:parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1004, :billing_address => { :address1 => '1313 lucky lane', :city => 'Lost Angeles', @@ -93,7 +93,7 @@ def test_purchase_is_valid_xml end def test_recurring_is_valid_xml - @gateway.send(:parameters, 1000, @credit_card, :ordertype => "SALE", :action => "SUBMIT", :installments => 12, :startdate => "immediate", :periodicity => "monthly", :order_id => 1006, + @gateway.send(:parameters, 1000, @credit_card, :ordertype => 'SALE', :action => 'SUBMIT', :installments => 12, :startdate => 'immediate', :periodicity => 'monthly', :order_id => 1006, :billing_address => { :address1 => '1313 lucky lane', :city => 'Lost Angeles', @@ -106,16 +106,16 @@ def test_recurring_is_valid_xml end def test_line_items_are_valid_xml - options = {:ordertype => "SALE", :action => "SUBMIT", :installments => 12, :startdate => "immediate", :periodicity => "monthly", :order_id => 1006, + options = {:ordertype => 'SALE', :action => 'SUBMIT', :installments => 12, :startdate => 'immediate', :periodicity => 'monthly', :order_id => 1006, :billing_address => { :address1 => '1313 lucky lane', :city => 'Lost Angeles', :state => 'CA', :zip => '90210' }, - :line_items => [{:id => '123456', :description => "Logo T-Shirt", :price => - "12.00", :quantity => '1', :options => [{:name => "Color", :value => - "Red"}, {:name => "Size", :value => "XL"}]},{:id => '111', :description => "keychain", :price => "3.00", :quantity => '1'}]} + :line_items => [{:id => '123456', :description => 'Logo T-Shirt', :price => + '12.00', :quantity => '1', :options => [{:name => 'Color', :value => + 'Red'}, {:name => 'Size', :value => 'XL'}]},{:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'}]} assert data = @gateway.send(:post_data, @amount, @credit_card, options) @@ -125,7 +125,7 @@ def test_line_items_are_valid_xml def test_declined_purchase_is_valid_xml @gateway = LinkpointGateway.new(:login => 123123, :pem => 'PEM') - @gateway.send(:parameters, 1000, @credit_card, :ordertype => "SALE", :order_id => 1005, + @gateway.send(:parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1005, :billing_address => { :address1 => '1313 lucky lane', :city => 'Lost Angeles', diff --git a/test/unit/gateways/litle_test.rb b/test/unit/gateways/litle_test.rb index 0687e48ea35..59cd7af5969 100644 --- a/test/unit/gateways/litle_test.rb +++ b/test/unit/gateways/litle_test.rb @@ -17,18 +17,18 @@ def setup { month: '01', year: '2012', - brand: "visa", - number: "44444444400009", - payment_cryptogram: "BwABBJQ1AgAAAAAgJDUCAAAAAAA=" + brand: 'visa', + number: '44444444400009', + payment_cryptogram: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=' }) @decrypted_android_pay = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new( { source: :android_pay, month: '01', year: '2021', - brand: "visa", - number: "4457000300000007", - payment_cryptogram: "BwABBJQ1AgAAAAAgJDUCAAAAAAA=" + brand: 'visa', + number: '4457000300000007', + payment_cryptogram: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=' }) @amount = 100 @options = {} @@ -53,7 +53,7 @@ def test_successful_purchase assert_success response - assert_equal "100000000000000006;sale;100", response.authorization + assert_equal '100000000000000006;sale;100', response.authorization assert response.test? end @@ -64,7 +64,7 @@ def test_successful_purchase_with_echeck assert_success response - assert_equal "621100411297330000;echeckSales;2004", response.authorization + assert_equal '621100411297330000;echeckSales;2004', response.authorization assert response.test? end @@ -74,8 +74,8 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "Insufficient Funds", response.message - assert_equal "110", response.params["response"] + assert_equal 'Insufficient Funds', response.message + assert_equal '110', response.params['response'] assert response.test? end @@ -104,7 +104,7 @@ def test_passing_name_on_card def test_passing_order_id stub_comms do - @gateway.purchase(@amount, @credit_card, order_id: "774488") + @gateway.purchase(@amount, @credit_card, order_id: '774488') end.check_request do |endpoint, data, headers| assert_match(/774488/, data) end.respond_with(successful_purchase_response) @@ -129,7 +129,7 @@ def test_passing_shipping_address def test_passing_descriptor stub_comms do @gateway.authorize(@amount, @credit_card, { - descriptor_name: "Name", descriptor_phone: "Phone" + descriptor_name: 'Name', descriptor_phone: 'Phone' }) end.check_request do |endpoint, data, headers| assert_match(%r(<customBilling>.*<descriptor>Name<)m, data) @@ -157,7 +157,7 @@ def test_add_applepay_order_source stub_comms do @gateway.purchase(@amount, @decrypted_apple_pay) end.check_request do |endpoint, data, headers| - assert_match "<orderSource>applepay</orderSource>", data + assert_match '<orderSource>applepay</orderSource>', data end.respond_with(successful_purchase_response) end @@ -165,7 +165,7 @@ def test_add_android_pay_order_source stub_comms do @gateway.purchase(@amount, @decrypted_android_pay) end.check_request do |endpoint, data, headers| - assert_match "<orderSource>androidpay</orderSource>", data + assert_match '<orderSource>androidpay</orderSource>', data end.respond_with(successful_purchase_response) end @@ -176,7 +176,7 @@ def test_successful_authorize_and_capture assert_success response - assert_equal "100000000000000001;authorization;100", response.authorization + assert_equal '100000000000000001;authorization;100', response.authorization assert response.test? capture = stub_comms do @@ -194,8 +194,8 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Insufficient Funds", response.message - assert_equal "110", response.params["response"] + assert_equal 'Insufficient Funds', response.message + assert_equal '110', response.params['response'] end def test_failed_capture @@ -204,8 +204,8 @@ def test_failed_capture end.respond_with(failed_capture_response) assert_failure response - assert_equal "No transaction found with specified litleTxnId", response.message - assert_equal "360", response.params["response"] + assert_equal 'No transaction found with specified litleTxnId', response.message + assert_equal '360', response.params['response'] end def test_successful_refund @@ -213,7 +213,7 @@ def test_successful_refund @gateway.purchase(@amount, @credit_card) end.respond_with(successful_purchase_response) - assert_equal "100000000000000006;sale;100", response.authorization + assert_equal '100000000000000006;sale;100', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -226,12 +226,12 @@ def test_successful_refund def test_failed_refund response = stub_comms do - @gateway.refund(@amount, "SomeAuthorization") + @gateway.refund(@amount, 'SomeAuthorization') end.respond_with(failed_refund_response) assert_failure response - assert_equal "No transaction found with specified litleTxnId", response.message - assert_equal "360", response.params["response"] + assert_equal 'No transaction found with specified litleTxnId', response.message + assert_equal '360', response.params['response'] end def test_successful_void_of_authorization @@ -240,7 +240,7 @@ def test_successful_void_of_authorization end.respond_with(successful_authorize_response) assert_success response - assert_equal "100000000000000001;authorization;100", response.authorization + assert_equal '100000000000000001;authorization;100', response.authorization void = stub_comms do @gateway.void(response.authorization) @@ -253,10 +253,10 @@ def test_successful_void_of_authorization def test_successful_void_of_other_things refund = stub_comms do - @gateway.refund(@amount, "SomeAuthorization") + @gateway.refund(@amount, 'SomeAuthorization') end.respond_with(successful_refund_response) - assert_equal "100000000000000003;credit;", refund.authorization + assert_equal '100000000000000003;credit;', refund.authorization void = stub_comms do @gateway.void(refund.authorization) @@ -269,31 +269,31 @@ def test_successful_void_of_other_things def test_failed_void_of_authorization response = stub_comms do - @gateway.void("123456789012345360;authorization;100") + @gateway.void('123456789012345360;authorization;100') end.respond_with(failed_void_of_authorization_response) assert_failure response - assert_equal "No transaction found with specified litleTxnId", response.message - assert_equal "360", response.params["response"] + assert_equal 'No transaction found with specified litleTxnId', response.message + assert_equal '360', response.params['response'] end def test_failed_void_of_other_things response = stub_comms do - @gateway.void("123456789012345360;credit;100") + @gateway.void('123456789012345360;credit;100') end.respond_with(failed_void_of_other_things_response) assert_failure response - assert_equal "No transaction found with specified litleTxnId", response.message - assert_equal "360", response.params["response"] + assert_equal 'No transaction found with specified litleTxnId', response.message + assert_equal '360', response.params['response'] end def test_successful_void_of_echeck response = stub_comms do - @gateway.void("945032206979933000;echeckSales;2004") + @gateway.void('945032206979933000;echeckSales;2004') end.respond_with(successful_void_of_echeck_response) assert_success response - assert_equal "986272331806746000;echeckVoid;", response.authorization + assert_equal '986272331806746000;echeckVoid;', response.authorization end def test_successful_store @@ -304,16 +304,16 @@ def test_successful_store end.respond_with(successful_store_response) assert_success response - assert_equal "1111222233330123", response.authorization + assert_equal '1111222233330123', response.authorization end def test_successful_store_with_paypage_registration_id response = stub_comms do - @gateway.store("cDZJcmd1VjNlYXNaSlRMTGpocVZQY1NNlYE4ZW5UTko4NU9KK3p1L1p1VzE4ZWVPQVlSUHNITG1JN2I0NzlyTg=") + @gateway.store('cDZJcmd1VjNlYXNaSlRMTGpocVZQY1NNlYE4ZW5UTko4NU9KK3p1L1p1VzE4ZWVPQVlSUHNITG1JN2I0NzlyTg=') end.respond_with(successful_store_paypage_response) assert_success response - assert_equal "1111222233334444", response.authorization + assert_equal '1111222233334444', response.authorization end def test_failed_store @@ -322,8 +322,8 @@ def test_failed_store end.respond_with(failed_store_response) assert_failure response - assert_equal "Credit card number was invalid", response.message - assert_equal "820", response.params["response"] + assert_equal 'Credit card number was invalid', response.message + assert_equal '820', response.params['response'] end def test_successful_verify @@ -338,7 +338,7 @@ def test_successful_verify_failed_void @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, failed_void_of_authorization_response) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_unsuccessful_verify @@ -346,17 +346,17 @@ def test_unsuccessful_verify @gateway.verify(@credit_card, @options) end.respond_with(failed_authorize_response, successful_void_of_auth_response) assert_failure response - assert_equal "Insufficient Funds", response.message + assert_equal 'Insufficient Funds', response.message end def test_add_swipe_data_with_creditcard - @credit_card.track_data = "Track Data" + @credit_card.track_data = 'Track Data' stub_comms do @gateway.purchase(@amount, @credit_card) end.check_request do |endpoint, data, headers| - assert_match "<track>Track Data</track>", data - assert_match "<orderSource>retail</orderSource>", data + assert_match '<track>Track Data</track>', data + assert_match '<orderSource>retail</orderSource>', data assert_match %r{<pos>.+<\/pos>}m, data end.respond_with(successful_purchase_response) end @@ -365,16 +365,16 @@ def test_order_source_with_creditcard_no_track_data stub_comms do @gateway.purchase(@amount, @credit_card) end.check_request do |endpoint, data, headers| - assert_match "<orderSource>ecommerce</orderSource>", data + assert_match '<orderSource>ecommerce</orderSource>', data assert %r{<pos>.+<\/pos>}m !~ data end.respond_with(successful_purchase_response) end def test_order_source_override stub_comms do - @gateway.purchase(@amount, @credit_card, order_source: "recurring") + @gateway.purchase(@amount, @credit_card, order_source: 'recurring') end.check_request do |endpoint, data, headers| - assert_match "<orderSource>recurring</orderSource>", data + assert_match '<orderSource>recurring</orderSource>', data end.respond_with(successful_purchase_response) end @@ -385,7 +385,7 @@ def test_unsuccessful_xml_schema_validation assert_failure response assert_match(/^Error validating xml data against the schema/, response.message) - assert_equal "1", response.params["response"] + assert_equal '1', response.params['response'] end def test_scrub diff --git a/test/unit/gateways/maxipago_test.rb b/test/unit/gateways/maxipago_test.rb index dce65d37260..04215332445 100644 --- a/test/unit/gateways/maxipago_test.rb +++ b/test/unit/gateways/maxipago_test.rb @@ -54,14 +54,14 @@ def test_failed_authorize def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - response = @gateway.capture(nil, "authorization", @options) + response = @gateway.capture(nil, 'authorization', @options) assert_success response end def test_failed_capture @gateway.expects(:ssl_post).returns(failed_capture_response) - response = @gateway.capture(nil, "bogus", @options) + response = @gateway.capture(nil, 'bogus', @options) assert_failure response end @@ -73,15 +73,15 @@ def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) void = @gateway.void(auth.authorization) assert_success void - assert_equal "VOIDED", void.params["response_message"] + assert_equal 'VOIDED', void.params['response_message'] end def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) - response = @gateway.void("NOAUTH|0000000") + response = @gateway.void('NOAUTH|0000000') assert_failure response - assert_equal "Unable to validate, original void transaction not found", response.message + assert_equal 'Unable to validate, original void transaction not found', response.message end def test_successful_refund @@ -92,7 +92,7 @@ def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) refund = @gateway.refund(@amount, purchase.authorization, @options) assert_success refund - assert_equal "CAPTURED", refund.message + assert_equal 'CAPTURED', refund.message end def test_failed_refund @@ -104,21 +104,21 @@ def test_failed_refund refund_amount = @amount + 10 refund = @gateway.refund(refund_amount, purchase.authorization, @options) assert_failure refund - assert_equal "The Return amount is greater than the amount that can be returned.", refund.message + assert_equal 'The Return amount is greater than the amount that can be returned.', refund.message end def test_successful_verify @gateway.expects(:ssl_post).times(2).returns(successful_authorize_response).then.returns(successful_void_response) response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "AUTHORIZED", response.message + assert_equal 'AUTHORIZED', response.message end def test_failed_verify @gateway.expects(:ssl_post).returns(failed_authorize_response) response = @gateway.verify(@credit_card, @options) assert_failure response - assert_equal "The transaction has an expired credit card.", response.message + assert_equal 'The transaction has an expired credit card.', response.message end def test_scrub diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb index aaf93e99361..1f6d043b612 100644 --- a/test/unit/gateways/mercado_pago_test.rb +++ b/test/unit/gateways/mercado_pago_test.rb @@ -21,8 +21,8 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "4141491|1.0", response.authorization - assert_equal "accredited", response.message + assert_equal '4141491|1.0', response.authorization + assert_equal 'accredited', response.message assert response.test? end @@ -31,8 +31,8 @@ def test_failed_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "rejected", response.error_code - assert_equal "cc_rejected_other_reason", response.message + assert_equal 'rejected', response.error_code + assert_equal 'cc_rejected_other_reason', response.message end def test_successful_authorize @@ -41,8 +41,8 @@ def test_successful_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "4261941|1.0", response.authorization - assert_equal "pending_capture", response.message + assert_equal '4261941|1.0', response.authorization + assert_equal 'pending_capture', response.message assert response.test? end @@ -51,29 +51,29 @@ def test_failed_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response - assert_equal "rejected", response.error_code - assert_equal "cc_rejected_other_reason", response.message + assert_equal 'rejected', response.error_code + assert_equal 'cc_rejected_other_reason', response.message end def test_successful_capture @gateway.expects(:ssl_request).returns(successful_capture_response) - response = @gateway.capture(@amount, "authorization|amount") + response = @gateway.capture(@amount, 'authorization|amount') assert_success response - assert_equal "4261941|1.0", response.authorization - assert_equal "accredited", response.message + assert_equal '4261941|1.0', response.authorization + assert_equal 'accredited', response.message assert response.test? end def test_failed_capture @gateway.expects(:ssl_request).returns(failed_capture_response) - response = @gateway.capture(@amount, "") + response = @gateway.capture(@amount, '') assert_failure response - assert_equal "|1.0", response.authorization - assert_equal "Method not allowed", response.message + assert_equal '|1.0', response.authorization + assert_equal 'Method not allowed', response.message assert response.test? end @@ -95,22 +95,22 @@ def test_failed_refund def test_successful_void @gateway.expects(:ssl_request).returns(successful_void_response) - response = @gateway.void("authorization|amount") + response = @gateway.void('authorization|amount') assert_success response - assert_equal "4261966|", response.authorization - assert_equal "by_collector", response.message + assert_equal '4261966|', response.authorization + assert_equal 'by_collector', response.message assert response.test? end def test_failed_void @gateway.expects(:ssl_request).returns(failed_void_response) - response = @gateway.void("") + response = @gateway.void('') assert_failure response - assert_equal "|", response.authorization - assert_equal "Method not allowed", response.message + assert_equal '|', response.authorization + assert_equal 'Method not allowed', response.message assert response.test? end @@ -120,7 +120,7 @@ def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "by_collector", response.message + assert_equal 'by_collector', response.message assert response.test? end @@ -130,7 +130,7 @@ def test_successful_verify_with_failed_void response = @gateway.verify(@credit_card, @options) assert_failure response - assert_equal "Method not allowed", response.message + assert_equal 'Method not allowed', response.message assert response.test? end @@ -140,7 +140,7 @@ def test_failed_verify response = @gateway.verify(@credit_card, @options) assert_failure response - assert_equal "cc_rejected_other_reason", response.message + assert_equal 'cc_rejected_other_reason', response.message assert response.test? end diff --git a/test/unit/gateways/merchant_e_solutions_test.rb b/test/unit/gateways/merchant_e_solutions_test.rb index a2bfa44a318..26b932d25a0 100644 --- a/test/unit/gateways/merchant_e_solutions_test.rb +++ b/test/unit/gateways/merchant_e_solutions_test.rb @@ -38,11 +38,11 @@ def test_unsuccessful_purchase end def test_purchase_with_long_order_id_truncates_id - options = {order_id: "thisislongerthan17characters"} + options = {order_id: 'thisislongerthan17characters'} @gateway.expects(:ssl_post).with( anything, all_of( - includes("invoice_number=thisislongerthan1"), + includes('invoice_number=thisislongerthan1'), ) ).returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, options) @@ -103,42 +103,42 @@ def test_unstore def test_successful_avs_check @gateway.expects(:ssl_post).returns(successful_purchase_response + '&avs_result=Y') assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal response.avs_result['code'], "Y" - assert_equal response.avs_result['message'], "Street address and 5-digit postal code match." - assert_equal response.avs_result['street_match'], "Y" - assert_equal response.avs_result['postal_match'], "Y" + assert_equal response.avs_result['code'], 'Y' + assert_equal response.avs_result['message'], 'Street address and 5-digit postal code match.' + assert_equal response.avs_result['street_match'], 'Y' + assert_equal response.avs_result['postal_match'], 'Y' end def test_unsuccessful_avs_check_with_bad_street_address @gateway.expects(:ssl_post).returns(successful_purchase_response + '&avs_result=Z') assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal response.avs_result['code'], "Z" - assert_equal response.avs_result['message'], "Street address does not match, but 5-digit postal code matches." - assert_equal response.avs_result['street_match'], "N" - assert_equal response.avs_result['postal_match'], "Y" + assert_equal response.avs_result['code'], 'Z' + assert_equal response.avs_result['message'], 'Street address does not match, but 5-digit postal code matches.' + assert_equal response.avs_result['street_match'], 'N' + assert_equal response.avs_result['postal_match'], 'Y' end def test_unsuccessful_avs_check_with_bad_zip @gateway.expects(:ssl_post).returns(successful_purchase_response + '&avs_result=A') assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal response.avs_result['code'], "A" - assert_equal response.avs_result['message'], "Street address matches, but 5-digit and 9-digit postal code do not match." - assert_equal response.avs_result['street_match'], "Y" - assert_equal response.avs_result['postal_match'], "N" + assert_equal response.avs_result['code'], 'A' + assert_equal response.avs_result['message'], 'Street address matches, but 5-digit and 9-digit postal code do not match.' + assert_equal response.avs_result['street_match'], 'Y' + assert_equal response.avs_result['postal_match'], 'N' end def test_successful_cvv_check @gateway.expects(:ssl_post).returns(successful_purchase_response + '&cvv2_result=M') assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal response.cvv_result['code'], "M" - assert_equal response.cvv_result['message'], "CVV matches" + assert_equal response.cvv_result['code'], 'M' + assert_equal response.cvv_result['message'], 'CVV matches' end def test_unsuccessful_cvv_check @gateway.expects(:ssl_post).returns(failed_purchase_response + '&cvv2_result=N') assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal response.cvv_result['code'], "N" - assert_equal response.cvv_result['message'], "CVV does not match" + assert_equal response.cvv_result['code'], 'N' + assert_equal response.cvv_result['message'], 'CVV does not match' end def test_visa_3dsecure_params_submitted diff --git a/test/unit/gateways/merchant_one_test.rb b/test/unit/gateways/merchant_one_test.rb index 839fc8ff8c5..16e3b879473 100644 --- a/test/unit/gateways/merchant_one_test.rb +++ b/test/unit/gateways/merchant_one_test.rb @@ -27,7 +27,7 @@ def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response assert_success response - assert_equal "281719471", response.authorization + assert_equal '281719471', response.authorization assert response.test?, response.test.to_s end @@ -60,10 +60,10 @@ def test_unsuccessful_request private def successful_purchase_response - "response=1&responsetext=SUCCESS&authcode=123456&transactionid=281719471&avsresponse=&cvvresponse=M&orderid=&type=sale&response_code=100" + 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=281719471&avsresponse=&cvvresponse=M&orderid=&type=sale&response_code=100' end def failed_purchase_response - "response=3&responsetext=DECLINE&authcode=123456&transactionid=281719471&avsresponse=&cvvresponse=M&orderid=&type=sale&response_code=300" + 'response=3&responsetext=DECLINE&authcode=123456&transactionid=281719471&avsresponse=&cvvresponse=M&orderid=&type=sale&response_code=300' end end diff --git a/test/unit/gateways/merchant_partners_test.rb b/test/unit/gateways/merchant_partners_test.rb index f1e48b964ba..77930e9830d 100644 --- a/test/unit/gateways/merchant_partners_test.rb +++ b/test/unit/gateways/merchant_partners_test.rb @@ -1,19 +1,19 @@ -require "test_helper" -require "nokogiri" +require 'test_helper' +require 'nokogiri' class MerchantPartnersTest < Test::Unit::TestCase include CommStub def setup @gateway = MerchantPartnersGateway.new( - account_id: "TEST0", - merchant_pin: "1234567890" + account_id: 'TEST0', + merchant_pin: '1234567890' ) @credit_card = credit_card @amount = 100 - @request_root = "/interface_driver/trans_catalog/transaction/inputs" + @request_root = '/interface_driver/trans_catalog/transaction/inputs' end def test_successful_purchase @@ -22,19 +22,19 @@ def test_successful_purchase end.check_request do |endpoint, data, headers| parse(data) do |doc| assert_not_nil root = doc.at_xpath(@request_root) - assert_equal @gateway.options[:account_id], root.at_xpath("//acctid").content - assert_equal @gateway.options[:merchant_pin], root.at_xpath("//merchantpin").content - assert_equal @credit_card.name, root.at_xpath("//ccname").content - assert_equal @credit_card.number, root.at_xpath("//ccnum").content - assert_equal @credit_card.verification_value, root.at_xpath("//cvv2").content - assert_equal "2", root.at_xpath("//service").content - assert_equal "1.00", root.at_xpath("//amount").content + assert_equal @gateway.options[:account_id], root.at_xpath('//acctid').content + assert_equal @gateway.options[:merchant_pin], root.at_xpath('//merchantpin').content + assert_equal @credit_card.name, root.at_xpath('//ccname').content + assert_equal @credit_card.number, root.at_xpath('//ccnum').content + assert_equal @credit_card.verification_value, root.at_xpath('//cvv2').content + assert_equal '2', root.at_xpath('//service').content + assert_equal '1.00', root.at_xpath('//amount').content end end.respond_with(successful_purchase_response) assert_success response assert response.test? - assert_equal "398182213", response.authorization + assert_equal '398182213', response.authorization end def test_failed_purchase @@ -43,8 +43,8 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "Invalid account number", response.message - assert response.params["result"].start_with?("DECLINED") + assert_equal 'Invalid account number', response.message + assert response.params['result'].start_with?('DECLINED') assert response.test? end @@ -54,36 +54,36 @@ def test_successful_authorize_and_capture end.check_request do |endpoint, data, headers| parse(data) do |doc| assert_not_nil root = doc.at_xpath(@request_root) - assert_equal @gateway.options[:account_id], root.at_xpath("//acctid").content - assert_equal @gateway.options[:merchant_pin], root.at_xpath("//merchantpin").content - assert_equal @credit_card.name, root.at_xpath("//ccname").content - assert_equal @credit_card.number, root.at_xpath("//ccnum").content - assert_equal @credit_card.verification_value, root.at_xpath("//cvv2").content - assert_equal "1", root.at_xpath("//service").content - assert_equal "1.00", root.at_xpath("//amount").content + assert_equal @gateway.options[:account_id], root.at_xpath('//acctid').content + assert_equal @gateway.options[:merchant_pin], root.at_xpath('//merchantpin').content + assert_equal @credit_card.name, root.at_xpath('//ccname').content + assert_equal @credit_card.number, root.at_xpath('//ccnum').content + assert_equal @credit_card.verification_value, root.at_xpath('//cvv2').content + assert_equal '1', root.at_xpath('//service').content + assert_equal '1.00', root.at_xpath('//amount').content end end.respond_with(successful_authorize_response) assert_success response assert response.test? - assert_equal "398047747", response.authorization + assert_equal '398047747', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) end.check_request do |endpoint, data, headers| parse(data) do |doc| assert_not_nil root = doc.at_xpath(@request_root) - assert_equal @gateway.options[:account_id], root.at_xpath("//acctid").content - assert_equal @gateway.options[:merchant_pin], root.at_xpath("//merchantpin").content - assert_equal response.authorization, root.at_xpath("//historykeyid").content - assert_equal "3", root.at_xpath("//service").content - assert_equal "1.00", root.at_xpath("//amount").content + assert_equal @gateway.options[:account_id], root.at_xpath('//acctid').content + assert_equal @gateway.options[:merchant_pin], root.at_xpath('//merchantpin').content + assert_equal response.authorization, root.at_xpath('//historykeyid').content + assert_equal '3', root.at_xpath('//service').content + assert_equal '1.00', root.at_xpath('//amount').content end end.respond_with(successful_capture_response) assert_success capture assert capture.test? - assert_equal "398044113", capture.authorization + assert_equal '398044113', capture.authorization end def test_failed_authorize @@ -92,14 +92,14 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Invalid account number", response.message - assert response.params["result"].start_with?("DECLINED") + assert_equal 'Invalid account number', response.message + assert response.params['result'].start_with?('DECLINED') assert response.test? end def test_failed_capture response = stub_comms do - @gateway.capture(100, "") + @gateway.capture(100, '') end.respond_with(failed_capture_response) assert_failure response @@ -111,17 +111,17 @@ def test_successful_void end.respond_with(successful_authorize_response) assert_success response - assert_equal "398047747", response.authorization + assert_equal '398047747', response.authorization void = stub_comms do @gateway.void(response.authorization) end.check_request do |endpoint, data, headers| parse(data) do |doc| assert_not_nil root = doc.at_xpath(@request_root) - assert_equal @gateway.options[:account_id], root.at_xpath("//acctid").content - assert_equal @gateway.options[:merchant_pin], root.at_xpath("//merchantpin").content - assert_equal response.authorization, root.at_xpath("//historykeyid").content - assert_equal "5", root.at_xpath("//service").content + assert_equal @gateway.options[:account_id], root.at_xpath('//acctid').content + assert_equal @gateway.options[:merchant_pin], root.at_xpath('//merchantpin').content + assert_equal response.authorization, root.at_xpath('//historykeyid').content + assert_equal '5', root.at_xpath('//service').content end end.respond_with(successful_void_response) @@ -130,7 +130,7 @@ def test_successful_void def test_failed_void response = stub_comms do - @gateway.void("5d53a33d960c46d00f5dc061947d998c") + @gateway.void('5d53a33d960c46d00f5dc061947d998c') end.respond_with(failed_void_response) assert_failure response @@ -148,11 +148,11 @@ def test_successful_refund end.check_request do |endpoint, data, headers| parse(data) do |doc| assert_not_nil root = doc.at_xpath(@request_root) - assert_equal @gateway.options[:account_id], root.at_xpath("//acctid").content - assert_equal @gateway.options[:merchant_pin], root.at_xpath("//merchantpin").content - assert_equal response.authorization, root.at_xpath("//historykeyid").content - assert_equal "4", root.at_xpath("//service").content - assert_equal "1.00", root.at_xpath("//amount").content + assert_equal @gateway.options[:account_id], root.at_xpath('//acctid').content + assert_equal @gateway.options[:merchant_pin], root.at_xpath('//merchantpin').content + assert_equal response.authorization, root.at_xpath('//historykeyid').content + assert_equal '4', root.at_xpath('//service').content + assert_equal '1.00', root.at_xpath('//amount').content end end.respond_with(successful_refund_response) @@ -161,7 +161,7 @@ def test_successful_refund def test_failed_refund response = stub_comms do - @gateway.refund(nil, "") + @gateway.refund(nil, '') end.respond_with(failed_refund_response) assert_failure response @@ -173,13 +173,13 @@ def test_successful_credit end.check_request do |endpoint, data, headers| parse(data) do |doc| assert_not_nil root = doc.at_xpath(@request_root) - assert_equal @gateway.options[:account_id], root.at_xpath("//acctid").content - assert_equal @gateway.options[:merchant_pin], root.at_xpath("//merchantpin").content - assert_equal @credit_card.name, root.at_xpath("//ccname").content - assert_equal @credit_card.number, root.at_xpath("//ccnum").content - assert_equal @credit_card.verification_value, root.at_xpath("//cvv2").content - assert_equal "6", root.at_xpath("//service").content - assert_equal "1.00", root.at_xpath("//amount").content + assert_equal @gateway.options[:account_id], root.at_xpath('//acctid').content + assert_equal @gateway.options[:merchant_pin], root.at_xpath('//merchantpin').content + assert_equal @credit_card.name, root.at_xpath('//ccname').content + assert_equal @credit_card.number, root.at_xpath('//ccnum').content + assert_equal @credit_card.verification_value, root.at_xpath('//cvv2').content + assert_equal '6', root.at_xpath('//service').content + assert_equal '1.00', root.at_xpath('//amount').content end end.respond_with(successful_credit_response) @@ -193,8 +193,8 @@ def test_failed_credit end.respond_with(failed_credit_response) assert_failure response - assert_equal "Invalid account number", response.message - assert response.params["result"].start_with?("DECLINED") + assert_equal 'Invalid account number', response.message + assert response.params['result'].start_with?('DECLINED') assert response.test? end @@ -203,7 +203,7 @@ def test_successful_verify @gateway.verify(@credit_card) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_verify @@ -211,7 +211,7 @@ def test_failed_verify @gateway.verify(@credit_card) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "Invalid account number", response.message + assert_equal 'Invalid account number', response.message end def test_successful_store @@ -220,18 +220,18 @@ def test_successful_store end.check_request do |endpoint, data, headers| parse(data) do |doc| assert_not_nil root = doc.at_xpath(@request_root) - assert_equal @gateway.options[:account_id], root.at_xpath("//acctid").content - assert_equal @gateway.options[:merchant_pin], root.at_xpath("//merchantpin").content - assert_equal @credit_card.name, root.at_xpath("//ccname").content - assert_equal @credit_card.number, root.at_xpath("//ccnum").content - assert_equal @credit_card.verification_value, root.at_xpath("//cvv2").content - assert_equal "7", root.at_xpath("//service").content + assert_equal @gateway.options[:account_id], root.at_xpath('//acctid').content + assert_equal @gateway.options[:merchant_pin], root.at_xpath('//merchantpin').content + assert_equal @credit_card.name, root.at_xpath('//ccname').content + assert_equal @credit_card.number, root.at_xpath('//ccnum').content + assert_equal @credit_card.verification_value, root.at_xpath('//cvv2').content + assert_equal '7', root.at_xpath('//service').content end end.respond_with(successful_store_response) assert_success response - assert_equal "Succeeded", response.message - assert_equal "17522090|6781", response.authorization + assert_equal 'Succeeded', response.message + assert_equal '17522090|6781', response.authorization assert response.test? end @@ -241,8 +241,8 @@ def test_successful_stored_purchase end.respond_with(successful_store_response) assert_success response - assert_equal "Succeeded", response.message - assert_equal "17522090|6781", response.authorization + assert_equal 'Succeeded', response.message + assert_equal '17522090|6781', response.authorization assert response.test? purchase = stub_comms do @@ -250,12 +250,12 @@ def test_successful_stored_purchase end.check_request do |endpoint, data, headers| parse(data) do |doc| assert_not_nil root = doc.at_xpath(@request_root) - assert_equal @gateway.options[:account_id], root.at_xpath("//acctid").content - assert_equal @gateway.options[:merchant_pin], root.at_xpath("//merchantpin").content - assert_equal response.params["userprofileid"], root.at_xpath("//userprofileid").content - assert_equal response.params["last4digits"], root.at_xpath("//last4digits").content - assert_equal "8", root.at_xpath("//service").content - assert_equal "1.00", root.at_xpath("//amount").content + assert_equal @gateway.options[:account_id], root.at_xpath('//acctid').content + assert_equal @gateway.options[:merchant_pin], root.at_xpath('//merchantpin').content + assert_equal response.params['userprofileid'], root.at_xpath('//userprofileid').content + assert_equal response.params['last4digits'], root.at_xpath('//last4digits').content + assert_equal '8', root.at_xpath('//service').content + assert_equal '1.00', root.at_xpath('//amount').content end end.respond_with(successful_purchase_response) @@ -269,8 +269,8 @@ def test_successful_stored_credit end.respond_with(successful_store_response) assert_success response - assert_equal "Succeeded", response.message - assert_equal "17522090|6781", response.authorization + assert_equal 'Succeeded', response.message + assert_equal '17522090|6781', response.authorization assert response.test? credit = stub_comms do @@ -278,12 +278,12 @@ def test_successful_stored_credit end.check_request do |endpoint, data, headers| parse(data) do |doc| assert_not_nil root = doc.at_xpath(@request_root) - assert_equal @gateway.options[:account_id], root.at_xpath("//acctid").content - assert_equal @gateway.options[:merchant_pin], root.at_xpath("//merchantpin").content - assert_equal response.params["userprofileid"], root.at_xpath("//userprofileid").content - assert_equal response.params["last4digits"], root.at_xpath("//last4digits").content - assert_equal "13", root.at_xpath("//service").content - assert_equal "1.00", root.at_xpath("//amount").content + assert_equal @gateway.options[:account_id], root.at_xpath('//acctid').content + assert_equal @gateway.options[:merchant_pin], root.at_xpath('//merchantpin').content + assert_equal response.params['userprofileid'], root.at_xpath('//userprofileid').content + assert_equal response.params['last4digits'], root.at_xpath('//last4digits').content + assert_equal '13', root.at_xpath('//service').content + assert_equal '1.00', root.at_xpath('//amount').content end end.respond_with(successful_purchase_response) @@ -297,8 +297,8 @@ def test_failed_store end.respond_with(failed_store_response) assert_failure response - assert_equal "Live Transactions Not Allowed", response.message - assert response.params["result"].start_with?("DECLINED") + assert_equal 'Live Transactions Not Allowed', response.message + assert response.params['result'].start_with?('DECLINED') assert response.test? end diff --git a/test/unit/gateways/merchant_ware_test.rb b/test/unit/gateways/merchant_ware_test.rb index 9f19d3d3090..bfaf52f2462 100644 --- a/test/unit/gateways/merchant_ware_test.rb +++ b/test/unit/gateways/merchant_ware_test.rb @@ -27,12 +27,12 @@ def test_successful_authorization assert_success response assert_equal '4706382;1', response.authorization - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end def test_soap_fault_during_authorization - response_500 = stub(:code => "500", :message => "Internal Server Error", :body => fault_authorization_response) + response_500 = stub(:code => '500', :message => 'Internal Server Error', :body => fault_authorization_response) @gateway.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(response_500)) assert response = @gateway.authorize(@amount, @credit_card, @options) @@ -41,9 +41,9 @@ def test_soap_fault_during_authorization assert response.test? assert_nil response.authorization - assert_equal "Server was unable to process request. ---> strPAN should be at least 13 to at most 19 characters in size. Parameter name: strPAN", response.message - assert_equal response_500.code, response.params["http_code"] - assert_equal response_500.message, response.params["http_message"] + assert_equal 'Server was unable to process request. ---> strPAN should be at least 13 to at most 19 characters in size. Parameter name: strPAN', response.message + assert_equal response_500.code, response.params['http_code'] + assert_equal response_500.message, response.params['http_message'] end def test_failed_authorization @@ -55,43 +55,43 @@ def test_failed_authorization assert response.test? assert_nil response.authorization - assert_equal "transaction type not supported by version", response.message - assert_equal "FAILED", response.params["status"] - assert_equal "1014", response.params["failure_code"] + assert_equal 'transaction type not supported by version', response.message + assert_equal 'FAILED', response.params['status'] + assert_equal '1014', response.params['failure_code'] end def test_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/<strPAN>#{@credit_card.number}<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<strPAN>#{@credit_card.number}<\//), anything).returns('') @gateway.expects(:parse).returns({}) @gateway.credit(@amount, @credit_card, @options) end def test_deprecated_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/<strReferenceCode>transaction_id<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<strReferenceCode>transaction_id<\//), anything).returns('') @gateway.expects(:parse).returns({}) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - @gateway.credit(@amount, "transaction_id", @options) + @gateway.credit(@amount, 'transaction_id', @options) end end def test_refund - @gateway.expects(:ssl_post).with(anything, regexp_matches(/<strReferenceCode>transaction_id<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<strReferenceCode>transaction_id<\//), anything).returns('') @gateway.expects(:parse).returns({}) - @gateway.refund(@amount, "transaction_id", @options) + @gateway.refund(@amount, 'transaction_id', @options) end def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) - assert response = @gateway.void("1") + assert response = @gateway.void('1') assert_instance_of Response, response assert_failure response assert response.test? assert_nil response.authorization - assert_equal "decline", response.message - assert_equal "DECLINED", response.params["status"] - assert_equal "1012", response.params["failure_code"] + assert_equal 'decline', response.message + assert_equal 'DECLINED', response.params['status'] + assert_equal '1012', response.params['failure_code'] end def test_avs_result @@ -109,12 +109,12 @@ def test_cvv_result end def test_add_swipe_data_with_creditcard - @credit_card.track_data = "Track Data" + @credit_card.track_data = 'Track Data' options = {:order_id => '1'} stub_comms do @gateway.authorize(@amount, @credit_card, options) end.check_request do |endpoint, data, headers| - assert_match "<trackData>Track Data</trackData>", data + assert_match '<trackData>Track Data</trackData>', data end.respond_with(successful_authorization_response) end diff --git a/test/unit/gateways/merchant_ware_version_four_test.rb b/test/unit/gateways/merchant_ware_version_four_test.rb index f30a7fef0c1..4119f8f63d9 100644 --- a/test/unit/gateways/merchant_ware_version_four_test.rb +++ b/test/unit/gateways/merchant_ware_version_four_test.rb @@ -26,12 +26,12 @@ def test_successful_authorization assert_success response assert_equal '1236564', response.authorization - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end def test_soap_fault_during_authorization - response_400 = stub(:code => "400", :message => "Bad Request", :body => failed_authorize_response) + response_400 = stub(:code => '400', :message => 'Bad Request', :body => failed_authorize_response) @gateway.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(response_400)) assert response = @gateway.authorize(@amount, @credit_card, @options) @@ -40,9 +40,9 @@ def test_soap_fault_during_authorization assert response.test? assert_nil response.authorization - assert_equal "amount cannot be null. Parameter name: amount", response.message - assert_equal response_400.code, response.params["http_code"] - assert_equal response_400.message, response.params["http_message"] + assert_equal 'amount cannot be null. Parameter name: amount', response.message + assert_equal response_400.code, response.params['http_code'] + assert_equal response_400.message, response.params['http_message'] end def test_failed_authorization @@ -54,9 +54,9 @@ def test_failed_authorization assert response.test? assert_nil response.authorization - assert_equal "invalid exp date", response.message - assert_equal "DECLINED", response.params["status"] - assert_equal "1024", response.params["failure_code"] + assert_equal 'invalid exp date', response.message + assert_equal 'DECLINED', response.params['status'] + assert_equal '1024', response.params['failure_code'] end def test_failed_authorization_due_to_invalid_credit_card_number @@ -68,29 +68,29 @@ def test_failed_authorization_due_to_invalid_credit_card_number assert response.test? assert_nil response.authorization - assert_equal "Invalid card number.", response.message - assert_nil response.params["status"] - assert_nil response.params["failure_code"] + assert_equal 'Invalid card number.', response.message + assert_nil response.params['status'] + assert_nil response.params['failure_code'] end def test_refund - @gateway.expects(:ssl_post).with(anything, regexp_matches(/<token>transaction_id<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<token>transaction_id<\//), anything).returns('') @gateway.expects(:parse).returns({}) - @gateway.refund(@amount, "transaction_id", @options) + @gateway.refund(@amount, 'transaction_id', @options) end def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) - assert response = @gateway.void("1") + assert response = @gateway.void('1') assert_instance_of Response, response assert_failure response assert response.test? assert_nil response.authorization - assert_equal "original transaction id not found", response.message - assert_equal "DECLINED", response.params["status"] - assert_equal "1019", response.params["failure_code"] + assert_equal 'original transaction id not found', response.message + assert_equal 'DECLINED', response.params['status'] + assert_equal '1019', response.params['failure_code'] end def test_avs_result @@ -115,7 +115,7 @@ def test_successful_purchase_using_prior_transaction assert_success response assert_equal '1236564', response.authorization - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end diff --git a/test/unit/gateways/merchant_warrior_test.rb b/test/unit/gateways/merchant_warrior_test.rb index 613e8e52511..8eb0e1e85f2 100644 --- a/test/unit/gateways/merchant_warrior_test.rb +++ b/test/unit/gateways/merchant_warrior_test.rb @@ -28,7 +28,7 @@ def test_successful_purchase assert_success response assert_equal 'Transaction approved', response.message assert response.test? - assert_equal "30-98a79008-dae8-11df-9322-0022198101cd", response.authorization + assert_equal '30-98a79008-dae8-11df-9322-0022198101cd', response.authorization end def test_failed_purchase @@ -38,7 +38,7 @@ def test_failed_purchase assert_failure response assert_equal 'Card has expired', response.message assert response.test? - assert_equal "30-69433444-af1-11df-9322-0022198101cd", response.authorization + assert_equal '30-69433444-af1-11df-9322-0022198101cd', response.authorization end def test_successful_refund @@ -48,7 +48,7 @@ def test_successful_refund assert_success response assert_equal 'Transaction approved', response.message assert response.test? - assert_equal "30-d4d19f4-db17-11df-9322-0022198101cd", response.authorization + assert_equal '30-d4d19f4-db17-11df-9322-0022198101cd', response.authorization end def test_failed_refund @@ -62,8 +62,8 @@ def test_failed_refund end def test_successful_store - @credit_card.month = "2" - @credit_card.year = "2005" + @credit_card.month = '2' + @credit_card.year = '2005' store = stub_comms do @gateway.store(@credit_card, @options) @@ -73,14 +73,14 @@ def test_successful_store end.respond_with(successful_store_response) assert_success store - assert_equal "Operation successful", store.message - assert_match "KOCI10023982", store.authorization + assert_equal 'Operation successful', store.message + assert_match 'KOCI10023982', store.authorization end def test_scrub_name @credit_card.first_name = "Chars; Merchant-Warrior Don't Like" - @credit_card.last_name = "& More. # Here" - @options[:address][:name] = "Ren & Stimpy" + @credit_card.last_name = '& More. # Here' + @options[:address][:name] = 'Ren & Stimpy' stub_comms do @gateway.purchase(@success_amount, @credit_card, @options) @@ -133,7 +133,7 @@ def test_address_without_state def test_orderid_truncated stub_comms do - @gateway.purchase(@success_amount, @credit_card, order_id: "ThisIsQuiteALongDescriptionWithLotsOfChars") + @gateway.purchase(@success_amount, @credit_card, order_id: 'ThisIsQuiteALongDescriptionWithLotsOfChars') end.check_request do |endpoint, data, headers| assert_match(/transactionProduct=ThisIsQuiteALongDescriptionWithLot&/, data) end.respond_with(successful_purchase_response) diff --git a/test/unit/gateways/mercury_test.rb b/test/unit/gateways/mercury_test.rb index fae8efc7143..e7d298f52b4 100644 --- a/test/unit/gateways/mercury_test.rb +++ b/test/unit/gateways/mercury_test.rb @@ -9,7 +9,7 @@ def setup @gateway = MercuryGateway.new(fixtures(:mercury)) @amount = 100 - @credit_card = credit_card("5499990123456781", :brand => "master") + @credit_card = credit_card('5499990123456781', :brand => 'master') @declined_card = credit_card('4000300011112220') @options = { @@ -64,7 +64,7 @@ def test_successful_refund end def test_card_present_with_track_1_data - track_data = "%B4003000123456781^LONGSEN/L. ^15121200000000000000123?" + track_data = '%B4003000123456781^LONGSEN/L. ^15121200000000000000123?' @credit_card.track_data = track_data response = stub_comms do @gateway.purchase(@amount, @credit_card, @options) @@ -77,8 +77,8 @@ def test_card_present_with_track_1_data end def test_card_present_with_track_2_data - track_data = ";5413330089010608=2512101097750213?" - stripped_track_data = "5413330089010608=2512101097750213" + track_data = ';5413330089010608=2512101097750213?' + stripped_track_data = '5413330089010608=2512101097750213' @credit_card.track_data = track_data response = stub_comms do @gateway.purchase(@amount, @credit_card, @options) @@ -91,8 +91,8 @@ def test_card_present_with_track_2_data end def test_card_present_with_max_length_track_1_data - track_data = "%B373953192351004^CARDUSER/JOHN^200910100000019301000000877000000930001234567?" - stripped_data = "B373953192351004^CARDUSER/JOHN^200910100000019301000000877000000930001234567" + track_data = '%B373953192351004^CARDUSER/JOHN^200910100000019301000000877000000930001234567?' + stripped_data = 'B373953192351004^CARDUSER/JOHN^200910100000019301000000877000000930001234567' @credit_card.track_data = track_data response = stub_comms do @gateway.purchase(@amount, @credit_card, @options) @@ -105,7 +105,7 @@ def test_card_present_with_max_length_track_1_data end def test_card_present_with_invalid_data - track_data = "this is not valid track data" + track_data = 'this is not valid track data' @credit_card.track_data = track_data response = stub_comms do @gateway.purchase(@amount, @credit_card, @options) diff --git a/test/unit/gateways/metrics_global_test.rb b/test/unit/gateways/metrics_global_test.rb index 04e8d7ed20c..e16afd5dd8f 100644 --- a/test/unit/gateways/metrics_global_test.rb +++ b/test/unit/gateways/metrics_global_test.rb @@ -46,7 +46,7 @@ def test_add_address_outsite_north_america @gateway.send(:add_address, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'DE', :state => ''} ) - assert_equal ["address", "city", "company", "country", "phone", "state", "zip"], result.stringify_keys.keys.sort + assert_equal ['address', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort assert_equal 'n/a', result[:state] assert_equal '164 Waverley Street', result[:address] assert_equal 'DE', result[:country] @@ -57,7 +57,7 @@ def test_add_address @gateway.send(:add_address, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} ) - assert_equal ["address", "city", "company", "country", "phone", "state", "zip"], result.stringify_keys.keys.sort + assert_equal ['address', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort assert_equal 'CO', result[:state] assert_equal '164 Waverley Street', result[:address] assert_equal 'US', result[:country] @@ -101,7 +101,7 @@ def test_purchase_is_valid_csv def test_purchase_meets_minimum_requirements params = { - :amount => "1.01", + :amount => '1.01', } @gateway.send(:add_creditcard, params, @credit_card) @@ -121,7 +121,7 @@ def test_successful_refund def test_refund_passing_extra_info response = stub_comms do - @gateway.refund(50, '123456789', :card_number => @credit_card.number, :first_name => "Bob", :last_name => "Smith", :zip => "12345") + @gateway.refund(50, '123456789', :card_number => @credit_card.number, :first_name => 'Bob', :last_name => 'Smith', :zip => '12345') end.check_request do |endpoint, data, headers| assert_match(/x_first_name=Bob/, data) assert_match(/x_last_name=Smith/, data) @@ -167,7 +167,7 @@ def test_response_under_review_by_fraud_service response = @gateway.purchase(@amount, @credit_card) assert_failure response assert response.fraud_review? - assert_equal "Thank you! For security reasons your order is currently being reviewed", response.message + assert_equal 'Thank you! For security reasons your order is currently being reviewed', response.message end def test_avs_result @@ -195,13 +195,13 @@ def test_message_from :response_reason_code => '27', :response_reason_text => 'Failure.', } - assert_equal "CVV does not match", @gateway.message_from(result) + assert_equal 'CVV does not match', @gateway.message_from(result) result[:card_code] = 'M' - assert_equal "Street address matches, but 5-digit and 9-digit postal code do not match.", @gateway.message_from(result) + assert_equal 'Street address matches, but 5-digit and 9-digit postal code do not match.', @gateway.message_from(result) result[:response_reason_code] = '22' - assert_equal "Failure", @gateway.message_from(result) + assert_equal 'Failure', @gateway.message_from(result) end private @@ -231,6 +231,6 @@ def failed_authorization_response end def fraud_review_response - "$4$,$$,$253$,$Thank you! For security reasons your order is currently being reviewed.$,$$,$X$,$0$,$$,$$,$1.00$,$$,$auth_capture$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$207BCBBF78E85CF174C87AE286B472D2$,$M$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$" + '$4$,$$,$253$,$Thank you! For security reasons your order is currently being reviewed.$,$$,$X$,$0$,$$,$$,$1.00$,$$,$auth_capture$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$207BCBBF78E85CF174C87AE286B472D2$,$M$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$' end end diff --git a/test/unit/gateways/micropayment_test.rb b/test/unit/gateways/micropayment_test.rb index 6a5862852fa..5e63d8f0fa3 100644 --- a/test/unit/gateways/micropayment_test.rb +++ b/test/unit/gateways/micropayment_test.rb @@ -5,7 +5,7 @@ class MicropaymentTest < Test::Unit::TestCase def setup @gateway = MicropaymentGateway.new( - access_key: "key" + access_key: 'key' ) @credit_card = credit_card @@ -23,7 +23,7 @@ def test_successful_purchase end.respond_with(successful_purchase_response) assert_success response - assert_equal "CCadc2b593ca98bfd730c383582de00faed995b0|www.spreedly.com-IDhm7nyju168", response.authorization + assert_equal 'CCadc2b593ca98bfd730c383582de00faed995b0|www.spreedly.com-IDhm7nyju168', response.authorization assert response.test? end @@ -33,7 +33,7 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "AS stellt falsches Routing fest", response.message + assert_equal 'AS stellt falsches Routing fest', response.message assert response.test? end @@ -48,7 +48,7 @@ def test_successful_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "CC747358d9598614c3ba1e9a7b82a28318cd81bc|www.spreedly.com-IDhngtaj81a1", response.authorization + assert_equal 'CC747358d9598614c3ba1e9a7b82a28318cd81bc|www.spreedly.com-IDhngtaj81a1', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -68,13 +68,13 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "AS stellt falsches Routing fest", response.message + assert_equal 'AS stellt falsches Routing fest', response.message assert response.test? end def test_failed_capture response = stub_comms do - @gateway.capture(100, "") + @gateway.capture(100, '') end.respond_with(failed_capture_response) assert_failure response @@ -100,7 +100,7 @@ def test_successful_void def test_failed_void response = stub_comms do - @gateway.void("") + @gateway.void('') end.respond_with(failed_void_response) assert_failure response @@ -127,7 +127,7 @@ def test_successful_refund def test_failed_refund response = stub_comms do - @gateway.refund(nil, "") + @gateway.refund(nil, '') end.respond_with(failed_refund_response) assert_failure response @@ -138,7 +138,7 @@ def test_successful_verify @gateway.verify(@credit_card) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_verify @@ -146,7 +146,7 @@ def test_failed_verify @gateway.verify(@credit_card) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "AS stellt falsches Routing fest", response.message + assert_equal 'AS stellt falsches Routing fest', response.message end def test_transcript_scrubbing diff --git a/test/unit/gateways/migs_test.rb b/test/unit/gateways/migs_test.rb index 4a0bd12a5b1..807a7def5b0 100644 --- a/test/unit/gateways/migs_test.rb +++ b/test/unit/gateways/migs_test.rb @@ -45,18 +45,18 @@ def test_secure_hash :OrderInfo => 'A48cvE28', :Amount => 2995 } - ordered_values = "vpc_Amount=2995&vpc_MerchantId=MER123&vpc_OrderInfo=A48cvE28" + ordered_values = 'vpc_Amount=2995&vpc_MerchantId=MER123&vpc_OrderInfo=A48cvE28' @gateway.send(:add_secure_hash, params) assert_equal OpenSSL::HMAC.hexdigest('SHA256', [@gateway.options[:secure_hash]].pack('H*'), ordered_values).upcase, params[:SecureHash] end def test_purchase_offsite_response # Below response from instance running remote test - response_params = "vpc_3DSXID=a1B8UcW%2BKYqkSinLQohGmqQd9uY%3D&vpc_3DSenrolled=U&vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=100&vpc_AuthorizeId=367739&vpc_BatchNo=20120421&vpc_CSCResultCode=Unsupported&vpc_Card=MC&vpc_Command=pay&vpc_Locale=en&vpc_MerchTxnRef=9&vpc_Merchant=TESTANZTEST3&vpc_Message=Approved&vpc_OrderInfo=1&vpc_ReceiptNo=120421367739&vpc_SecureHash=20DE2CDEBE40D6F24E3ABC5D74081CB5B341CD447530121AD51A9504A923BBD0&vpc_TransactionNo=2000025183&vpc_TxnResponseCode=0&vpc_VerSecurityLevel=06&vpc_VerStatus=U&vpc_VerType=3DS&vpc_Version=1" + response_params = 'vpc_3DSXID=a1B8UcW%2BKYqkSinLQohGmqQd9uY%3D&vpc_3DSenrolled=U&vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=100&vpc_AuthorizeId=367739&vpc_BatchNo=20120421&vpc_CSCResultCode=Unsupported&vpc_Card=MC&vpc_Command=pay&vpc_Locale=en&vpc_MerchTxnRef=9&vpc_Merchant=TESTANZTEST3&vpc_Message=Approved&vpc_OrderInfo=1&vpc_ReceiptNo=120421367739&vpc_SecureHash=20DE2CDEBE40D6F24E3ABC5D74081CB5B341CD447530121AD51A9504A923BBD0&vpc_TransactionNo=2000025183&vpc_TxnResponseCode=0&vpc_VerSecurityLevel=06&vpc_VerStatus=U&vpc_VerType=3DS&vpc_Version=1' response_hash = @gateway.send(:parse, response_params) calculated_hash = @gateway.send(:calculate_secure_hash, response_hash, @gateway.options[:secure_hash]) - expected_hash_input = "vpc_3DSXID=a1B8UcW+KYqkSinLQohGmqQd9uY=&vpc_3DSenrolled=U&vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=100&vpc_AuthorizeId=367739&vpc_BatchNo=20120421&vpc_CSCResultCode=Unsupported&vpc_Card=MC&vpc_Command=pay&vpc_Locale=en&vpc_MerchTxnRef=9&vpc_Merchant=TESTANZTEST3&vpc_Message=Approved&vpc_OrderInfo=1&vpc_ReceiptNo=120421367739&vpc_TransactionNo=2000025183&vpc_TxnResponseCode=0&vpc_VerSecurityLevel=06&vpc_VerStatus=U&vpc_VerType=3DS&vpc_Version=1" + expected_hash_input = 'vpc_3DSXID=a1B8UcW+KYqkSinLQohGmqQd9uY=&vpc_3DSenrolled=U&vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=100&vpc_AuthorizeId=367739&vpc_BatchNo=20120421&vpc_CSCResultCode=Unsupported&vpc_Card=MC&vpc_Command=pay&vpc_Locale=en&vpc_MerchTxnRef=9&vpc_Merchant=TESTANZTEST3&vpc_Message=Approved&vpc_OrderInfo=1&vpc_ReceiptNo=120421367739&vpc_TransactionNo=2000025183&vpc_TxnResponseCode=0&vpc_VerSecurityLevel=06&vpc_VerStatus=U&vpc_VerType=3DS&vpc_Version=1' assert_equal OpenSSL::HMAC.hexdigest('SHA256', [@gateway.options[:secure_hash]].pack('H*'), expected_hash_input).upcase, calculated_hash response = @gateway.purchase_offsite_response(response_params) diff --git a/test/unit/gateways/modern_payments_cim_test.rb b/test/unit/gateways/modern_payments_cim_test.rb index 6faaf1ee3b0..0e6aa87a998 100644 --- a/test/unit/gateways/modern_payments_cim_test.rb +++ b/test/unit/gateways/modern_payments_cim_test.rb @@ -26,35 +26,35 @@ def test_create_customer assert_instance_of Response, response assert response.test? assert_success response - assert_equal "6677348", response.params["create_customer_result"] + assert_equal '6677348', response.params['create_customer_result'] end def test_modify_customer_credit_card @gateway.expects(:ssl_post).returns(successful_modify_customer_credit_card_response) - assert response = @gateway.modify_customer_credit_card("10001", @credit_card) + assert response = @gateway.modify_customer_credit_card('10001', @credit_card) assert_instance_of Response, response assert response.test? assert_success response - assert_equal "6677757", response.params["modify_customer_credit_card_result"] + assert_equal '6677757', response.params['modify_customer_credit_card_result'] end def test_successful_credit_card_authorization @gateway.expects(:ssl_post).returns(successful_authorization_response) - assert response = @gateway.authorize_credit_card_payment("10001", @amount) + assert response = @gateway.authorize_credit_card_payment('10001', @amount) assert_instance_of Response, response assert response.test? assert_success response - assert_equal "18713505", response.params["trans_id"] - assert_equal "RESPONSECODE=A\nAUTHCODE=020411\nDECLINEREASON=\nAVSDATA=Z\nTRANSID=C00 17093294", response.params["auth_string"] - assert_equal "Approved", response.params["message_text"] - assert_equal "true", response.params["approved"] - assert_equal "Z", response.params["avs_code"] - assert_equal "020411", response.params["auth_code"] - assert_equal "C00 17093294", response.params["trans_code"] - assert_equal "18713505", response.authorization + assert_equal '18713505', response.params['trans_id'] + assert_equal "RESPONSECODE=A\nAUTHCODE=020411\nDECLINEREASON=\nAVSDATA=Z\nTRANSID=C00 17093294", response.params['auth_string'] + assert_equal 'Approved', response.params['message_text'] + assert_equal 'true', response.params['approved'] + assert_equal 'Z', response.params['avs_code'] + assert_equal '020411', response.params['auth_code'] + assert_equal 'C00 17093294', response.params['trans_code'] + assert_equal '18713505', response.authorization assert_equal ModernPaymentsCimGateway::SUCCESS_MESSAGE, response.message assert_equal 'Z', response.avs_result['code'] end @@ -62,12 +62,12 @@ def test_successful_credit_card_authorization def test_unsuccessful_credit_card_authorization @gateway.expects(:ssl_post).returns(unsuccessful_credit_card_authorization_response) - assert response = @gateway.authorize_credit_card_payment("10001", @amount) + assert response = @gateway.authorize_credit_card_payment('10001', @amount) assert_instance_of Response, response assert response.test? assert_failure response - assert_equal "999", response.authorization - assert_match %r{RESPONSECODE=D}, response.params["message_text"] + assert_equal '999', response.authorization + assert_match %r{RESPONSECODE=D}, response.params['message_text'] end def test_soap_fault_response @@ -77,7 +77,7 @@ def test_soap_fault_response assert_instance_of Response, response assert response.test? assert_failure response - assert_equal "soap:Client", response.params["faultcode"] + assert_equal 'soap:Client', response.params['faultcode'] end private diff --git a/test/unit/gateways/moneris_test.rb b/test/unit/gateways/moneris_test.rb index e9ecd7e34c7..084bc5c84ca 100644 --- a/test/unit/gateways/moneris_test.rb +++ b/test/unit/gateways/moneris_test.rb @@ -18,8 +18,8 @@ def setup def test_default_options assert_equal 7, @gateway.options[:crypt_type] - assert_equal "store1", @gateway.options[:login] - assert_equal "yesguy", @gateway.options[:password] + assert_equal 'store1', @gateway.options[:login] + assert_equal 'yesguy', @gateway.options[:password] end def test_successful_purchase @@ -33,7 +33,7 @@ def test_successful_purchase def test_successful_purchase_with_network_tokenization @gateway.expects(:ssl_post).returns(successful_purchase_network_tokenization) @credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', verification_value: nil ) assert response = @gateway.purchase(100, @credit_card, @options) @@ -49,17 +49,17 @@ def test_failed_purchase end def test_deprecated_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/txn_number>123<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/txn_number>123<\//), anything).returns('') @gateway.expects(:parse).returns({}) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - @gateway.credit(@amount, "123;456", @options) + @gateway.credit(@amount, '123;456', @options) end end def test_refund - @gateway.expects(:ssl_post).with(anything, regexp_matches(/txn_number>123<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/txn_number>123<\//), anything).returns('') @gateway.expects(:parse).returns({}) - @gateway.refund(@amount, "123;456", @options) + @gateway.refund(@amount, '123;456', @options) end def test_amount_style @@ -72,10 +72,10 @@ def test_amount_style def test_preauth_is_valid_xml params = { - :order_id => "order1", - :amount => "1.01", - :pan => "4242424242424242", - :expdate => "0303", + :order_id => 'order1', + :amount => '1.01', + :pan => '4242424242424242', + :expdate => '0303', :crypt_type => 7, } @@ -86,10 +86,10 @@ def test_preauth_is_valid_xml def test_purchase_is_valid_xml params = { - :order_id => "order1", - :amount => "1.01", - :pan => "4242424242424242", - :expdate => "0303", + :order_id => 'order1', + :amount => '1.01', + :pan => '4242424242424242', + :expdate => '0303', :crypt_type => 7, } @@ -100,10 +100,10 @@ def test_purchase_is_valid_xml def test_capture_is_valid_xml params = { - :order_id => "order1", - :amount => "1.01", - :pan => "4242424242424242", - :expdate => "0303", + :order_id => 'order1', + :amount => '1.01', + :pan => '4242424242424242', + :expdate => '0303', :crypt_type => 7, } @@ -117,7 +117,7 @@ def test_successful_verify @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_supported_countries @@ -138,9 +138,9 @@ def test_successful_store @gateway.expects(:ssl_post).returns(successful_store_response) assert response = @gateway.store(@credit_card) assert_success response - assert_equal "Successfully registered cc details", response.message - assert response.params["data_key"].present? - @data_key = response.params["data_key"] + assert_equal 'Successfully registered cc details', response.message + assert response.params['data_key'].present? + @data_key = response.params['data_key'] end def test_successful_unstore @@ -148,8 +148,8 @@ def test_successful_unstore test_successful_store assert response = @gateway.unstore(@data_key) assert_success response - assert_equal "Successfully deleted cc details", response.message - assert response.params["data_key"].present? + assert_equal 'Successfully deleted cc details', response.message + assert response.params['data_key'].present? end def test_update @@ -157,8 +157,8 @@ def test_update test_successful_store assert response = @gateway.update(@data_key, @credit_card) assert_success response - assert_equal "Successfully updated cc details", response.message - assert response.params["data_key"].present? + assert_equal 'Successfully updated cc details', response.message + assert response.params['data_key'].present? end def test_successful_purchase_with_vault @@ -166,14 +166,14 @@ def test_successful_purchase_with_vault test_successful_store assert response = @gateway.purchase(100, @data_key, {:order_id => generate_unique_id, :customer => generate_unique_id}) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert response.authorization.present? end def test_successful_authorize_with_network_tokenization @gateway.expects(:ssl_post).returns(successful_authorization_network_tokenization) @credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "BwABB4JRdgAAAAAAiFF2AAAAAAA=", + payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', verification_value: nil ) assert response = @gateway.authorize(100, @credit_card, @options) @@ -186,7 +186,7 @@ def test_successful_authorization_with_vault test_successful_store assert response = @gateway.authorize(100, @data_key, {:order_id => generate_unique_id, :customer => generate_unique_id}) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert response.authorization.present? end @@ -200,7 +200,7 @@ def test_failed_authorization_with_vault def test_cvv_enabled_and_provided gateway = MonerisGateway.new(login: 'store1', password: 'yesguy', cvv_enabled: true) - @credit_card.verification_value = "452" + @credit_card.verification_value = '452' stub_comms(gateway) do gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| @@ -212,7 +212,7 @@ def test_cvv_enabled_and_provided def test_cvv_enabled_but_not_provided gateway = MonerisGateway.new(login: 'store1', password: 'yesguy', cvv_enabled: true) - @credit_card.verification_value = "" + @credit_card.verification_value = '' stub_comms(gateway) do gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| @@ -222,7 +222,7 @@ def test_cvv_enabled_but_not_provided end def test_cvv_disabled_and_provided - @credit_card.verification_value = "452" + @credit_card.verification_value = '452' stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| @@ -232,7 +232,7 @@ def test_cvv_disabled_and_provided end def test_cvv_disabled_but_not_provided - @credit_card.verification_value = "" + @credit_card.verification_value = '' stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| @@ -244,9 +244,9 @@ def test_cvv_disabled_but_not_provided def test_avs_enabled_and_provided gateway = MonerisGateway.new(login: 'store1', password: 'yesguy', avs_enabled: true) - billing_address = address(address1: "1234 Anystreet", address2: "") + billing_address = address(address1: '1234 Anystreet', address2: '') stub_comms(gateway) do - gateway.purchase(@amount, @credit_card, billing_address: billing_address, order_id: "1") + gateway.purchase(@amount, @credit_card, billing_address: billing_address, order_id: '1') end.check_request do |endpoint, data, headers| assert_match(%r{avs_street_number>1234<}, data) assert_match(%r{avs_street_name>Anystreet<}, data) @@ -267,9 +267,9 @@ def test_avs_enabled_but_not_provided end def test_avs_disabled_and_provided - billing_address = address(address1: "1234 Anystreet", address2: "") + billing_address = address(address1: '1234 Anystreet', address2: '') stub_comms do - @gateway.purchase(@amount, @credit_card, billing_address: billing_address, order_id: "1") + @gateway.purchase(@amount, @credit_card, billing_address: billing_address, order_id: '1') end.check_request do |endpoint, data, headers| assert_no_match(%r{avs_street_number>}, data) assert_no_match(%r{avs_street_name>}, data) @@ -300,7 +300,7 @@ def test_avs_result_valid_with_address def test_customer_can_be_specified stub_comms do - @gateway.purchase(@amount, @credit_card, order_id: "3", customer: "Joe Jones") + @gateway.purchase(@amount, @credit_card, order_id: '3', customer: 'Joe Jones') end.check_request do |endpoint, data, headers| assert_match(%r{cust_id>Joe Jones}, data) end.respond_with(successful_purchase_response) @@ -308,20 +308,20 @@ def test_customer_can_be_specified def test_customer_not_specified_card_name_used stub_comms do - @gateway.purchase(@amount, @credit_card, order_id: "3") + @gateway.purchase(@amount, @credit_card, order_id: '3') end.check_request do |endpoint, data, headers| assert_match(%r{cust_id>Longbob Longsen}, data) end.respond_with(successful_purchase_response) end def test_add_swipe_data_with_creditcard - @credit_card.track_data = "Track Data" + @credit_card.track_data = 'Track Data' stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| - assert_match "<pos_code>00</pos_code>", data - assert_match "<track2>Track Data</track2>", data + assert_match '<pos_code>00</pos_code>', data + assert_match '<track2>Track Data</track2>', data end.respond_with(successful_purchase_response) end diff --git a/test/unit/gateways/moneris_us_test.rb b/test/unit/gateways/moneris_us_test.rb index 3a0834adbb8..9d358635147 100644 --- a/test/unit/gateways/moneris_us_test.rb +++ b/test/unit/gateways/moneris_us_test.rb @@ -23,8 +23,8 @@ def setup def test_default_options assert_equal 7, @gateway.options[:crypt_type] - assert_equal "monusqa002", @gateway.options[:login] - assert_equal "qatoken", @gateway.options[:password] + assert_equal 'monusqa002', @gateway.options[:login] + assert_equal 'qatoken', @gateway.options[:password] end def test_successful_purchase @@ -51,17 +51,17 @@ def test_successful_echeck_purchase end def test_deprecated_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/txn_number>123<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/txn_number>123<\//), anything).returns('') @gateway.expects(:parse).returns({}) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - @gateway.credit(@amount, "123;456", @options) + @gateway.credit(@amount, '123;456', @options) end end def test_refund - @gateway.expects(:ssl_post).with(anything, regexp_matches(/txn_number>123<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/txn_number>123<\//), anything).returns('') @gateway.expects(:parse).returns({}) - @gateway.refund(@amount, "123;456", @options) + @gateway.refund(@amount, '123;456', @options) end def test_successful_verify @@ -69,7 +69,7 @@ def test_successful_verify @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, successful_capture_response) assert_success response - assert_equal "830337-0_25;d315c7a28623dec77dc136450692d2dd", response.authorization + assert_equal '830337-0_25;d315c7a28623dec77dc136450692d2dd', response.authorization end def test_successful_verify_and_failed_void @@ -77,8 +77,8 @@ def test_successful_verify_and_failed_void @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, failed_capture_response) assert_success response - assert_equal "830337-0_25;d315c7a28623dec77dc136450692d2dd", response.authorization - assert_equal "Approved", response.message + assert_equal '830337-0_25;d315c7a28623dec77dc136450692d2dd', response.authorization + assert_equal 'Approved', response.message end def test_failed_verify @@ -86,7 +86,7 @@ def test_failed_verify @gateway.verify(@credit_card, @options) end.respond_with(failed_authorize_response, successful_capture_response) assert_failure response - assert_equal "Declined", response.message + assert_equal 'Declined', response.message end def test_amount_style @@ -100,10 +100,10 @@ def test_amount_style def test_preauth_is_valid_xml params = { - :order_id => "order1", - :amount => "1.01", - :pan => "4242424242424242", - :expdate => "0303", + :order_id => 'order1', + :amount => '1.01', + :pan => '4242424242424242', + :expdate => '0303', :crypt_type => 7, } @@ -115,10 +115,10 @@ def test_preauth_is_valid_xml def test_purchase_is_valid_xml params = { - :order_id => "order1", - :amount => "1.01", - :pan => "4242424242424242", - :expdate => "0303", + :order_id => 'order1', + :amount => '1.01', + :pan => '4242424242424242', + :expdate => '0303', :crypt_type => 7, } @@ -130,10 +130,10 @@ def test_purchase_is_valid_xml def test_capture_is_valid_xml params = { - :order_id => "order1", - :amount => "1.01", - :pan => "4242424242424242", - :expdate => "0303", + :order_id => 'order1', + :amount => '1.01', + :pan => '4242424242424242', + :expdate => '0303', :crypt_type => 7, } @@ -160,9 +160,9 @@ def test_successful_store @gateway.expects(:ssl_post).returns(successful_store_response) assert response = @gateway.store(@credit_card) assert_success response - assert_equal "Successfully registered cc details", response.message - assert response.params["data_key"].present? - @data_key = response.params["data_key"] + assert_equal 'Successfully registered cc details', response.message + assert response.params['data_key'].present? + @data_key = response.params['data_key'] end def test_successful_unstore @@ -170,8 +170,8 @@ def test_successful_unstore test_successful_store assert response = @gateway.unstore(@data_key) assert_success response - assert_equal "Successfully deleted cc details", response.message - assert response.params["data_key"].present? + assert_equal 'Successfully deleted cc details', response.message + assert response.params['data_key'].present? end def test_update @@ -179,8 +179,8 @@ def test_update test_successful_store assert response = @gateway.update(@data_key, @credit_card) assert_success response - assert_equal "Successfully updated cc details", response.message - assert response.params["data_key"].present? + assert_equal 'Successfully updated cc details', response.message + assert response.params['data_key'].present? end def test_successful_purchase_with_vault @@ -188,7 +188,7 @@ def test_successful_purchase_with_vault test_successful_store assert response = @gateway.purchase(100, @data_key, {:order_id => generate_unique_id, :customer => generate_unique_id}) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert response.authorization.present? end @@ -197,7 +197,7 @@ def test_successful_authorization_with_vault test_successful_store assert response = @gateway.authorize(100, @data_key, {:order_id => generate_unique_id, :customer => generate_unique_id}) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert response.authorization.present? end @@ -211,7 +211,7 @@ def test_failed_authorization_with_vault def test_cvv_enabled_and_provided gateway = MonerisGateway.new(login: 'store1', password: 'yesguy', cvv_enabled: true) - @credit_card.verification_value = "452" + @credit_card.verification_value = '452' stub_comms(gateway) do gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| @@ -223,7 +223,7 @@ def test_cvv_enabled_and_provided def test_cvv_enabled_but_not_provided gateway = MonerisGateway.new(login: 'store1', password: 'yesguy', cvv_enabled: true) - @credit_card.verification_value = "" + @credit_card.verification_value = '' stub_comms(gateway) do gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| @@ -233,7 +233,7 @@ def test_cvv_enabled_but_not_provided end def test_cvv_disabled_and_provided - @credit_card.verification_value = "452" + @credit_card.verification_value = '452' stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| @@ -243,7 +243,7 @@ def test_cvv_disabled_and_provided end def test_cvv_disabled_but_not_provided - @credit_card.verification_value = "" + @credit_card.verification_value = '' stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| @@ -255,9 +255,9 @@ def test_cvv_disabled_but_not_provided def test_avs_enabled_and_provided gateway = MonerisGateway.new(login: 'store1', password: 'yesguy', avs_enabled: true) - billing_address = address(address1: "1234 Anystreet", address2: "") + billing_address = address(address1: '1234 Anystreet', address2: '') stub_comms(gateway) do - gateway.purchase(@amount, @credit_card, billing_address: billing_address, order_id: "1") + gateway.purchase(@amount, @credit_card, billing_address: billing_address, order_id: '1') end.check_request do |endpoint, data, headers| assert_match(%r{avs_street_number>1234<}, data) assert_match(%r{avs_street_name>Anystreet<}, data) @@ -278,9 +278,9 @@ def test_avs_enabled_but_not_provided end def test_avs_disabled_and_provided - billing_address = address(address1: "1234 Anystreet", address2: "") + billing_address = address(address1: '1234 Anystreet', address2: '') stub_comms do - @gateway.purchase(@amount, @credit_card, billing_address: billing_address, order_id: "1") + @gateway.purchase(@amount, @credit_card, billing_address: billing_address, order_id: '1') end.check_request do |endpoint, data, headers| assert_no_match(%r{avs_street_number>}, data) assert_no_match(%r{avs_street_name>}, data) @@ -311,7 +311,7 @@ def test_avs_result_valid_with_address def test_customer_can_be_specified stub_comms do - @gateway.purchase(@amount, @credit_card, order_id: "3", customer: "Joe Jones") + @gateway.purchase(@amount, @credit_card, order_id: '3', customer: 'Joe Jones') end.check_request do |endpoint, data, headers| assert_match(%r{cust_id>Joe Jones}, data) end.respond_with(successful_purchase_response) @@ -319,7 +319,7 @@ def test_customer_can_be_specified def test_customer_not_specified_card_name_used stub_comms do - @gateway.purchase(@amount, @credit_card, order_id: "3") + @gateway.purchase(@amount, @credit_card, order_id: '3') end.check_request do |endpoint, data, headers| assert_match(%r{cust_id>Longbob Longsen}, data) end.respond_with(successful_purchase_response) diff --git a/test/unit/gateways/money_movers_test.rb b/test/unit/gateways/money_movers_test.rb index db0f48aa591..de2c1820701 100644 --- a/test/unit/gateways/money_movers_test.rb +++ b/test/unit/gateways/money_movers_test.rb @@ -44,8 +44,8 @@ def test_unsuccessful_request def test_add_address result = {} - @gateway.send(:add_address, result, :billing_address => {:address1 => '1 Main St.', :address2 => "apt 13", :country => 'US', :state => 'MI', :phone => '1234567890'} ) - assert_equal ["address1", "address2", "city", "company", "country", "phone", "state", "zip"], result.stringify_keys.keys.sort + @gateway.send(:add_address, result, :billing_address => {:address1 => '1 Main St.', :address2 => 'apt 13', :country => 'US', :state => 'MI', :phone => '1234567890'} ) + assert_equal ['address1', 'address2', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort assert_equal 'MI', result[:state] assert_equal '1 Main St.', result[:address1] assert_equal 'apt 13', result[:address2] @@ -54,7 +54,7 @@ def test_add_address def test_add_invoice result = {} - @gateway.send(:add_invoice, result, :order_id => '#1001', :description => "This is a great order") + @gateway.send(:add_invoice, result, :order_id => '#1001', :description => 'This is a great order') assert_equal '#1001', result[:orderid] assert_equal 'This is a great order', result[:orderdescription] end @@ -77,8 +77,8 @@ def test_purchase_meets_minimum_requirements end def test_expdate_formatting - assert_equal '0909', @gateway.send(:expdate, credit_card('4111111111111111', :month => "9", :year => "2009")) - assert_equal '0711', @gateway.send(:expdate, credit_card('4111111111111111', :month => "7", :year => "2011")) + assert_equal '0909', @gateway.send(:expdate, credit_card('4111111111111111', :month => '9', :year => '2009')) + assert_equal '0711', @gateway.send(:expdate, credit_card('4111111111111111', :month => '7', :year => '2011')) end def test_supported_countries @@ -112,7 +112,7 @@ def test_amount private def post_data_fixture - "password=password&type=auth&ccnumber=4111111111111111&username=demo&ccexp=1111&amount=100&cvv=999" + 'password=password&type=auth&ccnumber=4111111111111111&username=demo&ccexp=1111&amount=100&cvv=999' end def minimum_requirements @@ -120,14 +120,14 @@ def minimum_requirements end def successful_authorization_response - "response=1&responsetext=SUCCESS&authcode=123456&transactionid=1355694937&avsresponse=Y&cvvresponse=M&orderid=&type=auth&response_code=100" + 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1355694937&avsresponse=Y&cvvresponse=M&orderid=&type=auth&response_code=100' end def successful_purchase_response - "response=1&responsetext=SUCCESS&authcode=123456&transactionid=1346648416&avsresponse=N&cvvresponse=N&orderid=&type=sale&response_code=100" + 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1346648416&avsresponse=N&cvvresponse=N&orderid=&type=sale&response_code=100' end def failed_purchase_response - "response=2&responsetext=DECLINE&authcode=&transactionid=1346648595&avsresponse=N&cvvresponse=N&orderid=&type=sale&response_code=200" + 'response=2&responsetext=DECLINE&authcode=&transactionid=1346648595&avsresponse=N&cvvresponse=N&orderid=&type=sale&response_code=200' end end diff --git a/test/unit/gateways/mundipagg_test.rb b/test/unit/gateways/mundipagg_test.rb index 745add67c59..f8fe08779cb 100644 --- a/test/unit/gateways/mundipagg_test.rb +++ b/test/unit/gateways/mundipagg_test.rb @@ -25,7 +25,7 @@ def test_successful_purchase end def test_successful_purchase_with_holder_document - @options.merge!(holder_document: "a1b2c3d4") + @options.merge!(holder_document: 'a1b2c3d4') response = stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| @@ -41,7 +41,7 @@ def test_billing_not_sent stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| - refute data["billing_address"] + refute data['billing_address'] end.respond_with(successful_purchase_response) end diff --git a/test/unit/gateways/nab_transact_test.rb b/test/unit/gateways/nab_transact_test.rb index e4c56bb818b..3e7dca2eedb 100644 --- a/test/unit/gateways/nab_transact_test.rb +++ b/test/unit/gateways/nab_transact_test.rb @@ -86,7 +86,7 @@ def test_unsuccessful_purchase assert_instance_of Response, response assert_failure response assert response.test? - assert_equal "Expired Card", response.message + assert_equal 'Expired Card', response.message end def test_failed_login @@ -95,7 +95,7 @@ def test_failed_login response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response assert_failure response - assert_equal "Invalid merchant ID", response.message + assert_equal 'Invalid merchant ID', response.message end def test_supported_countries @@ -108,7 +108,7 @@ def test_supported_card_types def test_successful_refund @gateway.expects(:ssl_post).with(&check_transaction_type(:refund)).returns(successful_refund_response) - assert_success @gateway.refund(@amount, "009887", {:order_id => '1'}) + assert_success @gateway.refund(@amount, '009887', {:order_id => '1'}) end def test_successful_refund_with_merchant_descriptor @@ -131,9 +131,9 @@ def test_successful_credit def test_failed_refund @gateway.expects(:ssl_post).with(&check_transaction_type(:refund)).returns(failed_refund_response) - response = @gateway.refund(@amount, "009887", {:order_id => '1'}) + response = @gateway.refund(@amount, '009887', {:order_id => '1'}) assert_failure response - assert_equal "Only $1.00 available for refund", response.message + assert_equal 'Only $1.00 available for refund', response.message end def test_request_timeout_default diff --git a/test/unit/gateways/netaxept_test.rb b/test/unit/gateways/netaxept_test.rb index 2c03745c929..5dddbde3427 100644 --- a/test/unit/gateways/netaxept_test.rb +++ b/test/unit/gateways/netaxept_test.rb @@ -18,7 +18,7 @@ def setup end def test_successful_purchase - s = sequence("request") + s = sequence('request') @gateway.expects(:ssl_get).returns(successful_purchase_response[0]).in_sequence(s) @gateway.expects(:ssl_get).returns(successful_purchase_response[1]).in_sequence(s) @gateway.expects(:ssl_get).returns(successful_purchase_response[2]).in_sequence(s) @@ -32,7 +32,7 @@ def test_successful_purchase end def test_failed_purchase - s = sequence("request") + s = sequence('request') @gateway.expects(:ssl_get).returns(successful_purchase_response[0]).in_sequence(s) @gateway.expects(:ssl_get).returns(successful_purchase_response[1]).in_sequence(s) @gateway.expects(:ssl_get).returns(failed_purchase_response).in_sequence(s) @@ -51,7 +51,7 @@ def test_requires_order_id end def test_handles_currency_with_money - s = sequence("request") + s = sequence('request') @gateway.expects(:ssl_get).with(regexp_matches(/currencyCode=USD/)).returns(successful_purchase_response[0]).in_sequence(s) @gateway.expects(:ssl_get).returns(successful_purchase_response[1]).in_sequence(s) @gateway.expects(:ssl_get).returns(successful_purchase_response[2]).in_sequence(s) @@ -61,7 +61,7 @@ def test_handles_currency_with_money end def test_handles_currency_with_option - s = sequence("request") + s = sequence('request') @gateway.expects(:ssl_get).with(regexp_matches(/currencyCode=USD/)).returns(successful_purchase_response[0]).in_sequence(s) @gateway.expects(:ssl_get).returns(successful_purchase_response[1]).in_sequence(s) @gateway.expects(:ssl_get).returns(successful_purchase_response[2]).in_sequence(s) @@ -80,7 +80,7 @@ def test_handles_setup_transaction_error end def test_handles_query_error - s = sequence("request") + s = sequence('request') @gateway.expects(:ssl_get).returns(successful_purchase_response[0]).in_sequence(s) @gateway.expects(:ssl_get).returns(successful_purchase_response[1]).in_sequence(s) @gateway.expects(:ssl_get).returns(error_purchase_response[2]).in_sequence(s) @@ -93,7 +93,7 @@ def test_handles_query_error def test_url_escape_password @gateway = NetaxeptGateway.new(:login => 'login', :password => '1a=W+Yr2') - s = sequence("request") + s = sequence('request') @gateway.expects(:ssl_get).with(regexp_matches(/token=1a%3DW%2BYr2/)).returns(successful_purchase_response[0]).in_sequence(s) @gateway.expects(:ssl_get).returns(successful_purchase_response[1]).in_sequence(s) @gateway.expects(:ssl_get).returns(successful_purchase_response[2]).in_sequence(s) @@ -103,7 +103,7 @@ def test_url_escape_password end def test_using_credit_card_transaction_service_type - s = sequence("request") + s = sequence('request') @gateway.expects(:ssl_get).with(regexp_matches(/serviceType=M/)).returns(successful_purchase_response[0]).in_sequence(s) @gateway.expects(:ssl_get).returns(successful_purchase_response[1]).in_sequence(s) @gateway.expects(:ssl_get).returns(successful_purchase_response[2]).in_sequence(s) diff --git a/test/unit/gateways/netbilling_test.rb b/test/unit/gateways/netbilling_test.rb index c16b9d23ee3..1230046dfe1 100644 --- a/test/unit/gateways/netbilling_test.rb +++ b/test/unit/gateways/netbilling_test.rb @@ -115,34 +115,34 @@ def test_transcript_scrubbing private def successful_purchase_response - "avs_code=X&cvv2_code=M&status_code=1&auth_code=999999&trans_id=110270311543&auth_msg=TEST+APPROVED&auth_date=2008-01-25+16:43:54" + 'avs_code=X&cvv2_code=M&status_code=1&auth_code=999999&trans_id=110270311543&auth_msg=TEST+APPROVED&auth_date=2008-01-25+16:43:54' end def unsuccessful_purchase_response - "status_code=0&auth_msg=CARD+EXPIRED&trans_id=110492608613&auth_date=2008-01-25+17:47:44" + 'status_code=0&auth_msg=CARD+EXPIRED&trans_id=110492608613&auth_date=2008-01-25+17:47:44' end def successful_repeat_purchase_response - "avs_code=X&cvv2_code=M&status_code=1&processor=TEST&auth_code=999999&settle_amount=1.00&settle_currency=USD&trans_id=112232503575&auth_msg=TEST+APPROVED&auth_date=2014-12-29+18:23:40" + 'avs_code=X&cvv2_code=M&status_code=1&processor=TEST&auth_code=999999&settle_amount=1.00&settle_currency=USD&trans_id=112232503575&auth_msg=TEST+APPROVED&auth_date=2014-12-29+18:23:40' end def unsuccessful_repeat_purchase_invalid_trans_id_response - "No Record Found For Specified ID" + 'No Record Found For Specified ID' end def successful_store_response - "status_code=T&processor=TEST&settle_amount=0.00&settle_currency=USD&trans_id=112235386882&auth_msg=OFFLINE+RECORD&auth_date=2014-12-29+18:23:43" + 'status_code=T&processor=TEST&settle_amount=0.00&settle_currency=USD&trans_id=112235386882&auth_msg=OFFLINE+RECORD&auth_date=2014-12-29+18:23:43' end def unsuccessful_store_invalid_billing_info_response - "20111: Invalid credit card number: 123" + '20111: Invalid credit card number: 123' end def transcript - "amount=1.00&description=Internet+purchase&bill_name1=Longbob&bill_name2=Longsen&card_number=4444111111111119&card_expire=0916&card_cvv2=123&bill_street=1600+Amphitheatre+Parkway&cust_phone=650-253-0001&bill_zip=94043&bill_city=Mountain+View&bill_country=US&bill_state=CA&account_id=104901072025&pay_type=C&tran_type=S" + 'amount=1.00&description=Internet+purchase&bill_name1=Longbob&bill_name2=Longsen&card_number=4444111111111119&card_expire=0916&card_cvv2=123&bill_street=1600+Amphitheatre+Parkway&cust_phone=650-253-0001&bill_zip=94043&bill_city=Mountain+View&bill_country=US&bill_state=CA&account_id=104901072025&pay_type=C&tran_type=S' end def scrubbed_transcript - "amount=1.00&description=Internet+purchase&bill_name1=Longbob&bill_name2=Longsen&card_number=[FILTERED]&card_expire=0916&card_cvv2=[FILTERED]&bill_street=1600+Amphitheatre+Parkway&cust_phone=650-253-0001&bill_zip=94043&bill_city=Mountain+View&bill_country=US&bill_state=CA&account_id=104901072025&pay_type=C&tran_type=S" + 'amount=1.00&description=Internet+purchase&bill_name1=Longbob&bill_name2=Longsen&card_number=[FILTERED]&card_expire=0916&card_cvv2=[FILTERED]&bill_street=1600+Amphitheatre+Parkway&cust_phone=650-253-0001&bill_zip=94043&bill_city=Mountain+View&bill_country=US&bill_state=CA&account_id=104901072025&pay_type=C&tran_type=S' end end diff --git a/test/unit/gateways/netpay_test.rb b/test/unit/gateways/netpay_test.rb index 55ba0dc273f..42a47d8b3da 100644 --- a/test/unit/gateways/netpay_test.rb +++ b/test/unit/gateways/netpay_test.rb @@ -34,17 +34,17 @@ def test_successful_purchase @gateway.expects(:ssl_post).with( anything, all_of( - includes("StoreId=12345"), - includes("UserName=login"), - includes("Password=password"), - includes("ResourceName=Auth"), - includes("Total=10.00"), + includes('StoreId=12345'), + includes('UserName=login'), + includes('Password=password'), + includes('ResourceName=Auth'), + includes('Total=10.00'), includes("CardNumber=#{@credit_card.number}"), - includes("ExpDate=" + CGI.escape("09/#{@credit_card.year.to_s[-2..-1]}")), + includes('ExpDate=' + CGI.escape("09/#{@credit_card.year.to_s[-2..-1]}")), includes("CustomerName=#{CGI.escape(@credit_card.name)}"), includes("CVV2=#{@credit_card.verification_value}"), includes("Comments=#{CGI.escape(@options[:description])}"), - includes("CurrencyCode=484") + includes('CurrencyCode=484') ) ).returns(successful_response) @@ -81,17 +81,17 @@ def test_successful_authorize @gateway.expects(:ssl_post).with( anything, all_of( - includes("StoreId=12345"), - includes("UserName=login"), - includes("Password=password"), - includes("ResourceName=PreAuth"), - includes("Total=10.00"), + includes('StoreId=12345'), + includes('UserName=login'), + includes('Password=password'), + includes('ResourceName=PreAuth'), + includes('Total=10.00'), includes("CardNumber=#{@credit_card.number}"), - includes("ExpDate=" + CGI.escape("09/#{@credit_card.year.to_s[-2..-1]}")), + includes('ExpDate=' + CGI.escape("09/#{@credit_card.year.to_s[-2..-1]}")), includes("CustomerName=#{CGI.escape(@credit_card.name)}"), includes("CVV2=#{@credit_card.verification_value}"), includes("Comments=#{CGI.escape(@options[:description])}"), - includes("CurrencyCode=484") + includes('CurrencyCode=484') ) ).returns(successful_response) @@ -107,7 +107,7 @@ def test_successful_capture anything, all_of( includes('ResourceName=PostAuth'), - includes("Total=10.00"), + includes('Total=10.00'), includes("OrderId=#{@order_id}") ) ).returns(successful_response) @@ -120,9 +120,9 @@ def test_successful_void anything, all_of( includes('ResourceName=Refund'), - includes("Total=10.00"), + includes('Total=10.00'), includes("OrderId=#{@order_id}"), - includes("CurrencyCode=484") + includes('CurrencyCode=484') ) ).returns(successful_response) assert response = @gateway.void("#{@order_id}|10.00|484") @@ -134,7 +134,7 @@ def test_successful_refund anything, all_of( includes('ResourceName=Credit'), - includes("Total=10.00"), + includes('Total=10.00'), includes("OrderId=#{@order_id}") ) ).returns(successful_response) diff --git a/test/unit/gateways/network_merchants_test.rb b/test/unit/gateways/network_merchants_test.rb index 4baa4903314..57fbb837167 100644 --- a/test/unit/gateways/network_merchants_test.rb +++ b/test/unit/gateways/network_merchants_test.rb @@ -19,10 +19,10 @@ def setup end def test_add_swipe_data_with_creditcard - @credit_card.track_data = "data" + @credit_card.track_data = 'data' @gateway.expects(:ssl_post).with do |_, body| - body.include?("track_1=data") + body.include?('track_1=data') end.returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) @@ -63,7 +63,7 @@ def test_purchase_and_store assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:store => true)) assert_success response assert_equal 'SUCCESS', response.message - assert_equal "1378262091", response.params['customer_vault_id'] + assert_equal '1378262091', response.params['customer_vault_id'] end def test_authorize @@ -97,16 +97,16 @@ def test_void assert response = @gateway.void('1869041506', @options) assert_success response - assert_equal "Transaction Void Successful", response.message + assert_equal 'Transaction Void Successful', response.message end def test_refund @gateway.expects(:ssl_post).returns(successful_refund) - assert response = @gateway.refund(50, "1869041506") + assert response = @gateway.refund(50, '1869041506') assert_success response - assert_equal "SUCCESS", response.message - assert_equal "1869043195", response.authorization + assert_equal 'SUCCESS', response.message + assert_equal '1869043195', response.authorization end def test_store @@ -130,7 +130,7 @@ def test_store_check def test_store_failure @gateway.expects(:ssl_post).returns(failed_store) - @credit_card.number = "123" + @credit_card.number = '123' store = @gateway.store(@credit_card, @options) assert_failure store assert store.message.include?('Billing Information missing') @@ -143,7 +143,7 @@ def test_unstore assert unstore = @gateway.unstore('1200085822') assert_success unstore - assert_equal "Customer Deleted", unstore.message + assert_equal 'Customer Deleted', unstore.message end def test_purchase_on_stored_card @@ -151,7 +151,7 @@ def test_purchase_on_stored_card assert purchase = @gateway.purchase(@amount, 1200085822, @options) assert_success purchase - assert_equal "SUCCESS", purchase.message + assert_equal 'SUCCESS', purchase.message assert_equal '1869047279', purchase.authorization end @@ -165,7 +165,7 @@ def test_invalid_login def test_currency_uses_default_when_not_provided @gateway.expects(:ssl_post).with do |_, body| - body.include?("currency=USD") + body.include?('currency=USD') end.returns(successful_purchase_response) @gateway.purchase(@amount, @credit_card, @options) @@ -174,7 +174,7 @@ def test_currency_uses_default_when_not_provided def test_provided_currency_overrides_default @options.update(currency: 'EUR') @gateway.expects(:ssl_post).with do |_, body| - body.include?("currency=EUR") + body.include?('currency=EUR') end.returns(successful_purchase_response) @gateway.purchase(@amount, @credit_card, @options) @@ -184,59 +184,59 @@ def test_provided_currency_overrides_default # Place raw successful response from gateway here def successful_purchase_response - "response=1&responsetext=SUCCESS&authcode=123456&transactionid=1869031575&avsresponse=N&cvvresponse=N&orderid=1&type=auth&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=" + 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1869031575&avsresponse=N&cvvresponse=N&orderid=1&type=auth&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=' end # Place raw failed response from gateway here def failed_purchase_response - "response=2&responsetext=DECLINE&authcode=&transactionid=1869031793&avsresponse=N&cvvresponse=N&orderid=1&type=sale&response_code=200&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=" + 'response=2&responsetext=DECLINE&authcode=&transactionid=1869031793&avsresponse=N&cvvresponse=N&orderid=1&type=sale&response_code=200&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=' end def successful_check_purchase - "response=1&responsetext=SUCCESS&authcode=123456&transactionid=1869039732&avsresponse=&cvvresponse=&orderid=1&type=sale&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=" + 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1869039732&avsresponse=&cvvresponse=&orderid=1&type=sale&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=' end def successful_purchase_and_store - "response=1&responsetext=SUCCESS&authcode=123456&transactionid=1869036881&avsresponse=N&cvvresponse=N&orderid=1&type=sale&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=1378262091" + 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1869036881&avsresponse=N&cvvresponse=N&orderid=1&type=sale&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=1378262091' end def successful_authorize - "response=1&responsetext=SUCCESS&authcode=123456&transactionid=1869041506&avsresponse=N&cvvresponse=N&orderid=1&type=auth&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=" + 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1869041506&avsresponse=N&cvvresponse=N&orderid=1&type=auth&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=' end def successful_capture - "response=1&responsetext=SUCCESS&authcode=123456&transactionid=1869041506&avsresponse=&cvvresponse=&orderid=1&type=capture&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=" + 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1869041506&avsresponse=&cvvresponse=&orderid=1&type=capture&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=' end def failed_capture - "response=3&responsetext=Invalid Transaction ID / Object ID specified: REFID:342421573&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=capture&response_code=300&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=" + 'response=3&responsetext=Invalid Transaction ID / Object ID specified: REFID:342421573&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=capture&response_code=300&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=' end def successful_void - "response=1&responsetext=Transaction Void Successful&authcode=123456&transactionid=1869042801&avsresponse=&cvvresponse=&orderid=1&type=void&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=" + 'response=1&responsetext=Transaction Void Successful&authcode=123456&transactionid=1869042801&avsresponse=&cvvresponse=&orderid=1&type=void&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=' end def successful_refund - "response=1&responsetext=SUCCESS&authcode=&transactionid=1869043195&avsresponse=&cvvresponse=&orderid=1&type=refund&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=" + 'response=1&responsetext=SUCCESS&authcode=&transactionid=1869043195&avsresponse=&cvvresponse=&orderid=1&type=refund&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=' end def successful_store - "response=1&responsetext=Customer Added&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=1200085822" + 'response=1&responsetext=Customer Added&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=1200085822' end def failed_store - "response=3&responsetext=Billing Information missing REFID:342424380&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=300&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=" + 'response=3&responsetext=Billing Information missing REFID:342424380&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=300&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=' end def successful_unstore - "response=1&responsetext=Customer Deleted&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=" + 'response=1&responsetext=Customer Deleted&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=' end def successful_purchase_on_stored_card - "response=1&responsetext=SUCCESS&authcode=123456&transactionid=1869047279&avsresponse=N&cvvresponse=&orderid=1&type=sale&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=1138093627" + 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1869047279&avsresponse=N&cvvresponse=&orderid=1&type=sale&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=1138093627' end def failed_login - "response=3&responsetext=Invalid Username&authcode=&transactionid=0&avsresponse=&cvvresponse=&orderid=1&type=sale&response_code=300" + 'response=3&responsetext=Invalid Username&authcode=&transactionid=0&avsresponse=&cvvresponse=&orderid=1&type=sale&response_code=300' end end diff --git a/test/unit/gateways/nmi_test.rb b/test/unit/gateways/nmi_test.rb index e5ad32ae22c..8512e3d9ba1 100644 --- a/test/unit/gateways/nmi_test.rb +++ b/test/unit/gateways/nmi_test.rb @@ -29,15 +29,15 @@ def test_successful_purchase assert_success response assert response.test? - assert_equal "2762757839#creditcard", response.authorization + assert_equal '2762757839#creditcard', response.authorization end def test_purchase_with_options response = stub_comms do @gateway.purchase(@amount, @credit_card, - recurring: true, order_id: "#1001", description: "AM test", - currency: "GBP", dup_seconds: 15, customer: "123", - merchant_defined_field_8: "value8") + recurring: true, order_id: '#1001', description: 'AM test', + currency: 'GBP', dup_seconds: 15, customer: '123', + merchant_defined_field_8: 'value8') end.check_request do |endpoint, data, headers| assert_match(/billing_method=recurring/, data) assert_match(/orderid=#{CGI.escape("#1001")}/, data) @@ -58,7 +58,7 @@ def test_failed_purchase assert_failure response assert response.test? - assert_equal "DECLINE", response.message + assert_equal 'DECLINE', response.message end def test_successful_purchase_with_echeck @@ -82,7 +82,7 @@ def test_successful_purchase_with_echeck assert_success response assert response.test? - assert_equal "2762759808#check", response.authorization + assert_equal '2762759808#check', response.authorization end def test_failed_purchase_with_echeck @@ -92,7 +92,7 @@ def test_failed_purchase_with_echeck assert_failure response assert response.test? - assert_equal "FAILED", response.message + assert_equal 'FAILED', response.message end def test_successful_authorize_and_capture @@ -109,7 +109,7 @@ def test_successful_authorize_and_capture end.respond_with(successful_authorization_response) assert_success response - assert_equal "2762787830#creditcard", response.authorization + assert_equal '2762787830#creditcard', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -130,13 +130,13 @@ def test_failed_authorize end.respond_with(failed_authorization_response) assert_failure response - assert_equal "DECLINE", response.message + assert_equal 'DECLINE', response.message assert response.test? end def test_failed_capture response = stub_comms do - @gateway.capture(100, "") + @gateway.capture(100, '') end.respond_with(failed_capture_response) assert_failure response @@ -148,7 +148,7 @@ def test_successful_void end.respond_with(successful_purchase_response) assert_success response - assert_equal "2762757839#creditcard", response.authorization + assert_equal '2762757839#creditcard', response.authorization void = stub_comms do @gateway.void(response.authorization) @@ -164,7 +164,7 @@ def test_successful_void def test_failed_void response = stub_comms do - @gateway.void("5d53a33d960c46d00f5dc061947d998c") + @gateway.void('5d53a33d960c46d00f5dc061947d998c') end.respond_with(failed_void_response) assert_failure response @@ -176,7 +176,7 @@ def test_successful_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "2762757839#creditcard", response.authorization + assert_equal '2762757839#creditcard', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -193,7 +193,7 @@ def test_successful_refund def test_failed_refund response = stub_comms do - @gateway.refund(nil, "") + @gateway.refund(nil, '') end.respond_with(failed_refund_response) assert_failure response @@ -215,7 +215,7 @@ def test_successful_credit assert_success response - assert_equal "2762828010#creditcard", response.authorization + assert_equal '2762828010#creditcard', response.authorization assert response.test? end @@ -226,7 +226,7 @@ def test_failed_credit assert_failure response assert response.test? - assert_match "Invalid Credit Card", response.message + assert_match 'Invalid Credit Card', response.message end def test_successful_verify @@ -243,7 +243,7 @@ def test_successful_verify end.respond_with(successful_validate_response) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_verify @@ -252,7 +252,7 @@ def test_failed_verify end.respond_with(failed_validate_response) assert_failure response - assert_match "Invalid Credit Card", response.message + assert_match 'Invalid Credit Card', response.message end def test_successful_store @@ -270,8 +270,8 @@ def test_successful_store assert_success response assert response.test? - assert_equal "Succeeded", response.message - assert response.params["customer_vault_id"] + assert_equal 'Succeeded', response.message + assert response.params['customer_vault_id'] end def test_failed_store @@ -281,7 +281,7 @@ def test_failed_store assert_failure response assert response.test? - assert_match "Invalid Credit Card", response.message + assert_match 'Invalid Credit Card', response.message end def test_successful_store_with_echeck @@ -302,8 +302,8 @@ def test_successful_store_with_echeck assert_success response assert response.test? - assert_equal "Succeeded", response.message - assert response.params["customer_vault_id"] + assert_equal 'Succeeded', response.message + assert response.params['customer_vault_id'] end def test_avs_result @@ -342,7 +342,7 @@ def test_blank_cvv_not_sent assert_no_match(%r{cvv}, data) end.respond_with(successful_purchase_response) - @credit_card.verification_value = " " + @credit_card.verification_value = ' ' stub_comms do @gateway.purchase(@amount, @credit_card) end.check_request do |endpoint, data, headers| diff --git a/test/unit/gateways/ogone_test.rb b/test/unit/gateways/ogone_test.rb index f3f241ba32b..3118e4b7193 100644 --- a/test/unit/gateways/ogone_test.rb +++ b/test/unit/gateways/ogone_test.rb @@ -12,10 +12,10 @@ def setup @gateway = OgoneGateway.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" + @identification = '3014726' + @billing_id = 'myalias' @options = { :order_id => '1', :billing_address => address, @@ -34,7 +34,7 @@ def setup @parameters_d3d = { 'FLAG3D' => 'Y', 'WIN3DS' => 'MAINW', - 'HTTP_ACCEPT' => "*/*" + 'HTTP_ACCEPT' => '*/*' } end @@ -145,7 +145,7 @@ def test_successful_authorize_with_3dsecure def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - assert response = @gateway.capture(@amount, "3048326") + assert response = @gateway.capture(@amount, '3048326') assert_success response assert_equal '3048326;SAL', response.authorization assert response.test? @@ -153,7 +153,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? @@ -161,7 +161,7 @@ def test_successful_capture_with_action_option def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) - assert response = @gateway.void("3048606") + assert response = @gateway.void('3048606') assert_success response assert_equal '3048606;DES', response.authorization assert response.test? @@ -170,7 +170,7 @@ def test_successful_void def test_deprecated_credit @gateway.expects(:ssl_post).returns(successful_referenced_credit_response) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - assert response = @gateway.credit(@amount, "3049652;SAL") + assert response = @gateway.credit(@amount, '3049652;SAL') assert_success response assert_equal '3049652;RFD', response.authorization assert response.test? @@ -181,13 +181,13 @@ def test_successful_unreferenced_credit @gateway.expects(:ssl_post).returns(successful_unreferenced_credit_response) assert response = @gateway.credit(@amount, @credit_card) assert_success response - assert_equal "3049654;RFD", response.authorization + assert_equal '3049654;RFD', response.authorization assert response.test? end def test_successful_refund @gateway.expects(:ssl_post).returns(successful_referenced_credit_response) - assert response = @gateway.refund(@amount, "3049652") + assert response = @gateway.refund(@amount, '3049652') assert_success response assert_equal '3049652;RFD', response.authorization assert response.test? @@ -197,14 +197,14 @@ def test_successful_verify @gateway.expects(:ssl_post).times(2).returns(successful_authorize_response).then.returns(successful_void_response) assert response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "The transaction was successful", response.message + assert_equal 'The transaction was successful', response.message end def test_failed_verify @gateway.expects(:ssl_post).returns(failed_authorization_response) assert response = @gateway.verify(@credit_card, @options) assert_failure response - assert_equal "Unknown order", response.message + assert_equal 'Unknown order', response.message end def test_successful_store @@ -251,7 +251,7 @@ def test_create_readable_error_message_upon_failure assert_failure response assert response.test? - assert_equal "Unknown order", response.message + assert_equal 'Unknown order', response.message end def test_supported_countries @@ -328,19 +328,19 @@ def test_test_mode def test_format_error_message_with_slash_separator @gateway.expects(:ssl_post).returns('<ncresponse NCERRORPLUS="unknown order/1/i/67.192.100.64" STATUS="0" />') assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal "Unknown order", response.message + assert_equal 'Unknown order', response.message end def test_format_error_message_with_pipe_separator @gateway.expects(:ssl_post).returns('<ncresponse NCERRORPLUS=" no card no|no exp date|no brand" STATUS="0" />') assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal "No card no, no exp date, no brand", response.message + assert_equal 'No card no, no exp date, no brand', response.message end def test_format_error_message_with_no_separator @gateway.expects(:ssl_post).returns('<ncresponse NCERRORPLUS=" unknown order " STATUS="0" />') assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal "Unknown order", response.message + assert_equal 'Unknown order', response.message end def test_without_signature @@ -350,7 +350,7 @@ def test_without_signature gateway.purchase(@amount, @credit_card, @options) end - gateway = OgoneGateway.new(@credentials.merge(:signature => nil, :signature_encryptor => "none")) + gateway = OgoneGateway.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) @@ -360,7 +360,7 @@ def test_without_signature def test_signature_for_accounts_created_before_10_may_20101 gateway = OgoneGateway.new(@credentials.merge(:signature_encryptor => nil)) assert signature = gateway.send(:add_signature, @parameters) - assert_equal Digest::SHA1.hexdigest("1100EUR4111111111111111MrPSPIDRES2mynicesig").upcase, signature + assert_equal Digest::SHA1.hexdigest('1100EUR4111111111111111MrPSPIDRES2mynicesig').upcase, signature end def test_signature_for_accounts_with_signature_encryptor_to_sha1 @@ -394,13 +394,13 @@ def test_3dsecure_win_3ds_option gateway = OgoneGateway.new(@credentials) gateway.send(:add_d3d, post, { :win_3ds => :pop_up }) - assert 'POPUP', post["WIN3DS"] + assert 'POPUP', post['WIN3DS'] gateway.send(:add_d3d, post, { :win_3ds => :pop_ix }) - assert 'POPIX', post["WIN3DS"] + assert 'POPIX', post['WIN3DS'] gateway.send(:add_d3d, post, { :win_3ds => :invalid }) - assert 'MAINW', post["WIN3DS"] + assert 'MAINW', post['WIN3DS'] end def test_3dsecure_additional_options @@ -408,8 +408,8 @@ def test_3dsecure_additional_options gateway = OgoneGateway.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)", + :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', @@ -419,8 +419,8 @@ def test_3dsecure_additional_options :complus => 'com_plus', :language => 'fr_FR' }) - assert_equal post['HTTP_ACCEPT'], "text/html" - assert_equal post['HTTP_USER_AGENT'], "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" + assert_equal post['HTTP_ACCEPT'], 'text/html' + assert_equal post['HTTP_USER_AGENT'], 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)' assert_equal post['ACCEPTURL'], 'https://accept_url' assert_equal post['DECLINEURL'], 'https://decline_url' assert_equal post['EXCEPTIONURL'], 'https://exception_url' @@ -453,16 +453,16 @@ def test_transcript_scrubbing private def string_to_digest - "ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig"+ - "CN=Client NamemynicesigCURRENCY=EURmynicesigOPERATION=RESmynicesig"+ - "ORDERID=1mynicesigPSPID=MrPSPIDmynicesig" + 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'+ + 'CN=Client NamemynicesigCURRENCY=EURmynicesigOPERATION=RESmynicesig'+ + 'ORDERID=1mynicesigPSPID=MrPSPIDmynicesig' end def d3d_string_to_digest - "ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig"+ - "CN=Client NamemynicesigCURRENCY=EURmynicesigFLAG3D=Ymynicesig"+ - "HTTP_ACCEPT=*/*mynicesigOPERATION=RESmynicesigORDERID=1mynicesig"+ - "PSPID=MrPSPIDmynicesigWIN3DS=MAINWmynicesig" + 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'+ + 'CN=Client NamemynicesigCURRENCY=EURmynicesigFLAG3D=Ymynicesig'+ + 'HTTP_ACCEPT=*/*mynicesigOPERATION=RESmynicesigORDERID=1mynicesig'+ + 'PSPID=MrPSPIDmynicesigWIN3DS=MAINWmynicesig' end def successful_authorize_response diff --git a/test/unit/gateways/omise_test.rb b/test/unit/gateways/omise_test.rb index fbf75054d7a..52eb9cd22e0 100644 --- a/test/unit/gateways/omise_test.rb +++ b/test/unit/gateways/omise_test.rb @@ -51,24 +51,24 @@ def test_request_headers def test_post_data post_data = @gateway.send(:post_data, { card: {number: '4242424242424242'} }) - assert_equal "{\"card\":{\"number\":\"4242424242424242\"}}", post_data + assert_equal '{"card":{"number":"4242424242424242"}}', post_data end def test_parse_response response = @gateway.send(:parse, successful_purchase_response) - assert(response.key?('object'), "expect json response has object key") + assert(response.key?('object'), 'expect json response has object key') end def test_successful_response response = @gateway.send(:parse, successful_purchase_response) success = @gateway.send(:successful?, response) - assert(success, "expect success to be true") + assert(success, 'expect success to be true') end def test_error_response response = @gateway.send(:parse, error_response) success = @gateway.send(:successful?, response) - assert(!success, "expect success to be false") + assert(!success, 'expect success to be false') end def test_error_code_from diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb index e3306dfe71e..c955eb75d1e 100644 --- a/test/unit/gateways/opp_test.rb +++ b/test/unit/gateways/opp_test.rb @@ -7,8 +7,8 @@ def setup @gateway = OppGateway.new(fixtures(:opp)) @amount = 100 - @valid_card = credit_card("4200000000000000", month: 05, year: 2018, verification_value: '123') - @invalid_card = credit_card("4444444444444444", month: 05, year: 2018, verification_value: '123') + @valid_card = credit_card('4200000000000000', month: 05, year: 2018, verification_value: '123') + @invalid_card = credit_card('4444444444444444', month: 05, year: 2018, verification_value: '123') request_type = 'complete' # 'minimal' || 'complete' time = Time.now.to_i @@ -60,8 +60,8 @@ def setup @complete_request_options['customParameters[SHOPPER_test124TestName009]'] = 'customParameters_test' @complete_request_options['customParameters[SHOPPER_otherCustomerParameter]'] = 'otherCustomerParameter_test' - @test_success_id = "8a82944a4e008ca9014e1273e0696122" - @test_failure_id = "8a8294494e0078a6014e12b371fb6a8e" + @test_success_id = '8a82944a4e008ca9014e1273e0696122' + @test_failure_id = '8a8294494e0078a6014e12b371fb6a8e' @options = @minimal_request_options if request_type == 'minimal' @options = @complete_request_options if request_type == 'complete' @@ -71,7 +71,7 @@ def setup def test_successful_purchase @gateway.expects(:raw_ssl_request).returns(successful_response('DB', @test_success_id)) response = @gateway.purchase(@amount, @valid_card, @options) - assert_success response, "Failed purchase" + assert_success response, 'Failed purchase' assert_equal @test_success_id, response.authorization assert response.test? end @@ -79,7 +79,7 @@ def test_successful_purchase def test_successful_authorize @gateway.expects(:raw_ssl_request).returns(successful_response('PA', @test_success_id)) response = @gateway.authorize(@amount, @valid_card, @options) - assert_success response, "Authorization Failed" + assert_success response, 'Authorization Failed' assert_equal @test_success_id, response.authorization assert response.test? end @@ -87,12 +87,12 @@ def test_successful_authorize def test_successful_capture @gateway.expects(:raw_ssl_request).returns(successful_response('PA', @test_success_id)) auth = @gateway.authorize(@amount, @valid_card, @options) - assert_success auth, "Authorization Failed" + assert_success auth, 'Authorization Failed' assert_equal @test_success_id, auth.authorization assert auth.test? @gateway.expects(:raw_ssl_request).returns(successful_response('CP', @test_success_id)) capt = @gateway.capture(@amount, auth.authorization, @options) - assert_success capt, "Capture failed" + assert_success capt, 'Capture failed' assert_equal @test_success_id, capt.authorization assert capt.test? end @@ -100,11 +100,11 @@ def test_successful_capture def test_successful_refund @gateway.expects(:raw_ssl_request).returns(successful_response('DB', @test_success_id)) purchase = @gateway.purchase(@amount, @valid_card, @options) - assert_success purchase, "Purchase failed" + assert_success purchase, 'Purchase failed' assert purchase.test? @gateway.expects(:raw_ssl_request).returns(successful_response('RF', @test_success_id)) refund = @gateway.refund(@amount, purchase.authorization, @options) - assert_success refund, "Refund failed" + assert_success refund, 'Refund failed' assert_equal @test_success_id, refund.authorization assert refund.test? end @@ -112,11 +112,11 @@ def test_successful_refund def test_successful_void @gateway.expects(:raw_ssl_request).returns(successful_response('DB', @test_success_id)) purchase = @gateway.purchase(@amount, @valid_card, @options) - assert_success purchase, "Purchase failed" + assert_success purchase, 'Purchase failed' assert purchase.test? @gateway.expects(:raw_ssl_request).returns(successful_response('RV', @test_success_id)) void = @gateway.void(purchase.authorization, @options) - assert_success void, "Void failed" + assert_success void, 'Void failed' assert_equal @test_success_id, void.authorization assert void.test? end @@ -158,7 +158,7 @@ def test_failed_void end def test_passes_3d_secure_fields - options = @complete_request_options.merge({eci: "eci", cavv: "cavv", xid: "xid"}) + options = @complete_request_options.merge({eci: 'eci', cavv: 'cavv', xid: 'xid'}) response = stub_comms(@gateway, :raw_ssl_request) do @gateway.purchase(@amount, @valid_card, options) @@ -179,27 +179,27 @@ def test_scrub private def pre_scrubbed - "paymentType=DB&amount=1.00&currency=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=4200000000000000&card.expiryMonth=05&card.expiryYear=2018& card.cvv=123&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=8a8294174b7ecb28014b9699220015ca&authentication.password=sy6KJsT8&authentication.userId=8a8294174b7ecb28014b9699220015cc" + 'paymentType=DB&amount=1.00&currency=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=4200000000000000&card.expiryMonth=05&card.expiryYear=2018& card.cvv=123&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=8a8294174b7ecb28014b9699220015ca&authentication.password=sy6KJsT8&authentication.userId=8a8294174b7ecb28014b9699220015cc' end def post_scrubbed - "paymentType=DB&amount=1.00&currency=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=[FILTERED]&card.expiryMonth=05&card.expiryYear=2018& card.cvv=[FILTERED]&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=8a8294174b7ecb28014b9699220015ca&authentication.password=[FILTERED]&authentication.userId=8a8294174b7ecb28014b9699220015cc" + 'paymentType=DB&amount=1.00&currency=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=[FILTERED]&card.expiryMonth=05&card.expiryYear=2018& card.cvv=[FILTERED]&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=8a8294174b7ecb28014b9699220015ca&authentication.password=[FILTERED]&authentication.userId=8a8294174b7ecb28014b9699220015cc' end def successful_response(type, id) OppMockResponse.new(200, - JSON.generate({"id" => id,"paymentType" => type,"paymentBrand" => "VISA","amount" => "1.00","currency" => "EUR","des - criptor" => "5410.9959.0306 OPP_Channel ","result" => {"code" => "000.100.110","description" => "Request successfully processed in 'Merchant in Integrator Test Mode'"},"card" => {"bin - " => "420000","last4Digits" => "0000","holder" => "Longbob Longsen","expiryMonth" => "05","expiryYear" => "2018"},"buildNumber" => "20150618-111601.r185004.opp-tags-20150618_stage","time - stamp" => "2015-06-20 19:31:01+0000","ndc" => "8a8294174b7ecb28014b9699220015ca_4453edbc001f405da557c05cb3c3add9"}) + JSON.generate({'id' => id,'paymentType' => type,'paymentBrand' => 'VISA','amount' => '1.00','currency' => 'EUR',"des + criptor" => '5410.9959.0306 OPP_Channel ','result' => {'code' => '000.100.110','description' => "Request successfully processed in 'Merchant in Integrator Test Mode'"},'card' => {"bin + " => '420000','last4Digits' => '0000','holder' => 'Longbob Longsen','expiryMonth' => '05','expiryYear' => '2018'},'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage',"time + stamp" => '2015-06-20 19:31:01+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_4453edbc001f405da557c05cb3c3add9'}) ) end def failed_response(type, id, code='100.100.101') OppMockResponse.new(400, - JSON.generate({"id" => id,"paymentType" => type,"paymentBrand" => "VISA","result" => {"code" => code,"des - cription" => "invalid creditcard, bank account number or bank name"},"card" => {"bin" => "444444","last4Digits" => "4444","holder" => "Longbob Longsen","expiryMonth" => "05","expiryYear" => "2018"}, - "buildNumber" => "20150618-111601.r185004.opp-tags-20150618_stage","timestamp" => "2015-06-20 20:40:26+0000","ndc" => "8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d"}) + JSON.generate({'id' => id,'paymentType' => type,'paymentBrand' => 'VISA','result' => {'code' => code,"des + cription" => 'invalid creditcard, bank account number or bank name'},'card' => {'bin' => '444444','last4Digits' => '4444','holder' => 'Longbob Longsen','expiryMonth' => '05','expiryYear' => '2018'}, + 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage','timestamp' => '2015-06-20 20:40:26+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d'}) ) end diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb index 8b4dabe78c2..d2c255dfe61 100644 --- a/test/unit/gateways/optimal_payment_test.rb +++ b/test/unit/gateways/optimal_payment_test.rb @@ -33,7 +33,7 @@ def test_full_request def test_ip_address_is_passed stub_comms do - @gateway.purchase(@amount, @credit_card, @options.merge(ip: "1.2.3.4")) + @gateway.purchase(@amount, @credit_card, @options.merge(ip: '1.2.3.4')) end.check_request do |endpoint, data, headers| assert_match %r{customerIP%3E1.2.3.4%3C}, data end.respond_with(successful_purchase_response) @@ -72,7 +72,7 @@ def test_successful_purchase end def test_purchase_from_canada_includes_state_field - @options[:billing_address][:country] = "CA" + @options[:billing_address][:country] = 'CA' @gateway.expects(:ssl_post).with do |url, data| data =~ /state/ && data !~ /region/ end.returns(successful_purchase_response) @@ -81,7 +81,7 @@ def test_purchase_from_canada_includes_state_field end def test_purchase_from_us_includes_state_field - @options[:billing_address][:country] = "US" + @options[:billing_address][:country] = 'US' @gateway.expects(:ssl_post).with do |url, data| data =~ /state/ && data !~ /region/ end.returns(successful_purchase_response) @@ -90,7 +90,7 @@ def test_purchase_from_us_includes_state_field end def test_purchase_from_any_other_country_includes_region_field - @options[:billing_address][:country] = "GB" + @options[:billing_address][:country] = 'GB' @gateway.expects(:ssl_post).with do |url, data| data =~ /region/ && data !~ /state/ end.returns(successful_purchase_response) @@ -99,11 +99,11 @@ def test_purchase_from_any_other_country_includes_region_field end def test_purchase_with_shipping_address - @options[:shipping_address] = {:country => "CA"} + @options[:shipping_address] = {:country => 'CA'} @gateway.expects(:ssl_post).with do |url, data| - xml = data.split("&").detect{|string| string =~ /txnRequest=/}.gsub("txnRequest=","") + xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=','') doc = Nokogiri::XML.parse(CGI.unescape(xml)) - doc.xpath('//xmlns:shippingDetails/xmlns:country').first.text == "CA" && doc.to_s.include?('<shippingDetails>') + doc.xpath('//xmlns:shippingDetails/xmlns:country').first.text == 'CA' && doc.to_s.include?('<shippingDetails>') end.returns(successful_purchase_response) assert @gateway.purchase(@amount, @credit_card, @options) @@ -112,7 +112,7 @@ def test_purchase_with_shipping_address def test_purchase_without_shipping_address @options[:shipping_address] = nil @gateway.expects(:ssl_post).with do |url, data| - xml = data.split("&").detect{|string| string =~ /txnRequest=/}.gsub("txnRequest=","") + xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=','') doc = Nokogiri::XML.parse(CGI.unescape(xml)) doc.to_s.include?('<shippingDetails>') == false end.returns(successful_purchase_response) @@ -154,7 +154,7 @@ def test_cvd_fields_pass_correctly def test_successful_void @gateway.expects(:ssl_post).returns(successful_purchase_response) - assert response = @gateway.void("1234567", @options) + assert response = @gateway.void('1234567', @options) assert_instance_of Response, response assert_success response @@ -180,7 +180,7 @@ def test_in_production_with_test_param_sends_request_to_test_server :password => 'password', :test => true ) - @gateway.expects(:ssl_post).with("https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1", anything).returns(successful_purchase_response) + @gateway.expects(:ssl_post).with('https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1', anything).returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index 69ac058dab5..aac02cff291 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -12,11 +12,11 @@ def setup :password => 'password', :merchant_id => 'merchant_id' ) - @customer_ref_num = "ABC" + @customer_ref_num = 'ABC' @level_2 = { - tax_indicator: "1", - tax: "10", + tax_indicator: '1', + tax: '10', advice_addendum_1: 'taa1 - test', advice_addendum_2: 'taa2 - test', advice_addendum_3: 'taa3 - test', @@ -99,13 +99,13 @@ def test_unauthenticated_response assert response = @gateway.purchase(101, credit_card, :order_id => '1') assert_instance_of Response, response assert_failure response - assert_equal "AUTH DECLINED 12001", response.message + assert_equal 'AUTH DECLINED 12001', response.message end def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) - assert response = @gateway.void("identifier") + assert response = @gateway.void('identifier') assert_instance_of Response, response assert_success response assert_nil response.message @@ -114,8 +114,8 @@ def test_successful_void def test_deprecated_void @gateway.expects(:ssl_post).returns(successful_void_response) - assert_deprecation_warning("Calling the void method with an amount parameter is deprecated and will be removed in a future version.") do - assert response = @gateway.void(50, "identifier") + assert_deprecation_warning('Calling the void method with an amount parameter is deprecated and will be removed in a future version.') do + assert response = @gateway.void(50, 'identifier') assert_instance_of Response, response assert_success response assert_nil response.message @@ -137,7 +137,7 @@ def test_order_id_as_number def test_order_id_format response = stub_comms do - @gateway.purchase(101, credit_card, :order_id => " #101.23,56 $Hi &thére@Friends") + @gateway.purchase(101, credit_card, :order_id => ' #101.23,56 $Hi &thére@Friends') end.check_request do |endpoint, data, headers| assert_match(/<OrderID>101-23,56 \$Hi &amp;thre@Fr<\/OrderID>/, data) end.respond_with(successful_purchase_response) @@ -146,7 +146,7 @@ def test_order_id_format def test_order_id_format_for_capture response = stub_comms do - @gateway.capture(101, "4A5398CF9B87744GG84A1D30F2F2321C66249416;1001.1", :order_id => "#1001.1") + @gateway.capture(101, '4A5398CF9B87744GG84A1D30F2F2321C66249416;1001.1', :order_id => '#1001.1') end.check_request do |endpoint, data, headers| assert_match(/<OrderID>1001-1<\/OrderID>/, data) end.respond_with(successful_purchase_response) @@ -154,7 +154,7 @@ def test_order_id_format_for_capture end def test_expiry_date - year = (DateTime.now + 1.year).strftime("%y") + year = (DateTime.now + 1.year).strftime('%y') assert_equal "09#{year}", @gateway.send(:expiry_date, credit_card) end @@ -377,7 +377,7 @@ def test_default_managed_billing response = stub_comms do assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do assert_deprecation_warning do - @gateway.add_customer_profile(credit_card, :managed_billing => {:start_date => "10-10-2014" }) + @gateway.add_customer_profile(credit_card, :managed_billing => {:start_date => '10-10-2014' }) end end end.check_request do |endpoint, data, headers| @@ -393,8 +393,8 @@ def test_managed_billing response = stub_comms do assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do assert_deprecation_warning do - @gateway.add_customer_profile(credit_card, :managed_billing => {:start_date => "10-10-2014", - :end_date => "10-10-2015", + @gateway.add_customer_profile(credit_card, :managed_billing => {:start_date => '10-10-2014', + :end_date => '10-10-2015', :max_dollar_value => 1500, :max_transactions => 12}) end @@ -553,7 +553,7 @@ def test_american_requests_adhere_to_xml_schema schema_file = File.read("#{File.dirname(__FILE__)}/../../schema/orbital/Request_PTI54.xsd") doc = Nokogiri::XML(data) xsd = Nokogiri::XML::Schema(schema_file) - assert xsd.valid?(doc), "Request does not adhere to DTD" + assert xsd.valid?(doc), 'Request does not adhere to DTD' end.respond_with(successful_purchase_response) assert_success response end @@ -565,7 +565,7 @@ def test_german_requests_adhere_to_xml_schema schema_file = File.read("#{File.dirname(__FILE__)}/../../schema/orbital/Request_PTI54.xsd") doc = Nokogiri::XML(data) xsd = Nokogiri::XML::Schema(schema_file) - assert xsd.valid?(doc), "Request does not adhere to DTD" + assert xsd.valid?(doc), 'Request does not adhere to DTD' end.respond_with(successful_purchase_response) assert_success response end @@ -633,7 +633,7 @@ def test_delete_customer_profile end def test_attempts_seconday_url - @gateway.expects(:ssl_post).with(OrbitalGateway.test_url, anything, anything).raises(ActiveMerchant::ConnectionError.new("message", nil)) + @gateway.expects(:ssl_post).with(OrbitalGateway.test_url, anything, anything).raises(ActiveMerchant::ConnectionError.new('message', nil)) @gateway.expects(:ssl_post).with(OrbitalGateway.secondary_test_url, anything, anything).returns(successful_purchase_response) response = @gateway.purchase(50, credit_card, :order_id => '1') @@ -703,7 +703,7 @@ def test_successful_verify end.respond_with(successful_purchase_response, successful_purchase_response) assert_success response assert_equal '4A5398CF9B87744GG84A1D30F2F2321C66249416;1', response.authorization - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_successful_verify_and_failed_void @@ -712,7 +712,7 @@ def test_successful_verify_and_failed_void end.respond_with(successful_purchase_response, failed_purchase_response) assert_success response assert_equal '4A5398CF9B87744GG84A1D30F2F2321C66249416;1', response.authorization - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_failed_verify @@ -720,7 +720,7 @@ def test_failed_verify @gateway.verify(credit_card, @options) end.respond_with(failed_purchase_response, failed_purchase_response) assert_failure response - assert_equal "AUTH DECLINED 12001", response.message + assert_equal 'AUTH DECLINED 12001', response.message end def test_cvv_indicator_present_for_visas_with_cvvs diff --git a/test/unit/gateways/pac_net_raven_test.rb b/test/unit/gateways/pac_net_raven_test.rb index a3fd01cbab3..29d99cb9e84 100644 --- a/test/unit/gateways/pac_net_raven_test.rb +++ b/test/unit/gateways/pac_net_raven_test.rb @@ -30,14 +30,14 @@ def test_invalid_credit_card_authorization @gateway.expects(:ssl_post).returns(invalid_credit_card_response) assert response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response - assert_equal "Error processing transaction because CardNumber is not between 12 and 19 in length", response.message + assert_equal 'Error processing transaction because CardNumber is not between 12 and 19 in length', response.message end def test_expired_credit_card_authorization @gateway.expects(:ssl_post).returns(expired_credit_card_response) assert response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response - assert_equal "Invalid because the card expiry date is not a date in the future", response.message + assert_equal 'Invalid because the card expiry date is not a date in the future', response.message end def test_declined_authorization @@ -87,14 +87,14 @@ def test_invalid_credit_card_number_purchese @gateway.expects(:ssl_post).returns(invalid_credit_card_response) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Error processing transaction because CardNumber is not between 12 and 19 in length", response.message + assert_equal 'Error processing transaction because CardNumber is not between 12 and 19 in length', response.message end def test_expired_credit_card_purchese @gateway.expects(:ssl_post).returns(expired_credit_card_response) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Invalid because the card expiry date is not a date in the future", response.message + assert_equal 'Invalid because the card expiry date is not a date in the future', response.message end def test_declined_purchese @@ -146,14 +146,14 @@ def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) assert response = @gateway.void('123456789') assert_success response - assert_equal "This transaction has been voided", response.message + assert_equal 'This transaction has been voided', response.message end def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) assert response = @gateway.void('123456789') assert_failure response - assert_equal "Error processing transaction because the payment may not be voided", response.message + assert_equal 'Error processing transaction because the payment may not be voided', response.message end def test_argument_error_prn @@ -180,7 +180,7 @@ def test_argument_error_secret def test_add_address result = {} @gateway.send(:add_address, result, :billing_address => {:address1 => 'Address 1', :address2 => 'Address 2', :zip => 'ZIP'} ) - assert_equal ["BillingPostalCode", "BillingStreetAddressLineFour", "BillingStreetAddressLineOne"], result.stringify_keys.keys.sort + assert_equal ['BillingPostalCode', 'BillingStreetAddressLineFour', 'BillingStreetAddressLineOne'], result.stringify_keys.keys.sort assert_equal 'ZIP', result['BillingPostalCode'] assert_equal 'Address 2', result['BillingStreetAddressLineFour'] assert_equal 'Address 1', result['BillingStreetAddressLineOne'] @@ -189,7 +189,7 @@ def test_add_address def test_add_creditcard result = {} @gateway.send(:add_creditcard, result, @credit_card) - assert_equal ["CVV2", "CardNumber", "Expiry"], result.stringify_keys.keys.sort + assert_equal ['CVV2', 'CardNumber', 'Expiry'], result.stringify_keys.keys.sort assert_equal @credit_card.number, result['CardNumber'] assert_equal @gateway.send(:expdate, @credit_card), result['Expiry'] assert_equal @credit_card.verification_value, result['CVV2'] @@ -208,7 +208,7 @@ def test_add_currency_code_from_options end def test_parse - result = @gateway.send(:parse, "key1=value1&key2=value2") + result = @gateway.send(:parse, 'key1=value1&key2=value2') h = {'key1' => 'value1', 'key2' => 'value2'} assert_equal h, result end @@ -306,36 +306,36 @@ def test_success end def test_message_from_approved - assert_equal "This transaction has been approved", @gateway.send(:message_from, { + assert_equal 'This transaction has been approved', @gateway.send(:message_from, { 'Status' => 'Approved', 'Message'=> nil }) end def test_message_from_declined - assert_equal "This transaction has been declined", @gateway.send(:message_from, { + assert_equal 'This transaction has been declined', @gateway.send(:message_from, { 'Status' => 'Declined', 'Message'=> nil }) end def test_message_from_voided - assert_equal "This transaction has been voided", @gateway.send(:message_from, { + assert_equal 'This transaction has been voided', @gateway.send(:message_from, { 'Status' => 'Voided', 'Message'=> nil }) end def test_message_from_status - assert_equal "This is the message", @gateway.send(:message_from, { + assert_equal 'This is the message', @gateway.send(:message_from, { 'Status' => 'SomeStatus', - 'Message'=> "This is the message" + 'Message'=> 'This is the message' }) end def test_post_data - @gateway.stubs(:request_id => "wouykiikdvqbwwxueppby") - @gateway.stubs(:timestamp => "2013-10-08T14:31:54.Z") + @gateway.stubs(:request_id => 'wouykiikdvqbwwxueppby') + @gateway.stubs(:timestamp => '2013-10-08T14:31:54.Z') assert_equal "PymtType=cc_preauth&RAPIVersion=2&UserName=user&Timestamp=2013-10-08T14%3A31%3A54.Z&RequestID=wouykiikdvqbwwxueppby&Signature=7794efc8c0d39f0983edc10f778e6143ba13531d&CardNumber=4242424242424242&Expiry=09#{@credit_card.year.to_s[-2..-1]}&CVV2=123&Currency=USD&BillingStreetAddressLineOne=Address+1&BillingStreetAddressLineFour=Address+2&BillingPostalCode=ZIP123", @gateway.send(:post_data, 'cc_preauth', { @@ -416,7 +416,7 @@ def test_signature_for_void_action def test_expdate @credit_card.year = 2015 @credit_card.month = 9 - assert_equal "0915", @gateway.send(:expdate, @credit_card) + assert_equal '0915', @gateway.send(:expdate, @credit_card) end private diff --git a/test/unit/gateways/pagarme_test.rb b/test/unit/gateways/pagarme_test.rb index c874d7ccd37..4b12bb2739d 100644 --- a/test/unit/gateways/pagarme_test.rb +++ b/test/unit/gateways/pagarme_test.rb @@ -31,14 +31,14 @@ def test_successful_purchase assert_success response assert_equal 427312, response.authorization - assert_equal @amount, response.params["amount"] + assert_equal @amount, response.params['amount'] - assert_equal @credit_card.name, response.params["card"]["holder_name"] - assert_equal @credit_card.last_digits, response.params["card"]["last_digits"] - assert_equal @credit_card.brand, response.params["card"]["brand"] + assert_equal @credit_card.name, response.params['card']['holder_name'] + assert_equal @credit_card.last_digits, response.params['card']['last_digits'] + assert_equal @credit_card.brand, response.params['card']['brand'] - assert_equal 'credit_card', response.params["payment_method"] - assert_equal 'paid', response.params["status"] + assert_equal 'credit_card', response.params['payment_method'] + assert_equal 'paid', response.params['status'] assert_equal 'Transação aprovada', response.message assert response.test? end @@ -50,7 +50,7 @@ def test_failed_purchase assert_failure response assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code - assert_equal 'refused', response.params["status"] + assert_equal 'refused', response.params['status'] assert_equal 'Transação recusada', response.message end @@ -62,14 +62,14 @@ def test_successful_authorize assert_success response assert_equal 429356, response.authorization - assert_equal @amount, response.params["amount"] + assert_equal @amount, response.params['amount'] - assert_equal @credit_card.name, response.params["card"]["holder_name"] - assert_equal @credit_card.last_digits, response.params["card"]["last_digits"] - assert_equal @credit_card.brand, response.params["card"]["brand"] + assert_equal @credit_card.name, response.params['card']['holder_name'] + assert_equal @credit_card.last_digits, response.params['card']['last_digits'] + assert_equal @credit_card.brand, response.params['card']['brand'] - assert_equal 'credit_card', response.params["payment_method"] - assert_equal 'authorized', response.params["status"] + assert_equal 'credit_card', response.params['payment_method'] + assert_equal 'authorized', response.params['status'] assert_equal 'Transação autorizada', response.message assert response.test? end @@ -81,7 +81,7 @@ def test_failed_authorize assert_failure response assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code - assert_equal 'refused', response.params["status"] + assert_equal 'refused', response.params['status'] assert_equal 'Transação recusada', response.message end @@ -93,14 +93,14 @@ def test_successful_capture assert_success response assert_equal 429356, response.authorization - assert_equal @amount, response.params["amount"] + assert_equal @amount, response.params['amount'] - assert_equal @credit_card.name, response.params["card"]["holder_name"] - assert_equal @credit_card.last_digits, response.params["card"]["last_digits"] - assert_equal @credit_card.brand, response.params["card"]["brand"] + assert_equal @credit_card.name, response.params['card']['holder_name'] + assert_equal @credit_card.last_digits, response.params['card']['last_digits'] + assert_equal @credit_card.brand, response.params['card']['brand'] - assert_equal 'credit_card', response.params["payment_method"] - assert_equal 'paid', response.params["status"] + assert_equal 'credit_card', response.params['payment_method'] + assert_equal 'paid', response.params['status'] assert_equal 'Transação aprovada', response.message assert response.test? end @@ -124,8 +124,8 @@ def test_successful_refund assert_equal 429356, response.authorization - assert_equal 'credit_card', response.params["payment_method"] - assert_equal 'refunded', response.params["status"] + assert_equal 'credit_card', response.params['payment_method'] + assert_equal 'refunded', response.params['status'] assert_equal 'Transação estornada', response.message assert response.test? end @@ -149,8 +149,8 @@ def test_successful_void assert_equal 472218, response.authorization - assert_equal 'credit_card', response.params["payment_method"] - assert_equal 'refunded', response.params["status"] + assert_equal 'credit_card', response.params['payment_method'] + assert_equal 'refunded', response.params['status'] assert_equal 'Transação estornada', response.message assert response.test? end @@ -166,7 +166,7 @@ def test_failed_void end def test_successful_verify - s = sequence("request") + s = sequence('request') @gateway.expects(:ssl_request).returns(successful_verify_response).in_sequence(s) @gateway.expects(:ssl_request).returns(successful_verify_void_response).in_sequence(s) @@ -174,25 +174,25 @@ def test_successful_verify assert_instance_of MultiResponse, response assert_success response - assert_equal 127, response.params["amount"] + assert_equal 127, response.params['amount'] - assert_equal @credit_card.name, response.params["card"]["holder_name"] - assert_equal @credit_card.last_digits, response.params["card"]["last_digits"] - assert_equal @credit_card.brand, response.params["card"]["brand"] + assert_equal @credit_card.name, response.params['card']['holder_name'] + assert_equal @credit_card.last_digits, response.params['card']['last_digits'] + assert_equal @credit_card.brand, response.params['card']['brand'] - assert_equal 'credit_card', response.params["payment_method"] - assert_equal 'authorized', response.params["status"] + assert_equal 'credit_card', response.params['payment_method'] + assert_equal 'authorized', response.params['status'] assert_equal 'Transação autorizada', response.message assert_success response.responses[1] - assert_equal 'refunded', response.responses[1].params["status"] + assert_equal 'refunded', response.responses[1].params['status'] assert_equal 'Transação estornada', response.responses[1].message assert response.test? end def test_successful_verify_with_failed_void - s = sequence("request") + s = sequence('request') @gateway.expects(:ssl_request).returns(successful_verify_response).in_sequence(s) @gateway.expects(:ssl_request).returns(failed_void_response).in_sequence(s) @@ -200,14 +200,14 @@ def test_successful_verify_with_failed_void assert_instance_of MultiResponse, response assert_success response - assert_equal 127, response.params["amount"] + assert_equal 127, response.params['amount'] - assert_equal @credit_card.name, response.params["card"]["holder_name"] - assert_equal @credit_card.last_digits, response.params["card"]["last_digits"] - assert_equal @credit_card.brand, response.params["card"]["brand"] + assert_equal @credit_card.name, response.params['card']['holder_name'] + assert_equal @credit_card.last_digits, response.params['card']['last_digits'] + assert_equal @credit_card.brand, response.params['card']['brand'] - assert_equal 'credit_card', response.params["payment_method"] - assert_equal 'authorized', response.params["status"] + assert_equal 'credit_card', response.params['payment_method'] + assert_equal 'authorized', response.params['status'] assert_equal 'Transação autorizada', response.message assert_failure response.responses[1] @@ -222,8 +222,8 @@ def test_failed_verify assert_failure response assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code - assert_equal 127, response.params["amount"] - assert_equal 'refused', response.params["status"] + assert_equal 127, response.params['amount'] + assert_equal 'refused', response.params['status'] assert_equal 'Transação recusada', response.message end @@ -243,7 +243,7 @@ def test_failed_json_body assert_failure response assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code - assert response.message.start_with?("Resposta inválida") + assert response.message.start_with?('Resposta inválida') end def test_scrub diff --git a/test/unit/gateways/pago_facil_test.rb b/test/unit/gateways/pago_facil_test.rb index 539a8434717..cb75a847402 100644 --- a/test/unit/gateways/pago_facil_test.rb +++ b/test/unit/gateways/pago_facil_test.rb @@ -36,8 +36,8 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "305638", response.authorization - assert_equal "Transaction has been successful!-Approved", response.message + assert_equal '305638', response.authorization + assert_equal 'Transaction has been successful!-Approved', response.message assert response.test? end @@ -46,8 +46,8 @@ def test_successful_purchase_amex response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "305638", response.authorization - assert_equal "Transaction has been successful!-Approved", response.message + assert_equal '305638', response.authorization + assert_equal 'Transaction has been successful!-Approved', response.message assert response.test? end @@ -70,156 +70,156 @@ def test_invalid_json private def successful_purchase_response - {"WebServices_Transacciones"=> - {"transaccion"=> - {"autorizado"=>"1", - "autorizacion"=>"305638", - "transaccion"=>"S-PFE12S12I12568", - "texto"=>"Transaction has been successful!-Approved", - "mode"=>"R", - "empresa"=>"Usuario Invitado", - "TransIni"=>"15:33:18 pm 25/02/2014", - "TransFin"=>"15:33:27 pm 25/02/2014", - "param1"=>"", - "param2"=>"", - "param3"=>"", - "param4"=>"", - "param5"=>"", - "TipoTC"=>"Visa", - "data"=> - {"anyoExpiracion"=>"(2) **", - "apellidos"=>"Reyes Garza", - "calleyNumero"=>"Anatole France 311", - "celular"=>"5550123456", - "colonia"=>"Polanco", - "cp"=>"11560", - "cvt"=>"(3) ***", - "email"=>"comprador@correo.com", - "estado"=>"Distrito Federal", - "idPedido"=>"1", - "idServicio"=>"3", - "idSucursal"=>"60f961360ca187d533d5adba7d969d6334771370", - "idUsuario"=>"62ad6f592ecf2faa87ef2437ed85a4d175e73c58", - "mesExpiracion"=>"(2) **", - "monto"=>"1.00", - "municipio"=>"Miguel Hidalgo", - "nombre"=>"Juan", - "numeroTarjeta"=>"(16) **** **** ****1111", - "pais"=>"Mexico", - "telefono"=>"5550220910", - "transFechaHora"=>"1393363998", - "bin"=>"(6) ***1"}, - "dataVal"=> - {"idSucursal"=>"12", - "cp"=>"11560", - "nombre"=>"Juan", - "apellidos"=>"Reyes Garza", - "numeroTarjeta"=>"(16) **** **** ****1111", - "cvt"=>"(3) ***", - "monto"=>"1.00", - "mesExpiracion"=>"(2) **", - "anyoExpiracion"=>"(2) **", - "idUsuario"=>"14", - "source"=>"1", - "idServicio"=>"3", - "recurrente"=>"0", - "plan"=>"NOR", - "diferenciado"=>"00", - "mensualidades"=>"00", - "ip"=>"187.162.238.170", - "httpUserAgent"=>"Ruby", - "idPedido"=>"1", - "tipoTarjeta"=>"Visa", - "hashKeyCC"=>"e5be0afe08f125ec4f6f1251141c60df88d65eae", - "idEmpresa"=>"12", - "nombre_comercial"=>"Usuario Invitado", - "transFechaHora"=>"1393363998", - "noProcess"=>"", - "noMail"=>"", - "notaMail"=>"", - "settingsTransaction"=> - {"noMontoMes"=>"0.00", - "noTransaccionesDia"=>"0", - "minTransaccionTc"=>"5", - "tiempoDevolucion"=>"30", - "sendPdfTransCliente"=>"1", - "noMontoDia"=>"0.00", - "noTransaccionesMes"=>"0"}, - "email"=>"comprador@correo.com", - "telefono"=>"5550220910", - "celular"=>"5550123456", - "calleyNumero"=>"Anatole France 311", - "colonia"=>"Polanco", - "municipio"=>"Miguel Hidalgo", - "estado"=>"Distrito Federal", - "pais"=>"Mexico", - "idCaja"=>"", - "paisDetectedIP"=>"MX", - "qa"=>"1", - "https"=>"on"}, - "status"=>"success" + {'WebServices_Transacciones'=> + {'transaccion'=> + {'autorizado'=>'1', + 'autorizacion'=>'305638', + 'transaccion'=>'S-PFE12S12I12568', + 'texto'=>'Transaction has been successful!-Approved', + 'mode'=>'R', + 'empresa'=>'Usuario Invitado', + 'TransIni'=>'15:33:18 pm 25/02/2014', + 'TransFin'=>'15:33:27 pm 25/02/2014', + 'param1'=>'', + 'param2'=>'', + 'param3'=>'', + 'param4'=>'', + 'param5'=>'', + 'TipoTC'=>'Visa', + 'data'=> + {'anyoExpiracion'=>'(2) **', + 'apellidos'=>'Reyes Garza', + 'calleyNumero'=>'Anatole France 311', + 'celular'=>'5550123456', + 'colonia'=>'Polanco', + 'cp'=>'11560', + 'cvt'=>'(3) ***', + 'email'=>'comprador@correo.com', + 'estado'=>'Distrito Federal', + 'idPedido'=>'1', + 'idServicio'=>'3', + 'idSucursal'=>'60f961360ca187d533d5adba7d969d6334771370', + 'idUsuario'=>'62ad6f592ecf2faa87ef2437ed85a4d175e73c58', + 'mesExpiracion'=>'(2) **', + 'monto'=>'1.00', + 'municipio'=>'Miguel Hidalgo', + 'nombre'=>'Juan', + 'numeroTarjeta'=>'(16) **** **** ****1111', + 'pais'=>'Mexico', + 'telefono'=>'5550220910', + 'transFechaHora'=>'1393363998', + 'bin'=>'(6) ***1'}, + 'dataVal'=> + {'idSucursal'=>'12', + 'cp'=>'11560', + 'nombre'=>'Juan', + 'apellidos'=>'Reyes Garza', + 'numeroTarjeta'=>'(16) **** **** ****1111', + 'cvt'=>'(3) ***', + 'monto'=>'1.00', + 'mesExpiracion'=>'(2) **', + 'anyoExpiracion'=>'(2) **', + 'idUsuario'=>'14', + 'source'=>'1', + 'idServicio'=>'3', + 'recurrente'=>'0', + 'plan'=>'NOR', + 'diferenciado'=>'00', + 'mensualidades'=>'00', + 'ip'=>'187.162.238.170', + 'httpUserAgent'=>'Ruby', + 'idPedido'=>'1', + 'tipoTarjeta'=>'Visa', + 'hashKeyCC'=>'e5be0afe08f125ec4f6f1251141c60df88d65eae', + 'idEmpresa'=>'12', + 'nombre_comercial'=>'Usuario Invitado', + 'transFechaHora'=>'1393363998', + 'noProcess'=>'', + 'noMail'=>'', + 'notaMail'=>'', + 'settingsTransaction'=> + {'noMontoMes'=>'0.00', + 'noTransaccionesDia'=>'0', + 'minTransaccionTc'=>'5', + 'tiempoDevolucion'=>'30', + 'sendPdfTransCliente'=>'1', + 'noMontoDia'=>'0.00', + 'noTransaccionesMes'=>'0'}, + 'email'=>'comprador@correo.com', + 'telefono'=>'5550220910', + 'celular'=>'5550123456', + 'calleyNumero'=>'Anatole France 311', + 'colonia'=>'Polanco', + 'municipio'=>'Miguel Hidalgo', + 'estado'=>'Distrito Federal', + 'pais'=>'Mexico', + 'idCaja'=>'', + 'paisDetectedIP'=>'MX', + 'qa'=>'1', + 'https'=>'on'}, + 'status'=>'success' } } }.to_json end def failed_purchase_response - {"WebServices_Transacciones"=> - {"transaccion"=> - {"autorizado"=>"0", - "transaccion"=>"n/a", - "autorizacion"=>"n/a", - "texto"=>"Errores en los datos de entrada Validaciones", - "error"=> - {"numeroTarjeta"=>"'1111111111111111' no es de una institucion permitida"}, - "empresa"=>"Sin determinar", - "TransIni"=>"16:10:20 pm 25/02/2014", - "TransFin"=>"16:10:20 pm 25/02/2014", - "param1"=>"", - "param2"=>"", - "param3"=>"", - "param4"=>"", - "param5"=>"", - "TipoTC"=>"", - "data"=> - {"anyoExpiracion"=>"(2) **", - "apellidos"=>"Reyes Garza", - "calleyNumero"=>"Anatole France 311", - "celular"=>"5550123456", - "colonia"=>"Polanco", - "cp"=>"11560", - "cvt"=>"(3) ***", - "email"=>"comprador@correo.com", - "estado"=>"Distrito Federal", - "idPedido"=>"1", - "idServicio"=>"3", - "idSucursal"=>"60f961360ca187d533d5adba7d969d6334771370", - "idUsuario"=>"62ad6f592ecf2faa87ef2437ed85a4d175e73c58", - "mesExpiracion"=>"(2) **", - "monto"=>"1.00", - "municipio"=>"Miguel Hidalgo", - "nombre"=>"Juan", - "numeroTarjeta"=>"(16) **** **** ****1111", - "pais"=>"Mexico", - "telefono"=>"5550220910", - "transFechaHora"=>"1393366220", - "bin"=>"(6) ***1"}, - "dataVal"=> - {"email"=>"comprador@correo.com", - "telefono"=>"5550220910", - "celular"=>"5550123456", - "calleyNumero"=>"Anatole France 311", - "colonia"=>"Polanco", - "municipio"=>"Miguel Hidalgo", - "estado"=>"Distrito Federal", - "pais"=>"Mexico", - "idCaja"=>"", - "numeroTarjeta"=>"", - "cvt"=>"", - "anyoExpiracion"=>"", - "mesExpiracion"=>"", - "https"=>"on"}, - "status"=>"success" + {'WebServices_Transacciones'=> + {'transaccion'=> + {'autorizado'=>'0', + 'transaccion'=>'n/a', + 'autorizacion'=>'n/a', + 'texto'=>'Errores en los datos de entrada Validaciones', + 'error'=> + {'numeroTarjeta'=>"'1111111111111111' no es de una institucion permitida"}, + 'empresa'=>'Sin determinar', + 'TransIni'=>'16:10:20 pm 25/02/2014', + 'TransFin'=>'16:10:20 pm 25/02/2014', + 'param1'=>'', + 'param2'=>'', + 'param3'=>'', + 'param4'=>'', + 'param5'=>'', + 'TipoTC'=>'', + 'data'=> + {'anyoExpiracion'=>'(2) **', + 'apellidos'=>'Reyes Garza', + 'calleyNumero'=>'Anatole France 311', + 'celular'=>'5550123456', + 'colonia'=>'Polanco', + 'cp'=>'11560', + 'cvt'=>'(3) ***', + 'email'=>'comprador@correo.com', + 'estado'=>'Distrito Federal', + 'idPedido'=>'1', + 'idServicio'=>'3', + 'idSucursal'=>'60f961360ca187d533d5adba7d969d6334771370', + 'idUsuario'=>'62ad6f592ecf2faa87ef2437ed85a4d175e73c58', + 'mesExpiracion'=>'(2) **', + 'monto'=>'1.00', + 'municipio'=>'Miguel Hidalgo', + 'nombre'=>'Juan', + 'numeroTarjeta'=>'(16) **** **** ****1111', + 'pais'=>'Mexico', + 'telefono'=>'5550220910', + 'transFechaHora'=>'1393366220', + 'bin'=>'(6) ***1'}, + 'dataVal'=> + {'email'=>'comprador@correo.com', + 'telefono'=>'5550220910', + 'celular'=>'5550123456', + 'calleyNumero'=>'Anatole France 311', + 'colonia'=>'Polanco', + 'municipio'=>'Miguel Hidalgo', + 'estado'=>'Distrito Federal', + 'pais'=>'Mexico', + 'idCaja'=>'', + 'numeroTarjeta'=>'', + 'cvt'=>'', + 'anyoExpiracion'=>'', + 'mesExpiracion'=>'', + 'https'=>'on'}, + 'status'=>'success' } } }.to_json @@ -232,8 +232,8 @@ def invalid_json_response def successful_purchase_response_amex response = JSON.parse(successful_purchase_response) response. - fetch("WebServices_Transacciones"). - fetch("transaccion")["autorizado"] = true + fetch('WebServices_Transacciones'). + fetch('transaccion')['autorizado'] = true response.to_json end end diff --git a/test/unit/gateways/pay_conex_test.rb b/test/unit/gateways/pay_conex_test.rb index fd4a43b6648..0269f29396d 100644 --- a/test/unit/gateways/pay_conex_test.rb +++ b/test/unit/gateways/pay_conex_test.rb @@ -21,7 +21,7 @@ def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "000000001681", response.authorization + assert_equal '000000001681', response.authorization assert response.test? end @@ -30,19 +30,19 @@ def test_failed_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal 30002, response.params["error_code"] + assert_equal 30002, response.params['error_code'] end def test_successful_authorize_and_capture @gateway.expects(:ssl_post).returns(successful_authorize_response) response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "000000001721", response.authorization + assert_equal '000000001721', response.authorization @gateway.expects(:ssl_post).returns(successful_capture_response) response = @gateway.capture(@amount, response.authorization) assert_success response - assert_equal "CAPTURED", response.message + assert_equal 'CAPTURED', response.message end def test_failed_authorize @@ -50,66 +50,66 @@ def test_failed_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response - assert_equal 30002, response.params["error_code"] - assert_equal "DECLINED", response.message + assert_equal 30002, response.params['error_code'] + assert_equal 'DECLINED', response.message end def test_failed_capture @gateway.expects(:ssl_post).returns(failed_capture_response) - response = @gateway.capture(@amount, "Authorization") + response = @gateway.capture(@amount, 'Authorization') assert_failure response - assert_equal 20006, response.params["error_code"] - assert_equal "Invalid token_id", response.message + assert_equal 20006, response.params['error_code'] + assert_equal 'Invalid token_id', response.message end def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - response = @gateway.refund(@amount, "Authorization") + response = @gateway.refund(@amount, 'Authorization') assert_success response - assert_equal "000000001801", response.authorization - assert_equal "VOID", response.message + assert_equal '000000001801', response.authorization + assert_equal 'VOID', response.message end def test_failed_refund @gateway.expects(:ssl_post).returns(failed_refund_response) - response = @gateway.refund(@amount, "Authorization") + response = @gateway.refund(@amount, 'Authorization') assert_failure response - assert_equal 20017, response.params["error_code"] - assert_equal "INVALID REFUND AMOUNT", response.message + assert_equal 20017, response.params['error_code'] + assert_equal 'INVALID REFUND AMOUNT', response.message end def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) - response = @gateway.void("Authorization") + response = @gateway.void('Authorization') assert_success response - assert_equal "000000001881", response.authorization - assert_equal "APPROVED", response.message + assert_equal '000000001881', response.authorization + assert_equal 'APPROVED', response.message end def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) - response = @gateway.refund(@amount, "Authorization") + response = @gateway.refund(@amount, 'Authorization') assert_failure response - assert_equal 20687, response.params["error_code"] - assert_equal "TRANSACTION ID ALREADY REVERSED", response.message + assert_equal 20687, response.params['error_code'] + assert_equal 'TRANSACTION ID ALREADY REVERSED', response.message end def test_successful_verify @gateway.expects(:ssl_post).returns(successful_verify_response) response = @gateway.verify(@credit_card) assert_success response - assert_equal "000000001981", response.authorization - assert_equal "APPROVED", response.message + assert_equal '000000001981', response.authorization + assert_equal 'APPROVED', response.message end def test_successful_credit @gateway.expects(:ssl_post).returns(successful_credit_response) response = @gateway.credit(@amount, @credit_card) assert_success response - assert_equal "000000002061", response.authorization + assert_equal '000000002061', response.authorization end def test_failed_credit @@ -117,15 +117,15 @@ def test_failed_credit response = @gateway.authorize(@amount, @credit_card) assert_failure response - assert_equal "30370", response.params["error_code"] - assert_equal "CARD DATA UNREADABLE", response.message + assert_equal '30370', response.params['error_code'] + assert_equal 'CARD DATA UNREADABLE', response.message end def test_successful_store @gateway.expects(:ssl_post).returns(successful_store_response) response = @gateway.store(@credit_card) assert_success response - assert_equal "000000002101", response.authorization + assert_equal '000000002101', response.authorization end def test_failed_store @@ -133,8 +133,8 @@ def test_failed_store response = @gateway.store(@credit_card) assert_failure response - assert_equal "30370", response.params["error_code"] - assert_equal "CARD DATA UNREADABLE", response.message + assert_equal '30370', response.params['error_code'] + assert_equal 'CARD DATA UNREADABLE', response.message end def test_card_present_purchase_passes_track_data @@ -147,23 +147,23 @@ def test_card_present_purchase_passes_track_data def test_successful_purchase_using_token @gateway.expects(:ssl_post).returns(successful_purchase_using_token_response) - response = @gateway.purchase(@amount, "TheToken", @options) + response = @gateway.purchase(@amount, 'TheToken', @options) assert_success response - assert_equal "000000004561", response.authorization + assert_equal '000000004561', response.authorization end def test_successful_purchase_using_echeck @gateway.expects(:ssl_post).returns(successful_purchase_using_echeck_response) response = @gateway.purchase(@amount, check, @options) assert_success response - assert_equal "000000007161", response.authorization + assert_equal '000000007161', response.authorization end def test_failed_purchase_using_echeck @gateway.expects(:ssl_post).returns(failed_purchase_using_echeck_response) response = @gateway.purchase(@amount, check, @options) assert_failure response - assert_equal "Invalid bank_routing_number", response.message + assert_equal 'Invalid bank_routing_number', response.message end def test_scrub diff --git a/test/unit/gateways/pay_hub_test.rb b/test/unit/gateways/pay_hub_test.rb index 1666bce5bf5..0226cea3ec0 100644 --- a/test/unit/gateways/pay_hub_test.rb +++ b/test/unit/gateways/pay_hub_test.rb @@ -3,9 +3,9 @@ class PayHubTest < Test::Unit::TestCase def setup @gateway = PayHubGateway.new( - orgid: "123456", - username: "abc123DEF", - password: "abc123DEF", + orgid: '123456', + username: 'abc123DEF', + password: 'abc123DEF', tid: '123' ) @credit_card = credit_card @@ -31,7 +31,7 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert response.test? - assert_equal "SUCCESS", response.message + assert_equal 'SUCCESS', response.message end def test_successful_purchase_without_options @@ -39,7 +39,7 @@ def test_successful_purchase_without_options response = @gateway.purchase(@amount, @credit_card) assert_success response - assert_equal "SUCCESS", response.message + assert_equal 'SUCCESS', response.message end def test_successful_authorize @@ -47,7 +47,7 @@ def test_successful_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "SUCCESS", response.message + assert_equal 'SUCCESS', response.message end def test_successful_capture @@ -56,7 +56,7 @@ def test_successful_capture response = @gateway.capture(@amount, 123) assert_success response - assert_equal "TRANSACTION CAPTURED SUCCESSFULLY", response.message + assert_equal 'TRANSACTION CAPTURED SUCCESSFULLY', response.message end def test_unsuccessful_capture @@ -65,7 +65,7 @@ def test_unsuccessful_capture response = @gateway.capture(amount, 123) assert_failure response - assert_equal "UNABLE TO CAPTURE", response.message + assert_equal 'UNABLE TO CAPTURE', response.message end def test_successful_settled_refund @@ -74,7 +74,7 @@ def test_successful_settled_refund response = @gateway.refund(@amount, 123) assert_success response - assert_equal "SUCCESS", response.message + assert_equal 'SUCCESS', response.message end def test_successful_unsettled_refund @@ -83,7 +83,7 @@ def test_successful_unsettled_refund response = @gateway.refund(@amount, 123) assert_success response - assert_equal "SUCCESS", response.message + assert_equal 'SUCCESS', response.message end def test_unsuccessful_refund @@ -92,7 +92,7 @@ def test_unsuccessful_refund assert response = @gateway.refund(@amount, 123) assert_failure response - assert_equal "Unable to refund the previous transaction.", response.message + assert_equal 'Unable to refund the previous transaction.', response.message end def test_invalid_raw_response diff --git a/test/unit/gateways/pay_junction_test.rb b/test/unit/gateways/pay_junction_test.rb index be3c9713169..1a94fd2a77b 100644 --- a/test/unit/gateways/pay_junction_test.rb +++ b/test/unit/gateways/pay_junction_test.rb @@ -8,8 +8,8 @@ def setup Base.mode = :test @gateway = PayJunctionGateway.new( - :login => "pj-ql-01", - :password => "pj-ql-01p" + :login => 'pj-ql-01', + :password => 'pj-ql-01p' ) @credit_card = credit_card @@ -25,14 +25,14 @@ def test_detect_test_credentials_when_in_production Base.mode = :production live_gw = PayJunctionGateway.new( - :login => "l", - :password => "p" + :login => 'l', + :password => 'p' ) assert_false live_gw.test? test_gw = PayJunctionGateway.new( - :login => "pj-ql-01", - :password => "pj-ql-01p" + :login => 'pj-ql-01', + :password => 'pj-ql-01p' ) assert test_gw.test? end @@ -53,7 +53,7 @@ def test_failed_authorization def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - response = @gateway.refund(@amount, "123") + response = @gateway.refund(@amount, '123') assert_success response assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message end @@ -61,7 +61,7 @@ def test_successful_refund def test_successful_deprecated_credit @gateway.expects(:ssl_post).returns(successful_refund_response) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - response = @gateway.credit(@amount, "123") + response = @gateway.credit(@amount, '123') assert_success response assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message end @@ -82,11 +82,11 @@ def test_cvv_result_not_supported end def test_add_creditcard_with_track_data - @credit_card.track_data = "Tracking data" + @credit_card.track_data = 'Tracking data' stub_comms do @gateway.authorize(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| - assert_match "dc_track=Tracking+data", data + assert_match 'dc_track=Tracking+data', data assert_no_match(/dc_name=/, data) assert_no_match(/dc_number=/, data) assert_no_match(/dc_expiration_month=/, data) diff --git a/test/unit/gateways/pay_junction_v2_test.rb b/test/unit/gateways/pay_junction_v2_test.rb index b6231e6a178..99a40a808ec 100644 --- a/test/unit/gateways/pay_junction_v2_test.rb +++ b/test/unit/gateways/pay_junction_v2_test.rb @@ -102,7 +102,7 @@ def test_successful_credit response = @gateway.credit(@amount, @credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_failed_credit @@ -115,7 +115,7 @@ def test_failed_credit amount = 0 response = @gateway.credit(amount, @credit_card, @options) assert_failure response - assert_equal "Amount Base must be greater than 0.|", response.message + assert_equal 'Amount Base must be greater than 0.|', response.message end def test_successful_void @@ -148,7 +148,7 @@ def test_successful_verify response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_successful_verify_with_failed_void @@ -161,7 +161,7 @@ def test_successful_verify_with_failed_void response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_failed_verify @@ -185,7 +185,7 @@ def test_successful_store_and_purchase response = @gateway.store(@credit_card, @options) assert_success response assert response.authorization - assert_equal "Approved", response.message + assert_equal 'Approved', response.message response = @gateway.purchase(@amount, response.authorization, @options) assert_success response diff --git a/test/unit/gateways/paybox_direct_test.rb b/test/unit/gateways/paybox_direct_test.rb index 5ff7e8817b3..23ec8124b59 100644 --- a/test/unit/gateways/paybox_direct_test.rb +++ b/test/unit/gateways/paybox_direct_test.rb @@ -32,7 +32,7 @@ def test_successful_purchase # Replace with authorization number from the successful response assert_equal response.params['numappel'].to_s + response.params['numtrans'], response.authorization assert_equal 'XXXXXX', response.params['autorisation'] - assert_equal "The transaction was approved", response.message + assert_equal 'The transaction was approved', response.message assert response.test? end @@ -55,10 +55,10 @@ def test_purchase_with_set_currency end def test_deprecated_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/NUMAPPEL=transid/), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/NUMAPPEL=transid/), anything).returns('') @gateway.expects(:parse).returns({}) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - @gateway.credit(@amount, "transid", @options) + @gateway.credit(@amount, 'transid', @options) end end @@ -66,10 +66,10 @@ def test_refund @gateway.expects(:ssl_post).with(anything) do |_, body| body.include?('NUMAPPEL=transid') body.include?('MONTANT=0000000100&DEVISE=97') - end.returns("") + end.returns('') @gateway.expects(:parse).returns({}) - @gateway.refund(@amount, "transid", @options) + @gateway.refund(@amount, 'transid', @options) end def test_unsuccessful_request @@ -77,12 +77,12 @@ def test_unsuccessful_request assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Demande trait?e avec succ?s ✔漢", response.message + assert_equal 'Demande trait?e avec succ?s ✔漢', response.message assert response.test? end def test_keep_the_card_code_not_considered_fraudulent - @gateway.expects(:ssl_post).returns(purchase_response("00104")) + @gateway.expects(:ssl_post).returns(purchase_response('00104')) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response @@ -90,7 +90,7 @@ def test_keep_the_card_code_not_considered_fraudulent end def test_do_not_honour_code_not_considered_fraudulent - @gateway.expects(:ssl_post).returns(purchase_response("00105")) + @gateway.expects(:ssl_post).returns(purchase_response('00105')) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response @@ -98,7 +98,7 @@ def test_do_not_honour_code_not_considered_fraudulent end def test_card_absent_from_file_code_not_considered_fraudulent - @gateway.expects(:ssl_post).returns(purchase_response("00156")) + @gateway.expects(:ssl_post).returns(purchase_response('00156')) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response @@ -113,7 +113,7 @@ def test_version private # Place raw successful response from gateway here - def purchase_response(code="00000") + def purchase_response(code='00000') "NUMTRANS=0720248861&NUMAPPEL=0713790302&NUMQUESTION=0000790217&SITE=1999888&RANG=99&AUTORISATION=XXXXXX&CODEREPONSE=#{code}&COMMENTAIRE=Demande trait?e avec succ?s ✔漢" end diff --git a/test/unit/gateways/payeezy_test.rb b/test/unit/gateways/payeezy_test.rb index b6b73fad994..08319f927f4 100644 --- a/test/unit/gateways/payeezy_test.rb +++ b/test/unit/gateways/payeezy_test.rb @@ -15,7 +15,7 @@ def setup :billing_address => address, :ta_token => '123' } - @authorization = "ET1700|106625152|credit_card|4738" + @authorization = 'ET1700|106625152|credit_card|4738' end def test_invalid_credentials @@ -120,7 +120,7 @@ def test_failed_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response assert_failure response - assert_equal response.error_code, "card_expired" + assert_equal response.error_code, 'card_expired' end def test_successful_authorize @@ -141,7 +141,7 @@ def test_failed_authorize def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - assert response = @gateway.capture(@amount, "ET156862|69601979|credit_card|100") + assert response = @gateway.capture(@amount, 'ET156862|69601979|credit_card|100') assert_success response assert_equal 'ET176427|69601874|credit_card|100', response.authorization assert response.test? @@ -150,7 +150,7 @@ def test_successful_capture def test_failed_capture @gateway.expects(:ssl_post).raises(failed_capture_response) - assert response = @gateway.capture(@amount, "") + assert response = @gateway.capture(@amount, '') assert_instance_of Response, response assert_failure response end @@ -205,8 +205,8 @@ def test_invalid_transaction_tag assert response = @gateway.capture(@amount, @authorization) assert_instance_of Response, response assert_failure response - assert_equal response.error_code, "server_error" - assert_equal response.message, "ProcessedBad Request (69) - Invalid Transaction Tag" + assert_equal response.error_code, 'server_error' + assert_equal response.message, 'ProcessedBad Request (69) - Invalid Transaction Tag' end def test_supported_countries diff --git a/test/unit/gateways/payex_test.rb b/test/unit/gateways/payex_test.rb index deafad22def..c948304954a 100644 --- a/test/unit/gateways/payex_test.rb +++ b/test/unit/gateways/payex_test.rb @@ -72,7 +72,7 @@ def test_successful_void def test_unsuccessful_void @gateway.expects(:ssl_post).returns(unsuccessful_void_response) - assert response = @gateway.void("1") + assert response = @gateway.void('1') assert_failure response assert_not_equal 'OK', response.message assert_match %r{1}, response.message @@ -89,7 +89,7 @@ def test_successful_refund def test_unsuccessful_refund @gateway.expects(:ssl_post).returns(unsuccessful_refund_response) - assert response = @gateway.refund(@amount, "1", order_id: '123') + assert response = @gateway.refund(@amount, '1', order_id: '123') assert_failure response assert_not_equal 'OK', response.message assert_match %r{1}, response.message diff --git a/test/unit/gateways/payflow_express_test.rb b/test/unit/gateways/payflow_express_test.rb index 2486752caf1..719fd885117 100644 --- a/test/unit/gateways/payflow_express_test.rb +++ b/test/unit/gateways/payflow_express_test.rb @@ -118,7 +118,7 @@ def test_get_express_details end def test_get_express_details_with_invalid_xml - @gateway.expects(:ssl_post).returns(successful_get_express_details_response(:street => "Main & Magic")) + @gateway.expects(:ssl_post).returns(successful_get_express_details_response(:street => 'Main & Magic')) response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV') assert_instance_of PayflowExpressResponse, response assert_success response @@ -137,7 +137,7 @@ def test_button_source private - def successful_get_express_details_response(options={:street => "111 Main St."}) + def successful_get_express_details_response(options={:street => '111 Main St.'}) <<-RESPONSE <XMLPayResponse xmlns='http://www.verisign.com/XMLPay'> <ResponseData> diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb index 119f2d4cc7d..b85956a69b5 100644 --- a/test/unit/gateways/payflow_test.rb +++ b/test/unit/gateways/payflow_test.rb @@ -13,7 +13,7 @@ def setup @amount = 100 @credit_card = credit_card('4242424242424242') - @options = { :billing_address => address.merge(:first_name => "Longbob", :last_name => "Longsen") } + @options = { :billing_address => address.merge(:first_name => 'Longbob', :last_name => 'Longsen') } @check = check( :name => 'Jim Smith' ) end @@ -21,10 +21,10 @@ def test_successful_authorization @gateway.stubs(:ssl_post).returns(successful_authorization_response) assert response = @gateway.authorize(@amount, @credit_card, @options) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? - assert_equal "VUJN1A6E11D9", response.authorization + assert_equal 'VUJN1A6E11D9', response.authorization refute response.fraud_review? end @@ -32,7 +32,7 @@ def test_failed_authorization @gateway.stubs(:ssl_post).returns(failed_authorization_response) assert response = @gateway.authorize(@amount, @credit_card, @options) - assert_equal "Declined", response.message + assert_equal 'Declined', response.message assert_failure response assert response.test? end @@ -43,21 +43,21 @@ def test_authorization_with_three_d_secure_option end.check_request do |endpoint, data, headers| assert_three_d_secure REXML::Document.new(data), authorize_buyer_auth_result_path end.respond_with(successful_authorization_response) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? - assert_equal "VUJN1A6E11D9", response.authorization + assert_equal 'VUJN1A6E11D9', response.authorization refute response.fraud_review? end def test_successful_authorization_with_more_options options = @options.merge( { - order_id: "123", - description: "Description string", - order_desc: "OrderDesc string", - comment: "Comment string", - comment2: "Comment2 string" + order_id: '123', + description: 'Description string', + order_desc: 'OrderDesc string', + comment: 'Comment string', + comment2: 'Comment2 string' } ) @@ -70,10 +70,10 @@ def test_successful_authorization_with_more_options assert_match %r(<Comment>Comment string</Comment>), data assert_match %r(<ExtData Name=\"COMMENT2\" Value=\"Comment2 string\"/>), data end.respond_with(successful_authorization_response) - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_success response assert response.test? - assert_equal "VUJN1A6E11D9", response.authorization + assert_equal 'VUJN1A6E11D9', response.authorization refute response.fraud_review? end @@ -82,7 +82,7 @@ def test_successful_purchase_with_fraud_review assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "126", response.params["result"] + assert_equal '126', response.params['result'] assert response.fraud_review? end @@ -93,28 +93,28 @@ def test_successful_purchase_with_three_d_secure_option assert_three_d_secure REXML::Document.new(data), purchase_buyer_auth_result_path end.respond_with(successful_purchase_with_fraud_review_response) assert_success response - assert_equal "126", response.params["result"] + assert_equal '126', response.params['result'] assert response.fraud_review? end def test_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/<CardNum>#{@credit_card.number}<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<CardNum>#{@credit_card.number}<\//), anything).returns('') @gateway.expects(:parse).returns({}) @gateway.credit(@amount, @credit_card, @options) end def test_deprecated_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/<PNRef>transaction_id<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<PNRef>transaction_id<\//), anything).returns('') @gateway.expects(:parse).returns({}) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - @gateway.credit(@amount, "transaction_id", @options) + @gateway.credit(@amount, 'transaction_id', @options) end end def test_refund - @gateway.expects(:ssl_post).with(anything, regexp_matches(/<PNRef>transaction_id<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<PNRef>transaction_id<\//), anything).returns('') @gateway.expects(:parse).returns({}) - @gateway.refund(@amount, "transaction_id", @options) + @gateway.refund(@amount, 'transaction_id', @options) end def test_avs_result @@ -143,13 +143,13 @@ def test_cvv_result end def test_ach_purchase - @gateway.expects(:ssl_post).with(anything, regexp_matches(/<AcctNum>#{@check.account_number}<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<AcctNum>#{@check.account_number}<\//), anything).returns('') @gateway.expects(:parse).returns({}) @gateway.purchase(@amount, @check) end def test_ach_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/<AcctNum>#{@check.account_number}<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<AcctNum>#{@check.account_number}<\//), anything).returns('') @gateway.expects(:parse).returns({}) @gateway.credit(@amount, @check) end @@ -235,7 +235,7 @@ def test_unsuccessful_verify @gateway.verify(@credit_card, @options) end.respond_with(failed_authorization_response) assert_failure response - assert_equal "Declined", response.message + assert_equal 'Declined', response.message end def test_initial_recurring_transaction_missing_parameters @@ -287,42 +287,42 @@ def test_successful_recurring_action assert_success response assert_equal 'RT0000000009', response.profile_id assert response.test? - assert_equal "R7960E739F80", response.authorization + assert_equal 'R7960E739F80', response.authorization end def test_successful_recurring_modify_action @gateway.stubs(:ssl_post).returns(successful_recurring_response) response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do - @gateway.recurring(@amount, nil, :profile_id => "RT0000000009", :periodicity => :monthly) + @gateway.recurring(@amount, nil, :profile_id => 'RT0000000009', :periodicity => :monthly) end assert_instance_of PayflowResponse, response assert_success response assert_equal 'RT0000000009', response.profile_id assert response.test? - assert_equal "R7960E739F80", response.authorization + assert_equal 'R7960E739F80', response.authorization end def test_successful_recurring_modify_action_with_retry_num_days @gateway.stubs(:ssl_post).returns(successful_recurring_response) response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do - @gateway.recurring(@amount, nil, :profile_id => "RT0000000009", :retry_num_days => 3, :periodicity => :monthly) + @gateway.recurring(@amount, nil, :profile_id => 'RT0000000009', :retry_num_days => 3, :periodicity => :monthly) end assert_instance_of PayflowResponse, response assert_success response assert_equal 'RT0000000009', response.profile_id assert response.test? - assert_equal "R7960E739F80", response.authorization + assert_equal 'R7960E739F80', response.authorization end def test_falied_recurring_modify_action_with_starting_at_in_the_past @gateway.stubs(:ssl_post).returns(start_date_error_recurring_response) response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do - @gateway.recurring(@amount, nil, :profile_id => "RT0000000009", :starting_at => Date.yesterday, :periodicity => :monthly) + @gateway.recurring(@amount, nil, :profile_id => 'RT0000000009', :starting_at => Date.yesterday, :periodicity => :monthly) end assert_instance_of PayflowResponse, response @@ -330,14 +330,14 @@ def test_falied_recurring_modify_action_with_starting_at_in_the_past assert_equal 'RT0000000009', response.profile_id assert_equal 'Field format error: START or NEXTPAYMENTDATE older than last payment date', response.message assert response.test? - assert_equal "R7960E739F80", response.authorization + assert_equal 'R7960E739F80', response.authorization end def test_falied_recurring_modify_action_with_starting_at_missing_and_changed_periodicity @gateway.stubs(:ssl_post).returns(start_date_missing_recurring_response) response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do - @gateway.recurring(@amount, nil, :profile_id => "RT0000000009", :periodicity => :yearly) + @gateway.recurring(@amount, nil, :profile_id => 'RT0000000009', :periodicity => :yearly) end assert_instance_of PayflowResponse, response @@ -345,7 +345,7 @@ def test_falied_recurring_modify_action_with_starting_at_missing_and_changed_per assert_equal 'RT0000000009', response.profile_id assert_equal 'Field format error: START field missing', response.message assert response.test? - assert_equal "R7960E739F80", response.authorization + assert_equal 'R7960E739F80', response.authorization end def test_recurring_profile_payment_history_inquiry @@ -366,8 +366,8 @@ def test_recurring_profile_payment_history_inquiry_contains_the_proper_xml def test_format_issue_number xml = Builder::XmlMarkup.new - credit_card = credit_card("5641820000000005", - :brand => "switch", + credit_card = credit_card('5641820000000005', + :brand => 'switch', :issue_number => 1 ) @@ -379,8 +379,8 @@ def test_format_issue_number def test_add_credit_card_with_three_d_secure xml = Builder::XmlMarkup.new - credit_card = credit_card("5641820000000005", - :brand => "switch", + credit_card = credit_card('5641820000000005', + :brand => 'switch', :issue_number => 1 ) diff --git a/test/unit/gateways/payment_express_test.rb b/test/unit/gateways/payment_express_test.rb index f892ab3f715..5b8b9dfbebe 100644 --- a/test/unit/gateways/payment_express_test.rb +++ b/test/unit/gateways/payment_express_test.rb @@ -11,7 +11,7 @@ def setup @visa = credit_card - @solo = credit_card("6334900000000005", :brand => "solo", :issue_number => '01') + @solo = credit_card('6334900000000005', :brand => 'solo', :issue_number => '01') @options = { :order_id => generate_unique_id, @@ -74,9 +74,9 @@ def test_successful_card_store end def test_successful_card_store_with_custom_billing_id - @gateway.expects(:ssl_post).returns(successful_store_response(:billing_id => "my-custom-id")) + @gateway.expects(:ssl_post).returns(successful_store_response(:billing_id => 'my-custom-id')) - assert response = @gateway.store(@visa, :billing_id => "my-custom-id") + assert response = @gateway.store(@visa, :billing_id => 'my-custom-id') assert_success response assert response.test? assert_equal 'my-custom-id', response.token @@ -158,9 +158,9 @@ def test_expect_no_optional_fields_by_default def test_pass_optional_txn_data options = { - :txn_data1 => "Transaction Data 1", - :txn_data2 => "Transaction Data 2", - :txn_data3 => "Transaction Data 3" + :txn_data1 => 'Transaction Data 1', + :txn_data2 => 'Transaction Data 2', + :txn_data3 => 'Transaction Data 3' } perform_each_transaction_type_with_request_body_assertions(options) do |body| @@ -172,12 +172,12 @@ def test_pass_optional_txn_data def test_pass_optional_txn_data_truncated_to_255_chars options = { - :txn_data1 => "Transaction Data 1-01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345-EXTRA", - :txn_data2 => "Transaction Data 2-01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345-EXTRA", - :txn_data3 => "Transaction Data 3-01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345-EXTRA" + :txn_data1 => 'Transaction Data 1-01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345-EXTRA', + :txn_data2 => 'Transaction Data 2-01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345-EXTRA', + :txn_data3 => 'Transaction Data 3-01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345-EXTRA' } - truncated_addendum = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345" + truncated_addendum = '01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345' perform_each_transaction_type_with_request_body_assertions(options) do |body| assert_match(/<TxnData1>Transaction Data 1-#{truncated_addendum}<\/TxnData1>/, body) @@ -244,7 +244,7 @@ def test_pass_client_type_as_symbol_for_unknown_type_omits_element def test_purchase_truncates_order_id_to_16_chars stub_comms do - @gateway.purchase(@amount, @visa, {:order_id => "16chars---------EXTRA"}) + @gateway.purchase(@amount, @visa, {:order_id => '16chars---------EXTRA'}) end.check_request do |endpoint, data, headers| assert_match(/<TxnId>16chars---------<\/TxnId>/, data) end.respond_with(successful_authorization_response) @@ -252,7 +252,7 @@ def test_purchase_truncates_order_id_to_16_chars def test_authorize_truncates_order_id_to_16_chars stub_comms do - @gateway.authorize(@amount, @visa, {:order_id => "16chars---------EXTRA"}) + @gateway.authorize(@amount, @visa, {:order_id => '16chars---------EXTRA'}) end.check_request do |endpoint, data, headers| assert_match(/<TxnId>16chars---------<\/TxnId>/, data) end.respond_with(successful_authorization_response) @@ -260,7 +260,7 @@ def test_authorize_truncates_order_id_to_16_chars def test_capture_truncates_order_id_to_16_chars stub_comms do - @gateway.capture(@amount, 'identification', {:order_id => "16chars---------EXTRA"}) + @gateway.capture(@amount, 'identification', {:order_id => '16chars---------EXTRA'}) end.check_request do |endpoint, data, headers| assert_match(/<TxnId>16chars---------<\/TxnId>/, data) end.respond_with(successful_authorization_response) @@ -268,7 +268,7 @@ def test_capture_truncates_order_id_to_16_chars def test_refund_truncates_order_id_to_16_chars stub_comms do - @gateway.refund(@amount, 'identification', {:description => 'refund', :order_id => "16chars---------EXTRA"}) + @gateway.refund(@amount, 'identification', {:description => 'refund', :order_id => '16chars---------EXTRA'}) end.check_request do |endpoint, data, headers| assert_match(/<TxnId>16chars---------<\/TxnId>/, data) end.respond_with(successful_authorization_response) @@ -276,7 +276,7 @@ def test_refund_truncates_order_id_to_16_chars def test_purchase_truncates_description_to_50_chars stub_comms do - @gateway.purchase(@amount, @visa, {:description => "50chars-------------------------------------------EXTRA"}) + @gateway.purchase(@amount, @visa, {:description => '50chars-------------------------------------------EXTRA'}) end.check_request do |endpoint, data, headers| assert_match(/<MerchantReference>50chars-------------------------------------------<\/MerchantReference>/, data) end.respond_with(successful_authorization_response) @@ -284,7 +284,7 @@ def test_purchase_truncates_description_to_50_chars def test_authorize_truncates_description_to_50_chars stub_comms do - @gateway.authorize(@amount, @visa, {:description => "50chars-------------------------------------------EXTRA"}) + @gateway.authorize(@amount, @visa, {:description => '50chars-------------------------------------------EXTRA'}) end.check_request do |endpoint, data, headers| assert_match(/<MerchantReference>50chars-------------------------------------------<\/MerchantReference>/, data) end.respond_with(successful_authorization_response) @@ -292,7 +292,7 @@ def test_authorize_truncates_description_to_50_chars def test_capture_truncates_description_to_50_chars stub_comms do - @gateway.capture(@amount, 'identification', {:description => "50chars-------------------------------------------EXTRA"}) + @gateway.capture(@amount, 'identification', {:description => '50chars-------------------------------------------EXTRA'}) end.check_request do |endpoint, data, headers| assert_match(/<MerchantReference>50chars-------------------------------------------<\/MerchantReference>/, data) end.respond_with(successful_authorization_response) @@ -300,7 +300,7 @@ def test_capture_truncates_description_to_50_chars def test_refund_truncates_description_to_50_chars stub_comms do - @gateway.capture(@amount, 'identification', {:description => "50chars-------------------------------------------EXTRA"}) + @gateway.capture(@amount, 'identification', {:description => '50chars-------------------------------------------EXTRA'}) end.check_request do |endpoint, data, headers| assert_match(/<MerchantReference>50chars-------------------------------------------<\/MerchantReference>/, data) end.respond_with(successful_authorization_response) @@ -336,7 +336,7 @@ def perform_each_transaction_type_with_request_body_assertions(options = {}) # refund stub_comms do - @gateway.refund(@amount, 'identification', {:description => "description"}.merge(options)) + @gateway.refund(@amount, 'identification', {:description => 'description'}.merge(options)) end.check_request do |endpoint, data, headers| yield data end.respond_with(successful_authorization_response) diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb index b5605fc63bd..05c16c6fd25 100644 --- a/test/unit/gateways/paymentez_test.rb +++ b/test/unit/gateways/paymentez_test.rb @@ -356,7 +356,7 @@ def successful_capture_response end def failed_capture_response - "{\"error\": {\"type\": \"Carrier not supported\", \"help\": \"\", \"description\": \"{}\"}}" + '{"error": {"type": "Carrier not supported", "help": "", "description": "{}"}}' end def successful_void_response diff --git a/test/unit/gateways/paymill_test.rb b/test/unit/gateways/paymill_test.rb index 7db94b84ab4..816b6198213 100644 --- a/test/unit/gateways/paymill_test.rb +++ b/test/unit/gateways/paymill_test.rb @@ -13,13 +13,13 @@ def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card) assert_success response - assert_equal "tran_c94ba7df2dae8fd55028df41173c;", response.authorization - assert_equal "Operation successful", response.message + assert_equal 'tran_c94ba7df2dae8fd55028df41173c;', response.authorization + assert_equal 'Operation successful', response.message assert_equal 20000, response.params['data']['response_code'] assert_equal 'pay_b8e6a28fc5e5e1601cdbefbaeb8a', response.params['data']['payment']['id'] assert_equal '5100', response.params['data']['payment']['last4'] - assert_nil response.cvv_result["message"] - assert_nil response.avs_result["message"] + assert_nil response.cvv_result['message'] + assert_nil response.avs_result['message'] assert response.test? end @@ -81,19 +81,19 @@ def test_successful_authorize_and_capture assert_success response assert response.test? - assert_equal "tran_4c612d5293e26d56d986eb89648c;preauth_fdf916cab73b97c4a139", response.authorization - assert_equal "Operation successful", response.message + assert_equal 'tran_4c612d5293e26d56d986eb89648c;preauth_fdf916cab73b97c4a139', response.authorization + assert_equal 'Operation successful', response.message assert_equal '0004', response.params['data']['payment']['last4'] assert_equal 20000, response.params['data']['response_code'] - assert_nil response.avs_result["message"] - assert_nil response.cvv_result["message"] + assert_nil response.avs_result['message'] + assert_nil response.cvv_result['message'] @gateway.expects(:raw_ssl_request).returns(successful_capture_response) response = @gateway.capture(@amount, response.authorization) assert_success response assert response.test? assert_equal 20000, response.params['data']['response_code'] - assert_equal "Operation successful", response.message + assert_equal 'Operation successful', response.message end def test_failed_authorize @@ -114,7 +114,7 @@ def test_successful_authorize_and_void response = @gateway.void(response.authorization) assert_success response assert response.test? - assert_equal "Transaction approved.", response.message + assert_equal 'Transaction approved.', response.message end def test_failed_capture @@ -176,7 +176,7 @@ def test_successful_store assert response = @gateway.store(@credit_card) assert_success response - assert_equal "tok_4f9a571b39bd8d0b4db5", response.authorization + assert_equal 'tok_4f9a571b39bd8d0b4db5', response.authorization assert_equal "Request successfully processed in 'Merchant in Connector Test Mode'", response.message assert response.test? end @@ -192,31 +192,31 @@ def test_failed_store_with_invalid_credit_card def test_successful_purchase_with_token @gateway.stubs(:raw_ssl_request).returns(successful_purchase_response) - assert response = @gateway.purchase(@amount, "token") + assert response = @gateway.purchase(@amount, 'token') assert_success response - assert_equal "tran_c94ba7df2dae8fd55028df41173c;", response.authorization - assert_equal "Operation successful", response.message + assert_equal 'tran_c94ba7df2dae8fd55028df41173c;', response.authorization + assert_equal 'Operation successful', response.message assert_equal 20000, response.params['data']['response_code'] assert_equal 'pay_b8e6a28fc5e5e1601cdbefbaeb8a', response.params['data']['payment']['id'] assert_equal '5100', response.params['data']['payment']['last4'] - assert_nil response.cvv_result["message"] - assert_nil response.avs_result["message"] + assert_nil response.cvv_result['message'] + assert_nil response.avs_result['message'] assert response.test? end def test_successful_authorize_with_token @gateway.stubs(:raw_ssl_request).returns(successful_authorize_response) - assert response = @gateway.authorize(@amount, "token") + assert response = @gateway.authorize(@amount, 'token') assert_success response assert response.test? - assert_equal "tran_4c612d5293e26d56d986eb89648c;preauth_fdf916cab73b97c4a139", response.authorization - assert_equal "Operation successful", response.message + assert_equal 'tran_4c612d5293e26d56d986eb89648c;preauth_fdf916cab73b97c4a139', response.authorization + assert_equal 'Operation successful', response.message assert_equal '0004', response.params['data']['payment']['last4'] assert_equal 20000, response.params['data']['response_code'] - assert_nil response.avs_result["message"] - assert_nil response.cvv_result["message"] + assert_nil response.avs_result['message'] + assert_nil response.cvv_result['message'] end def test_transcript_scrubbing @@ -751,11 +751,11 @@ def failed_capture_response end def transcript - "connection_uri=https://test-token.paymill.com?account.number=5500000000000004&account.expiry.month=09&account.expiry.year=2016&account.verification=123" + 'connection_uri=https://test-token.paymill.com?account.number=5500000000000004&account.expiry.month=09&account.expiry.year=2016&account.verification=123' end def scrubbed_transcript - "connection_uri=https://test-token.paymill.com?account.number=[FILTERED]&account.expiry.month=09&account.expiry.year=2016&account.verification=[FILTERED]" + 'connection_uri=https://test-token.paymill.com?account.number=[FILTERED]&account.expiry.month=09&account.expiry.year=2016&account.verification=[FILTERED]' end end diff --git a/test/unit/gateways/paypal_digital_goods_test.rb b/test/unit/gateways/paypal_digital_goods_test.rb index 65b1e291f55..ba8e05f12a8 100644 --- a/test/unit/gateways/paypal_digital_goods_test.rb +++ b/test/unit/gateways/paypal_digital_goods_test.rb @@ -35,42 +35,42 @@ def test_test_redirect_url def test_setup_request_invalid_requests assert_raise ArgumentError do @gateway.setup_purchase(100, - :ip => "127.0.0.1", - :description => "Test Title", - :return_url => "http://return.url", - :cancel_return_url => "http://cancel.url") + :ip => '127.0.0.1', + :description => 'Test Title', + :return_url => 'http://return.url', + :cancel_return_url => 'http://cancel.url') end assert_raise ArgumentError do @gateway.setup_purchase(100, - :ip => "127.0.0.1", - :description => "Test Title", - :return_url => "http://return.url", - :cancel_return_url => "http://cancel.url", + :ip => '127.0.0.1', + :description => 'Test Title', + :return_url => 'http://return.url', + :cancel_return_url => 'http://cancel.url', :items => [ ]) end assert_raise ArgumentError do @gateway.setup_purchase(100, - :ip => "127.0.0.1", - :description => "Test Title", - :return_url => "http://return.url", - :cancel_return_url => "http://cancel.url", + :ip => '127.0.0.1', + :description => 'Test Title', + :return_url => 'http://return.url', + :cancel_return_url => 'http://cancel.url', :items => [ Hash.new ] ) end assert_raise ArgumentError do @gateway.setup_purchase(100, - :ip => "127.0.0.1", - :description => "Test Title", - :return_url => "http://return.url", - :cancel_return_url => "http://cancel.url", - :items => [ { :name => "Charge", - :number => "1", - :quantity => "1", + :ip => '127.0.0.1', + :description => 'Test Title', + :return_url => 'http://return.url', + :cancel_return_url => 'http://cancel.url', + :items => [ { :name => 'Charge', + :number => '1', + :quantity => '1', :amount => 100, - :description => "Description", - :category => "Physical" } ] ) + :description => 'Description', + :category => 'Physical' } ] ) end end @@ -79,16 +79,16 @@ def test_build_setup_request_valid @gateway.expects(:ssl_post).returns(successful_setup_response) @gateway.setup_purchase(100, - :ip => "127.0.0.1", - :description => "Test Title", - :return_url => "http://return.url", - :cancel_return_url => "http://cancel.url", - :items => [ { :name => "Charge", - :number => "1", - :quantity => "1", + :ip => '127.0.0.1', + :description => 'Test Title', + :return_url => 'http://return.url', + :cancel_return_url => 'http://cancel.url', + :items => [ { :name => 'Charge', + :number => '1', + :quantity => '1', :amount => 100, - :description => "Description", - :category => "Digital" } ] ) + :description => 'Description', + :category => 'Digital' } ] ) end diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb index 349debe7eb5..6ac936f3023 100644 --- a/test/unit/gateways/paypal_express_test.rb +++ b/test/unit/gateways/paypal_express_test.rb @@ -104,7 +104,7 @@ def test_get_express_details end def test_express_response_missing_address - response = PaypalExpressResponse.new(true, "ok") + response = PaypalExpressResponse.new(true, 'ok') assert_nil response.address['address1'] end @@ -192,7 +192,7 @@ def test_does_not_include_callback_url_if_not_specified end def test_callback_url_is_included_if_specified_in_build_setup_request - xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, {:callback_url => "http://example.com/update_callback"})) + xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, {:callback_url => 'http://example.com/update_callback'})) assert_equal 'http://example.com/update_callback', REXML::XPath.first(xml, '//n2:CallbackURL').text end @@ -230,11 +230,11 @@ def test_does_not_include_flatrate_shipping_options_if_not_specified def test_flatrate_shipping_options_are_included_if_specified_in_build_setup_request xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, {:currency => 'AUD', :shipping_options => [ {:default => true, - :name => "first one", + :name => 'first one', :amount => 1000 }, {:default => false, - :name => "second one", + :name => 'second one', :amount => 2000 } ]})) @@ -252,12 +252,12 @@ def test_flatrate_shipping_options_are_included_if_specified_in_build_setup_requ def test_address_is_included_if_specified xml = REXML::Document.new(@gateway.send(:build_setup_request, 'Sale', 0, {:currency => 'GBP', :address => { - :name => "John Doe", - :address1 => "123 somewhere", - :city => "Townville", - :country => "Canada", - :zip => "k1l4p2", - :phone => "1231231231" + :name => 'John Doe', + :address1 => '123 somewhere', + :city => 'Townville', + :country => 'Canada', + :zip => 'k1l4p2', + :phone => '1231231231' }})) assert_equal 'John Doe', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:ShipToAddress/n2:Name').text @@ -390,7 +390,7 @@ def test_items_are_included_if_specified_in_build_sale_or_authorization_request def test_build_create_billing_agreement PaypalExpressGateway.application_id = 'ActiveMerchant_FOO' - xml = REXML::Document.new(@gateway.send(:build_create_billing_agreement_request, "ref_id")) + xml = REXML::Document.new(@gateway.send(:build_create_billing_agreement_request, 'ref_id')) assert_equal 'ref_id', REXML::XPath.first(xml, '//CreateBillingAgreementReq/CreateBillingAgreementRequest/Token').text end @@ -398,60 +398,60 @@ def test_build_create_billing_agreement def test_store @gateway.expects(:ssl_post).returns(successful_create_billing_agreement_response) - response = @gateway.store("ref_id") + response = @gateway.store('ref_id') - assert_equal "Success", response.params['ack'] - assert_equal "Success", response.message - assert_equal "B-3R788221G4476823M", response.params["billing_agreement_id"] + assert_equal 'Success', response.params['ack'] + assert_equal 'Success', response.message + assert_equal 'B-3R788221G4476823M', response.params['billing_agreement_id'] end def test_unstore_successful @gateway.expects(:ssl_post).returns(successful_cancel_billing_agreement_response) - response = @gateway.unstore("B-3RU433629T663020S") + response = @gateway.unstore('B-3RU433629T663020S') assert response.success? - assert_equal "Success", response.params['ack'] - assert_equal "Success", response.message - assert_equal "B-3RU433629T663020S", response.params["billing_agreement_id"] - assert_equal "Canceled", response.params["billing_agreement_status"] + assert_equal 'Success', response.params['ack'] + assert_equal 'Success', response.message + assert_equal 'B-3RU433629T663020S', response.params['billing_agreement_id'] + assert_equal 'Canceled', response.params['billing_agreement_status'] end def test_unstore_failed @gateway.expects(:ssl_post).returns(failed_cancel_billing_agreement_response) - response = @gateway.unstore("B-3RU433629T663020S") + response = @gateway.unstore('B-3RU433629T663020S') assert !response.success? - assert_equal "Failure", response.params['ack'] - assert_equal "Billing Agreement was cancelled", response.message - assert_equal "10201", response.params["error_codes"] + assert_equal 'Failure', response.params['ack'] + assert_equal 'Billing Agreement was cancelled', response.message + assert_equal '10201', response.params['error_codes'] end def test_agreement_details_successful @gateway.expects(:ssl_post).returns(successful_billing_agreement_details_response) - response = @gateway.agreement_details("B-6VE21702A47915521") + response = @gateway.agreement_details('B-6VE21702A47915521') assert response.success? - assert_equal "Success", response.params['ack'] - assert_equal "Success", response.message - assert_equal "B-6VE21702A47915521", response.params["billing_agreement_id"] - assert_equal "Active", response.params["billing_agreement_status"] + assert_equal 'Success', response.params['ack'] + assert_equal 'Success', response.message + assert_equal 'B-6VE21702A47915521', response.params['billing_agreement_id'] + assert_equal 'Active', response.params['billing_agreement_status'] end def test_agreement_details_failure @gateway.expects(:ssl_post).returns(failure_billing_agreement_details_response) - response = @gateway.agreement_details("bad_reference_id") + response = @gateway.agreement_details('bad_reference_id') assert !response.success? - assert_equal "Failure", response.params['ack'] - assert_equal "Billing Agreement Id or transaction Id is not valid", response.message - assert_equal "11451", response.params["error_codes"] + assert_equal 'Failure', response.params['ack'] + assert_equal 'Billing Agreement Id or transaction Id is not valid', response.message + assert_equal '11451', response.params['error_codes'] end def test_build_reference_transaction_test PaypalExpressGateway.application_id = 'ActiveMerchant_FOO' xml = REXML::Document.new(@gateway.send(:build_reference_transaction_request, 'Sale', 2000, { - :reference_id => "ref_id", + :reference_id => 'ref_id', :payment_type => 'Any', :invoice_id => 'invoice_id', :description => 'Description', @@ -478,25 +478,25 @@ def test_authorize_reference_transaction @gateway.expects(:ssl_post).returns(successful_authorize_reference_transaction_response) response = @gateway.authorize_reference_transaction(2000, { - :reference_id => "ref_id", + :reference_id => 'ref_id', :payment_type => 'Any', :invoice_id => 'invoice_id', :description => 'Description', :ip => '127.0.0.1' }) - assert_equal "Success", response.params['ack'] - assert_equal "Success", response.message - assert_equal "9R43552341412482K", response.authorization + assert_equal 'Success', response.params['ack'] + assert_equal 'Success', response.message + assert_equal '9R43552341412482K', response.authorization end def test_reference_transaction @gateway.expects(:ssl_post).returns(successful_reference_transaction_response) - response = @gateway.reference_transaction(2000, { :reference_id => "ref_id" }) + response = @gateway.reference_transaction(2000, { :reference_id => 'ref_id' }) - assert_equal "Success", response.params['ack'] - assert_equal "Success", response.message - assert_equal "9R43552341412482K", response.authorization + assert_equal 'Success', response.params['ack'] + assert_equal 'Success', response.message + assert_equal '9R43552341412482K', response.authorization end def test_reference_transaction_requires_fields @@ -511,7 +511,7 @@ def test_error_code_for_single_error :return_url => 'http://example.com', :cancel_return_url => 'http://example.com' ) - assert_equal "10736", response.params['error_codes'] + assert_equal '10736', response.params['error_codes'] end def test_ensure_only_unique_error_codes @@ -521,7 +521,7 @@ def test_ensure_only_unique_error_codes :cancel_return_url => 'http://example.com' ) - assert_equal "10736" , response.params['error_codes'] + assert_equal '10736' , response.params['error_codes'] end def test_error_codes_for_multiple_errors @@ -531,7 +531,7 @@ def test_error_codes_for_multiple_errors :cancel_return_url => 'http://example.com' ) - assert_equal ["10736", "10002"] , response.params['error_codes'].split(',') + assert_equal ['10736', '10002'] , response.params['error_codes'].split(',') end def test_allow_guest_checkout @@ -614,12 +614,12 @@ def test_structure_correct :country => 'AU', :zip => '2000', :phone => '555 5555'}, - :callback_url => "http://example.com/update_callback", + :callback_url => 'http://example.com/update_callback', :callback_timeout => 2, :callback_version => '53.0', :funding_sources => {:source => 'BML'}, :shipping_options => [{:default => true, - :name => "first one", + :name => 'first one', :amount => 10}] } diff --git a/test/unit/gateways/paypal_test.rb b/test/unit/gateways/paypal_test.rb index 906b1c9b938..0dc0926f0ca 100644 --- a/test/unit/gateways/paypal_test.rb +++ b/test/unit/gateways/paypal_test.rb @@ -156,7 +156,7 @@ def test_failed_purchase def test_descriptors_passed stub_comms do - @gateway.purchase(@amount, @credit_card, @options.merge(soft_descriptor: "Eggcellent", soft_descriptor_city: "New York")) + @gateway.purchase(@amount, @credit_card, @options.merge(soft_descriptor: 'Eggcellent', soft_descriptor_city: 'New York')) end.check_request do |endpoint, data, headers| assert_match(%r{<n2:SoftDescriptor>Eggcellent}, data) assert_match(%r{<n2:SoftDescriptorCity>New York}, data) @@ -190,10 +190,10 @@ def test_amount_style def test_paypal_timeout_error @gateway.stubs(:ssl_post).returns(paypal_timeout_error_response) response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal "SOAP-ENV:Server", response.params['faultcode'] - assert_equal "Internal error", response.params['faultstring'] - assert_equal "Timeout processing request", response.params['detail'] - assert_equal "SOAP-ENV:Server: Internal error - Timeout processing request", response.message + assert_equal 'SOAP-ENV:Server', response.params['faultcode'] + assert_equal 'Internal error', response.params['faultstring'] + assert_equal 'Timeout processing request', response.params['detail'] + assert_equal 'SOAP-ENV:Server: Internal error - Timeout processing request', response.message end def test_pem_file_accessor @@ -239,7 +239,7 @@ def test_button_source_via_credentials login: 'cody', password: 'test', pem: 'PEM', - button_source: "WOOHOO" + button_source: 'WOOHOO' ) xml = REXML::Document.new(gateway.send(:build_sale_or_authorization_request, 'Test', @amount, @credit_card, {})) @@ -252,7 +252,7 @@ def test_button_source_via_credentials_with_no_application_id login: 'cody', password: 'test', pem: 'PEM', - button_source: "WOOHOO" + button_source: 'WOOHOO' ) xml = REXML::Document.new(gateway.send(:build_sale_or_authorization_request, 'Test', @amount, @credit_card, {})) @@ -348,8 +348,8 @@ def test_fraud_review response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "SuccessWithWarning", response.params["ack"] - assert_equal "Payment Pending your review in Fraud Management Filters", response.message + assert_equal 'SuccessWithWarning', response.params['ack'] + assert_equal 'Payment Pending your review in Fraud Management Filters', response.message assert response.fraud_review? end @@ -358,7 +358,7 @@ def test_failed_capture_due_to_pending_fraud_review response = @gateway.capture(@amount, 'authorization') assert_failure response - assert_equal "Transaction must be accepted in Fraud Management Filters before capture.", response.message + assert_equal 'Transaction must be accepted in Fraud Management Filters before capture.', response.message end # This occurs when sufficient 3rd party API permissions are not present to make the call for the user @@ -366,8 +366,8 @@ def test_authentication_failed_response @gateway.expects(:ssl_post).returns(authentication_failed_response) response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "10002", response.params["error_codes"] - assert_equal "You do not have permissions to make this API call", response.message + assert_equal '10002', response.params['error_codes'] + assert_equal 'You do not have permissions to make this API call', response.message end def test_amount_format_for_jpy_currency @@ -379,7 +379,7 @@ def test_amount_format_for_jpy_currency def test_successful_create_profile @gateway.expects(:ssl_post).returns(successful_create_profile_paypal_response) response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do - @gateway.recurring(@amount, @credit_card, :description => "some description", :start_date => Time.now, :frequency => 12, :period => 'Month') + @gateway.recurring(@amount, @credit_card, :description => 'some description', :start_date => Time.now, :frequency => 12, :period => 'Month') end assert_instance_of Response, response assert response.success? @@ -391,7 +391,7 @@ def test_successful_create_profile def test_failed_create_profile @gateway.expects(:ssl_post).returns(failed_create_profile_paypal_response) response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do - @gateway.recurring(@amount, @credit_card, :description => "some description", :start_date => Time.now, :frequency => 12, :period => 'Month') + @gateway.recurring(@amount, @credit_card, :description => 'some description', :start_date => Time.now, :frequency => 12, :period => 'Month') end assert_instance_of Response, response assert !response.success? @@ -481,14 +481,14 @@ def test_mass_pay_transfer_recipient_types end.respond_with(successful_purchase_response) response = stub_comms do - @gateway.transfer 1000, 'fred@example.com', :receiver_type => "EmailAddress" + @gateway.transfer 1000, 'fred@example.com', :receiver_type => 'EmailAddress' end.check_request do |endpoint, data, headers| assert_match %r{<ReceiverType>EmailAddress</ReceiverType>}, data assert_match %r{<ReceiverEmail>fred@example\.com</ReceiverEmail>}, data end.respond_with(successful_purchase_response) response = stub_comms do - @gateway.transfer 1000, 'fred@example.com', :receiver_type => "UserID" + @gateway.transfer 1000, 'fred@example.com', :receiver_type => 'UserID' end.check_request do |endpoint, data, headers| assert_match %r{<ReceiverType>UserID</ReceiverType>}, data assert_match %r{<ReceiverID>fred@example\.com</ReceiverID>}, data @@ -500,8 +500,8 @@ def test_successful_verify @gateway.verify(@credit_card, @options) end.respond_with(successful_zero_dollar_auth_response) assert_success response - assert_equal "This card authorization verification is not a payment transaction.", response.message - assert_equal "0.00", response.params["amount"] + assert_equal 'This card authorization verification is not a payment transaction.', response.message + assert_equal '0.00', response.params['amount'] end def test_failed_verify @@ -518,8 +518,8 @@ def test_successful_verify_non_visa_mc @gateway.verify(amex_card, @options) end.respond_with(successful_one_dollar_auth_response, successful_void_response) assert_success response - assert_equal "Success", response.message - assert_equal "1.00", response.params["amount"] + assert_equal 'Success', response.message + assert_equal '1.00', response.params['amount'] end def test_successful_verify_non_visa_mc_failed_void @@ -528,8 +528,8 @@ def test_successful_verify_non_visa_mc_failed_void @gateway.verify(amex_card, @options) end.respond_with(successful_one_dollar_auth_response, failed_void_response) assert_success response - assert_equal "Success", response.message - assert_equal "1.00", response.params["amount"] + assert_equal 'Success', response.message + assert_equal '1.00', response.params['amount'] end def test_failed_verify_non_visa_mc @@ -539,7 +539,7 @@ def test_failed_verify_non_visa_mc end.respond_with(failed_one_dollar_auth_response, successful_void_response) assert_failure response assert_match %r{This transaction cannot be processed}, response.message - assert_equal "1.00", response.params["amount"] + assert_equal '1.00', response.params['amount'] end def test_scrub @@ -566,7 +566,7 @@ def test_blank_cvv_not_sent assert_no_match(%r{CVV2}, data) end.respond_with(successful_purchase_response) - @credit_card.verification_value = " " + @credit_card.verification_value = ' ' stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| @@ -575,7 +575,7 @@ def test_blank_cvv_not_sent end def test_card_declined - ["15005", "10754", "10752", "10759", "10761", "15002", "11084"].each do |error_code| + ['15005', '10754', '10752', '10759', '10761', '15002', '11084'].each do |error_code| @gateway.expects(:ssl_request).returns(response_with_error_code(error_code)) response = @gateway.purchase(@amount, @credit_card, @options) @@ -585,7 +585,7 @@ def test_card_declined end def test_incorrect_cvc - ["15004"].each do |error_code| + ['15004'].each do |error_code| @gateway.expects(:ssl_request).returns(response_with_error_code(error_code)) response = @gateway.purchase(@amount, @credit_card, @options) @@ -595,7 +595,7 @@ def test_incorrect_cvc end def test_invalid_cvc - ["10762"].each do |error_code| + ['10762'].each do |error_code| @gateway.expects(:ssl_request).returns(response_with_error_code(error_code)) response = @gateway.purchase(@amount, @credit_card, @options) @@ -605,7 +605,7 @@ def test_invalid_cvc end def test_error_code_with_no_mapping_returns_standardized_processing_error - @gateway.expects(:ssl_request).returns(response_with_error_code("999999")) + @gateway.expects(:ssl_request).returns(response_with_error_code('999999')) response = @gateway.purchase(@amount, @credit_card, @options) assert_equal(:processing_error, response.error_code) diff --git a/test/unit/gateways/payscout_test.rb b/test/unit/gateways/payscout_test.rb index 0781da14568..7e84b6e4b29 100644 --- a/test/unit/gateways/payscout_test.rb +++ b/test/unit/gateways/payscout_test.rb @@ -118,7 +118,7 @@ def test_approved_refund assert refund = @gateway.refund(@amount, '1234567890') assert_success refund - assert_equal "The transaction has been approved", refund.message + assert_equal 'The transaction has been approved', refund.message end def test_not_found_transaction_id_refund @@ -126,7 +126,7 @@ def test_not_found_transaction_id_refund assert refund = @gateway.refund(@amount, '1234567890') assert_failure refund - assert_match "Transaction+not+found", refund.message + assert_match 'Transaction+not+found', refund.message end def test_invalid_transaction_id_refund @@ -134,7 +134,7 @@ def test_invalid_transaction_id_refund assert refund = @gateway.refund(@amount, '') assert_failure refund - assert_match "Invalid+Transaction+ID", refund.message + assert_match 'Invalid+Transaction+ID', refund.message end def test_invalid_amount_refund @@ -142,7 +142,7 @@ def test_invalid_amount_refund assert refund = @gateway.refund(200, '1234567890') assert_failure refund - assert_match "Refund+amount+may+not+exceed+the+transaction+balance", refund.message + assert_match 'Refund+amount+may+not+exceed+the+transaction+balance', refund.message end # Void @@ -152,7 +152,7 @@ def test_approved_void_purchase assert void = @gateway.void('1234567890') assert_success void - assert_equal "The transaction has been approved", void.message + assert_equal 'The transaction has been approved', void.message end def test_approved_void_authorization @@ -160,7 +160,7 @@ def test_approved_void_authorization assert void = @gateway.void('1234567890') assert_success void - assert_equal "The transaction has been approved", void.message + assert_equal 'The transaction has been approved', void.message end def test_invalid_transaction_id_void @@ -168,7 +168,7 @@ def test_invalid_transaction_id_void assert void = @gateway.void('') assert_failure void - assert_match "Invalid+Transaction+ID", void.message + assert_match 'Invalid+Transaction+ID', void.message end def test_not_found_transaction_id_void @@ -176,7 +176,7 @@ def test_not_found_transaction_id_void assert void = @gateway.void('1234567890') assert_failure void - assert_match "Transaction+not+found", void.message + assert_match 'Transaction+not+found', void.message end # Methods @@ -243,7 +243,7 @@ def test_expdate @credit_card.year = 2015 @credit_card.month = 8 - assert_equal "0815", @gateway.send(:expdate, @credit_card) + assert_equal '0815', @gateway.send(:expdate, @credit_card) end def test_add_creditcard @@ -303,11 +303,11 @@ def test_post_data parameters = {param1: 'value1', param2: 'value2'} result = @gateway.send(:post_data, 'auth', parameters) - assert_match "username=xxx", result - assert_match "password=xxx", result - assert_match "type=auth", result - assert_match "param1=value1", result - assert_match "param2=value2", result + assert_match 'username=xxx', result + assert_match 'password=xxx', result + assert_match 'type=auth', result + assert_match 'param1=value1', result + assert_match 'param2=value2', result end private diff --git a/test/unit/gateways/paystation_test.rb b/test/unit/gateways/paystation_test.rb index c4550e4d37e..f49d013b5ce 100644 --- a/test/unit/gateways/paystation_test.rb +++ b/test/unit/gateways/paystation_test.rb @@ -27,7 +27,7 @@ def test_successful_purchase assert_equal '0008813023-01', response.authorization - assert_equal 'Store Purchase', response.params["merchant_reference"] + assert_equal 'Store Purchase', response.params['merchant_reference'] assert response.test? end @@ -42,24 +42,24 @@ def test_unsuccessful_request def test_successful_store @gateway.expects(:ssl_post).returns(successful_store_response) - assert response = @gateway.store(@credit_card, @options.merge(:token => "justatest1310263135")) + assert response = @gateway.store(@credit_card, @options.merge(:token => 'justatest1310263135')) assert_success response assert response.test? - assert_equal "justatest1310263135", response.token + assert_equal 'justatest1310263135', response.token end def test_successful_purchase_from_token @gateway.expects(:ssl_post).returns(successful_stored_purchase_response) - token = "u09fxli14afpnd6022x0z82317beqe9e2w048l9it8286k6lpvz9x27hdal9bl95" + token = 'u09fxli14afpnd6022x0z82317beqe9e2w048l9it8286k6lpvz9x27hdal9bl95' assert response = @gateway.purchase(@amount, token, @options) assert_success response assert_equal '0009062149-01', response.authorization - assert_equal 'Store Purchase', response.params["merchant_reference"] + assert_equal 'Store Purchase', response.params['merchant_reference'] assert response.test? end @@ -75,7 +75,7 @@ def test_successful_authorization def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - assert response = @gateway.capture(@amount, "0009062250-01", @options.merge(:credit_card_verification => 123)) + assert response = @gateway.capture(@amount, '0009062250-01', @options.merge(:credit_card_verification => 123)) assert_success response end @@ -87,7 +87,7 @@ def test_successful_refund assert_success response assert_equal '0008813023-01', response.authorization - assert_equal 'Store Purchase', response.params["merchant_reference"] + assert_equal 'Store Purchase', response.params['merchant_reference'] refund = stub_comms do @gateway.refund(@amount, response.authorization, @options) @@ -100,7 +100,7 @@ def test_successful_refund def test_failed_refund response = stub_comms do - @gateway.refund(nil, "", @options) + @gateway.refund(nil, '', @options) end.respond_with(failed_refund_response) assert_failure response @@ -421,11 +421,11 @@ def failed_refund_response end def pre_scrubbed - "pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=5123456789012346&pstn_ct=visa&pstn_ex=1305&pstn_cc=123&pstn_tm=T&paystation=_empty" + 'pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=5123456789012346&pstn_ct=visa&pstn_ex=1305&pstn_cc=123&pstn_tm=T&paystation=_empty' end def post_scrubbed - "pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=[FILTERED]&pstn_ct=visa&pstn_ex=1305&pstn_cc=[FILTERED]&pstn_tm=T&paystation=_empty" + 'pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=[FILTERED]&pstn_ct=visa&pstn_ex=1305&pstn_cc=[FILTERED]&pstn_tm=T&paystation=_empty' end end diff --git a/test/unit/gateways/payu_in_test.rb b/test/unit/gateways/payu_in_test.rb index 8a366f1fb6e..876bae34162 100644 --- a/test/unit/gateways/payu_in_test.rb +++ b/test/unit/gateways/payu_in_test.rb @@ -1,24 +1,24 @@ -require "test_helper" +require 'test_helper' class PayuInTest < Test::Unit::TestCase include CommStub def setup @gateway = PayuInGateway.new( - key: "key", - salt: "salt" + key: 'key', + salt: 'salt' ) @credit_card = credit_card @options = { - order_id: "1" + order_id: '1' } end def assert_parameter(parameter, expected_value, data, options={}) assert (data =~ %r{(?:^|&)#{parameter}=([^&]*)(?:&|$)}), "Unable to find #{parameter} in #{data}" - value = CGI.unescape($1 || "") + value = CGI.unescape($1 || '') case expected_value when Regexp assert_match expected_value, value, "#{parameter} value does not match expected" @@ -34,41 +34,41 @@ def test_successful_purchase response = stub_comms do @gateway.purchase(100, @credit_card, @options) end.check_request do |endpoint, data, headers| - assert_equal "identity", headers["Accept-Encoding"] + assert_equal 'identity', headers['Accept-Encoding'] case endpoint when /_payment/ - assert_parameter("amount", "1.00", data) - assert_parameter("txnid", "1", data) - assert_parameter("productinfo", "Purchase", data) - assert_parameter("surl", "http://example.com", data) - assert_parameter("furl", "http://example.com", data) - assert_parameter("pg", "CC", data) - assert_parameter("firstname", @credit_card.first_name, data) - assert_parameter("bankcode", @credit_card.brand.upcase, data) - assert_parameter("ccnum", @credit_card.number, data) - assert_parameter("ccvv", @credit_card.verification_value, data) - assert_parameter("ccname", @credit_card.name, data) - assert_parameter("ccexpmon", "%02d" % @credit_card.month.to_i, data) - assert_parameter("ccexpyr", @credit_card.year, data) - assert_parameter("email", "unknown@example.com", data) - assert_parameter("phone", "11111111111", data) - assert_parameter("key", "key", data) - assert_parameter("txn_s2s_flow", "1", data) - assert_parameter("hash", "5199c0735c21d647f287a2781024743d35fabfd640bc20f2ae7b5277e3d7d06fa315fcdda266cfa64920517944244c632e5f38768481626b22e2b0d70c806d60", data) + assert_parameter('amount', '1.00', data) + assert_parameter('txnid', '1', data) + assert_parameter('productinfo', 'Purchase', data) + assert_parameter('surl', 'http://example.com', data) + assert_parameter('furl', 'http://example.com', data) + assert_parameter('pg', 'CC', data) + assert_parameter('firstname', @credit_card.first_name, data) + assert_parameter('bankcode', @credit_card.brand.upcase, data) + assert_parameter('ccnum', @credit_card.number, data) + assert_parameter('ccvv', @credit_card.verification_value, data) + assert_parameter('ccname', @credit_card.name, data) + assert_parameter('ccexpmon', '%02d' % @credit_card.month.to_i, data) + assert_parameter('ccexpyr', @credit_card.year, data) + assert_parameter('email', 'unknown@example.com', data) + assert_parameter('phone', '11111111111', data) + assert_parameter('key', 'key', data) + assert_parameter('txn_s2s_flow', '1', data) + assert_parameter('hash', '5199c0735c21d647f287a2781024743d35fabfd640bc20f2ae7b5277e3d7d06fa315fcdda266cfa64920517944244c632e5f38768481626b22e2b0d70c806d60', data) when /hdfc_not_enrolled/ - assert_parameter("transactionId", "6e7e62723683934e6c5507675df11bdd86197c5c935878ff72e344205f3c8a1d", data) - assert_parameter("pgId", "8", data) - assert_parameter("eci", "7", data) - assert_parameter("nonEnrolled", "1", data) - assert_parameter("nonDomestic", "0", data) - assert_parameter("bank", "VISA", data) - assert_parameter("cccat", "creditcard", data) - assert_parameter("ccnum", "4b5c9002295c6cd8e5289e2f9c312dc737810a747b84e71665cf077c78fe245a", data) - assert_parameter("ccname", "53ab689fdb1b025c7e9c53c6b4a6e27f51e0d627579e7c12af2cb6cbc4944cc0", data) - assert_parameter("ccvv", "cc8d6cfb6b03f94e2a64b490ae10c261c10747f543b1fba09d7f56f9ef6aac04", data) - assert_parameter("ccexpmon", "5ddf3702e74f473ec89762f6efece025737c2ab999e695cf10496e6fa3946079", data) - assert_parameter("ccexpyr", "5da83563fcaa945063dc4c2094c48e800badf7c8246c9d13b43757fe99d63e6d", data) - assert_parameter("is_seamless", "1", data) + assert_parameter('transactionId', '6e7e62723683934e6c5507675df11bdd86197c5c935878ff72e344205f3c8a1d', data) + assert_parameter('pgId', '8', data) + assert_parameter('eci', '7', data) + assert_parameter('nonEnrolled', '1', data) + assert_parameter('nonDomestic', '0', data) + assert_parameter('bank', 'VISA', data) + assert_parameter('cccat', 'creditcard', data) + assert_parameter('ccnum', '4b5c9002295c6cd8e5289e2f9c312dc737810a747b84e71665cf077c78fe245a', data) + assert_parameter('ccname', '53ab689fdb1b025c7e9c53c6b4a6e27f51e0d627579e7c12af2cb6cbc4944cc0', data) + assert_parameter('ccvv', 'cc8d6cfb6b03f94e2a64b490ae10c261c10747f543b1fba09d7f56f9ef6aac04', data) + assert_parameter('ccexpmon', '5ddf3702e74f473ec89762f6efece025737c2ab999e695cf10496e6fa3946079', data) + assert_parameter('ccexpyr', '5da83563fcaa945063dc4c2094c48e800badf7c8246c9d13b43757fe99d63e6d', data) + assert_parameter('is_seamless', '1', data) else flunk "Unknown endpoint #{endpoint}" end @@ -76,8 +76,8 @@ def test_successful_purchase assert_success response - assert_equal "403993715512145540", response.authorization - assert_equal "No Error", response.message + assert_equal '403993715512145540', response.authorization + assert_equal 'No Error', response.message assert response.test? end @@ -85,83 +85,83 @@ def test_successful_purchase_with_full_options response = stub_comms do @gateway.purchase( 100, - credit_card("4242424242424242", name: "Bobby Jimbob", verification_value: "678", month: "4", year: "2015"), - order_id: "99", - description: "Awesome!", - email: "jim@example.com", + credit_card('4242424242424242', name: 'Bobby Jimbob', verification_value: '678', month: '4', year: '2015'), + order_id: '99', + description: 'Awesome!', + email: 'jim@example.com', billing_address: { - name: "Jim Smith", - address1: "123 Road", - address2: "Suite 123", - city: "Somewhere", - state: "ZZ", - country: "US", - zip: "12345", - phone: "12223334444" + name: 'Jim Smith', + address1: '123 Road', + address2: 'Suite 123', + city: 'Somewhere', + state: 'ZZ', + country: 'US', + zip: '12345', + phone: '12223334444' }, shipping_address: { - name: "Joe Bob", - address1: "987 Street", - address2: "Suite 987", - city: "Anyplace", - state: "AA", - country: "IN", - zip: "98765", - phone: "98887776666" + name: 'Joe Bob', + address1: '987 Street', + address2: 'Suite 987', + city: 'Anyplace', + state: 'AA', + country: 'IN', + zip: '98765', + phone: '98887776666' } ) end.check_request do |endpoint, data, headers| - assert_equal "identity", headers["Accept-Encoding"] + assert_equal 'identity', headers['Accept-Encoding'] case endpoint when /_payment/ - assert_parameter("amount", "1.00", data) - assert_parameter("txnid", "99", data) - assert_parameter("productinfo", "Awesome!", data) - assert_parameter("surl", "http://example.com", data) - assert_parameter("furl", "http://example.com", data) - assert_parameter("pg", "CC", data) - assert_parameter("firstname", "Bobby", data) - assert_parameter("lastname", "Jimbob", data) - assert_parameter("bankcode", "VISA", data) - assert_parameter("ccnum", "4242424242424242", data) - assert_parameter("ccvv", "678", data) - assert_parameter("ccname", "Bobby Jimbob", data) - assert_parameter("ccexpmon", "04", data) - assert_parameter("ccexpyr", "2015", data) - assert_parameter("email", "jim@example.com", data) - assert_parameter("phone", "12223334444", data) - assert_parameter("key", "key", data) - assert_parameter("txn_s2s_flow", "1", data) - assert_parameter("hash", "1ee17ee9615b55fdee4cd92cee4f28bd88e0c7ff16bd7525cb7b0a792728502f71ffba37606b1b77504d1d0b9d520d39cb1829fffd1aa5eef27dfa4c4a887f61", data) - assert_parameter("address1", "123 Road", data) - assert_parameter("address2", "Suite 123", data) - assert_parameter("city", "Somewhere", data) - assert_parameter("state", "ZZ", data) - assert_parameter("country", "US", data) - assert_parameter("zipcode", "12345", data) - assert_parameter("shipping_firstname", "Joe", data) - assert_parameter("shipping_lastname", "Bob", data) - assert_parameter("shipping_address1", "987 Street", data) - assert_parameter("shipping_address2", "Suite 987", data) - assert_parameter("shipping_city", "Anyplace", data) - assert_parameter("shipping_state", "AA", data) - assert_parameter("shipping_country", "IN", data) - assert_parameter("shipping_zipcode", "98765", data) - assert_parameter("shipping_phone", "98887776666", data) + assert_parameter('amount', '1.00', data) + assert_parameter('txnid', '99', data) + assert_parameter('productinfo', 'Awesome!', data) + assert_parameter('surl', 'http://example.com', data) + assert_parameter('furl', 'http://example.com', data) + assert_parameter('pg', 'CC', data) + assert_parameter('firstname', 'Bobby', data) + assert_parameter('lastname', 'Jimbob', data) + assert_parameter('bankcode', 'VISA', data) + assert_parameter('ccnum', '4242424242424242', data) + assert_parameter('ccvv', '678', data) + assert_parameter('ccname', 'Bobby Jimbob', data) + assert_parameter('ccexpmon', '04', data) + assert_parameter('ccexpyr', '2015', data) + assert_parameter('email', 'jim@example.com', data) + assert_parameter('phone', '12223334444', data) + assert_parameter('key', 'key', data) + assert_parameter('txn_s2s_flow', '1', data) + assert_parameter('hash', '1ee17ee9615b55fdee4cd92cee4f28bd88e0c7ff16bd7525cb7b0a792728502f71ffba37606b1b77504d1d0b9d520d39cb1829fffd1aa5eef27dfa4c4a887f61', data) + assert_parameter('address1', '123 Road', data) + assert_parameter('address2', 'Suite 123', data) + assert_parameter('city', 'Somewhere', data) + assert_parameter('state', 'ZZ', data) + assert_parameter('country', 'US', data) + assert_parameter('zipcode', '12345', data) + assert_parameter('shipping_firstname', 'Joe', data) + assert_parameter('shipping_lastname', 'Bob', data) + assert_parameter('shipping_address1', '987 Street', data) + assert_parameter('shipping_address2', 'Suite 987', data) + assert_parameter('shipping_city', 'Anyplace', data) + assert_parameter('shipping_state', 'AA', data) + assert_parameter('shipping_country', 'IN', data) + assert_parameter('shipping_zipcode', '98765', data) + assert_parameter('shipping_phone', '98887776666', data) when /hdfc_not_enrolled/ - assert_parameter("transactionId", "6e7e62723683934e6c5507675df11bdd86197c5c935878ff72e344205f3c8a1d", data) - assert_parameter("pgId", "8", data) - assert_parameter("eci", "7", data) - assert_parameter("nonEnrolled", "1", data) - assert_parameter("nonDomestic", "0", data) - assert_parameter("bank", "VISA", data) - assert_parameter("cccat", "creditcard", data) - assert_parameter("ccnum", "4b5c9002295c6cd8e5289e2f9c312dc737810a747b84e71665cf077c78fe245a", data) - assert_parameter("ccname", "53ab689fdb1b025c7e9c53c6b4a6e27f51e0d627579e7c12af2cb6cbc4944cc0", data) - assert_parameter("ccvv", "cc8d6cfb6b03f94e2a64b490ae10c261c10747f543b1fba09d7f56f9ef6aac04", data) - assert_parameter("ccexpmon", "5ddf3702e74f473ec89762f6efece025737c2ab999e695cf10496e6fa3946079", data) - assert_parameter("ccexpyr", "5da83563fcaa945063dc4c2094c48e800badf7c8246c9d13b43757fe99d63e6d", data) - assert_parameter("is_seamless", "1", data) + assert_parameter('transactionId', '6e7e62723683934e6c5507675df11bdd86197c5c935878ff72e344205f3c8a1d', data) + assert_parameter('pgId', '8', data) + assert_parameter('eci', '7', data) + assert_parameter('nonEnrolled', '1', data) + assert_parameter('nonDomestic', '0', data) + assert_parameter('bank', 'VISA', data) + assert_parameter('cccat', 'creditcard', data) + assert_parameter('ccnum', '4b5c9002295c6cd8e5289e2f9c312dc737810a747b84e71665cf077c78fe245a', data) + assert_parameter('ccname', '53ab689fdb1b025c7e9c53c6b4a6e27f51e0d627579e7c12af2cb6cbc4944cc0', data) + assert_parameter('ccvv', 'cc8d6cfb6b03f94e2a64b490ae10c261c10747f543b1fba09d7f56f9ef6aac04', data) + assert_parameter('ccexpmon', '5ddf3702e74f473ec89762f6efece025737c2ab999e695cf10496e6fa3946079', data) + assert_parameter('ccexpyr', '5da83563fcaa945063dc4c2094c48e800badf7c8246c9d13b43757fe99d63e6d', data) + assert_parameter('is_seamless', '1', data) else flunk "Unknown endpoint #{endpoint}" end @@ -175,60 +175,60 @@ def test_input_constraint_cleanup @gateway.purchase( 100, credit_card( - "4242424242424242", - first_name: ("3" + ("a" * 61)), - last_name: ("3" + ("a" * 21)), - month: "4", - year: "2015" + '4242424242424242', + first_name: ('3' + ('a' * 61)), + last_name: ('3' + ('a' * 21)), + month: '4', + year: '2015' ), - order_id: ("!@#" + ("a" * 31)), - description: ("a" * 101), - email: ("c" * 51), + order_id: ('!@#' + ('a' * 31)), + description: ('a' * 101), + email: ('c' * 51), billing_address: { - name: "Jim Smith", - address1: ("!#$%^&'\"()" + "Aa0@-_/ ." + ("a" * 101)), - address2: ("!#$%^&'\"()" + "Aa0@-_/ ." + ("a" * 101)), - city: ("!#$%^&'\"()" + "Aa0@-_/ ." + ("a" * 51)), - state: ("!#$%^&'\"()" + "Aa0@-_/ ." + ("a" * 51)), - country: ("!#$%^&'\"()" + "Aa0@-_/ ." + ("a" * 51)), - zip: ("a-" + ("1" * 21)), - phone: ("a-" + ("1" * 51)) + name: 'Jim Smith', + address1: ("!#$%^&'\"()" + 'Aa0@-_/ .' + ('a' * 101)), + address2: ("!#$%^&'\"()" + 'Aa0@-_/ .' + ('a' * 101)), + city: ("!#$%^&'\"()" + 'Aa0@-_/ .' + ('a' * 51)), + state: ("!#$%^&'\"()" + 'Aa0@-_/ .' + ('a' * 51)), + country: ("!#$%^&'\"()" + 'Aa0@-_/ .' + ('a' * 51)), + zip: ('a-' + ('1' * 21)), + phone: ('a-' + ('1' * 51)) }, shipping_address: { - name: (("3" + ("a" * 61)) + " " + ("3" + ("a" * 21))), - address1: ("!#$%^&'\"()" + "Aa0@-_/ ." + ("a" * 101)), - address2: ("!#$%^&'\"()" + "Aa0@-_/ ." + ("a" * 101)), - city: ("!#$%^&'\"()" + "Aa0@-_/ ." + ("a" * 51)), - state: ("!#$%^&'\"()" + "Aa0@-_/ ." + ("a" * 51)), - country: ("!#$%^&'\"()" + "Aa0@-_/ ." + ("a" * 51)), - zip: ("a-" + ("1" * 21)), - phone: ("a-" + ("1" * 51)) + name: (('3' + ('a' * 61)) + ' ' + ('3' + ('a' * 21))), + address1: ("!#$%^&'\"()" + 'Aa0@-_/ .' + ('a' * 101)), + address2: ("!#$%^&'\"()" + 'Aa0@-_/ .' + ('a' * 101)), + city: ("!#$%^&'\"()" + 'Aa0@-_/ .' + ('a' * 51)), + state: ("!#$%^&'\"()" + 'Aa0@-_/ .' + ('a' * 51)), + country: ("!#$%^&'\"()" + 'Aa0@-_/ .' + ('a' * 51)), + zip: ('a-' + ('1' * 21)), + phone: ('a-' + ('1' * 51)) } ) end.check_request do |endpoint, data, headers| case endpoint when /_payment/ - assert_parameter("txnid", /^a/, data, length: 30) - assert_parameter("productinfo", /^a/, data, length: 100) - assert_parameter("firstname", /^a/, data, length: 60) - assert_parameter("lastname", /^a/, data, length: 20) - assert_parameter("email", /^c/, data, length: 50) - assert_parameter("phone", /^\d/, data, length: 50) - assert_parameter("address1", /^Aa0@-_\/ \.a/, data, length: 100) - assert_parameter("address2", /^Aa0@-_\/ \.a/, data, length: 100) - assert_parameter("city", /^Aa0@-_\/ \.a/, data, length: 50) - assert_parameter("state", /^Aa0@-_\/ \.a/, data, length: 50) - assert_parameter("country", /^Aa0@-_\/ \.a/, data, length: 50) - assert_parameter("zipcode", /^1/, data, length: 20) - assert_parameter("shipping_firstname", /^a/, data, length: 60) - assert_parameter("shipping_lastname", /^a/, data, length: 20) - assert_parameter("shipping_address1", /^Aa0@-_\/ \.a/, data, length: 100) - assert_parameter("shipping_address2", /^Aa0@-_\/ \.a/, data, length: 100) - assert_parameter("shipping_city", /^Aa0@-_\/ \.a/, data, length: 50) - assert_parameter("shipping_state", /^Aa0@-_\/ \.a/, data, length: 50) - assert_parameter("shipping_country", /^Aa0@-_\/ \.a/, data, length: 50) - assert_parameter("shipping_zipcode", /^1/, data, length: 20) - assert_parameter("shipping_phone", /^\d/, data, length: 50) + assert_parameter('txnid', /^a/, data, length: 30) + assert_parameter('productinfo', /^a/, data, length: 100) + assert_parameter('firstname', /^a/, data, length: 60) + assert_parameter('lastname', /^a/, data, length: 20) + assert_parameter('email', /^c/, data, length: 50) + assert_parameter('phone', /^\d/, data, length: 50) + assert_parameter('address1', /^Aa0@-_\/ \.a/, data, length: 100) + assert_parameter('address2', /^Aa0@-_\/ \.a/, data, length: 100) + assert_parameter('city', /^Aa0@-_\/ \.a/, data, length: 50) + assert_parameter('state', /^Aa0@-_\/ \.a/, data, length: 50) + assert_parameter('country', /^Aa0@-_\/ \.a/, data, length: 50) + assert_parameter('zipcode', /^1/, data, length: 20) + assert_parameter('shipping_firstname', /^a/, data, length: 60) + assert_parameter('shipping_lastname', /^a/, data, length: 20) + assert_parameter('shipping_address1', /^Aa0@-_\/ \.a/, data, length: 100) + assert_parameter('shipping_address2', /^Aa0@-_\/ \.a/, data, length: 100) + assert_parameter('shipping_city', /^Aa0@-_\/ \.a/, data, length: 50) + assert_parameter('shipping_state', /^Aa0@-_\/ \.a/, data, length: 50) + assert_parameter('shipping_country', /^Aa0@-_\/ \.a/, data, length: 50) + assert_parameter('shipping_zipcode', /^1/, data, length: 20) + assert_parameter('shipping_phone', /^\d/, data, length: 50) end end.respond_with(successful_purchase_setup_response, successful_purchase_response) @@ -237,47 +237,47 @@ def test_input_constraint_cleanup def test_brand_mappings stub_comms do - @gateway.purchase(100, credit_card("4242424242424242", brand: :visa), @options) + @gateway.purchase(100, credit_card('4242424242424242', brand: :visa), @options) end.check_request do |endpoint, data, _| case endpoint when /_payment/ - assert_parameter("bankcode", "VISA", data) + assert_parameter('bankcode', 'VISA', data) end end.respond_with(successful_purchase_response) stub_comms do - @gateway.purchase(100, credit_card("4242424242424242", brand: :master), @options) + @gateway.purchase(100, credit_card('4242424242424242', brand: :master), @options) end.check_request do |endpoint, data, _| case endpoint when /_payment/ - assert_parameter("bankcode", "MAST", data) + assert_parameter('bankcode', 'MAST', data) end end.respond_with(successful_purchase_response) stub_comms do - @gateway.purchase(100, credit_card("4242424242424242", brand: :american_express), @options) + @gateway.purchase(100, credit_card('4242424242424242', brand: :american_express), @options) end.check_request do |endpoint, data, _| case endpoint when /_payment/ - assert_parameter("bankcode", "AMEX", data) + assert_parameter('bankcode', 'AMEX', data) end end.respond_with(successful_purchase_response) stub_comms do - @gateway.purchase(100, credit_card("4242424242424242", brand: :diners_club), @options) + @gateway.purchase(100, credit_card('4242424242424242', brand: :diners_club), @options) end.check_request do |endpoint, data, _| case endpoint when /_payment/ - assert_parameter("bankcode", "DINR", data) + assert_parameter('bankcode', 'DINR', data) end end.respond_with(successful_purchase_response) stub_comms do - @gateway.purchase(100, credit_card("4242424242424242", brand: :maestro), @options) + @gateway.purchase(100, credit_card('4242424242424242', brand: :maestro), @options) end.check_request do |endpoint, data, _| case endpoint when /_payment/ - assert_parameter("bankcode", "MAES", data) + assert_parameter('bankcode', 'MAES', data) end end.respond_with(successful_purchase_response) end @@ -287,37 +287,37 @@ def test_failed_purchase response = @gateway.purchase(100, @credit_card, @options) assert_failure response - assert_equal "Invalid amount @~@ ExceptionConstant : INVALID_AMOUNT", response.message + assert_equal 'Invalid amount @~@ ExceptionConstant : INVALID_AMOUNT', response.message end def test_successful_refund response = stub_comms do - @gateway.refund(100, "abc") + @gateway.refund(100, 'abc') end.check_request do |endpoint, data, headers| - assert_parameter("command", "cancel_refund_transaction", data) - assert_parameter("var1", "abc", data) - assert_parameter("var2", /./, data) - assert_parameter("var3", "1.00", data) - assert_parameter("key", "key", data) - assert_parameter("txn_s2s_flow", "1", data) - assert_parameter("hash", "06ee55774af4e3eee3f946d4079d34efca243453199b0d4a1328f248b93428ed5c6342c6d73010c0b86d19afc04ae7a1c62c68c472cc0811d00a9a10ecf28791", data) + assert_parameter('command', 'cancel_refund_transaction', data) + assert_parameter('var1', 'abc', data) + assert_parameter('var2', /./, data) + assert_parameter('var3', '1.00', data) + assert_parameter('key', 'key', data) + assert_parameter('txn_s2s_flow', '1', data) + assert_parameter('hash', '06ee55774af4e3eee3f946d4079d34efca243453199b0d4a1328f248b93428ed5c6342c6d73010c0b86d19afc04ae7a1c62c68c472cc0811d00a9a10ecf28791', data) end.respond_with(successful_refund_response) assert_success response - assert_equal "Refund Request Queued", response.message + assert_equal 'Refund Request Queued', response.message end def test_failed_refund @gateway.expects(:ssl_post).returns(failed_refund_response) - response = @gateway.refund(100, "abc") + response = @gateway.refund(100, 'abc') assert_failure response - assert_equal "Invalid payuid", response.message + assert_equal 'Invalid payuid', response.message end def test_refund_without_amount assert_raise ArgumentError do - @gateway.refund(nil, "abc") + @gateway.refund(nil, 'abc') end end @@ -326,7 +326,7 @@ def test_3dsecure_cards_fail response = @gateway.purchase(100, @credit_card, @options) assert_failure response - assert_equal "3D-secure enrolled cards are not supported.", response.message + assert_equal '3D-secure enrolled cards are not supported.', response.message end def test_scrub diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb index 7ce307432c9..897cf82be56 100644 --- a/test/unit/gateways/payu_latam_test.rb +++ b/test/unit/gateways/payu_latam_test.rb @@ -7,34 +7,34 @@ def setup @gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key', payment_country: 'AR') @amount = 4000 - @credit_card = credit_card("4097440000000004", verification_value: "444", first_name: "APPROVED", last_name: "") - @declined_card = credit_card("4097440000000004", verification_value: "333", first_name: "REJECTED", last_name: "") - @pending_card = credit_card("4097440000000004", verification_value: "222", first_name: "PENDING", last_name: "") - @no_cvv_visa_card = credit_card("4097440000000004", verification_value: " ") - @no_cvv_amex_card = credit_card("4097440000000004", verification_value: " ", brand: "american_express") + @credit_card = credit_card('4097440000000004', verification_value: '444', first_name: 'APPROVED', last_name: '') + @declined_card = credit_card('4097440000000004', verification_value: '333', first_name: 'REJECTED', last_name: '') + @pending_card = credit_card('4097440000000004', verification_value: '222', first_name: 'PENDING', last_name: '') + @no_cvv_visa_card = credit_card('4097440000000004', verification_value: ' ') + @no_cvv_amex_card = credit_card('4097440000000004', verification_value: ' ', brand: 'american_express') @options = { dni_number: '5415668464654', dni_type: 'TI', - currency: "ARS", + currency: 'ARS', order_id: generate_unique_id, - description: "Active Merchant Transaction", + description: 'Active Merchant Transaction', installments_number: 1, tax: 0, tax_return_base: 0, - email: "username@domain.com", - ip: "127.0.0.1", + email: 'username@domain.com', + ip: '127.0.0.1', device_session_id: 'vghs6tvkcle931686k1900o6e1', cookie: 'pt1t38347bs6jc9ruv2ecpv7o2', user_agent: 'Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0', billing_address: address( - address1: "Viamonte", - address2: "1366", - city: "Plata", - state: "Buenos Aires", - country: "AR", - zip: "64000", - phone: "7563126" + address1: 'Viamonte', + address2: '1366', + city: 'Plata', + state: 'Buenos Aires', + country: 'AR', + zip: '64000', + phone: '7563126' ) } end @@ -44,7 +44,7 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end @@ -61,8 +61,8 @@ def test_failed_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "ANTIFRAUD_REJECTED", response.message - assert_equal "DECLINED", response.params["transactionResponse"]["state"] + assert_equal 'ANTIFRAUD_REJECTED', response.message + assert_equal 'DECLINED', response.params['transactionResponse']['state'] end def test_successful_authorize @@ -70,7 +70,7 @@ def test_successful_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert_match %r(^\d+\|(\w|-)+$), response.authorization end @@ -87,21 +87,21 @@ def test_failed_authorize response = @gateway.authorize(@amount, @pending_card, @options) assert_failure response - assert_equal "PENDING_TRANSACTION_REVIEW", response.message - assert_equal "PENDING", response.params["transactionResponse"]["state"] + assert_equal 'PENDING_TRANSACTION_REVIEW', response.message + assert_equal 'PENDING', response.params['transactionResponse']['state'] end def test_pending_refund @gateway.expects(:ssl_post).returns(pending_refund_response) - response = @gateway.refund(@amount, "7edbaf68-8f3a-4ae7-b9c7-d1e27e314999") + response = @gateway.refund(@amount, '7edbaf68-8f3a-4ae7-b9c7-d1e27e314999') assert_success response - assert_equal "PENDING", response.params["transactionResponse"]["state"] + assert_equal 'PENDING', response.params['transactionResponse']['state'] end def test_pending_refund_with_specified_language stub_comms do - @gateway.refund(@amount, "7edbaf68-8f3a-4ae7-b9c7-d1e27e314999", @options.merge(language: 'es')) + @gateway.refund(@amount, '7edbaf68-8f3a-4ae7-b9c7-d1e27e314999', @options.merge(language: 'es')) end.check_request do |endpoint, data, headers| assert_match(/"language":"es"/, data) end.respond_with(pending_refund_response) @@ -110,22 +110,22 @@ def test_pending_refund_with_specified_language def test_failed_refund @gateway.expects(:ssl_post).returns(failed_refund_response) - response = @gateway.refund(@amount, "") + response = @gateway.refund(@amount, '') assert_failure response - assert_equal "property: order.id, message: must not be null property: parentTransactionId, message: must not be null", response.message + assert_equal 'property: order.id, message: must not be null property: parentTransactionId, message: must not be null', response.message end def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) - response = @gateway.void("7edbaf68-8f3a-4ae7-b9c7-d1e27e314999", @options) + response = @gateway.void('7edbaf68-8f3a-4ae7-b9c7-d1e27e314999', @options) assert_success response - assert_equal "PENDING_REVIEW", response.message + assert_equal 'PENDING_REVIEW', response.message end def test_successful_void_with_specified_language stub_comms do - @gateway.void("7edbaf68-8f3a-4ae7-b9c7-d1e27e314999", @options.merge(language: 'es')) + @gateway.void('7edbaf68-8f3a-4ae7-b9c7-d1e27e314999', @options.merge(language: 'es')) end.check_request do |endpoint, data, headers| assert_match(/"language":"es"/, data) end.respond_with(successful_void_response) @@ -134,9 +134,9 @@ def test_successful_void_with_specified_language def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) - response = @gateway.void("") + response = @gateway.void('') assert_failure response - assert_equal "property: order.id, message: must not be null property: parentTransactionId, message: must not be null", response.message + assert_equal 'property: order.id, message: must not be null property: parentTransactionId, message: must not be null', response.message end def test_successful_purchase_with_dni_number @@ -164,7 +164,7 @@ def test_request_using_visa_card_with_no_cvv }.returns(successful_purchase_response) response = @gateway.purchase(@amount, @no_cvv_visa_card, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end @@ -175,7 +175,7 @@ def test_request_using_amex_card_with_no_cvv }.returns(successful_purchase_response) response = @gateway.purchase(@amount, @no_cvv_amex_card, @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end @@ -184,24 +184,24 @@ def test_request_passes_cvv_option body.match '"securityCode":"777"' !body.match '"processWithoutCvv2"' }.returns(successful_purchase_response) - options = @options.merge(cvv: "777") + options = @options.merge(cvv: '777') response = @gateway.purchase(@amount, @no_cvv_visa_card, options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message assert response.test? end def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - response = @gateway.capture(@amount, "4000|authorization", @options) + response = @gateway.capture(@amount, '4000|authorization', @options) assert_success response - assert_equal "APPROVED", response.message + assert_equal 'APPROVED', response.message end def test_successful_capture_with_specified_language stub_comms do - @gateway.capture(@amount, "4000|authorization", @options.merge(language: 'es')) + @gateway.capture(@amount, '4000|authorization', @options.merge(language: 'es')) end.check_request do |endpoint, data, headers| assert_match(/"language":"es"/, data) end.respond_with(successful_purchase_response) @@ -210,21 +210,21 @@ def test_successful_capture_with_specified_language def test_failed_capture @gateway.expects(:ssl_post).returns(failed_void_response) - response = @gateway.capture(@amount, "") + response = @gateway.capture(@amount, '') assert_failure response - assert_equal "property: order.id, message: must not be null property: parentTransactionId, message: must not be null", response.message + assert_equal 'property: order.id, message: must not be null property: parentTransactionId, message: must not be null', response.message end def test_partial_buyer_hash_info options_buyer = { shipping_address: address( - address1: "Calle 200", - address2: "N107", - city: "Sao Paulo", - state: "SP", - country: "BR", - zip: "01019-030", - phone: "(11)756312345" + address1: 'Calle 200', + address2: 'N107', + city: 'Sao Paulo', + state: 'SP', + country: 'BR', + zip: '01019-030', + phone: '(11)756312345' ), buyer: { name: 'Jorge Borges', @@ -252,27 +252,27 @@ def test_brazil_required_fields gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key', payment_country: 'BR') options_brazil = { - currency: "BRL", + currency: 'BRL', billing_address: address( - address1: "Calle 100", - address2: "BL4", - city: "Sao Paulo", - state: "SP", - country: "BR", - zip: "09210710", - phone: "(11)756312633" + address1: 'Calle 100', + address2: 'BL4', + city: 'Sao Paulo', + state: 'SP', + country: 'BR', + zip: '09210710', + phone: '(11)756312633' ), shipping_address: address( - address1: "Calle 200", - address2: "N107", - city: "Sao Paulo", - state: "SP", - country: "BR", - zip: "01019-030", - phone: "(11)756312633" + address1: 'Calle 200', + address2: 'N107', + city: 'Sao Paulo', + state: 'SP', + country: 'BR', + zip: '01019-030', + phone: '(11)756312633' ), buyer: { - cnpj: "32593371000110" + cnpj: '32593371000110' } } @@ -287,24 +287,24 @@ def test_colombia_required_fields gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key', payment_country: 'CO') options_colombia = { - currency: "COP", + currency: 'COP', billing_address: address( - address1: "Calle 100", - address2: "BL4", - city: "Bogota", - state: "Bogota DC", - country: "CO", - zip: "09210710", - phone: "(11)756312633" + address1: 'Calle 100', + address2: 'BL4', + city: 'Bogota', + state: 'Bogota DC', + country: 'CO', + zip: '09210710', + phone: '(11)756312633' ), shipping_address: address( - address1: "Calle 200", - address2: "N107", - city: "Bogota", - state: "Bogota DC", - country: "CO", - zip: "01019-030", - phone: "(11)756312633" + address1: 'Calle 200', + address2: 'N107', + city: 'Bogota', + state: 'Bogota DC', + country: 'CO', + zip: '01019-030', + phone: '(11)756312633' ), tx_tax: '3193', tx_tax_return_base: '16806' @@ -321,24 +321,24 @@ def test_mexico_required_fields gateway = PayuLatamGateway.new(merchant_id: 'merchant_id', account_id: 'account_id', api_login: 'api_login', api_key: 'api_key', payment_country: 'MX') options_mexico = { - currency: "MXN", + currency: 'MXN', billing_address: address( - address1: "Calle 100", - address2: "BL4", - city: "Guadalajara", - state: "Jalisco", - country: "MX", - zip: "09210710", - phone: "(11)756312633" + address1: 'Calle 100', + address2: 'BL4', + city: 'Guadalajara', + state: 'Jalisco', + country: 'MX', + zip: '09210710', + phone: '(11)756312633' ), shipping_address: address( - address1: "Calle 200", - address2: "N107", - city: "Guadalajara", - state: "Jalisco", - country: "MX", - zip: "01019-030", - phone: "(11)756312633" + address1: 'Calle 200', + address2: 'N107', + city: 'Guadalajara', + state: 'Jalisco', + country: 'MX', + zip: '01019-030', + phone: '(11)756312633' ), birth_date: '1985-05-25' } diff --git a/test/unit/gateways/payway_test.rb b/test/unit/gateways/payway_test.rb index 416f1c6bb0f..86ae5139140 100644 --- a/test/unit/gateways/payway_test.rb +++ b/test/unit/gateways/payway_test.rb @@ -221,35 +221,35 @@ def test_store private def successful_response_store - "response.responseCode=00" + 'response.responseCode=00' end def successful_response_visa - "response.summaryCode=0&response.responseCode=08&response.cardSchemeName=VISA" + 'response.summaryCode=0&response.responseCode=08&response.cardSchemeName=VISA' end def successful_response_master_card - "response.summaryCode=0&response.responseCode=08&response.cardSchemeName=MASTERCARD" + 'response.summaryCode=0&response.responseCode=08&response.cardSchemeName=MASTERCARD' end def purchase_with_invalid_credit_card_response - "response.summaryCode=1&response.responseCode=14" + 'response.summaryCode=1&response.responseCode=14' end def purchase_with_expired_credit_card_response - "response.summaryCode=1&response.responseCode=54" + 'response.summaryCode=1&response.responseCode=54' end def purchase_with_invalid_month_response - "response.summaryCode=3&response.responseCode=QA" + 'response.summaryCode=3&response.responseCode=QA' end def bad_login_response - "response.summaryCode=3&response.responseCode=QH" + 'response.summaryCode=3&response.responseCode=QH' end def bad_merchant_response - "response.summaryCode=3&response.responseCode=QK" + 'response.summaryCode=3&response.responseCode=QK' end def certificate diff --git a/test/unit/gateways/pin_test.rb b/test/unit/gateways/pin_test.rb index e7b9241bbba..fc16c0d1f68 100644 --- a/test/unit/gateways/pin_test.rb +++ b/test/unit/gateways/pin_test.rb @@ -80,12 +80,12 @@ def test_unsuccessful_request assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "The current resource was deemed invalid.", response.message + assert_equal 'The current resource was deemed invalid.', response.message assert response.test? end def test_unparsable_body_of_successful_response - @gateway.stubs(:raw_ssl_request).returns(MockResponse.succeeded("This is not [ JSON")) + @gateway.stubs(:raw_ssl_request).returns(MockResponse.succeeded('This is not [ JSON')) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response @@ -93,7 +93,7 @@ def test_unparsable_body_of_successful_response end def test_unparsable_body_of_failed_response - @gateway.stubs(:raw_ssl_request).returns(MockResponse.failed("This is not [ JSON")) + @gateway.stubs(:raw_ssl_request).returns(MockResponse.failed('This is not [ JSON')) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response @@ -114,7 +114,7 @@ def test_unsuccessful_store assert response = @gateway.store(@credit_card, @options) assert_failure response - assert_equal "The current resource was deemed invalid.", response.message + assert_equal 'The current resource was deemed invalid.', response.message assert response.test? end @@ -144,7 +144,7 @@ def test_unsuccessful_refund assert response = @gateway.refund(100, token) assert_failure response - assert_equal "The current resource was deemed invalid.", response.message + assert_equal 'The current resource was deemed invalid.', response.message assert response.test? end @@ -299,8 +299,8 @@ def test_post_data def test_headers expected_headers = { - "Content-Type" => "application/json", - "Authorization" => "Basic #{Base64.strict_encode64('I_THISISNOTAREALAPIKEY:').strip}" + 'Content-Type' => 'application/json', + 'Authorization' => "Basic #{Base64.strict_encode64('I_THISISNOTAREALAPIKEY:').strip}" } @gateway.expects(:ssl_request).with(:post, anything, anything, expected_headers).returns(successful_purchase_response) diff --git a/test/unit/gateways/plugnpay_test.rb b/test/unit/gateways/plugnpay_test.rb index 0ee24e4d241..5591e435414 100644 --- a/test/unit/gateways/plugnpay_test.rb +++ b/test/unit/gateways/plugnpay_test.rb @@ -36,35 +36,35 @@ def test_purchase_error end def test_capture_partial_amount - @gateway.expects(:ssl_post).with(anything, all_of(regexp_matches(/mode=mark/), regexp_matches(/card_amount=0.99/)), anything).returns("") + @gateway.expects(:ssl_post).with(anything, all_of(regexp_matches(/mode=mark/), regexp_matches(/card_amount=0.99/)), anything).returns('') @gateway.expects(:parse).returns({}) @gateway.capture(@amount - 1, @credit_card, @options) end def test_capture_full_amount - @gateway.expects(:ssl_post).with(anything, all_of(regexp_matches(/mode=mark/), regexp_matches(/card_amount=1.00/)), anything).returns("") + @gateway.expects(:ssl_post).with(anything, all_of(regexp_matches(/mode=mark/), regexp_matches(/card_amount=1.00/)), anything).returns('') @gateway.expects(:parse).returns({'auth_msg' => 'Blah blah blah Transaction may not be reauthorized'}, {}) @gateway.capture(@amount, @credit_card, @options) end def test_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/card_number=#{@credit_card.number}/), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/card_number=#{@credit_card.number}/), anything).returns('') @gateway.expects(:parse).returns({}) @gateway.credit(@amount, @credit_card, @options) end def test_deprecated_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/orderID=transaction_id/), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/orderID=transaction_id/), anything).returns('') @gateway.expects(:parse).returns({}) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - @gateway.credit(@amount, "transaction_id", @options) + @gateway.credit(@amount, 'transaction_id', @options) end end def test_refund - @gateway.expects(:ssl_post).with(anything, regexp_matches(/orderID=transaction_id/), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/orderID=transaction_id/), anything).returns('') @gateway.expects(:parse).returns({}) - @gateway.refund(@amount, "transaction_id", @options) + @gateway.refund(@amount, 'transaction_id', @options) end def test_add_address_outsite_north_america diff --git a/test/unit/gateways/pro_pay_test.rb b/test/unit/gateways/pro_pay_test.rb index ae462de87f3..b6704553ff2 100644 --- a/test/unit/gateways/pro_pay_test.rb +++ b/test/unit/gateways/pro_pay_test.rb @@ -56,7 +56,7 @@ def test_failed_authorize def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - response = @gateway.capture(@amount, "auth", @options) + response = @gateway.capture(@amount, 'auth', @options) assert_success response assert_equal '24', response.authorization @@ -66,7 +66,7 @@ def test_successful_capture def test_failed_capture @gateway.expects(:ssl_post).returns(failed_capture_response) - response = @gateway.capture(@amount, "invalid-auth", @options) + response = @gateway.capture(@amount, 'invalid-auth', @options) assert_failure response assert_equal '51', response.error_code assert_equal 'Invalid transNum and/or Unable to act perform actions on transNum due to funding', response.message @@ -145,7 +145,7 @@ def test_failed_verify response = @gateway.verify(@credit_card, @options) assert_failure response - assert_equal "58", response.error_code + assert_equal '58', response.error_code end def test_scrub diff --git a/test/unit/gateways/psigate_test.rb b/test/unit/gateways/psigate_test.rb index b3c76703c65..1bcb49689fb 100644 --- a/test/unit/gateways/psigate_test.rb +++ b/test/unit/gateways/psigate_test.rb @@ -9,7 +9,7 @@ def setup @amount = 100 @credit_card = credit_card('4111111111111111') - @options = { :order_id => "1", :billing_address => address } + @options = { :order_id => '1', :billing_address => address } end def test_successful_authorization @@ -38,23 +38,23 @@ def test_failed_purchase end def test_deprecated_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/<OrderID>transaction_id<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<OrderID>transaction_id<\//), anything).returns('') @gateway.expects(:parse).returns({}) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - @gateway.credit(@amount, "transaction_id", @options) + @gateway.credit(@amount, 'transaction_id', @options) end end def test_refund - @gateway.expects(:ssl_post).with(anything, regexp_matches(/<OrderID>transaction_id<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<OrderID>transaction_id<\//), anything).returns('') @gateway.expects(:parse).returns({}) - @gateway.refund(@amount, "transaction_id", @options) + @gateway.refund(@amount, 'transaction_id', @options) end def test_void - @gateway.expects(:ssl_post).with(anything, regexp_matches(/<OrderID>transaction_id<\//), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/<OrderID>transaction_id<\//), anything).returns('') @gateway.expects(:parse).returns({}) - @gateway.void("transaction_id;1", @options) + @gateway.void('transaction_id;1', @options) end def test_amount_style diff --git a/test/unit/gateways/psl_card_test.rb b/test/unit/gateways/psl_card_test.rb index 9c6aca35b82..64d62400301 100644 --- a/test/unit/gateways/psl_card_test.rb +++ b/test/unit/gateways/psl_card_test.rb @@ -55,10 +55,10 @@ def test_cvv_result private def successful_purchase_response - "ResponseCode=00&Message=AUTHCODE:01256&CrossReference=08012522454901256086&First4=4543&Last4=9982&ExpMonth=12&ExpYear=2010&AVSCV2Check=ALL MATCH&Amount=1000&QAAddress=76 Roseby Avenue Manchester&QAPostcode=M63X 7TH&MerchantName=Merchant Name&QAName=John Smith" + 'ResponseCode=00&Message=AUTHCODE:01256&CrossReference=08012522454901256086&First4=4543&Last4=9982&ExpMonth=12&ExpYear=2010&AVSCV2Check=ALL MATCH&Amount=1000&QAAddress=76 Roseby Avenue Manchester&QAPostcode=M63X 7TH&MerchantName=Merchant Name&QAName=John Smith' end def unsuccessful_purchase_response - "ResponseCode=05&Message=CARD DECLINED&QAAddress=The Parkway Larches Approach Hull North Humberside&QAPostcode=HU7 9OP&MerchantName=Merchant Name&QAName=" + 'ResponseCode=05&Message=CARD DECLINED&QAAddress=The Parkway Larches Approach Hull North Humberside&QAPostcode=HU7 9OP&MerchantName=Merchant Name&QAName=' end end \ No newline at end of file diff --git a/test/unit/gateways/qbms_test.rb b/test/unit/gateways/qbms_test.rb index ee8095368cf..894a3e0571d 100644 --- a/test/unit/gateways/qbms_test.rb +++ b/test/unit/gateways/qbms_test.rb @@ -5,8 +5,8 @@ def setup Base.mode = :test @gateway = QbmsGateway.new( - :login => "test", - :ticket => "abc123", + :login => 'test', + :ticket => 'abc123', :pem => 'PEM') @amount = 100 @@ -45,7 +45,7 @@ def test_truncated_address_is_sent with(anything, regexp_matches(/12345 Ridiculously Lengthy Roa\<.*445566778\</), anything). returns(charge_response) - options = { :billing_address => address.update(:address1 => "12345 Ridiculously Lengthy Road Name", :zip => '4455667788') } + options = { :billing_address => address.update(:address1 => '12345 Ridiculously Lengthy Road Name', :zip => '4455667788') } assert response = @gateway.purchase(@amount, @card, options) assert_success response end @@ -61,7 +61,7 @@ def test_partial_address_is_ok def test_successful_void @gateway.expects(:ssl_post).returns(void_response) - assert response = @gateway.void("x") + assert response = @gateway.void('x') assert_instance_of Response, response assert_success response end @@ -70,7 +70,7 @@ def test_successful_deprecated_credit @gateway.expects(:ssl_post).returns(credit_response) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - assert response = @gateway.credit(@amount, "x") + assert response = @gateway.credit(@amount, 'x') assert_instance_of Response, response assert_success response end @@ -79,7 +79,7 @@ def test_successful_deprecated_credit def test_successful_refund @gateway.expects(:ssl_post).returns(credit_response) - assert response = @gateway.refund(@amount, "x") + assert response = @gateway.refund(@amount, 'x') assert_instance_of Response, response assert_success response end @@ -90,17 +90,17 @@ def test_avs_result assert_equal 'Y', response.avs_result['street_match'] assert_equal 'Y', response.avs_result['postal_match'] - @gateway.expects(:ssl_post).returns(authorization_response(:avs_street => "Fail")) + @gateway.expects(:ssl_post).returns(authorization_response(:avs_street => 'Fail')) assert response = @gateway.authorize(@amount, @card) assert_equal 'N', response.avs_result['street_match'] assert_equal 'Y', response.avs_result['postal_match'] - @gateway.expects(:ssl_post).returns(authorization_response(:avs_zip => "Fail")) + @gateway.expects(:ssl_post).returns(authorization_response(:avs_zip => 'Fail')) assert response = @gateway.authorize(@amount, @card) assert_equal 'Y', response.avs_result['street_match'] assert_equal 'N', response.avs_result['postal_match'] - @gateway.expects(:ssl_post).returns(authorization_response(:avs_street => "Fail", :avs_zip => "Fail")) + @gateway.expects(:ssl_post).returns(authorization_response(:avs_street => 'Fail', :avs_zip => 'Fail')) assert response = @gateway.authorize(@amount, @card) assert_equal 'N', response.avs_result['street_match'] assert_equal 'N', response.avs_result['postal_match'] @@ -111,11 +111,11 @@ def test_cvv_result assert response = @gateway.authorize(@amount, @card) assert_equal 'M', response.cvv_result['code'] - @gateway.expects(:ssl_post).returns(authorization_response(:card_security_code_match => "Fail")) + @gateway.expects(:ssl_post).returns(authorization_response(:card_security_code_match => 'Fail')) assert response = @gateway.authorize(@amount, @card) assert_equal 'N', response.cvv_result['code'] - @gateway.expects(:ssl_post).returns(authorization_response(:card_security_code_match => "NotAvailable")) + @gateway.expects(:ssl_post).returns(authorization_response(:card_security_code_match => 'NotAvailable')) assert response = @gateway.authorize(@amount, @card) assert_equal 'P', response.cvv_result['code'] end @@ -147,7 +147,7 @@ def test_failed_authorization def test_use_test_url_when_overwriting_with_test_option ActiveMerchant::Billing::Base.mode = :production - @gateway = QbmsGateway.new(:login => "test", :ticket => "abc123", :test => true) + @gateway = QbmsGateway.new(:login => 'test', :ticket => 'abc123', :test => true) @gateway.stubs(:parse).returns({}) @gateway.expects(:ssl_post).with(QbmsGateway.test_url, anything, anything).returns(authorization_response) @gateway.authorize(@amount, @card) @@ -163,7 +163,7 @@ def test_scrub # helper methods start here def query_response(opts = {}) - wrap "MerchantAccountQuery", opts, <<-"XML" + wrap 'MerchantAccountQuery', opts, <<-"XML" <ConvenienceFees>0.0</ConvenienceFees> <CreditCardType>Visa</CreditCardType> <CreditCardType>MasterCard</CreditCardType> @@ -173,12 +173,12 @@ def query_response(opts = {}) def authorization_response(opts = {}) opts = { - :avs_street => "Pass", - :avs_zip => "Pass", - :card_security_code_match => "Pass", + :avs_street => 'Pass', + :avs_zip => 'Pass', + :card_security_code_match => 'Pass', }.merge(opts) - wrap "CustomerCreditCardAuth", opts, <<-"XML" + wrap 'CustomerCreditCardAuth', opts, <<-"XML" <CreditCardTransID>1000</CreditCardTransID> <AuthorizationCode>STRTYPE</AuthorizationCode> <AVSStreet>#{opts[:avs_street]}</AVSStreet> @@ -189,7 +189,7 @@ def authorization_response(opts = {}) end def capture_response(opts = {}) - wrap "CustomerCreditCardCapture", opts, <<-"XML" + wrap 'CustomerCreditCardCapture', opts, <<-"XML" <CreditCardTransID>1000</CreditCardTransID> <AuthorizationCode>STRTYPE</AuthorizationCode> <MerchantAccountNumber>STRTYPE</MerchantAccountNumber> @@ -200,12 +200,12 @@ def capture_response(opts = {}) def charge_response(opts = {}) opts = { - :avs_street => "Pass", - :avs_zip => "Pass", - :card_security_code_match => "Pass", + :avs_street => 'Pass', + :avs_zip => 'Pass', + :card_security_code_match => 'Pass', }.merge(opts) - wrap "CustomerCreditCardCharge", opts, <<-"XML" + wrap 'CustomerCreditCardCharge', opts, <<-"XML" <CreditCardTransID>1000</CreditCardTransID> <AuthorizationCode>STRTYPE</AuthorizationCode> <AVSStreet>#{opts[:avs_street]}</AVSStreet> @@ -218,14 +218,14 @@ def charge_response(opts = {}) end def void_response(opts = {}) - wrap "CustomerCreditCardTxnVoid", opts, <<-"XML" + wrap 'CustomerCreditCardTxnVoid', opts, <<-"XML" <CreditCardTransID>1000</CreditCardTransID> <ClientTransID>STRTYPE</ClientTransID> XML end def credit_response(opts = {}) - wrap "CustomerCreditCardTxnVoidOrRefund", opts, <<-"XML" + wrap 'CustomerCreditCardTxnVoidOrRefund', opts, <<-"XML" <CreditCardTransID>1000</CreditCardTransID> <VoidOrRefundTxnType>STRTYPE</VoidOrRefundTxnType> <MerchantAccountNumber>STRTYPE</MerchantAccountNumber> @@ -237,7 +237,7 @@ def credit_response(opts = {}) def wrap(type, opts, xml) opts = { :signon_status_code => 0, - :request_id => "x", + :request_id => 'x', :status_code => 0, }.merge(opts) diff --git a/test/unit/gateways/quickbooks_test.rb b/test/unit/gateways/quickbooks_test.rb index c8f5641d1ce..bf6bc9d2017 100644 --- a/test/unit/gateways/quickbooks_test.rb +++ b/test/unit/gateways/quickbooks_test.rb @@ -21,7 +21,7 @@ def setup description: 'Store Purchase' } - @authorization = "ECZ7U0SO423E" + @authorization = 'ECZ7U0SO423E' end def test_successful_purchase @@ -29,7 +29,7 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "EF1IQ9GGXS2D", response.authorization + assert_equal 'EF1IQ9GGXS2D', response.authorization assert response.test? end diff --git a/test/unit/gateways/quickpay_v10_test.rb b/test/unit/gateways/quickpay_v10_test.rb index cdd88a1938f..aac4bdb1e10 100644 --- a/test/unit/gateways/quickpay_v10_test.rb +++ b/test/unit/gateways/quickpay_v10_test.rb @@ -26,7 +26,7 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert response assert_success response - assert_equal "1145", response.authorization + assert_equal '1145', response.authorization assert response.test? end.check_request do |endpoint, data, headers| parsed = parse(data) @@ -45,13 +45,13 @@ def test_successful_authorization stub_comms do assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "1145", response.authorization + assert_equal '1145', response.authorization assert response.test? end.check_request do |endpoint, data, headers| parsed_data = parse(data) if parsed_data['order_id'] assert_match %r{/payments}, endpoint - assert_match "1.1.1.1", @options[:customer_ip] + assert_match '1.1.1.1', @options[:customer_ip] else assert_match %r{/payments/\d+/authorize}, endpoint end @@ -111,7 +111,7 @@ def test_successful_verify @gateway.verify(@credit_card, @options) end.respond_with(successful_authorization_response) assert_success response - assert_equal "OK", response.message + assert_equal 'OK', response.message end def test_failed_verify @@ -119,7 +119,7 @@ def test_failed_verify @gateway.verify(@credit_card, @options) end.respond_with(failed_authorization_response, {'id' => 1145}.to_json) assert_failure response - assert_equal "Validation error", response.message + assert_equal 'Validation error', response.message end def test_supported_countries @@ -146,108 +146,108 @@ def test_transcript_scrubbing def successful_payment_response { - "id" =>1145, - "order_id" =>"310f59c57a", - "accepted" =>false, - "test_mode" =>false, - "branding_id" =>nil, - "variables" =>{}, - "acquirer" =>nil, - "operations" =>[], - "metadata" =>{}, - "created_at" =>"2015-03-30T16:56:17Z", - "balance" =>0, - "currency" =>"DKK" + 'id' =>1145, + 'order_id' =>'310f59c57a', + 'accepted' =>false, + 'test_mode' =>false, + 'branding_id' =>nil, + 'variables' =>{}, + 'acquirer' =>nil, + 'operations' =>[], + 'metadata' =>{}, + 'created_at' =>'2015-03-30T16:56:17Z', + 'balance' =>0, + 'currency' =>'DKK' }.to_json end def successful_authorization_response { - "id" => 1145, - "order_id" => "310f59c57a", - "accepted" => false, - "test_mode" => true, - "branding_id" => nil, - "variables" => {}, - "acquirer" => "clearhaus", - "operations" => [], - "metadata" => { - "type" =>"card", - "brand" =>"quickpay-test-card", - "last4" =>"0008", - "exp_month" =>9, - "exp_year" =>2016, - "country" =>"DK", - "is_3d_secure" =>false, - "customer_ip" =>nil, - "customer_country" =>nil + 'id' => 1145, + 'order_id' => '310f59c57a', + 'accepted' => false, + 'test_mode' => true, + 'branding_id' => nil, + 'variables' => {}, + 'acquirer' => 'clearhaus', + 'operations' => [], + 'metadata' => { + 'type' =>'card', + 'brand' =>'quickpay-test-card', + 'last4' =>'0008', + 'exp_month' =>9, + 'exp_year' =>2016, + 'country' =>'DK', + 'is_3d_secure' =>false, + 'customer_ip' =>nil, + 'customer_country' =>nil }, - "created_at" => "2015-03-30T16:56:17Z", - "balance" => 0, - "currency" => "DKK" + 'created_at' => '2015-03-30T16:56:17Z', + 'balance' => 0, + 'currency' => 'DKK' }.to_json end def successful_capture_response { - "id" =>1145, - "order_id" =>"310f59c57a", - "accepted" =>true, - "test_mode" =>true, - "branding_id" =>nil, - "variables" =>{}, - "acquirer" =>"clearhaus", - "operations" =>[], - "metadata" =>{"type"=>"card", "brand"=>"quickpay-test-card", "last4"=>"0008", "exp_month"=>9, "exp_year"=>2016, "country"=>"DK", "is_3d_secure"=>false, "customer_ip"=>nil, "customer_country"=>nil}, - "created_at" =>"2015-03-30T16:56:17Z", - "balance" =>0, - "currency" =>"DKK" + 'id' =>1145, + 'order_id' =>'310f59c57a', + 'accepted' =>true, + 'test_mode' =>true, + 'branding_id' =>nil, + 'variables' =>{}, + 'acquirer' =>'clearhaus', + 'operations' =>[], + 'metadata' =>{'type'=>'card', 'brand'=>'quickpay-test-card', 'last4'=>'0008', 'exp_month'=>9, 'exp_year'=>2016, 'country'=>'DK', 'is_3d_secure'=>false, 'customer_ip'=>nil, 'customer_country'=>nil}, + 'created_at' =>'2015-03-30T16:56:17Z', + 'balance' =>0, + 'currency' =>'DKK' }.to_json end def succesful_refund_response { - "id" =>1145, - "order_id" =>"310f59c57a", - "accepted" =>true, - "test_mode" =>true, - "branding_id" =>nil, - "variables" =>{}, - "acquirer" =>"clearhaus", - "operations" =>[], - "metadata"=>{ - "type" =>"card", - "brand" =>"quickpay-test-card", - "last4" =>"0008", - "exp_month" =>9, - "exp_year" =>2016, - "country" =>"DK", - "is_3d_secure" =>false, - "customer_ip" =>nil, - "customer_country" =>nil + 'id' =>1145, + 'order_id' =>'310f59c57a', + 'accepted' =>true, + 'test_mode' =>true, + 'branding_id' =>nil, + 'variables' =>{}, + 'acquirer' =>'clearhaus', + 'operations' =>[], + 'metadata'=>{ + 'type' =>'card', + 'brand' =>'quickpay-test-card', + 'last4' =>'0008', + 'exp_month' =>9, + 'exp_year' =>2016, + 'country' =>'DK', + 'is_3d_secure' =>false, + 'customer_ip' =>nil, + 'customer_country' =>nil }, - "created_at" =>"2015-03-30T16:56:17Z", - "balance" =>100, - "currency" =>"DKK" + 'created_at' =>'2015-03-30T16:56:17Z', + 'balance' =>100, + 'currency' =>'DKK' }.to_json end def failed_authorization_response { - 'message' => "Validation error", - "errors" => { - "id" => ["is not valid"] + 'message' => 'Validation error', + 'errors' => { + 'id' => ['is not valid'] } }.to_json end def failed_payment_response { - "message" => "Validation error", - "errors" => { - "currency" => ["must be three uppercase letters"] + 'message' => 'Validation error', + 'errors' => { + 'currency' => ['must be three uppercase letters'] }, - "error_code" => nil + 'error_code' => nil }.to_json end diff --git a/test/unit/gateways/quickpay_v4to7_test.rb b/test/unit/gateways/quickpay_v4to7_test.rb index fd14e56b563..e666efbadb3 100644 --- a/test/unit/gateways/quickpay_v4to7_test.rb +++ b/test/unit/gateways/quickpay_v4to7_test.rb @@ -4,7 +4,7 @@ class QuickpayV4to7Test < Test::Unit::TestCase include CommStub def merchant_id - "80000000000" + '80000000000' end def setup @@ -133,7 +133,7 @@ def test_supported_card_types end def test_add_testmode_does_not_add_testmode_if_transaction_id_present - post_hash = {:transaction => "12345"} + post_hash = {:transaction => '12345'} @gateway.send(:add_testmode, post_hash) assert_equal nil, post_hash[:testmode] end @@ -146,7 +146,7 @@ def test_add_testmode_adds_a_testmode_param_if_transaction_id_not_present def test_finalize_is_disabled_by_default stub_comms(@gateway, :ssl_request) do - @gateway.capture(@amount, "12345") + @gateway.capture(@amount, '12345') end.check_request do |method, endpoint, data, headers| assert data =~ /finalize=0/ end.respond_with(successful_capture_response) @@ -154,7 +154,7 @@ def test_finalize_is_disabled_by_default def test_finalize_is_enabled stub_comms(@gateway, :ssl_request) do - @gateway.capture(@amount, "12345", finalize: true) + @gateway.capture(@amount, '12345', finalize: true) end.check_request do |method, endpoint, data, headers| assert data =~ /finalize=1/ end.respond_with(successful_capture_response) @@ -192,33 +192,33 @@ def failed_authorization_response def expected_store_parameters_v6 { - "cardnumber"=>["4242424242424242"], - "cvd"=>["123"], - "expirationdate"=>[expected_expiration_date], - "ordernumber"=>["fa73664073e23597bbdd"], - "description"=>["Storing Card"], - "testmode"=>["1"], - "protocol"=>["6"], - "msgtype"=>["subscribe"], - "merchant"=>[merchant_id], - "md5check"=>[mock_md5_hash] + 'cardnumber'=>['4242424242424242'], + 'cvd'=>['123'], + 'expirationdate'=>[expected_expiration_date], + 'ordernumber'=>['fa73664073e23597bbdd'], + 'description'=>['Storing Card'], + 'testmode'=>['1'], + 'protocol'=>['6'], + 'msgtype'=>['subscribe'], + 'merchant'=>[merchant_id], + 'md5check'=>[mock_md5_hash] } end def expected_store_parameters_v7 { - "amount"=>["0"], - "currency"=>["DKK"], - "cardnumber"=>["4242424242424242"], - "cvd"=>["123"], - "expirationdate"=>[expected_expiration_date], - "ordernumber"=>["ed7546cb4ceb8f017ea4"], - "description"=>["Storing Card"], - "testmode"=>["1"], - "protocol"=>["7"], - "msgtype"=>["subscribe"], - "merchant"=>[merchant_id], - "md5check"=>[mock_md5_hash] + 'amount'=>['0'], + 'currency'=>['DKK'], + 'cardnumber'=>['4242424242424242'], + 'cvd'=>['123'], + 'expirationdate'=>[expected_expiration_date], + 'ordernumber'=>['ed7546cb4ceb8f017ea4'], + 'description'=>['Storing Card'], + 'testmode'=>['1'], + 'protocol'=>['7'], + 'msgtype'=>['subscribe'], + 'merchant'=>[merchant_id], + 'md5check'=>[mock_md5_hash] } end @@ -227,6 +227,6 @@ def expected_expiration_date end def mock_md5_hash - "mock_hash" + 'mock_hash' end end diff --git a/test/unit/gateways/qvalent_test.rb b/test/unit/gateways/qvalent_test.rb index d16d01c7bff..12a53e48d1d 100644 --- a/test/unit/gateways/qvalent_test.rb +++ b/test/unit/gateways/qvalent_test.rb @@ -1,15 +1,15 @@ -require "test_helper" +require 'test_helper' class QvalentTest < Test::Unit::TestCase include CommStub def setup @gateway = QvalentGateway.new( - username: "username", - password: "password", - merchant: "merchant", - pem: "pem", - pem_password: "pempassword" + username: 'username', + password: 'password', + merchant: 'merchant', + pem: 'pem', + pem_password: 'pempassword' ) @credit_card = credit_card @@ -23,7 +23,7 @@ def test_successful_purchase assert_success response - assert_equal "5d53a33d960c46d00f5dc061947d998c", response.authorization + assert_equal '5d53a33d960c46d00f5dc061947d998c', response.authorization assert response.test? end @@ -33,7 +33,7 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "Invalid card number (no such number)", response.message + assert_equal 'Invalid card number (no such number)', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code assert response.test? end @@ -45,7 +45,7 @@ def test_successful_authorize assert_success response - assert_equal "21c74c8f08bca415b5373022e6194f74", response.authorization + assert_equal '21c74c8f08bca415b5373022e6194f74', response.authorization assert response.test? end @@ -55,28 +55,28 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Expired card",response.message + assert_equal 'Expired card',response.message assert response.test? end def test_successful_capture response = stub_comms do - @gateway.capture(@amount, "auth") + @gateway.capture(@amount, 'auth') end.respond_with(successful_capture_response) assert_success response - assert_equal "fedf9ea13afa46872592d62e8cdcb0a3", response.authorization + assert_equal 'fedf9ea13afa46872592d62e8cdcb0a3', response.authorization assert response.test? end def test_failed_capture response = stub_comms do - @gateway.capture(@amount, "") + @gateway.capture(@amount, '') end.respond_with(failed_capture_response) assert_failure response - assert_equal "Invalid Parameters - order.authId: Required field", response.message + assert_equal 'Invalid Parameters - order.authId: Required field', response.message assert response.test? end @@ -86,7 +86,7 @@ def test_successful_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "5d53a33d960c46d00f5dc061947d998c", response.authorization + assert_equal '5d53a33d960c46d00f5dc061947d998c', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -99,7 +99,7 @@ def test_successful_refund def test_failed_refund response = stub_comms do - @gateway.refund(nil, "") + @gateway.refund(nil, '') end.respond_with(failed_refund_response) assert_failure response @@ -123,22 +123,22 @@ def test_failed_credit def test_successful_void response = stub_comms do - @gateway.void("auth") + @gateway.void('auth') end.respond_with(successful_void_response) assert_success response - assert_equal "67686b64b544335815002fd85704c8a1", response.authorization + assert_equal '67686b64b544335815002fd85704c8a1', response.authorization assert response.test? end def test_failed_void response = stub_comms do - @gateway.void("") + @gateway.void('') end.respond_with(failed_void_response) assert_failure response - assert_equal "Invalid Parameters - customer.originalOrderNumber: Required field", response.message + assert_equal 'Invalid Parameters - customer.originalOrderNumber: Required field', response.message assert response.test? end @@ -149,8 +149,8 @@ def test_successful_store assert_success response - assert_equal "RSL-20887450", response.authorization - assert_equal "Succeeded", response.message + assert_equal 'RSL-20887450', response.authorization + assert_equal 'Succeeded', response.message assert response.test? end @@ -160,7 +160,7 @@ def test_failed_store end.respond_with(failed_store_response) assert_failure response - assert_equal "Invalid card number (no such number)", response.message + assert_equal 'Invalid card number (no such number)', response.message assert_equal Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code assert response.test? end @@ -171,7 +171,7 @@ def test_empty_response_fails end.respond_with(empty_purchase_response) assert_failure response - assert_equal "Unable to read error message", response.message + assert_equal 'Unable to read error message', response.message end def test_3d_secure_fields diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb index ad4f0ce32f1..4830137b271 100644 --- a/test/unit/gateways/realex_test.rb +++ b/test/unit/gateways/realex_test.rb @@ -95,7 +95,7 @@ def test_deprecated_credit end def test_supported_countries - assert_equal ['IE', 'GB', "FR", "BE", "NL", "LU", "IT", "US", "CA", "ES"], RealexGateway.supported_countries + assert_equal ['IE', 'GB', 'FR', 'BE', 'NL', 'LU', 'IT', 'US', 'CA', 'ES'], RealexGateway.supported_countries end def test_supported_card_types diff --git a/test/unit/gateways/redsys_sha256_test.rb b/test/unit/gateways/redsys_sha256_test.rb index 67e093762ba..bab7b23ed96 100644 --- a/test/unit/gateways/redsys_sha256_test.rb +++ b/test/unit/gateways/redsys_sha256_test.rb @@ -7,8 +7,8 @@ def setup Base.mode = :test @credentials = { :login => '091952713', - :secret_key => "QIK77hYl6UFcoCYFKcj+ZjJg8Q6I93Dx", - :signature_algorithm => "sha256" + :secret_key => 'QIK77hYl6UFcoCYFKcj+ZjJg8Q6I93Dx', + :signature_algorithm => 'sha256' } @gateway = RedsysGateway.new(@credentials) @credit_card = credit_card('4548812049400004') @@ -34,18 +34,18 @@ def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) res = @gateway.purchase(100, credit_card, :order_id => '144742736014') assert_success res - assert_equal "Transaction Approved", res.message - assert_equal "144742736014|100|978", res.authorization + assert_equal 'Transaction Approved', res.message + assert_equal '144742736014|100|978', res.authorization assert_equal '144742736014', res.params['ds_order'] end # This one is being werid... def test_successful_purchase_requesting_credit_card_token @gateway.expects(:ssl_post).returns(successful_purchase_response_with_credit_card_token) - res = @gateway.purchase(100, "e55e1d0ef338e281baf1d0b5b68be433260ddea0", :order_id => '144742955848') + res = @gateway.purchase(100, 'e55e1d0ef338e281baf1d0b5b68be433260ddea0', :order_id => '144742955848') assert_success res - assert_equal "Transaction Approved", res.message - assert_equal "144742955848|100|978", res.authorization + assert_equal 'Transaction Approved', res.message + assert_equal '144742955848|100|978', res.authorization assert_equal '144742955848', res.params['ds_order'] assert_equal 'e55e1d0ef338e281baf1d0b5b68be433260ddea0', res.params['ds_merchant_identifier'] end @@ -54,7 +54,7 @@ def test_failed_purchase @gateway.expects(:ssl_post).returns(failed_purchase_response) res = @gateway.purchase(100, credit_card, :order_id => '144743314659') assert_failure res - assert_equal "SIS0093 ERROR", res.message + assert_equal 'SIS0093 ERROR', res.message end def test_purchase_without_order_id @@ -65,9 +65,9 @@ def test_purchase_without_order_id def test_error_purchase @gateway.expects(:ssl_post).returns(error_purchase_response) - res = @gateway.purchase(100, credit_card, :order_id => "123") + res = @gateway.purchase(100, credit_card, :order_id => '123') assert_failure res - assert_equal "SIS0051 ERROR", res.message + assert_equal 'SIS0051 ERROR', res.message end def test_refund_request @@ -77,18 +77,18 @@ def test_refund_request def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - res = @gateway.refund(100, "1001") + res = @gateway.refund(100, '1001') assert_success res - assert_equal "Refund / Confirmation approved", res.message - assert_equal "144743427234|100|978", res.authorization - assert_equal "144743427234", res.params['ds_order'] + assert_equal 'Refund / Confirmation approved', res.message + assert_equal '144743427234|100|978', res.authorization + assert_equal '144743427234', res.params['ds_order'] end def test_error_refund @gateway.expects(:ssl_post).returns(error_refund_response) - res = @gateway.refund(100, "1001") + res = @gateway.refund(100, '1001') assert_failure res - assert_equal "SIS0057 ERROR", res.message + assert_equal 'SIS0057 ERROR', res.message end # Remaining methods a pretty much the same, so we just test that @@ -98,13 +98,13 @@ def test_authorize @gateway.expects(:ssl_post).with( anything, all_of( - includes(CGI.escape("<DS_MERCHANT_TRANSACTIONTYPE>1</DS_MERCHANT_TRANSACTIONTYPE>")), - includes(CGI.escape("<DS_MERCHANT_PAN>4242424242424242</DS_MERCHANT_PAN>")), - includes(CGI.escape("<DS_MERCHANT_AMOUNT>100</DS_MERCHANT_AMOUNT>")) + includes(CGI.escape('<DS_MERCHANT_TRANSACTIONTYPE>1</DS_MERCHANT_TRANSACTIONTYPE>')), + includes(CGI.escape('<DS_MERCHANT_PAN>4242424242424242</DS_MERCHANT_PAN>')), + includes(CGI.escape('<DS_MERCHANT_AMOUNT>100</DS_MERCHANT_AMOUNT>')) ), anything ).returns(successful_authorize_response) - response = @gateway.authorize(100, credit_card, :order_id => "144743367273") + response = @gateway.authorize(100, credit_card, :order_id => '144743367273') assert_success response end @@ -116,7 +116,7 @@ def test_authorize_without_order_id def test_bad_order_id_format stub_comms(@gateway, :ssl_request) do - @gateway.authorize(100, credit_card, order_id: "Una#cce-ptable44Format") + @gateway.authorize(100, credit_card, order_id: 'Una#cce-ptable44Format') end.check_request do |method, endpoint, data, headers| assert_match(/MERCHANT_ORDER%3E\d\d\d\dUnaccept%3C/, data) end.respond_with(successful_authorize_response) @@ -124,7 +124,7 @@ def test_bad_order_id_format def test_order_id_numeric_start_but_too_long stub_comms(@gateway, :ssl_request) do - @gateway.authorize(100, credit_card, order_id: "1234ThisIs]FineButTooLong") + @gateway.authorize(100, credit_card, order_id: '1234ThisIs]FineButTooLong') end.check_request do |method, endpoint, data, headers| assert_match(/MERCHANT_ORDER%3E1234ThisIsFi%3C/, data) end.respond_with(successful_authorize_response) @@ -134,9 +134,9 @@ def test_capture @gateway.expects(:ssl_post).with( anything, all_of( - includes(CGI.escape("<DS_MERCHANT_TRANSACTIONTYPE>2</DS_MERCHANT_TRANSACTIONTYPE>")), - includes(CGI.escape("<DS_MERCHANT_ORDER>144743367273</DS_MERCHANT_ORDER>")), - includes(CGI.escape("<DS_MERCHANT_AMOUNT>100</DS_MERCHANT_AMOUNT>")) + includes(CGI.escape('<DS_MERCHANT_TRANSACTIONTYPE>2</DS_MERCHANT_TRANSACTIONTYPE>')), + includes(CGI.escape('<DS_MERCHANT_ORDER>144743367273</DS_MERCHANT_ORDER>')), + includes(CGI.escape('<DS_MERCHANT_AMOUNT>100</DS_MERCHANT_AMOUNT>')) ), anything ).returns(successful_capture_response) @@ -147,10 +147,10 @@ def test_void @gateway.expects(:ssl_post).with( anything, all_of( - includes(CGI.escape("<DS_MERCHANT_TRANSACTIONTYPE>9</DS_MERCHANT_TRANSACTIONTYPE>")), - includes(CGI.escape("<DS_MERCHANT_ORDER>144743389043</DS_MERCHANT_ORDER>")), - includes(CGI.escape("<DS_MERCHANT_AMOUNT>100</DS_MERCHANT_AMOUNT>")), - includes(CGI.escape("<DS_MERCHANT_CURRENCY>978</DS_MERCHANT_CURRENCY>")) + includes(CGI.escape('<DS_MERCHANT_TRANSACTIONTYPE>9</DS_MERCHANT_TRANSACTIONTYPE>')), + includes(CGI.escape('<DS_MERCHANT_ORDER>144743389043</DS_MERCHANT_ORDER>')), + includes(CGI.escape('<DS_MERCHANT_AMOUNT>100</DS_MERCHANT_AMOUNT>')), + includes(CGI.escape('<DS_MERCHANT_CURRENCY>978</DS_MERCHANT_CURRENCY>')) ), anything ).returns(successful_void_response) @@ -160,7 +160,7 @@ def test_void def test_override_currency @gateway.expects(:ssl_post).with( anything, - includes(CGI.escape("<DS_MERCHANT_CURRENCY>840</DS_MERCHANT_CURRENCY>")), + includes(CGI.escape('<DS_MERCHANT_CURRENCY>840</DS_MERCHANT_CURRENCY>')), anything ).returns(successful_purchase_response) @gateway.authorize(100, credit_card, :order_id => '1001', :currency => 'USD') @@ -176,19 +176,19 @@ def test_successful_verify_with_failed_void @gateway.expects(:ssl_post).times(2).returns(successful_authorize_response).then.returns(failed_void_response) response = @gateway.verify(credit_card, :order_id => '144743367273') assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message end def test_unsuccessful_verify @gateway.expects(:ssl_post).returns(failed_authorize_response) - response = @gateway.verify(credit_card, :order_id => "141278225678") + response = @gateway.verify(credit_card, :order_id => '141278225678') assert_failure response - assert_equal "SIS0093 ERROR", response.message + assert_equal 'SIS0093 ERROR', response.message end def test_unknown_currency assert_raise ArgumentError do - @gateway.purchase(100, credit_card, @options.merge(currency: "HUH WUT")) + @gateway.purchase(100, credit_card, @options.merge(currency: 'HUH WUT')) end end @@ -262,11 +262,11 @@ def generate_order_id # one with card and another without. def purchase_request - "entrada=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3CREQUEST%3E%3CDATOSENTRADA%3E%3CDS_Version%3E0.1%3C%2FDS_Version%3E%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%3CDS_MERCHANT_AMOUNT%3E100%3C%2FDS_MERCHANT_AMOUNT%3E%3CDS_MERCHANT_ORDER%3E144742736014%3C%2FDS_MERCHANT_ORDER%3E%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%3CDS_MERCHANT_TITULAR%3ELongbob+Longsen%3C%2FDS_MERCHANT_TITULAR%3E%3CDS_MERCHANT_PAN%3E4548812049400004%3C%2FDS_MERCHANT_PAN%3E%3CDS_MERCHANT_EXPIRYDATE%3E1709%3C%2FDS_MERCHANT_EXPIRYDATE%3E%3CDS_MERCHANT_CVV2%3E123%3C%2FDS_MERCHANT_CVV2%3E%3C%2FDATOSENTRADA%3E%3CDS_SIGNATUREVERSION%3EHMAC_SHA256_V1%3C%2FDS_SIGNATUREVERSION%3E%3CDS_SIGNATURE%3Eq9QH2P%2B4qm8w%2FS85KRPVaepWOrOT2RXlEmyPUce5XRM%3D%3C%2FDS_SIGNATURE%3E%3C%2FREQUEST%3E" + 'entrada=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3CREQUEST%3E%3CDATOSENTRADA%3E%3CDS_Version%3E0.1%3C%2FDS_Version%3E%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%3CDS_MERCHANT_AMOUNT%3E100%3C%2FDS_MERCHANT_AMOUNT%3E%3CDS_MERCHANT_ORDER%3E144742736014%3C%2FDS_MERCHANT_ORDER%3E%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%3CDS_MERCHANT_TITULAR%3ELongbob+Longsen%3C%2FDS_MERCHANT_TITULAR%3E%3CDS_MERCHANT_PAN%3E4548812049400004%3C%2FDS_MERCHANT_PAN%3E%3CDS_MERCHANT_EXPIRYDATE%3E1709%3C%2FDS_MERCHANT_EXPIRYDATE%3E%3CDS_MERCHANT_CVV2%3E123%3C%2FDS_MERCHANT_CVV2%3E%3C%2FDATOSENTRADA%3E%3CDS_SIGNATUREVERSION%3EHMAC_SHA256_V1%3C%2FDS_SIGNATUREVERSION%3E%3CDS_SIGNATURE%3Eq9QH2P%2B4qm8w%2FS85KRPVaepWOrOT2RXlEmyPUce5XRM%3D%3C%2FDS_SIGNATURE%3E%3C%2FREQUEST%3E' end def purchase_request_with_credit_card_token - "entrada=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3CREQUEST%3E%3CDATOSENTRADA%3E%3CDS_Version%3E0.1%3C%2FDS_Version%3E%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%3CDS_MERCHANT_AMOUNT%3E100%3C%2FDS_MERCHANT_AMOUNT%3E%3CDS_MERCHANT_ORDER%3E144742884282%3C%2FDS_MERCHANT_ORDER%3E%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%3CDS_MERCHANT_IDENTIFIER%3E3126bb8b80a79e66eb1ecc39e305288b60075f86%3C%2FDS_MERCHANT_IDENTIFIER%3E%3C%2FDATOSENTRADA%3E%3CDS_SIGNATUREVERSION%3EHMAC_SHA256_V1%3C%2FDS_SIGNATUREVERSION%3E%3CDS_SIGNATURE%3EFFiY%2B5BTlw1zGwSHySBKWJw4DN7SbgVNSgWMTX8sll0%3D%3C%2FDS_SIGNATURE%3E%3C%2FREQUEST%3E" + 'entrada=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3CREQUEST%3E%3CDATOSENTRADA%3E%3CDS_Version%3E0.1%3C%2FDS_Version%3E%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%3CDS_MERCHANT_AMOUNT%3E100%3C%2FDS_MERCHANT_AMOUNT%3E%3CDS_MERCHANT_ORDER%3E144742884282%3C%2FDS_MERCHANT_ORDER%3E%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%3CDS_MERCHANT_IDENTIFIER%3E3126bb8b80a79e66eb1ecc39e305288b60075f86%3C%2FDS_MERCHANT_IDENTIFIER%3E%3C%2FDATOSENTRADA%3E%3CDS_SIGNATUREVERSION%3EHMAC_SHA256_V1%3C%2FDS_SIGNATUREVERSION%3E%3CDS_SIGNATURE%3EFFiY%2B5BTlw1zGwSHySBKWJw4DN7SbgVNSgWMTX8sll0%3D%3C%2FDS_SIGNATURE%3E%3C%2FREQUEST%3E' end def successful_purchase_response @@ -294,7 +294,7 @@ def failed_authorize_response end def refund_request - "entrada=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3CREQUEST%3E%3CDATOSENTRADA%3E%3CDS_Version%3E0.1%3C%2FDS_Version%3E%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%3CDS_MERCHANT_AMOUNT%3E100%3C%2FDS_MERCHANT_AMOUNT%3E%3CDS_MERCHANT_ORDER%3E144743427234%3C%2FDS_MERCHANT_ORDER%3E%3CDS_MERCHANT_TRANSACTIONTYPE%3E3%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%3C%2FDATOSENTRADA%3E%3CDS_SIGNATUREVERSION%3EHMAC_SHA256_V1%3C%2FDS_SIGNATUREVERSION%3E%3CDS_SIGNATURE%3EQhNVtjoee6s%2Bvo%2B5bJVM4esT58bz7zkY1Xe7qjdmxA0%3D%3C%2FDS_SIGNATURE%3E%3C%2FREQUEST%3E" + 'entrada=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3CREQUEST%3E%3CDATOSENTRADA%3E%3CDS_Version%3E0.1%3C%2FDS_Version%3E%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%3CDS_MERCHANT_AMOUNT%3E100%3C%2FDS_MERCHANT_AMOUNT%3E%3CDS_MERCHANT_ORDER%3E144743427234%3C%2FDS_MERCHANT_ORDER%3E%3CDS_MERCHANT_TRANSACTIONTYPE%3E3%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%3C%2FDATOSENTRADA%3E%3CDS_SIGNATUREVERSION%3EHMAC_SHA256_V1%3C%2FDS_SIGNATUREVERSION%3E%3CDS_SIGNATURE%3EQhNVtjoee6s%2Bvo%2B5bJVM4esT58bz7zkY1Xe7qjdmxA0%3D%3C%2FDS_SIGNATURE%3E%3C%2FREQUEST%3E' end def successful_refund_response diff --git a/test/unit/gateways/redsys_test.rb b/test/unit/gateways/redsys_test.rb index c955ad3b67a..fa143deb3b9 100644 --- a/test/unit/gateways/redsys_test.rb +++ b/test/unit/gateways/redsys_test.rb @@ -7,7 +7,7 @@ def setup Base.mode = :test @credentials = { :login => '091952713', - :secret_key => "qwertyasdf0123456789", + :secret_key => 'qwertyasdf0123456789', :terminal => '1', } @gateway = RedsysGateway.new(@credentials) @@ -32,8 +32,8 @@ def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) res = @gateway.purchase(123, credit_card, @options) assert_success res - assert_equal "Transaction Approved", res.message - assert_equal "1001|123|978", res.authorization + assert_equal 'Transaction Approved', res.message + assert_equal '1001|123|978', res.authorization assert_equal '1001', res.params['ds_order'] end @@ -41,8 +41,8 @@ def test_successful_purchase_requesting_credit_card_token @gateway.expects(:ssl_post).returns(successful_purchase_response_with_credit_card_token) res = @gateway.purchase(123, credit_card, @options) assert_success res - assert_equal "Transaction Approved", res.message - assert_equal "141661632759|100|978", res.authorization + assert_equal 'Transaction Approved', res.message + assert_equal '141661632759|100|978', res.authorization assert_equal '141661632759', res.params['ds_order'] assert_equal '77bff3a969d6f97b2ec815448cdcff453971f573', res.params['ds_merchant_identifier'] end @@ -51,7 +51,7 @@ def test_failed_purchase @gateway.expects(:ssl_post).returns(failed_purchase_response) res = @gateway.purchase(123, credit_card, @options) assert_failure res - assert_equal "Refusal with no specific reason", res.message + assert_equal 'Refusal with no specific reason', res.message assert_equal '1002', res.params['ds_order'] end @@ -65,7 +65,7 @@ def test_error_purchase @gateway.expects(:ssl_post).returns(error_purchase_response) res = @gateway.purchase(123, credit_card, @options) assert_failure res - assert_equal "SIS0051 ERROR", res.message + assert_equal 'SIS0051 ERROR', res.message end def test_refund_request @@ -75,18 +75,18 @@ def test_refund_request def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - res = @gateway.refund(123, "1001") + res = @gateway.refund(123, '1001') assert_success res - assert_equal "Refund / Confirmation approved", res.message - assert_equal "1001|123|978", res.authorization - assert_equal "1001", res.params['ds_order'] + assert_equal 'Refund / Confirmation approved', res.message + assert_equal '1001|123|978', res.authorization + assert_equal '1001', res.params['ds_order'] end def test_error_refund @gateway.expects(:ssl_post).returns(error_refund_response) - res = @gateway.refund(123, "1001") + res = @gateway.refund(123, '1001') assert_failure res - assert_equal "SIS0057 ERROR", res.message + assert_equal 'SIS0057 ERROR', res.message end # Remaining methods a pretty much the same, so we just test that @@ -96,9 +96,9 @@ def test_authorize @gateway.expects(:ssl_post).with( anything, all_of( - includes(CGI.escape("<DS_MERCHANT_TRANSACTIONTYPE>1</DS_MERCHANT_TRANSACTIONTYPE>")), - includes(CGI.escape("<DS_MERCHANT_PAN>4242424242424242</DS_MERCHANT_PAN>")), - includes(CGI.escape("<DS_MERCHANT_AMOUNT>123</DS_MERCHANT_AMOUNT>")) + includes(CGI.escape('<DS_MERCHANT_TRANSACTIONTYPE>1</DS_MERCHANT_TRANSACTIONTYPE>')), + includes(CGI.escape('<DS_MERCHANT_PAN>4242424242424242</DS_MERCHANT_PAN>')), + includes(CGI.escape('<DS_MERCHANT_AMOUNT>123</DS_MERCHANT_AMOUNT>')) ), anything ).returns(successful_authorize_response) @@ -114,7 +114,7 @@ def test_authorize_without_order_id def test_bad_order_id_format stub_comms(@gateway, :ssl_request) do - @gateway.authorize(123, credit_card, order_id: "Una#cce-ptable44Format") + @gateway.authorize(123, credit_card, order_id: 'Una#cce-ptable44Format') end.check_request do |method, endpoint, data, headers| assert_match(/MERCHANT_ORDER%3E\d\d\d\dUnaccept%3C/, data) end.respond_with(successful_authorize_response) @@ -122,7 +122,7 @@ def test_bad_order_id_format def test_order_id_numeric_start_but_too_long stub_comms(@gateway, :ssl_request) do - @gateway.authorize(123, credit_card, order_id: "1234ThisIs]FineButTooLong") + @gateway.authorize(123, credit_card, order_id: '1234ThisIs]FineButTooLong') end.check_request do |method, endpoint, data, headers| assert_match(/MERCHANT_ORDER%3E1234ThisIsFi%3C/, data) end.respond_with(successful_authorize_response) @@ -132,9 +132,9 @@ def test_capture @gateway.expects(:ssl_post).with( anything, all_of( - includes(CGI.escape("<DS_MERCHANT_TRANSACTIONTYPE>2</DS_MERCHANT_TRANSACTIONTYPE>")), - includes(CGI.escape("<DS_MERCHANT_ORDER>1001</DS_MERCHANT_ORDER>")), - includes(CGI.escape("<DS_MERCHANT_AMOUNT>123</DS_MERCHANT_AMOUNT>")) + includes(CGI.escape('<DS_MERCHANT_TRANSACTIONTYPE>2</DS_MERCHANT_TRANSACTIONTYPE>')), + includes(CGI.escape('<DS_MERCHANT_ORDER>1001</DS_MERCHANT_ORDER>')), + includes(CGI.escape('<DS_MERCHANT_AMOUNT>123</DS_MERCHANT_AMOUNT>')) ), anything ).returns(successful_capture_response) @@ -145,10 +145,10 @@ def test_void @gateway.expects(:ssl_post).with( anything, all_of( - includes(CGI.escape("<DS_MERCHANT_TRANSACTIONTYPE>9</DS_MERCHANT_TRANSACTIONTYPE>")), - includes(CGI.escape("<DS_MERCHANT_ORDER>1001</DS_MERCHANT_ORDER>")), - includes(CGI.escape("<DS_MERCHANT_AMOUNT>123</DS_MERCHANT_AMOUNT>")), - includes(CGI.escape("<DS_MERCHANT_CURRENCY>978</DS_MERCHANT_CURRENCY>")) + includes(CGI.escape('<DS_MERCHANT_TRANSACTIONTYPE>9</DS_MERCHANT_TRANSACTIONTYPE>')), + includes(CGI.escape('<DS_MERCHANT_ORDER>1001</DS_MERCHANT_ORDER>')), + includes(CGI.escape('<DS_MERCHANT_AMOUNT>123</DS_MERCHANT_AMOUNT>')), + includes(CGI.escape('<DS_MERCHANT_CURRENCY>978</DS_MERCHANT_CURRENCY>')) ), anything ).returns(successful_void_response) @@ -158,7 +158,7 @@ def test_void def test_override_currency @gateway.expects(:ssl_post).with( anything, - includes(CGI.escape("<DS_MERCHANT_CURRENCY>840</DS_MERCHANT_CURRENCY>")), + includes(CGI.escape('<DS_MERCHANT_CURRENCY>840</DS_MERCHANT_CURRENCY>')), anything ).returns(successful_purchase_response) @gateway.authorize(123, credit_card, :order_id => '1001', :currency => 'USD') @@ -174,19 +174,19 @@ def test_successful_verify_with_failed_void @gateway.expects(:ssl_post).times(2).returns(successful_authorize_response).then.returns(failed_void_response) response = @gateway.verify(credit_card, @options) assert_success response - assert_equal "Transaction Approved", response.message + assert_equal 'Transaction Approved', response.message end def test_unsuccessful_verify @gateway.expects(:ssl_post).returns(failed_authorize_response) response = @gateway.verify(credit_card, @options) assert_failure response - assert_equal "SIS0093 ERROR", response.message + assert_equal 'SIS0093 ERROR', response.message end def test_unknown_currency assert_raise ArgumentError do - @gateway.purchase(123, credit_card, @options.merge(currency: "HUH WUT")) + @gateway.purchase(123, credit_card, @options.merge(currency: 'HUH WUT')) end end @@ -260,7 +260,7 @@ def purchase_request end def purchase_request_with_credit_card_token - "entrada=%3CDATOSENTRADA%3E%0A++%3CDS_Version%3E0.1%3C%2FDS_Version%3E%0A++%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%0A++%3CDS_MERCHANT_AMOUNT%3E123%3C%2FDS_MERCHANT_AMOUNT%3E%0A++%3CDS_MERCHANT_ORDER%3E1001%3C%2FDS_MERCHANT_ORDER%3E%0A++%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%0A++%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%0A++%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%0A++%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%0A++%3CDS_MERCHANT_MERCHANTSIGNATURE%3Ecbcc0dee5724cd3fff08bbd4371946a0599c7fb9%3C%2FDS_MERCHANT_MERCHANTSIGNATURE%3E%0A++%3CDS_MERCHANT_IDENTIFIER%3E77bff3a969d6f97b2ec815448cdcff453971f573%3C%2FDS_MERCHANT_IDENTIFIER%3E%0A%3C%2FDATOSENTRADA%3E%0A" + 'entrada=%3CDATOSENTRADA%3E%0A++%3CDS_Version%3E0.1%3C%2FDS_Version%3E%0A++%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%0A++%3CDS_MERCHANT_AMOUNT%3E123%3C%2FDS_MERCHANT_AMOUNT%3E%0A++%3CDS_MERCHANT_ORDER%3E1001%3C%2FDS_MERCHANT_ORDER%3E%0A++%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%0A++%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%0A++%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%0A++%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%0A++%3CDS_MERCHANT_MERCHANTSIGNATURE%3Ecbcc0dee5724cd3fff08bbd4371946a0599c7fb9%3C%2FDS_MERCHANT_MERCHANTSIGNATURE%3E%0A++%3CDS_MERCHANT_IDENTIFIER%3E77bff3a969d6f97b2ec815448cdcff453971f573%3C%2FDS_MERCHANT_IDENTIFIER%3E%0A%3C%2FDATOSENTRADA%3E%0A' end def successful_purchase_response diff --git a/test/unit/gateways/safe_charge_test.rb b/test/unit/gateways/safe_charge_test.rb index 3cddc23e4e2..94d310907c6 100644 --- a/test/unit/gateways/safe_charge_test.rb +++ b/test/unit/gateways/safe_charge_test.rb @@ -30,7 +30,7 @@ def test_successful_purchase assert_equal '111951|101508189567|ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAd' \ 'AAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAF' \ - "UAbQBYAFIAMwA=|%02d|%d|1.00|USD" % [@credit_card.month, @credit_card.year.to_s[-2..-1]], response.authorization + 'UAbQBYAFIAMwA=|%02d|%d|1.00|USD' % [@credit_card.month, @credit_card.year.to_s[-2..-1]], response.authorization assert response.test? end @@ -46,7 +46,7 @@ def test_successful_purchase_with_merchant_options assert_success purchase assert_equal '111951|101508189567|ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAd' \ 'AAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAF' \ - "UAbQBYAFIAMwA=|%02d|%d|1.00|USD" % [@credit_card.month, @credit_card.year.to_s[-2..-1]], purchase.authorization + 'UAbQBYAFIAMwA=|%02d|%d|1.00|USD' % [@credit_card.month, @credit_card.year.to_s[-2..-1]], purchase.authorization assert purchase.test? end @@ -60,7 +60,7 @@ def test_successful_purchase_with_truthy_stored_credential_mode assert_success purchase assert_equal '111951|101508189567|ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAd' \ 'AAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAF' \ - "UAbQBYAFIAMwA=|%02d|%d|1.00|USD" % [@credit_card.month, @credit_card.year.to_s[-2..-1]], purchase.authorization + 'UAbQBYAFIAMwA=|%02d|%d|1.00|USD' % [@credit_card.month, @credit_card.year.to_s[-2..-1]], purchase.authorization assert purchase.test? end @@ -74,7 +74,7 @@ def test_successful_purchase_with_falsey_stored_credential_mode assert_success purchase assert_equal '111951|101508189567|ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAd' \ 'AAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAF' \ - "UAbQBYAFIAMwA=|%02d|%d|1.00|USD" % [@credit_card.month, @credit_card.year.to_s[-2..-1]], purchase.authorization + 'UAbQBYAFIAMwA=|%02d|%d|1.00|USD' % [@credit_card.month, @credit_card.year.to_s[-2..-1]], purchase.authorization assert purchase.test? end @@ -83,7 +83,7 @@ def test_failed_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "0", response.error_code + assert_equal '0', response.error_code end def test_successful_authorize @@ -94,7 +94,7 @@ def test_successful_authorize assert_equal '111534|101508189855|MQBVAG4ASABkAEgAagB3AEsAbgAtACoAWgAzAFwAW' \ 'wBNAF8ATQBUAD0AegBQAGwAQAAtAD0AXAB5AFkALwBtAFAALABaAHoAOgBFAE' \ - "wAUAA1AFUAMwA=|%02d|%d|1.00|USD" % [@credit_card.month, @credit_card.year.to_s[-2..-1]], response.authorization + 'wAUAA1AFUAMwA=|%02d|%d|1.00|USD' % [@credit_card.month, @credit_card.year.to_s[-2..-1]], response.authorization assert response.test? end @@ -103,13 +103,13 @@ def test_failed_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response - assert_equal "0", response.error_code + assert_equal '0', response.error_code end def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - response = @gateway.capture(@amount, "auth|transaction_id|token|month|year|amount|currency") + response = @gateway.capture(@amount, 'auth|transaction_id|token|month|year|amount|currency') assert_success response assert_equal '111301|101508190200|RwA1AGQAMgAwAEkAWABKADkAcABjAHYAQQA4AC8AZ' \ @@ -123,7 +123,7 @@ def test_failed_capture response = @gateway.capture(@amount, '', @options) assert_failure response - assert_equal "1163", response.error_code + assert_equal '1163', response.error_code end def test_successful_refund @@ -139,7 +139,7 @@ def test_failed_refund response = @gateway.refund(@amount, '', @options) assert_failure response - assert_equal "1163", response.error_code + assert_equal '1163', response.error_code end def test_successful_credit @@ -161,7 +161,7 @@ def test_failed_credit def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) - response = @gateway.void("auth|transaction_id|token|month|year|amount|currency") + response = @gateway.void('auth|transaction_id|token|month|year|amount|currency') assert_success response assert_equal '111171|101508208625|ZQBpAFAAZgBuAHEATgBUAHcASAAwADUAcwBHAHQAV' \ @@ -175,7 +175,7 @@ def test_failed_void response = @gateway.void('') assert_failure response - assert_equal "Invalid Amount", response.message + assert_equal 'Invalid Amount', response.message assert response.test? end @@ -187,7 +187,7 @@ def test_successful_verify assert_equal '111534|101508189855|MQBVAG4ASABkAEgAagB3AEsAbgAtACoAWgAzAFwAW' \ 'wBNAF8ATQBUAD0AegBQAGwAQAAtAD0AXAB5AFkALwBtAFAALABaAHoAOgBFAE' \ - "wAUAA1AFUAMwA=|%02d|%d|1.00|USD" % [@credit_card.month, @credit_card.year.to_s[-2..-1]], response.authorization + 'wAUAA1AFUAMwA=|%02d|%d|1.00|USD' % [@credit_card.month, @credit_card.year.to_s[-2..-1]], response.authorization assert response.test? end @@ -203,7 +203,7 @@ def test_failed_verify response = @gateway.verify(@credit_card, @options) assert_failure response - assert_equal "0", response.error_code + assert_equal '0', response.error_code end def test_scrub @@ -220,9 +220,9 @@ def test_3ds_response end.respond_with(successful_3ds_purchase_response) assert_success purchase - assert_equal "MDAwMDAwMDAwMDE1MTAxMDgzMTA=", purchase.params["xid"] - assert_equal "eJxVUdtuwjAM/ZWK95GYgijIjVTWaUNTGdqQ4DUKFq2gF9J0A75+SVcuixTF59g+sY5xlWqi+ItUo0lgQnUtd+Rl27BXyScYAQce+MB7ApfRJx0FfpOus7IQ0Of9AbIrtK1apbIwAqU6zuYLMQSY8ABZBzEnPY8FfzhjGCH7o7GQOYlIq9J4K6qNd5VD1mZQlU1h9FkEQ47sCrDRB5EaU00ZO5RKHtKyth2ORXYfaNm4qLYqp2wrkjj6ud8XSFbRKYl3F/uGyFwFbqUhMeAwBvC5B6Opz6c+IGt5lLn73hlgR+kAVu6PqMu4xCOB1l1NhTqLydg6ckNIp6osyFZYJ28xsvvAz2/OT2WsRa+bdf2+X6cXtd9oHxZNPks+ojB0DrcFTi2zrkDAJ62cA8icBOuWx7oF2+jf4n8B", purchase.params["pareq"] - assert_equal "https://pit.3dsecure.net/VbVTestSuiteService/pit1/acsService/paReq?summary=MjRlZGYwY2EtZTk5Zi00NDJjLTljOTAtNWUxZmRhMjEwODg3", purchase.params["acsurl"] + assert_equal 'MDAwMDAwMDAwMDE1MTAxMDgzMTA=', purchase.params['xid'] + assert_equal 'eJxVUdtuwjAM/ZWK95GYgijIjVTWaUNTGdqQ4DUKFq2gF9J0A75+SVcuixTF59g+sY5xlWqi+ItUo0lgQnUtd+Rl27BXyScYAQce+MB7ApfRJx0FfpOus7IQ0Of9AbIrtK1apbIwAqU6zuYLMQSY8ABZBzEnPY8FfzhjGCH7o7GQOYlIq9J4K6qNd5VD1mZQlU1h9FkEQ47sCrDRB5EaU00ZO5RKHtKyth2ORXYfaNm4qLYqp2wrkjj6ud8XSFbRKYl3F/uGyFwFbqUhMeAwBvC5B6Opz6c+IGt5lLn73hlgR+kAVu6PqMu4xCOB1l1NhTqLydg6ckNIp6osyFZYJ28xsvvAz2/OT2WsRa+bdf2+X6cXtd9oHxZNPks+ojB0DrcFTi2zrkDAJ62cA8icBOuWx7oF2+jf4n8B', purchase.params['pareq'] + assert_equal 'https://pit.3dsecure.net/VbVTestSuiteService/pit1/acsService/paReq?summary=MjRlZGYwY2EtZTk5Zi00NDJjLTljOTAtNWUxZmRhMjEwODg3', purchase.params['acsurl'] end private diff --git a/test/unit/gateways/sage_pay_test.rb b/test/unit/gateways/sage_pay_test.rb index fda0187a170..256af606eff 100644 --- a/test/unit/gateways/sage_pay_test.rb +++ b/test/unit/gateways/sage_pay_test.rb @@ -13,7 +13,7 @@ def setup :name => 'Tekin Suleyman', :address1 => 'Flat 10 Lapwing Court', :address2 => 'West Didsbury', - :city => "Manchester", + :city => 'Manchester', :county => 'Greater Manchester', :country => 'GB', :zip => 'M20 2PS' @@ -31,7 +31,7 @@ def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal "1;B8AE1CF6-9DEF-C876-1BB4-9B382E6CE520;4193753;OHMETD7DFK;purchase", response.authorization + assert_equal '1;B8AE1CF6-9DEF-C876-1BB4-9B382E6CE520;4193753;OHMETD7DFK;purchase', response.authorization assert_success response end @@ -234,7 +234,7 @@ def test_FIxxxx_optional_fields_are_submitted end def test_description_is_truncated - huge_description = "SagePay transactions fail if the déscription is more than 100 characters. Therefore, we truncate it to 100 characters." + " Lots more text " * 1000 + huge_description = 'SagePay transactions fail if the déscription is more than 100 characters. Therefore, we truncate it to 100 characters.' + ' Lots more text ' * 1000 stub_comms(@gateway, :ssl_request) do purchase_with_options(description: huge_description) end.check_request do |method, endpoint, data, headers| @@ -243,7 +243,7 @@ def test_description_is_truncated end def test_protocol_version_is_honoured - gateway = SagePayGateway.new(protocol_version: '2.23', login: "X") + gateway = SagePayGateway.new(protocol_version: '2.23', login: 'X') stub_comms(gateway, :ssl_request) do gateway.purchase(@amount, @credit_card, @options) @@ -257,7 +257,7 @@ def test_referrer_id_is_added_to_post_data_parameters stub_comms(@gateway, :ssl_request) do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |method, endpoint, data, headers| - assert data.include?("ReferrerID=00000000-0000-0000-0000-000000000001") + assert data.include?('ReferrerID=00000000-0000-0000-0000-000000000001') end.respond_with(successful_purchase_response) ensure ActiveMerchant::Billing::SagePayGateway.application_id = nil @@ -300,8 +300,8 @@ def test_transcript_scrubbing def test_truncate_accounts_for_url_encoding assert_nil @gateway.send(:truncate, nil, 3) - assert_equal "Wow", @gateway.send(:truncate, "WowAmaze", 3) - assert_equal "Joikam Lomström", @gateway.send(:truncate, "Joikam Lomström Rate", 20) + assert_equal 'Wow', @gateway.send(:truncate, 'WowAmaze', 3) + assert_equal 'Joikam Lomström', @gateway.send(:truncate, 'Joikam Lomström Rate', 20) end def test_successful_authorization_and_capture_and_refund @@ -318,7 +318,7 @@ def test_successful_authorization_and_capture_and_refund refund = stub_comms do @gateway.refund(@amount, capture.authorization, order_id: generate_unique_id, - description: "Refund txn" + description: 'Refund txn' ) end.respond_with(successful_refund_response) assert_success refund @@ -326,7 +326,7 @@ def test_successful_authorization_and_capture_and_refund def test_repeat_purchase_with_reference_token stub_comms(@gateway, :ssl_request) do - @gateway.purchase(@amount, "1455548a8d178beecd88fe6a285f50ff;{0D2ACAF0-FA64-6DFF-3869-7ADDDC1E0474};15353766;BS231FNE14;purchase", @options) + @gateway.purchase(@amount, '1455548a8d178beecd88fe6a285f50ff;{0D2ACAF0-FA64-6DFF-3869-7ADDDC1E0474};15353766;BS231FNE14;purchase', @options) end.check_request do |method, endpoint, data, headers| assert_match(/RelatedVPSTxId=%7B0D2ACAF0-FA64-6DFF-3869-7ADDDC1E0474%/, data) assert_match(/TxType=REPEAT/, data) diff --git a/test/unit/gateways/sage_test.rb b/test/unit/gateways/sage_test.rb index 314490ed87a..9d7b2707929 100644 --- a/test/unit/gateways/sage_test.rb +++ b/test/unit/gateways/sage_test.rb @@ -38,19 +38,19 @@ def test_successful_authorization assert_instance_of Response, response assert_success response - assert_equal "APPROVED", response.message - assert_equal "1234567890;bankcard", response.authorization + assert_equal 'APPROVED', response.message + assert_equal '1234567890;bankcard', response.authorization - assert_equal "A", response.params["success"] - assert_equal "911911", response.params["code"] - assert_equal "APPROVED", response.params["message"] - assert_equal "00", response.params["front_end"] - assert_equal "M", response.params["cvv_result"] - assert_equal "X", response.params["avs_result"] - assert_equal "00", response.params["risk"] - assert_equal "1234567890", response.params["reference"] - assert_equal "1000", response.params["order_number"] - assert_equal "0", response.params["recurring"] + assert_equal 'A', response.params['success'] + assert_equal '911911', response.params['code'] + assert_equal 'APPROVED', response.params['message'] + assert_equal '00', response.params['front_end'] + assert_equal 'M', response.params['cvv_result'] + assert_equal 'X', response.params['avs_result'] + assert_equal '00', response.params['risk'] + assert_equal '1234567890', response.params['reference'] + assert_equal '1000', response.params['order_number'] + assert_equal '0', response.params['recurring'] end def test_successful_purchase @@ -60,19 +60,19 @@ def test_successful_purchase assert_instance_of Response, response assert_success response - assert_equal "APPROVED 000001", response.message - assert_equal "B5O89VPdf0;bankcard", response.authorization + assert_equal 'APPROVED 000001', response.message + assert_equal 'B5O89VPdf0;bankcard', response.authorization - assert_equal "A", response.params["success"] - assert_equal "000001", response.params["code"] - assert_equal "APPROVED 000001", response.params["message"] - assert_equal "10", response.params["front_end"] - assert_equal "M", response.params["cvv_result"] - assert_equal "", response.params["avs_result"] - assert_equal "00", response.params["risk"] - assert_equal "B5O89VPdf0", response.params["reference"] - assert_equal "e81cab9e6144a160da82", response.params["order_number"] - assert_equal "0", response.params["recurring"] + assert_equal 'A', response.params['success'] + assert_equal '000001', response.params['code'] + assert_equal 'APPROVED 000001', response.params['message'] + assert_equal '10', response.params['front_end'] + assert_equal 'M', response.params['cvv_result'] + assert_equal '', response.params['avs_result'] + assert_equal '00', response.params['risk'] + assert_equal 'B5O89VPdf0', response.params['reference'] + assert_equal 'e81cab9e6144a160da82', response.params['order_number'] + assert_equal '0', response.params['recurring'] end def test_declined_purchase @@ -81,57 +81,57 @@ def test_declined_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response assert response.test? - assert_equal "DECLINED", response.message - assert_equal "A5O89kkix0;bankcard", response.authorization + assert_equal 'DECLINED', response.message + assert_equal 'A5O89kkix0;bankcard', response.authorization - assert_equal "E", response.params["success"] - assert_equal "000002", response.params["code"] - assert_equal "DECLINED", response.params["message"] - assert_equal "10", response.params["front_end"] - assert_equal "N", response.params["cvv_result"] - assert_equal "", response.params["avs_result"] - assert_equal "00", response.params["risk"] - assert_equal "A5O89kkix0", response.params["reference"] - assert_equal "3443d6426188f8256b8f", response.params["order_number"] - assert_equal "0", response.params["recurring"] + assert_equal 'E', response.params['success'] + assert_equal '000002', response.params['code'] + assert_equal 'DECLINED', response.params['message'] + assert_equal '10', response.params['front_end'] + assert_equal 'N', response.params['cvv_result'] + assert_equal '', response.params['avs_result'] + assert_equal '00', response.params['risk'] + assert_equal 'A5O89kkix0', response.params['reference'] + assert_equal '3443d6426188f8256b8f', response.params['order_number'] + assert_equal '0', response.params['recurring'] end def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - assert response = @gateway.capture(@amount, "A5O89kkix0") + assert response = @gateway.capture(@amount, 'A5O89kkix0') assert_instance_of Response, response assert_success response - assert_equal "APPROVED 000001", response.message - assert_equal "B5O8AdFhu0;bankcard", response.authorization + assert_equal 'APPROVED 000001', response.message + assert_equal 'B5O8AdFhu0;bankcard', response.authorization - assert_equal "A", response.params["success"] - assert_equal "000001", response.params["code"] - assert_equal "APPROVED 000001", response.params["message"] - assert_equal "10", response.params["front_end"] - assert_equal "P", response.params["cvv_result"] - assert_equal "", response.params["avs_result"] - assert_equal "00", response.params["risk"] - assert_equal "B5O8AdFhu0", response.params["reference"] - assert_equal "ID5O8AdFhw", response.params["order_number"] - assert_equal "0", response.params["recurring"] + assert_equal 'A', response.params['success'] + assert_equal '000001', response.params['code'] + assert_equal 'APPROVED 000001', response.params['message'] + assert_equal '10', response.params['front_end'] + assert_equal 'P', response.params['cvv_result'] + assert_equal '', response.params['avs_result'] + assert_equal '00', response.params['risk'] + assert_equal 'B5O8AdFhu0', response.params['reference'] + assert_equal 'ID5O8AdFhw', response.params['order_number'] + assert_equal '0', response.params['recurring'] end def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - response = @gateway.refund(@amount, "Authorization") + response = @gateway.refund(@amount, 'Authorization') assert_success response - assert_equal "G68FCU2c60;bankcard", response.authorization - assert_equal "APPROVED", response.message + assert_equal 'G68FCU2c60;bankcard', response.authorization + assert_equal 'APPROVED', response.message end def test_failed_refund @gateway.expects(:ssl_post).returns(failed_refund_response) - response = @gateway.refund(@amount, "Authorization") + response = @gateway.refund(@amount, 'Authorization') assert_failure response - assert_equal "INVALID T_REFERENCE", response.message + assert_equal 'INVALID T_REFERENCE', response.message end def test_invalid_login @@ -140,24 +140,24 @@ def test_invalid_login assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response assert response.test? - assert_equal "SECURITY VIOLATION", response.message - assert_equal "0000000000;bankcard", response.authorization + assert_equal 'SECURITY VIOLATION', response.message + assert_equal '0000000000;bankcard', response.authorization - assert_equal "X", response.params["success"] - assert_equal "911911", response.params["code"] - assert_equal "SECURITY VIOLATION", response.params["message"] - assert_equal "00", response.params["front_end"] - assert_equal "P", response.params["cvv_result"] - assert_equal "", response.params["avs_result"] - assert_equal "00", response.params["risk"] - assert_equal "0000000000", response.params["reference"] - assert_equal "", response.params["order_number"] - assert_equal "0", response.params["recurring"] + assert_equal 'X', response.params['success'] + assert_equal '911911', response.params['code'] + assert_equal 'SECURITY VIOLATION', response.params['message'] + assert_equal '00', response.params['front_end'] + assert_equal 'P', response.params['cvv_result'] + assert_equal '', response.params['avs_result'] + assert_equal '00', response.params['risk'] + assert_equal '0000000000', response.params['reference'] + assert_equal '', response.params['order_number'] + assert_equal '0', response.params['recurring'] end def test_include_customer_number_for_numeric_values stub_comms do - @gateway.purchase(@amount, @credit_card, @options.merge({:customer => "123"})) + @gateway.purchase(@amount, @credit_card, @options.merge({:customer => '123'})) end.check_request do |method, data| assert data =~ /T_customer_number=123/ end.respond_with(successful_authorization_response) @@ -165,7 +165,7 @@ def test_include_customer_number_for_numeric_values def test_dont_include_customer_number_for_numeric_values stub_comms do - @gateway.purchase(@amount, @credit_card, @options.merge({:customer => "bob@test.com"})) + @gateway.purchase(@amount, @credit_card, @options.merge({:customer => 'bob@test.com'})) end.check_request do |method, data| assert data !~ /T_customer_number/ end.respond_with(successful_authorization_response) @@ -188,23 +188,23 @@ def test_cvv_result def test_address_with_state post = {} options = { - :billing_address => { :country => "US", :state => "CA"} + :billing_address => { :country => 'US', :state => 'CA'} } @gateway.send(:add_addresses, post, options) - assert_equal "US", post[:C_country] - assert_equal "CA", post[:C_state] + assert_equal 'US', post[:C_country] + assert_equal 'CA', post[:C_state] end def test_address_without_state post = {} options = { - :billing_address => { :country => "NZ", :state => ""} + :billing_address => { :country => 'NZ', :state => ''} } @gateway.send(:add_addresses, post, options) - assert_equal "NZ", post[:C_country] - assert_equal "Outside of US", post[:C_state] + assert_equal 'NZ', post[:C_country] + assert_equal 'Outside of US', post[:C_state] end def test_successful_check_purchase @@ -214,17 +214,17 @@ def test_successful_check_purchase assert_instance_of Response, response assert_success response - assert_equal "ACCEPTED", response.message - assert_equal "C5O8NUdNt0;virtual_check", response.authorization + assert_equal 'ACCEPTED', response.message + assert_equal 'C5O8NUdNt0;virtual_check', response.authorization - assert_equal "A", response.params["success"] - assert_equal "", response.params["code"] - assert_equal "ACCEPTED", response.params["message"] - assert_equal "00", response.params["risk"] - assert_equal "C5O8NUdNt0", response.params["reference"] - assert_equal "89be635e663b05eca587", response.params["order_number"] - assert_equal "0", response.params["authentication_indicator"] - assert_equal "NONE", response.params["authentication_disclosure"] + assert_equal 'A', response.params['success'] + assert_equal '', response.params['code'] + assert_equal 'ACCEPTED', response.params['message'] + assert_equal '00', response.params['risk'] + assert_equal 'C5O8NUdNt0', response.params['reference'] + assert_equal '89be635e663b05eca587', response.params['order_number'] + assert_equal '0', response.params['authentication_indicator'] + assert_equal 'NONE', response.params['authentication_disclosure'] end def test_declined_check_purchase @@ -233,17 +233,17 @@ def test_declined_check_purchase response = @gateway.purchase(@amount, @check, @check_options) assert_failure response assert response.test? - assert_equal "INVALID C_RTE", response.message - assert_equal "C5O8NR6Nr0;virtual_check", response.authorization - - assert_equal "X", response.params["success"] - assert_equal "900016", response.params["code"] - assert_equal "INVALID C_RTE", response.params["message"] - assert_equal "00", response.params["risk"] - assert_equal "C5O8NR6Nr0", response.params["reference"] - assert_equal "d98cf50f7a2430fe04ad", response.params["order_number"] - assert_equal "0", response.params["authentication_indicator"] - assert_equal nil, response.params["authentication_disclosure"] + assert_equal 'INVALID C_RTE', response.message + assert_equal 'C5O8NR6Nr0;virtual_check', response.authorization + + assert_equal 'X', response.params['success'] + assert_equal '900016', response.params['code'] + assert_equal 'INVALID C_RTE', response.params['message'] + assert_equal '00', response.params['risk'] + assert_equal 'C5O8NR6Nr0', response.params['reference'] + assert_equal 'd98cf50f7a2430fe04ad', response.params['order_number'] + assert_equal '0', response.params['authentication_indicator'] + assert_equal nil, response.params['authentication_disclosure'] end def test_successful_store diff --git a/test/unit/gateways/sallie_mae_test.rb b/test/unit/gateways/sallie_mae_test.rb index e8779111f22..40194a47164 100644 --- a/test/unit/gateways/sallie_mae_test.rb +++ b/test/unit/gateways/sallie_mae_test.rb @@ -35,7 +35,7 @@ def test_non_test_account end def test_test_account - gateway = SallieMaeGateway.new(:login => "TEST0") + gateway = SallieMaeGateway.new(:login => 'TEST0') assert gateway.test? end @@ -43,11 +43,11 @@ def test_test_account # Place raw successful response from gateway here def successful_purchase_response - "Status=Accepted" + 'Status=Accepted' end # Place raw failed response from gateway here def failed_purchase_response - "Status=Declined" + 'Status=Declined' end end diff --git a/test/unit/gateways/secure_net_test.rb b/test/unit/gateways/secure_net_test.rb index f1c83e93698..01c9b55c70d 100644 --- a/test/unit/gateways/secure_net_test.rb +++ b/test/unit/gateways/secure_net_test.rb @@ -130,7 +130,7 @@ def test_failure_without_response_reason_text end def test_passes_optional_fields - options = { description: "Good Stuff", invoice_description: "Sweet Invoice", invoice_number: "48" } + options = { description: 'Good Stuff', invoice_description: 'Sweet Invoice', invoice_number: '48' } stub_comms do @gateway.purchase(@amount, @credit_card, options) end.check_request do |endpoint, data, headers| diff --git a/test/unit/gateways/secure_pay_au_test.rb b/test/unit/gateways/secure_pay_au_test.rb index af937c7910a..163c41fe0fa 100644 --- a/test/unit/gateways/secure_pay_au_test.rb +++ b/test/unit/gateways/secure_pay_au_test.rb @@ -71,13 +71,13 @@ def test_failed_purchase assert_instance_of Response, response assert_failure response assert response.test? - assert_equal "CARD EXPIRED", response.message + assert_equal 'CARD EXPIRED', response.message end def test_purchase_with_stored_id_calls_commit_periodic @gateway.expects(:commit_periodic) - @gateway.purchase(@amount, "123", @options) + @gateway.purchase(@amount, '123', @options) end def test_purchase_with_creditcard_calls_commit_with_purchase @@ -100,59 +100,59 @@ def test_failed_authorization assert response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response - assert_equal "Insufficient Funds", response.message + assert_equal 'Insufficient Funds', response.message end def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - assert response = @gateway.capture(@amount, "crazy*reference*thingy*100", {}) + assert response = @gateway.capture(@amount, 'crazy*reference*thingy*100', {}) assert_success response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message end def test_failed_capture @gateway.expects(:ssl_post).returns(failed_capture_response) - assert response = @gateway.capture(@amount, "crazy*reference*thingy*100") + assert response = @gateway.capture(@amount, 'crazy*reference*thingy*100') assert_failure response - assert_equal "Preauth was done for smaller amount", response.message + assert_equal 'Preauth was done for smaller amount', response.message end def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - assert_success @gateway.refund(@amount, "crazy*reference*thingy*100", {}) + assert_success @gateway.refund(@amount, 'crazy*reference*thingy*100', {}) end def test_failed_refund @gateway.expects(:ssl_post).returns(failed_refund_response) - assert response = @gateway.refund(@amount, "crazy*reference*thingy*100") + assert response = @gateway.refund(@amount, 'crazy*reference*thingy*100') assert_failure response - assert_equal "Only $1.00 available for refund", response.message + assert_equal 'Only $1.00 available for refund', response.message end def test_deprecated_credit @gateway.expects(:ssl_post).returns(successful_refund_response) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - assert_success @gateway.credit(@amount, "crazy*reference*thingy*100", {}) + assert_success @gateway.credit(@amount, 'crazy*reference*thingy*100', {}) end end def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) - assert response = @gateway.void("crazy*reference*thingy*100", {}) + assert response = @gateway.void('crazy*reference*thingy*100', {}) assert_success response end def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) - assert response = @gateway.void("crazy*reference*thingy*100") + assert response = @gateway.void('crazy*reference*thingy*100') assert_failure response - assert_equal "Transaction was done for different amount", response.message + assert_equal 'Transaction was done for different amount', response.message end def test_failed_login @@ -161,7 +161,7 @@ def test_failed_login assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response assert_failure response - assert_equal "Invalid merchant ID", response.message + assert_equal 'Invalid merchant ID', response.message end def test_successful_store @@ -169,7 +169,7 @@ def test_successful_store assert response = @gateway.store(@credit_card, {:billing_id => 'test3', :amount => 123}) assert_instance_of Response, response - assert_equal "Successful", response.message + assert_equal 'Successful', response.message assert_equal 'test3', response.params['client_id'] end @@ -178,7 +178,7 @@ def test_successful_unstore assert response = @gateway.unstore('test2') assert_instance_of Response, response - assert_equal "Successful", response.message + assert_equal 'Successful', response.message assert_equal 'test2', response.params['client_id'] end @@ -187,7 +187,7 @@ def test_successful_triggered_payment assert response = @gateway.purchase(@amount, 'test3', @options) assert_instance_of Response, response - assert_equal "Approved", response.message + assert_equal 'Approved', response.message assert_equal 'test3', response.params['client_id'] end diff --git a/test/unit/gateways/securion_pay_test.rb b/test/unit/gateways/securion_pay_test.rb index 829976987da..ea2a5d85025 100644 --- a/test/unit/gateways/securion_pay_test.rb +++ b/test/unit/gateways/securion_pay_test.rb @@ -28,9 +28,9 @@ def test_successful_store response = @gateway.store(@credit_card, @options) assert_success response assert_match %r(^cust_\w+$), response.authorization - assert_equal "customer", response.params["objectType"] - assert_match %r(^card_\w+$), response.params["cards"][0]["id"] - assert_equal "card", response.params["cards"][0]["objectType"] + assert_equal 'customer', response.params['objectType'] + assert_match %r(^card_\w+$), response.params['cards'][0]['id'] + assert_equal 'card', response.params['cards'][0]['objectType'] @gateway.expects(:ssl_post).returns(successful_authorize_response) @gateway.expects(:ssl_post).returns(successful_void_response) @@ -38,18 +38,18 @@ def test_successful_store @options[:customer_id] = response.authorization response = @gateway.store(@new_credit_card, @options) assert_success response - assert_match %r(^card_\w+$), response.params["card"]["id"] - assert_equal @options[:customer_id], response.params["card"]["customerId"] + assert_match %r(^card_\w+$), response.params['card']['id'] + assert_equal @options[:customer_id], response.params['card']['customerId'] @gateway.expects(:ssl_request).returns(successful_customer_update_response) response = @gateway.customer(@options) assert_success response - assert_equal @options[:customer_id], response.params["id"] - assert_equal "401288", response.params["cards"][0]["first6"] - assert_equal "1881", response.params["cards"][0]["last4"] - assert_equal "424242", response.params["cards"][1]["first6"] - assert_equal "4242", response.params["cards"][1]["last4"] + assert_equal @options[:customer_id], response.params['id'] + assert_equal '401288', response.params['cards'][0]['first6'] + assert_equal '1881', response.params['cards'][0]['last4'] + assert_equal '424242', response.params['cards'][1]['first6'] + assert_equal '4242', response.params['cards'][1]['last4'] end def test_successful_purchase @@ -65,7 +65,7 @@ def test_successful_purchase def test_successful_purchase_with_token response = stub_comms(@gateway, :ssl_request) do - @gateway.purchase(@amount, "tok_xxx") + @gateway.purchase(@amount, 'tok_xxx') end.check_request do |method, endpoint, data, headers| assert_match(/card=tok_xxx/, data) refute_match(/card\[number\]/, data) @@ -86,7 +86,7 @@ def test_invalid_raw_response def test_client_data_submitted_with_purchase stub_comms(@gateway, :ssl_request) do - updated_options = @options.merge({ description: "test charge", ip: "127.127.127.127", user_agent: "browser XXX", referrer: "http://www.foobar.com", email: "foo@bar.com" }) + updated_options = @options.merge({ description: 'test charge', ip: '127.127.127.127', user_agent: 'browser XXX', referrer: 'http://www.foobar.com', email: 'foo@bar.com' }) @gateway.purchase(@amount,@credit_card,updated_options) end.check_request do |method, endpoint, data, headers| assert_match(/description=test\+charge/, data) @@ -99,7 +99,7 @@ def test_client_data_submitted_with_purchase def test_client_data_submitted_with_purchase_without_email_or_order stub_comms(@gateway, :ssl_request) do - updated_options = @options.merge({ description: "test charge", ip: "127.127.127.127", user_agent: "browser XXX", referrer: "http://www.foobar.com" }) + updated_options = @options.merge({ description: 'test charge', ip: '127.127.127.127', user_agent: 'browser XXX', referrer: 'http://www.foobar.com' }) @gateway.purchase(@amount,@credit_card,updated_options) end.check_request do |method, endpoint, data, headers| assert_match(/description=test\+charge/, data) @@ -177,7 +177,7 @@ def test_failed_authorize def test_successful_capture @gateway.expects(:ssl_request).returns(successful_capture_response) - response = @gateway.capture(@amount, "char_CqH9rftszMnaMYBrgtVI49LM", @options) + response = @gateway.capture(@amount, 'char_CqH9rftszMnaMYBrgtVI49LM', @options) assert_instance_of Response, response assert_success response assert response.test? @@ -186,7 +186,7 @@ def test_successful_capture def test_failed_capture @gateway.expects(:ssl_request).returns(failed_capture_response) - response = @gateway.capture(@amount, "invalid_authorization_token", @options) + response = @gateway.capture(@amount, 'invalid_authorization_token', @options) assert_failure response assert_match(/^Requested Charge does not exist/, response.message) assert_nil response.authorization @@ -199,10 +199,10 @@ def test_successful_full_refund response = @gateway.refund(@amount, 'char_DQca5ZjbewP2Oe0lIsNe4EXP', @options) assert_instance_of Response, response assert_success response - assert response.params["refunded"] - assert_equal 0, response.params["amount"] - assert_equal 1, response.params["refunds"].size - assert_equal @amount, response.params["refunds"].map{|r| r["amount"]}.sum + assert response.params['refunded'] + assert_equal 0, response.params['amount'] + assert_equal 1, response.params['refunds'].size + assert_equal @amount, response.params['refunds'].map{|r| r['amount']}.sum assert_equal 'char_DQca5ZjbewP2Oe0lIsNe4EXP', response.authorization assert response.test? end @@ -213,9 +213,9 @@ def test_successful_partially_refund response = @gateway.refund(@refund_amount, 'char_oVnJ1j6fZqOvnopBBvlnpEuX', @options) assert_instance_of Response, response assert_success response - assert response.params["refunded"] - assert_equal @amount - @refund_amount, response.params["amount"] - assert_equal @refund_amount, response.params["refunds"].map{|r| r["amount"]}.sum + assert response.params['refunded'] + assert_equal @amount - @refund_amount, response.params['amount'] + assert_equal @refund_amount, response.params['refunds'].map{|r| r['amount']}.sum assert_equal 'char_oVnJ1j6fZqOvnopBBvlnpEuX', response.authorization assert response.test? end @@ -252,7 +252,7 @@ def test_failed_authorization_void response = @gateway.void('invalid_authorization_token', @options) assert_failure response - assert_equal "Requested Charge does not exist", response.message + assert_equal 'Requested Charge does not exist', response.message assert_nil response.authorization end @@ -268,7 +268,7 @@ def test_successful_verify_with_failed_void @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Transaction approved", response.message + assert_equal 'Transaction approved', response.message end def test_failed_verify @@ -276,7 +276,7 @@ def test_failed_verify @gateway.verify(@declined_card, @options) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "The card was declined for other reason.", response.message + assert_equal 'The card was declined for other reason.', response.message end def test_scrub diff --git a/test/unit/gateways/skip_jack_test.rb b/test/unit/gateways/skip_jack_test.rb index a79cf6eda5d..10cc562bbfa 100644 --- a/test/unit/gateways/skip_jack_test.rb +++ b/test/unit/gateways/skip_jack_test.rb @@ -60,7 +60,7 @@ def test_purchase_success response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "9802853155172.022", response.authorization + assert_equal '9802853155172.022', response.authorization end def test_purchase_failure @@ -131,49 +131,49 @@ def test_cvv_result def test_basic_test_url @gateway.stubs(:test?).returns(true) @gateway.stubs(:advanced?).returns(false) - assert_equal "https://developer.skipjackic.com/scripts/evolvcc.dll?AuthorizeAPI", @gateway.send(:url_for, :authorization) + assert_equal 'https://developer.skipjackic.com/scripts/evolvcc.dll?AuthorizeAPI', @gateway.send(:url_for, :authorization) end def test_basic_test_url_non_authorization @gateway.stubs(:test?).returns(true) @gateway.stubs(:advanced?).returns(false) - assert_equal "https://developer.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest", @gateway.send(:url_for, :change_status) + assert_equal 'https://developer.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest', @gateway.send(:url_for, :change_status) end def test_advanced_test_url @gateway.stubs(:test?).returns(true) @gateway.stubs(:advanced?).returns(true) - assert_equal "https://developer.skipjackic.com/evolvcc/evolvcc.aspx?AuthorizeAPI", @gateway.send(:url_for, :authorization) + assert_equal 'https://developer.skipjackic.com/evolvcc/evolvcc.aspx?AuthorizeAPI', @gateway.send(:url_for, :authorization) end def test_advanced_test_url_non_authorization @gateway.stubs(:test?).returns(true) @gateway.stubs(:advanced?).returns(true) - assert_equal "https://developer.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest", @gateway.send(:url_for, :change_status) + assert_equal 'https://developer.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest', @gateway.send(:url_for, :change_status) end def test_basic_live_url @gateway.stubs(:test?).returns(false) @gateway.stubs(:advanced?).returns(false) - assert_equal "https://www.skipjackic.com/scripts/evolvcc.dll?AuthorizeAPI", @gateway.send(:url_for, :authorization) + assert_equal 'https://www.skipjackic.com/scripts/evolvcc.dll?AuthorizeAPI', @gateway.send(:url_for, :authorization) end def test_basic_live_url_non_authorization @gateway.stubs(:test?).returns(false) @gateway.stubs(:advanced?).returns(false) - assert_equal "https://www.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest", @gateway.send(:url_for, :change_status) + assert_equal 'https://www.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest', @gateway.send(:url_for, :change_status) end def test_advanced_live_url @gateway.stubs(:test?).returns(false) @gateway.stubs(:advanced?).returns(true) - assert_equal "https://www.skipjackic.com/evolvcc/evolvcc.aspx?AuthorizeAPI", @gateway.send(:url_for, :authorization) + assert_equal 'https://www.skipjackic.com/evolvcc/evolvcc.aspx?AuthorizeAPI', @gateway.send(:url_for, :authorization) end def test_advanced_live_url_non_authorization @gateway.stubs(:test?).returns(false) @gateway.stubs(:advanced?).returns(true) - assert_equal "https://www.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest", @gateway.send(:url_for, :change_status) + assert_equal 'https://www.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest', @gateway.send(:url_for, :change_status) end def test_paymentech_authorization_success @@ -217,7 +217,7 @@ def test_successful_partial_capture @gateway.expects(:ssl_post).with('https://developer.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest', "szTransactionId=#{response.authorization}&szSerialNumber=X&szForceSettlement=0&szDeveloperSerialNumber=Y&szDesiredStatus=SETTLE&szAmount=1.00").returns(successful_capture_response) response = @gateway.capture(@amount/2, response.authorization) - assert_equal "1.0000", response.params["TransactionAmount"] + assert_equal '1.0000', response.params['TransactionAmount'] end def test_dont_send_blank_state diff --git a/test/unit/gateways/so_easy_pay_test.rb b/test/unit/gateways/so_easy_pay_test.rb index daa8a9f9d35..1dead1bd716 100644 --- a/test/unit/gateways/so_easy_pay_test.rb +++ b/test/unit/gateways/so_easy_pay_test.rb @@ -52,7 +52,7 @@ def test_successful_authorize def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - assert response = @gateway.capture(1111, "1708980") + assert response = @gateway.capture(1111, '1708980') assert_instance_of Response, response assert_success response @@ -87,7 +87,7 @@ def test_do_not_depend_on_expiry_date_class def test_use_ducktyping_for_credit_card @gateway.expects(:ssl_post).returns(successful_purchase_response) - credit_card = stub(:number => '4242424242424242', :verification_value => '123', :name => "Hans Tester", :year => 2012, :month => 1) + credit_card = stub(:number => '4242424242424242', :verification_value => '123', :name => 'Hans Tester', :year => 2012, :month => 1) assert_nothing_raised do assert_success @gateway.purchase(@amount, credit_card, @options) diff --git a/test/unit/gateways/spreedly_core_test.rb b/test/unit/gateways/spreedly_core_test.rb index 251b1c4a119..afc5d4dd961 100644 --- a/test/unit/gateways/spreedly_core_test.rb +++ b/test/unit/gateways/spreedly_core_test.rb @@ -20,10 +20,10 @@ def test_successful_purchase_with_payment_method_token assert_success response assert !response.test? - assert_equal "K1CRcdN0jK32UyrnZGPOXLRjqJl", response.authorization - assert_equal "Succeeded!", response.message - assert_equal "Non-U.S. issuing bank does not support AVS.", response.avs_result["message"] - assert_equal "CVV failed data validation check", response.cvv_result["message"] + assert_equal 'K1CRcdN0jK32UyrnZGPOXLRjqJl', response.authorization + assert_equal 'Succeeded!', response.message + assert_equal 'Non-U.S. issuing bank does not support AVS.', response.avs_result['message'] + assert_equal 'CVV failed data validation check', response.cvv_result['message'] end def test_failed_purchase_with_payment_method_token @@ -33,8 +33,8 @@ def test_failed_purchase_with_payment_method_token assert_failure response assert !response.test? - assert_equal "Xh0T15CfYQeUqYV9Ixm8YV283Ds", response.authorization - assert_equal "This transaction cannot be processed.", response.message + assert_equal 'Xh0T15CfYQeUqYV9Ixm8YV283Ds', response.authorization + assert_equal 'This transaction cannot be processed.', response.message assert_equal '10762', response.params['response_error_code'] assert_nil response.avs_result['message'] assert_nil response.cvv_result['message'] @@ -47,10 +47,10 @@ def test_successful_purchase_with_credit_card assert_success response assert !response.test? - assert_equal "K1CRcdN0jK32UyrnZGPOXLRjqJl", response.authorization - assert_equal "Succeeded!", response.message - assert_equal "Non-U.S. issuing bank does not support AVS.", response.avs_result["message"] - assert_equal "CVV failed data validation check", response.cvv_result["message"] + assert_equal 'K1CRcdN0jK32UyrnZGPOXLRjqJl', response.authorization + assert_equal 'Succeeded!', response.message + assert_equal 'Non-U.S. issuing bank does not support AVS.', response.avs_result['message'] + assert_equal 'CVV failed data validation check', response.cvv_result['message'] assert_equal 'Purchase', response.params['transaction_type'] assert_equal '5WxC03VQ0LmmkYvIHl7XsPKIpUb', response.params['payment_method_token'] assert_equal '6644', response.params['payment_method_last_four_digits'] @@ -69,8 +69,8 @@ def test_failed_purchase_with_credit_card response = @gateway.purchase(@amount, @credit_card) assert_failure response - assert_equal "Xh0T15CfYQeUqYV9Ixm8YV283Ds", response.authorization - assert_equal "This transaction cannot be processed.", response.message + assert_equal 'Xh0T15CfYQeUqYV9Ixm8YV283Ds', response.authorization + assert_equal 'This transaction cannot be processed.', response.message assert_equal '10762', response.params['response_error_code'] assert_nil response.avs_result['message'] assert_nil response.cvv_result['message'] @@ -78,12 +78,12 @@ def test_failed_purchase_with_credit_card end def test_purchase_without_gateway_token_option - @gateway.expects(:commit).with("gateways/token/purchase.xml", anything) + @gateway.expects(:commit).with('gateways/token/purchase.xml', anything) @gateway.purchase(@amount, @payment_method_token) end def test_purchase_with_gateway_token_option - @gateway.expects(:commit).with("gateways/mynewtoken/purchase.xml", anything) + @gateway.expects(:commit).with('gateways/mynewtoken/purchase.xml', anything) @gateway.purchase(@amount, @payment_method_token, gateway_token: 'mynewtoken') end @@ -94,18 +94,18 @@ def test_successful_authorize_with_token_and_capture assert_success response assert !response.test? - assert_equal "NKz5SO6jrsRDc0UyaujwayXJZ1a", response.authorization - assert_equal "Succeeded!", response.message - assert_equal "Non-U.S. issuing bank does not support AVS.", response.avs_result["message"] - assert_equal "CVV failed data validation check", response.cvv_result["message"] + assert_equal 'NKz5SO6jrsRDc0UyaujwayXJZ1a', response.authorization + assert_equal 'Succeeded!', response.message + assert_equal 'Non-U.S. issuing bank does not support AVS.', response.avs_result['message'] + assert_equal 'CVV failed data validation check', response.cvv_result['message'] @gateway.expects(:raw_ssl_request).returns(successful_capture_response) response = @gateway.capture(@amount, response.authorization) assert_success response assert !response.test? - assert_equal "Bd1ZeztpPyjfXzfUa14BQGfaLmg", response.authorization - assert_equal "Succeeded!", response.message + assert_equal 'Bd1ZeztpPyjfXzfUa14BQGfaLmg', response.authorization + assert_equal 'Succeeded!', response.message assert_nil response.avs_result['message'] assert_nil response.cvv_result['message'] end @@ -114,7 +114,7 @@ def test_failed_authorize_with_token @gateway.expects(:raw_ssl_request).returns(failed_authorize_response) response = @gateway.authorize(@amount, @payment_method_token) assert_failure response - assert_equal "This transaction cannot be processed.", response.message + assert_equal 'This transaction cannot be processed.', response.message assert_equal '10762', response.params['response_error_code'] assert_nil response.avs_result['message'] assert_nil response.cvv_result['message'] @@ -127,10 +127,10 @@ def test_successful_authorize_with_credit_card_and_capture assert_success response assert !response.test? - assert_equal "NKz5SO6jrsRDc0UyaujwayXJZ1a", response.authorization - assert_equal "Succeeded!", response.message - assert_equal "Non-U.S. issuing bank does not support AVS.", response.avs_result["message"] - assert_equal "CVV failed data validation check", response.cvv_result["message"] + assert_equal 'NKz5SO6jrsRDc0UyaujwayXJZ1a', response.authorization + assert_equal 'Succeeded!', response.message + assert_equal 'Non-U.S. issuing bank does not support AVS.', response.avs_result['message'] + assert_equal 'CVV failed data validation check', response.cvv_result['message'] assert_equal 'Authorization', response.params['transaction_type'] assert_equal '5WxC03VQ0LmmkYvIHl7XsPKIpUb', response.params['payment_method_token'] assert_equal '6644', response.params['payment_method_last_four_digits'] @@ -139,15 +139,15 @@ def test_successful_authorize_with_credit_card_and_capture @gateway.expects(:raw_ssl_request).returns(successful_capture_response) response = @gateway.capture(@amount, response.authorization) assert_success response - assert_equal "Bd1ZeztpPyjfXzfUa14BQGfaLmg", response.authorization - assert_equal "Succeeded!", response.message + assert_equal 'Bd1ZeztpPyjfXzfUa14BQGfaLmg', response.authorization + assert_equal 'Succeeded!', response.message end def test_failed_authorize_with_credit_card @gateway.stubs(:raw_ssl_request).returns(successful_store_response, failed_authorize_response) response = @gateway.authorize(@amount, @credit_card) assert_failure response - assert_equal "This transaction cannot be processed.", response.message + assert_equal 'This transaction cannot be processed.', response.message assert_equal '10762', response.params['response_error_code'] end @@ -166,7 +166,7 @@ def test_failed_capture @gateway.expects(:raw_ssl_request).returns(failed_capture_response) response = @gateway.capture(@amount + 20, response.authorization) assert_failure response - assert_equal "Amount specified exceeds allowable limit.", response.message + assert_equal 'Amount specified exceeds allowable limit.', response.message end def test_successful_refund @@ -177,8 +177,8 @@ def test_successful_refund @gateway.expects(:raw_ssl_request).returns(successful_refund_response) response = @gateway.refund(@amount, response.authorization) assert_success response - assert_equal "Succeeded!", response.message - assert_equal "Credit", response.params["transaction_type"] + assert_equal 'Succeeded!', response.message + assert_equal 'Credit', response.params['transaction_type'] end def test_failed_refund @@ -189,7 +189,7 @@ def test_failed_refund @gateway.expects(:raw_ssl_request).returns(failed_refund_response) response = @gateway.refund(@amount + 20, response.authorization) assert_failure response - assert_equal "The partial refund amount must be less than or equal to the original transaction amount", response.message + assert_equal 'The partial refund amount must be less than or equal to the original transaction amount', response.message assert_equal '10009', response.params['response_error_code'] end @@ -201,7 +201,7 @@ def test_successful_void @gateway.expects(:raw_ssl_request).returns(successful_void_response) response = @gateway.void(response.authorization) assert_success response - assert_equal "Succeeded!", response.message + assert_equal 'Succeeded!', response.message end def test_failed_void @@ -212,7 +212,7 @@ def test_failed_void @gateway.expects(:raw_ssl_request).returns(failed_void_response) response = @gateway.void(response.authorization) assert_failure response - assert_equal "Authorization is voided.", response.message + assert_equal 'Authorization is voided.', response.message assert_equal '10600', response.params['response_error_code'] end @@ -221,8 +221,8 @@ def test_successful_verify response = @gateway.verify(@payment_method_token) assert_success response - assert_equal "Succeeded!", response.message - assert_equal "Verification", response.params["transaction_type"] + assert_equal 'Succeeded!', response.message + assert_equal 'Verification', response.params['transaction_type'] end def test_failed_verify @@ -230,7 +230,7 @@ def test_failed_verify response = @gateway.verify(@payment_method_token) assert_failure response - assert_equal "Unable to process the verify transaction.", response.message + assert_equal 'Unable to process the verify transaction.', response.message assert_empty response.params['response_error_code'] end @@ -238,9 +238,9 @@ def test_successful_store @gateway.expects(:raw_ssl_request).returns(successful_store_response) response = @gateway.store(@credit_card) assert_success response - assert_equal "Succeeded!", response.message - assert_equal "Bml92ojQgsTf7bQ7z7WlwQVIdjr", response.authorization - assert_equal "true", response.params["retained"] + assert_equal 'Succeeded!', response.message + assert_equal 'Bml92ojQgsTf7bQ7z7WlwQVIdjr', response.authorization + assert_equal 'true', response.params['retained'] end def test_failed_store @@ -258,7 +258,7 @@ def test_successful_unstore @gateway.expects(:raw_ssl_request).returns(successful_unstore_response) response = @gateway.unstore(response.authorization) assert_success response - assert_equal "Succeeded!", response.message + assert_equal 'Succeeded!', response.message end def test_successful_find @@ -266,8 +266,8 @@ def test_successful_find response = @gateway.find(@existing_transaction) assert_success response - assert_equal "Succeeded!", response.message - assert_equal "LKA3RchoqYO0njAfhHVw60ohjrC", response.authorization + assert_equal 'Succeeded!', response.message + assert_equal 'LKA3RchoqYO0njAfhHVw60ohjrC', response.authorization end def test_failed_find diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index b62f017a61e..c5b2b0ba2c4 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -19,12 +19,12 @@ def setup @apple_pay_payment_token = apple_pay_payment_token @emv_credit_card = credit_card_with_icc_data @payment_token = StripeGateway::StripePaymentToken.new(token_params) - @token_string = @payment_token.payment_data["id"] + @token_string = @payment_token.payment_data['id'] @check = check({ - bank_name: "STRIPE TEST BANK", - account_number: "000123456789", - routing_number: "110000000", + bank_name: 'STRIPE TEST BANK', + account_number: '000123456789', + routing_number: '110000000', }) end @@ -289,7 +289,7 @@ def test_passing_validate_false_on_store def test_empty_values_not_sent response = stub_comms(@gateway, :ssl_request) do - @gateway.purchase(@amount, @credit_card, referrer: "") + @gateway.purchase(@amount, @credit_card, referrer: '') end.check_request do |method, endpoint, data, headers| refute_match(/referrer/, data) end.respond_with(successful_purchase_response) @@ -353,7 +353,7 @@ def test_successful_authorization_with_emv_credit_card assert_success response assert_equal 'ch_test_emv_charge', response.authorization - assert response.emv_authorization, "Response should include emv_authorization containing the EMV ARPC" + assert response.emv_authorization, 'Response should include emv_authorization containing the EMV ARPC' end def test_declined_authorization_with_emv_credit_card @@ -364,13 +364,13 @@ def test_declined_authorization_with_emv_credit_card assert_failure response assert_equal 'ch_declined_auth', response.authorization - assert response.emv_authorization, "Response should include emv_auth_data containing the EMV ARC" + assert response.emv_authorization, 'Response should include emv_auth_data containing the EMV ARC' end def test_successful_capture @gateway.expects(:ssl_request).returns(successful_capture_response) - assert response = @gateway.capture(@amount, "ch_test_charge") + assert response = @gateway.capture(@amount, 'ch_test_charge') assert_success response assert response.test? end @@ -378,9 +378,9 @@ def test_successful_capture def test_successful_capture_with_emv_credit_card_tc @gateway.expects(:ssl_request).returns(successful_capture_response_with_icc_data) - assert response = @gateway.capture(@amount, "ch_test_emv_charge") + assert response = @gateway.capture(@amount, 'ch_test_emv_charge') assert_success response - assert response.emv_authorization, "Response should include emv_authorization containing the EMV TC" + assert response.emv_authorization, 'Response should include emv_authorization containing the EMV TC' end def test_successful_purchase @@ -442,18 +442,18 @@ def test_amount_localization def test_adds_application_to_x_stripe_client_user_agent_header application = { - name: "app", - version: "1.0", - url: "https://example.com" + name: 'app', + version: '1.0', + url: 'https://example.com' } response = stub_comms(@gateway, :ssl_request) do - @gateway.purchase(@amount, "cus_xxx|card_xxx", @options.merge({application: application})) + @gateway.purchase(@amount, 'cus_xxx|card_xxx', @options.merge({application: application})) end.check_request do |method, endpoint, data, headers| - assert_match(/\"application\"/, headers["X-Stripe-Client-User-Agent"]) - assert_match(/\"name\":\"app\"/, headers["X-Stripe-Client-User-Agent"]) - assert_match(/\"version\":\"1.0\"/, headers["X-Stripe-Client-User-Agent"]) - assert_match(/\"url\":\"https:\/\/example.com\"/, headers["X-Stripe-Client-User-Agent"]) + assert_match(/\"application\"/, headers['X-Stripe-Client-User-Agent']) + assert_match(/\"name\":\"app\"/, headers['X-Stripe-Client-User-Agent']) + assert_match(/\"version\":\"1.0\"/, headers['X-Stripe-Client-User-Agent']) + assert_match(/\"url\":\"https:\/\/example.com\"/, headers['X-Stripe-Client-User-Agent']) end.respond_with(successful_purchase_response) assert_success response @@ -461,7 +461,7 @@ def test_adds_application_to_x_stripe_client_user_agent_header def test_successful_purchase_with_token_including_customer response = stub_comms(@gateway, :ssl_request) do - @gateway.purchase(@amount, "cus_xxx|card_xxx") + @gateway.purchase(@amount, 'cus_xxx|card_xxx') end.check_request do |method, endpoint, data, headers| assert_match(/customer=cus_xxx/, data) assert_match(/card=card_xxx/, data) @@ -472,7 +472,7 @@ def test_successful_purchase_with_token_including_customer def test_successful_purchase_with_token response = stub_comms(@gateway, :ssl_request) do - @gateway.purchase(@amount, "card_xxx") + @gateway.purchase(@amount, 'card_xxx') end.check_request do |method, endpoint, data, headers| assert_match(/card=card_xxx/, data) end.respond_with(successful_purchase_response) @@ -501,7 +501,7 @@ def test_successful_void def test_void_contains_charge_expand @gateway.expects(:ssl_request).with do |_, _, post, _| - post.include?("expand[]=charge") + post.include?('expand[]=charge') end.returns(successful_purchase_response(true)) assert response = @gateway.void('ch_test_charge') @@ -521,7 +521,7 @@ def test_void_with_additional_expand_contains_two_expands def test_void_with_expand_charge_only_sends_one_charge_expand @gateway.expects(:ssl_request).with do |_, _, post, _| parsed = CGI.parse(post) - parsed["expand[]"] == ['charge'] + parsed['expand[]'] == ['charge'] end.returns(successful_purchase_response(true)) assert response = @gateway.void('ch_test_charge', expand: ['charge']) @@ -530,7 +530,7 @@ def test_void_with_expand_charge_only_sends_one_charge_expand def test_successful_void_with_metadata @gateway.expects(:ssl_request).with do |_, _, post, _| - post.include?("metadata[first_value]=true") + post.include?('metadata[first_value]=true') end.returns(successful_purchase_response(true)) assert response = @gateway.void('ch_test_charge', {metadata: {first_value: true}}) @@ -555,7 +555,7 @@ def test_unsuccessful_refund def test_successful_refund_with_refund_application_fee @gateway.expects(:ssl_request).with do |method, url, post, headers| - post.include?("refund_application_fee=true") + post.include?('refund_application_fee=true') end.returns(successful_partially_refunded_response) assert response = @gateway.refund(@refund_amount, 'ch_test_charge', :refund_application_fee => true) @@ -564,7 +564,7 @@ def test_successful_refund_with_refund_application_fee def test_refund_contains_charge_expand @gateway.expects(:ssl_request).with do |_, _, post, _| - post.include?("expand[]=charge") + post.include?('expand[]=charge') end.returns(successful_partially_refunded_response) assert response = @gateway.refund(@refund_amount, 'ch_test_charge') @@ -584,7 +584,7 @@ def test_refund_with_additional_expand_contains_two_expands def test_refund_with_expand_charge_only_sends_one_charge_expand @gateway.expects(:ssl_request).with do |_, _, post, _| parsed = CGI.parse(post) - parsed["expand[]"] == ['charge'] + parsed['expand[]'] == ['charge'] end.returns(successful_partially_refunded_response) assert response = @gateway.refund(@refund_amount, 'ch_test_charge', expand: ['charge']) @@ -593,7 +593,7 @@ def test_refund_with_expand_charge_only_sends_one_charge_expand def test_successful_refund_with_metadata @gateway.expects(:ssl_request).with do |method, url, post, headers| - post.include?("metadata[first_value]=true") + post.include?('metadata[first_value]=true') end.returns(successful_partially_refunded_response) assert response = @gateway.refund(@refund_amount, 'ch_test_charge', {metadata: {first_value: true}}) @@ -602,14 +602,14 @@ def test_successful_refund_with_metadata def test_successful_refund_with_reverse_transfer stub_comms(@gateway, :ssl_request) do - @gateway.refund(@amount, "auth", reverse_transfer: true) + @gateway.refund(@amount, 'auth', reverse_transfer: true) end.check_request do |method, endpoint, data, headers| assert_match(/reverse_transfer=true/, data) end.respond_with(successful_partially_refunded_response) end def test_successful_refund_with_refund_fee_amount - s = sequence("request") + s = sequence('request') @gateway.expects(:ssl_request).returns(successful_partially_refunded_response).in_sequence(s) @gateway.expects(:ssl_request).returns(successful_fetch_application_fee_response).in_sequence(s) @gateway.expects(:ssl_request).returns(successful_partially_refunded_application_fee_response).in_sequence(s) @@ -620,7 +620,7 @@ def test_successful_refund_with_refund_fee_amount # What is the significance of this??? it's to test that the first response is used as primary. so identical to above with an extra assertion def test_refund_with_fee_response_gives_a_charge_authorization - s = sequence("request") + s = sequence('request') @gateway.expects(:ssl_request).returns(successful_partially_refunded_response).in_sequence(s) @gateway.expects(:ssl_request).returns(successful_fetch_application_fee_response).in_sequence(s) @gateway.expects(:ssl_request).returns(successful_partially_refunded_application_fee_response).in_sequence(s) @@ -631,7 +631,7 @@ def test_refund_with_fee_response_gives_a_charge_authorization end def test_unsuccessful_refund_with_refund_fee_amount_when_application_fee_id_not_found - s = sequence("request") + s = sequence('request') @gateway.expects(:ssl_request).returns(successful_partially_refunded_response).in_sequence(s) @gateway.expects(:ssl_request).returns(unsuccessful_fetch_application_fee_response).in_sequence(s) @@ -641,7 +641,7 @@ def test_unsuccessful_refund_with_refund_fee_amount_when_application_fee_id_not_ end def test_unsuccessful_refund_with_refund_fee_amount_when_refunding_application_fee - s = sequence("request") + s = sequence('request') @gateway.expects(:ssl_request).returns(successful_partially_refunded_response).in_sequence(s) @gateway.expects(:ssl_request).returns(successful_fetch_application_fee_response).in_sequence(s) @gateway.expects(:ssl_request).returns(generic_error_response).in_sequence(s) @@ -662,7 +662,7 @@ def test_successful_verify_with_failed_void @gateway.verify(@credit_card, @options) end.respond_with(successful_authorization_response, failed_void_response) assert_success response - assert_equal "Transaction approved", response.message + assert_equal 'Transaction approved', response.message end def test_unsuccessful_verify @@ -670,7 +670,7 @@ def test_unsuccessful_verify @gateway.verify(@credit_card, @options) end.respond_with(declined_authorization_response, successful_void_response) assert_failure response - assert_equal "Your card was declined.", response.message + assert_equal 'Your card was declined.', response.message end def test_successful_request_always_uses_live_mode_to_determine_test_request @@ -755,11 +755,11 @@ def test_add_creditcard_with_credit_card def test_add_creditcard_with_track_data post = {} - @credit_card.stubs(:track_data).returns("Swipe data") + @credit_card.stubs(:track_data).returns('Swipe data') @credit_card.stubs(:read_method).returns('contactless_magstripe') @gateway.send(:add_creditcard, post, @credit_card, {}) assert_equal @credit_card.track_data, post[:card][:swipe_data] - assert_equal "contactless_magstripe_mode", post[:card][:read_method] + assert_equal 'contactless_magstripe_mode', post[:card][:read_method] assert_nil post[:card][:number] assert_nil post[:card][:exp_year] assert_nil post[:card][:exp_month] @@ -769,11 +769,11 @@ def test_add_creditcard_with_track_data def test_add_creditcard_with_fallback_no_chip post = {} - @credit_card.stubs(:track_data).returns("Swipe data") + @credit_card.stubs(:track_data).returns('Swipe data') @credit_card.stubs(:read_method).returns('fallback_no_chip') @gateway.send(:add_creditcard, post, @credit_card, {}) assert_equal @credit_card.track_data, post[:card][:swipe_data] - assert_equal "no_chip", post[:card][:fallback_reason] + assert_equal 'no_chip', post[:card][:fallback_reason] assert_nil post[:card][:number] assert_nil post[:card][:exp_year] assert_nil post[:card][:exp_month] @@ -783,11 +783,11 @@ def test_add_creditcard_with_fallback_no_chip def test_add_creditcard_with_fallback_chip_error post = {} - @credit_card.stubs(:track_data).returns("Swipe data") + @credit_card.stubs(:track_data).returns('Swipe data') @credit_card.stubs(:read_method).returns('fallback_chip_error') @gateway.send(:add_creditcard, post, @credit_card, {}) assert_equal @credit_card.track_data, post[:card][:swipe_data] - assert_equal "chip_error", post[:card][:fallback_reason] + assert_equal 'chip_error', post[:card][:fallback_reason] assert_nil post[:card][:number] assert_nil post[:card][:exp_year] assert_nil post[:card][:exp_month] @@ -797,24 +797,24 @@ def test_add_creditcard_with_fallback_chip_error def test_add_creditcard_with_card_token post = {} - credit_card_token = "card_2iD4AezYnNNzkW" + credit_card_token = 'card_2iD4AezYnNNzkW' @gateway.send(:add_creditcard, post, credit_card_token, {}) - assert_equal "card_2iD4AezYnNNzkW", post[:card] + assert_equal 'card_2iD4AezYnNNzkW', post[:card] end def test_add_creditcard_with_card_token_and_customer post = {} - credit_card_token = "cus_3sgheFxeBgTQ3M|card_2iD4AezYnNNzkW" + credit_card_token = 'cus_3sgheFxeBgTQ3M|card_2iD4AezYnNNzkW' @gateway.send(:add_creditcard, post, credit_card_token, {}) - assert_equal "cus_3sgheFxeBgTQ3M", post[:customer] - assert_equal "card_2iD4AezYnNNzkW", post[:card] + assert_equal 'cus_3sgheFxeBgTQ3M', post[:customer] + assert_equal 'card_2iD4AezYnNNzkW', post[:card] end def test_add_creditcard_with_card_token_and_track_data post = {} - credit_card_token = "card_2iD4AezYnNNzkW" - @gateway.send(:add_creditcard, post, credit_card_token, :track_data => "Tracking data") - assert_equal "Tracking data", post[:card][:swipe_data] + credit_card_token = 'card_2iD4AezYnNNzkW' + @gateway.send(:add_creditcard, post, credit_card_token, :track_data => 'Tracking data') + assert_equal 'Tracking data', post[:card][:swipe_data] end def test_add_creditcard_with_emv_credit_card @@ -827,14 +827,14 @@ def test_add_creditcard_with_emv_credit_card def test_add_creditcard_pads_eci_value post = {} credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "111111111100cryptogram", + payment_cryptogram: '111111111100cryptogram', verification_value: nil, - eci: "7" + eci: '7' ) @gateway.send(:add_creditcard, post, credit_card, {}) - assert_equal "07", post[:card][:eci] + assert_equal '07', post[:card][:eci] end def test_application_fee_is_submitted_for_purchase @@ -847,7 +847,7 @@ def test_application_fee_is_submitted_for_purchase def test_application_fee_is_submitted_for_capture stub_comms(@gateway, :ssl_request) do - @gateway.capture(@amount, "ch_test_charge", @options.merge({:application_fee => 144})) + @gateway.capture(@amount, 'ch_test_charge', @options.merge({:application_fee => 144})) end.check_request do |method, endpoint, data, headers| assert_match(/application_fee=144/, data) end.respond_with(successful_capture_response) @@ -863,7 +863,7 @@ def test_exchange_rate_is_submitted_for_purchase def test_exchange_rate_is_submitted_for_capture stub_comms(@gateway, :ssl_request) do - @gateway.capture(@amount, "ch_test_charge", @options.merge({:exchange_rate => 0.96251})) + @gateway.capture(@amount, 'ch_test_charge', @options.merge({:exchange_rate => 0.96251})) end.check_request do |method, endpoint, data, headers| assert_match(/exchange_rate=0.96251/, data) end.respond_with(successful_capture_response) @@ -887,7 +887,7 @@ def test_destination_amount_is_submitted_for_purchase def test_client_data_submitted_with_purchase stub_comms(@gateway, :ssl_request) do - updated_options = @options.merge({:description => "a test customer",:ip => "127.127.127.127", :user_agent => "some browser", :order_id => "42", :email => "foo@wonderfullyfakedomain.com", :receipt_email => "receipt-receiver@wonderfullyfakedomain.com", :referrer =>"http://www.shopify.com"}) + updated_options = @options.merge({:description => 'a test customer',:ip => '127.127.127.127', :user_agent => 'some browser', :order_id => '42', :email => 'foo@wonderfullyfakedomain.com', :receipt_email => 'receipt-receiver@wonderfullyfakedomain.com', :referrer =>'http://www.shopify.com'}) @gateway.purchase(@amount,@credit_card,updated_options) end.check_request do |method, endpoint, data, headers| assert_match(/description=a\+test\+customer/, data) @@ -904,7 +904,7 @@ def test_client_data_submitted_with_purchase def test_client_data_submitted_with_purchase_without_email_or_order stub_comms(@gateway, :ssl_request) do - updated_options = @options.merge({:description => "a test customer",:ip => "127.127.127.127", :user_agent => "some browser", :referrer =>"http://www.shopify.com"}) + updated_options = @options.merge({:description => 'a test customer',:ip => '127.127.127.127', :user_agent => 'some browser', :referrer =>'http://www.shopify.com'}) @gateway.purchase(@amount,@credit_card,updated_options) end.check_request do |method, endpoint, data, headers| assert_match(/description=a\+test\+customer/, data) @@ -918,7 +918,7 @@ def test_client_data_submitted_with_purchase_without_email_or_order def test_client_data_submitted_with_metadata_in_options stub_comms(@gateway, :ssl_request) do - updated_options = @options.merge({:metadata => {:this_is_a_random_key_name => 'with a random value', :i_made_up_this_key_too => 'canyoutell'}, :order_id => "42", :email => "foo@wonderfullyfakedomain.com"}) + updated_options = @options.merge({:metadata => {:this_is_a_random_key_name => 'with a random value', :i_made_up_this_key_too => 'canyoutell'}, :order_id => '42', :email => 'foo@wonderfullyfakedomain.com'}) @gateway.purchase(@amount,@credit_card,updated_options) end.check_request do |method, endpoint, data, headers| assert_match(/metadata\[this_is_a_random_key_name\]=with\+a\+random\+value/, data) @@ -930,7 +930,7 @@ def test_client_data_submitted_with_metadata_in_options def test_client_data_submitted_with_metadata_in_options_with_emv_credit_card_purchase stub_comms(@gateway, :ssl_request) do - updated_options = @options.merge({:metadata => {:this_is_a_random_key_name => 'with a random value', :i_made_up_this_key_too => 'canyoutell'}, :order_id => "42", :email => "foo@wonderfullyfakedomain.com"}) + updated_options = @options.merge({:metadata => {:this_is_a_random_key_name => 'with a random value', :i_made_up_this_key_too => 'canyoutell'}, :order_id => '42', :email => 'foo@wonderfullyfakedomain.com'}) @gateway.purchase(@amount, @emv_credit_card, updated_options) end.check_request do |method, endpoint, data, headers| assert_match(/metadata\[this_is_a_random_key_name\]=with\+a\+random\+value/, data) @@ -943,7 +943,7 @@ def test_client_data_submitted_with_metadata_in_options_with_emv_credit_card_pur def test_client_data_submitted_with_metadata_in_options_with_emv_credit_card_authorize stub_comms(@gateway, :ssl_request) do - updated_options = @options.merge({:metadata => {:this_is_a_random_key_name => 'with a random value', :i_made_up_this_key_too => 'canyoutell'}, :order_id => "42", :email => "foo@wonderfullyfakedomain.com"}) + updated_options = @options.merge({:metadata => {:this_is_a_random_key_name => 'with a random value', :i_made_up_this_key_too => 'canyoutell'}, :order_id => '42', :email => 'foo@wonderfullyfakedomain.com'}) @gateway.authorize(@amount, @emv_credit_card, updated_options) end.check_request do |method, endpoint, data, headers| assert_match(/metadata\[this_is_a_random_key_name\]=with\+a\+random\+value/, data) @@ -1128,8 +1128,8 @@ def test_contactless_flag_is_not_included_with_emv_card_data_by_default def test_encrypted_pin_is_included_with_emv_card_data stub_comms(@gateway, :ssl_request) do - @emv_credit_card.encrypted_pin_cryptogram = "8b68af72199529b8" - @emv_credit_card.encrypted_pin_ksn = "ffff0102628d12000001" + @emv_credit_card.encrypted_pin_cryptogram = '8b68af72199529b8' + @emv_credit_card.encrypted_pin_ksn = 'ffff0102628d12000001' @gateway.purchase(@amount, @emv_credit_card, @options) end.check_request do |method, endpoint, data, headers| assert data =~ /card\[encrypted_pin\]=8b68af72199529b8/ @@ -1143,7 +1143,7 @@ def generate_options_should_allow_key def test_passing_expand_parameters @gateway.expects(:ssl_request).with do |method, url, post, headers| - post.include?("expand[]=balance_transaction") + post.include?('expand[]=balance_transaction') end.returns(successful_authorization_response) @options.merge!(:expand => :balance_transaction) @@ -1153,7 +1153,7 @@ def test_passing_expand_parameters def test_passing_expand_parameters_as_array @gateway.expects(:ssl_request).with do |method, url, post, headers| - post.include?("expand[]=balance_transaction&expand[]=customer") + post.include?('expand[]=balance_transaction&expand[]=customer') end.returns(successful_authorization_response) @options.merge!(:expand => [:balance_transaction, :customer]) @@ -1163,7 +1163,7 @@ def test_passing_expand_parameters_as_array def test_recurring_flag_not_set_by_default @gateway.expects(:ssl_request).with do |method, url, post, headers| - !post.include?("recurring") + !post.include?('recurring') end.returns(successful_authorization_response) @gateway.authorize(@amount, @credit_card, @options) @@ -1171,7 +1171,7 @@ def test_recurring_flag_not_set_by_default def test_passing_recurring_eci_sets_recurring_flag @gateway.expects(:ssl_request).with do |method, url, post, headers| - post.include?("recurring=true") + post.include?('recurring=true') end.returns(successful_authorization_response) @options.merge!(eci: 'recurring') @@ -1181,7 +1181,7 @@ def test_passing_recurring_eci_sets_recurring_flag def test_passing_unknown_eci_does_not_set_recurring_flag @gateway.expects(:ssl_request).with do |method, url, post, headers| - !post.include?("recurring") + !post.include?('recurring') end.returns(successful_authorization_response) @options.merge!(eci: 'installment') @@ -1191,7 +1191,7 @@ def test_passing_unknown_eci_does_not_set_recurring_flag def test_passing_recurring_true_option_sets_recurring_flag @gateway.expects(:ssl_request).with do |method, url, post, headers| - post.include?("recurring=true") + post.include?('recurring=true') end.returns(successful_authorization_response) @options.merge!(recurring: true) @@ -1201,7 +1201,7 @@ def test_passing_recurring_true_option_sets_recurring_flag def test_passing_recurring_false_option_does_not_set_recurring_flag @gateway.expects(:ssl_request).with do |method, url, post, headers| - !post.include?("recurring") + !post.include?('recurring') end.returns(successful_authorization_response) @options.merge!(recurring: false) @@ -1211,10 +1211,10 @@ def test_passing_recurring_false_option_does_not_set_recurring_flag def test_new_attributes_are_included_in_update stub_comms(@gateway, :ssl_request) do - @gateway.send(:update, "cus_3sgheFxeBgTQ3M", "card_483etw4er9fg4vF3sQdrt3FG", { :name => "John Smith", :exp_year => 2021, :exp_month => 6 }) + @gateway.send(:update, 'cus_3sgheFxeBgTQ3M', 'card_483etw4er9fg4vF3sQdrt3FG', { :name => 'John Smith', :exp_year => 2021, :exp_month => 6 }) end.check_request do |method, endpoint, data, headers| - assert data == "name=John+Smith&exp_year=2021&exp_month=6" - assert endpoint.include? "/customers/cus_3sgheFxeBgTQ3M/cards/card_483etw4er9fg4vF3sQdrt3FG" + assert data == 'name=John+Smith&exp_year=2021&exp_month=6' + assert endpoint.include? '/customers/cus_3sgheFxeBgTQ3M/cards/card_483etw4er9fg4vF3sQdrt3FG' end.respond_with(successful_update_credit_card_response) end @@ -1242,7 +1242,7 @@ def test_successful_auth_with_network_tokenization_apple_pay end.returns(successful_authorization_response) credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "111111111100cryptogram", + payment_cryptogram: '111111111100cryptogram', verification_value: nil, eci: '05' ) @@ -1263,7 +1263,7 @@ def test_successful_auth_with_network_tokenization_android_pay end.returns(successful_authorization_response) credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "111111111100cryptogram", + payment_cryptogram: '111111111100cryptogram', verification_value: nil, eci: '05', source: :android_pay @@ -1285,7 +1285,7 @@ def test_successful_purchase_with_network_tokenization_apple_pay end.returns(successful_authorization_response) credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "111111111100cryptogram", + payment_cryptogram: '111111111100cryptogram', verification_value: nil, eci: '05' ) @@ -1306,7 +1306,7 @@ def test_successful_purchase_with_network_tokenization_android_pay end.returns(successful_authorization_response) credit_card = network_tokenization_credit_card('4242424242424242', - payment_cryptogram: "111111111100cryptogram", + payment_cryptogram: '111111111100cryptogram', verification_value: nil, eci: '05', source: :android_pay @@ -1326,9 +1326,9 @@ def test_supports_network_tokenization def test_emv_capture_application_fee_ignored response = stub_comms(@gateway, :ssl_request) do - @gateway.capture(@amount, "ch_test_charge", application_fee: 100, icc_data: @emv_credit_card.icc_data) + @gateway.capture(@amount, 'ch_test_charge', application_fee: 100, icc_data: @emv_credit_card.icc_data) end.check_request do |method, endpoint, data, headers| - assert data !~ /application_fee/, "request should not include application_fee" + assert data !~ /application_fee/, 'request should not include application_fee' end.respond_with(successful_capture_response_with_icc_data) assert_success response @@ -1336,9 +1336,9 @@ def test_emv_capture_application_fee_ignored def test_authorization_with_emv_payment_application_fee_included response = stub_comms(@gateway, :ssl_request) do - @gateway.authorize(@amount, "ch_test_charge", application_fee: 100, icc_data: @emv_credit_card.icc_data) + @gateway.authorize(@amount, 'ch_test_charge', application_fee: 100, icc_data: @emv_credit_card.icc_data) end.check_request do |method, endpoint, data, headers| - assert data =~ /application_fee/, "request should include application_fee" + assert data =~ /application_fee/, 'request should include application_fee' end.respond_with(successful_capture_response_with_icc_data) assert_success response @@ -1347,7 +1347,7 @@ def test_authorization_with_emv_payment_application_fee_included def test_passing_stripe_account_header @gateway.expects(:ssl_request).with do |method, url, post, headers| - headers.include?("Stripe-Account") + headers.include?('Stripe-Account') end.returns(successful_authorization_response) @options.merge!(stripe_account: fixtures(:stripe_destination)[:stripe_user_id]) @@ -1371,7 +1371,7 @@ def test_stripe_internal_error_fails assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal response.message, "No error details" + assert_equal response.message, 'No error details' assert response.test? end @@ -2324,37 +2324,37 @@ def stripe_internal_error_response def token_params { - "id" => "tok_14uq3k2gKyKnHxtYUAZZZlH3", - "object" => "token", - "card" => { - "id" => "card_189f8n2eZvKYlo2CgvOd3Vtn", - "object" => "card", - "address_city" => nil, - "address_country" => nil, - "address_line1" => nil, - "address_line1_check" => nil, - "address_line2" => nil, - "address_state" => nil, - "address_zip" => nil, - "address_zip_check" => nil, - "brand" => "Visa", - "country" => "US", - "cvc_check" => nil, - "dynamic_last4" => nil, - "exp_month" => 8, - "exp_year" => 2017, - "funding" => "credit", - "last4" => "4242", - "metadata" => { + 'id' => 'tok_14uq3k2gKyKnHxtYUAZZZlH3', + 'object' => 'token', + 'card' => { + 'id' => 'card_189f8n2eZvKYlo2CgvOd3Vtn', + 'object' => 'card', + 'address_city' => nil, + 'address_country' => nil, + 'address_line1' => nil, + 'address_line1_check' => nil, + 'address_line2' => nil, + 'address_state' => nil, + 'address_zip' => nil, + 'address_zip_check' => nil, + 'brand' => 'Visa', + 'country' => 'US', + 'cvc_check' => nil, + 'dynamic_last4' => nil, + 'exp_month' => 8, + 'exp_year' => 2017, + 'funding' => 'credit', + 'last4' => '4242', + 'metadata' => { }, - "name" => nil, - "tokenization_method" => nil + 'name' => nil, + 'tokenization_method' => nil }, - "client_ip" => nil, - "created" => 1462903169, - "livemode" => false, - "type" => "card", - "used" => false + 'client_ip' => nil, + 'created' => 1462903169, + 'livemode' => false, + 'type' => 'card', + 'used' => false } end end diff --git a/test/unit/gateways/telr_test.rb b/test/unit/gateways/telr_test.rb index 19730ded31d..8e3ac5766bd 100644 --- a/test/unit/gateways/telr_test.rb +++ b/test/unit/gateways/telr_test.rb @@ -1,12 +1,12 @@ -require "test_helper" +require 'test_helper' class TelrTest < Test::Unit::TestCase include CommStub def setup @gateway = TelrGateway.new( - merchant_id: "login", - api_key: "password" + merchant_id: 'login', + api_key: 'password' ) @credit_card = credit_card @@ -20,7 +20,7 @@ def test_successful_purchase assert_success response - assert_equal "029724176180|100|AED", response.authorization + assert_equal '029724176180|100|AED', response.authorization assert response.test? end @@ -30,7 +30,7 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "Not authorised", response.message + assert_equal 'Not authorised', response.message end def test_successful_authorize_and_capture @@ -56,12 +56,12 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Not authorised", response.message + assert_equal 'Not authorised', response.message end def test_failed_capture response = stub_comms do - @gateway.capture(100, "") + @gateway.capture(100, '') end.respond_with(failed_capture_response) assert_failure response @@ -73,7 +73,7 @@ def test_successful_void end.respond_with(successful_authorize_response) assert_success response - assert_equal "029894296182|100|AED", response.authorization + assert_equal '029894296182|100|AED', response.authorization void = stub_comms do @gateway.void(response.authorization) @@ -86,7 +86,7 @@ def test_successful_void def test_failed_void response = stub_comms do - @gateway.void("5d53a33d960c46d00f5dc061947d998c") + @gateway.void('5d53a33d960c46d00f5dc061947d998c') end.check_request do |endpoint, data, headers| assert_match(/5d53a33d960c46d00f5dc061947d998c/, data) end.respond_with(failed_void_response) @@ -100,7 +100,7 @@ def test_successful_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "029724176180|100|AED", response.authorization + assert_equal '029724176180|100|AED', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -113,7 +113,7 @@ def test_successful_refund def test_failed_refund response = stub_comms do - @gateway.refund(nil, "") + @gateway.refund(nil, '') end.respond_with(failed_refund_response) assert_failure response @@ -124,7 +124,7 @@ def test_successful_verify @gateway.verify(@credit_card) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_verify @@ -132,7 +132,7 @@ def test_failed_verify @gateway.verify(@credit_card) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "Not authorised", response.message + assert_equal 'Not authorised', response.message end def test_successful_reference_purchase diff --git a/test/unit/gateways/tns_test.rb b/test/unit/gateways/tns_test.rb index b8a5052f2c3..f97a0e6e242 100644 --- a/test/unit/gateways/tns_test.rb +++ b/test/unit/gateways/tns_test.rb @@ -91,7 +91,7 @@ def test_void def test_passing_alpha3_country_code stub_comms(@gateway, :ssl_request) do - @gateway.authorize(@amount, @credit_card, :billing_address => {country: "US"}) + @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) @@ -99,7 +99,7 @@ def test_passing_alpha3_country_code def test_non_existent_country stub_comms(@gateway, :ssl_request) do - @gateway.authorize(@amount, @credit_card, :billing_address => {country: "Blah"}) + @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) @@ -138,7 +138,7 @@ def test_successful_verify @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, successful_void_response) assert_success response - assert_equal "91debbeb-d88f-42e9-a6ce-9b62c99d656b", response.params['order']['id'] + assert_equal '91debbeb-d88f-42e9-a6ce-9b62c99d656b', response.params['order']['id'] end def test_successful_verify_with_failed_void @@ -146,7 +146,7 @@ def test_successful_verify_with_failed_void @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_unsuccessful_verify @@ -154,7 +154,7 @@ def test_unsuccessful_verify @gateway.verify(@credit_card, @options) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "FAILURE - DECLINED", response.message + assert_equal 'FAILURE - DECLINED', response.message end def test_north_america_region_url diff --git a/test/unit/gateways/trans_first_test.rb b/test/unit/gateways/trans_first_test.rb index 25c1ef9545d..34f04f9a75c 100644 --- a/test/unit/gateways/trans_first_test.rb +++ b/test/unit/gateways/trans_first_test.rb @@ -65,30 +65,30 @@ def test_failed_purchase_with_echeck def test_successful_refund @gateway.stubs(:ssl_post).returns(successful_refund_response) - response = @gateway.refund(@amount, "TransID") + response = @gateway.refund(@amount, 'TransID') assert_success response assert_equal '207686608|creditcard', response.authorization - assert_equal @amount, response.params["amount"].to_i*100 + assert_equal @amount, response.params['amount'].to_i*100 end def test_failed_refund @gateway.stubs(:ssl_post).returns(failed_refund_response) - response = @gateway.refund(@amount, "TransID") + response = @gateway.refund(@amount, 'TransID') assert_failure response end def test_successful_void @gateway.stubs(:ssl_post).returns(successful_void_response) - response = @gateway.void("TransID") + response = @gateway.void('TransID') assert_success response end def test_failed_void @gateway.stubs(:ssl_post).returns(failed_void_response) - response = @gateway.void("TransID") + response = @gateway.void('TransID') assert_failure response end diff --git a/test/unit/gateways/trans_first_transaction_express_test.rb b/test/unit/gateways/trans_first_transaction_express_test.rb index 86db994262b..1bbfdf81f88 100644 --- a/test/unit/gateways/trans_first_transaction_express_test.rb +++ b/test/unit/gateways/trans_first_transaction_express_test.rb @@ -1,12 +1,12 @@ -require "test_helper" +require 'test_helper' class TransFirstTransactionExpressTest < Test::Unit::TestCase include CommStub def setup @gateway = TransFirstTransactionExpressGateway.new( - gateway_id: "gateway_id", - reg_key: "reg_key" + gateway_id: 'gateway_id', + reg_key: 'reg_key' ) @credit_card = credit_card @@ -22,7 +22,7 @@ def test_successful_purchase assert_success response - assert_equal "purchase|000015212561", response.authorization + assert_equal 'purchase|000015212561', response.authorization assert response.test? end @@ -32,8 +32,8 @@ def test_failed_purchase end.respond_with(failed_purchase_response) assert_failure response - assert_equal "Not sufficient funds", response.message - assert_equal "51", response.error_code + assert_equal 'Not sufficient funds', response.message + assert_equal '51', response.error_code assert response.test? end @@ -42,7 +42,7 @@ def test_successful_purchase_with_echeck response = @gateway.purchase(@amount, @check) assert_success response - assert_equal "purchase_echeck|000028705491", response.authorization + assert_equal 'purchase_echeck|000028705491', response.authorization end def test_failed_purchase_with_echeck @@ -50,7 +50,7 @@ def test_failed_purchase_with_echeck response = @gateway.purchase(@amount, @check) assert_failure response - assert_equal "Error. Bank routing number validation negative (ABA).", response.message + assert_equal 'Error. Bank routing number validation negative (ABA).', response.message end def test_successful_authorize_and_capture @@ -59,7 +59,7 @@ def test_successful_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "authorize|000015377801", response.authorization + assert_equal 'authorize|000015377801', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -76,14 +76,14 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal "Not sufficient funds", response.message - assert_equal "51", response.error_code + assert_equal 'Not sufficient funds', response.message + assert_equal '51', response.error_code assert response.test? end def test_failed_capture response = stub_comms do - @gateway.capture(100, "") + @gateway.capture(100, '') end.respond_with(failed_capture_response) assert_failure response @@ -95,7 +95,7 @@ def test_successful_void end.respond_with(successful_purchase_response) assert_success response - assert_equal "purchase|000015212561", response.authorization + assert_equal 'purchase|000015212561', response.authorization void = stub_comms do @gateway.void(response.authorization) @@ -108,13 +108,13 @@ def test_successful_void def test_failed_void response = stub_comms do - @gateway.void("purchase|5d53a33d960c46d00f5dc061947d998c") + @gateway.void('purchase|5d53a33d960c46d00f5dc061947d998c') end.check_request do |endpoint, data, headers| assert_match(/5d53a33d960c46d00f5dc061947d998c/, data) end.respond_with(failed_void_response) assert_failure response - assert_equal "50011", response.error_code + assert_equal '50011', response.error_code end def test_successful_refund @@ -123,7 +123,7 @@ def test_successful_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "purchase|000015212561", response.authorization + assert_equal 'purchase|000015212561', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -136,11 +136,11 @@ def test_successful_refund def test_failed_refund response = stub_comms do - @gateway.refund(nil, "") + @gateway.refund(nil, '') end.respond_with(failed_refund_response) assert_failure response - assert_equal "50011", response.error_code + assert_equal '50011', response.error_code end def test_successful_refund_with_echeck @@ -149,7 +149,7 @@ def test_successful_refund_with_echeck end.respond_with(successful_purchase_echeck_response) assert_success response - assert_equal "purchase_echeck|000028705491", response.authorization + assert_equal 'purchase_echeck|000028705491', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -166,7 +166,7 @@ def test_failed_refund_with_echeck end.respond_with(failed_refund_response) assert_failure response - assert_equal "50011", response.error_code + assert_equal '50011', response.error_code end def test_successful_credit @@ -176,7 +176,7 @@ def test_successful_credit assert_success response - assert_equal "credit|000001677461", response.authorization + assert_equal 'credit|000001677461', response.authorization assert response.test? end @@ -186,8 +186,8 @@ def test_failed_credit end.respond_with(failed_credit_response) assert_failure response - assert_equal "Validation Error", response.message - assert_equal "51334", response.error_code + assert_equal 'Validation Error', response.message + assert_equal '51334', response.error_code assert response.test? end @@ -196,7 +196,7 @@ def test_successful_verify @gateway.verify(@credit_card) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_failed_verify @@ -204,7 +204,7 @@ def test_failed_verify @gateway.verify(@credit_card) end.respond_with(failed_authorize_response, successful_void_response) assert_failure response - assert_equal "Not sufficient funds", response.message + assert_equal 'Not sufficient funds', response.message end def test_successful_store @@ -214,8 +214,8 @@ def test_successful_store assert_success response - assert_equal "Succeeded", response.message - assert_equal "store|1453495229881170023", response.authorization + assert_equal 'Succeeded', response.message + assert_equal 'store|1453495229881170023', response.authorization assert response.test? end @@ -225,7 +225,7 @@ def test_failed_store end.respond_with(failed_store_response) assert_failure response - assert_equal "Validation Failure", response.message + assert_equal 'Validation Failure', response.message assert response.test? end diff --git a/test/unit/gateways/transact_pro_test.rb b/test/unit/gateways/transact_pro_test.rb index a394e91431d..6590b82cb2a 100644 --- a/test/unit/gateways/transact_pro_test.rb +++ b/test/unit/gateways/transact_pro_test.rb @@ -84,7 +84,7 @@ def test_failed_capture capture = @gateway.capture(nil, '3d25ab044075924479d3836f549b015481d15d74|100') assert_failure capture - assert_equal "4dd02f79f428470bbd794590834dfbf38b5721ac|100", capture.authorization + assert_equal '4dd02f79f428470bbd794590834dfbf38b5721ac|100', capture.authorization assert_equal 'Failed', capture.message end @@ -154,31 +154,31 @@ def test_failed_verify private def successful_purchase_response - "ID:a27891dedd57e875df653144c518b8fb646b2351~Status:Success~MerchantID:1410896668~Terminal:Rietumu - non3D~ResultCode:000~ApprovalCode:646391~CardIssuerCountry:XX" + 'ID:a27891dedd57e875df653144c518b8fb646b2351~Status:Success~MerchantID:1410896668~Terminal:Rietumu - non3D~ResultCode:000~ApprovalCode:646391~CardIssuerCountry:XX' end def failed_purchase_response - "ID:fed54b10b610bb760816aad42721672e8fd19327~Status:Failed~MerchantID:1410965369~Terminal:Rietumu - non3D~ResultCode:908~ApprovalCode:-3~CardIssuerCountry:XX" + 'ID:fed54b10b610bb760816aad42721672e8fd19327~Status:Failed~MerchantID:1410965369~Terminal:Rietumu - non3D~ResultCode:908~ApprovalCode:-3~CardIssuerCountry:XX' end def successful_authorize_response - "ID:3d25ab044075924479d3836f549b015481d15d74~Status:HoldOk~MerchantID:1410974273~Terminal:Rietumu - non3D~ResultCode:000~ApprovalCode:524282~CardIssuerCountry:XX" + 'ID:3d25ab044075924479d3836f549b015481d15d74~Status:HoldOk~MerchantID:1410974273~Terminal:Rietumu - non3D~ResultCode:000~ApprovalCode:524282~CardIssuerCountry:XX' end def failed_authorize_response - "ID:c9c789a575ba8556e2c5f56174d859c23ac56e09~Status:Failed~MerchantID:1410974976~Terminal:Rietumu - non3D~ResultCode:908~ApprovalCode:-3~CardIssuerCountry:XX" + 'ID:c9c789a575ba8556e2c5f56174d859c23ac56e09~Status:Failed~MerchantID:1410974976~Terminal:Rietumu - non3D~ResultCode:908~ApprovalCode:-3~CardIssuerCountry:XX' end def successful_capture_response - "ID:3d25ab044075924479d3836f549b015481d15d74~Status:Success~MerchantID:1410974273~Terminal:Rietumu - non3D~ResultCode:000~ApprovalCode:524282~CardIssuerCountry:XX" + 'ID:3d25ab044075924479d3836f549b015481d15d74~Status:Success~MerchantID:1410974273~Terminal:Rietumu - non3D~ResultCode:000~ApprovalCode:524282~CardIssuerCountry:XX' end def failed_capture_response - "ID:4dd02f79f428470bbd794590834dfbf38b5721ac~Status:Failed~MerchantID:1325788706~Terminal:TerminalName~ResultCode:000~ApprovalCode:804958" + 'ID:4dd02f79f428470bbd794590834dfbf38b5721ac~Status:Failed~MerchantID:1325788706~Terminal:TerminalName~ResultCode:000~ApprovalCode:804958' end def successful_refund_response - "Refund Success" + 'Refund Success' end def failed_refund_response @@ -186,14 +186,14 @@ def failed_refund_response end def successful_void_response - "DMS canceled OK" + 'DMS canceled OK' end def failed_void_response - "DMS Cancel failed" + 'DMS Cancel failed' end def successful_init_response - "OK:a27891dedd57e875df653144c518b8fb646b2351" + 'OK:a27891dedd57e875df653144c518b8fb646b2351' end end diff --git a/test/unit/gateways/trexle_test.rb b/test/unit/gateways/trexle_test.rb index 7bbd31db900..288ca190d21 100644 --- a/test/unit/gateways/trexle_test.rb +++ b/test/unit/gateways/trexle_test.rb @@ -83,11 +83,11 @@ def test_unsuccessful_request assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Invalid response.", response.message + assert_equal 'Invalid response.', response.message end def test_unparsable_body_of_successful_response - @gateway.stubs(:raw_ssl_request).returns(MockResponse.succeeded("not-json")) + @gateway.stubs(:raw_ssl_request).returns(MockResponse.succeeded('not-json')) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response @@ -108,7 +108,7 @@ def test_unsuccessful_store assert response = @gateway.store(@credit_card, @options) assert_failure response - assert_equal "Invalid response.", response.message + assert_equal 'Invalid response.', response.message end def test_successful_update @@ -137,7 +137,7 @@ def test_unsuccessful_refund assert response = @gateway.refund(100, token) assert_failure response - assert_equal "Invalid response.", response.message + assert_equal 'Invalid response.', response.message end def test_successful_authorize @@ -281,8 +281,8 @@ def test_post_data def test_headers expected_headers = { - "Content-Type" => "application/json", - "Authorization" => "Basic #{Base64.strict_encode64('THIS_IS_NOT_A_REAL_API_KEY:').strip}" + 'Content-Type' => 'application/json', + 'Authorization' => "Basic #{Base64.strict_encode64('THIS_IS_NOT_A_REAL_API_KEY:').strip}" } @gateway.expects(:ssl_request).with(:post, anything, anything, expected_headers).returns(successful_purchase_response) diff --git a/test/unit/gateways/usa_epay_advanced_test.rb b/test/unit/gateways/usa_epay_advanced_test.rb index 10c8967b96a..ad96353bc4e 100644 --- a/test/unit/gateways/usa_epay_advanced_test.rb +++ b/test/unit/gateways/usa_epay_advanced_test.rb @@ -26,40 +26,40 @@ def setup :year => 12, :brand => 'visa', :verification_value => '123', - :first_name => "Fred", - :last_name => "Flintstone" + :first_name => 'Fred', + :last_name => 'Flintstone' ) @check = ActiveMerchant::Billing::Check.new( :account_number => '123456789012', :routing_number => '123456789', :account_type => 'checking', - :first_name => "Fred", - :last_name => "Flintstone" + :first_name => 'Fred', + :last_name => 'Flintstone' ) payment_methods = [ { - :name => "My Visa", # optional + :name => 'My Visa', # optional :sort => 2, # optional :method => @credit_card }, { - :name => "My Checking", + :name => 'My Checking', :method => @check } ] payment_method = { - :name => "My new Visa", # optional + :name => 'My new Visa', # optional :method => @credit_card } @customer_options = { :id => 1, # optional: merchant assigned id, usually db id - :notes => "Note about customer", # optional - :data => "Some Data", # optional - :url => "awesomesite.com", # optional + :notes => 'Note about customer', # optional + :data => 'Some Data', # optional + :url => 'awesomesite.com', # optional :payment_methods => payment_methods # optional } diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb index a4e632ae278..7138a6e5b52 100644 --- a/test/unit/gateways/usa_epay_transaction_test.rb +++ b/test/unit/gateways/usa_epay_transaction_test.rb @@ -64,7 +64,7 @@ def test_unsuccessful_request def test_successful_purchase_passing_extra_info response = stub_comms do - @gateway.purchase(@amount, @credit_card, @options.merge(:order_id => "1337", :description => "socool")) + @gateway.purchase(@amount, @credit_card, @options.merge(:order_id => '1337', :description => 'socool')) end.check_request do |endpoint, data, headers| assert_match(/UMinvoice=1337/, data) assert_match(/UMdescription=socool/, data) @@ -84,7 +84,7 @@ def test_successful_purchase_passing_extra_test_mode def test_successful_purchase_email_receipt response = stub_comms do - @gateway.purchase(@amount, @credit_card, @options.merge(:email => 'bobby@hill.com', :cust_receipt => 'Yes', :cust_receipt_name => "socool")) + @gateway.purchase(@amount, @credit_card, @options.merge(:email => 'bobby@hill.com', :cust_receipt => 'Yes', :cust_receipt_name => 'socool')) end.check_request do |endpoint, data, headers| assert_match(/UMcustreceipt=Yes/, data) assert_match(/UMcustreceiptname=socool/, data) @@ -140,7 +140,7 @@ def test_successful_authorize_request def test_successful_authorize_passing_extra_info response = stub_comms do - @gateway.authorize(@amount, @credit_card, @options.merge(:order_id => "1337", :description => "socool")) + @gateway.authorize(@amount, @credit_card, @options.merge(:order_id => '1337', :description => 'socool')) end.check_request do |endpoint, data, headers| assert_match(/UMinvoice=1337/, data) assert_match(/UMdescription=socool/, data) @@ -367,10 +367,10 @@ def test_cvv_result end def test_add_track_data_with_creditcard - @credit_card.track_data = "data" + @credit_card.track_data = 'data' @gateway.expects(:ssl_post).with do |_, body| - body.include?("UMmagstripe=data") + body.include?('UMmagstripe=data') end.returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) @@ -378,11 +378,11 @@ def test_add_track_data_with_creditcard end def test_add_track_data_with_empty_data - ["", nil].each do |data| + ['', nil].each do |data| @credit_card.track_data = data @gateway.expects(:ssl_post).with do |_, body| - refute body.include? "UMmagstripe=" + refute body.include? 'UMmagstripe=' body end.returns(successful_purchase_response) @@ -406,7 +406,7 @@ def test_manual_entry_is_properly_indicated_on_purchase end def test_does_not_raise_error_on_missing_values - @gateway.expects(:ssl_post).returns("status") + @gateway.expects(:ssl_post).returns('status') assert_nothing_raised do response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response @@ -460,39 +460,39 @@ def purchase_request end def successful_purchase_response - "UMversion=2.9&UMstatus=Approved&UMauthCode=001716&UMrefNum=55074409&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=Y&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=596&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMfiller=filled" + 'UMversion=2.9&UMstatus=Approved&UMauthCode=001716&UMrefNum=55074409&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=Y&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=596&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMfiller=filled' end def unsuccessful_purchase_response - "UMversion=2.9&UMstatus=Declined&UMauthCode=000000&UMrefNum=55076060&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=Y&UMcvv2Result=Not%20Processed&UMcvv2ResultCode=P&UMvpasResultCode=&UMresult=D&UMerror=Card%20Declined&UMerrorcode=10127&UMbatch=596&UMfiller=filled" + 'UMversion=2.9&UMstatus=Declined&UMauthCode=000000&UMrefNum=55076060&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=Y&UMcvv2Result=Not%20Processed&UMcvv2ResultCode=P&UMvpasResultCode=&UMresult=D&UMerror=Card%20Declined&UMerrorcode=10127&UMbatch=596&UMfiller=filled' end def successful_authorize_response - "UMversion=2.9&UMstatus=Approved&UMauthCode=101716&UMrefNum=65074409&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=Y&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=596&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMfiller=filled" + 'UMversion=2.9&UMstatus=Approved&UMauthCode=101716&UMrefNum=65074409&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=Y&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=596&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMfiller=filled' end def successful_capture_response - "UMversion=2.9&UMstatus=Approved&UMauthCode=101716&UMrefNum=65074409&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled" + 'UMversion=2.9&UMstatus=Approved&UMauthCode=101716&UMrefNum=65074409&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled' end def successful_refund_response - "UMversion=2.9&UMstatus=Approved&UMauthCode=101716&UMrefNum=63813138&UMavsResult=Unmapped%20AVS%20response%20%28%20%20%20%29&UMavsResultCode=%20%20%20&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=1.00&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled" + 'UMversion=2.9&UMstatus=Approved&UMauthCode=101716&UMrefNum=63813138&UMavsResult=Unmapped%20AVS%20response%20%28%20%20%20%29&UMavsResultCode=%20%20%20&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=1.00&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled' end def successful_void_response - "UMversion=2.9&UMstatus=Approved&UMauthCode=&UMrefNum=63812270&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=Transaction%20Voided%20Successfully&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled" + 'UMversion=2.9&UMstatus=Approved&UMauthCode=&UMrefNum=63812270&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=Transaction%20Voided%20Successfully&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled' end def successful_purchase_response_echeck - "UMversion=2.9&UMstatus=Approved&UMauthCode=TMEC4D&UMrefNum=133134803&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=180316&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=18031621233065&UMcardLevelResult=&UMauthAmount=&UMfiller=filled" + 'UMversion=2.9&UMstatus=Approved&UMauthCode=TMEC4D&UMrefNum=133134803&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=180316&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=18031621233065&UMcardLevelResult=&UMauthAmount=&UMfiller=filled' end def successful_refund_response_echeck - "UMversion=2.9&UMstatus=Approved&UMauthCode=TM1E74&UMrefNum=133134926&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled" + 'UMversion=2.9&UMstatus=Approved&UMauthCode=TM1E74&UMrefNum=133134926&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled' end def successful_void_response_echeck - "UMversion=2.9&UMstatus=Approved&UMauthCode=TM80A5&UMrefNum=133134971&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled" + 'UMversion=2.9&UMstatus=Approved&UMauthCode=TM80A5&UMrefNum=133134971&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled' end diff --git a/test/unit/gateways/vanco_test.rb b/test/unit/gateways/vanco_test.rb index 9b6faa66f2e..449cd696448 100644 --- a/test/unit/gateways/vanco_test.rb +++ b/test/unit/gateways/vanco_test.rb @@ -22,13 +22,13 @@ def test_successful_purchase assert_success response assert_equal '14949117|15756594|16136938', response.authorization - assert_equal "Success", response.message + assert_equal 'Success', response.message assert response.test? end def test_successful_purchase_with_fund_id response = stub_comms do - @gateway.purchase(@amount, @credit_card, @options.merge(fund_id: "MyEggcellentFund")) + @gateway.purchase(@amount, @credit_card, @options.merge(fund_id: 'MyEggcellentFund')) end.check_request do |endpoint, data, headers| if data =~ /<RequestType>EFTAdd/ assert_match(%r(<FundID>MyEggcellentFund<\/FundID>), data) @@ -37,12 +37,12 @@ def test_successful_purchase_with_fund_id assert_success response assert_equal '14949117|15756594|16137331', response.authorization - assert_equal "Success", response.message + assert_equal 'Success', response.message end def test_successful_purchase_with_ip_address response = stub_comms do - @gateway.purchase(@amount, @credit_card, @options.merge(ip: "192.168.0.1")) + @gateway.purchase(@amount, @credit_card, @options.merge(ip: '192.168.0.1')) end.check_request do |endpoint, data, headers| if data =~ /<RequestType>EFTAdd/ assert_match(%r(<CustomerIPAddress>192), data) @@ -57,7 +57,7 @@ def test_failed_purchase end.respond_with(successful_login_response, failed_purchase_response) assert_failure response - assert_equal "286", response.params["error_codes"] + assert_equal '286', response.params['error_codes'] end def test_failed_purchase_multiple_errors @@ -66,8 +66,8 @@ def test_failed_purchase_multiple_errors end.respond_with(successful_login_response, failed_purchase_multiple_errors_response) assert_failure response - assert_equal "Client not set up for International Credit Card Processing. Another Error.", response.message - assert_equal "286, 331", response.params["error_codes"] + assert_equal 'Client not set up for International Credit Card Processing. Another Error.', response.message + assert_equal '286, 331', response.params['error_codes'] end def test_successful_purchase_echeck @@ -77,7 +77,7 @@ def test_successful_purchase_echeck assert_success response assert_equal '14949514|15757035|16138421', response.authorization - assert_equal "Success", response.message + assert_equal 'Success', response.message assert response.test? end @@ -87,25 +87,25 @@ def test_failed_purchase_echeck end.respond_with(successful_login_response, failed_purchase_echeck_response) assert_failure response - assert_equal "178", response.params["error_codes"] + assert_equal '178', response.params['error_codes'] end def test_successful_refund response = stub_comms do - @gateway.refund(@amount, "authoriziation") + @gateway.refund(@amount, 'authoriziation') end.respond_with(successful_login_response, successful_refund_response) assert_success response - assert_equal "Success", response.message + assert_equal 'Success', response.message end def test_failed_refund response = stub_comms do - @gateway.refund(@amount, "authorization") + @gateway.refund(@amount, 'authorization') end.respond_with(successful_login_response, failed_refund_response) assert_failure response - assert_equal "575", response.params["error_codes"] + assert_equal '575', response.params['error_codes'] end def test_scrub diff --git a/test/unit/gateways/verifi_test.rb b/test/unit/gateways/verifi_test.rb index b9dae02ce2a..028c623a996 100644 --- a/test/unit/gateways/verifi_test.rb +++ b/test/unit/gateways/verifi_test.rb @@ -13,7 +13,7 @@ def setup @options = { :order_id => '37', - :email => "paul@example.com", + :email => 'paul@example.com', :billing_address => address } @@ -38,23 +38,23 @@ def test_unsuccessful_request end def test_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/ccnumber=#{@credit_card.number}/), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/ccnumber=#{@credit_card.number}/), anything).returns('') @gateway.expects(:parse).returns({}) @gateway.credit(@amount, @credit_card, @options) end def test_deprecated_credit - @gateway.expects(:ssl_post).with(anything, regexp_matches(/transactionid=transaction_id/), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/transactionid=transaction_id/), anything).returns('') @gateway.expects(:parse).returns({}) assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do - @gateway.credit(@amount, "transaction_id", @options) + @gateway.credit(@amount, 'transaction_id', @options) end end def test_refund - @gateway.expects(:ssl_post).with(anything, regexp_matches(/transactionid=transaction_id/), anything).returns("") + @gateway.expects(:ssl_post).with(anything, regexp_matches(/transactionid=transaction_id/), anything).returns('') @gateway.expects(:parse).returns({}) - @gateway.refund(@amount, "transaction_id", @options) + @gateway.refund(@amount, 'transaction_id', @options) end def test_amount_style @@ -74,7 +74,7 @@ def test_add_description def test_purchase_meets_minimum_requirements post = VerifiGateway::VerifiPostData.new - post[:amount] = "1.01" + post[:amount] = '1.01' @gateway.send(:add_credit_card, post, @credit_card) @@ -107,10 +107,10 @@ def minimum_requirements end def successful_purchase_response - "response=1&responsetext=SUCCESS&authcode=123456&transactionid=546061538&avsresponse=N&cvvresponse=N&orderid=37&type=sale&response_code=100" + 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=546061538&avsresponse=N&cvvresponse=N&orderid=37&type=sale&response_code=100' end def unsuccessful_purchase_response - "response=3&responsetext=Field required: ccnumber REFID:12109909&authcode=&transactionid=0&avsresponse=&cvvresponse=&orderid=37&type=sale&response_code=300" + 'response=3&responsetext=Field required: ccnumber REFID:12109909&authcode=&transactionid=0&avsresponse=&cvvresponse=&orderid=37&type=sale&response_code=300' end end diff --git a/test/unit/gateways/viaklix_test.rb b/test/unit/gateways/viaklix_test.rb index 8625f01ad5d..ea24cf3f3e2 100644 --- a/test/unit/gateways/viaklix_test.rb +++ b/test/unit/gateways/viaklix_test.rb @@ -11,7 +11,7 @@ def setup @credit_card = credit_card @options = { :order_id => '37', - :email => "paul@domain.com", + :email => 'paul@domain.com', :description => 'Test Transaction', :billing_address => address } diff --git a/test/unit/gateways/visanet_peru_test.rb b/test/unit/gateways/visanet_peru_test.rb index 49aab0a9bc7..55d77cb4427 100644 --- a/test/unit/gateways/visanet_peru_test.rb +++ b/test/unit/gateways/visanet_peru_test.rb @@ -5,13 +5,13 @@ def setup @gateway = VisanetPeruGateway.new(fixtures(:visanet_peru)) @amount = 100 - @credit_card = credit_card("4500340090000016", verification_value: "377") - @declined_card = credit_card("4111111111111111") + @credit_card = credit_card('4500340090000016', verification_value: '377') + @declined_card = credit_card('4111111111111111') @options = { billing_address: address, order_id: generate_unique_id, - email: "visanetperutest@mailinator.com" + email: 'visanetperutest@mailinator.com' } end @@ -21,10 +21,10 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "OK", response.message + assert_equal 'OK', response.message assert_match %r([0-9]{9}|$), response.authorization - assert_equal @options[:order_id], response.params["externalTransactionId"] + assert_equal @options[:order_id], response.params['externalTransactionId'] assert response.test? end @@ -34,17 +34,17 @@ def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response assert_equal 400, response.error_code - assert_equal "Operacion Denegada.", response.message + assert_equal 'Operacion Denegada.', response.message end def test_successful_authorize @gateway.expects(:ssl_request).returns(successful_authorize_response) response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - assert_equal "OK", response.message + assert_equal 'OK', response.message assert_match %r(^[0-9]{9}|$), response.authorization - assert_equal @options[:order_id], response.params["externalTransactionId"] - assert_equal "1.00", response.params["data"]["IMP_AUTORIZADO"] + assert_equal @options[:order_id], response.params['externalTransactionId'] + assert_equal '1.00', response.params['data']['IMP_AUTORIZADO'] assert response.test? end @@ -53,14 +53,14 @@ def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response assert_equal 400, response.error_code - assert_equal "Operacion Denegada.", response.message + assert_equal 'Operacion Denegada.', response.message @gateway.expects(:ssl_request).returns(failed_authorize_response_bad_email) - @options[:email] = "cybersource@reject.com" + @options[:email] = 'cybersource@reject.com' response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response assert_equal 400, response.error_code - assert_equal "REJECT", response.message + assert_equal 'REJECT', response.message end def test_successful_capture @@ -69,15 +69,15 @@ def test_successful_capture response = @gateway.authorize(@amount, @credit_card, @options) capture = @gateway.capture(response.authorization, @options) assert_success capture - assert_equal "OK", capture.message + assert_equal 'OK', capture.message assert_match %r(^[0-9]{9}|$), capture.authorization - assert_equal @options[:order_id], capture.params["externalTransactionId"] + assert_equal @options[:order_id], capture.params['externalTransactionId'] assert capture.test? end def test_failed_capture @gateway.expects(:ssl_request).returns(failed_capture_response) - invalid_purchase_number = "900000044" + invalid_purchase_number = '900000044' response = @gateway.capture(invalid_purchase_number) assert_failure response assert_equal '[ "NUMORDEN 900000044 no se encuentra registrado", "No se realizo el deposito" ]', response.message @@ -93,12 +93,12 @@ def test_successful_refund @gateway.expects(:ssl_request).returns(successful_refund_response) refund = @gateway.refund(@amount, response.authorization) assert_success refund - assert_equal "OK", refund.message + assert_equal 'OK', refund.message end def test_failed_refund @gateway.expects(:ssl_request).returns(failed_refund_response) - response = @gateway.refund(@amount, "122333444") + response = @gateway.refund(@amount, '122333444') assert_failure response assert_match(/No se realizo la anulacion del deposito/, response.message) assert_equal 400, response.error_code @@ -112,12 +112,12 @@ def test_successful_void @gateway.expects(:ssl_request).returns(successful_void_response) void = @gateway.void(response.authorization) assert_success void - assert_equal "OK", void.message + assert_equal 'OK', void.message end def test_failed_void @gateway.expects(:ssl_request).returns(failed_void_response) - response = @gateway.void("122333444") + response = @gateway.void('122333444') assert_failure response assert_match(/No se ha realizado la anulacion del pedido/, response.message) assert_equal 400, response.error_code @@ -128,8 +128,8 @@ def test_successful_verify @gateway.expects(:ssl_request).returns(successful_verify_response) response = @gateway.verify(@credit_card, @options) assert_success response - assert_equal "OK", response.message - assert_equal @options[:order_id], response.params["externalTransactionId"] + assert_equal 'OK', response.message + assert_equal @options[:order_id], response.params['externalTransactionId'] end def test_failed_verify @@ -137,7 +137,7 @@ def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response assert_equal 400, response.error_code - assert_equal "Operacion Denegada.", response.message + assert_equal 'Operacion Denegada.', response.message end def test_scrub diff --git a/test/unit/gateways/webpay_test.rb b/test/unit/gateways/webpay_test.rb index 476a5d514c4..d0163560e37 100644 --- a/test/unit/gateways/webpay_test.rb +++ b/test/unit/gateways/webpay_test.rb @@ -30,7 +30,7 @@ def test_successful_authorization def test_successful_capture @gateway.expects(:ssl_request).returns(successful_capture_response) - assert response = @gateway.capture(@amount, "ch_test_charge") + assert response = @gateway.capture(@amount, 'ch_test_charge') assert_success response assert response.test? end @@ -54,12 +54,12 @@ def test_appropriate_purchase_amount assert_instance_of Response, response assert_success response - assert_equal @amount / 100, response.params["amount"] + assert_equal @amount / 100, response.params['amount'] end def test_successful_purchase_with_token response = stub_comms(@gateway, :ssl_request) do - @gateway.purchase(@amount, "cus_xxx|card_xxx") + @gateway.purchase(@amount, 'cus_xxx|card_xxx') end.check_request do |method, endpoint, data, headers| assert_match(/customer=cus_xxx/, data) assert_match(/card=card_xxx/, data) @@ -121,20 +121,20 @@ def test_invalid_raw_response def test_add_customer post = {} - @gateway.send(:add_customer, post, 'card_token', {:customer => "test_customer"}) - assert_equal "test_customer", post[:customer] + @gateway.send(:add_customer, post, 'card_token', {:customer => 'test_customer'}) + assert_equal 'test_customer', post[:customer] end def test_doesnt_add_customer_if_card post = {} - @gateway.send(:add_customer, post, @credit_card, {:customer => "test_customer"}) + @gateway.send(:add_customer, post, @credit_card, {:customer => 'test_customer'}) assert !post[:customer] end def test_add_customer_data post = {} - @gateway.send(:add_customer_data, post, {:description => "a test customer"}) - assert_equal "a test customer", post[:description] + @gateway.send(:add_customer_data, post, {:description => 'a test customer'}) + assert_equal 'a test customer', post[:description] end def test_add_address diff --git a/test/unit/gateways/wepay_test.rb b/test/unit/gateways/wepay_test.rb index 8f64d00b984..9f749e27916 100644 --- a/test/unit/gateways/wepay_test.rb +++ b/test/unit/gateways/wepay_test.rb @@ -14,7 +14,7 @@ def setup @amount = 20000 @options = { - email: "test@example.com" + email: 'test@example.com' } end @@ -24,7 +24,7 @@ def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - assert_equal "1181910285|20.00", response.authorization + assert_equal '1181910285|20.00', response.authorization end def test_failed_purchase @@ -37,16 +37,16 @@ def test_failed_purchase def test_successful_purchase_with_token @gateway.expects(:ssl_post).at_most(2).returns(successful_capture_response) - response = @gateway.purchase(@amount, "1422891921", @options) + response = @gateway.purchase(@amount, '1422891921', @options) assert_success response - assert_equal "1181910285|20.00", response.authorization + assert_equal '1181910285|20.00', response.authorization end def test_failed_purchase_with_token @gateway.expects(:ssl_post).at_most(2).returns(failed_capture_response) - response = @gateway.purchase(@amount, "1422891921", @options) + response = @gateway.purchase(@amount, '1422891921', @options) assert_failure response end @@ -62,7 +62,7 @@ def test_failed_refund response = @gateway.refund(@amount, @credit_card, @options) assert_failure response - assert_equal "refund_reason parameter is required", response.message + assert_equal 'refund_reason parameter is required', response.message end def test_successful_authorize @@ -77,35 +77,35 @@ def test_failed_authorize response = @gateway.authorize(@amount, @credit_card, @options) assert_failure response - assert_equal "Invalid credit card number", response.message + assert_equal 'Invalid credit card number', response.message end def test_successful_authorize_with_token @gateway.expects(:ssl_post).at_most(2).returns(successful_authorize_response) - response = @gateway.authorize(@amount, "1422891921", @options) + response = @gateway.authorize(@amount, '1422891921', @options) assert_success response end def test_failed_authorize_with_token @gateway.expects(:ssl_post).at_most(2).returns(failed_authorize_response) - response = @gateway.authorize(@amount, "1422891921", @options) + response = @gateway.authorize(@amount, '1422891921', @options) assert_failure response - assert_equal "Invalid credit card number", response.message + assert_equal 'Invalid credit card number', response.message end def test_successful_capture @gateway.expects(:ssl_post).at_most(2).returns(successful_capture_response) - response = @gateway.capture(@amount, "auth|amount", @options) + response = @gateway.capture(@amount, 'auth|amount', @options) assert_success response end def test_failed_capture @gateway.expects(:ssl_post).at_most(3).returns(failed_capture_response) - response = @gateway.capture(@amount, "auth|200.00", @options) + response = @gateway.capture(@amount, 'auth|200.00', @options) assert_failure response assert_equal "Checkout object must be in state 'Reserved' to capture. Currently it is in state captured", response.message end @@ -113,16 +113,16 @@ def test_failed_capture def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) - response = @gateway.void("auth|amount", @options) + response = @gateway.void('auth|amount', @options) assert_success response end def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) - response = @gateway.void("auth|amount", @options) + response = @gateway.void('auth|amount', @options) assert_failure response - assert_equal "this checkout has already been cancelled", response.message + assert_equal 'this checkout has already been cancelled', response.message end def test_successful_store_via_create @@ -130,7 +130,7 @@ def test_successful_store_via_create response = @gateway.store(@credit_card, @options) assert_success response - assert_equal "3322208138", response.authorization + assert_equal '3322208138', response.authorization end def test_successful_store_via_transfer @@ -138,7 +138,7 @@ def test_successful_store_via_transfer response = @gateway.store(@credit_card, @options.merge(recurring: true)) assert_success response - assert_equal "3322208138", response.authorization + assert_equal '3322208138', response.authorization end def test_failed_store @@ -146,7 +146,7 @@ def test_failed_store response = @gateway.store(@credit_card, @options) assert_failure response - assert_equal "Invalid credit card number", response.message + assert_equal 'Invalid credit card number', response.message end def test_invalid_json_response diff --git a/test/unit/gateways/wirecard_test.rb b/test/unit/gateways/wirecard_test.rb index d073f2eecd7..b5ee72ebbc7 100644 --- a/test/unit/gateways/wirecard_test.rb +++ b/test/unit/gateways/wirecard_test.rb @@ -13,7 +13,7 @@ def setup @credit_card = credit_card('4200000000000000') @declined_card = credit_card('4000300011112220') @unsupported_card = credit_card('4200000000000000', brand: :maestro) - @amex_card = credit_card('370000000000000', brand: "american_express") + @amex_card = credit_card('370000000000000', brand: 'american_express') @amount = 111 @@ -149,23 +149,23 @@ def test_successful_authorization_and_partial_capture def test_unauthorized_capture @gateway.expects(:ssl_post).returns(unauthorized_capture_response) - assert response = @gateway.capture(@amount, "1234567890123456789012", @options) + assert response = @gateway.capture(@amount, '1234567890123456789012', @options) assert_failure response assert_equal TEST_CAPTURE_GUWID, response.authorization - assert response.message["Could not find referenced transaction for GuWID 1234567890123456789012."] + assert response.message['Could not find referenced transaction for GuWID 1234567890123456789012.'] end def test_failed_refund @gateway.expects(:ssl_post).returns(failed_refund_response) - assert response = @gateway.refund(@amount - 30, "TheIdentifcation", @options) + assert response = @gateway.refund(@amount - 30, 'TheIdentifcation', @options) assert_failure response assert_match %r{Not prudent}, response.message end def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) - assert response = @gateway.refund(@amount - 30, "TheIdentifcation", @options) + assert response = @gateway.refund(@amount - 30, 'TheIdentifcation', @options) assert_failure response assert_match %r{Not gonna do it}, response.message end @@ -187,7 +187,7 @@ def test_no_error_if_no_address_provided end def test_description_trucated_to_32_chars_in_authorize - options = { description: "32chars-------------------------EXTRA" } + options = { description: '32chars-------------------------EXTRA' } stub_comms do @gateway.authorize(@amount, @credit_card, options) @@ -197,7 +197,7 @@ def test_description_trucated_to_32_chars_in_authorize end def test_description_trucated_to_32_chars_in_purchase - options = { description: "32chars-------------------------EXTRA" } + options = { description: '32chars-------------------------EXTRA' } stub_comms do @gateway.purchase(@amount, @credit_card, options) @@ -207,7 +207,7 @@ def test_description_trucated_to_32_chars_in_purchase end def test_description_is_ascii_encoded_since_wirecard_does_not_like_utf_8 - options = { description: "¿Dónde está la estación?" } + options = { description: '¿Dónde está la estación?' } stub_comms do @gateway.purchase(@amount, @credit_card, options) @@ -220,18 +220,18 @@ def test_failed_avs_response_message options = @options.merge(billing_address: @address_avs) @gateway.expects(:ssl_post).returns(failed_avs_response) response = @gateway.purchase(@amount, @credit_card, options) - assert_match %r{A}, response.avs_result["code"] + assert_match %r{A}, response.avs_result['code'] end def test_failed_amex_avs_response_code options = @options.merge(billing_address: @address_avs) @gateway.expects(:ssl_post).returns(failed_avs_response) response = @gateway.purchase(@amount, @amex_card, options) - assert_match %r{B}, response.avs_result["code"] + assert_match %r{B}, response.avs_result['code'] end def test_commerce_type_option - options = { commerce_type: "MOTO" } + options = { commerce_type: 'MOTO' } stub_comms do @gateway.purchase(@amount, @credit_card, options) @@ -244,7 +244,7 @@ def test_store_sets_recurring_transaction_type_to_initial stub_comms do @gateway.store(@credit_card) end.check_request do |endpoint, body, headers| - assert_xml_element_text(body, "//RECURRING_TRANSACTION/Type", "Initial") + assert_xml_element_text(body, '//RECURRING_TRANSACTION/Type', 'Initial') end.respond_with(successful_authorization_response) end @@ -252,7 +252,7 @@ def test_store_sets_amount_to_100_by_default stub_comms do @gateway.store(@credit_card) end.check_request do |endpoint, body, headers| - assert_xml_element_text(body, "//CC_TRANSACTION/Amount", "100") + assert_xml_element_text(body, '//CC_TRANSACTION/Amount', '100') end.respond_with(successful_authorization_response) end @@ -260,7 +260,7 @@ def test_store_sets_amount_to_amount_from_options stub_comms do @gateway.store(@credit_card, :amount => 120) end.check_request do |endpoint, body, headers| - assert_xml_element_text(body, "//CC_TRANSACTION/Amount", "120") + assert_xml_element_text(body, '//CC_TRANSACTION/Amount', '120') end.respond_with(successful_authorization_response) end @@ -268,7 +268,7 @@ def test_authorization_using_reference_sets_proper_elements stub_comms do @gateway.authorize(@amount, '45678', @options) end.check_request do |endpoint, body, headers| - assert_xml_element_text(body, "//GuWID", '45678') + assert_xml_element_text(body, '//GuWID', '45678') assert_no_match(/<CREDIT_CARD_DATA>/, body) end.respond_with(successful_authorization_response) end @@ -277,24 +277,24 @@ def test_purchase_using_reference_sets_proper_elements stub_comms do @gateway.purchase(@amount, '87654', @options) end.check_request do |endpoint, body, headers| - assert_xml_element_text(body, "//GuWID", '87654') + assert_xml_element_text(body, '//GuWID', '87654') assert_no_match(/<CREDIT_CARD_DATA>/, body) end.respond_with(successful_authorization_response) end def test_authorization_with_recurring_transaction_type_initial stub_comms do - @gateway.authorize(@amount, @credit_card, @options.merge(:recurring => "Initial")) + @gateway.authorize(@amount, @credit_card, @options.merge(:recurring => 'Initial')) end.check_request do |endpoint, body, headers| - assert_xml_element_text(body, "//RECURRING_TRANSACTION/Type", 'Initial') + assert_xml_element_text(body, '//RECURRING_TRANSACTION/Type', 'Initial') end.respond_with(successful_authorization_response) end def test_purchase_using_with_recurring_transaction_type_initial stub_comms do - @gateway.purchase(@amount, @credit_card, @options.merge(:recurring => "Initial")) + @gateway.purchase(@amount, @credit_card, @options.merge(:recurring => 'Initial')) end.check_request do |endpoint, body, headers| - assert_xml_element_text(body, "//RECURRING_TRANSACTION/Type", 'Initial') + assert_xml_element_text(body, '//RECURRING_TRANSACTION/Type', 'Initial') end.respond_with(successful_authorization_response) end @@ -310,8 +310,8 @@ def test_system_error_response_without_job assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_equal "Job Refused", response.params["Message"] - assert_equal "10003", response.params["ErrorCode"] + assert_equal 'Job Refused', response.params['Message'] + assert_equal '10003', response.params['ErrorCode'] end def test_transcript_scrubbing diff --git a/test/unit/gateways/worldpay_online_payments_test.rb b/test/unit/gateways/worldpay_online_payments_test.rb index 1ab94e025a2..e97d3b457e0 100644 --- a/test/unit/gateways/worldpay_online_payments_test.rb +++ b/test/unit/gateways/worldpay_online_payments_test.rb @@ -14,11 +14,11 @@ def setup description: 'Test Purchase' } - @token = "TEST_RU_8fcc4f2f-8c0d-483d-a0a3-eaad7356623e" - @intoken = "_TEST_RU_8fcc4f2f-8c0d-483d-a0a3-eaad7356623e_" + @token = 'TEST_RU_8fcc4f2f-8c0d-483d-a0a3-eaad7356623e' + @intoken = '_TEST_RU_8fcc4f2f-8c0d-483d-a0a3-eaad7356623e_' - @orderCode = "e69b5445-2a46-4f2c-b67d-7e1e95bd00a5" - @inorderCode = "_e69b5445-2a46-4f2c-b67d-7e1e95bd00a5_" + @orderCode = 'e69b5445-2a46-4f2c-b67d-7e1e95bd00a5' + @inorderCode = '_e69b5445-2a46-4f2c-b67d-7e1e95bd00a5_' end def test_successful_purchase @@ -184,8 +184,8 @@ def test_failed_verify def test_invalid_login badgateway = WorldpayOnlinePaymentsGateway.new( - client_key: "T_C_NOT_VALID", - service_key: "T_S_NOT_VALID" + client_key: 'T_C_NOT_VALID', + service_key: 'T_S_NOT_VALID' ) badgateway.expects(:ssl_request).returns(failed_login_response) diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index 35d18b69a5e..2fb4297ffcb 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -97,7 +97,7 @@ def test_purchase_does_not_run_inquiry end.respond_with(successful_capture_response) assert_success response - assert_equal %w(authorize capture), response.responses.collect{|e| e.params["action"]} + assert_equal %w(authorize capture), response.responses.collect{|e| e.params['action']} end def test_successful_void @@ -105,8 +105,8 @@ def test_successful_void @gateway.void(@options[:order_id], @options) end.respond_with(successful_void_inquiry_response, successful_void_response) assert_success response - assert_equal "SUCCESS", response.message - assert_equal "924e810350efc21a989e0ac7727ce43b", response.params["cancel_received_order_code"] + assert_equal 'SUCCESS', response.message + assert_equal '924e810350efc21a989e0ac7727ce43b', response.params['cancel_received_order_code'] end def test_void_fails_unless_status_is_authorized @@ -129,7 +129,7 @@ def test_successful_refund_for_settled_payment @gateway.refund(@amount, @options[:order_id], @options) end.respond_with(successful_refund_inquiry_response('SETTLED'), successful_refund_response) assert_success response - assert_equal "05d9f8c622553b1df1fe3a145ce91ccf", response.params['refund_received_order_code'] + assert_equal '05d9f8c622553b1df1fe3a145ce91ccf', response.params['refund_received_order_code'] end def test_successful_refund_for_settled_by_merchant_payment @@ -137,7 +137,7 @@ def test_successful_refund_for_settled_by_merchant_payment @gateway.refund(@amount, @options[:order_id], @options) end.respond_with(successful_refund_inquiry_response('SETTLED_BY_MERCHANT'), successful_refund_response) assert_success response - assert_equal "05d9f8c622553b1df1fe3a145ce91ccf", response.params['refund_received_order_code'] + assert_equal '05d9f8c622553b1df1fe3a145ce91ccf', response.params['refund_received_order_code'] end def test_refund_fails_unless_status_is_captured @@ -153,7 +153,7 @@ def test_full_refund_for_unsettled_payment_forces_void @gateway.refund(@amount, @options[:order_id], @options.merge(force_full_refund_if_unsettled: true)) end.respond_with(failed_refund_inquiry_response, failed_refund_inquiry_response, successful_void_response) assert_success response - assert "cancel", response.responses.last.params["action"] + assert 'cancel', response.responses.last.params['action'] end def test_capture @@ -182,7 +182,7 @@ def test_description end.respond_with(successful_authorize_response) stub_comms do - @gateway.authorize(@amount, @credit_card, @options.merge(description: "Something cool.")) + @gateway.authorize(@amount, @credit_card, @options.merge(description: 'Something cool.')) end.check_request do |endpoint, data, headers| assert_match %r(<description>Something cool.</description>), data end.respond_with(successful_authorize_response) @@ -287,7 +287,7 @@ def test_address_handling end.respond_with(successful_authorize_response) stub_comms do - @gateway.authorize(100, @credit_card, @options.merge(billing_address: { phone: "555-3323" })) + @gateway.authorize(100, @credit_card, @options.merge(billing_address: { phone: '555-3323' })) end.check_request do |endpoint, data, headers| assert_no_match %r(firstName), data assert_no_match %r(lastName), data @@ -340,7 +340,7 @@ def test_address_with_parts_unspecified def test_email stub_comms do - @gateway.authorize(100, @credit_card, @options.merge(email: "eggcellent@example.com")) + @gateway.authorize(100, @credit_card, @options.merge(email: 'eggcellent@example.com')) end.check_request do |endpoint, data, headers| assert_match %r(<shopperEmailAddress>eggcellent@example.com</shopperEmailAddress>), data end.respond_with(successful_authorize_response) @@ -354,7 +354,7 @@ def test_email def test_ip stub_comms do - @gateway.authorize(100, @credit_card, @options.merge(ip: "192.137.11.44")) + @gateway.authorize(100, @credit_card, @options.merge(ip: '192.137.11.44')) end.check_request do |endpoint, data, headers| assert_match %r(<session shopperIPAddress="192.137.11.44"/>), data end.respond_with(successful_authorize_response) @@ -368,30 +368,30 @@ def test_ip def test_parsing response = stub_comms do - @gateway.authorize(100, @credit_card, @options.merge(address: {address1: "123 Anystreet", country: "US"})) + @gateway.authorize(100, @credit_card, @options.merge(address: {address1: '123 Anystreet', country: 'US'})) end.respond_with(successful_authorize_response) assert_equal({ - "action"=>"authorize", - "amount_currency_code"=>"HKD", - "amount_debit_credit_indicator"=>"credit", - "amount_exponent"=>"2", - "amount_value"=>"15000", - "avs_result_code_description"=>"UNKNOWN", - "balance"=>true, - "balance_account_type"=>"IN_PROCESS_AUTHORISED", - "card_number"=>"4111********1111", - "cvc_result_code_description"=>"UNKNOWN", - "last_event"=>"AUTHORISED", - "order_status"=>true, - "order_status_order_code"=>"R50704213207145707", - "payment"=>true, - "payment_method"=>"VISA-SSL", - "payment_service"=>true, - "payment_service_merchant_code"=>"XXXXXXXXXXXXXXX", - "payment_service_version"=>"1.4", - "reply"=>true, - "risk_score_value"=>"1", + 'action'=>'authorize', + 'amount_currency_code'=>'HKD', + 'amount_debit_credit_indicator'=>'credit', + 'amount_exponent'=>'2', + 'amount_value'=>'15000', + 'avs_result_code_description'=>'UNKNOWN', + 'balance'=>true, + 'balance_account_type'=>'IN_PROCESS_AUTHORISED', + 'card_number'=>'4111********1111', + 'cvc_result_code_description'=>'UNKNOWN', + 'last_event'=>'AUTHORISED', + 'order_status'=>true, + 'order_status_order_code'=>'R50704213207145707', + 'payment'=>true, + 'payment_method'=>'VISA-SSL', + 'payment_service'=>true, + 'payment_service_merchant_code'=>'XXXXXXXXXXXXXXX', + 'payment_service_version'=>'1.4', + 'reply'=>true, + 'risk_score_value'=>'1', }, response.params) end @@ -399,7 +399,7 @@ def test_auth stub_comms do @gateway.authorize(100, @credit_card, @options) end.check_request do |endpoint, data, headers| - assert_equal "Basic dGVzdGxvZ2luOnRlc3RwYXNzd29yZA==", headers['Authorization'] + assert_equal 'Basic dGVzdGxvZ2luOnRlc3RwYXNzd29yZA==', headers['Authorization'] end.respond_with(successful_authorize_response) end @@ -625,7 +625,7 @@ def failed_void_inquiry_response RESPONSE end - def successful_refund_inquiry_response(last_event="CAPTURED") + def successful_refund_inquiry_response(last_event='CAPTURED') <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE paymentService PUBLIC "-//Bibit//DTD Bibit PaymentService v1//EN" diff --git a/test/unit/gateways/worldpay_us_test.rb b/test/unit/gateways/worldpay_us_test.rb index 55797ebbe2b..ee576daa591 100644 --- a/test/unit/gateways/worldpay_us_test.rb +++ b/test/unit/gateways/worldpay_us_test.rb @@ -28,7 +28,7 @@ def test_successful_purchase assert_success response - assert_equal "353583515|252889136", response.authorization + assert_equal '353583515|252889136', response.authorization assert response.test? end @@ -46,7 +46,7 @@ def test_successful_echeck_purchase assert_success response - assert_equal "421414035|306588394", response.authorization + assert_equal '421414035|306588394', response.authorization assert response.test? end @@ -63,7 +63,7 @@ def test_authorize_and_capture end.respond_with(successful_authorize_response) assert_success response - assert_equal "354275517|253394390", response.authorization + assert_equal '354275517|253394390', response.authorization capture = stub_comms do @gateway.capture(@amount, response.authorization) @@ -80,7 +80,7 @@ def test_refund end.respond_with(successful_purchase_response) assert_success response - assert_equal "353583515|252889136", response.authorization + assert_equal '353583515|252889136', response.authorization refund = stub_comms do @gateway.refund(@amount, response.authorization) @@ -98,7 +98,7 @@ def test_void end.respond_with(successful_purchase_response) assert_success response - assert_equal "353583515|252889136", response.authorization + assert_equal '353583515|252889136', response.authorization refund = stub_comms do @gateway.void(response.authorization) @@ -122,7 +122,7 @@ def test_successful_verify_failed_void @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, failed_void_response) assert_success response - assert_equal "Succeeded", response.message + assert_equal 'Succeeded', response.message end def test_unsuccessful_verify @@ -172,7 +172,7 @@ def test_empty_response_fails end.respond_with(empty_purchase_response) assert_failure response - assert_equal "Unable to read error message", response.message + assert_equal 'Unable to read error message', response.message end def test_backup_url diff --git a/test/unit/multi_response_test.rb b/test/unit/multi_response_test.rb index a07de6fa243..82e8735e962 100644 --- a/test/unit/multi_response_test.rb +++ b/test/unit/multi_response_test.rb @@ -9,8 +9,8 @@ def test_initial_state end def test_processes_sub_requests - r1 = Response.new(true, "1", {}) - r2 = Response.new(true, "2", {}) + r1 = Response.new(true, '1', {}) + r2 = Response.new(true, '2', {}) m = MultiResponse.run do |r| r.process{r1} r.process{r2} @@ -19,8 +19,8 @@ def test_processes_sub_requests end def test_run_convenience_method - r1 = Response.new(true, "1", {}) - r2 = Response.new(true, "2", {}) + r1 = Response.new(true, '1', {}) + r2 = Response.new(true, '2', {}) m = MultiResponse.run do |r| r.process{r1} r.process{r2} @@ -33,43 +33,43 @@ def test_proxies_last_request r1 = Response.new( true, - "1", - {"one" => 1}, + '1', + {'one' => 1}, :test => true, - :authorization => "auth1", - :avs_result => {:code => "AVS1"}, - :cvv_result => "CVV1", + :authorization => 'auth1', + :avs_result => {:code => 'AVS1'}, + :cvv_result => 'CVV1', :error_code => :card_declined, :fraud_review => true ) m.process{r1} - assert_equal({"one" => 1}, m.params) - assert_equal "1", m.message + assert_equal({'one' => 1}, m.params) + assert_equal '1', m.message assert m.test - assert_equal "auth1", m.authorization - assert_equal "AVS1", m.avs_result["code"] - assert_equal "CVV1", m.cvv_result["code"] + assert_equal 'auth1', m.authorization + assert_equal 'AVS1', m.avs_result['code'] + assert_equal 'CVV1', m.cvv_result['code'] assert_equal :card_declined, m.error_code assert m.test? assert m.fraud_review? r2 = Response.new( true, - "2", - {"two" => 2}, + '2', + {'two' => 2}, :test => false, - :authorization => "auth2", - :avs_result => {:code => "AVS2"}, - :cvv_result => "CVV2", + :authorization => 'auth2', + :avs_result => {:code => 'AVS2'}, + :cvv_result => 'CVV2', :fraud_review => false ) m.process{r2} - assert_equal({"two" => 2}, m.params) - assert_equal "2", m.message + assert_equal({'two' => 2}, m.params) + assert_equal '2', m.message assert !m.test - assert_equal "auth2", m.authorization - assert_equal "AVS2", m.avs_result["code"] - assert_equal "CVV2", m.cvv_result["code"] + assert_equal 'auth2', m.authorization + assert_equal 'AVS2', m.avs_result['code'] + assert_equal 'CVV2', m.cvv_result['code'] assert !m.test? assert !m.fraud_review? end @@ -79,41 +79,41 @@ def test_proxies_first_request_if_marked r1 = Response.new( true, - "1", - {"one" => 1}, + '1', + {'one' => 1}, :test => true, - :authorization => "auth1", - :avs_result => {:code => "AVS1"}, - :cvv_result => "CVV1", + :authorization => 'auth1', + :avs_result => {:code => 'AVS1'}, + :cvv_result => 'CVV1', :fraud_review => true ) m.process{r1} - assert_equal({"one" => 1}, m.params) - assert_equal "1", m.message + assert_equal({'one' => 1}, m.params) + assert_equal '1', m.message assert m.test - assert_equal "auth1", m.authorization - assert_equal "AVS1", m.avs_result["code"] - assert_equal "CVV1", m.cvv_result["code"] + assert_equal 'auth1', m.authorization + assert_equal 'AVS1', m.avs_result['code'] + assert_equal 'CVV1', m.cvv_result['code'] assert m.test? assert m.fraud_review? r2 = Response.new( true, - "2", - {"two" => 2}, + '2', + {'two' => 2}, :test => false, - :authorization => "auth2", - :avs_result => {:code => "AVS2"}, - :cvv_result => "CVV2", + :authorization => 'auth2', + :avs_result => {:code => 'AVS2'}, + :cvv_result => 'CVV2', :fraud_review => false ) m.process{r2} - assert_equal({"one" => 1}, m.params) - assert_equal "1", m.message + assert_equal({'one' => 1}, m.params) + assert_equal '1', m.message assert m.test - assert_equal "auth1", m.authorization - assert_equal "AVS1", m.avs_result["code"] - assert_equal "CVV1", m.cvv_result["code"] + assert_equal 'auth1', m.authorization + assert_equal 'AVS1', m.avs_result['code'] + assert_equal 'CVV1', m.cvv_result['code'] assert m.test? assert m.fraud_review? end @@ -121,9 +121,9 @@ def test_proxies_first_request_if_marked def test_primary_response_always_returns_the_last_response_on_failure m = MultiResponse.new(:use_first_response) - r1 = Response.new(true, "1", {}, {}) - r2 = Response.new(false, "2", {}, {}) - r3 = Response.new(false, "3", {}, {}) + r1 = Response.new(true, '1', {}, {}) + r2 = Response.new(false, '2', {}, {}) + r3 = Response.new(false, '3', {}, {}) m.process{r1} m.process{r2} m.process{r3} @@ -132,8 +132,8 @@ def test_primary_response_always_returns_the_last_response_on_failure end def test_stops_processing_upon_failure - r1 = Response.new(false, "1", {}) - r2 = Response.new(true, "2", {}) + r1 = Response.new(false, '1', {}) + r2 = Response.new(true, '2', {}) m = MultiResponse.run do |r| r.process{r1} r.process{r2} @@ -143,9 +143,9 @@ def test_stops_processing_upon_failure end def test_merges_sub_multi_responses - r1 = Response.new(true, "1", {}) - r2 = Response.new(true, "2", {}) - r3 = Response.new(true, "3", {}) + r1 = Response.new(true, '1', {}) + r2 = Response.new(true, '2', {}) + r3 = Response.new(true, '3', {}) m1 = MultiResponse.run do |r| r.process{r1} r.process{r2} @@ -160,14 +160,14 @@ def test_merges_sub_multi_responses def test_handles_ignores_optional_request_result m = MultiResponse.new - r1 = Response.new(true, "1") + r1 = Response.new(true, '1') m.process{r1} - assert_equal "1", m.message + assert_equal '1', m.message assert_equal [r1], m.responses - r2 = Response.new(false, "2") + r2 = Response.new(false, '2') m.process(:ignore_result){r2} - assert_equal "1", m.message + assert_equal '1', m.message assert_equal [r1, r2], m.responses assert m.success? diff --git a/test/unit/network_connection_retries_test.rb b/test/unit/network_connection_retries_test.rb index aff10190667..84fbfac2c08 100644 --- a/test/unit/network_connection_retries_test.rb +++ b/test/unit/network_connection_retries_test.rb @@ -19,7 +19,7 @@ def test_eoferror_raises_correctly end end - assert_equal "The remote server dropped the connection", raised.message + assert_equal 'The remote server dropped the connection', raised.message end def test_econnreset_raises_correctly @@ -28,7 +28,7 @@ def test_econnreset_raises_correctly raise Errno::ECONNRESET end end - assert_equal "The remote server reset the connection", raised.message + assert_equal 'The remote server reset the connection', raised.message end def test_timeout_errors_raise_correctly @@ -40,7 +40,7 @@ def test_timeout_errors_raise_correctly raise exception end end - assert_equal "The connection to the remote server timed out", raised.message + assert_equal 'The connection to the remote server timed out', raised.message end end @@ -50,7 +50,7 @@ def test_socket_error_raises_correctly raise SocketError end end - assert_equal "The connection to the remote server could not be established", raised.message + assert_equal 'The connection to the remote server could not be established', raised.message end def test_ssl_errors_raise_correctly @@ -63,7 +63,7 @@ def test_ssl_errors_raise_correctly raise exception end end - assert_equal "The SSL connection to the remote server could not be established", raised.message + assert_equal 'The SSL connection to the remote server could not be established', raised.message end end @@ -169,7 +169,7 @@ def test_failure_with_additional_exceptions_specified @requester.expects(:post).raises(MyNewError) assert_raises(ActiveMerchant::ConnectionError) do - retry_exceptions :connection_exceptions => {MyNewError => "my message"} do + retry_exceptions :connection_exceptions => {MyNewError => 'my message'} do @requester.post end end diff --git a/test/unit/network_tokenization_credit_card_test.rb b/test/unit/network_tokenization_credit_card_test.rb index c864240d91e..a5ac80e822d 100644 --- a/test/unit/network_tokenization_credit_card_test.rb +++ b/test/unit/network_tokenization_credit_card_test.rb @@ -4,9 +4,9 @@ class NetworkTokenizationCreditCardTest < Test::Unit::TestCase def setup @tokenized_card = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new({ - number: "4242424242424242", :brand => "visa", + number: '4242424242424242', :brand => 'visa', month: default_expiration_date.month, year: default_expiration_date.year, - payment_cryptogram: "EHuWW9PiBkWvqE5juRwDzAUFBAk=", eci: "05" + payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', eci: '05' }) @tokenized_apple_pay_card = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new({ source: :apple_pay @@ -23,7 +23,7 @@ def setup end def test_type - assert_equal "network_tokenization", @tokenized_card.type + assert_equal 'network_tokenization', @tokenized_card.type end def test_credit_card? @@ -35,7 +35,7 @@ def test_credit_card? end def test_optional_validations - assert_valid @tokenized_card, "Network tokenization card should not require name or verification value" + assert_valid @tokenized_card, 'Network tokenization card should not require name or verification value' end def test_source diff --git a/test/unit/posts_data_test.rb b/test/unit/posts_data_test.rb index 962cf2e5ae5..960992cd0d4 100644 --- a/test/unit/posts_data_test.rb +++ b/test/unit/posts_data_test.rb @@ -45,9 +45,9 @@ def test_successful_raw_request def test_raw_ssl_request_does_not_mutate_headers_argument ActiveMerchant::Connection.any_instance.expects(:request).returns(@ok) - headers = { "Content-Type" => "text/xml" }.freeze + headers = { 'Content-Type' => 'text/xml' }.freeze @gateway.raw_ssl_request(:post, @url, '', headers) - assert_equal({ "Content-Type" => "text/xml" }, headers) + assert_equal({ 'Content-Type' => 'text/xml' }, headers) end def test_setting_ssl_strict_outside_class_definition diff --git a/test/unit/rails_compatibility_test.rb b/test/unit/rails_compatibility_test.rb index 696c7c92bd5..addcb3ec701 100644 --- a/test/unit/rails_compatibility_test.rb +++ b/test/unit/rails_compatibility_test.rb @@ -1,14 +1,14 @@ -require "test_helper" +require 'test_helper' class RailsCompatibilityTest < Test::Unit::TestCase def test_should_be_able_to_access_errors_indifferently - cc = credit_card("4779139500118580", :first_name => "") + cc = credit_card('4779139500118580', :first_name => '') silence_deprecation_warnings do assert !cc.valid? assert cc.errors.on(:first_name) - assert cc.errors.on("first_name") - assert_equal "cannot be empty", cc.errors.on(:first_name) + assert cc.errors.on('first_name') + assert_equal 'cannot be empty', cc.errors.on(:first_name) end end end From 487842623b6548ca8d08723d36b9e2698dbfa2e6 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Thu, 28 Jun 2018 16:16:28 -0400 Subject: [PATCH 456/677] Conekta: Allow customer application in headers Also, options were not previously being passed to the commit method, so the metadata header was not being utilized until these changes. Remote: 15 tests, 57 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 13 tests, 84 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/conekta.rb | 27 +++++++++++-------- test/unit/gateways/conekta_test.rb | 20 ++++++++++++++ 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 919f98a9bfa..c8cdf82e09c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,7 @@ * Braintree: add support for Maestro cards [matthewheath] #2571 * Visanet Peru: Refund on unsettled transactions [nfarve] #2772 * Remove iDeal offsite gateway references [bdewater] #2807 +* Conekta: Allow customer application in headers [curiousepic] #2908 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/conekta.rb b/lib/active_merchant/billing/gateways/conekta.rb index d0857a0b917..6b3dccd915e 100644 --- a/lib/active_merchant/billing/gateways/conekta.rb +++ b/lib/active_merchant/billing/gateways/conekta.rb @@ -23,7 +23,7 @@ def purchase(money, payment_source, options = {}) add_payment_source(post, payment_source, options) add_details_data(post, options) - commit(:post, 'charges', post) + commit(:post, 'charges', post, options) end def authorize(money, payment_source, options = {}) @@ -34,7 +34,7 @@ def authorize(money, payment_source, options = {}) add_details_data(post, options) post[:capture] = false - commit(:post, 'charges', post) + commit(:post, 'charges', post, options) end def capture(money, identifier, options = {}) @@ -43,7 +43,7 @@ def capture(money, identifier, options = {}) post[:order_id] = identifier add_order(post, money, options) - commit(:post, "charges/#{identifier}/capture", post) + commit(:post, "charges/#{identifier}/capture", post, options) end def refund(money, identifier, options) @@ -52,12 +52,12 @@ def refund(money, identifier, options) post[:order_id] = identifier add_order(post, money, options) - commit(:post, "charges/#{identifier}/refund", post) + commit(:post, "charges/#{identifier}/refund", post, options) end def void(identifier, options = {}) post = {} - commit(:post, "charges/#{identifier}/void", post) + commit(:post, "charges/#{identifier}/void", post, options) end def supports_scrubbing @@ -173,22 +173,27 @@ def parse(body) JSON.parse(body) end - def headers(meta) + def headers(options) { - 'Accept' => "application/vnd.conekta-v#{options[:version]}+json", + 'Accept' => "application/vnd.conekta-v#{@options[:version]}+json", 'Accept-Language' => 'es', - 'Authorization' => 'Basic ' + Base64.encode64("#{options[:key]}:"), + 'Authorization' => 'Basic ' + Base64.encode64("#{@options[:key]}:"), 'RaiseHtmlError' => 'false', 'Conekta-Client-User-Agent' => {'agent'=>"Conekta ActiveMerchantBindings/#{ActiveMerchant::VERSION}"}.to_json, - 'X-Conekta-Client-User-Agent' => user_agent, - 'X-Conekta-Client-User-Metadata' => meta.to_json + 'X-Conekta-Client-User-Agent' => conekta_client_user_agent(options), + 'X-Conekta-Client-User-Metadata' => options[:meta].to_json } end + def conekta_client_user_agent(options) + return user_agent unless options[:application] + JSON.dump(JSON.parse(user_agent).merge!({application: options[:application]})) + end + def commit(method, url, parameters, options = {}) success = false begin - raw_response = parse(ssl_request(method, live_url + url, (parameters ? parameters.to_query : nil), headers(options[:meta]))) + raw_response = parse(ssl_request(method, live_url + url, (parameters ? parameters.to_query : nil), headers(options))) success = (raw_response.key?('object') && (raw_response['object'] != 'error')) rescue ResponseError => e raw_response = response_error(e.response.body) diff --git a/test/unit/gateways/conekta_test.rb b/test/unit/gateways/conekta_test.rb index 31b0319cb3b..215a50b1ba3 100644 --- a/test/unit/gateways/conekta_test.rb +++ b/test/unit/gateways/conekta_test.rb @@ -146,6 +146,26 @@ def test_invalid_key assert response.test? end + def test_adds_application_and_meta_headers + application = { + name: 'app', + version: '1.0', + url: 'https://example.com' + } + + 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| + 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']) + assert_match(/\"url\":\"https:\/\/example.com\"/, headers['X-Conekta-Client-User-Agent']) + assert_match(/\"its_so_meta\":\"even this acronym\"/, headers['X-Conekta-Client-User-Metadata']) + end.respond_with(successful_purchase_response) + + assert_success response + end + def test_transcript_scrubbing assert_equal scrubbed_transcript, @gateway.scrub(transcript) end From 2c8032f3ff63d5e83476f3b6f9015a2245072580 Mon Sep 17 00:00:00 2001 From: Bart de Water <bart.dewater@shopify.com> Date: Fri, 29 Jun 2018 12:53:37 -0400 Subject: [PATCH 457/677] Default SSL min_version to TLS 1.1 to comply with PCI DSS deadline Ruby supports setting this from version 2.5, I backported this for 2.3 and 2.4 with the min_max_ssl gem. For more details about the deadline: https://blog.pcisecuritystandards.org/are-you-ready-for-30-june-2018-sayin-goodbye-to-ssl-early-tls --- CHANGELOG | 1 + lib/active_merchant/connection.rb | 3 ++- lib/active_merchant/posts_data.rb | 2 +- test/unit/connection_test.rb | 6 +++--- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c8cdf82e09c..10b250c38e8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 * Paymentez: return a Result object even when the upstream server 500s [bpollack] #2871 * Drop support for Ruby versions older than 2.3 [bpollack] #2863 * Bridge Pay: don't throw an exception when bank account type is omitted [bpollack] #2873 diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index 42ceb2d6770..a289bcdd82f 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -14,6 +14,7 @@ class Connection VERIFY_PEER = true CA_FILE = File.expand_path('../certs/cacert.pem', File.dirname(__FILE__)) CA_PATH = nil + MIN_VERSION = :TLS1_1 RETRY_SAFE = false RUBY_184_POST_HEADERS = { 'Content-Type' => 'application/x-www-form-urlencoded' } @@ -51,7 +52,7 @@ def initialize(endpoint) @ignore_http_status = false @ssl_version = nil if Net::HTTP.instance_methods.include?(:min_version=) - @min_version = nil + @min_version = MIN_VERSION @max_version = nil end @ssl_connection = {} diff --git a/lib/active_merchant/posts_data.rb b/lib/active_merchant/posts_data.rb index e7de9be2f99..9930f2635e4 100644 --- a/lib/active_merchant/posts_data.rb +++ b/lib/active_merchant/posts_data.rb @@ -9,7 +9,7 @@ def self.included(base) base.ssl_version = nil base.class_attribute :min_version - base.min_version = nil + base.min_version = Connection::MIN_VERSION base.class_attribute :max_version base.max_version = nil diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index df2f07f2ed9..03261fcbf0c 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -115,9 +115,9 @@ def test_override_ssl_version def test_override_min_version omit_if Net::HTTP.instance_methods.exclude?(:min_version=) - refute_equal :TLS1_1, @connection.min_version - @connection.min_version = :TLS1_1 - assert_equal :TLS1_1, @connection.min_version + refute_equal :TLS1_2, @connection.min_version + @connection.min_version = :TLS1_2 + assert_equal :TLS1_2, @connection.min_version end def test_override_max_version From 3d0e832bf76561a4d72c67149da02f69966fed34 Mon Sep 17 00:00:00 2001 From: Serguei Okladnikov <oklaspec@gmail.com> Date: Sat, 1 Oct 2016 10:38:35 +0000 Subject: [PATCH 458/677] Update Payment Express testing URLs The testing URL for Payment Express is different from the production URL. Add the test URL, and properly toggle based on the testing flag. For more details, see https://www.paymentexpress.com/developer-e-commerce-paymentexpress-hosted-pxpay Closes #2231 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/payment_express.rb | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 10b250c38e8..ecb42b0173f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -28,6 +28,7 @@ * Visanet Peru: Refund on unsettled transactions [nfarve] #2772 * Remove iDeal offsite gateway references [bdewater] #2807 * Conekta: Allow customer application in headers [curiousepic] #2908 +* Payment Express: use testing URLs when testing [oklas] #2231 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb index b78e112a8f0..688a49a3001 100644 --- a/lib/active_merchant/billing/gateways/payment_express.rb +++ b/lib/active_merchant/billing/gateways/payment_express.rb @@ -21,7 +21,8 @@ class PaymentExpressGateway < Gateway self.homepage_url = 'http://www.paymentexpress.com/' self.display_name = 'PaymentExpress' - self.live_url = self.test_url = 'https://sec.paymentexpress.com/pxpost.aspx' + self.live_url = 'https://sec.paymentexpress.com/pxpost.aspx' + self.test_url = 'https://uat.paymentexpress.com/pxpost.aspx' APPROVED = '1' @@ -293,8 +294,10 @@ def commit(action, request) add_credentials(request) add_transaction_type(request, action) + url = test? ? self.test_url : self.live_url + # Parse the XML response - response = parse( ssl_post(self.live_url, request.to_s) ) + response = parse(ssl_post(url, request.to_s)) # Return a response PaymentExpressResponse.new(response[:success] == APPROVED, message_from(response), response, From 40dc522376ad13305c514963612591f9089a1892 Mon Sep 17 00:00:00 2001 From: nerburish <nerburish@gmail.com> Date: Mon, 23 Oct 2017 20:45:01 +0200 Subject: [PATCH 459/677] Missing cardnumber params in xml_signed_fields --- lib/active_merchant/billing/gateways/redsys.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb index 9e9ab4313e2..bb5c5fa2986 100644 --- a/lib/active_merchant/billing/gateways/redsys.rb +++ b/lib/active_merchant/billing/gateways/redsys.rb @@ -514,8 +514,14 @@ def mac256(key, data) end def xml_signed_fields(data) - data[:ds_amount] + data[:ds_order] + data[:ds_merchantcode] + data[:ds_currency] + - data[:ds_response] + data[:ds_transactiontype] + data[:ds_securepayment] + xml_signed_fields = data[:ds_amount] + data[:ds_order] + data[:ds_merchantcode] + + data[:ds_currency] + data[:ds_response] + + if data[:ds_cardnumber] + xml_signed_fields += data[:ds_cardnumber] + end + + xml_signed_fields += data[:ds_transactiontype] + data[:ds_securepayment] end def get_key(order_id) From 5980146eedc24ae00567edbbc3234430ad599db6 Mon Sep 17 00:00:00 2001 From: Leonardo Diez <leio10@users.noreply.github.com> Date: Mon, 18 Sep 2017 12:10:54 +0200 Subject: [PATCH 460/677] Fix payments with cc token in Redsys gateway Payment by reference (using credit card token obtained from a store_in_vault transaction) fails when the parameter Ds_Merchant_DirectPayment is missing. The documentation is a little bit confusing, but in practice (at least in my case) the payment is only authorized when this parameter is present. --- lib/active_merchant/billing/gateways/redsys.rb | 1 + test/unit/gateways/redsys_sha256_test.rb | 2 +- test/unit/gateways/redsys_test.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb index bb5c5fa2986..2fb8ecfcd02 100644 --- a/lib/active_merchant/billing/gateways/redsys.rb +++ b/lib/active_merchant/billing/gateways/redsys.rb @@ -395,6 +395,7 @@ def build_merchant_data(xml, data) xml.DS_MERCHANT_IDENTIFIER 'REQUIRED' if data[:store_in_vault] elsif data[:credit_card_token] xml.DS_MERCHANT_IDENTIFIER data[:credit_card_token] + xml.DS_MERCHANT_DIRECTPAYMENT 'true' end end end diff --git a/test/unit/gateways/redsys_sha256_test.rb b/test/unit/gateways/redsys_sha256_test.rb index bab7b23ed96..f1fbac3c70f 100644 --- a/test/unit/gateways/redsys_sha256_test.rb +++ b/test/unit/gateways/redsys_sha256_test.rb @@ -266,7 +266,7 @@ def purchase_request end def purchase_request_with_credit_card_token - 'entrada=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3CREQUEST%3E%3CDATOSENTRADA%3E%3CDS_Version%3E0.1%3C%2FDS_Version%3E%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%3CDS_MERCHANT_AMOUNT%3E100%3C%2FDS_MERCHANT_AMOUNT%3E%3CDS_MERCHANT_ORDER%3E144742884282%3C%2FDS_MERCHANT_ORDER%3E%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%3CDS_MERCHANT_IDENTIFIER%3E3126bb8b80a79e66eb1ecc39e305288b60075f86%3C%2FDS_MERCHANT_IDENTIFIER%3E%3C%2FDATOSENTRADA%3E%3CDS_SIGNATUREVERSION%3EHMAC_SHA256_V1%3C%2FDS_SIGNATUREVERSION%3E%3CDS_SIGNATURE%3EFFiY%2B5BTlw1zGwSHySBKWJw4DN7SbgVNSgWMTX8sll0%3D%3C%2FDS_SIGNATURE%3E%3C%2FREQUEST%3E' + 'entrada=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3CREQUEST%3E%3CDATOSENTRADA%3E%3CDS_Version%3E0.1%3C%2FDS_Version%3E%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%3CDS_MERCHANT_AMOUNT%3E100%3C%2FDS_MERCHANT_AMOUNT%3E%3CDS_MERCHANT_ORDER%3E144742884282%3C%2FDS_MERCHANT_ORDER%3E%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%3CDS_MERCHANT_IDENTIFIER%3E3126bb8b80a79e66eb1ecc39e305288b60075f86%3C%2FDS_MERCHANT_IDENTIFIER%3E%3CDS_MERCHANT_DIRECTPAYMENT%3Etrue%3C%2FDS_MERCHANT_DIRECTPAYMENT%3E%3C%2FDATOSENTRADA%3E%3CDS_SIGNATUREVERSION%3EHMAC_SHA256_V1%3C%2FDS_SIGNATUREVERSION%3E%3CDS_SIGNATURE%3EN0tYMrHGf1PmmJ7WIiRONdqbIGmyhaV%2BhP4acTyfJYE%3D%3C%2FDS_SIGNATURE%3E%3C%2FREQUEST%3E' end def successful_purchase_response diff --git a/test/unit/gateways/redsys_test.rb b/test/unit/gateways/redsys_test.rb index fa143deb3b9..4a5e9ce3816 100644 --- a/test/unit/gateways/redsys_test.rb +++ b/test/unit/gateways/redsys_test.rb @@ -260,7 +260,7 @@ def purchase_request end def purchase_request_with_credit_card_token - 'entrada=%3CDATOSENTRADA%3E%0A++%3CDS_Version%3E0.1%3C%2FDS_Version%3E%0A++%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%0A++%3CDS_MERCHANT_AMOUNT%3E123%3C%2FDS_MERCHANT_AMOUNT%3E%0A++%3CDS_MERCHANT_ORDER%3E1001%3C%2FDS_MERCHANT_ORDER%3E%0A++%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%0A++%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%0A++%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%0A++%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%0A++%3CDS_MERCHANT_MERCHANTSIGNATURE%3Ecbcc0dee5724cd3fff08bbd4371946a0599c7fb9%3C%2FDS_MERCHANT_MERCHANTSIGNATURE%3E%0A++%3CDS_MERCHANT_IDENTIFIER%3E77bff3a969d6f97b2ec815448cdcff453971f573%3C%2FDS_MERCHANT_IDENTIFIER%3E%0A%3C%2FDATOSENTRADA%3E%0A' + 'entrada=%3CDATOSENTRADA%3E%0A++%3CDS_Version%3E0.1%3C%2FDS_Version%3E%0A++%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%0A++%3CDS_MERCHANT_AMOUNT%3E123%3C%2FDS_MERCHANT_AMOUNT%3E%0A++%3CDS_MERCHANT_ORDER%3E1001%3C%2FDS_MERCHANT_ORDER%3E%0A++%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%0A++%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%0A++%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%0A++%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%0A++%3CDS_MERCHANT_MERCHANTSIGNATURE%3Ecbcc0dee5724cd3fff08bbd4371946a0599c7fb9%3C%2FDS_MERCHANT_MERCHANTSIGNATURE%3E%0A++%3CDS_MERCHANT_IDENTIFIER%3E77bff3a969d6f97b2ec815448cdcff453971f573%3C%2FDS_MERCHANT_IDENTIFIER%3E%0A++%3CDS_MERCHANT_DIRECTPAYMENT%3Etrue%3C%2FDS_MERCHANT_DIRECTPAYMENT%3E%0A%3C%2FDATOSENTRADA%3E%0A' end def successful_purchase_response From b4c212800882373caf943e5d3f6a54bcb3f43060 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Fri, 29 Jun 2018 17:01:30 -0400 Subject: [PATCH 461/677] Redsys: Add skipped changelog entries 5980146eedc24ae00567edbbc3234430ad599db6 Closes #2586 40dc522376ad13305c514963612591f9089a1892 Closes #2628 --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index ecb42b0173f..818487496d7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -29,6 +29,8 @@ * Remove iDeal offsite gateway references [bdewater] #2807 * Conekta: Allow customer application in headers [curiousepic] #2908 * Payment Express: use testing URLs when testing [oklas] #2231 +* Redsys: Fix payments with cc token [Leonardo Diez] #2586 +* Redsys: Missing cardnumber params in xml_signed_fields [nerburish] #2628 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] From dc22cda58ca6fb1b784ec439e90e632a69c3157a Mon Sep 17 00:00:00 2001 From: Karol Galanciak <karol.galanciak@gmail.com> Date: Tue, 9 Jan 2018 23:13:14 +0700 Subject: [PATCH 462/677] Bogus: allow authorize with tokenized card Unit: 20 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: N/A Closes #2703 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/bogus.rb | 2 +- test/unit/gateways/bogus_test.rb | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 818487496d7..64f96ed2222 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -31,6 +31,7 @@ * Payment Express: use testing URLs when testing [oklas] #2231 * Redsys: Fix payments with cc token [Leonardo Diez] #2586 * Redsys: Missing cardnumber params in xml_signed_fields [nerburish] #2628 +* Bogus: allow authorizing with a tokenized card [Azdaroth] #2703 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/bogus.rb b/lib/active_merchant/billing/gateways/bogus.rb index f6662fca7f2..b5d51182368 100644 --- a/lib/active_merchant/billing/gateways/bogus.rb +++ b/lib/active_merchant/billing/gateways/bogus.rb @@ -129,7 +129,7 @@ def authorize_emv(money, paysource, options = {}) def authorize_swipe(money, paysource, options = {}) money = amount(money) case normalize(paysource) - when /1$/ + when /1$/, AUTHORIZATION Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION ) when /2$/ Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error]) diff --git a/test/unit/gateways/bogus_test.rb b/test/unit/gateways/bogus_test.rb index 64da3842489..ddd8a1dcd31 100644 --- a/test/unit/gateways/bogus_test.rb +++ b/test/unit/gateways/bogus_test.rb @@ -28,6 +28,11 @@ def test_authorize assert_equal('Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error', e.message) end + def test_authorize_using_credit_card_token + token = @gateway.store(credit_card(CC_SUCCESS_PLACEHOLDER)).authorization + assert @gateway.authorize(1000, token).success? + end + def test_purchase assert @gateway.purchase(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success? response = @gateway.purchase(1000, credit_card(CC_FAILURE_PLACEHOLDER)) From b1ae4aebd598f20bf4c698ee3d779c55e9e3d36c Mon Sep 17 00:00:00 2001 From: cyclotron3k <aidan.samuel@gmail.com> Date: Tue, 21 Nov 2017 15:22:20 +1100 Subject: [PATCH 463/677] Update documentation to reflect current standards `:type` has been deprecated in favour of `:brand`, and `:verification_value` is an available parameter Closes #2654 --- GettingStarted.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/GettingStarted.md b/GettingStarted.md index f8fac95f593..d78458d7d40 100644 --- a/GettingStarted.md +++ b/GettingStarted.md @@ -43,12 +43,13 @@ Instantiating such an object is simple: ```ruby credit_card = ActiveMerchant::Billing::CreditCard.new( - :first_name => 'Steve', - :last_name => 'Smith', - :month => '9', - :year => '2014', - :type => 'visa', - :number => '4242424242424242') + :first_name => 'Steve', + :last_name => 'Smith', + :month => '9', + :year => '2022', + :brand => 'visa', + :number => '4242424242424242', + :verification_value => '424') ``` Most often, though, you'll be using user-supplied data. In a typical Rails controller: From 3d4d7d9f58d8d4b7537bc9f6ede78720d01951ba Mon Sep 17 00:00:00 2001 From: Filipe Costa <filipebarcos@gmail.com> Date: Wed, 4 Jul 2018 09:47:02 -0400 Subject: [PATCH 464/677] Release 1.80.0 --- CHANGELOG | 2 ++ lib/active_merchant/version.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 64f96ed2222..a63a94dd4d2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ = ActiveMerchant CHANGELOG == HEAD + +== Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 * Paymentez: return a Result object even when the upstream server 500s [bpollack] #2871 * Drop support for Ruby versions older than 2.3 [bpollack] #2863 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 46c298f78d8..b1883e4e5c3 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = '1.79.2' + VERSION = '1.80.0' end From 0c2cb7f21bfd225b47f2ae32ffcc224adccde631 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@bitquabit.com> Date: Wed, 4 Jul 2018 08:11:10 -0400 Subject: [PATCH 465/677] Prevent connections being made in unit tests The test introduced in 262b65c45bf9 was not properly stubbed, and would attempt to make connections. This fixes it. Unit: 3866 tests, 67888 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- test/unit/connection_test.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index 03261fcbf0c..564fea45f49 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -46,7 +46,9 @@ def test_connection_does_pass_requested_proxy def test_connection_does_not_mutate_headers_argument headers = { 'Content-Type' => 'text/xml' }.freeze - @connection.request(:get, nil, headers) + Net::HTTP.any_instance.expects(:get).with('/tx.php', headers.merge({'connection' => 'close'})).returns(@ok) + Net::HTTP.any_instance.expects(:start).returns(true) + response = @connection.request(:get, nil, headers) assert_equal({ 'Content-Type' => 'text/xml' }, headers) end From eb86d5eec73a40aa6d0ba037a59140113f48bb96 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@bitquabit.com> Date: Wed, 4 Jul 2018 08:04:55 -0400 Subject: [PATCH 466/677] Convert all YAML calls from .load to .safe_load .load can deserialize arbitrary Ruby classes. Currently, we only use YAML for fixtures and other patently safe purposes, but leaving them sets a bad precedent, and prevents us using RuboCop's security linter for YAML properly. Enable the linter and fix the usages. 3866 tests, 67884 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- .rubocop_todo.yml | 9 --------- generators/gateway/gateway_generator.rb | 2 +- test/test_helper.rb | 2 +- test/unit/fixtures_test.rb | 2 +- test/unit/gateways/firstdata_e4_test.rb | 4 ++-- test/unit/gateways/payeezy_test.rb | 14 +++++++------- 6 files changed, 12 insertions(+), 21 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f00fcb20eb8..2a376ba8a24 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -860,15 +860,6 @@ Performance/StringReplacement: - 'lib/active_merchant/billing/gateways/realex.rb' - 'test/unit/gateways/nab_transact_test.rb' -# Offense count: 11 -# Cop supports --auto-correct. -Security/YAMLLoad: - Exclude: - - 'test/test_helper.rb' - - 'test/unit/fixtures_test.rb' - - 'test/unit/gateways/firstdata_e4_test.rb' - - 'test/unit/gateways/payeezy_test.rb' - # Offense count: 2 # Configuration parameters: EnforcedStyle. # SupportedStyles: inline, group diff --git a/generators/gateway/gateway_generator.rb b/generators/gateway/gateway_generator.rb index d20ad21343c..febddbb1c7e 100644 --- a/generators/gateway/gateway_generator.rb +++ b/generators/gateway/gateway_generator.rb @@ -38,7 +38,7 @@ def fixtures_file end def next_identifier - fixtures = (YAML.load(File.read(fixtures_file)).keys + [identifier]).uniq.sort + fixtures = (YAML.safe_load(File.read(fixtures_file)).keys + [identifier], [], [], true).uniq.sort fixtures[fixtures.sort.index(identifier)+1] end end diff --git a/test/test_helper.rb b/test/test_helper.rb index e26efecf87d..1f1159493c5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -261,7 +261,7 @@ def fixtures(key) def load_fixtures [DEFAULT_CREDENTIALS, LOCAL_CREDENTIALS].inject({}) do |credentials, file_name| if File.exist?(file_name) - yaml_data = YAML.load(File.read(file_name)) + yaml_data = YAML.safe_load(File.read(file_name), [], [], true) credentials.merge!(symbolize_keys(yaml_data)) end credentials diff --git a/test/unit/fixtures_test.rb b/test/unit/fixtures_test.rb index 5f5baa93eb0..b72720d928c 100644 --- a/test/unit/fixtures_test.rb +++ b/test/unit/fixtures_test.rb @@ -2,7 +2,7 @@ class FixturesTest < Test::Unit::TestCase def test_sort - keys = YAML.load(File.read(ActiveMerchant::Fixtures::DEFAULT_CREDENTIALS)).keys + keys = YAML.safe_load(File.read(ActiveMerchant::Fixtures::DEFAULT_CREDENTIALS), [], [], true).keys assert_equal( keys, keys.sort diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb index eb01abdebbd..e7e6e6c9fc4 100755 --- a/test/unit/gateways/firstdata_e4_test.rb +++ b/test/unit/gateways/firstdata_e4_test.rb @@ -1037,7 +1037,7 @@ def no_transaction_response read: true socket: RESPONSE - YAML.load(yamlexcep) + YAML.safe_load(yamlexcep, ['Net::HTTPBadRequest', 'ActiveMerchant::ResponseError']) end def bad_credentials_response @@ -1074,7 +1074,7 @@ def bad_credentials_response http_version: '1.1' socket: RESPONSE - YAML.load(yamlexcep) + YAML.safe_load(yamlexcep, ['Net::HTTPUnauthorized', 'ActiveMerchant::ResponseError']) end def successful_void_response diff --git a/test/unit/gateways/payeezy_test.rb b/test/unit/gateways/payeezy_test.rb index 08319f927f4..87c61922b34 100644 --- a/test/unit/gateways/payeezy_test.rb +++ b/test/unit/gateways/payeezy_test.rb @@ -511,7 +511,7 @@ def failed_purchase_response body_exist: true message: RESPONSE - YAML.load(yamlexcep) + YAML.safe_load(yamlexcep, ['Net::HTTPBadRequest', 'ActiveMerchant::ResponseError']) end def successful_authorize_response @@ -586,7 +586,7 @@ def failed_refund_response body_exist: true message: RESPONSE - YAML.load(yamlexcep) + YAML.safe_load(yamlexcep, ['Net::HTTPBadRequest', 'ActiveMerchant::ResponseError']) end def successful_void_response @@ -631,7 +631,7 @@ def failed_void_response body_exist: true message: RESPONSE - YAML.load(yamlexcep) + YAML.safe_load(yamlexcep, ['Net::HTTPBadRequest', 'ActiveMerchant::ResponseError']) end def failed_capture_response @@ -671,7 +671,7 @@ def failed_capture_response body_exist: true message: RESPONSE - YAML.load(yamlexcep) + YAML.safe_load(yamlexcep, ['Net::HTTPBadRequest', 'ActiveMerchant::ResponseError']) end def invalid_token_response @@ -710,7 +710,7 @@ def invalid_token_response body_exist: true message: RESPONSE - YAML.load(yamlexcep) + YAML.safe_load(yamlexcep, ['Net::HTTPUnauthorized', 'ActiveMerchant::ResponseError']) end def invalid_token_response_integration @@ -735,7 +735,7 @@ def invalid_token_response_integration body_exist: true message: RESPONSE - YAML.load(yamlexcep) + YAML.safe_load(yamlexcep, ['Net::HTTPUnauthorized', 'ActiveMerchant::ResponseError']) end def bad_credentials_response @@ -760,6 +760,6 @@ def bad_credentials_response body_exist: true message: RESPONSE - YAML.load(yamlexcep) + YAML.safe_load(yamlexcep, ['Net::HTTPForbidden', 'ActiveMerchant::ResponseError']) end end From b10bee7956d3b66fdd5f92718004df26b32c31b9 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Thu, 5 Jul 2018 15:04:30 -0400 Subject: [PATCH 467/677] GlobalCollect: Don't overwrite contactDetails Previously, if there was an address provided, it would overwrite the contactDeatails field which may have already had an email field added. Now we have a conditional for both email and phone number elements within contactDetails. Also updates the sandbox url to the current endpoint. Closes #2915 Remote: 16 tests, 37 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 17 tests, 79 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/global_collect.rb | 18 +++++++----------- .../gateways/remote_global_collect_test.rb | 3 ++- test/unit/gateways/global_collect_test.rb | 3 +++ 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a63a94dd4d2..868e36b876f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 3f37eb85177..1152f495e56 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -4,7 +4,7 @@ class GlobalCollectGateway < Gateway self.display_name = 'GlobalCollect' self.homepage_url = 'http://www.globalcollect.com/' - self.test_url = 'https://api-sandbox.globalcollect.com/' + self.test_url = 'https://eu.sandbox.api-ingenico.com/' self.live_url = 'https://api.globalcollect.com/' self.supported_countries = ['AD', 'AE', 'AG', 'AI', 'AL', 'AM', 'AO', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PL', 'PN', 'PS', 'PT', 'PW', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SR', 'ST', 'SV', 'SZ', 'TC', 'TD', 'TG', 'TH', 'TJ', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'US', 'UY', 'UZ', 'VC', 'VE', 'VG', 'VI', 'VN', 'WF', 'WS', 'ZA', 'ZM', 'ZW'] @@ -154,13 +154,9 @@ def add_customer_data(post, options, payment = nil) post['order']['companyInformation'] = { 'name' => options[:company] } - post['order']['contactDetails'] = { - 'emailAddress' => options[:email] - } + post['order']['contactDetails']['emailAddress'] = options[:email] if options[:email] if address = options[:billing_address] || options[:address] - post['order']['contactDetails'] = { - 'phoneNumber' => address[:phone] - } + post['order']['contactDetails']['phoneNumber'] = address[:phone] if address[:phone] end end @@ -169,10 +165,10 @@ def add_refund_customer_data(post, options) post['customer']['address'] = { 'countryCode' => address[:country] } - post['customer']['contactDetails'] = { - 'emailAddress' => options[:email], - 'phoneNumber' => address[:phone] - } + post['customer']['contactDetails']['emailAddress'] = options[:email] if options[:email] + if address = options[:billing_address] || options[:address] + post['customer']['contactDetails']['phoneNumber'] = address[:phone] if address[:phone] + end end end diff --git a/test/remote/gateways/remote_global_collect_test.rb b/test/remote/gateways/remote_global_collect_test.rb index b04a60ae53a..519db653470 100644 --- a/test/remote/gateways/remote_global_collect_test.rb +++ b/test/remote/gateways/remote_global_collect_test.rb @@ -10,6 +10,7 @@ def setup @accepted_amount = 4005 @rejected_amount = 2997 @options = { + email: 'example@example.com', billing_address: address, description: 'Store Purchase' } @@ -153,7 +154,7 @@ def test_invalid_login response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_match %r{MISSING_OR_INVALID_AUTHORIZATION}, response.message + assert_match %r{UNKNOWN_SERVER_ERROR}, response.message end def test_transcript_scrubbing diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb index d7c9a81801b..605e1aa0563 100644 --- a/test/unit/gateways/global_collect_test.rb +++ b/test/unit/gateways/global_collect_test.rb @@ -68,6 +68,7 @@ def test_authorize_without_pre_authorization_flag def test_successful_authorization_with_extra_options options = @options.merge( { + email: 'example@example.com', order_id: '123', ip: '127.0.0.1', fraud_fields: @@ -83,6 +84,8 @@ def test_successful_authorization_with_extra_options end.check_request do |endpoint, data, headers| assert_match %r("fraudFields":{"website":"www.example.com","giftMessage":"Happy Day!","customerIpAddress":"127.0.0.1"}), data assert_match %r("merchantReference":"123"), data + assert_match %r("emailAddress":"example@example.com"), data + assert_match %r("phoneNumber":"\(555\)555-5555"), data end.respond_with(successful_authorize_response) assert_success response From 371b07613a8b154b18123ed245fa4eaed74a1760 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 6 Jul 2018 12:52:38 -0400 Subject: [PATCH 468/677] Set RuboCop to require: false It makes zero sense to auto-require RuboCop, since we never use it as a library at any point. --- Gemfile | 2 +- Gemfile.rails42 | 2 +- Gemfile.rails50 | 2 +- Gemfile.rails51 | 2 +- Gemfile.rails52 | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 2c314a40873..6e287b04095 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' gemspec gem 'jruby-openssl', :platforms => :jruby -gem 'rubocop', '~> 0.57.2' +gem 'rubocop', '~> 0.57.2', require: false group :test, :remote_test do # gateway-specific dependencies, keeping these gems out of the gemspec diff --git a/Gemfile.rails42 b/Gemfile.rails42 index 98b0dd0c7a4..890b340923a 100644 --- a/Gemfile.rails42 +++ b/Gemfile.rails42 @@ -2,7 +2,7 @@ source 'https://rubygems.org' gemspec gem 'jruby-openssl', :platforms => :jruby -gem 'rubocop', '~> 0.57.2' +gem 'rubocop', '~> 0.57.2', require: false group :test, :remote_test do # gateway-specific dependencies, keeping these gems out of the gemspec diff --git a/Gemfile.rails50 b/Gemfile.rails50 index cfe7103ac08..c014f53a18e 100644 --- a/Gemfile.rails50 +++ b/Gemfile.rails50 @@ -2,7 +2,7 @@ source 'https://rubygems.org' gemspec gem 'jruby-openssl', :platforms => :jruby -gem 'rubocop', '~> 0.57.2' +gem 'rubocop', '~> 0.57.2', require: false group :test, :remote_test do # gateway-specific dependencies, keeping these gems out of the gemspec diff --git a/Gemfile.rails51 b/Gemfile.rails51 index 4bbed6e8884..c83abf0b54b 100644 --- a/Gemfile.rails51 +++ b/Gemfile.rails51 @@ -2,7 +2,7 @@ source 'https://rubygems.org' gemspec gem 'jruby-openssl', :platforms => :jruby -gem 'rubocop', '~> 0.57.2' +gem 'rubocop', '~> 0.57.2', require: false group :test, :remote_test do # gateway-specific dependencies, keeping these gems out of the gemspec diff --git a/Gemfile.rails52 b/Gemfile.rails52 index e76569231cf..cf1a88c3011 100644 --- a/Gemfile.rails52 +++ b/Gemfile.rails52 @@ -2,7 +2,7 @@ source 'https://rubygems.org' gemspec gem 'jruby-openssl', :platforms => :jruby -gem 'rubocop', '~> 0.57.2' +gem 'rubocop', '~> 0.57.2', require: false group :test, :remote_test do # gateway-specific dependencies, keeping these gems out of the gemspec From 89e446357c19d66477b7e4ab39a269d94c2f46ef Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Fri, 6 Jul 2018 16:26:58 -0400 Subject: [PATCH 469/677] Pin Payments: Pass reference for statement desc This passes an undocumented field that is used to specify a descriptor that appears on the customer's statement. Closes #2919 Remote: 16 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 37 tests, 112 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/pin.rb | 1 + test/remote/gateways/remote_pin_test.rb | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 868e36b876f..c7d7091e4a2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 +* Pin Payments: Pass reference for statement desc [curiousepic] #2919 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/pin.rb b/lib/active_merchant/billing/gateways/pin.rb index 7b364e2eaea..3d8af8a56b1 100644 --- a/lib/active_merchant/billing/gateways/pin.rb +++ b/lib/active_merchant/billing/gateways/pin.rb @@ -114,6 +114,7 @@ def add_address(post, creditcard, options) def add_invoice(post, options) post[:description] = options[:description] || 'Active Merchant Purchase' + post[:reference] = options[:reference] if options[:reference] end def add_capture(post, options) diff --git a/test/remote/gateways/remote_pin_test.rb b/test/remote/gateways/remote_pin_test.rb index 010830cf89b..e9851eacdf6 100644 --- a/test/remote/gateways/remote_pin_test.rb +++ b/test/remote/gateways/remote_pin_test.rb @@ -38,6 +38,11 @@ def test_successful_purchase_with_metadata assert_equal options_with_metadata[:metadata][:purchase_number], response.params['response']['metadata']['purchase_number'] end + def test_successful_purchase_with_reference + response = @gateway.purchase(@amount, @credit_card, @options.merge(reference: 'statement descriptor')) + assert_success response + end + def test_successful_authorize_and_capture authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization From 4cd2a2ef6e98c94d396ad7fa48dbffa3b75a5e5e Mon Sep 17 00:00:00 2001 From: Sanjay Chakrapani <sanjay@spreedly.com> Date: Wed, 4 Jul 2018 00:08:35 +0530 Subject: [PATCH 470/677] Firstdata E4 (GGE4) v27: Add new gateway v27 diverges significantly from existing firstdata_e4 (v11) in terms of additional credentials for HMAC and multiple field changes including address & cvv fields. Unit: 29 tests, 136 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 23 tests, 92 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #2912 --- CHANGELOG | 1 + .../billing/gateways/firstdata_e4_v27.rb | 444 ++++++++ test/fixtures.yml | 6 + .../gateways/remote_firstdata_e4_v27_test.rb | 222 ++++ test/schema/firstdata_e4/v27.xsd | 223 ++++ test/unit/gateways/firstdata_e4_v27_test.rb | 979 ++++++++++++++++++ 6 files changed, 1875 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/firstdata_e4_v27.rb create mode 100644 test/remote/gateways/remote_firstdata_e4_v27_test.rb create mode 100644 test/schema/firstdata_e4/v27.xsd create mode 100644 test/unit/gateways/firstdata_e4_v27_test.rb diff --git a/CHANGELOG b/CHANGELOG index c7d7091e4a2..ef8d131a9d0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 * Pin Payments: Pass reference for statement desc [curiousepic] #2919 +* FirstData: introduce v27 gateway [shasum] #2912 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb new file mode 100644 index 00000000000..9bdd77d9b62 --- /dev/null +++ b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb @@ -0,0 +1,444 @@ +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class FirstdataE4V27Gateway < Gateway + self.test_url = 'https://api.demo.globalgatewaye4.firstdata.com/transaction/v27' + self.live_url = 'https://api.globalgatewaye4.firstdata.com/transaction/v27' + + TRANSACTIONS = { + sale: '00', + authorization: '01', + verify: '05', + capture: '32', + void: '33', + credit: '34', + store: '05' + } + + SUCCESS = 'true' + + SENSITIVE_FIELDS = [:cvdcode, :expiry_date, :card_number] + + BRANDS = { + :visa => 'Visa', + :master => 'Mastercard', + :american_express => 'American Express', + :jcb => 'JCB', + :discover => 'Discover' + } + + DEFAULT_ECI = '07' + + self.supported_cardtypes = BRANDS.keys + self.supported_countries = ['CA', 'US'] + self.default_currency = 'USD' + self.homepage_url = 'http://www.firstdata.com' + self.display_name = 'FirstData Global Gateway e4 v27' + + STANDARD_ERROR_CODE_MAPPING = { + # Bank error codes: https://support.payeezy.com/hc/en-us/articles/203730509-First-Data-Global-Gateway-e4-Bank-Response-Codes + '201' => STANDARD_ERROR_CODE[:incorrect_number], + '531' => STANDARD_ERROR_CODE[:invalid_cvc], + '503' => STANDARD_ERROR_CODE[:invalid_cvc], + '811' => STANDARD_ERROR_CODE[:invalid_cvc], + '605' => STANDARD_ERROR_CODE[:invalid_expiry_date], + '522' => STANDARD_ERROR_CODE[:expired_card], + '303' => STANDARD_ERROR_CODE[:card_declined], + '530' => STANDARD_ERROR_CODE[:card_declined], + '401' => STANDARD_ERROR_CODE[:call_issuer], + '402' => STANDARD_ERROR_CODE[:call_issuer], + '501' => STANDARD_ERROR_CODE[:pickup_card], + # Ecommerce error codes: https://support.payeezy.com/hc/en-us/articles/203730499-eCommerce-Response-Codes-ETG-e4-Transaction-Gateway-Codes + '22' => STANDARD_ERROR_CODE[:invalid_number], + '25' => STANDARD_ERROR_CODE[:invalid_expiry_date], + '31' => STANDARD_ERROR_CODE[:incorrect_cvc], + '44' => STANDARD_ERROR_CODE[:incorrect_zip], + '42' => STANDARD_ERROR_CODE[:processing_error] + } + + def initialize(options = {}) + requires!(options, :login, :password, :key_id, :hmac_key) + @options = options + + super + end + + def authorize(money, credit_card_or_store_authorization, options = {}) + commit(:authorization, build_sale_or_authorization_request(money, credit_card_or_store_authorization, options)) + end + + def purchase(money, credit_card_or_store_authorization, options = {}) + commit(:sale, build_sale_or_authorization_request(money, credit_card_or_store_authorization, options)) + end + + def capture(money, authorization, options = {}) + commit(:capture, build_capture_or_credit_request(money, authorization, options)) + end + + def void(authorization, options = {}) + commit(:void, build_capture_or_credit_request(money_from_authorization(authorization), authorization, options)) + end + + def refund(money, authorization, options = {}) + commit(:credit, build_capture_or_credit_request(money, authorization, options)) + end + + def verify(credit_card, options = {}) + commit(:verify, build_sale_or_authorization_request(0, credit_card, options)) + end + + # Tokenize a credit card with TransArmor + # + # The TransArmor token and other card data necessary for subsequent + # transactions is stored in the response's +authorization+ attribute. + # The authorization string may be passed to +authorize+ and +purchase+ + # instead of a +ActiveMerchant::Billing::CreditCard+ instance. + # + # TransArmor support must be explicitly activated on your gateway + # account by FirstData. If your authorization string is empty, contact + # FirstData support for account setup assistance. + # + # https://support.payeezy.com/hc/en-us/articles/203731189-TransArmor-Tokenization + def store(credit_card, options = {}) + commit(:store, build_store_request(credit_card, options), credit_card) + end + + def verify_credentials + response = void('0') + response.message != 'Unauthorized Request. Bad or missing credentials.' + end + + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript + .gsub(%r((<Card_Number>).+(</Card_Number>)), '\1[FILTERED]\2') + .gsub(%r((<CVDCode>).+(</CVDCode>)), '\1[FILTERED]\2') + .gsub(%r((<Password>).+(</Password>))i, '\1[FILTERED]\2') + .gsub(%r((<CAVV>).+(</CAVV>)), '\1[FILTERED]\2') + .gsub(%r((CARD NUMBER\s+: )#+\d+), '\1[FILTERED]') + end + + def supports_network_tokenization? + true + end + + private + + def build_request(action, body) + xml = Builder::XmlMarkup.new + + xml.instruct! + xml.tag! 'Transaction', xmlns: 'http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes' do + add_credentials(xml) + add_transaction_type(xml, action) + xml << body + end + + xml.target! + end + + def build_sale_or_authorization_request(money, credit_card_or_store_authorization, options) + xml = Builder::XmlMarkup.new + + add_amount(xml, money, options) + + if credit_card_or_store_authorization.is_a? String + add_credit_card_token(xml, credit_card_or_store_authorization, options) + else + add_credit_card(xml, credit_card_or_store_authorization, options) + end + + add_address(xml, options) + add_customer_data(xml, options) + add_invoice(xml, options) + add_tax_fields(xml, options) + add_level_3(xml, options) + + xml.target! + end + + def build_capture_or_credit_request(money, identification, options) + xml = Builder::XmlMarkup.new + + add_identification(xml, identification) + add_amount(xml, money, options) + add_customer_data(xml, options) + add_card_authentication_data(xml, options) + + xml.target! + end + + def build_store_request(credit_card, options) + xml = Builder::XmlMarkup.new + + add_credit_card(xml, credit_card, options) + add_address(xml, options) + add_customer_data(xml, options) + + xml.target! + end + + def add_credentials(xml) + xml.tag! 'ExactID', @options[:login] + xml.tag! 'Password', @options[:password] + end + + def add_transaction_type(xml, action) + xml.tag! 'Transaction_Type', TRANSACTIONS[action] + end + + def add_identification(xml, identification) + authorization_num, transaction_tag, _ = identification.split(';') + + xml.tag! 'Authorization_Num', authorization_num + xml.tag! 'Transaction_Tag', transaction_tag + end + + def add_amount(xml, money, options) + currency_code = options[:currency] || default_currency + xml.tag! 'DollarAmount', localized_amount(money, currency_code) + xml.tag! 'Currency', currency_code + end + + def add_credit_card(xml, credit_card, options) + if credit_card.respond_to?(:track_data) && credit_card.track_data.present? + xml.tag! 'Track1', credit_card.track_data + xml.tag! 'Ecommerce_Flag', 'R' + else + xml.tag! 'Card_Number', credit_card.number + xml.tag! 'Expiry_Date', expdate(credit_card) + xml.tag! 'CardHoldersName', credit_card.name + xml.tag! 'CardType', card_type(credit_card.brand) + + add_credit_card_eci(xml, credit_card, options) + add_credit_card_verification_strings(xml, credit_card, options) + end + end + + def add_credit_card_eci(xml, credit_card, options) + eci = if credit_card.is_a?(NetworkTokenizationCreditCard) && credit_card.source == :apple_pay && card_brand(credit_card) == 'discover' + # Discover requires any Apple Pay transaction, regardless of in-app + # or web, and regardless of the ECI contained in the PKPaymentToken, + # to have an ECI value explicitly of 04. + '04' + else + (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI + end + + xml.tag! 'Ecommerce_Flag', eci.to_s =~ /^[0-9]+$/ ? eci.to_s.rjust(2, '0') : eci + end + + def add_credit_card_verification_strings(xml, credit_card, options) + if credit_card.is_a?(NetworkTokenizationCreditCard) + add_network_tokenization_credit_card(xml, credit_card) + else + if credit_card.verification_value? + xml.tag! 'CVD_Presence_Ind', '1' + xml.tag! 'CVDCode', credit_card.verification_value + end + + add_card_authentication_data(xml, options) + end + end + + def add_network_tokenization_credit_card(xml, credit_card) + case card_brand(credit_card).to_sym + when :american_express + cryptogram = Base64.decode64(credit_card.payment_cryptogram) + xml.tag!('XID', Base64.encode64(cryptogram[20...40])) + xml.tag!('CAVV', Base64.encode64(cryptogram[0...20])) + else + xml.tag!('XID', credit_card.transaction_id) if credit_card.transaction_id + xml.tag!('CAVV', credit_card.payment_cryptogram) + end + end + + def add_card_authentication_data(xml, options) + xml.tag! 'CAVV', options[:cavv] + xml.tag! 'XID', options[:xid] + end + + def add_credit_card_token(xml, store_authorization, options) + params = store_authorization.split(';') + credit_card = CreditCard.new( + :brand => params[1], + :first_name => params[2], + :last_name => params[3], + :month => params[4], + :year => params[5]) + + xml.tag! 'TransarmorToken', params[0] + xml.tag! 'Expiry_Date', expdate(credit_card) + xml.tag! 'CardHoldersName', credit_card.name + xml.tag! 'CardType', card_type(credit_card.brand) + add_card_authentication_data(xml, options) + end + + def add_customer_data(xml, options) + xml.tag! 'Customer_Ref', options[:customer] if options[:customer] + xml.tag! 'Client_IP', options[:ip] if options[:ip] + xml.tag! 'Client_Email', options[:email] if options[:email] + end + + def add_address(xml, options) + if (address = options[:billing_address] || options[:address]) + xml.tag! 'Address' do + xml.tag! 'Address1', address[:address1] + xml.tag! 'Address2', address[:address2] if address[:address2] + xml.tag! 'City', address[:city] + xml.tag! 'State', address[:state] + xml.tag! 'Zip', address[:zip] + xml.tag! 'CountryCode', address[:country] + end + xml.tag! 'ZipCode', address[:zip] + end + end + + def add_invoice(xml, options) + xml.tag! 'Reference_No', options[:order_id] + xml.tag! 'Reference_3', options[:description] if options[:description] + end + + def add_tax_fields(xml, options) + xml.tag! 'Tax1Amount', options[:tax1_amount] if options[:tax1_amount] + xml.tag! 'Tax1Number', options[:tax1_number] if options[:tax1_number] + end + + def add_level_3(xml, options) + xml.tag!('Level3') { |x| x << options[:level_3] } if options[:level_3] + end + + def expdate(credit_card) + "#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}" + end + + def card_type(credit_card_brand) + BRANDS[credit_card_brand.to_sym] if credit_card_brand + end + + def commit(action, data, credit_card = nil) + url = (test? ? self.test_url : self.live_url) + request = build_request(action, data) + begin + response = parse(ssl_post(url, request, headers('POST', url, request))) + rescue ResponseError => e + response = parse_error(e.response) + end + + Response.new(successful?(response), message_from(response), response, + :test => test?, + :authorization => successful?(response) ? response_authorization(action, response, credit_card) : '', + :avs_result => {:code => response[:avs]}, + :cvv_result => response[:cvv2], + :error_code => standard_error_code(response) + ) + end + + def headers(method, url, request) + content_type = 'application/xml' + content_digest = Digest::SHA1.hexdigest(request) + sending_time = Time.now.utc.iso8601 + payload = [method, content_type, content_digest, sending_time, url.split('.com')[1]].join("\n") + hmac = OpenSSL::HMAC.digest('sha1', @options[:hmac_key], payload) + encoded = Base64.strict_encode64(hmac) + + { + 'x-gge4-date' => sending_time, + 'x-gge4-content-sha1' => content_digest, + 'Authorization' => 'GGE4_API ' + @options[:key_id].to_s + ':' + encoded, + 'Accepts' => content_type, + 'Content-Type' => content_type + } + end + + def successful?(response) + response[:transaction_approved] == SUCCESS + end + + def response_authorization(action, response, credit_card) + if action == :store + store_authorization_from(response, credit_card) + else + authorization_from(response) + end + end + + def authorization_from(response) + if response[:authorization_num] && response[:transaction_tag] + [ + response[:authorization_num], + response[:transaction_tag], + (response[:dollar_amount].to_f * 100).round + ].join(';') + else + '' + end + end + + def store_authorization_from(response, credit_card) + if response[:transarmor_token].present? + [ + response[:transarmor_token], + credit_card.brand, + credit_card.first_name, + credit_card.last_name, + credit_card.month, + credit_card.year + ].map { |value| value.to_s.tr(';', '') }.join(';') + else + raise StandardError, "TransArmor support is not enabled on your #{display_name} account" + end + end + + def money_from_authorization(auth) + _, _, amount = auth.split(/;/, 3) + amount.to_i + end + + def message_from(response) + if(response[:faultcode] && response[:faultstring]) + response[:faultstring] + elsif(response[:error_number] && response[:error_number] != '0') + response[:error_description] + else + result = (response[:exact_message] || '') + result << " - #{response[:bank_message]}" if response[:bank_message].present? + result + end + end + + def parse_error(error) + { + :transaction_approved => 'false', + :error_number => error.code, + :error_description => error.body, + :ecommerce_error_code => error.body.gsub(/[^\d]/, '') + } + end + + def standard_error_code(response) + STANDARD_ERROR_CODE_MAPPING[response[:bank_resp_code] || response[:ecommerce_error_code]] + end + + def parse(xml) + response = {} + xml = REXML::Document.new(xml) + + if (root = REXML::XPath.first(xml, '//TransactionResult')) + parse_elements(response, root) + end + + SENSITIVE_FIELDS.each { |key| response.delete(key) } + response + end + + def parse_elements(response, root) + root.elements.to_a.each do |node| + response[node.name.gsub(/EXact/, 'Exact').underscore.to_sym] = (node.text || '').strip + end + end + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index c14a40480aa..99d218d55eb 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -331,6 +331,12 @@ firstdata_e4: login: SD8821-67 password: T6bxSywbcccbJ19eDXNIGaCDOBg1W7T8 +firstdata_e4_v27: + login: ALOGIN + password: APASSWORD + key_id: ANINTEGER + hmac_key: AMAGICALKEY + flo2cash: username: SOMECREDENTIAL password: ANOTHERCREDENTIAL diff --git a/test/remote/gateways/remote_firstdata_e4_v27_test.rb b/test/remote/gateways/remote_firstdata_e4_v27_test.rb new file mode 100644 index 00000000000..464f8d87f56 --- /dev/null +++ b/test/remote/gateways/remote_firstdata_e4_v27_test.rb @@ -0,0 +1,222 @@ +require 'test_helper' + +class RemoteFirstdataE4V27Test < Test::Unit::TestCase + def setup + @gateway = FirstdataE4V27Gateway.new(fixtures(:firstdata_e4_v27)) + @credit_card = credit_card + @bad_credit_card = credit_card('4111111111111113') + @credit_card_with_track_data = credit_card_with_track_data('4003000123456781') + @amount = 100 + @options = { + :order_id => '1', + :billing_address => address, + :description => 'Store Purchase' + } + @options_with_authentication_data = @options.merge({ + eci: '5', + cavv: 'TESTCAVV', + xid: 'TESTXID' + }) + end + + def test_successful_purchase + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_match(/Transaction Normal/, response.message) + assert_success response + end + + def test_successful_purchase_with_network_tokenization + @credit_card = network_tokenization_credit_card('4242424242424242', + payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', + verification_value: nil + ) + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Transaction Normal - Approved', response.message + assert_false response.authorization.blank? + end + + def test_successful_purchase_with_track_data + assert response = @gateway.purchase(@amount, @credit_card_with_track_data, @options) + assert_match(/Transaction Normal/, response.message) + assert_success response + end + + def test_successful_purchase_with_level_3 + level_3_xml = <<-LEVEL3 + <LineItem> + <LineItemTotal>107.20</LineItemTotal> + <Quantity>3</Quantity> + <Description>The Description</Description> + <UnitCost>2.33</UnitCost> + </LineItem> + LEVEL3 + + response = @gateway.purchase(500, @credit_card, @options.merge(level_3: level_3_xml)) + assert_success response + assert_equal 'Transaction Normal - Approved', response.message + end + + def test_successful_purchase_with_tax_fields + response = @gateway.purchase(500, @credit_card, @options.merge(tax1_amount: 50, tax1_number: 'A458')) + assert_success response + assert_equal '50.0', response.params['tax1_amount'] + assert_equal '', response.params['tax1_number'], 'E4 blanks this out in the response' + end + + def test_successful_purchase_with_customer_ref + response = @gateway.purchase(500, @credit_card, @options.merge(customer: '267')) + assert_success response + assert_equal '267', response.params['customer_ref'] + end + + def test_successful_purchase_with_card_authentication + assert response = @gateway.purchase(@amount, @credit_card, @options_with_authentication_data) + assert_equal response.params['cavv'], @options_with_authentication_data[:cavv] + assert_equal response.params['ecommerce_flag'], @options_with_authentication_data[:eci] + assert_equal response.params['xid'], @options_with_authentication_data[:xid] + assert_success response + end + + def test_unsuccessful_purchase + # ask for error 13 response (Amount Error) via dollar amount 5,000 + error + @amount = 501300 + assert response = @gateway.purchase(@amount, @credit_card, @options ) + assert_match(/Transaction Normal/, response.message) + assert_failure response + end + + def test_bad_creditcard_number + assert response = @gateway.purchase(@amount, @bad_credit_card, @options) + assert_match(/Invalid Credit Card/, response.message) + assert_failure response + assert_equal response.error_code, 'invalid_number' + end + + def test_trans_error + # ask for error 42 (unable to send trans) as the cents bit... + @amount = 500042 + assert response = @gateway.purchase(@amount, @credit_card, @options ) + assert_match(/Unable to Send Transaction/, response.message) # 42 is 'unable to send trans' + assert_failure response + assert_equal response.error_code, 'processing_error' + end + + def test_purchase_and_credit + assert purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + assert purchase.authorization + assert credit = @gateway.refund(@amount, purchase.authorization) + assert_success credit + end + + def test_purchase_and_void + assert purchase = @gateway.purchase(29234, @credit_card, @options) + assert_success purchase + + assert purchase.authorization + assert void = @gateway.void(purchase.authorization) + assert_success void + end + + def test_purchase_and_void_with_even_dollar_amount + assert purchase = @gateway.purchase(5000, @credit_card, @options) + assert_success purchase + + assert purchase.authorization + assert void = @gateway.void(purchase.authorization) + assert_success void + end + + def test_authorize_and_capture + assert auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + assert auth.authorization + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + end + + def test_failed_capture + assert response = @gateway.capture(@amount, 'ET838747474;frob') + assert_failure response + assert_match(/Invalid Authorization Number/i, response.message) + end + + def test_successful_verify + assert response = @gateway.verify(@credit_card, @options) + assert_success response + + assert_equal 'Transaction Normal - Approved', response.message + assert_equal '0.0', response.params['dollar_amount'] + assert_equal '05', response.params['transaction_type'] + end + + def test_failed_verify + assert response = @gateway.verify(@bad_credit_card, @options) + assert_failure response + assert_match %r{Invalid Credit Card Number}, response.message + assert_equal response.error_code, 'invalid_number' + end + + def test_invalid_login + gateway = FirstdataE4V27Gateway.new(:login => 'NotARealUser', + :password => 'NotARealPassword', + :key_id => 'NotARealKey', + :hmac_key => 'NotARealHMAC' ) + assert response = gateway.purchase(@amount, @credit_card, @options) + assert_match %r{Unauthorized Request}, response.message + assert_failure response + end + + def test_response_contains_cvv_and_avs_results + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'M', response.cvv_result['code'] + assert_equal '4', response.avs_result['code'] + end + + def test_refund + assert purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_match(/Transaction Normal/, purchase.message) + assert_success purchase + + assert response = @gateway.refund(50, purchase.authorization) + assert_success response + assert_match(/Transaction Normal/, response.message) + assert response.authorization + end + + def test_refund_with_track_data + assert purchase = @gateway.purchase(@amount, @credit_card_with_track_data, @options) + assert_match(/Transaction Normal/, purchase.message) + assert_success purchase + + assert response = @gateway.refund(50, purchase.authorization) + assert_success response + assert_match(/Transaction Normal/, response.message) + assert response.authorization + end + + def test_verify_credentials + assert @gateway.verify_credentials + + gateway = FirstdataE4V27Gateway.new(login: 'unknown', password: 'unknown', key_id: 'unknown', hmac_key: 'unknown') + assert !gateway.verify_credentials + gateway = FirstdataE4V27Gateway.new(login: fixtures(:firstdata_e4)[:login], password: 'unknown', key_id: 'unknown', hmac_key: 'unknown') + assert !gateway.verify_credentials + end + + def test_transcript_scrubbing + cc_with_different_cvc = credit_card(verification_value: '999') + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, cc_with_different_cvc, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(cc_with_different_cvc.number, transcript) + assert_scrubbed(cc_with_different_cvc.verification_value, transcript) + assert_scrubbed(@gateway.options[:password], transcript) + assert_scrubbed(@gateway.options[:hmac_key], transcript) + end + +end diff --git a/test/schema/firstdata_e4/v27.xsd b/test/schema/firstdata_e4/v27.xsd new file mode 100644 index 00000000000..775018838c6 --- /dev/null +++ b/test/schema/firstdata_e4/v27.xsd @@ -0,0 +1,223 @@ +<?xml version="1.0" encoding="utf-8"?> +<s:schema + elementFormDefault="qualified" + xmlns:s="http://www.w3.org/2001/XMLSchema" + xmlns:s0="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes" + xmlns="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes" + targetNamespace="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes"> + <s:complexType name="SoftDescriptor_Type"> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="DBAName" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Street" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="City" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Region" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="PostalCode" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="CountryCode" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="MID" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="MCC" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="MerchantContactInfo" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="MVV_MAID" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="AMEXMerchantPhone" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="AMEXMerchantEmail" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="PFacSubmerchantId" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="PFacName" type="s:string"/> + </s:sequence> + </s:complexType> + <s:complexType name="Level3_ShipToAddress_Type"> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="Address1" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="City" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="State" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Country" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="CustomerNumber" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Email" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Phone" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Zip" type="s:string"/> + </s:sequence> + </s:complexType> + <s:complexType name="Level3_LineItem_Type"> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="CommodityCode" type="s:string"/> + <s:element minOccurs="1" maxOccurs="1" name="Description" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="DiscountAmount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="DiscountIndicator" type="s:boolean"/> + <s:element minOccurs="0" maxOccurs="1" name="GrossNetIndicator" type="s:boolean"/> + <s:element minOccurs="1" maxOccurs="1" name="LineItemTotal" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="ProductCode" type="s:string"/> + <s:element minOccurs="1" maxOccurs="1" name="Quantity" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="TaxAmount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="TaxRate" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="TaxType" type="s:string"/> + <s:element minOccurs="1" maxOccurs="1" name="UnitCost" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="UnitOfMeasure" type="s:string"/> + </s:sequence> + </s:complexType> + <s:complexType name="Level3_Type"> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="TaxAmount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="TaxRate" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="AltTaxAmount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="AltTaxId" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="DutyAmount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="FreightAmount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="DiscountAmount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="ShipFromZip" type="s:string"/> + <s:element minOccurs="1" maxOccurs="1" name="ShipToAddress" type="Level3_ShipToAddress_Type"/> + <s:element minOccurs="1" maxOccurs="98" name="LineItem" type="Level3_LineItem_Type"/> + </s:sequence> + </s:complexType> + <s:complexType name="PaypalTransactionDetails"> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="PayerID" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="GrossAmountCurrencyID" type="s:string"/> + <s:element minOccurs="1" maxOccurs="1" name="Success" type="s:boolean"/> + <s:element minOccurs="0" maxOccurs="1" name="Authorization" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Message" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="CorrelationID" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Timestamp" type="s:string"/> + </s:sequence> + </s:complexType> + <s:complexType name="Address_Type"> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="Address1" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Address2" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="City" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="State" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Zip" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="CountryCode" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="PhoneNumber" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="PhoneType" type="s:string"/> + </s:sequence> + </s:complexType> + <s:complexType name="DynamicCurrency"> + <s:sequence> + <s:element minOccurs="1" maxOccurs="1" name="OptedIn" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="RateResponseSignature" type="s:string"/> + </s:sequence> + </s:complexType> + <s:complexType name="DynamicPricing"> + <s:sequence> + <s:element minOccurs="1" maxOccurs="1" name="OptedIn" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="RateResponseSignature" type="s:string"/> + </s:sequence> + </s:complexType> + <s:complexType name="ForeignCurrencyDetails"> + <s:sequence> + <s:element minOccurs="1" maxOccurs="1" name="DCCIndicator" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="ForeignAmount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="ForeignCurrencyCode" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="ExchangeRate" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="MarginRate" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="RateSource" type="s:string"/> + </s:sequence> + </s:complexType> + <s:complexType name="FraudDetectResult"> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="Score" type="s:integer"/> + <s:element minOccurs="0" maxOccurs="1" name="Recommendation" type="s:string"/> + <s:element minOccurs="0" maxOccurs="5" name="Explanation" type="FraudDetectExplanation_Type"/> + </s:sequence> + </s:complexType> + <s:complexType name="FraudDetectExplanation_Type"> + <s:sequence> + <s:element minOccurs="1" maxOccurs="1" name="type" type="s:integer"/> + <s:element minOccurs="1" maxOccurs="1" name="description" type="s:string"/> + </s:sequence> + </s:complexType> + <s:complexType name="VisaCheckout"> + <s:sequence> + <s:element minOccurs="1" maxOccurs="1" name="CallID" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="PromoCode" type="s:string"/> + </s:sequence> + </s:complexType> + <s:complexType name="MasterPass"> + <s:sequence> + <s:element minOccurs="1" maxOccurs="1" name="TransactionID" type="s:string"/> + <s:element minOccurs="1" maxOccurs="1" name="WalletID" type="s:string"/> + <s:element minOccurs="1" maxOccurs="1" name="Indicator" type="s:string"/> + </s:sequence> + </s:complexType> + <s:complexType name="Transaction"> + <s:all> + <s:element minOccurs="1" maxOccurs="1" name="ExactID" type="s:string"/> + <s:element minOccurs="1" maxOccurs="1" name="Password" type="s:string"/> + <s:element minOccurs="1" maxOccurs="1" name="Transaction_Type" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="DollarAmount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="SurchargeAmount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Card_Number" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Transaction_Tag" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="SplitTenderID" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Track1" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Track2" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="PAN" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Authorization_Num" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Expiry_Date" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="CardHoldersName" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="CVDCode" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="CVD_Presence_Ind" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="ZipCode" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Tax1Amount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Tax1Number" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Tax2Amount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Tax2Number" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Ecommerce_Flag" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="XID" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="CAVV" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Reference_No" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Customer_Ref" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Reference_3" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Language" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Client_IP" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Client_Email" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="User_Name" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Currency" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="PartialRedemption" type="s:boolean"/> + <s:element minOccurs="0" maxOccurs="1" name="Level3" type="Level3_Type"/> + <s:element minOccurs="0" maxOccurs="1" name="TransarmorToken" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="CardType" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="EAN" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="VirtualCard" type="s:boolean"/> + <s:element minOccurs="0" maxOccurs="1" name="CardCost" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="FraudSuspected" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="PaypalResponse" type="PaypalTransactionDetails"/> + <s:element minOccurs="0" maxOccurs="1" name="SoftDescriptor" type="SoftDescriptor_Type"/> + <s:element minOccurs="0" maxOccurs="1" name="Address" type="Address_Type"/> + <s:element minOccurs="0" maxOccurs="1" name="TPPID" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="SplitShipmentNumber" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="AmexFraud" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="DynamicCurrency" type="DynamicCurrency"/> + <s:element minOccurs="0" maxOccurs="1" name="DynamicPricing" type="DynamicPricing"/> + <s:element minOccurs="0" maxOccurs="1" name="FeeAmount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="VisaCheckout" type="VisaCheckout"/> + <s:element minOccurs="0" maxOccurs="1" name="PostDate" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="OtherAmount" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="GiftDepositAvailable" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="SpecialPayment" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="WalletProviderID" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="MasterPass" type="MasterPass"/> + <s:element minOccurs="0" maxOccurs="1" name="FraudDetectInAuthTransId" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="SCV" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="StoredCredentials" type="StoredCredentialsType"/> + <s:element minOccurs="0" maxOccurs="1" name="Extra" type="Extra_Type"/> + </s:all> + </s:complexType> + <s:complexType name="StoredCredentialsType"> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="AuthorizationTypeOverride" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Initiation" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Indicator" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="Schedule" type="s:string"/> + <s:element minOccurs="0" maxOccurs="1" name="TransactionId" type="s:string"/> + </s:sequence> + </s:complexType> + <s:complexType name="Extra_Type"> + <s:sequence> + <s:element minOccurs="1" maxOccurs="1" name="Field" type="s:string"/> + <s:element minOccurs="1" maxOccurs="1" name="Value" type="s:string"/> + </s:sequence> + </s:complexType> + + <s:element name="Transaction" type="s0:Transaction"/> + +</s:schema> diff --git a/test/unit/gateways/firstdata_e4_v27_test.rb b/test/unit/gateways/firstdata_e4_v27_test.rb new file mode 100644 index 00000000000..ed4e9c45512 --- /dev/null +++ b/test/unit/gateways/firstdata_e4_v27_test.rb @@ -0,0 +1,979 @@ +require 'test_helper' +require 'nokogiri' +require 'yaml' + +class FirstdataE4V27Test < Test::Unit::TestCase + include CommStub + + def setup + @gateway = FirstdataE4V27Gateway.new( + :login => 'A00427-01', + :password => 'testus', + :key_id => '12345', + :hmac_key => 'hexkey' + ) + + @credit_card = credit_card + @amount = 100 + @options = { + :order_id => '1', + :billing_address => address, + :description => 'Store Purchase' + } + @authorization = 'ET1700;106625152;4738' + end + + def test_invalid_credentials + @gateway.expects(:ssl_post).raises(bad_credentials_response) + assert response = @gateway.store(@credit_card, {}) + assert_failure response + assert response.test? + assert_equal '', response.authorization + assert_equal 'Unauthorized Request. Bad or missing credentials.', response.message + end + + def test_successful_purchase + @gateway.expects(:ssl_post).returns(successful_purchase_response) + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'ET1700;106625152;4738', response.authorization + assert response.test? + assert_equal 'Transaction Normal - Approved', response.message + + FirstdataE4V27Gateway::SENSITIVE_FIELDS.each{|f| assert !response.params.has_key?(f.to_s)} + end + + def test_successful_purchase_with_token + @gateway.expects(:ssl_post).returns(successful_purchase_response) + assert response = @gateway.purchase(@amount, '8938737759041111;visa;Longbob;Longsen;9;2014') + assert_success response + end + + def test_successful_void + @gateway.expects(:ssl_post).returns(successful_void_response) + assert response = @gateway.void(@authorization, @options) + assert_success response + end + + def test_successful_refund + @gateway.expects(:ssl_post).returns(successful_refund_response) + assert response = @gateway.refund(@amount, @authorization) + assert_success response + end + + def test_successful_store + @gateway.expects(:ssl_post).returns(successful_purchase_response) + assert response = @gateway.store(@credit_card, @options) + assert_success response + assert_equal '8938737759041111', response.params['transarmor_token'] + assert_equal "8938737759041111;visa;Longbob;Longsen;9;#{@credit_card.year}", response.authorization + end + + def test_failed_store_without_transarmor_support + @gateway.expects(:ssl_post).returns(successful_purchase_response_without_transarmor) + assert_raise StandardError do + @gateway.store(@credit_card, @options) + end + end + + def test_failed_purchase + @gateway.expects(:ssl_post).returns(failed_purchase_response) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_instance_of Response, response + assert_failure response + assert_equal response.error_code, 'invalid_expiry_date' + end + + def test_successful_verify + response = stub_comms do + @gateway.verify(@credit_card) + end.respond_with(successful_verify_response) + assert_success response + end + + def test_expdate + assert_equal( + '%02d%2s' % [@credit_card.month, @credit_card.year.to_s[-2..-1]], + @gateway.send(:expdate, @credit_card) + ) + end + + def test_no_transaction + @gateway.expects(:ssl_post).raises(no_transaction_response()) + assert response = @gateway.purchase(100, @credit_card, {}) + assert_failure response + assert response.test? + assert_equal 'Malformed request: Transaction Type is missing.', response.message + end + + def test_supported_countries + assert_equal ['CA', 'US'], FirstdataE4V27Gateway.supported_countries + end + + def test_supported_cardtypes + assert_equal [:visa, :master, :american_express, :jcb, :discover], FirstdataE4V27Gateway.supported_cardtypes + end + + def test_avs_result + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card) + assert_equal 'U', response.avs_result['code'] + end + + def test_cvv_result + @gateway.expects(:ssl_post).returns(successful_purchase_response) + + response = @gateway.purchase(@amount, @credit_card) + assert_equal 'M', response.cvv_result['code'] + end + + def test_request_includes_address + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match '<Address><Address1>456 My Street</Address1><Address2>Apt 1</Address2><City>Ottawa</City><State>ON</State><Zip>K1C2N6</Zip><CountryCode>CA</CountryCode></Address>', data + end.respond_with(successful_purchase_response) + end + + def test_tax_fields_are_sent + stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(tax1_amount: 830, tax1_number: 'Br59a')) + end.check_request do |endpoint, data, headers| + assert_match '<Tax1Amount>830', data + assert_match '<Tax1Number>Br59a', data + end.respond_with(successful_purchase_response) + end + + def test_customer_ref_is_sent + stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(customer: '932')) + end.check_request do |endpoint, data, headers| + assert_match '<Customer_Ref>932', data + end.respond_with(successful_purchase_response) + end + + def test_eci_default_value + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match '<Ecommerce_Flag>07</Ecommerce_Flag>', data + end.respond_with(successful_purchase_response) + end + + def test_eci_numeric_padding + @credit_card = network_tokenization_credit_card + @credit_card.eci = '5' + + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match '<Ecommerce_Flag>05</Ecommerce_Flag>', data + end.respond_with(successful_purchase_response) + + @credit_card = network_tokenization_credit_card + @credit_card.eci = 5 + + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match '<Ecommerce_Flag>05</Ecommerce_Flag>', data + end.respond_with(successful_purchase_response) + end + + def test_eci_option_value + stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(eci: '05')) + end.check_request do |endpoint, data, headers| + assert_match '<Ecommerce_Flag>05</Ecommerce_Flag>', data + end.respond_with(successful_purchase_response) + end + + def test_network_tokenization_requests_with_amex + stub_comms do + credit_card = network_tokenization_credit_card( + '378282246310005', + brand: 'american_express', + transaction_id: '123', + eci: '05', + payment_cryptogram: 'whatever_the_cryptogram_of_at_least_20_characters_is', + ) + + @gateway.purchase(@amount, credit_card, @options) + end.check_request do |_, data, _| + assert_match '<Ecommerce_Flag>05</Ecommerce_Flag>', data + assert_match "<XID>mrLdtHIWq2nLXq7IrA==\n</XID>", data + assert_match "<CAVV>whateverthecryptogramofatlc=\n</CAVV>", data + assert_xml_valid_to_wsdl(data) + end.respond_with(successful_purchase_response) + end + + def test_network_tokenization_requests_with_discover + stub_comms do + credit_card = network_tokenization_credit_card( + '6011111111111117', + brand: 'discover', + transaction_id: '123', + eci: '05', + payment_cryptogram: 'whatever_the_cryptogram_is', + ) + + @gateway.purchase(@amount, credit_card, @options) + end.check_request do |_, data, _| + assert_match '<Ecommerce_Flag>04</Ecommerce_Flag>', data + assert_match '<XID>123</XID>', data + assert_match '<CAVV>whatever_the_cryptogram_is</CAVV>', data + assert_xml_valid_to_wsdl(data) + end.respond_with(successful_purchase_response) + end + + def test_network_tokenization_requests_with_other_brands + %w(visa mastercard other).each do |brand| + stub_comms do + credit_card = network_tokenization_credit_card( + '378282246310005', + brand: brand, + transaction_id: '123', + eci: '05', + payment_cryptogram: 'whatever_the_cryptogram_is', + ) + + @gateway.purchase(@amount, credit_card, @options) + end.check_request do |_, data, _| + assert_match '<Ecommerce_Flag>05</Ecommerce_Flag>', data + assert_match '<XID>123</XID>', data + assert_match '<CAVV>whatever_the_cryptogram_is</CAVV>', data + assert_xml_valid_to_wsdl(data) + end.respond_with(successful_purchase_response) + end + end + + def test_requests_include_card_authentication_data + authentication_hash = { + eci: '06', + cavv: 'SAMPLECAVV', + xid: 'SAMPLEXID' + } + options_with_authentication_data = @options.merge(authentication_hash) + + stub_comms do + @gateway.purchase(@amount, @credit_card, options_with_authentication_data) + end.check_request do |endpoint, data, headers| + assert_match '<Ecommerce_Flag>06</Ecommerce_Flag>', data + assert_match '<CAVV>SAMPLECAVV</CAVV>', data + assert_match '<XID>SAMPLEXID</XID>', data + assert_xml_valid_to_wsdl(data) + end.respond_with(successful_purchase_response) + end + + def test_card_type + assert_equal 'Visa', @gateway.send(:card_type, 'visa') + assert_equal 'Mastercard', @gateway.send(:card_type, 'master') + assert_equal 'American Express', @gateway.send(:card_type, 'american_express') + assert_equal 'JCB', @gateway.send(:card_type, 'jcb') + assert_equal 'Discover', @gateway.send(:card_type, 'discover') + end + + def test_add_swipe_data_with_creditcard + @credit_card.track_data = 'Track Data' + + stub_comms do + @gateway.purchase(@amount, @credit_card) + end.check_request do |endpoint, data, headers| + assert_match '<Track1>Track Data</Track1>', data + assert_match '<Ecommerce_Flag>R</Ecommerce_Flag>', data + end.respond_with(successful_purchase_response) + end + + def test_transcript_scrubbing + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrub), post_scrub + end + + def test_supports_network_tokenization + assert_instance_of TrueClass, @gateway.supports_network_tokenization? + end + + private + + def assert_xml_valid_to_wsdl(data) + xsd = Nokogiri::XML::Schema(File.open("#{File.dirname(__FILE__)}/../../schema/firstdata_e4/v27.xsd")) + doc = Nokogiri::XML(data) + errors = xsd.validate(doc) + assert_empty errors, "XSD validation errors in the following XML:\n#{doc}" + end + + def pre_scrub + <<-PRE_SCRUBBED + opening connection to api.demo.globalgatewaye4.firstdata.com:443... + opened + starting SSL for api.demo.globalgatewaye4.firstdata.com:443... + SSL established + <- "POST /transaction/v27 HTTP/1.1\r\nContent-Type: application/xml\r\nX-Gge4-Date: 2018-07-03T07:35:34Z\r\nX-Gge4-Content-Sha1: 5335f81daf59c493fe5d4c18910d17eba69558d4\r\nAuthorization: GGE4_API 397439:iwaxRr8f3GQIMSucb+dmDeiwoAk=\r\nAccepts: application/xml\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: api.demo.globalgatewaye4.firstdata.com\r\nContent-Length: 807\r\n\r\n" + <- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Transaction xmlns=\"http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes\"><ExactID>SD8821-67</ExactID><Password>cBhEc4GENtZ5fnVtpb2qlrhKUDprqtar</Password><Transaction_Type>00</Transaction_Type><DollarAmount>1.00</DollarAmount><Currency>USD</Currency><Card_Number>4242424242424242</Card_Number><Expiry_Date>0919</Expiry_Date><CardHoldersName>Longbob Longsen</CardHoldersName><CardType>Visa</CardType><Ecommerce_Flag>07</Ecommerce_Flag><CVD_Presence_Ind>1</CVD_Presence_Ind><CVDCode>123</CVDCode><CAVV/><XID/><Address><Address1>456 My Street</Address1><Address2>Apt 1</Address2><City>Ottawa</City><State>ON</State><Zip>K1C2N6</Zip><CountryCode>CA</CountryCode></Address><Reference_No>1</Reference_No><Reference_3>Store Purchase</Reference_3></Transaction>" + -> "HTTP/1.1 201 Created\r\n" + -> "Server: nginx\r\n" + -> "Date: Tue, 03 Jul 2018 07:35:34 GMT\r\n" + -> "Content-Type: application/xml; charset=utf-8\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Connection: close\r\n" + -> "X-Frame-Options: SAMEORIGIN\r\n" + -> "X-XSS-Protection: 1; mode=block\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "X-GGE4-Date: 2018-07-03T07:35:34Z\r\n" + -> "X-GGE4-CONTENT-SHA1: 87ae8c40ae5afbfd060c7569645f3f6b4045994f\r\n" + -> "Authorization: GGE4_API 397439:dPOI+d2MkNJjBJhHTYUo0ieILw4=\r\n" + -> "Pragma: no-cache\r\n" + -> "Expires: Tue, 03 Jul 2018 06:35:34 GMT\r\n" + -> "Cache-Control: no-store, no-cache\r\n" + -> "X-Request-Id: 0f9ba7k2rd80a2tpch40\r\n" + -> "Location: https://api.demo.globalgatewaye4.firstdata.com/transaction/v27/2264726018\r\n" + -> "Status: 201 Created\r\n" + -> "Strict-Transport-Security: max-age=31536000; includeSubDomains\r\n" + -> "Strict-Transport-Security: max-age=315360000; includeSubdomains\r\n" + -> "\r\n" + -> "2da\r\n" + reading 2944 bytes... + -> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<TransactionResult>\n <ExactID>SD8821-67</ExactID>\n <Password/>\n <Transaction_Type>00</Transaction_Type>\n <DollarAmount>1.0</DollarAmount>\n <SurchargeAmount/>\n <Card_Number>############4242</Card_Number>\n <Transaction_Tag>2264726018</Transaction_Tag>\n <SplitTenderID/>\n <Track1/>\n <Track2/>\n <PAN/>\n <Authorization_Num>ET121995</Authorization_Num>\n <Expiry_Date>0919</Expiry_Date>\n <CardHoldersName>Longbob Longsen</CardHoldersName>\n <CVD_Presence_Ind>1</CVD_Presence_Ind>\n <ZipCode/>\n <Tax1Amount/>\n <Tax1Number/>\n <Tax2Amount/>\n <Tax2Number/>\n <Secure_AuthRequired/>\n <Secure_AuthResult/>\n <Ecommerce_Flag>7</Ecommerce_Flag>\n <XID/>\n <CAVV/>\n <Reference_No>1</Reference_No>\n <Customer_Ref/>\n <Reference_3>Store Purchase</Reference_3>\n <Language/>\n <Client_IP/>\n <Client_Email/>\n <User_Name/>\n <Transaction_Error>false</Transaction_Error>\n <Transaction_Approved>true</Transaction_Approved>\n <EXact_Resp_Code>00</EXact_Resp_Code>\n <EXact_Message>Transaction Normal</EXact_Message>\n <Bank_Resp_Code>100</Bank_Resp_Code>\n <Bank_Message>Approved</Bank_Message>\n <Bank_Resp_Code_2/>\n <SequenceNo>001157</SequenceNo>\n <AVS>4</AVS>\n <CVV2>M</CVV2>\n <Retrieval_Ref_No>1196543</Retrieval_Ref_No>\n <CAVV_Response/>\n <Currency>USD</Currency>\n <AmountRequested/>\n <PartialRedemption>false</PartialRedemption>\n <MerchantName>Spreedly DEMO0095</MerchantName>\n <MerchantAddress>123 Testing</MerchantAddress>\n <MerchantCity>Durham</MerchantCity>\n <MerchantProvince>North Carolina</MerchantProvince>\n <MerchantCountry>United States</MerchantCountry>\n <MerchantPostal>27701</MerchantPostal>\n <MerchantURL/>\n <TransarmorToken/>\n <CardType>Visa</CardType>\n <CurrentBalance/>\n <PreviousBalance/>\n <EAN/>\n <CardCost/>\n <VirtualCard>false</VirtualCard>\n <CTR>========== TRANSACTION RECORD ==========\nSpreedly DEMO0095\n123 Testing\nDurham, NC 27701\nUnited States\n\n\nTYPE: Purchase\n\nACCT: Visa $ 1.00 USD\n\nCARDHOLDER NAME : Longbob Longsen\nCARD NUMBER : ############4242\nDATE/TIME : 03 Jul 18 03:35:34\nREFERENCE # : 03 001157 M\nAUTHOR. # : ET121995\nTRANS. REF. : 1\n\n Approved - Thank You 100\n\n\nPlease retain this copy for your records.\n\nCardholder will pay above amount to\ncard issuer pursuant to cardholder\nagreement.\n========================================</CTR>\n <FraudSuspected/>\n <Address>\n <Address1>456 My Street</Address1>\n <Address2>Apt 1</Address2>\n <City>Ottawa</City>\n <State>ON</State>\n <Zip>K1C2N6</Zip>\n <CountryCode>CA</CountryCode>\n </Address>\n <CVDCode>123</CVDCode>\n <SplitShipmentNumber/>\n</TransactionResult>\n" + read 2944 bytes + Conn close + PRE_SCRUBBED + end + + def post_scrub + <<-POST_SCRUBBED + opening connection to api.demo.globalgatewaye4.firstdata.com:443... + opened + starting SSL for api.demo.globalgatewaye4.firstdata.com:443... + SSL established + <- "POST /transaction/v27 HTTP/1.1\r\nContent-Type: application/xml\r\nX-Gge4-Date: 2018-07-03T07:35:34Z\r\nX-Gge4-Content-Sha1: 5335f81daf59c493fe5d4c18910d17eba69558d4\r\nAuthorization: GGE4_API 397439:iwaxRr8f3GQIMSucb+dmDeiwoAk=\r\nAccepts: application/xml\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: api.demo.globalgatewaye4.firstdata.com\r\nContent-Length: 807\r\n\r\n" + <- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Transaction xmlns=\"http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes\"><ExactID>SD8821-67</ExactID><Password>[FILTERED]</Password><Transaction_Type>00</Transaction_Type><DollarAmount>1.00</DollarAmount><Currency>USD</Currency><Card_Number>[FILTERED]</Card_Number><Expiry_Date>0919</Expiry_Date><CardHoldersName>Longbob Longsen</CardHoldersName><CardType>Visa</CardType><Ecommerce_Flag>07</Ecommerce_Flag><CVD_Presence_Ind>1</CVD_Presence_Ind><CVDCode>[FILTERED]</CVDCode><CAVV/><XID/><Address><Address1>456 My Street</Address1><Address2>Apt 1</Address2><City>Ottawa</City><State>ON</State><Zip>K1C2N6</Zip><CountryCode>CA</CountryCode></Address><Reference_No>1</Reference_No><Reference_3>Store Purchase</Reference_3></Transaction>" + -> "HTTP/1.1 201 Created\r\n" + -> "Server: nginx\r\n" + -> "Date: Tue, 03 Jul 2018 07:35:34 GMT\r\n" + -> "Content-Type: application/xml; charset=utf-8\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Connection: close\r\n" + -> "X-Frame-Options: SAMEORIGIN\r\n" + -> "X-XSS-Protection: 1; mode=block\r\n" + -> "X-Content-Type-Options: nosniff\r\n" + -> "X-GGE4-Date: 2018-07-03T07:35:34Z\r\n" + -> "X-GGE4-CONTENT-SHA1: 87ae8c40ae5afbfd060c7569645f3f6b4045994f\r\n" + -> "Authorization: GGE4_API 397439:dPOI+d2MkNJjBJhHTYUo0ieILw4=\r\n" + -> "Pragma: no-cache\r\n" + -> "Expires: Tue, 03 Jul 2018 06:35:34 GMT\r\n" + -> "Cache-Control: no-store, no-cache\r\n" + -> "X-Request-Id: 0f9ba7k2rd80a2tpch40\r\n" + -> "Location: https://api.demo.globalgatewaye4.firstdata.com/transaction/v27/2264726018\r\n" + -> "Status: 201 Created\r\n" + -> "Strict-Transport-Security: max-age=31536000; includeSubDomains\r\n" + -> "Strict-Transport-Security: max-age=315360000; includeSubdomains\r\n" + -> "\r\n" + -> "2da\r\n" + reading 2944 bytes... + -> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<TransactionResult>\n <ExactID>SD8821-67</ExactID>\n <Password/>\n <Transaction_Type>00</Transaction_Type>\n <DollarAmount>1.0</DollarAmount>\n <SurchargeAmount/>\n <Card_Number>[FILTERED]</Card_Number>\n <Transaction_Tag>2264726018</Transaction_Tag>\n <SplitTenderID/>\n <Track1/>\n <Track2/>\n <PAN/>\n <Authorization_Num>ET121995</Authorization_Num>\n <Expiry_Date>0919</Expiry_Date>\n <CardHoldersName>Longbob Longsen</CardHoldersName>\n <CVD_Presence_Ind>1</CVD_Presence_Ind>\n <ZipCode/>\n <Tax1Amount/>\n <Tax1Number/>\n <Tax2Amount/>\n <Tax2Number/>\n <Secure_AuthRequired/>\n <Secure_AuthResult/>\n <Ecommerce_Flag>7</Ecommerce_Flag>\n <XID/>\n <CAVV/>\n <Reference_No>1</Reference_No>\n <Customer_Ref/>\n <Reference_3>Store Purchase</Reference_3>\n <Language/>\n <Client_IP/>\n <Client_Email/>\n <User_Name/>\n <Transaction_Error>false</Transaction_Error>\n <Transaction_Approved>true</Transaction_Approved>\n <EXact_Resp_Code>00</EXact_Resp_Code>\n <EXact_Message>Transaction Normal</EXact_Message>\n <Bank_Resp_Code>100</Bank_Resp_Code>\n <Bank_Message>Approved</Bank_Message>\n <Bank_Resp_Code_2/>\n <SequenceNo>001157</SequenceNo>\n <AVS>4</AVS>\n <CVV2>M</CVV2>\n <Retrieval_Ref_No>1196543</Retrieval_Ref_No>\n <CAVV_Response/>\n <Currency>USD</Currency>\n <AmountRequested/>\n <PartialRedemption>false</PartialRedemption>\n <MerchantName>Spreedly DEMO0095</MerchantName>\n <MerchantAddress>123 Testing</MerchantAddress>\n <MerchantCity>Durham</MerchantCity>\n <MerchantProvince>North Carolina</MerchantProvince>\n <MerchantCountry>United States</MerchantCountry>\n <MerchantPostal>27701</MerchantPostal>\n <MerchantURL/>\n <TransarmorToken/>\n <CardType>Visa</CardType>\n <CurrentBalance/>\n <PreviousBalance/>\n <EAN/>\n <CardCost/>\n <VirtualCard>false</VirtualCard>\n <CTR>========== TRANSACTION RECORD ==========\nSpreedly DEMO0095\n123 Testing\nDurham, NC 27701\nUnited States\n\n\nTYPE: Purchase\n\nACCT: Visa $ 1.00 USD\n\nCARDHOLDER NAME : Longbob Longsen\nCARD NUMBER : [FILTERED]\nDATE/TIME : 03 Jul 18 03:35:34\nREFERENCE # : 03 001157 M\nAUTHOR. # : ET121995\nTRANS. REF. : 1\n\n Approved - Thank You 100\n\n\nPlease retain this copy for your records.\n\nCardholder will pay above amount to\ncard issuer pursuant to cardholder\nagreement.\n========================================</CTR>\n <FraudSuspected/>\n <Address>\n <Address1>456 My Street</Address1>\n <Address2>Apt 1</Address2>\n <City>Ottawa</City>\n <State>ON</State>\n <Zip>K1C2N6</Zip>\n <CountryCode>CA</CountryCode>\n </Address>\n <CVDCode>[FILTERED]</CVDCode>\n <SplitShipmentNumber/>\n</TransactionResult>\n" + read 2944 bytes + Conn close + POST_SCRUBBED + end + + def successful_purchase_response + <<-RESPONSE + <?xml version="1.0" encoding="UTF-8"?> + <TransactionResult> + <ExactID>AD1234-56</ExactID> + <Password></Password> + <Transaction_Type>00</Transaction_Type> + <DollarAmount>47.38</DollarAmount> + <SurchargeAmount></SurchargeAmount> + <Card_Number>############1111</Card_Number> + <Transaction_Tag>106625152</Transaction_Tag> + <Track1></Track1> + <Track2></Track2> + <PAN></PAN> + <Authorization_Num>ET1700</Authorization_Num> + <Expiry_Date>0913</Expiry_Date> + <CardHoldersName>Fred Burfle</CardHoldersName> + <CVD_Presence_Ind>0</CVD_Presence_Ind> + <ZipCode></ZipCode> + <Tax1Amount></Tax1Amount> + <Tax1Number></Tax1Number> + <Tax2Amount></Tax2Amount> + <Tax2Number></Tax2Number> + <Secure_AuthRequired></Secure_AuthRequired> + <Secure_AuthResult></Secure_AuthResult> + <Ecommerce_Flag></Ecommerce_Flag> + <XID></XID> + <CAVV></CAVV> + <CAVV_Algorithm></CAVV_Algorithm> + <Reference_No>77</Reference_No> + <Customer_Ref></Customer_Ref> + <Reference_3></Reference_3> + <Language></Language> + <Client_IP>1.1.1.10</Client_IP> + <Client_Email></Client_Email> + <Transaction_Error>false</Transaction_Error> + <Transaction_Approved>true</Transaction_Approved> + <EXact_Resp_Code>00</EXact_Resp_Code> + <EXact_Message>Transaction Normal</EXact_Message> + <Bank_Resp_Code>100</Bank_Resp_Code> + <Bank_Message>Approved</Bank_Message> + <Bank_Resp_Code_2></Bank_Resp_Code_2> + <SequenceNo>000040</SequenceNo> + <AVS>U</AVS> + <CVV2>M</CVV2> + <Retrieval_Ref_No>3146117</Retrieval_Ref_No> + <CAVV_Response></CAVV_Response> + <Currency>USD</Currency> + <AmountRequested></AmountRequested> + <PartialRedemption>false</PartialRedemption> + <MerchantName>Friendly Inc DEMO0983</MerchantName> + <MerchantAddress>123 King St</MerchantAddress> + <MerchantCity>Toronto</MerchantCity> + <MerchantProvince>Ontario</MerchantProvince> + <MerchantCountry>Canada</MerchantCountry> + <MerchantPostal>L7Z 3K8</MerchantPostal> + <MerchantURL></MerchantURL> + <TransarmorToken>8938737759041111</TransarmorToken> + <CTR>=========== TRANSACTION RECORD ========== +Friendly Inc DEMO0983 +123 King St +Toronto, ON L7Z 3K8 +Canada + + +TYPE: Purchase + +ACCT: Visa $ 47.38 USD + +CARD NUMBER : ############1111 +DATE/TIME : 28 Sep 12 07:54:48 +REFERENCE # : 000040 M +AUTHOR. # : ET120454 +TRANS. REF. : 77 + + Approved - Thank You 100 + + +Please retain this copy for your records. + +Cardholder will pay above amount to card +issuer pursuant to cardholder agreement. +=========================================</CTR> + <Address> + <Address1>456 My Street</Address1> + <Address2>Apt 1</Address2> + <City>Ottawa</City> + <State>ON</State> + <Zip>K1C2N6</Zip> + <CountryCode>CA</CountryCode> + </Address> + </TransactionResult> + RESPONSE + end + + def successful_purchase_response_without_transarmor + <<-RESPONSE + <?xml version="1.0" encoding="UTF-8"?> + <TransactionResult> + <ExactID>AD1234-56</ExactID> + <Password></Password> + <Transaction_Type>00</Transaction_Type> + <DollarAmount>47.38</DollarAmount> + <SurchargeAmount></SurchargeAmount> + <Card_Number>############1111</Card_Number> + <Transaction_Tag>106625152</Transaction_Tag> + <Track1></Track1> + <Track2></Track2> + <PAN></PAN> + <Authorization_Num>ET1700</Authorization_Num> + <Expiry_Date>0913</Expiry_Date> + <CardHoldersName>Fred Burfle</CardHoldersName> + <CVD_Presence_Ind>0</CVD_Presence_Ind> + <ZipCode></ZipCode> + <Tax1Amount></Tax1Amount> + <Tax1Number></Tax1Number> + <Tax2Amount></Tax2Amount> + <Tax2Number></Tax2Number> + <Secure_AuthRequired></Secure_AuthRequired> + <Secure_AuthResult></Secure_AuthResult> + <Ecommerce_Flag></Ecommerce_Flag> + <XID></XID> + <CAVV></CAVV> + <CAVV_Algorithm></CAVV_Algorithm> + <Reference_No>77</Reference_No> + <Customer_Ref></Customer_Ref> + <Reference_3></Reference_3> + <Language></Language> + <Client_IP>1.1.1.10</Client_IP> + <Client_Email></Client_Email> + <Transaction_Error>false</Transaction_Error> + <Transaction_Approved>true</Transaction_Approved> + <EXact_Resp_Code>00</EXact_Resp_Code> + <EXact_Message>Transaction Normal</EXact_Message> + <Bank_Resp_Code>100</Bank_Resp_Code> + <Bank_Message>Approved</Bank_Message> + <Bank_Resp_Code_2></Bank_Resp_Code_2> + <SequenceNo>000040</SequenceNo> + <AVS>U</AVS> + <CVV2>M</CVV2> + <Retrieval_Ref_No>3146117</Retrieval_Ref_No> + <CAVV_Response></CAVV_Response> + <Currency>USD</Currency> + <AmountRequested></AmountRequested> + <PartialRedemption>false</PartialRedemption> + <MerchantName>Friendly Inc DEMO0983</MerchantName> + <MerchantAddress>123 King St</MerchantAddress> + <MerchantCity>Toronto</MerchantCity> + <MerchantProvince>Ontario</MerchantProvince> + <MerchantCountry>Canada</MerchantCountry> + <MerchantPostal>L7Z 3K8</MerchantPostal> + <MerchantURL></MerchantURL> + <TransarmorToken></TransarmorToken> + <CTR>=========== TRANSACTION RECORD ========== +Friendly Inc DEMO0983 +123 King St +Toronto, ON L7Z 3K8 +Canada + + +TYPE: Purchase + +ACCT: Visa $ 47.38 USD + +CARD NUMBER : ############1111 +DATE/TIME : 28 Sep 12 07:54:48 +REFERENCE # : 000040 M +AUTHOR. # : ET120454 +TRANS. REF. : 77 + + Approved - Thank You 100 + + +Please retain this copy for your records. + +Cardholder will pay above amount to card +issuer pursuant to cardholder agreement. +=========================================</CTR> + </TransactionResult> + RESPONSE + end + + def successful_refund_response + <<-RESPONSE + <?xml version="1.0" encoding="UTF-8"?> + <TransactionResult> + <ExactID>AD1234-56</ExactID> + <Password></Password> + <Transaction_Type>34</Transaction_Type> + <DollarAmount>123</DollarAmount> + <SurchargeAmount></SurchargeAmount> + <Card_Number>############1111</Card_Number> + <Transaction_Tag>888</Transaction_Tag> + <Track1></Track1> + <Track2></Track2> + <PAN></PAN> + <Authorization_Num>ET112216</Authorization_Num> + <Expiry_Date>0913</Expiry_Date> + <CardHoldersName>Fred Burfle</CardHoldersName> + <CVD_Presence_Ind>0</CVD_Presence_Ind> + <ZipCode></ZipCode> + <Tax1Amount></Tax1Amount> + <Tax1Number></Tax1Number> + <Tax2Amount></Tax2Amount> + <Tax2Number></Tax2Number> + <Secure_AuthRequired></Secure_AuthRequired> + <Secure_AuthResult></Secure_AuthResult> + <Ecommerce_Flag></Ecommerce_Flag> + <XID></XID> + <CAVV></CAVV> + <CAVV_Algorithm></CAVV_Algorithm> + <Reference_No></Reference_No> + <Customer_Ref></Customer_Ref> + <Reference_3></Reference_3> + <Language></Language> + <Client_IP>1.1.1.10</Client_IP> + <Client_Email></Client_Email> + <Transaction_Error>false</Transaction_Error> + <Transaction_Approved>true</Transaction_Approved> + <EXact_Resp_Code>00</EXact_Resp_Code> + <EXact_Message>Transaction Normal</EXact_Message> + <Bank_Resp_Code>100</Bank_Resp_Code> + <Bank_Message>Approved</Bank_Message> + <Bank_Resp_Code_2></Bank_Resp_Code_2> + <SequenceNo>000041</SequenceNo> + <AVS></AVS> + <CVV2>I</CVV2> + <Retrieval_Ref_No>9176784</Retrieval_Ref_No> + <CAVV_Response></CAVV_Response> + <Currency>USD</Currency> + <AmountRequested></AmountRequested> + <PartialRedemption>false</PartialRedemption> + <MerchantName>Friendly Inc DEMO0983</MerchantName> + <MerchantAddress>123 King St</MerchantAddress> + <MerchantCity>Toronto</MerchantCity> + <MerchantProvince>Ontario</MerchantProvince> + <MerchantCountry>Canada</MerchantCountry> + <MerchantPostal>L7Z 3K8</MerchantPostal> + <MerchantURL></MerchantURL> + <CTR>=========== TRANSACTION RECORD ========== +Friendly Inc DEMO0983 +123 King St +Toronto, ON L7Z 3K8 +Canada + + +TYPE: Refund + +ACCT: Visa $ 23.69 USD + +CARD NUMBER : ############1111 +DATE/TIME : 28 Sep 12 08:31:23 +REFERENCE # : 000041 M +AUTHOR. # : ET112216 +TRANS. REF. : + + Approved - Thank You 100 + + +Please retain this copy for your records. + +=========================================</CTR> + </TransactionResult> + RESPONSE + end + + def failed_purchase_response + <<-RESPONSE + <?xml version="1.0" encoding="UTF-8"?> + <TransactionResult> + <ExactID>AD1234-56</ExactID> + <Password></Password> + <Transaction_Type>00</Transaction_Type> + <DollarAmount>5013.0</DollarAmount> + <SurchargeAmount></SurchargeAmount> + <Card_Number>############1111</Card_Number> + <Transaction_Tag>555555</Transaction_Tag> + <Track1></Track1> + <Track2></Track2> + <PAN></PAN> + <Authorization_Num></Authorization_Num> + <Expiry_Date>0911</Expiry_Date> + <CardHoldersName>Fred Burfle</CardHoldersName> + <CVD_Presence_Ind>0</CVD_Presence_Ind> + <ZipCode></ZipCode> + <Tax1Amount></Tax1Amount> + <Tax1Number></Tax1Number> + <Tax2Amount></Tax2Amount> + <Tax2Number></Tax2Number> + <Secure_AuthRequired></Secure_AuthRequired> + <Secure_AuthResult></Secure_AuthResult> + <Ecommerce_Flag></Ecommerce_Flag> + <XID></XID> + <CAVV></CAVV> + <CAVV_Algorithm></CAVV_Algorithm> + <Reference_No>77</Reference_No> + <Customer_Ref></Customer_Ref> + <Reference_3></Reference_3> + <Language></Language> + <Client_IP>1.1.1.10</Client_IP> + <Client_Email></Client_Email> + <LogonMessage></LogonMessage> + <Error_Number>0</Error_Number> + <Error_Description> </Error_Description> + <Transaction_Error>false</Transaction_Error> + <Transaction_Approved>false</Transaction_Approved> + <EXact_Resp_Code>00</EXact_Resp_Code> + <EXact_Message>Transaction Normal</EXact_Message> + <Bank_Resp_Code>605</Bank_Resp_Code> + <Bank_Message>Invalid Expiration Date</Bank_Message> + <Bank_Resp_Code_2></Bank_Resp_Code_2> + <SequenceNo>000033</SequenceNo> + <AVS></AVS> + <CVV2></CVV2> + <Retrieval_Ref_No></Retrieval_Ref_No> + <CAVV_Response></CAVV_Response> + <Currency>USD</Currency> + <AmountRequested></AmountRequested> + <PartialRedemption>false</PartialRedemption> + <MerchantName>Friendly Inc DEMO0983</MerchantName> + <MerchantAddress>123 King St</MerchantAddress> + <MerchantCity>Toronto</MerchantCity> + <MerchantProvince>Ontario</MerchantProvince> + <MerchantCountry>Canada</MerchantCountry> + <MerchantPostal>L7Z 3K8</MerchantPostal> + <MerchantURL></MerchantURL> + <CTR>=========== TRANSACTION RECORD ========== +Friendly Inc DEMO0983 +123 King St +Toronto, ON L7Z 3K8 +Canada + + +TYPE: Purchase +ACCT: Visa $ 5,013.00 USD +CARD NUMBER : ############1111 +DATE/TIME : 25 Sep 12 07:27:00 +REFERENCE # : 000033 M +AUTHOR. # : +TRANS. REF. : 77 +Transaction not approved 605 +Please retain this copy for your records. +=========================================</CTR> + </TransactionResult> + RESPONSE + end + + def successful_verify_response + <<-RESPONSE +<?xml version="1.0" encoding="UTF-8"?> +<TransactionResult> + <ExactID>AD2552-05</ExactID> + <Password></Password> + <Transaction_Type>05</Transaction_Type> + <DollarAmount>0.0</DollarAmount> + <SurchargeAmount></SurchargeAmount> + <Card_Number>############4242</Card_Number> + <Transaction_Tag>25101911</Transaction_Tag> + <Track1></Track1> + <Track2></Track2> + <PAN></PAN> + <Authorization_Num>ET184931</Authorization_Num> + <Expiry_Date>0915</Expiry_Date> + <CardHoldersName>Longbob Longsen</CardHoldersName> + <CVD_Presence_Ind>0</CVD_Presence_Ind> + <ZipCode></ZipCode> + <Tax1Amount></Tax1Amount> + <Tax1Number></Tax1Number> + <Tax2Amount></Tax2Amount> + <Tax2Number></Tax2Number> + <Secure_AuthRequired></Secure_AuthRequired> + <Secure_AuthResult></Secure_AuthResult> + <Ecommerce_Flag></Ecommerce_Flag> + <XID></XID> + <CAVV></CAVV> + <CAVV_Algorithm></CAVV_Algorithm> + <Reference_No>1</Reference_No> + <Customer_Ref></Customer_Ref> + <Reference_3>Store Purchase</Reference_3> + <Language></Language> + <Client_IP>75.182.123.244</Client_IP> + <Client_Email></Client_Email> + <Transaction_Error>false</Transaction_Error> + <Transaction_Approved>true</Transaction_Approved> + <EXact_Resp_Code>00</EXact_Resp_Code> + <EXact_Message>Transaction Normal</EXact_Message> + <Bank_Resp_Code>100</Bank_Resp_Code> + <Bank_Message>Approved</Bank_Message> + <Bank_Resp_Code_2></Bank_Resp_Code_2> + <SequenceNo>000040</SequenceNo> + <AVS>1</AVS> + <CVV2>M</CVV2> + <Retrieval_Ref_No>7228838</Retrieval_Ref_No> + <CAVV_Response></CAVV_Response> + <Currency>USD</Currency> + <AmountRequested></AmountRequested> + <PartialRedemption>false</PartialRedemption> + <MerchantName>FriendlyInc</MerchantName> + <MerchantAddress>123 Main Street</MerchantAddress> + <MerchantCity>Durham</MerchantCity> + <MerchantProvince>North Carolina</MerchantProvince> + <MerchantCountry>United States</MerchantCountry> + <MerchantPostal>27592</MerchantPostal> + <MerchantURL></MerchantURL> + <TransarmorToken></TransarmorToken> + <CardType>Visa</CardType> + <CurrentBalance></CurrentBalance> + <PreviousBalance></PreviousBalance> + <EAN></EAN> + <CardCost></CardCost> + <VirtualCard>false</VirtualCard> + <CTR>=========== TRANSACTION RECORD ========== +FriendlyInc DEMO0 +123 Main Street +Durham, NC 27592 +United States + + +TYPE: Auth Only + +ACCT: Visa $ 0.00 USD + +CARDHOLDER NAME : Longbob Longsen +CARD NUMBER : ############4242 +DATE/TIME : 04 Jul 14 14:21:52 +REFERENCE # : 000040 M +AUTHOR. # : ET184931 +TRANS. REF. : 1 + + Approved - Thank You 100 + + +Please retain this copy for your records. + +Cardholder will pay above amount to card +issuer pursuant to cardholder agreement. +=========================================</CTR> +</TransactionResult> + RESPONSE + end + + def no_transaction_response + yamlexcep = <<-RESPONSE +--- !ruby/exception:ActiveMerchant::ResponseError +message: Failed with 400 Bad Request +message: +response: !ruby/object:Net::HTTPBadRequest + body: "Malformed request: Transaction Type is missing." + body_exist: true + code: "400" + header: + connection: + - Close + content-type: + - text/html; charset=utf-8 + server: + - Apache + date: + - Fri, 28 Sep 2012 18:21:37 GMT + content-length: + - "47" + status: + - "400" + cache-control: + - no-cache + http_version: "1.1" + message: Bad Request + read: true + socket: + RESPONSE + YAML.safe_load(yamlexcep, ['Net::HTTPBadRequest', 'ActiveMerchant::ResponseError']) + end + + def bad_credentials_response + yamlexcep = <<-RESPONSE +--- !ruby/exception:ActiveMerchant::ResponseError +message: +response: !ruby/object:Net::HTTPUnauthorized + code: '401' + message: Authorization Required + body: Unauthorized Request. Bad or missing credentials. + read: true + header: + cache-control: + - no-cache + content-type: + - text/html; charset=utf-8 + date: + - Tue, 30 Dec 2014 23:28:32 GMT + server: + - Apache + status: + - '401' + x-rack-cache: + - invalidate, pass + x-request-id: + - 4157e21cc5620a95ead8d2025b55bdf4 + x-ua-compatible: + - IE=Edge,chrome=1 + content-length: + - '49' + connection: + - Close + body_exist: true + http_version: '1.1' + socket: + RESPONSE + YAML.safe_load(yamlexcep, ['Net::HTTPUnauthorized', 'ActiveMerchant::ResponseError']) + end + + def successful_void_response + <<-RESPONSE + <?xml version="1.0" encoding="UTF-8"?> + <TransactionResult> + <ExactID>AD1234-56</ExactID> + <Password></Password> + <Transaction_Type>33</Transaction_Type> + <DollarAmount>11.45</DollarAmount> + <SurchargeAmount></SurchargeAmount> + <Card_Number>############1111</Card_Number> + <Transaction_Tag>987123</Transaction_Tag> + <Track1></Track1> + <Track2></Track2> + <PAN></PAN> + <Authorization_Num>ET112112</Authorization_Num> + <Expiry_Date>0913</Expiry_Date> + <CardHoldersName>Fred Burfle</CardHoldersName> + <CVD_Presence_Ind>0</CVD_Presence_Ind> + <ZipCode></ZipCode> + <Tax1Amount></Tax1Amount> + <Tax1Number></Tax1Number> + <Tax2Amount></Tax2Amount> + <Tax2Number></Tax2Number> + <Secure_AuthRequired></Secure_AuthRequired> + <Secure_AuthResult></Secure_AuthResult> + <Ecommerce_Flag></Ecommerce_Flag> + <XID></XID> + <CAVV></CAVV> + <CAVV_Algorithm></CAVV_Algorithm> + <Reference_No></Reference_No> + <Customer_Ref></Customer_Ref> + <Reference_3></Reference_3> + <Language></Language> + <Client_IP>1.1.1.10</Client_IP> + <Client_Email></Client_Email> + <LogonMessage></LogonMessage> + <Error_Number>0</Error_Number> + <Error_Description> </Error_Description> + <Transaction_Error>false</Transaction_Error> + <Transaction_Approved>true</Transaction_Approved> + <EXact_Resp_Code>00</EXact_Resp_Code> + <EXact_Message>Transaction Normal</EXact_Message> + <Bank_Resp_Code>100</Bank_Resp_Code> + <Bank_Message>Approved</Bank_Message> + <Bank_Resp_Code_2></Bank_Resp_Code_2> + <SequenceNo>000166</SequenceNo> + <AVS></AVS> + <CVV2>I</CVV2> + <Retrieval_Ref_No>2046743</Retrieval_Ref_No> + <CAVV_Response></CAVV_Response> + <Currency>USD</Currency> + <AmountRequested></AmountRequested> + <PartialRedemption>false</PartialRedemption> + <MerchantName>FreshBooks DEMO0785</MerchantName> + <MerchantAddress>35 Golden Ave</MerchantAddress> + <MerchantCity>Toronto</MerchantCity> + <MerchantProvince>Ontario</MerchantProvince> + <MerchantCountry>Canada</MerchantCountry> + <MerchantPostal>M6R 2J5</MerchantPostal> + <MerchantURL></MerchantURL> +<CTR>=========== TRANSACTION RECORD ========== +FreshBooks DEMO0785 +35 Golden Ave +Toronto, ON M6R 2J5 +Canada + + +TYPE: Void + +ACCT: Visa $ 47.38 USD + +CARD NUMBER : ############1111 +DATE/TIME : 15 Nov 12 08:20:36 +REFERENCE # : 000166 M +AUTHOR. # : ET112112 +TRANS. REF. : + +Approved - Thank You 100 + + +Please retain this copy for your records. + +Cardholder will pay above amount to card +issuer pursuant to cardholder agreement. +=========================================</CTR> + </TransactionResult> +RESPONSE + end +end From dc9206f9d3f2d65077ed6d0a6a52a5b0269a72a7 Mon Sep 17 00:00:00 2001 From: Abhinandan Ramaprasath <abhiin1947@gmail.com> Date: Thu, 5 Jul 2018 23:47:20 -0400 Subject: [PATCH 471/677] Set contactless_magstripe_mode when transaction is contactless magstripe. Fix silently failing tests. --- lib/active_merchant/billing/gateways/stripe.rb | 1 + test/unit/gateways/stripe_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index aeaac0b4b82..d680dfaf353 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -397,6 +397,7 @@ def add_creditcard(post, creditcard, options) if emv_payment?(creditcard) add_emv_creditcard(post, creditcard.icc_data) post[:card][:read_method] = 'contactless' if creditcard.read_method == 'contactless' + post[:card][:read_method] = 'contactless_magstripe_mode' if creditcard.read_method == 'contactless_magstripe' if creditcard.encrypted_pin_cryptogram.present? && creditcard.encrypted_pin_ksn.present? post[:card][:encrypted_pin] = creditcard.encrypted_pin_cryptogram post[:card][:encrypted_pin_key_id] = creditcard.encrypted_pin_ksn diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index c5b2b0ba2c4..4839433bd48 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -1105,7 +1105,7 @@ def test_contactless_flag_is_included_with_emv_card_data @emv_credit_card.read_method = 'contactless' @gateway.purchase(@amount, @emv_credit_card, @options) end.check_request do |method, endpoint, data, headers| - data =~ /card\[read_method\]=contactless/ + assert data =~ /card\[read_method\]=contactless/ end.respond_with(successful_purchase_response) end @@ -1114,7 +1114,7 @@ def test_contactless_magstripe_flag_is_included_with_emv_card_data @emv_credit_card.read_method = 'contactless_magstripe' @gateway.purchase(@amount, @emv_credit_card, @options) end.check_request do |method, endpoint, data, headers| - data =~ /card\[read_method\]=contactless_magstripe_mode/ + assert data =~ /card\[read_method\]=contactless_magstripe_mode/ end.respond_with(successful_purchase_response) end @@ -1122,7 +1122,7 @@ def test_contactless_flag_is_not_included_with_emv_card_data_by_default stub_comms(@gateway, :ssl_request) do @gateway.purchase(@amount, @emv_credit_card, @options) end.check_request do |method, endpoint, data, headers| - data !~ /card\[read_method\]=contactless/ && data !~ /card\[read_method\]=contactless_magstripe_mode/ + assert data !~ /card\[read_method\]=contactless/ && data !~ /card\[read_method\]=contactless_magstripe_mode/ end.respond_with(successful_purchase_response) end From 5ddf3143ae5fddea02ba150ae258746ac49531f0 Mon Sep 17 00:00:00 2001 From: Abhinandan Ramaprasath <abhiin1947@gmail.com> Date: Fri, 6 Jul 2018 11:37:33 -0400 Subject: [PATCH 472/677] Update changelog --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index ef8d131a9d0..dfaff4123c5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 * Pin Payments: Pass reference for statement desc [curiousepic] #2919 * FirstData: introduce v27 gateway [shasum] #2912 +* Stripe: Fix contactless magstripe support [abhiin1947] #2917 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 From 220f06d98ca9bef18bc9eeceb3bda8770b02574b Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Fri, 15 Jun 2018 15:21:39 -0400 Subject: [PATCH 473/677] CT Payment: Add new gateway Adds a new gateway (ct_payment) along with a certicication test file Loaded suite test/unit/gateways/ct_payment_test 14 tests, 48 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_ct_payment_test 20 tests, 56 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/ct_payment.rb | 267 ++++++++++++++++ test/fixtures.yml | 5 + .../remote_ct_payment_certification_test.rb | 243 ++++++++++++++ .../remote/gateways/remote_ct_payment_test.rb | 173 ++++++++++ test/unit/gateways/ct_payment_test.rb | 302 ++++++++++++++++++ 6 files changed, 991 insertions(+) create mode 100644 lib/active_merchant/billing/gateways/ct_payment.rb create mode 100644 test/remote/gateways/remote_ct_payment_certification_test.rb create mode 100644 test/remote/gateways/remote_ct_payment_test.rb create mode 100644 test/unit/gateways/ct_payment_test.rb diff --git a/CHANGELOG b/CHANGELOG index dfaff4123c5..44097274cb2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -38,6 +38,7 @@ * Redsys: Fix payments with cc token [Leonardo Diez] #2586 * Redsys: Missing cardnumber params in xml_signed_fields [nerburish] #2628 * Bogus: allow authorizing with a tokenized card [Azdaroth] #2703 +* CT Payment: Add new gateway [nfarve] #2911 == Version 1.79.2 (June 2, 2018) * Fix Gateway#max_version= overwriting min_version [bdewater] diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb new file mode 100644 index 00000000000..889266d65c1 --- /dev/null +++ b/lib/active_merchant/billing/gateways/ct_payment.rb @@ -0,0 +1,267 @@ +module ActiveMerchant #:nodoc: + module Billing #:nodoc: + class CtPaymentGateway < Gateway + self.test_url = 'https://test.ctpaiement.ca/v1/' + self.live_url = 'hhtps://www.ctpaiement.com/v1/' + + self.supported_countries = ['US', 'CA'] + self.default_currency = 'CAD' + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club] + + self.homepage_url = 'http://www.ct-payment.com/' + self.display_name = 'CT Payment' + + STANDARD_ERROR_CODE_MAPPING = { + '14' => STANDARD_ERROR_CODE[:invalid_number], + '05' => STANDARD_ERROR_CODE[:card_declined], + 'M6' => STANDARD_ERROR_CODE[:card_declined], + '9068' => STANDARD_ERROR_CODE[:incorrect_number], + '9067' => STANDARD_ERROR_CODE[:incorrect_number] + } + CARD_BRAND = { + 'american_express' => 'A', + 'master' => 'M', + 'diners_club' => 'I', + 'visa' => 'V', + 'discover' => 'O' + } + + def initialize(options={}) + requires!(options, :api_key, :company_number, :merchant_number) + super + end + + def purchase(money, payment, options={}) + requires!(options, :order_id) + post = {} + add_terminal_number(post, options) + add_money(post, money) + add_operator_id(post, options) + add_invoice(post, money, options) + add_payment(post, payment) + add_address(post, payment, options) + add_customer_data(post, options) + + payment.is_a?(String) ? commit('purchaseWithToken', post) : commit('purchase', post) + end + + def authorize(money, payment, options={}) + requires!(options, :order_id) + post = {} + add_money(post, money) + add_terminal_number(post, options) + add_operator_id(post, options) + add_invoice(post, money, options) + add_payment(post, payment) + add_address(post, payment, options) + add_customer_data(post, options) + + payment.is_a?(String) ? commit('preAuthorizationWithToken', post) : commit('preAuthorization', post) + end + + def capture(money, authorization, options={}) + requires!(options, :order_id) + post = {} + add_invoice(post, money, options) + add_money(post, money) + add_customer_data(post, options) + transaction_number, authorization_number, invoice_number = split_authorization(authorization) + post[:OriginalTransactionNumber] = transaction_number + post[:OriginalAuthorizationNumber] = authorization_number + post[:OriginalInvoiceNumber] = invoice_number + + commit('completion', post) + end + + def refund(money, authorization, options={}) + requires!(options, :order_id) + post = {} + add_invoice(post, money, options) + add_money(post, money) + add_customer_data(post, options) + transaction_number, _, invoice_number = split_authorization(authorization) + post[:OriginalTransactionNumber] = transaction_number + post[:OriginalInvoiceNumber] = invoice_number + + commit('refundWithoutCard', post) + end + + def credit(money, payment, options={}) + requires!(options, :order_id) + post = {} + add_terminal_number(post, options) + add_money(post, money) + add_operator_id(post, options) + add_invoice(post, money, options) + add_payment(post, payment) + add_address(post, payment, options) + add_customer_data(post, options) + + payment.is_a?(String) ? commit('refundWithToken', post) : commit('refund', post) + end + + def void(authorization, options={}) + post = {} + post[:InputType] = 'I' + post[:LanguageCode] = 'E' + transaction_number, _, invoice_number = split_authorization(authorization) + post[:OriginalTransactionNumber] = transaction_number + post[:OriginalInvoiceNumber] = invoice_number + add_operator_id(post, options) + add_customer_data(post, options) + + commit('void', post) + end + + def verify(credit_card, options={}) + requires!(options, :order_id) + post = {} + add_terminal_number(post, options) + add_operator_id(post, options) + add_invoice(post,0, options) + add_payment(post, credit_card) + add_customer_data(post, options) + + commit('verifyAccount', post) + end + + def store(credit_card, options={}) + requires!(options, :email) + post = { + LanguageCode: 'E', + Name: credit_card.name.rjust(50, ' '), + Email: options[:email].rjust(240, ' ') + } + add_operator_id(post, options) + add_payment(post, credit_card) + add_customer_data(post, options) + + commit('recur/AddUser', post) + end + + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((&?auth-api-key=)[^&]*)i, '\1[FILTERED]'). + gsub(%r((&?payload=)[a-zA-Z%0-9=]+)i, '\1[FILTERED]'). + gsub(%r((&?token:)[^&]*)i, '\1[FILTERED]'). + gsub(%r((&?cardNumber:)[^&]*)i, '\1[FILTERED]') + end + + private + + def add_terminal_number(post, options) + post[:MerchantTerminalNumber] = options[:merchant_terminal_number] || ' ' * 5 + end + + def add_money(post, money) + post[:Amount] = money.to_s.rjust(11,'0') + end + + def add_operator_id(post, options) + post[:OperatorID] = options[:operator_id] || '0' * 8 + end + + def add_customer_data(post, options) + post[:CustomerNumber] = options[:customer_number] || '0' * 8 + end + + def add_address(post, creditcard, options) + if address = options[:billing_address] || options[:address] + post[:CardHolderAddress] = ("#{address[:address1]} #{address[:address2]}").rjust(20, ' ') + post[:CardHolderPostalCode] = address[:zip].gsub(/\s+/, '').rjust(9, ' ') + end + end + + def add_invoice(post, money, options) + post[:CurrencyCode] = options[:currency] || (currency(money) if money) + post[:InvoiceNumber] = options[:order_id].rjust(12,'0') + post[:InputType] = 'I' + post[:LanguageCode] = 'E' + end + + def add_payment(post, payment) + if payment.is_a?(String) + post[:Token] = split_authorization(payment)[3].strip + else + post[:CardType] = CARD_BRAND[payment.brand] || ' ' + post[:CardNumber] = payment.number.rjust(40,' ') + post[:ExpirationDate] = expdate(payment) + post[:Cvv2Cvc2Number] = payment.verification_value + end + end + + def parse(body) + JSON.parse(body) + end + + def split_authorization(authorization) + authorization.split(';') + end + + def commit_raw(action, parameters) + url = (test? ? test_url : live_url) + action + response = parse(ssl_post(url, post_data(action, parameters))) + + final_response = Response.new( + success_from(response), + message_from(response), + response, + authorization: authorization_from(response), + avs_result: AVSResult.new(code: response['avsStatus']), + cvv_result: CVVResult.new(response['cvv2Cvc2Status']), + test: test?, + error_code: error_code_from(response) + ) + end + + def commit(action, parameters) + if action == 'void' + commit_raw(action, parameters) + else + MultiResponse.run(true) do |r| + r.process { commit_raw(action, parameters)} + r.process { + split_auth = split_authorization(r.authorization) + auth = (action.include?('recur')? split_auth[4] : split_auth[0]) + action.include?('recur') ? commit_raw('recur/ack', {ID: auth}) : commit_raw('ack', {TransactionNumber: auth}) + } + end + end + end + + def success_from(response) + return true if response['returnCode'] == ' 00' + return true if response['returnCode'] == 'true' + return true if response['recurReturnCode'] == ' 00' + return false + end + + def message_from(response) + response['errorDescription'] || (response['terminalDisp'].strip if response['terminalDisp']) + end + + def authorization_from(response) + "#{response['transactionNumber']};#{response['authorizationNumber']};"\ + "#{response['invoiceNumber']};#{response['token']};#{response['id']}" + end + + def post_data(action, parameters = {}) + parameters[:CompanyNumber] = @options[:company_number] + parameters[:MerchantNumber] = @options[:merchant_number] + parameters = parameters.collect do |key, value| + "#{key}=#{value}" unless (value.nil? || value.empty?) + end.join('&') + payload = Base64.strict_encode64(parameters) + "auth-api-key=#{@options[:api_key]}&payload=#{payload}".strip + end + + def error_code_from(response) + STANDARD_ERROR_CODE_MAPPING[response['returnCode'].strip || response['recurReturnCode'.strip]] unless success_from(response) + end + end + end +end diff --git a/test/fixtures.yml b/test/fixtures.yml index 99d218d55eb..d7775b0ef28 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -219,6 +219,11 @@ credorax: merchant_id: 'merchant_id' cipher_key: 'cipher_key' +ct_payment: + api_key: SOMECREDENTIAL + company_number: '12345' + merchant_number: '12345678' + # Culqi does not provide public testing data culqi: merchant_id: MERCHANT diff --git a/test/remote/gateways/remote_ct_payment_certification_test.rb b/test/remote/gateways/remote_ct_payment_certification_test.rb new file mode 100644 index 00000000000..97ac2d6073b --- /dev/null +++ b/test/remote/gateways/remote_ct_payment_certification_test.rb @@ -0,0 +1,243 @@ +require 'test_helper' + +class RemoteCtPaymentCertificationTest < Test::Unit::TestCase + def setup + @gateway = CtPaymentGateway.new(fixtures(:ct_payment)) + + @amount = 100 + @declined_card = credit_card('4502244713161718') + @options = { + billing_address: address, + description: 'Store Purchase', + merchant_terminal_number: ' ', + order_id: generate_unique_id[0,11] + } + end + + def test1 + @credit_card = credit_card('4501161107217214', month: '07', year: 2025) + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(1, response) + end + + def test2 + @credit_card = credit_card('5194419000000007', month: '07', year: 2025) + @credit_card.brand = 'master' + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(2, response) + end + + def test3 + @credit_card = credit_card('341400000000000', month: '07', year: 2025, verification_value: '1234') + @credit_card.brand = 'american_express' + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(3, response) + end + + def test6 + @credit_card = credit_card('341400000000000', month: '07', year: 2025, verification_value: '1234') + @credit_card.brand = 'american_express' + response = @gateway.credit(@amount, @credit_card, @options) + print_result(6, response) + end + + def test4 + @credit_card = credit_card('4501161107217214', month: '07', year: 2025) + response = @gateway.credit(@amount, @credit_card, @options) + print_result(4, response) + end + + def test5 + @credit_card = credit_card('5194419000000007', month: '07', year: 2025) + @credit_card.brand = 'master' + response = @gateway.credit(@amount, @credit_card, @options) + print_result(5, response) + end + + def test7 + @credit_card = credit_card('4501161107217214', month: '07', year: 2025) + response = @gateway.authorize(@amount, @credit_card, @options) + print_result(7, response) + + capture_response = @gateway.capture(@amount, response.authorization, @options.merge(order_id: generate_unique_id[0,11])) + print_result(10, capture_response) + end + + def test8 + @credit_card = credit_card('5194419000000007', month: '07', year: 2025) + @credit_card.brand = 'master' + response = @gateway.authorize(@amount, @credit_card, @options) + print_result(8, response) + + capture_response = @gateway.capture(@amount, response.authorization, @options.merge(order_id: generate_unique_id[0,11])) + print_result(11, capture_response) + end + + def test9 + @credit_card = credit_card('341400000000000', month: '07', year: 2025, verification_value: '1234') + @credit_card.brand = 'american_express' + response = @gateway.authorize(@amount, @credit_card, @options.merge(order_id: generate_unique_id[0,11])) + print_result(9, response) + + capture_response = @gateway.capture(@amount, response.authorization, @options) + print_result(12, capture_response) + end + + def test13 + @credit_card = credit_card('4501161107217214', month: '07', year: 2025) + response = @gateway.purchase('000', @credit_card, @options) + print_result(13, response) + end + + def test14 + @credit_card = credit_card('4501161107217214', month: '07', year: 2025) + response = @gateway.purchase(-100, @credit_card, @options) + print_result(14, response) + end + + def test15 + @credit_card = credit_card('4501161107217214', month: '07', year: 2025) + response = @gateway.purchase('-1A0', @credit_card, @options) + print_result(15, response) + end + + def test16 + @credit_card = credit_card('5194419000000007', month: '07', year: 2025) + @credit_card.brand = 'visa' + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(16, response) + end + + def test17 + @credit_card = credit_card('4501161107217214', month: '07', year: 2025) + @credit_card.brand = 'master' + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(17, response) + end + + def test18 + @credit_card = credit_card('', month: '07', year: 2025) + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(18, response) + end + + def test19 + @credit_card = credit_card('4501123412341234', month: '07', year: 2025) + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(19, response) + end + + def test20 + #requires editing the model to run with a 3 digit expiration date + @credit_card = credit_card('4501161107217214', month: '07', year: 2) + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(20, response) + end + + def test21 + @credit_card = credit_card('4501161107217214', month: 17, year: 2017) + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(21, response) + end + + def test22 + @credit_card = credit_card('4501161107217214', month: '01', year: 2016) + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(22, response) + end + + def test24 + @credit_card = credit_card('4502244713161718', month: '07', year: 2025) + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(24, response) + end + + def test25 + # Needs an edit to the Model to run + @credit_card = credit_card('4501161107217214', month: '07', year: 2025) + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(25, response) + end + + def test26 + @credit_card = credit_card('4501161107217214', month: '07', year: 2025) + response = @gateway.credit('000', @credit_card, @options) + print_result(26, response) + end + + def test27 + @credit_card = credit_card('4501161107217214', month: '07', year: 2025) + response = @gateway.credit(-100, @credit_card, @options) + print_result(27, response) + end + + def test28 + @credit_card = credit_card('4501161107217214', month: '07', year: 2025) + response = @gateway.credit('-1A0', @credit_card, @options) + print_result(28, response) + end + + def test29 + @credit_card = credit_card('5194419000000007', month: '07', year: 2025) + @credit_card.brand = 'visa' + response = @gateway.credit(@amount, @credit_card, @options) + print_result(29, response) + end + + def test30 + @credit_card = credit_card('4501161107217214', month: '07', year: 2025) + @credit_card.brand = 'master' + response = @gateway.credit(@amount, @credit_card, @options) + print_result(30, response) + end + + def test31 + @credit_card = credit_card('', month: '07', year: 2025) + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(31, response) + end + + def test32 + @credit_card = credit_card('4501123412341234', month: '07', year: 2025) + response = @gateway.credit(@amount, @credit_card, @options) + print_result(32, response) + end + + def test33 + #requires edit to model to make 3 digit expiration date + @credit_card = credit_card('4501161107217214', month: '07', year: 2) + response = @gateway.credit(@amount, @credit_card, @options) + print_result(33, response) + end + + def test34 + @credit_card = credit_card('4501161107217214', month: 17, year: 2017) + response = @gateway.credit(@amount, @credit_card, @options) + print_result(34, response) + end + + def test35 + @credit_card = credit_card('4501161107217214', month: '01', year: 2016) + response = @gateway.credit(@amount, @credit_card, @options) + print_result(35, response) + end + + def test37 + @credit_card = credit_card('4502244713161718', month: '07', year: 2025) + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(37, response) + end + + def test38 + # Needs an edit to the Model to run + @credit_card = credit_card('4501161107217214', month: '07', year: 2025) + response = @gateway.purchase(@amount, @credit_card, @options) + print_result(38, response) + end + + def print_result(test_number, response) + puts "Test #{test_number} | transaction number: #{response.params['transactionNumber']}, invoice number #{response.params['invoiceNumber']}, timestamp: #{response.params['timeStamp']}, result: #{response.params['returnCode']}" + puts response.inspect + end + +end diff --git a/test/remote/gateways/remote_ct_payment_test.rb b/test/remote/gateways/remote_ct_payment_test.rb new file mode 100644 index 00000000000..43a198bd09a --- /dev/null +++ b/test/remote/gateways/remote_ct_payment_test.rb @@ -0,0 +1,173 @@ +require 'test_helper' + +class RemoteCtPaymentTest < Test::Unit::TestCase + def setup + @gateway = CtPaymentGateway.new(fixtures(:ct_payment)) + + @amount = 100 + @credit_card = credit_card('4501161107217214', month: '07', year: 2020) + @declined_card = credit_card('4502244713161718') + @options = { + billing_address: address, + description: 'Store Purchase', + order_id: generate_unique_id[0,11], + email: 'bigbird@sesamestreet.com' + + } + end + + def test_successful_purchase + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'APPROVED', response.message + end + + def test_failed_purchase + response = @gateway.purchase(@amount, @declined_card, @options) + assert_failure response + assert_equal 'Transaction declined', response.message + end + + def test_successful_authorize_and_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount, auth.authorization, @options.merge(order_id: generate_unique_id[0,11])) + assert_success capture + assert_equal 'APPROVED', capture.message + end + + def test_failed_authorize + response = @gateway.authorize(@amount, @declined_card, @options) + assert_failure response + assert_equal 'Transaction declined', response.message + end + + def test_partial_capture + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + assert capture = @gateway.capture(@amount-1, auth.authorization, @options.merge(order_id: generate_unique_id[0,11])) + assert_success capture + end + + def test_failed_capture + response = @gateway.capture(@amount, '0123456789asd;0123456789asdf;12345678', @options) + assert_failure response + assert_equal 'The original transaction number does not match any actual transaction', response.message + end + + def test_successful_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount, purchase.authorization, @options.merge(order_id: generate_unique_id[0,11])) + assert_success refund + assert_equal 'APPROVED', refund.message + end + + def test_partial_refund + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert refund = @gateway.refund(@amount-1, purchase.authorization, @options.merge(order_id: generate_unique_id[0,11])) + assert_success refund + end + + def test_failed_refund + response = @gateway.refund(@amount, '0123456789asd;0123456789asdf;12345678', @options.merge(order_id: generate_unique_id[0,11])) + assert_failure response + assert_equal 'The original transaction number does not match any actual transaction', response.message + end + + def test_successful_void + purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase + + assert void = @gateway.void(purchase.authorization) + assert_success void + assert_equal 'APPROVED', void.message + end + + def test_failed_void + response = @gateway.void('0123456789asd;0123456789asdf;12345678') + assert_failure response + assert_equal 'The original transaction number does not match any actual transaction', response.message + end + + def test_successful_credit + assert response = @gateway.credit(@amount, @credit_card, @options) + assert_success response + assert_equal 'APPROVED', response.message + end + + def test_successful_store + assert response = @gateway.store(@credit_card, @options) + + assert_success response + assert !response.authorization.split(';')[3].nil? + end + + def test_successful_purchase_using_stored_card + assert store_response = @gateway.store(@credit_card, @options) + assert_success store_response + + response = @gateway.purchase(@amount, store_response.authorization, @options) + assert_success response + assert_equal 'APPROVED', response.message + end + + def test_successful_authorize_using_stored_card + assert store_response = @gateway.store(@credit_card, @options) + assert_success store_response + + response = @gateway.authorize(@amount, store_response.authorization, @options) + assert_success response + assert_equal 'APPROVED', response.message + end + + def test_successful_verify + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_match %r{APPROVED}, response.message + end + + def test_failed_verify + response = @gateway.verify(@declined_card, @options) + assert_failure response + assert_match %r{Transaction declined}, response.message + end + + def test_invalid_login + gateway = CtPaymentGateway.new(api_key: '', company_number: '12345', merchant_number: '12345') + + response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_match %r{Invalid API KEY}, response.message + end + + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(Base64.strict_encode64(@credit_card.number), transcript) + assert_scrubbed(@gateway.options[:api_key], transcript) + end + + def test_transcript_scrubbing_store + transcript = capture_transcript(@gateway) do + @gateway.store(@credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(Base64.strict_encode64(@credit_card.number), transcript) + assert_scrubbed(@gateway.options[:api_key], transcript) + end + +end diff --git a/test/unit/gateways/ct_payment_test.rb b/test/unit/gateways/ct_payment_test.rb new file mode 100644 index 00000000000..98da844e37f --- /dev/null +++ b/test/unit/gateways/ct_payment_test.rb @@ -0,0 +1,302 @@ +require 'test_helper' + +class CtPaymentTest < Test::Unit::TestCase + def setup + @gateway = CtPaymentGateway.new(api_key: 'api_key', company_number: 'company number', merchant_number: 'merchant_number') + @credit_card = credit_card + @amount = 100 + + @options = { + order_id: '1', + billing_address: address, + description: 'Store Purchase' + } + end + + def test_successful_purchase + @gateway.expects(:ssl_post).twice.returns(successful_purchase_response, successful_ack_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + + assert_equal '000007708972;443752 ;021efc336262;;', response.authorization + assert response.test? + end + + def test_failed_purchase + @gateway.expects(:ssl_post).returns(failed_purchase_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code + end + + def test_successful_authorize + @gateway.expects(:ssl_post).twice.returns(successful_authorize_response, successful_ack_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + + assert_equal '000007708990;448572 ;0e7ebe0a804f;;', response.authorization + assert response.test? + end + + def test_failed_authorize + @gateway.expects(:ssl_post).returns(failed_authorize_response) + + response = @gateway.authorize(@amount, @credit_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code + end + + def test_successful_capture + @gateway.expects(:ssl_post).twice.returns(successful_capture_response, successful_ack_response) + + response = @gateway.capture(@amount, '000007708990;448572 ;0e7ebe0a804f;', @options) + assert_success response + + assert_equal '000007708991; ;0636aca3dd8e;;', response.authorization + assert response.test? + end + + def test_failed_capture + @gateway.expects(:ssl_post).returns(failed_capture_response) + + response = @gateway.capture(@amount, '0123456789asd;0123456789asdf;12345678', @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + end + + def test_successful_refund + @gateway.expects(:ssl_post).twice.returns(successful_refund_response, successful_ack_response) + + response = @gateway.refund(@amount, '000007708990;448572 ;0e7ebe0a804f;', @options) + assert_success response + + assert_equal '000007709004; ;0a08f144b6ea;;', response.authorization + assert response.test? + end + + def test_failed_refund + @gateway.expects(:ssl_post).returns(failed_refund_response) + + response = @gateway.capture(@amount, '0123456789asd;0123456789asdf;12345678', @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + end + + def test_successful_void + @gateway.expects(:ssl_post).returns(successful_void_response) + + response = @gateway.void('000007708990;448572 ;0e7ebe0a804f;', @options) + assert_success response + + assert_equal '000007709013; ;0de38871ce96;;', response.authorization + assert response.test? + end + + def test_failed_void + @gateway.expects(:ssl_post).returns(failed_void_response) + + response = @gateway.void('0123456789asd;0123456789asdf;12345678') + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code + end + + def test_successful_verify + @gateway.expects(:ssl_post).twice.returns(successful_verify_response, successful_ack_response) + + response = @gateway.verify(@credit_card, @options) + assert_success response + + assert_equal '000007709025; ;0b882fe35f69;;', response.authorization + assert response.test? + end + + def test_failed_verify + @gateway.expects(:ssl_post).returns(failed_verify_response) + + response = @gateway.verify(@credit_card, @options) + assert_failure response + assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code + end + + def test_successful_credit + @gateway.expects(:ssl_post).twice.returns(successful_credit_response, successful_ack_response) + + response = @gateway.credit(@amount, @credit_card, @options) + assert_success response + + assert_equal '000007709063; ;054902f2ded0;;', response.authorization + assert response.test? + end + + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + + private + + def pre_scrubbed + %q( + opening connection to test.ctpaiement.ca:443... + opened + starting SSL for test.ctpaiement.ca:443... + SSL established + <- "POST /v1/purchase HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: test.ctpaiement.ca\r\nContent-Length: 528\r\n\r\n" + <- "auth-api-key=R46SNTJ42UCJ3264182Y0T087YHBA50RTK&payload=TWVyY2hhbnRUZXJtaW5hbE51bWJlcj0gICAgICZBbW91bnQ9MDAwMDAwMDAxMDAmT3BlcmF0b3JJRD0wMDAwMDAwMCZDdXJyZW5jeUNvZGU9VVNEJkludm9pY2VOdW1iZXI9MDYzZmI1MmMyOTc2JklucHV0VHlwZT1JJkxhbmd1YWdlQ29kZT1FJkNhcmRUeXBlPVYmQ2FyZE51bWJlcj00NTAxMTYxMTA3MjE3MjE0JkV4cGlyYXRpb25EYXRlPTA3MjAmQ2FyZEhvbGRlckFkZHJlc3M9NDU2IE15IFN0cmVldE90dGF3YSAgICAgICAgICAgICAgICAgIE9OJkNhcmRIb2xkZXJQb3N0YWxDb2RlPSAgIEsxQzJONiZDdXN0b21lck51bWJlcj0wMDAwMDAwMCZDb21wYW55TnVtYmVyPTAwNTg5Jk1lcmNoYW50TnVtYmVyPTUzNDAwMDMw" + -> "HTTP/1.1 200 200\r\n" + -> "Date: Fri, 29 Jun 2018 18:21:07 GMT\r\n" + -> "Server: Apache\r\n" + -> "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n" + -> "Connection: close\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Content-Type: application/json;charset=ISO-8859-1\r\n" + -> "\r\n" + -> "480\r\n" + reading 1152 bytes... + -> "{\"returnCode\":\" 00\",\"errorDescription\":null,\"authorizationNumber\":\"448186 \",\"referenceNumber\":\" \",\"transactionNumber\":\"000007709037\",\"batchNumber\":\"0001\",\"terminalNumber\":\"13366\",\"serverNumber\":\"0001\",\"timeStamp\":\"20180629-14210749\",\"trxCode\":\"00\",\"merchantNumber\":\"53400030\",\"amount\":\"00000000100\",\"invoiceNumber\":\"063fb52c2976\",\"trxType\":\"C\",\"cardType\":\"V\",\"cardNumber\":\"450116XXXXXX7214 \",\"expirationDate\":\"0720\",\"bankTerminalNumber\":\"53400188\",\"trxDate\":\"06292018\",\"trxTime\":\"142107\",\"accountType\":\"0\",\"trxMethod\":\"T@1\",\"languageCode\":\"E\",\"sequenceNumber\":\"000000000028\",\"receiptDisp\":\" APPROVED-THANK YOU \",\"terminalDisp\":\"APPROVED \",\"operatorId\":\"00000000\",\"surchargeAmount\":\"\",\"companyNumber\":\"00589\",\"secureID\":\"\",\"cvv2Cvc2Status\":\" \",\"iopIssuerConfirmationNumber\":null,\"iopIssuerName\":null,\"avsStatus\":null,\"holderName\":null,\"threeDSStatus\":null,\"emvLabel\":null,\"emvAID\":null,\"emvTVR\":null,\"emvTSI\":null,\"emvTC\":null,\"demoMode\":null,\"terminalInvoiceNumber\":null,\"cashbackAmount\":null,\"tipAmount\":null,\"taxAmount\":null,\"cvmResults\":null,\"token\":null,\"customerNumber\":null,\"email\":\"\"}" + read 1152 bytes + reading 2 bytes... + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + opening connection to test.ctpaiement.ca:443... + opened + starting SSL for test.ctpaiement.ca:443... + SSL established + <- "POST /v1/ack HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: test.ctpaiement.ca\r\nContent-Length: 156\r\n\r\n" + <- "auth-api-key=R46SNTJ42UCJ3264182Y0T087YHBA50RTK&payload=VHJhbnNhY3Rpb25OdW1iZXI9MDAwMDA3NzA5MDM3JkNvbXBhbnlOdW1iZXI9MDA1ODkmTWVyY2hhbnROdW1iZXI9NTM0MDAwMzA=" + -> "HTTP/1.1 200 200\r\n" + -> "Date: Fri, 29 Jun 2018 18:21:08 GMT\r\n" + -> "Server: Apache\r\n" + -> "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n" + -> "Connection: close\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Content-Type: application/json;charset=ISO-8859-1\r\n" + -> "\r\n" + -> "15\r\n" + reading 21 bytes... + -> "{\"returnCode\":\"true\"}" + read 21 bytes + reading 2 bytes... + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + ) + end + + def post_scrubbed + %q( + opening connection to test.ctpaiement.ca:443... + opened + starting SSL for test.ctpaiement.ca:443... + SSL established + <- "POST /v1/purchase HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: test.ctpaiement.ca\r\nContent-Length: 528\r\n\r\n" + <- "auth-api-key=[FILTERED]&payload=[FILTERED]" + -> "HTTP/1.1 200 200\r\n" + -> "Date: Fri, 29 Jun 2018 18:21:07 GMT\r\n" + -> "Server: Apache\r\n" + -> "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n" + -> "Connection: close\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Content-Type: application/json;charset=ISO-8859-1\r\n" + -> "\r\n" + -> "480\r\n" + reading 1152 bytes... + -> "{\"returnCode\":\" 00\",\"errorDescription\":null,\"authorizationNumber\":\"448186 \",\"referenceNumber\":\" \",\"transactionNumber\":\"000007709037\",\"batchNumber\":\"0001\",\"terminalNumber\":\"13366\",\"serverNumber\":\"0001\",\"timeStamp\":\"20180629-14210749\",\"trxCode\":\"00\",\"merchantNumber\":\"53400030\",\"amount\":\"00000000100\",\"invoiceNumber\":\"063fb52c2976\",\"trxType\":\"C\",\"cardType\":\"V\",\"cardNumber\":\"450116XXXXXX7214 \",\"expirationDate\":\"0720\",\"bankTerminalNumber\":\"53400188\",\"trxDate\":\"06292018\",\"trxTime\":\"142107\",\"accountType\":\"0\",\"trxMethod\":\"T@1\",\"languageCode\":\"E\",\"sequenceNumber\":\"000000000028\",\"receiptDisp\":\" APPROVED-THANK YOU \",\"terminalDisp\":\"APPROVED \",\"operatorId\":\"00000000\",\"surchargeAmount\":\"\",\"companyNumber\":\"00589\",\"secureID\":\"\",\"cvv2Cvc2Status\":\" \",\"iopIssuerConfirmationNumber\":null,\"iopIssuerName\":null,\"avsStatus\":null,\"holderName\":null,\"threeDSStatus\":null,\"emvLabel\":null,\"emvAID\":null,\"emvTVR\":null,\"emvTSI\":null,\"emvTC\":null,\"demoMode\":null,\"terminalInvoiceNumber\":null,\"cashbackAmount\":null,\"tipAmount\":null,\"taxAmount\":null,\"cvmResults\":null,\"token\":null,\"customerNumber\":null,\"email\":\"\"}" + read 1152 bytes + reading 2 bytes... + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + opening connection to test.ctpaiement.ca:443... + opened + starting SSL for test.ctpaiement.ca:443... + SSL established + <- "POST /v1/ack HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: test.ctpaiement.ca\r\nContent-Length: 156\r\n\r\n" + <- "auth-api-key=[FILTERED]&payload=[FILTERED]" + -> "HTTP/1.1 200 200\r\n" + -> "Date: Fri, 29 Jun 2018 18:21:08 GMT\r\n" + -> "Server: Apache\r\n" + -> "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n" + -> "Connection: close\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Content-Type: application/json;charset=ISO-8859-1\r\n" + -> "\r\n" + -> "15\r\n" + reading 21 bytes... + -> "{\"returnCode\":\"true\"}" + read 21 bytes + reading 2 bytes... + -> "\r\n" + read 2 bytes + -> "0\r\n" + -> "\r\n" + Conn close + ) + end + + def successful_purchase_response + '{"returnCode":" 00","errorDescription":null,"authorizationNumber":"443752 ","referenceNumber":" ","transactionNumber":"000007708972","batchNumber":"0001","terminalNumber":"13366","serverNumber":"0001","timeStamp":"20180629-12110905","trxCode":"00","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"021efc336262","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214 ","expirationDate":"0720","bankTerminalNumber":"53400188","trxDate":"06292018","trxTime":"121109","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000008","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}' + end + + def successful_ack_response + '{"returnCode":"true"}' + end + + def failed_purchase_response + '{"returnCode":" 05","errorDescription":"Transaction declined","authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007708975","batchNumber":"0000","terminalNumber":"13366","serverNumber":"0001","timeStamp":"20180629-12272768","trxCode":"00","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"098096b31937","trxType":"C","cardType":"V","cardNumber":"450224XXXXXX1718 ","expirationDate":"0919","bankTerminalNumber":"53400188","trxDate":"06292018","trxTime":"122727","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000009","receiptDisp":" TRANSACTION NOT APPROVED ","terminalDisp":"05-DECLINE ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}' + end + + def successful_authorize_response + '{"returnCode":" 00","errorDescription":null,"authorizationNumber":"448572 ","referenceNumber":" ","transactionNumber":"000007708990","batchNumber":"0001","terminalNumber":"13367","serverNumber":"0001","timeStamp":"20180629-12501747","trxCode":"01","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"0e7ebe0a804f","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214 ","expirationDate":"0720","bankTerminalNumber":"53400189","trxDate":"06292018","trxTime":"125017","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000014","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}' + end + + def failed_authorize_response + '{"returnCode":" 05","errorDescription":"Transaction declined","authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007708993","batchNumber":"0000","terminalNumber":"13367","serverNumber":"0001","timeStamp":"20180629-13072751","trxCode":"01","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"02ec22cbb5db","trxType":"C","cardType":"V","cardNumber":"450224XXXXXX1718 ","expirationDate":"0919","bankTerminalNumber":"53400189","trxDate":"06292018","trxTime":"130727","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000015","receiptDisp":" TRANSACTION NOT APPROVED ","terminalDisp":"05-DECLINE ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}' + end + + def successful_capture_response + '{"returnCode":" 00","errorDescription":null,"authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007708991","batchNumber":"0001","terminalNumber":"13366","serverNumber":"0001","timeStamp":"20180629-12501869","trxCode":"02","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"0636aca3dd8e","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214 ","expirationDate":"0720","bankTerminalNumber":"53400188","trxDate":"06292018","trxTime":"125018","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000015","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}' + end + + def failed_capture_response + '{"returnCode":"9068","errorDescription":"The original transaction number does not match any actual transaction","authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007708999","batchNumber":" ","terminalNumber":" ","serverNumber":" ","timeStamp":"20180629-13224441","trxCode":" ","merchantNumber":" ","amount":"00000000000","invoiceNumber":" ","trxType":" ","cardType":" ","cardNumber":" ","expirationDate":" ","bankTerminalNumber":" ","trxDate":" ","trxTime":" ","accountType":" ","trxMethod":" ","languageCode":" ","sequenceNumber":" ","receiptDisp":" OPERATION NON COMPLETEE ","terminalDisp":"9068: Contactez support.","operatorId":" ","surchargeAmount":" ","companyNumber":" ","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}' + end + + def successful_refund_response + ' {"returnCode":" 00","errorDescription":null,"authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007709004","batchNumber":"0001","terminalNumber":"13367","serverNumber":"0001","timeStamp":"20180629-13294388","trxCode":"03","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"0a08f144b6ea","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214 ","expirationDate":"0720","bankTerminalNumber":"53400189","trxDate":"06292018","trxTime":"132944","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000019","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}' + end + + def failed_refund_response + '{"returnCode":"9068","errorDescription":"The original transaction number does not match any actual transaction","authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007709009","batchNumber":" ","terminalNumber":" ","serverNumber":" ","timeStamp":"20180629-13402119","trxCode":" ","merchantNumber":" ","amount":"00000000000","invoiceNumber":" ","trxType":" ","cardType":" ","cardNumber":" ","expirationDate":" ","bankTerminalNumber":" ","trxDate":" ","trxTime":" ","accountType":" ","trxMethod":" ","languageCode":" ","sequenceNumber":" ","receiptDisp":" OPERATION NON COMPLETEE ","terminalDisp":"9068: Contactez support.","operatorId":" ","surchargeAmount":" ","companyNumber":" ","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}' + end + + def successful_void_response + '{"returnCode":" 00","errorDescription":null,"authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007709013","batchNumber":"0001","terminalNumber":"13367","serverNumber":"0001","timeStamp":"20180629-13451840","trxCode":"04","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"0de38871ce96","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214","expirationDate":"0720","bankTerminalNumber":"53400189","trxDate":"06292018","trxTime":"134518","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000023","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":" ","companyNumber":" ","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}' + end + + def failed_void_response + '{"returnCode":"9068","errorDescription":"The original transaction number does not match any actual transaction","authorizationNumber":" ","referenceNumber":" ","transactionNumber":"0000000000-1","batchNumber":" ","terminalNumber":" ","serverNumber":" ","timeStamp":"20180629-13520693","trxCode":" ","merchantNumber":" ","amount":"00000000000","invoiceNumber":" ","trxType":" ","cardType":" ","cardNumber":" ","expirationDate":" ","bankTerminalNumber":" ","trxDate":" ","trxTime":" ","accountType":" ","trxMethod":" ","languageCode":" ","sequenceNumber":" ","receiptDisp":" OPERATION NOT COMPLETED ","terminalDisp":"9068: Contact support. ","operatorId":" ","surchargeAmount":" ","companyNumber":" ","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}' + end + + def successful_verify_response + '{"returnCode":" 00","errorDescription":null,"authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007709025","batchNumber":"0001","terminalNumber":"13367","serverNumber":"0001","timeStamp":"20180629-14023575","trxCode":"08","merchantNumber":"53400030","amount":"00000000000","invoiceNumber":"0b882fe35f69","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214 ","expirationDate":"0720","bankTerminalNumber":"53400189","trxDate":"06292018","trxTime":"140236","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000025","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}' + end + + def failed_verify_response + '{"returnCode":" 05","errorDescription":"Transaction declined","authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007709029","batchNumber":"0000","terminalNumber":"13367","serverNumber":"0001","timeStamp":"20180629-14104707","trxCode":"08","merchantNumber":"53400030","amount":"00000000000","invoiceNumber":"0c0054d2bb7a","trxType":"C","cardType":"V","cardNumber":"450224XXXXXX1718 ","expirationDate":"0919","bankTerminalNumber":"53400189","trxDate":"06292018","trxTime":"141047","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000026","receiptDisp":" TRANSACTION NOT APPROVED ","terminalDisp":"05-DECLINE ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}' + end + + def successful_credit_response + '{"returnCode":" 00","errorDescription":null,"authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007709063","batchNumber":"0001","terminalNumber":"13366","serverNumber":"0001","timeStamp":"20180629-14420931","trxCode":"03","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"054902f2ded0","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214 ","expirationDate":"0720","bankTerminalNumber":"53400188","trxDate":"06292018","trxTime":"144209","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000032","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}' + end +end From 44bdbd98bea484c2e0671c1e535392c260e357ae Mon Sep 17 00:00:00 2001 From: Bart <bart.dewater@shopify.com> Date: Tue, 10 Jul 2018 10:31:08 -0400 Subject: [PATCH 474/677] Update contributing document regarding gateways [ci skip] --- CONTRIBUTING.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7d7989b171d..c9ce8e449ea 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,10 +1,16 @@ # Contributing guidelines -We gladly accept bugfixes and new gateways. Please follow the guidelines here to ensure your work is accepted. +We gladly accept bugfixes, but are not actively looking to add new gateways. Please follow the guidelines here to ensure your work is accepted. ## New Gateways -Please see the [ActiveMerchant Guide to Contributing a new Gateway](https://github.com/activemerchant/active_merchant/wiki/contributing) for information on adding a new gateway to ActiveMerchant. +We're not taking on many new gateways at the moment. The team maintaining ActiveMerchant is small and with the limited resources available, we generally prefer not to support a gateway than to support a gateway poorly. + +Please see the [ActiveMerchant Guide to Contributing a new Gateway](https://github.com/activemerchant/active_merchant/wiki/contributing) for information on creating a new gateway. You can place your gateway code in your application's `lib/active_merchant/billing` folder to use it. + +We would like to work with the community to figure out how gateways can release and maintain their integrations outside of the the ActiveMerchant repository. Please join [the discussion](https://github.com/activemerchant/active_merchant/issues/2923) if you're interested or have ideas. + +Gateway placement within Shopify is available by invitation only at this time. ## Issues & Bugfixes @@ -25,10 +31,6 @@ When submitting a pull request to resolve an issue: 4. Push your changes to your fork (`git push origin my_awesome_feature`) 5. Open a [Pull Request](https://github.com/activemerchant/active_merchant/pulls) -## Gateway Placement within Shopify - -Placement within Shopify is available by invitation only at this time. - ## Version/Release Management Contributors don't need to worry about versions, this is something Committers do at important milestones: From 90b6b18c1324f69a591a51db1216207afc18111b Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 11 Jul 2018 08:24:15 -0400 Subject: [PATCH 475/677] Do not care about test module/class lengths This is counterproductive when it comes to tests. --- .rubocop.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 80efd64708b..f6b1bee81b2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -16,3 +16,12 @@ AllCops: - "vendor/**/*" ExtraDetails: false TargetRubyVersion: 2.3 + +# Limiting module/class lengths in specs is counterproductive +Metrics/ClassLength: + Exclude: + - 'test/**/*' + +Metrics/ModuleLength: + Exclude: + - 'test/**/*' From 8c254bb4faf022d016e060490a304a41f1947e0c Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 10 Jul 2018 16:44:51 -0400 Subject: [PATCH 476/677] ANET: Expose full response code Closes #2924 Remote: 67 tests, 230 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 92 tests, 525 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/authorize_net.rb | 4 ++++ test/remote/gateways/remote_authorize_net_test.rb | 1 + test/unit/gateways/authorize_net_test.rb | 1 + 4 files changed, 7 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 44097274cb2..b69d679062e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Pin Payments: Pass reference for statement desc [curiousepic] #2919 * FirstData: introduce v27 gateway [shasum] #2912 * Stripe: Fix contactless magstripe support [abhiin1947] #2917 +* ANET: Expose full response code [curiousepic] #2924 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index 5db6708cb7e..12df74d02bc 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -863,6 +863,10 @@ def parse_normal(action, body) (empty?(element.content) ? nil : element.content) end + response[:full_response_code] = if(element = doc.at_xpath('//messages/message/code')) + (empty?(element.content) ? nil : element.content) + end + response end diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb index af48e65a4b5..57b24453e07 100644 --- a/test/remote/gateways/remote_authorize_net_test.rb +++ b/test/remote/gateways/remote_authorize_net_test.rb @@ -525,6 +525,7 @@ def test_bad_login avs_result_code card_code cardholder_authentication_code + full_response_code response_code response_reason_code response_reason_text diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 9b3516bb25d..3c7eac296e5 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -262,6 +262,7 @@ def test_successful_authorization assert_equal 'M', response.cvv_result['code'] assert_equal 'CVV matches', response.cvv_result['message'] + assert_equal 'I00001', response.params['full_response_code'] assert_equal '508141794', response.authorization.split('#')[0] assert response.test? From f20dfab46920874a9317643bd2392437421106f4 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 11 Jul 2018 12:23:29 -0400 Subject: [PATCH 477/677] Remove redundancy in Gemfiles --- Gemfile.rails42 | 11 +---------- Gemfile.rails50 | 11 +---------- Gemfile.rails51 | 11 +---------- Gemfile.rails52 | 11 +---------- 4 files changed, 4 insertions(+), 40 deletions(-) diff --git a/Gemfile.rails42 b/Gemfile.rails42 index 890b340923a..037e7c6a80c 100644 --- a/Gemfile.rails42 +++ b/Gemfile.rails42 @@ -1,12 +1,3 @@ -source 'https://rubygems.org' -gemspec - -gem 'jruby-openssl', :platforms => :jruby -gem 'rubocop', '~> 0.57.2', require: false - -group :test, :remote_test do - # gateway-specific dependencies, keeping these gems out of the gemspec - gem 'braintree', '>= 2.50.0' -end +eval File.read('Gemfile') gem 'activesupport', '~> 4.2.0' diff --git a/Gemfile.rails50 b/Gemfile.rails50 index c014f53a18e..9512083b540 100644 --- a/Gemfile.rails50 +++ b/Gemfile.rails50 @@ -1,12 +1,3 @@ -source 'https://rubygems.org' -gemspec - -gem 'jruby-openssl', :platforms => :jruby -gem 'rubocop', '~> 0.57.2', require: false - -group :test, :remote_test do - # gateway-specific dependencies, keeping these gems out of the gemspec - gem 'braintree', '>= 2.50.0' -end +eval File.read('Gemfile') gem 'activesupport', '~> 5.0.0' diff --git a/Gemfile.rails51 b/Gemfile.rails51 index c83abf0b54b..eee047fc94e 100644 --- a/Gemfile.rails51 +++ b/Gemfile.rails51 @@ -1,12 +1,3 @@ -source 'https://rubygems.org' -gemspec - -gem 'jruby-openssl', :platforms => :jruby -gem 'rubocop', '~> 0.57.2', require: false - -group :test, :remote_test do - # gateway-specific dependencies, keeping these gems out of the gemspec - gem 'braintree', '>= 2.50.0' -end +eval File.read('Gemfile') gem 'activesupport', '~> 5.1.0' diff --git a/Gemfile.rails52 b/Gemfile.rails52 index cf1a88c3011..c078c3f1a89 100644 --- a/Gemfile.rails52 +++ b/Gemfile.rails52 @@ -1,12 +1,3 @@ -source 'https://rubygems.org' -gemspec - -gem 'jruby-openssl', :platforms => :jruby -gem 'rubocop', '~> 0.57.2', require: false - -group :test, :remote_test do - # gateway-specific dependencies, keeping these gems out of the gemspec - gem 'braintree', '>= 2.50.0' -end +eval File.read('Gemfile') gem 'activesupport', '~> 5.2.0.rc1' From cc8585cfa0b3878965f09634cdf2ece71ba48d4c Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 11 Jul 2018 12:28:03 -0400 Subject: [PATCH 478/677] Run RuboCop only once, as a separate step --- .travis.yml | 7 ++++--- Rakefile | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 726411a1e7e..a4c02349ad8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,11 @@ gemfile: - Gemfile.rails50 - Gemfile.rails42 -matrix: +jobs: include: - - rvm: 2.3 - gemfile: Gemfile.rails42 + rvm: 2.5 + gemfile: Gemfile + script: bundle exec rubocop --parallel notifications: email: diff --git a/Rakefile b/Rakefile index 1aa5657c126..5e92782a541 100644 --- a/Rakefile +++ b/Rakefile @@ -24,7 +24,7 @@ task :tag_release do end desc 'Run the unit test suite' -task :default => 'test:local' +task :default => 'test:units' task :test => 'test:units' RuboCop::RakeTask.new From 0626f13ca8a651641627f1333a10ea873d0a1d21 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 11 Jul 2018 12:40:11 -0400 Subject: [PATCH 479/677] Upgrade RuboCop to 0.58.1 This *almost* allows PayPal to be re-added, but some upstream bugs in the parser gem still prevent that being a go. Fixes a new issue found in Mercury as well. --- Gemfile | 2 +- lib/active_merchant/billing/gateways/mercury.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 6e287b04095..8fe123d5eb8 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' gemspec gem 'jruby-openssl', :platforms => :jruby -gem 'rubocop', '~> 0.57.2', require: false +gem 'rubocop', '~> 0.58.1', require: false group :test, :remote_test do # gateway-specific dependencies, keeping these gems out of the gemspec diff --git a/lib/active_merchant/billing/gateways/mercury.rb b/lib/active_merchant/billing/gateways/mercury.rb index 54f51af876c..090ffaad3f1 100644 --- a/lib/active_merchant/billing/gateways/mercury.rb +++ b/lib/active_merchant/billing/gateways/mercury.rb @@ -103,7 +103,7 @@ def build_non_authorized_request(action, money, credit_card, options) xml.tag! 'Transaction' do xml.tag! 'TranType', 'Credit' xml.tag! 'TranCode', action - if options[:allow_partial_auth] && (action == 'PreAuth' || action == 'Sale') + if options[:allow_partial_auth] && ['PreAuth', 'Sale'].include?(action) xml.tag! 'PartialAuth', 'Allow' end add_invoice(xml, options[:order_id], nil, options) From c68c60cd9107ac7ed315cbc7d8d3eedf30e3018c Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Wed, 11 Jul 2018 15:52:01 -0400 Subject: [PATCH 480/677] Global Collect: Fix customer data field structure Previously, many customer data fields were not being properly placed in the customer envelope. Closes #2929 Remote: 16 tests, 37 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 17 tests, 78 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/global_collect.rb | 12 ++++-------- test/unit/gateways/global_collect_test.rb | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b69d679062e..4a22fa8d964 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * FirstData: introduce v27 gateway [shasum] #2912 * Stripe: Fix contactless magstripe support [abhiin1947] #2917 * ANET: Expose full response code [curiousepic] #2924 +* Global Collect: Fix customer data field structure [curiousepic] #2929 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 1152f495e56..2bd27df7aed 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -140,9 +140,6 @@ def add_payment(post, payment, options) end def add_customer_data(post, options, payment = nil) - post['order']['customer'] = { - 'merchantCustomerId' => options[:customer] - } if payment post['order']['customer']['personalInformation'] = { 'name' => { @@ -151,12 +148,11 @@ def add_customer_data(post, options, payment = nil) } } end - post['order']['companyInformation'] = { - 'name' => options[:company] - } - post['order']['contactDetails']['emailAddress'] = options[:email] if options[:email] + post['order']['customer']['merchantCustomerId'] = options[:customer] if options[:customer] + post['order']['customer']['companyInformation']['name'] = options[:company] if options[:company] + post['order']['customer']['contactDetails']['emailAddress'] = options[:email] if options[:email] if address = options[:billing_address] || options[:address] - post['order']['contactDetails']['phoneNumber'] = address[:phone] if address[:phone] + post['order']['customer']['contactDetails']['phoneNumber'] = address[:phone] if address[:phone] end end diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb index 605e1aa0563..5a5c7df22c4 100644 --- a/test/unit/gateways/global_collect_test.rb +++ b/test/unit/gateways/global_collect_test.rb @@ -68,6 +68,7 @@ def test_authorize_without_pre_authorization_flag def test_successful_authorization_with_extra_options options = @options.merge( { + customer: '123987', email: 'example@example.com', order_id: '123', ip: '127.0.0.1', @@ -84,8 +85,7 @@ def test_successful_authorization_with_extra_options end.check_request do |endpoint, data, headers| assert_match %r("fraudFields":{"website":"www.example.com","giftMessage":"Happy Day!","customerIpAddress":"127.0.0.1"}), data assert_match %r("merchantReference":"123"), data - assert_match %r("emailAddress":"example@example.com"), data - assert_match %r("phoneNumber":"\(555\)555-5555"), data + assert_match %r("customer":{"personalInformation":{"name":{"firstName":"Longbob","surname":"Longsen"}},"merchantCustomerId":"123987","contactDetails":{"emailAddress":"example@example.com","phoneNumber":"\(555\)555-5555"},"billingAddress":{"street":"456 My Street","additionalInfo":"Apt 1","zip":"K1C2N6","city":"Ottawa","state":"ON","countryCode":"CA"}}}), data end.respond_with(successful_authorize_response) assert_success response From ccb7de63403d588cfcc742e32c245158c2da8d17 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Wed, 11 Jul 2018 22:55:48 -0400 Subject: [PATCH 481/677] Adyen: Set Default Name for Apple Pay Transactions Name is required for Adyen but not always paseed on Apple Pay transactions. This creates the default name place holder of `Not Provided` on apply pay transactions. Updates one remote test with new message. Loaded suite test/unit/gateways/adyen_test ...................... 22 tests, 101 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_adyen_test Started .................................. 34 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 1 + test/remote/gateways/remote_adyen_test.rb | 2 +- test/unit/gateways/adyen_test.rb | 11 +++++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 4a22fa8d964..4e135584118 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * Stripe: Fix contactless magstripe support [abhiin1947] #2917 * ANET: Expose full response code [curiousepic] #2924 * Global Collect: Fix customer data field structure [curiousepic] #2929 +* Adyen: Set Default Name for Apple Pay Transactions [nfarve] #2930 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index afea91c45ee..6a118616b63 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -179,6 +179,7 @@ def add_card(post, credit_card) } card.delete_if{|k,v| v.blank? } + card[:holderName] ||= 'Not Provided' if credit_card.is_a?(NetworkTokenizationCreditCard) requires!(card, :expiryMonth, :expiryYear, :holderName, :number) post[:card] = card end diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb index a5d646f182b..e4f752d2260 100644 --- a/test/remote/gateways/remote_adyen_test.rb +++ b/test/remote/gateways/remote_adyen_test.rb @@ -233,7 +233,7 @@ def test_invalid_expiry_month_for_purchase card = credit_card('4242424242424242', month: 16) assert response = @gateway.purchase(@amount, card, @options) assert_failure response - assert_equal 'Expiry month should be between 1 and 12 inclusive', response.message + assert_equal 'Expiry Date Invalid: Expiry month should be between 1 and 12 inclusive', response.message end def test_invalid_expiry_year_for_purchase diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index c0e0f69b3d5..e9f7753b76f 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -220,6 +220,17 @@ def test_add_address assert_equal @options[:billing_address][:country], post[:card][:billingAddress][:country] end + def test_authorize_with_network_tokenization_credit_card_no_name + @apple_pay_card.first_name = nil + @apple_pay_card.last_name = nil + response = stub_comms do + @gateway.authorize(@amount, @apple_pay_card, @options) + end.check_request do |endpoint, data, headers| + assert_equal 'Not Provided', JSON.parse(data)['card']['holderName'] + end.respond_with(successful_authorize_response) + assert_success response + end + def test_authorize_with_network_tokenization_credit_card response = stub_comms do @gateway.authorize(@amount, @apple_pay_card, @options) From dde5ab42d5c9d59f8b1e2ca805d8baa7017260ed Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 13 Jul 2018 16:52:48 -0400 Subject: [PATCH 482/677] Use eval_gemfile for nested Gemfiles This also allows moving the only-used-by-Travis Gemfiles into their own directory. Hat-tip @varyonic for the suggestion. --- .travis.yml | 8 ++++---- Gemfile.rails42 => gemfiles/Gemfile.rails42 | 2 +- Gemfile.rails50 => gemfiles/Gemfile.rails50 | 2 +- Gemfile.rails51 => gemfiles/Gemfile.rails51 | 2 +- Gemfile.rails52 => gemfiles/Gemfile.rails52 | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) rename Gemfile.rails42 => gemfiles/Gemfile.rails42 (55%) rename Gemfile.rails50 => gemfiles/Gemfile.rails50 (55%) rename Gemfile.rails51 => gemfiles/Gemfile.rails51 (55%) rename Gemfile.rails52 => gemfiles/Gemfile.rails52 (58%) diff --git a/.travis.yml b/.travis.yml index a4c02349ad8..68ff33a3358 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,10 @@ rvm: - 2.3 gemfile: -- Gemfile.rails52 -- Gemfile.rails51 -- Gemfile.rails50 -- Gemfile.rails42 +- gemfiles/Gemfile.rails52 +- gemfiles/Gemfile.rails51 +- gemfiles/Gemfile.rails50 +- gemfiles/Gemfile.rails42 jobs: include: diff --git a/Gemfile.rails42 b/gemfiles/Gemfile.rails42 similarity index 55% rename from Gemfile.rails42 rename to gemfiles/Gemfile.rails42 index 037e7c6a80c..8d11bec617c 100644 --- a/Gemfile.rails42 +++ b/gemfiles/Gemfile.rails42 @@ -1,3 +1,3 @@ -eval File.read('Gemfile') +eval_gemfile '../Gemfile' gem 'activesupport', '~> 4.2.0' diff --git a/Gemfile.rails50 b/gemfiles/Gemfile.rails50 similarity index 55% rename from Gemfile.rails50 rename to gemfiles/Gemfile.rails50 index 9512083b540..ce57bebccbe 100644 --- a/Gemfile.rails50 +++ b/gemfiles/Gemfile.rails50 @@ -1,3 +1,3 @@ -eval File.read('Gemfile') +eval_gemfile '../Gemfile' gem 'activesupport', '~> 5.0.0' diff --git a/Gemfile.rails51 b/gemfiles/Gemfile.rails51 similarity index 55% rename from Gemfile.rails51 rename to gemfiles/Gemfile.rails51 index eee047fc94e..a352b24eaa8 100644 --- a/Gemfile.rails51 +++ b/gemfiles/Gemfile.rails51 @@ -1,3 +1,3 @@ -eval File.read('Gemfile') +eval_gemfile '../Gemfile' gem 'activesupport', '~> 5.1.0' diff --git a/Gemfile.rails52 b/gemfiles/Gemfile.rails52 similarity index 58% rename from Gemfile.rails52 rename to gemfiles/Gemfile.rails52 index c078c3f1a89..c6c439fce53 100644 --- a/Gemfile.rails52 +++ b/gemfiles/Gemfile.rails52 @@ -1,3 +1,3 @@ -eval File.read('Gemfile') +eval_gemfile '../Gemfile' gem 'activesupport', '~> 5.2.0.rc1' From eb77de8230da22fcf55bc4621e2e00236f738558 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 17 Jul 2018 12:33:28 -0400 Subject: [PATCH 483/677] Disable Metrics/ClassLength and ModuleLength These are great restrictions in theory, but the running design pattern in our gateways means that basically *all* of them violate these rules. Given most of the tests do also, let's just kill these entirely. --- .rubocop.yml | 8 +++----- .rubocop_todo.yml | 10 ---------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f6b1bee81b2..bf6cd8ae418 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -17,11 +17,9 @@ AllCops: ExtraDetails: false TargetRubyVersion: 2.3 -# Limiting module/class lengths in specs is counterproductive +# Active Merchant gateways are not amenable to length restrictions Metrics/ClassLength: - Exclude: - - 'test/**/*' + Enabled: false Metrics/ModuleLength: - Exclude: - - 'test/**/*' + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2a376ba8a24..35c175ad580 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -642,11 +642,6 @@ Metrics/BlockLength: Metrics/BlockNesting: Max: 6 -# Offense count: 489 -# Configuration parameters: CountComments. -Metrics/ClassLength: - Max: 2135 - # Offense count: 175 Metrics/CyclomaticComplexity: Max: 36 @@ -656,11 +651,6 @@ Metrics/CyclomaticComplexity: Metrics/MethodLength: Max: 163 -# Offense count: 5 -# Configuration parameters: CountComments. -Metrics/ModuleLength: - Max: 383 - # Offense count: 2 # Configuration parameters: CountKeywordArgs. Metrics/ParameterLists: From 4719cb2ca0df449428a227fe05d330eaf42f114a Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Tue, 17 Jul 2018 11:12:06 -0400 Subject: [PATCH 484/677] Beanstream: Update to use api key with login credentials Beanstream is requiring that users that connect via username and password also supply a api key. 2 echeck tests are failing unrelated to this change. Loaded suite test/remote/gateways/remote_beanstream_test 41 tests, 185 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 95.122% passed Loaded suite test/unit/gateways/beanstream_test 23 tests, 108 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/beanstream.rb | 1 + .../billing/gateways/beanstream/beanstream_core.rb | 3 +-- test/fixtures.yml | 1 + test/remote/gateways/remote_beanstream_test.rb | 1 + test/unit/gateways/beanstream_test.rb | 3 ++- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/active_merchant/billing/gateways/beanstream.rb b/lib/active_merchant/billing/gateways/beanstream.rb index e86e21d60a5..3530ddfd167 100644 --- a/lib/active_merchant/billing/gateways/beanstream.rb +++ b/lib/active_merchant/billing/gateways/beanstream.rb @@ -199,6 +199,7 @@ def scrub(transcript) transcript. gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). gsub(/(&?password=)[^&\s]*(&?)/, '\1[FILTERED]\2'). + gsub(/(&?passcode=)[^&\s]*(&?)/, '\1[FILTERED]\2'). gsub(/(&?trnCardCvd=)\d*(&?)/, '\1[FILTERED]\2'). gsub(/(&?trnCardNumber=)\d*(&?)/, '\1[FILTERED]\2') end diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index f6d8ba851d3..3a8a36fc8de 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -156,7 +156,6 @@ def initialize(options = {}) def capture(money, authorization, options = {}) reference, _, _ = split_auth(authorization) - post = {} add_amount(post, money) add_reference(post, reference) @@ -313,7 +312,6 @@ def add_secure_profile_variables(post, options = {}) post[:serviceVersion] = SP_SERVICE_VERSION post[:responseFormat] = 'QS' post[:cardValidation] = (options[:cardValidation].to_i == 1) || '0' - post[:operationType] = options[:operationType] || options[:operation] || secure_profile_action(:new) post[:customerCode] = options[:billing_id] || options[:vault_id] || false post[:status] = options[:status] @@ -462,6 +460,7 @@ def post_data(params, use_profile_api) params[:username] = @options[:user] if @options[:user] params[:password] = @options[:password] if @options[:password] params[:merchant_id] = @options[:login] + params[:passcode] = @options[:api_key] end params[:vbvEnabled] = '0' params[:scEnabled] = '0' diff --git a/test/fixtures.yml b/test/fixtures.yml index d7775b0ef28..d5dc2626ca6 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -67,6 +67,7 @@ beanstream: password: password secure_profile_api_key: API Access Passcode recurring_api_key: API Access Passcode + api_key: API KEY beanstream_interac: login: merchant id diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb index 0002e292bc8..67abd08ff7d 100644 --- a/test/remote/gateways/remote_beanstream_test.rb +++ b/test/remote/gateways/remote_beanstream_test.rb @@ -384,6 +384,7 @@ def test_transcript_scrubbing assert_scrubbed(@visa.number, clean_transcript) assert_scrubbed(@visa.verification_value.to_s, clean_transcript) assert_scrubbed(@gateway.options[:password], clean_transcript) + assert_scrubbed(@gateway.options[:api_key], clean_transcript) end private diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb index be07b0c9e4a..37787acfc7c 100644 --- a/test/unit/gateways/beanstream_test.rb +++ b/test/unit/gateways/beanstream_test.rb @@ -9,7 +9,8 @@ def setup @gateway = BeanstreamGateway.new( :login => 'merchant id', :user => 'username', - :password => 'password' + :password => 'password', + :api_key => 'api_key' ) @credit_card = credit_card From 959101179fa6a1ae399b316256f398ac31fa95e5 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Tue, 17 Jul 2018 14:59:24 -0400 Subject: [PATCH 485/677] Changelog update Update changelog for #2934 --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 4e135584118..8bb42ae7018 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * ANET: Expose full response code [curiousepic] #2924 * Global Collect: Fix customer data field structure [curiousepic] #2929 * Adyen: Set Default Name for Apple Pay Transactions [nfarve] #2930 +* Beanstream: Update to use api key with login credentials [nfarve] #2934 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 From d3a64ec053fd39fd56b702d063a5e371a768e8f6 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 17 Jul 2018 17:21:55 -0400 Subject: [PATCH 486/677] CT Payments: fix URL typo --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/ct_payment.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 8bb42ae7018..98ac3a559a9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * Global Collect: Fix customer data field structure [curiousepic] #2929 * Adyen: Set Default Name for Apple Pay Transactions [nfarve] #2930 * Beanstream: Update to use api key with login credentials [nfarve] #2934 +* CT Payments: Fix a typo in the live URL scheme [bpollack] #2936 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb index 889266d65c1..0b9083c4cf6 100644 --- a/lib/active_merchant/billing/gateways/ct_payment.rb +++ b/lib/active_merchant/billing/gateways/ct_payment.rb @@ -2,7 +2,7 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class CtPaymentGateway < Gateway self.test_url = 'https://test.ctpaiement.ca/v1/' - self.live_url = 'hhtps://www.ctpaiement.com/v1/' + self.live_url = 'https://www.ctpaiement.com/v1/' self.supported_countries = ['US', 'CA'] self.default_currency = 'CAD' From 5b52f971722349032694dbd2b0b11b0ff760983a Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 18 Jul 2018 15:11:47 -0400 Subject: [PATCH 487/677] CyberSource: do not raise on HTML responses Sometimes, CyberSource will 500, and return an HTML response body. But that's a problem, because we assume all responses are XML. There was a previous attempt to handle this situation in ba586a28b4d1, but it won't work if an exception (e.g. a 400 or 500) is thrown as part of the response, since the rescue block will be catching at the wrong scope. Instead, capture the response or the exception, and then parse that as a separate step, so we can be sure to catch the XML parse error regardless. Unit: 46 tests, 222 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: didn't bother due to comment in fixtures.yml --- CHANGELOG | 1 + .../billing/gateways/cyber_source.rb | 8 ++++++-- test/unit/gateways/cyber_source_test.rb | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 98ac3a559a9..fed2409241c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * Adyen: Set Default Name for Apple Pay Transactions [nfarve] #2930 * Beanstream: Update to use api key with login credentials [nfarve] #2934 * CT Payments: Fix a typo in the live URL scheme [bpollack] #2936 +* CyberSource: Don't throw exceptions on HTML responses [bpollack] #2937 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 7d7beba89d6..96278d097b2 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -708,9 +708,13 @@ def build_request(body, options) # Response object def commit(request, action, amount, options) begin - response = parse(ssl_post(test? ? self.test_url : self.live_url, build_request(request, options))) + raw_response = ssl_post(test? ? self.test_url : self.live_url, build_request(request, options)) rescue ResponseError => e - response = parse(e.response.body) + raw_response = e.response.body + end + + begin + response = parse(raw_response) rescue REXML::ParseException => e response = { message: e.to_s } end diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index 318fc9931f9..e0765ea00fa 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -482,6 +482,16 @@ def test_supports_network_tokenization assert_instance_of TrueClass, @gateway.supports_network_tokenization? end + def test_does_not_throw_on_invalid_xml + raw_response = mock + raw_response.expects(:body).returns(invalid_xml_response) + exception = ActiveMerchant::ResponseError.new(raw_response) + @gateway.expects(:ssl_post).raises(exception) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + end + private def pre_scrubbed @@ -732,6 +742,10 @@ def successful_threedeesecure_validate_response XML end + def invalid_xml_response + "What's all this then, govna?</p>" + end + def assert_xml_valid_to_xsd(data, root_element = '//s:Body/*') schema_file = File.open("#{File.dirname(__FILE__)}/../../schema/cyber_source/CyberSourceTransaction_#{CyberSourceGateway::XSD_VERSION}.xsd") doc = Nokogiri::XML(data) From 85f87a3443f6911e3ffd95ff7a2f898a54aa0fe2 Mon Sep 17 00:00:00 2001 From: Chris Coetzee <develop@zendo.me> Date: Tue, 29 May 2018 14:48:19 +0200 Subject: [PATCH 488/677] Remove options parameter from Cybersource add_check_service call Closes #2861 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/cyber_source.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index fed2409241c..c742044a70d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Beanstream: Update to use api key with login credentials [nfarve] #2934 * CT Payments: Fix a typo in the live URL scheme [bpollack] #2936 * CyberSource: Don't throw exceptions on HTML responses [bpollack] #2937 +* CyberSource: Remove extraneous parameter blocking echecks [chriscz] #2861 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 96278d097b2..02e81821aed 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -356,7 +356,7 @@ def build_create_subscription_request(payment_method, options) add_subscription(xml, options) if options[:setup_fee] if card_brand(payment_method) == 'check' - add_check_service(xml, options) + add_check_service(xml) else add_purchase_service(xml, payment_method, options) add_payment_network_token(xml) if network_tokenization?(payment_method) From a792422a3115b3350d5fa285971186ede45e56c1 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Tue, 24 Jul 2018 08:58:52 -0400 Subject: [PATCH 489/677] FirstPay: Update Fields For Recurring Payments Updates fields for recurring payment and adds a new field for recurring type. Loaded suite test/remote/gateways/remote_first_pay_test Started ............. 13 tests, 29 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/first_pay_test ........... 11 tests, 116 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/first_pay.rb | 5 +++-- test/remote/gateways/remote_first_pay_test.rb | 2 +- test/unit/gateways/first_pay_test.rb | 10 ++++++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c742044a70d..9cdae70ea2c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * CT Payments: Fix a typo in the live URL scheme [bpollack] #2936 * CyberSource: Don't throw exceptions on HTML responses [bpollack] #2937 * CyberSource: Remove extraneous parameter blocking echecks [chriscz] #2861 +* FirstPay: Update Fields For Recurring Payments [nfarve] #2940 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb index b218557b4c7..0c0b6ff4897 100644 --- a/lib/active_merchant/billing/gateways/first_pay.rb +++ b/lib/active_merchant/billing/gateways/first_pay.rb @@ -93,8 +93,9 @@ def add_payment(post, payment, options) post[:card_exp] = expdate(payment) post[:cvv2] = payment.verification_value post[:recurring] = options[:recurring] if options[:recurring] - post[:recurringStartDate] = options[:recurring_start_date] if options[:recurring_start_date] - post[:recurringEndDate] = options[:recurring_end_date] if options[:recurring_end_date] + post[:recurring_start_date] = options[:recurring_start_date] if options[:recurring_start_date] + post[:recurring_end_date] = options[:recurring_end_date] if options[:recurring_end_date] + post[:recurring_type] = options[:recurring_type] if options[:recurring_type] end def add_reference(post, action, money, authorization) diff --git a/test/remote/gateways/remote_first_pay_test.rb b/test/remote/gateways/remote_first_pay_test.rb index 923667078b3..23aa35e8a30 100644 --- a/test/remote/gateways/remote_first_pay_test.rb +++ b/test/remote/gateways/remote_first_pay_test.rb @@ -111,7 +111,7 @@ def test_invalid_login end def test_recurring_payment - @options.merge!({recurring: 'none', recurring_start_date: DateTime.now, recurring_end_date: DateTime.now}) + @options.merge!({recurring: 1, recurring_start_date: DateTime.now.strftime('%m/%d/%Y'), recurring_end_date: DateTime.now.strftime('%m/%d/%Y'), recurring_type: 'monthly'}) response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal 'Approved', response.message diff --git a/test/unit/gateways/first_pay_test.rb b/test/unit/gateways/first_pay_test.rb index 0b3de0f9c25..6596389bf64 100644 --- a/test/unit/gateways/first_pay_test.rb +++ b/test/unit/gateways/first_pay_test.rb @@ -182,15 +182,17 @@ def test_failed_void end def test_recurring_payments - @options[:recurring] = 'none' + @options[:recurring] = 1 @options[:recurring_start_date] = '01/01/1900' @options[:recurring_end_date] = '02/02/1901' + @options[:recurring_type] = 'monthly' response = stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| - assert_match(%r{<FIELD KEY="recurring">none</FIELD>}, data) - assert_match(%r{<FIELD KEY="recurringStartDate">01/01/1900</FIELD>}, data) - assert_match(%r{<FIELD KEY="recurringEndDate">02/02/1901</FIELD>}, data) + assert_match(%r{<FIELD KEY="recurring">1</FIELD>}, data) + assert_match(%r{<FIELD KEY="recurring_start_date">01/01/1900</FIELD>}, data) + assert_match(%r{<FIELD KEY="recurring_end_date">02/02/1901</FIELD>}, data) + assert_match(%r{<FIELD KEY="recurring_type">monthly</FIELD>}, data) end.respond_with(successful_purchase_response) assert response From 33fba2fcfe32fb6597d53875ce438e9c85e9bafa Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 24 Jul 2018 11:40:48 -0400 Subject: [PATCH 490/677] BlueSnap: Update list of supported countries Closes #2942 Unit: 18 tests, 68 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote (two unrelated failures): 25 tests, 72 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 92% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/blue_snap.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 9cdae70ea2c..962a00f3365 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * CyberSource: Don't throw exceptions on HTML responses [bpollack] #2937 * CyberSource: Remove extraneous parameter blocking echecks [chriscz] #2861 * FirstPay: Update Fields For Recurring Payments [nfarve] #2940 +* BlueSnap: Update list of supported countries [curiousepic] #2942 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb index e736fe14152..c857cbe93f6 100644 --- a/lib/active_merchant/billing/gateways/blue_snap.rb +++ b/lib/active_merchant/billing/gateways/blue_snap.rb @@ -5,7 +5,7 @@ module Billing class BlueSnapGateway < Gateway self.test_url = 'https://sandbox.bluesnap.com/services/2' self.live_url = 'https://ws.bluesnap.com/services/2' - self.supported_countries = %w(US CA GB AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE) + self.supported_countries = %w(AD AE AG AI AL AM AO AQ AR AS AT AU AW AZ BA BB BD BE BF BG BH BI BJ BM BN BO BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IS IT JE JM JO JP KE KG KH KI KM KN KR KW KY KZ LA LC LI LK LR LS LT LU LV MA MC MD ME MF MG MH MK ML MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PT PW PY QA RE RO RS RU RW SA SB SC SE SG SH SI SJ SK SL SM SN SO SR ST SV SX SZ TC TD TF TG TH TJ TK TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YT ZA ZM ZW) self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro] From 3169f0c1dd58cc3e195df0e6be7ed392c7cab256 Mon Sep 17 00:00:00 2001 From: Bernard Laveaux <blaveaux@outlook.com> Date: Wed, 18 Jan 2017 12:39:57 -0500 Subject: [PATCH 491/677] Remove unused `handle_response` method The `handle_response` method defined in `Connection` - looks to be implemented on each gateway within `PostsData` module - doesn't seem to be called anywhere in code and passes test suite Unit: 3911 tests, 68082 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed Closes #2309 --- CHANGELOG | 1 + lib/active_merchant/connection.rb | 13 ------------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 962a00f3365..c580d46bd6b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * CyberSource: Remove extraneous parameter blocking echecks [chriscz] #2861 * FirstPay: Update Fields For Recurring Payments [nfarve] #2940 * BlueSnap: Update list of supported countries [curiousepic] #2942 +* Remove unused handle_response method [bl] #2309 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index a289bcdd82f..5df801ca301 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -177,19 +177,6 @@ def configure_cert(http) end end - def handle_response(response) - if @ignore_http_status then - return response.body - else - case response.code.to_i - when 200...300 - response.body - else - raise ResponseError.new(response) - end - end - end - def debug(message, tag = nil) log(:debug, message, tag) end From 7074c900409a080008239f9c628f066172272b85 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 24 Jul 2018 11:41:38 -0400 Subject: [PATCH 492/677] Barclaycard Smartpay: bump API to v30 This currently shouldn't change any behavior, but preps for handling third-party payouts and also serves as a marker that the API package should run cleanly on v30 of the API. Unit: 25 tests, 114 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 29 tests, 61 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/barclaycard_smartpay.rb | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c580d46bd6b..a89d8f73228 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * FirstPay: Update Fields For Recurring Payments [nfarve] #2940 * BlueSnap: Update list of supported countries [curiousepic] #2942 * Remove unused handle_response method [bl] #2309 +* Barclaycard Smartpay: bump API version to v30 [bpollack] #2941 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index 56fe408d503..33e4945a434 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -13,6 +13,8 @@ class BarclaycardSmartpayGateway < Gateway self.homepage_url = 'https://www.barclaycardsmartpay.com/' self.display_name = 'Barclaycard Smartpay' + API_VERSION = 'v30' + def initialize(options = {}) requires!(options, :company, :merchant, :password) super @@ -222,11 +224,11 @@ def success_from(response) def build_url(action) case action when 'store' - "#{test? ? self.test_url : self.live_url}/Recurring/v12/storeToken" + "#{test? ? self.test_url : self.live_url}/Recurring/#{API_VERSION}/storeToken" when 'finalize3ds' - "#{test? ? self.test_url : self.live_url}/Payment/v12/authorise3d" + "#{test? ? self.test_url : self.live_url}/Payment/#{API_VERSION}/authorise3d" else - "#{test? ? self.test_url : self.live_url}/Payment/v12/#{action}" + "#{test? ? self.test_url : self.live_url}/Payment/#{API_VERSION}/#{action}" end end From af70e08ba12f4ba577f56145c192deacbbe515d8 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 24 Jul 2018 15:00:14 -0400 Subject: [PATCH 493/677] Revert "BlueSnap: Update list of supported countries" This reverts commit 33fba2fcfe32fb6597d53875ce438e9c85e9bafa. Whoops, forgot that "supported countries" is actually the countries that merchants can be based in, rather than supported billing addresses. --- CHANGELOG | 1 - lib/active_merchant/billing/gateways/blue_snap.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a89d8f73228..3e22609a554 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,7 +13,6 @@ * CyberSource: Don't throw exceptions on HTML responses [bpollack] #2937 * CyberSource: Remove extraneous parameter blocking echecks [chriscz] #2861 * FirstPay: Update Fields For Recurring Payments [nfarve] #2940 -* BlueSnap: Update list of supported countries [curiousepic] #2942 * Remove unused handle_response method [bl] #2309 * Barclaycard Smartpay: bump API version to v30 [bpollack] #2941 diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb index c857cbe93f6..e736fe14152 100644 --- a/lib/active_merchant/billing/gateways/blue_snap.rb +++ b/lib/active_merchant/billing/gateways/blue_snap.rb @@ -5,7 +5,7 @@ module Billing class BlueSnapGateway < Gateway self.test_url = 'https://sandbox.bluesnap.com/services/2' self.live_url = 'https://ws.bluesnap.com/services/2' - self.supported_countries = %w(AD AE AG AI AL AM AO AQ AR AS AT AU AW AZ BA BB BD BE BF BG BH BI BJ BM BN BO BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IS IT JE JM JO JP KE KG KH KI KM KN KR KW KY KZ LA LC LI LK LR LS LT LU LV MA MC MD ME MF MG MH MK ML MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PT PW PY QA RE RO RS RU RW SA SB SC SE SG SH SI SJ SK SL SM SN SO SR ST SV SX SZ TC TD TF TG TH TJ TK TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YT ZA ZM ZW) + self.supported_countries = %w(US CA GB AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE) self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro] From ab51e8c942df53c3538d361a781e26786073f117 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Thu, 26 Jul 2018 11:22:34 -0400 Subject: [PATCH 494/677] Safecharge: Remove duplicate supported country Remote: 23 tests, 68 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 20 tests, 96 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/safe_charge.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 3e22609a554..e8c7bb0ed8f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * FirstPay: Update Fields For Recurring Payments [nfarve] #2940 * Remove unused handle_response method [bl] #2309 * Barclaycard Smartpay: bump API version to v30 [bpollack] #2941 +* Safecharge: Remove duplicate supported country [curiousepic] == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index a2c8022655e..684f1c3d468 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -6,7 +6,7 @@ class SafeChargeGateway < Gateway self.test_url = 'https://process.sandbox.safecharge.com/service.asmx/Process' self.live_url = 'https://process.safecharge.com/service.asmx/Process' - self.supported_countries = ['AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'GR', 'ES', 'FI', 'FR', 'HR', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SE', 'SI', 'SK', 'GB', 'US'] + self.supported_countries = ['AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'GR', 'ES', 'FI', 'FR', 'HR', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK', 'GB', 'US'] self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master] From 3baa26e4cb48f818e130cb49a6ae4c5bb211cf14 Mon Sep 17 00:00:00 2001 From: Filipe Costa <filipebarcos@users.noreply.github.com> Date: Fri, 27 Jul 2018 11:49:34 -0300 Subject: [PATCH 495/677] Use SHIPTONAME instead of `full_name` for Payflow Express (#2945) * Remove whitespaces * Use primarily SHIPTONAME for Payflow Express `full_name` is not necessarily the person receiving the products being bought, it's the buyer account owner name, many time SHIPTONAME and `full_name` would be the same, but in others, products could be a gift to someone else, shipped to their address. --- .../payflow/payflow_express_response.rb | 12 +- test/unit/gateways/payflow_express_test.rb | 108 ++++++++++++++---- test/unit/gateways/payflow_express_uk_test.rb | 72 +++++++++++- 3 files changed, 162 insertions(+), 30 deletions(-) diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb b/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb index 7b4068dea05..0c01ee481b2 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb @@ -4,26 +4,26 @@ class PayflowExpressResponse < Response def email @params['e_mail'] end - + def full_name "#{@params['name']} #{@params['lastname']}" end - + def token @params['token'] end - + def payer_id @params['payer_id'] end - + # Really the shipping country, but it is all the information provided def payer_country address['country'] end - + def address - { 'name' => full_name, + { 'name' => @params['shiptoname'] || full_name, 'company' => nil, 'address1' => @params['street'], 'address2' => @params['shiptostreet2'] || @params['street2'], diff --git a/test/unit/gateways/payflow_express_test.rb b/test/unit/gateways/payflow_express_test.rb index 719fd885117..a78238a6a3a 100644 --- a/test/unit/gateways/payflow_express_test.rb +++ b/test/unit/gateways/payflow_express_test.rb @@ -5,15 +5,15 @@ class PayflowExpressTest < Test::Unit::TestCase TEST_REDIRECT_URL_MOBILE = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout-mobile&token=1234567890' LIVE_REDIRECT_URL = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=1234567890' LIVE_REDIRECT_URL_MOBILE = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout-mobile&token=1234567890' - + TEST_REDIRECT_URL_WITHOUT_REVIEW = "#{TEST_REDIRECT_URL}&useraction=commit" LIVE_REDIRECT_URL_WITHOUT_REVIEW = "#{LIVE_REDIRECT_URL}&useraction=commit" TEST_REDIRECT_URL_MOBILE_WITHOUT_REVIEW = "#{TEST_REDIRECT_URL_MOBILE}&useraction=commit" LIVE_REDIRECT_URL_MOBILE_WITHOUT_REVIEW = "#{LIVE_REDIRECT_URL_MOBILE}&useraction=commit" - + def setup Base.mode = :test - + @gateway = PayflowExpressGateway.new( :login => 'LOGIN', :password => 'PASSWORD' @@ -29,61 +29,61 @@ def setup :phone => '(555)555-5555' } end - + def teardown Base.mode = :test end - + def test_using_test_mode assert @gateway.test? end - + def test_overriding_test_mode Base.mode = :production - + gateway = PayflowExpressGateway.new( :login => 'LOGIN', :password => 'PASSWORD', :test => true ) - + assert gateway.test? end - + def test_using_production_mode Base.mode = :production - + gateway = PayflowExpressGateway.new( :login => 'LOGIN', :password => 'PASSWORD' ) - + assert !gateway.test? end - + def test_live_redirect_url Base.mode = :production assert_equal LIVE_REDIRECT_URL, @gateway.redirect_url_for('1234567890') assert_equal LIVE_REDIRECT_URL_MOBILE, @gateway.redirect_url_for('1234567890', :mobile => true) end - + def test_test_redirect_url assert_equal TEST_REDIRECT_URL, @gateway.redirect_url_for('1234567890') assert_equal TEST_REDIRECT_URL_MOBILE, @gateway.redirect_url_for('1234567890', :mobile => true) end - + def test_live_redirect_url_without_review Base.mode = :production assert_equal LIVE_REDIRECT_URL_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', :review => false) assert_equal LIVE_REDIRECT_URL_MOBILE_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', :review => false, :mobile => true) end - + def test_test_redirect_url_without_review assert_equal :test, Base.mode assert_equal TEST_REDIRECT_URL_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', :review => false) assert_equal TEST_REDIRECT_URL_MOBILE_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', :review => false, :mobile => true) end - + def test_invalid_get_express_details_request @gateway.expects(:ssl_post).returns(invalid_get_express_details_response) response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV') @@ -91,20 +91,20 @@ def test_invalid_get_express_details_request assert response.test? assert_equal 'Field format error: Invalid Token', response.message end - + def test_get_express_details @gateway.expects(:ssl_post).returns(successful_get_express_details_response) response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV') assert_instance_of PayflowExpressResponse, response assert_success response assert response.test? - + assert_equal 'EC-2OPN7UJGFWK9OYFV', response.token assert_equal '12345678901234567', response.payer_id assert_equal 'Buyer1@paypal.com', response.email assert_equal 'Joe Smith', response.full_name assert_equal 'US', response.payer_country - + assert address = response.address assert_equal 'Joe Smith', address['name'] assert_nil address['company'] @@ -117,6 +117,31 @@ def test_get_express_details assert_nil address['phone'] end + def test_get_express_details_with_ship_to_name + @gateway.expects(:ssl_post).returns(successful_get_express_details_response_with_ship_to_name) + response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV') + assert_instance_of PayflowExpressResponse, response + assert_success response + assert response.test? + + assert_equal 'EC-2OPN7UJGFWK9OYFV', response.token + assert_equal '12345678901234567', response.payer_id + assert_equal 'Buyer1@paypal.com', response.email + assert_equal 'Joe Smith', response.full_name + assert_equal 'US', response.payer_country + + assert address = response.address + assert_equal 'John Joseph', address['name'] + assert_nil address['company'] + assert_equal '111 Main St.', address['address1'] + assert_nil address['address2'] + assert_equal 'San Jose', address['city'] + assert_equal 'CA', address['state'] + assert_equal '95100', address['zip'] + assert_equal 'US', address['country'] + assert_nil address['phone'] + end + def test_get_express_details_with_invalid_xml @gateway.expects(:ssl_post).returns(successful_get_express_details_response(:street => 'Main & Magic')) response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV') @@ -134,9 +159,9 @@ def test_button_source xml_doc = REXML::Document.new(xml.target!) assert_nil REXML::XPath.first(xml_doc, '/PayPal/ButtonSource') end - + private - + def successful_get_express_details_response(options={:street => '111 Main St.'}) <<-RESPONSE <XMLPayResponse xmlns='http://www.verisign.com/XMLPay'> @@ -172,7 +197,44 @@ def successful_get_express_details_response(options={:street => '111 Main St.'}) </XMLPayResponse> RESPONSE end - + + def successful_get_express_details_response_with_ship_to_name + <<-RESPONSE +<XMLPayResponse xmlns='http://www.verisign.com/XMLPay'> + <ResponseData> + <Vendor>TEST</Vendor> + <Partner>verisign</Partner> + <TransactionResults> + <TransactionResult> + <Result>0</Result> + <Message>Approved</Message> + <PayPalResult> + <EMail>Buyer1@paypal.com</EMail> + <PayerID>12345678901234567</PayerID> + <Token>EC-2OPN7UJGFWK9OYFV</Token> + <FeeAmount>0</FeeAmount> + <PayerStatus>verified</PayerStatus> + <Name>Joe</Name> + <ShipTo> + <Address> + <Street>111 Main St.</Street> + <City>San Jose</City> + <State>CA</State> + <Zip>95100</Zip> + <Country>US</Country> + </Address> + </ShipTo> + <CorrelationID>9c3706997455e</CorrelationID> + </PayPalResult> + <ExtData Name='LASTNAME' Value='Smith'/> + <ExtData Name='SHIPTONAME' Value='John Joseph'/> + </TransactionResult> + </TransactionResults> + </ResponseData> + </XMLPayResponse> + RESPONSE + end + def invalid_get_express_details_response <<-RESPONSE <XMLPayResponse xmlns='http://www.verisign.com/XMLPay'> @@ -186,7 +248,7 @@ def invalid_get_express_details_response </TransactionResult> </TransactionResults> </ResponseData> -</XMLPayResponse> +</XMLPayResponse> RESPONSE end end diff --git a/test/unit/gateways/payflow_express_uk_test.rb b/test/unit/gateways/payflow_express_uk_test.rb index 25f88820b1e..6c40fa8aca9 100644 --- a/test/unit/gateways/payflow_express_uk_test.rb +++ b/test/unit/gateways/payflow_express_uk_test.rb @@ -37,6 +37,31 @@ def test_get_express_details assert_nil address['phone'] end + def test_get_express_details_with_ship_to_name + @gateway.expects(:ssl_post).returns(successful_get_express_details_response_with_ship_to_name) + response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV') + assert_instance_of PayflowExpressResponse, response + assert_success response + assert response.test? + + assert_equal 'EC-2OPN7UJGFWK9OYFV', response.token + assert_equal 'LYWCMEN4FA7ZQ', response.payer_id + assert_equal 'paul@test.com', response.email + assert_equal 'paul smith', response.full_name + assert_equal 'GB', response.payer_country + + assert address = response.address + assert_equal 'John Joseph', address['name'] + assert_nil address['company'] + assert_equal '10 keyworth avenue', address['address1'] + assert_equal 'grangetown', address['address2'] + assert_equal 'hinterland', address['city'] + assert_equal 'Tyne and Wear', address['state'] + assert_equal 'sr5 2uh', address['zip'] + assert_equal 'GB', address['country'] + assert_nil address['phone'] + end + private def successful_get_express_details_response <<-RESPONSE @@ -73,7 +98,52 @@ def successful_get_express_details_response </PayPalResult> <ExtData Name="LASTNAME" Value="smith"/> <ExtData Name="SHIPTOSTREET2" Value="grangetown"/> - <ExtData Name="SHIPTONAME" Value="paul smith"/> + <ExtData Name="STREET2" Value="ALLAWAY AVENUE"/> + <ExtData Name="COUNTRYCODE" Value="GB"/> + <ExtData Name="ADDRESSSTATUS" Value="Y"/> + </TransactionResult> + </TransactionResults> + </ResponseData> +</XMLPayResponse> + RESPONSE + end + + def successful_get_express_details_response_with_ship_to_name + <<-RESPONSE +<?xml version="1.0"?> +<XMLPayResponse xmlns="http://www.paypal.com/XMLPay"> + <ResponseData> + <Vendor>markcoop</Vendor> + <Partner>paypaluk</Partner> + <TransactionResults> + <TransactionResult> + <Result>0</Result> + <AVSResult> + <StreetMatch>Match</StreetMatch> + <ZipMatch>Match</ZipMatch> + </AVSResult> + <Message>Approved</Message> + <PayPalResult> + <EMail>paul@test.com</EMail> + <PayerID>LYWCMEN4FA7ZQ</PayerID> + <Token>EC-2OPN7UJGFWK9OYFV</Token> + <FeeAmount>0</FeeAmount> + <PayerStatus>unverified</PayerStatus> + <Name>paul</Name> + <ShipTo> + <Address> + <Street>10 keyworth avenue</Street> + <City>hinterland</City> + <State>Tyne and Wear</State> + <Zip>sr5 2uh</Zip> + <Country>GB</Country> + </Address> + </ShipTo> + <CorrelationID>1ea22ef3873ba</CorrelationID> + </PayPalResult> + <ExtData Name="LASTNAME" Value="smith"/> + <ExtData Name="SHIPTOSTREET2" Value="grangetown"/> + <ExtData Name="SHIPTONAME" Value="John Joseph"/> <ExtData Name="STREET2" Value="ALLAWAY AVENUE"/> <ExtData Name="COUNTRYCODE" Value="GB"/> <ExtData Name="ADDRESSSTATUS" Value="Y"/> From 5d8da4eb5647477d23fc2c7bf9843cae4fc52e25 Mon Sep 17 00:00:00 2001 From: Filipe Costa <filipebarcos@gmail.com> Date: Mon, 30 Jul 2018 10:04:11 -0300 Subject: [PATCH 496/677] Release v1.81.0 --- CHANGELOG | 1 + lib/active_merchant/version.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index e8c7bb0ed8f..4e6260f5886 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * Remove unused handle_response method [bl] #2309 * Barclaycard Smartpay: bump API version to v30 [bpollack] #2941 * Safecharge: Remove duplicate supported country [curiousepic] +* Payflow Express: Use SHIPTONAME instead of `full_name` for shipping address [filipebarcos] #2945 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index b1883e4e5c3..b305d6325eb 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = '1.80.0' + VERSION = '1.81.0' end From b50f685d4a6c4256ca42403306c361fdbccb6983 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 31 Jul 2018 13:31:03 -0400 Subject: [PATCH 497/677] FirstData E4 v27: Support WalletProviderID Unit: 30 tests, 139 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 23 tests, 92 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/firstdata_e4_v27.rb | 6 ++++-- test/unit/gateways/firstdata_e4_v27_test.rb | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4e6260f5886..820baa86cfc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ * Barclaycard Smartpay: bump API version to v30 [bpollack] #2941 * Safecharge: Remove duplicate supported country [curiousepic] * Payflow Express: Use SHIPTONAME instead of `full_name` for shipping address [filipebarcos] #2945 +* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb index 9bdd77d9b62..7f5fde83f3e 100644 --- a/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb @@ -211,6 +211,7 @@ def add_credit_card(xml, credit_card, options) xml.tag! 'Expiry_Date', expdate(credit_card) xml.tag! 'CardHoldersName', credit_card.name xml.tag! 'CardType', card_type(credit_card.brand) + xml.tag! 'WalletProviderID', options[:wallet_provider_id] if options[:wallet_provider_id] add_credit_card_eci(xml, credit_card, options) add_credit_card_verification_strings(xml, credit_card, options) @@ -273,6 +274,7 @@ def add_credit_card_token(xml, store_authorization, options) xml.tag! 'Expiry_Date', expdate(credit_card) xml.tag! 'CardHoldersName', credit_card.name xml.tag! 'CardType', card_type(credit_card.brand) + xml.tag! 'WalletProviderID', options[:wallet_provider_id] if options[:wallet_provider_id] add_card_authentication_data(xml, options) end @@ -398,9 +400,9 @@ def money_from_authorization(auth) end def message_from(response) - if(response[:faultcode] && response[:faultstring]) + if response[:faultcode] && response[:faultstring] response[:faultstring] - elsif(response[:error_number] && response[:error_number] != '0') + elsif response[:error_number] && response[:error_number] != '0' response[:error_description] else result = (response[:exact_message] || '') diff --git a/test/unit/gateways/firstdata_e4_v27_test.rb b/test/unit/gateways/firstdata_e4_v27_test.rb index ed4e9c45512..3e502c430e8 100644 --- a/test/unit/gateways/firstdata_e4_v27_test.rb +++ b/test/unit/gateways/firstdata_e4_v27_test.rb @@ -49,6 +49,16 @@ def test_successful_purchase_with_token assert_success response end + def test_successful_purchase_with_wallet + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge!({wallet_provider_id: 4})) + end.check_request do |endpoint, data, headers| + assert_match /WalletProviderID>4</, data + end.respond_with(successful_purchase_response) + + assert_success response + end + def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) assert response = @gateway.void(@authorization, @options) From 77b8d3b073992aa3dca52b53b47898990e743af7 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Mon, 6 Aug 2018 14:25:04 -0400 Subject: [PATCH 498/677] BlueSnap: Handle 403 responses 403 Forbidden responses due to insufficient account permissions were causing parsing exception errors. This handles them with a bespoke response passing the raw text as message. This also fixes the verify_credentials call; a change at the gateways caused the response given for a bogus url (url/nonexistent) to be a success with a different message. Hitting the root url now seems sufficient to provoke a 401. Closes #2948 Remote (1 unrelated failure): 25 tests, 72 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 96% passed Unit: 19 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/blue_snap.rb | 7 ++++++- test/unit/gateways/blue_snap_test.rb | 15 +++++++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 820baa86cfc..6782a2191a6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * Safecharge: Remove duplicate supported country [curiousepic] * Payflow Express: Use SHIPTONAME instead of `full_name` for shipping address [filipebarcos] #2945 * FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946 +* BlueSnap: Handle 403 responses [curiousepic] #2948 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb index e736fe14152..3a378f25716 100644 --- a/lib/active_merchant/billing/gateways/blue_snap.rb +++ b/lib/active_merchant/billing/gateways/blue_snap.rb @@ -116,7 +116,7 @@ def store(credit_card, options = {}) def verify_credentials begin - ssl_get("#{url}/nonexistent", headers) + ssl_get(url.to_s, headers) rescue ResponseError => e return false if e.response.code.to_i == 401 end @@ -209,6 +209,7 @@ def add_authorization(doc, authorization) def parse(response) return bad_authentication_response if response.code.to_i == 401 + return forbidden_response(response.body) if response.code.to_i == 403 parsed = {} doc = Nokogiri::XML(response.body) @@ -338,6 +339,10 @@ def handle_response(response) def bad_authentication_response { 'description' => 'Unable to authenticate. Please check your credentials.' } end + + def forbidden_response(body) + { 'description' => body } + end end end end diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb index dffaf3d9565..54416d767dc 100644 --- a/test/unit/gateways/blue_snap_test.rb +++ b/test/unit/gateways/blue_snap_test.rb @@ -140,6 +140,14 @@ def test_verify_bad_credentials assert !@gateway.verify_credentials end + def test_failed_forbidden_response + @gateway.expects(:raw_ssl_request).returns(forbidden_response) + + response = @gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal '<xml>You are not authorized to perform this request due to inappropriate role permissions.</xml>', response.message + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed @@ -516,12 +524,15 @@ def failed_store_response MockResponse.failed(body, 400) end + def forbidden_response + MockResponse.new(403, '<xml>You are not authorized to perform this request due to inappropriate role permissions.</xml>') + end + def credentials_are_legit_response MockResponse.new(400, '<xml>Server Error</xml>') end def credentials_are_bogus_response - MockResponse.new(401, %{<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.24 - Error report</title><style type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}</style> </head><body><h1>HTTP Status 401 - Bad credentials</h1><div class="line"></div><p><b>type</b> Status report</p><p><b>message</b> <u>Bad credentials</u></p><p><b>description</b> <u>This request requires HTTP authentication.</u></p><hr class="line"><h3>Apache Tomcat/8.0.24</h3></body></html>}) + MockResponse.new(401, %{<!DOCTYPE html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Bad credentials</p><p><b>Description</b> The request has not been applied because it lacks valid authentication credentials for the target resource.</p><hr class="line" /><h3>Apache Tomcat Version X</h3></body></html>}) end - end From 99db685a6940b1ba5f6d00047e9d908a5330fcd0 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Wed, 8 Aug 2018 14:01:38 -0400 Subject: [PATCH 499/677] BlueSnap: Add StoreCard Field With increase in visa regulations, merchants must pass a `storeCard` value which shows if a user has authorized their card to be stored. One test failing in remote unrelated to these changes. Loaded suite test/unit/gateways/blue_snap_test 19 tests, 73 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications Loaded suite test/remote/gateways/remote_blue_snap_test 25 tests, 72 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 96% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/blue_snap.rb | 1 + test/unit/gateways/blue_snap_test.rb | 8 +++++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6782a2191a6..8583b3a9ba1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * Payflow Express: Use SHIPTONAME instead of `full_name` for shipping address [filipebarcos] #2945 * FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946 * BlueSnap: Handle 403 responses [curiousepic] #2948 +* BlueSnap: Add StoreCard Field [nfarve] #2953 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb index 3a378f25716..95cab53ca27 100644 --- a/lib/active_merchant/billing/gateways/blue_snap.rb +++ b/lib/active_merchant/billing/gateways/blue_snap.rb @@ -140,6 +140,7 @@ def scrub(transcript) def add_auth_purchase(doc, money, payment_method, options) doc.send('recurring-transaction', options[:recurring] ? 'RECURRING' : 'ECOMMERCE') add_order(doc, options) + doc.send('storeCard', options[:store_card] || false) add_amount(doc, money, options) doc.send('transaction-fraud-info') do doc.send('shopper-ip-address', options[:ip]) if options[:ip] diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb index 54416d767dc..444e43832af 100644 --- a/test/unit/gateways/blue_snap_test.rb +++ b/test/unit/gateways/blue_snap_test.rb @@ -27,9 +27,11 @@ def test_failed_purchase end def test_successful_authorize - @gateway.expects(:raw_ssl_request).returns(successful_authorize_response) - - response = @gateway.authorize(@amount, @credit_card, @options) + response = stub_comms(@gateway, :raw_ssl_request) do + @gateway.authorize(@amount, @credit_card, @options) + end.check_request do |type, endpoint, data, headers| + assert_match '<storeCard>false</storeCard>', data + end.respond_with(successful_authorize_response) assert_success response assert_equal '1012082893', response.authorization end From a3874d3776996dc96afe8a7a3f20abfbc12a7892 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 9 Aug 2018 15:12:38 -0400 Subject: [PATCH 500/677] Worldpay: support instalments Failing remote tests have nothing to do with the new functionality (that test passes). Unit: 38 tests, 217 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 26 tests, 90 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 84.6154% passed --- CHANGELOG | 1 + .../billing/gateways/worldpay.rb | 12 ++++++++++- test/remote/gateways/remote_worldpay_test.rb | 14 ++++++++++--- test/unit/gateways/worldpay_test.rb | 20 +++++++++++++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8583b3a9ba1..c9d3dc34886 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ * FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946 * BlueSnap: Handle 403 responses [curiousepic] #2948 * BlueSnap: Add StoreCard Field [nfarve] #2953 +* Worldpay: support installments [bpollack] #2957 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index b88c10afe04..4ef6f38eb1a 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -168,6 +168,9 @@ def build_authorization_request(money, payment_method, options) if options[:hcg_additional_data] add_hcg_additional_data(xml, options) end + if options[:instalments] + add_instalments_data(xml, options) + end end end end @@ -292,6 +295,13 @@ def add_hcg_additional_data(xml, options) end end + def add_instalments_data(xml, options) + xml.tag! 'thirdPartyData' do + xml.tag! 'instalments', options[:instalments] + xml.tag! 'cpf', options[:cpf] if options[:cpf] + end + end + def address_with_defaults(address) address ||= {} address.delete_if { |_, v| v.blank? } @@ -370,7 +380,7 @@ def url def handle_response(response) case response.code.to_i when 200...300 - @cookie = response.response['Set-Cookie'] + @cookie = response['Set-Cookie'] response.body else raise ResponseError.new(response) diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index e1cb7f3cb64..ae768a760d5 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -82,9 +82,18 @@ def test_authorize_and_purchase_by_reference assert_success capture end + def test_authorize_and_purchase_with_instalments + assert auth = @gateway.authorize(@amount, @credit_card, @options.merge(instalment: 3)) + assert_success auth + assert_equal 'SUCCESS', auth.message + assert auth.authorization + sleep(40) + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + end + def test_successful_authorize_with_3ds session_id = generate_unique_id - order_id = @options[:order_id] options = @options.merge( { execute_threed: true, @@ -106,7 +115,6 @@ def test_successful_authorize_with_3ds def test_failed_authorize_with_3ds session_id = generate_unique_id - order_id = @options[:order_id] options = @options.merge( { execute_threed: true, @@ -196,7 +204,7 @@ def test_refund_fails_unless_status_is_captured assert refund = @gateway.refund(30, response.authorization) assert_failure refund - assert_equal "A transaction status of 'CAPTURED' or 'SETTLED' or 'SETTLED_BY_MERCHANT' is required.", refund.message + assert_equal 'Order not ready', refund.message end def test_refund_nonexistent_transaction diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index 2fb4297ffcb..02a6eca5834 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -352,6 +352,26 @@ def test_email end.respond_with(successful_authorize_response) end + def test_instalments + stub_comms do + @gateway.purchase(100, @credit_card, @options.merge(instalments: 3)) + end.check_request do |endpoint, data, headers| + unless /<capture>/ =~ data + assert_match %r(<instalments>3</instalments>), data + assert_no_match %r(cpf), data + end + end.respond_with(successful_authorize_response, successful_capture_response) + + stub_comms do + @gateway.purchase(100, @credit_card, @options.merge(instalments: 3, cpf: 12341234)) + end.check_request do |endpoint, data, headers| + unless /<capture>/ =~ data + assert_match %r(<instalments>3</instalments>), data + assert_match %r(<cpf>12341234</cpf>), data + end + end.respond_with(successful_authorize_response, successful_capture_response) + end + def test_ip stub_comms do @gateway.authorize(100, @credit_card, @options.merge(ip: '192.137.11.44')) From ee619b3b9c1209ac8ee4d310d2c85c6adc607b82 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 13 Aug 2018 07:13:29 -0400 Subject: [PATCH 501/677] Paymentez: add support for partial refunds Unit: 19 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 17 tests, 44 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 88.2353% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/paymentez.rb | 7 +++++-- test/remote/gateways/remote_paymentez_test.rb | 8 ++++++++ test/unit/gateways/paymentez_test.rb | 14 +++++++++++++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c9d3dc34886..af5d69e7097 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,7 @@ * BlueSnap: Handle 403 responses [curiousepic] #2948 * BlueSnap: Add StoreCard Field [nfarve] #2953 * Worldpay: support installments [bpollack] #2957 +* Paymentez: support partial refunds [bpollack] #2959 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index 49b628834d7..db72d1da65e 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -76,8 +76,11 @@ def capture(money, authorization, _options = {}) commit_transaction('capture', post) end - def refund(_money, authorization, options = {}) - void(authorization, options) + def refund(money, authorization, options = {}) + post = {transaction: {id: authorization}} + post[:order] = {amount: amount(money).to_f} if money + + commit_transaction('refund', post) end def void(authorization, _options = {}) diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb index 6164e7e2e9b..b6c2fca7173 100644 --- a/test/remote/gateways/remote_paymentez_test.rb +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -47,6 +47,14 @@ def test_failed_purchase assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code end + def test_successful_refund + auth = @gateway.purchase(@amount, @credit_card, @options) + assert_success auth + + assert refund = @gateway.refund(@amount, @credit_card, @options) + assert_success refund + end + def test_successful_void auth = @gateway.purchase(@amount, @credit_card, @options) assert_success auth diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb index 05c16c6fd25..8cfd9eb690d 100644 --- a/test/unit/gateways/paymentez_test.rb +++ b/test/unit/gateways/paymentez_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class PaymentezTest < Test::Unit::TestCase + include CommStub + def setup @gateway = PaymentezGateway.new(application_code: 'foo', app_key: 'bar') @credit_card = credit_card @@ -107,7 +109,17 @@ def test_failed_capture def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - response = @gateway.refund(@amount, '1234', @options) + response = @gateway.refund(nil, '1234', @options) + assert_success response + assert response.test? + end + + def test_partial_refund + response = stub_comms do + @gateway.refund(@amount, '1234', @options) + end.check_request do |_endpoint, data, _headers| + assert_match /"amount":1.0/, data + end.respond_with(successful_refund_response) assert_success response assert response.test? end From fb2c448e9f2dec84552c3ef9f5db3a93c7fca093 Mon Sep 17 00:00:00 2001 From: Pierre Nespo <pierre.nespo@gmail.com> Date: Mon, 13 Aug 2018 11:33:32 -0400 Subject: [PATCH 502/677] Allow setting CAPTURECOMPLETE on Payflow capture transactions (#2952) By default Payflow will consider the first capture the final one, by passing `CAPTURECOMPLETE=N` it lets us capture again later on. [Docs](https://developer.paypal.com/docs/classic/payflow/integration-guide/#paypal-credit-card-transaction-request-parameters) Remote: (Failures related to ACH and recurring billing) 32 tests, 137 assertions, 8 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 75% passed Unit: 46 tests, 208 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- .../gateways/payflow/payflow_common_api.rb | 5 ++++ .../billing/gateways/payflow_express.rb | 5 +--- test/remote/gateways/remote_payflow_test.rb | 26 +++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb index fc0b78a5013..e8258844aec 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb @@ -119,6 +119,11 @@ def build_reference_request(action, money, authorization, options) xml.tag!('Description', options[:description]) unless options[:description].blank? xml.tag!('Comment', options[:comment]) unless options[:comment].blank? xml.tag!('ExtData', 'Name'=> 'COMMENT2', 'Value'=> options[:comment2]) unless options[:comment2].blank? + xml.tag!( + 'ExtData', + 'Name' => 'CAPTURECOMPLETE', + 'Value' => options[:capture_complete] + ) unless options[:capture_complete].blank? end end end diff --git a/lib/active_merchant/billing/gateways/payflow_express.rb b/lib/active_merchant/billing/gateways/payflow_express.rb index d2e0b27ede5..a8fee1d6476 100644 --- a/lib/active_merchant/billing/gateways/payflow_express.rb +++ b/lib/active_merchant/billing/gateways/payflow_express.rb @@ -9,9 +9,7 @@ module Billing #:nodoc: # in the docs that they recommend you pass the exact same parameters to both setup and authorize/purchase. # # This information was gleaned from a mix of: - # * PayFlow documentation - # * for key value pairs: {Express Checkout for Payflow Pro (PDF)}[https://cms.paypal.com/cms_content/US/en_US/files/developer/PFP_ExpressCheckout_PP.pdf] - # * XMLPay: {Payflow Pro XMLPay Developer's Guide (PDF)}[https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_PayflowPro_XMLPay_Guide.pdf] + # * {PayFlow documentation}[https://developer.paypal.com/docs/classic/payflow/integration-guide/] # * previous ActiveMerchant code # * trial & error # @@ -221,4 +219,3 @@ def build_response(success, message, response, options = {}) end end end - diff --git a/test/remote/gateways/remote_payflow_test.rb b/test/remote/gateways/remote_payflow_test.rb index 23b7a13f37b..1ec03b627a2 100644 --- a/test/remote/gateways/remote_payflow_test.rb +++ b/test/remote/gateways/remote_payflow_test.rb @@ -135,6 +135,32 @@ def test_authorize_and_partial_capture assert_success capture end + def test_authorize_and_complete_capture + assert auth = @gateway.authorize(100 * 2, @credit_card, @options) + assert_success auth + assert_equal 'Approved', auth.message + assert auth.authorization + + assert capture = @gateway.capture(100, auth.authorization, :capture_complete => 'Y') + assert_success capture + + assert capture = @gateway.capture(100, auth.authorization) + assert_failure capture + end + + def test_authorize_and_uncomplete_capture + assert auth = @gateway.authorize(100 * 2, @credit_card, @options) + assert_success auth + assert_equal 'Approved', auth.message + assert auth.authorization + + assert capture = @gateway.capture(100, auth.authorization, :capture_complete => 'N') + assert_success capture + + assert capture = @gateway.capture(100, auth.authorization) + assert_success capture + end + def test_failed_capture assert response = @gateway.capture(100, '999') assert_failure response From 15761ba77de5833ba88f335c6d377d9adcf9a8d7 Mon Sep 17 00:00:00 2001 From: Filipe Costa <filipebarcos@gmail.com> Date: Mon, 13 Aug 2018 12:55:31 -0400 Subject: [PATCH 503/677] Release 1.82.0 --- CHANGELOG | 14 +++++++++----- lib/active_merchant/version.rb | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index af5d69e7097..7c3104ec011 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,15 @@ = ActiveMerchant CHANGELOG == HEAD +== Version 1.82.0 (August 13, 2018) +* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946 +* BlueSnap: Handle 403 responses [curiousepic] #2948 +* BlueSnap: Add StoreCard Field [nfarve] #2953 +* Worldpay: support installments [bpollack] #2957 +* Paymentez: support partial refunds [bpollack] #2959 +* Payflow: allow support for partial captures [pi3r] #2952 + +== Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 * Pin Payments: Pass reference for statement desc [curiousepic] #2919 * FirstData: introduce v27 gateway [shasum] #2912 @@ -17,11 +26,6 @@ * Barclaycard Smartpay: bump API version to v30 [bpollack] #2941 * Safecharge: Remove duplicate supported country [curiousepic] * Payflow Express: Use SHIPTONAME instead of `full_name` for shipping address [filipebarcos] #2945 -* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946 -* BlueSnap: Handle 403 responses [curiousepic] #2948 -* BlueSnap: Add StoreCard Field [nfarve] #2953 -* Worldpay: support installments [bpollack] #2957 -* Paymentez: support partial refunds [bpollack] #2959 == Version 1.80.0 (July 4, 2018) * Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index b305d6325eb..c3ac04fa8c8 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = '1.81.0' + VERSION = '1.82.0' end From 1202eef3fe6bacbcd354eb8393cd8b8f577b1d41 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Mon, 13 Aug 2018 11:37:05 -0400 Subject: [PATCH 504/677] CT Payment: Update How Address is Passed Adds city and state to the address information passed in `CardHolderAddress`. Also allows for verify method to send address information. Loaded suite test/unit/gateways/ct_payment_test .............. 14 tests, 48 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_ct_payment_test .................... 20 tests, 58 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/ct_payment.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7c3104ec011..b8cb47ac6ee 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * Worldpay: support installments [bpollack] #2957 * Paymentez: support partial refunds [bpollack] #2959 * Payflow: allow support for partial captures [pi3r] #2952 +* CT Payment: Update How Address is Passed [nfarve] #2960 == Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb index 0b9083c4cf6..2214645437e 100644 --- a/lib/active_merchant/billing/gateways/ct_payment.rb +++ b/lib/active_merchant/billing/gateways/ct_payment.rb @@ -120,6 +120,7 @@ def verify(credit_card, options={}) add_operator_id(post, options) add_invoice(post,0, options) add_payment(post, credit_card) + add_address(post, credit_card, options) add_customer_data(post, options) commit('verifyAccount', post) @@ -171,7 +172,7 @@ def add_customer_data(post, options) def add_address(post, creditcard, options) if address = options[:billing_address] || options[:address] - post[:CardHolderAddress] = ("#{address[:address1]} #{address[:address2]}").rjust(20, ' ') + post[:CardHolderAddress] = ("#{address[:address1]} #{address[:address2]} #{address[:city]} #{address[:state]}").rjust(20, ' ') post[:CardHolderPostalCode] = address[:zip].gsub(/\s+/, '').rjust(9, ' ') end end From 9062b6d7d0e68ccae8413132d5577589f2cebe36 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Wed, 8 Aug 2018 08:41:32 -0400 Subject: [PATCH 505/677] Adyen: Add RecurringProcessingModel With visa updates, Adyen now requires the type of recurring processing model for all recurring transactions. This adds the neccessary field. Loaded suite test/remote/gateways/remote_adyen_test .................................. 34 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/adyen_test ...................... 22 tests, 102 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 1 + test/remote/gateways/remote_adyen_test.rb | 3 ++- test/unit/gateways/adyen_test.rb | 10 +++++++--- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b8cb47ac6ee..051595682a7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * Paymentez: support partial refunds [bpollack] #2959 * Payflow: allow support for partial captures [pi3r] #2952 * CT Payment: Update How Address is Passed [nfarve] #2960 +* Adyen: Add RecurringProcessingModel [nfarve] #2951 == Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index 6a118616b63..d938036894e 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -148,6 +148,7 @@ def add_invoice(post, money, options) currency: options[:currency] || currency(money) } post[:amount] = amount + post[:recurringProcessingModel] = options[:recurring_processing_model] if options[:recurring_processing_model] end def add_invoice_for_modification(post, money, options) diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb index e4f752d2260..6a6bd3240d8 100644 --- a/test/remote/gateways/remote_adyen_test.rb +++ b/test/remote/gateways/remote_adyen_test.rb @@ -31,7 +31,8 @@ def setup shopper_ip: '77.110.174.153', shopper_reference: 'John Smith', billing_address: address(), - order_id: '123' + order_id: '123', + recurring_processing_model: 'CardOnFile' } end diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index e9f7753b76f..b752a9c4875 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -33,7 +33,8 @@ def setup billing_address: address(), shopper_reference: 'John Smith', order_id: '345123', - installments: 2 + installments: 2, + recurring_processing_model: 'CardOnFile' } end @@ -156,8 +157,11 @@ def test_failed_void end def test_successful_store - @gateway.expects(:ssl_post).returns(successful_store_response) - response = @gateway.store(@credit_card, @options) + response = stub_comms do + @gateway.store(@credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_equal 'CardOnFile', JSON.parse(data)['recurringProcessingModel'] + end.respond_with(successful_store_response) assert_success response assert_equal '#8835205392522157#8315202663743702', response.authorization end From 2c7f5e316ce0d3f4a10268da0a4189c95d448ae7 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 14 Aug 2018 09:55:55 -0400 Subject: [PATCH 506/677] Optimal: document additional country support --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/optimal_payment.rb | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 051595682a7..936c008a9ef 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * Payflow: allow support for partial captures [pi3r] #2952 * CT Payment: Update How Address is Passed [nfarve] #2960 * Adyen: Add RecurringProcessingModel [nfarve] #2951 +* Optimal Payments: update country list [bpollack] #2961 == Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb index 2bf3b323f97..2641cf7994a 100644 --- a/lib/active_merchant/billing/gateways/optimal_payment.rb +++ b/lib/active_merchant/billing/gateways/optimal_payment.rb @@ -5,7 +5,9 @@ class OptimalPaymentGateway < Gateway self.live_url = 'https://webservices.optimalpayments.com/creditcardWS/CreditCardServlet/v1' # The countries the gateway supports merchants from as 2 digit ISO country codes - self.supported_countries = ['CA', 'US', 'GB'] + self.supported_countries = ['CA', 'US', 'GB', 'AU', 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', + 'EE', 'FI', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', + 'NL', 'NO', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'CH'] # The card types supported by the payment gateway self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :solo] # :switch? From e4ba8e6618a101fb8a46384c72f9553451078420 Mon Sep 17 00:00:00 2001 From: Vinicius Brasil <vinicius@ebanx.com> Date: Wed, 8 Aug 2018 00:56:38 -0300 Subject: [PATCH 507/677] Update EBANX API URL Remote tests failing don't appear to be related to the URL change. Unit: 16 tests, 54 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 21 tests, 57 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 85.7143% passed Closes #2949 --- lib/active_merchant/billing/gateways/ebanx.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb index ef42b12d449..1dc51b009cc 100644 --- a/lib/active_merchant/billing/gateways/ebanx.rb +++ b/lib/active_merchant/billing/gateways/ebanx.rb @@ -1,15 +1,15 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class EbanxGateway < Gateway - self.test_url = 'https://sandbox.ebanx.com/ws/' - self.live_url = 'https://api.ebanx.com/ws/' + self.test_url = 'https://sandbox.ebanxpay.com/ws/' + self.live_url = 'https://api.ebanxpay.com/ws/' self.supported_countries = ['BR', 'MX', 'CO'] self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club] self.homepage_url = 'http://www.ebanx.com/' - self.display_name = 'Ebanx' + self.display_name = 'EBANX' CARD_BRAND = { visa: 'visa', From 09d54fb0e4ce35df04c777ac73cb4f8a55fb0ed0 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 16 Aug 2018 15:40:42 -0400 Subject: [PATCH 508/677] Add missing CHANGELOG entry for #2949 --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 936c008a9ef..f30bbe20dfd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * CT Payment: Update How Address is Passed [nfarve] #2960 * Adyen: Add RecurringProcessingModel [nfarve] #2951 * Optimal Payments: update country list [bpollack] #2961 +* Ebanx: update sandbox and production URLs [vnbrs] #2949 == Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 From 9e3cc3e001a45767aef81623ee2a0985a838be9e Mon Sep 17 00:00:00 2001 From: Vinicius Brasil <vinicius@ebanx.com> Date: Wed, 8 Aug 2018 01:02:55 -0300 Subject: [PATCH 509/677] Add additional countries for EBANX EBANX accepts credit card payments from Chile and Argentina (https://business.ebanx.com/en/payment-methods). Closes #2950 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/ebanx.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index f30bbe20dfd..507ec3691bd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * Adyen: Add RecurringProcessingModel [nfarve] #2951 * Optimal Payments: update country list [bpollack] #2961 * Ebanx: update sandbox and production URLs [vnbrs] #2949 +* Ebanx: support additional countries [vnbrs] #2950 == Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb index 1dc51b009cc..d22affa971f 100644 --- a/lib/active_merchant/billing/gateways/ebanx.rb +++ b/lib/active_merchant/billing/gateways/ebanx.rb @@ -4,7 +4,7 @@ class EbanxGateway < Gateway self.test_url = 'https://sandbox.ebanxpay.com/ws/' self.live_url = 'https://api.ebanxpay.com/ws/' - self.supported_countries = ['BR', 'MX', 'CO'] + self.supported_countries = ['BR', 'MX', 'CO', 'CL', 'AR'] self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club] From c9c1e3bf665c84d687e3f9625469c602ebcbb532 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 16 Aug 2018 15:30:37 -0400 Subject: [PATCH 510/677] Fix typo in gateway generator When I fixed YAML, I accidentally committed this script with parens in the wrong place. Fix that. --- CHANGELOG | 1 + generators/gateway/gateway_generator.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 507ec3691bd..1937f880a09 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * Optimal Payments: update country list [bpollack] #2961 * Ebanx: update sandbox and production URLs [vnbrs] #2949 * Ebanx: support additional countries [vnbrs] #2950 +* Gateway generator: fix a typo that would cause the script to crash [bpollack] #2962 == Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 diff --git a/generators/gateway/gateway_generator.rb b/generators/gateway/gateway_generator.rb index febddbb1c7e..27dda8aa510 100644 --- a/generators/gateway/gateway_generator.rb +++ b/generators/gateway/gateway_generator.rb @@ -38,7 +38,7 @@ def fixtures_file end def next_identifier - fixtures = (YAML.safe_load(File.read(fixtures_file)).keys + [identifier], [], [], true).uniq.sort + fixtures = (YAML.safe_load(File.read(fixtures_file), [], [], true).keys + [identifier]).uniq.sort fixtures[fixtures.sort.index(identifier)+1] end end From 3534c7741a1b0bad9f19df85e2eea0286c47d2c1 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 16 Aug 2018 15:46:23 -0400 Subject: [PATCH 511/677] Remove unused variables and fix ambiguous invocations This patch contains four quick fixes, all for ambiguous code or unused variables. Specifically, the following issues are rectified: - test/unit/connection_test.rb:51: warning: assigned but unused variable - response - test/unit/gateways/firstdata_e4_v27_test.rb:56: warning: ambiguous first argument; put parentheses or a space even after `/' operator - test/unit/gateways/paymentez_test.rb:121: warning: ambiguous first argument; put parentheses or a space even after `/' operator - lib/active_merchant/billing/gateways/ct_payment.rb:210: warning: assigned but unused variable - final_response --- lib/active_merchant/billing/gateways/ct_payment.rb | 2 +- test/unit/connection_test.rb | 2 +- test/unit/gateways/firstdata_e4_v27_test.rb | 2 +- test/unit/gateways/paymentez_test.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb index 2214645437e..18b111f0a12 100644 --- a/lib/active_merchant/billing/gateways/ct_payment.rb +++ b/lib/active_merchant/billing/gateways/ct_payment.rb @@ -207,7 +207,7 @@ def commit_raw(action, parameters) url = (test? ? test_url : live_url) + action response = parse(ssl_post(url, post_data(action, parameters))) - final_response = Response.new( + Response.new( success_from(response), message_from(response), response, diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index 564fea45f49..c33797de2a0 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -48,7 +48,7 @@ def test_connection_does_not_mutate_headers_argument headers = { 'Content-Type' => 'text/xml' }.freeze Net::HTTP.any_instance.expects(:get).with('/tx.php', headers.merge({'connection' => 'close'})).returns(@ok) Net::HTTP.any_instance.expects(:start).returns(true) - response = @connection.request(:get, nil, headers) + @connection.request(:get, nil, headers) assert_equal({ 'Content-Type' => 'text/xml' }, headers) end diff --git a/test/unit/gateways/firstdata_e4_v27_test.rb b/test/unit/gateways/firstdata_e4_v27_test.rb index 3e502c430e8..305faf51efb 100644 --- a/test/unit/gateways/firstdata_e4_v27_test.rb +++ b/test/unit/gateways/firstdata_e4_v27_test.rb @@ -53,7 +53,7 @@ def test_successful_purchase_with_wallet response = stub_comms do @gateway.purchase(@amount, @credit_card, @options.merge!({wallet_provider_id: 4})) end.check_request do |endpoint, data, headers| - assert_match /WalletProviderID>4</, data + assert_match(/WalletProviderID>4</, data) end.respond_with(successful_purchase_response) assert_success response diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb index 8cfd9eb690d..166ab7ebcf0 100644 --- a/test/unit/gateways/paymentez_test.rb +++ b/test/unit/gateways/paymentez_test.rb @@ -118,7 +118,7 @@ def test_partial_refund response = stub_comms do @gateway.refund(@amount, '1234', @options) end.check_request do |_endpoint, data, _headers| - assert_match /"amount":1.0/, data + assert_match(/"amount":1.0/, data) end.respond_with(successful_refund_response) assert_success response assert response.test? From 1dda734b861d317f17b7858d02a59e7d8f7da556 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 20 Aug 2018 13:41:42 -0400 Subject: [PATCH 512/677] Clearhaus: use $0 for verification tests Clearhaus now allows $0 auths, allowing us to tweak verify to use a $0 transaction. Unit: 22 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 23 tests, 70 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/clearhaus.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 1937f880a09..b5dbb605fb2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * Ebanx: update sandbox and production URLs [vnbrs] #2949 * Ebanx: support additional countries [vnbrs] #2950 * Gateway generator: fix a typo that would cause the script to crash [bpollack] #2962 +* Clearhaus: use $0 for verify transactions [bpollack] #2964 == Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 diff --git a/lib/active_merchant/billing/gateways/clearhaus.rb b/lib/active_merchant/billing/gateways/clearhaus.rb index 43b68fb56c4..4fd7745f395 100644 --- a/lib/active_merchant/billing/gateways/clearhaus.rb +++ b/lib/active_merchant/billing/gateways/clearhaus.rb @@ -88,7 +88,7 @@ def void(authorization, options = {}) def verify(credit_card, options={}) MultiResponse.run(:use_first_response) do |r| - r.process { authorize(100, credit_card, options) } + r.process { authorize(0, credit_card, options) } r.process(:ignore_result) { void(r.authorization, options) } end end From a1a5c99786d38fe099c8e4b601f8d4df6b46bebc Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 24 Aug 2018 08:49:40 -0400 Subject: [PATCH 513/677] Global Collect: allow partial captures Unit: 17 tests, 78 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 16 tests, 38 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/global_collect.rb | 17 +++++++++-------- .../gateways/remote_global_collect_test.rb | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b5dbb605fb2..07156f32d4b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * Ebanx: support additional countries [vnbrs] #2950 * Gateway generator: fix a typo that would cause the script to crash [bpollack] #2962 * Clearhaus: use $0 for verify transactions [bpollack] #2964 +* Global Collect: properly handle partial captures [bpollack] #2967 == Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 2bd27df7aed..7942dbcec76 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -4,8 +4,8 @@ class GlobalCollectGateway < Gateway self.display_name = 'GlobalCollect' self.homepage_url = 'http://www.globalcollect.com/' - self.test_url = 'https://eu.sandbox.api-ingenico.com/' - self.live_url = 'https://api.globalcollect.com/' + self.test_url = 'https://eu.sandbox.api-ingenico.com' + self.live_url = 'https://api.globalcollect.com' self.supported_countries = ['AD', 'AE', 'AG', 'AI', 'AL', 'AM', 'AO', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PL', 'PN', 'PS', 'PT', 'PW', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SR', 'ST', 'SV', 'SZ', 'TC', 'TD', 'TG', 'TH', 'TJ', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'US', 'UY', 'UZ', 'VC', 'VE', 'VG', 'VI', 'VN', 'WF', 'WS', 'ZA', 'ZM', 'ZW'] self.default_currency = 'USD' @@ -38,7 +38,7 @@ def authorize(money, payment, options={}) def capture(money, authorization, options={}) post = nestable_hash - add_order(post, money, options) + add_order(post, money, options, capture: true) add_customer_data(post, options) add_creator_info(post, options) commit(:capture, post, authorization) @@ -87,11 +87,12 @@ def scrub(transcript) 'diners_club' => '132' } - def add_order(post, money, options) - post['order']['amountOfMoney'] = { - 'amount' => amount(money), - 'currencyCode' => options[:currency] || currency(money) - } + def add_order(post, money, options, capture: false) + if capture + post['amount'] = amount(money) + else + add_amount(post['order'], money, options) + end post['order']['references'] = { 'merchantReference' => options[:order_id], 'descriptor' => options[:description] # Max 256 chars diff --git a/test/remote/gateways/remote_global_collect_test.rb b/test/remote/gateways/remote_global_collect_test.rb index 519db653470..b7497b13f00 100644 --- a/test/remote/gateways/remote_global_collect_test.rb +++ b/test/remote/gateways/remote_global_collect_test.rb @@ -88,8 +88,9 @@ def test_partial_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert capture = @gateway.capture(@amount-1, auth.authorization) + assert capture = @gateway.capture(@amount - 1, auth.authorization) assert_success capture + assert_equal 99, capture.params['payment']['paymentOutput']['amountOfMoney']['amount'] end def test_failed_capture From 416e4a8d6e3a236a31b33ee98d084b6fa55cef78 Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Fri, 24 Aug 2018 08:01:28 -0400 Subject: [PATCH 514/677] Braintree: Add support for GooglePay Adds support for processing GooglePay payment methods. It appears that Braintree treats GooglePay in the same manner as AndroidPay. Even their documentation (linked below) claims that GooglePay cards are represented as AndroidPay cards. As such, the only way to get the GooglePay remote test to pass is to pass the payment information in as `android_pay`. Ref: https://developers.braintreepayments.com/guides/google-pay/server-side/ruby Remote: 63 tests, 361 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 50 tests, 124 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- .rubocop_todo.yml | 2 ++ CHANGELOG | 1 + .../billing/gateways/braintree_blue.rb | 2 +- .../gateways/remote_braintree_blue_test.rb | 18 ++++++++++ test/unit/gateways/braintree_blue_test.rb | 34 +++++++++++++++++++ 5 files changed, 56 insertions(+), 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 35c175ad580..b5e9ff77717 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -659,6 +659,8 @@ Metrics/ParameterLists: # Offense count: 126 Metrics/PerceivedComplexity: Max: 32 + Exclude: + - 'lib/active_merchant/billing/gateways/braintree_blue.rb' # Offense count: 6 Naming/AccessorMethodName: diff --git a/CHANGELOG b/CHANGELOG index 07156f32d4b..d1308957428 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * Gateway generator: fix a typo that would cause the script to crash [bpollack] #2962 * Clearhaus: use $0 for verify transactions [bpollack] #2964 * Global Collect: properly handle partial captures [bpollack] #2967 +* Braintree: Add support for GooglePay [dtykocki] [#2966] == Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 96bdbdae5b8..7f0dbcaacbf 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -598,7 +598,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) :cryptogram => credit_card_or_vault_id.payment_cryptogram, :eci_indicator => credit_card_or_vault_id.eci } - elsif credit_card_or_vault_id.source == :android_pay + elsif credit_card_or_vault_id.source == :android_pay || credit_card_or_vault_id.source == :google_pay parameters[:android_pay_card] = { :number => credit_card_or_vault_id.number, :cryptogram => credit_card_or_vault_id.payment_cryptogram, diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index 82ad314494b..5f48f9ee313 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -432,6 +432,24 @@ def test_authorize_and_capture_with_android_pay_card assert_success capture end + def test_authorize_and_capture_with_google_pay_card + credit_card = network_tokenization_credit_card('4111111111111111', + :payment_cryptogram => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', + :month => '01', + :year => '2024', + :source => :google_pay, + :transaction_id => '123456789', + :eci => '05' + ) + + assert auth = @gateway.authorize(@amount, credit_card, @options) + assert_success auth + assert_equal '1000 Approved', auth.message + assert auth.authorization + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture + end + def test_authorize_and_void assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index ff67f2dc983..194c7552176 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -681,6 +681,40 @@ def test_android_pay_card assert_equal 'transaction_id', response.authorization end + def test_google_pay_card + Braintree::TransactionGateway.any_instance.expects(:sale). + with( + :amount => '1.00', + :order_id => '1', + :customer => {:id => nil, :email => nil, :phone => nil, + :first_name => 'Longbob', :last_name => 'Longsen'}, + :options => {:store_in_vault => false, :submit_for_settlement => nil, :hold_in_escrow => nil}, + :custom_fields => nil, + :android_pay_card => { + :number => '4111111111111111', + :expiration_month => '09', + :expiration_year => (Time.now.year + 1).to_s, + :cryptogram => '111111111100cryptogram', + :google_transaction_id => '1234567890', + :source_card_type => 'visa', + :source_card_last_four => '1111', + :eci_indicator => '05' + } + ). + returns(braintree_result(:id => 'transaction_id')) + + credit_card = network_tokenization_credit_card('4111111111111111', + :brand => 'visa', + :eci => '05', + :payment_cryptogram => '111111111100cryptogram', + :source => :google_pay, + :transaction_id => '1234567890' + ) + + response = @gateway.authorize(100, credit_card, :test => true, :order_id => '1') + assert_equal 'transaction_id', response.authorization + end + def test_supports_network_tokenization assert_instance_of TrueClass, @gateway.supports_network_tokenization? end From db3a22b8a49638a426f84cc48a8d283f08942e42 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 23 Aug 2018 14:59:03 -0400 Subject: [PATCH 515/677] Adyen: add Maestro and Electron support Unit: 23 tests, 109 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 35 tests, 88 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 5 +++- test/remote/gateways/remote_adyen_test.rb | 24 +++++++++++++++---- test/unit/gateways/adyen_test.rb | 14 +++++++++++ 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d1308957428..a77eb3b0f6d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ * Clearhaus: use $0 for verify transactions [bpollack] #2964 * Global Collect: properly handle partial captures [bpollack] #2967 * Braintree: Add support for GooglePay [dtykocki] [#2966] +* Adyen: allow overriding card brands [bpollack] #2968 == Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index d938036894e..822043c8c97 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -114,9 +114,12 @@ def add_extra_data(post, payment, options) post[:shopperIP] = options[:shopper_ip] if options[:shopper_ip] post[:shopperReference] = options[:shopper_reference] if options[:shopper_reference] post[:fraudOffset] = options[:fraud_offset] if options[:fraud_offset] - post[:selectedBrand] = options[:selected_brand] || NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard) + post[:selectedBrand] = options[:selected_brand] if options[:selected_brand] + post[:selectedBrand] ||= NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard) post[:deliveryDate] = options[:delivery_date] if options[:delivery_date] post[:merchantOrderReference] = options[:merchant_order_reference] if options[:merchant_order_reference] + post[:additionalData] ||= {} + post[:additionalData][:overwriteBrand] = normalize(options[:overwrite_brand]) if options[:overwrite_brand] end def add_shopper_interaction(post, payment, options={}) diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb index 6a6bd3240d8..b717292cba3 100644 --- a/test/remote/gateways/remote_adyen_test.rb +++ b/test/remote/gateways/remote_adyen_test.rb @@ -17,6 +17,16 @@ def setup @declined_card = credit_card('4000300011112220') + @improperly_branded_maestro = credit_card( + '5500000000000004', + month: 8, + year: 2018, + first_name: 'John', + last_name: 'Smith', + verification_value: '737', + brand: 'mastercard' + ) + @apple_pay_card = network_tokenization_credit_card('4111111111111111', :payment_cryptogram => 'YwAAAAAABaYcCMX/OhNRQAAAAAA=', :month => '08', @@ -45,7 +55,7 @@ def test_successful_authorize def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal 'Refused', response.message + assert_equal 'CVC Declined', response.message end def test_successful_purchase @@ -75,10 +85,16 @@ def test_successful_purchase_with_apple_pay assert_equal '[capture-received]', response.message end + def test_succesful_purchase_with_brand_override + response = @gateway.purchase(@amount, @improperly_branded_maestro, @options.merge({overwrite_brand: true, selected_brand: 'maestro'})) + assert_success response + assert_equal '[capture-received]', response.message + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal 'Refused', response.message + assert_equal 'CVC Declined', response.message end def test_successful_authorize_and_capture @@ -154,7 +170,7 @@ def test_failed_store assert response = @gateway.store(@declined_card, @options) assert_failure response - assert_equal 'Refused', response.message + assert_equal 'CVC Declined', response.message end def test_successful_purchase_using_stored_card @@ -184,7 +200,7 @@ def test_successful_verify def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_match 'Refused', response.message + assert_match 'CVC Declined', response.message end def test_invalid_login diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index b752a9c4875..0b3d5df48a5 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -100,6 +100,20 @@ def test_successful_purchase assert response.test? end + def test_successful_maestro_purchase + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge({selected_brand: 'maestro', overwrite_brand: 'true'})) + end.check_request do |endpoint, data, headers| + if endpoint =~ /authorise/ + assert_match(/"overwriteBrand":true/, data) + assert_match(/"selectedBrand":"maestro"/, data) + end + end.respond_with(successful_authorize_response, successful_capture_response) + assert_success response + assert_equal '7914775043909934#8814775564188305#', response.authorization + assert response.test? + end + def test_installments_sent stub_comms do @gateway.authorize(@amount, @credit_card, @options) From ddd7abdff569ada2212f1dce2ae4dc15080e07ff Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 27 Aug 2018 15:29:57 -0400 Subject: [PATCH 516/677] Adyen: add support for customRoutingFlag Note that this can't really be tested in the sandbox (it's changing how Adyen processes the card, so the sandbox doesn't do anything with it), so remote tests are omitted. Remote: 35 tests, 88 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 24 tests, 112 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 1 + test/unit/gateways/adyen_test.rb | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index a77eb3b0f6d..8ab49a258bd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * Global Collect: properly handle partial captures [bpollack] #2967 * Braintree: Add support for GooglePay [dtykocki] [#2966] * Adyen: allow overriding card brands [bpollack] #2968 +* Adyen: allow custom routing [bpollack] #2969 == Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index 822043c8c97..09961e936e1 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -120,6 +120,7 @@ def add_extra_data(post, payment, options) post[:merchantOrderReference] = options[:merchant_order_reference] if options[:merchant_order_reference] post[:additionalData] ||= {} post[:additionalData][:overwriteBrand] = normalize(options[:overwrite_brand]) if options[:overwrite_brand] + post[:additionalData][:customRoutingFlag] = options[:custom_routing_flag] if options[:custom_routing_flag] end def add_shopper_interaction(post, payment, options={}) diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index 0b3d5df48a5..c989b1d45b9 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -122,6 +122,14 @@ def test_installments_sent end.respond_with(successful_authorize_response) end + def test_custom_routing_sent + stub_comms do + @gateway.authorize(@amount, @credit_card, @options.merge({custom_routing_flag: 'abcdefg'})) + end.check_request do |endpoint, data, headers| + assert_equal 'abcdefg', JSON.parse(data)['additionalData']['customRoutingFlag'] + end.respond_with(successful_authorize_response) + end + def test_failed_purchase @gateway.expects(:ssl_post).returns(failed_purchase_response) From 0e779a865869dcfb7674cbd5b042a55f3025ea8a Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder <deedeelavinder@gmail.com> Date: Wed, 29 Aug 2018 11:18:06 -0400 Subject: [PATCH 517/677] First Pay: Adds scrubbing for gateway_id, card_number, and cvv2 Unit Tests: 12 tests, 119 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote Tests: 14 tests, 32 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/first_pay.rb | 11 ++++ test/remote/gateways/remote_first_pay_test.rb | 12 +++++ test/unit/gateways/first_pay_test.rb | 51 +++++++++++++++++++ 4 files changed, 75 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 8ab49a258bd..8d3d21c4ca9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * Braintree: Add support for GooglePay [dtykocki] [#2966] * Adyen: allow overriding card brands [bpollack] #2968 * Adyen: allow custom routing [bpollack] #2969 +* First Pay: Adds scrubbing [deedeelavinder] #2972 == Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb index 0c0b6ff4897..08b4f417986 100644 --- a/lib/active_merchant/billing/gateways/first_pay.rb +++ b/lib/active_merchant/billing/gateways/first_pay.rb @@ -56,6 +56,17 @@ def void(authorization, options={}) commit('void', post) end + def supports_scrubbing? + true + end + + def scrub(transcript) + transcript. + gsub(%r((gateway_id)[^<]*(</FIELD>))i, '\1[FILTERED]\2'). + gsub(%r((card_number)[^<]*(</FIELD>))i, '\1[FILTERED]\2'). + gsub(%r((cvv2)[^<]*(</FIELD>))i, '\1[FILTERED]\2') + end + private def add_authentication(post, options) diff --git a/test/remote/gateways/remote_first_pay_test.rb b/test/remote/gateways/remote_first_pay_test.rb index 23aa35e8a30..3edab642a57 100644 --- a/test/remote/gateways/remote_first_pay_test.rb +++ b/test/remote/gateways/remote_first_pay_test.rb @@ -116,4 +116,16 @@ def test_recurring_payment assert_success response assert_equal 'Approved', response.message end + + def test_transcript_scrubbing + @credit_card.verification_value = 789 + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + transcript = @gateway.scrub(transcript) + + assert_scrubbed(@credit_card.number, transcript) + assert_scrubbed(@credit_card.verification_value, transcript) + assert_scrubbed(@gateway.options[:gateway_id], transcript) + end end diff --git a/test/unit/gateways/first_pay_test.rb b/test/unit/gateways/first_pay_test.rb index 6596389bf64..1e0bab16e96 100644 --- a/test/unit/gateways/first_pay_test.rb +++ b/test/unit/gateways/first_pay_test.rb @@ -199,6 +199,11 @@ def test_recurring_payments assert_success response end + def test_scrub + assert @gateway.supports_scrubbing? + assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed + end + private def successful_purchase_response @@ -362,6 +367,52 @@ def failed_void_response <FIELD KEY="reference_number1">1</FIELD> <FIELD KEY="error1" /> </FIELDS> +</RESPONSE>) + end + + def pre_scrubbed + %(<RESPONSE> + <FIELDS> + <FIELD KEY="order_id">77b61bfe08510e00852f2f20011e7952d80f9a4be17d27cf</FIELD> + <FIELD KEY="total">1.00</FIELD><FIELD KEY="card_name">visa</FIELD> + <FIELD KEY="card_number">4111111111111111</FIELD> + <FIELD KEY="card_exp">0919</FIELD> + <FIELD KEY="cvv2">789</FIELD> + <FIELD KEY="owner_name">Jim Smith</FIELD> + <FIELD KEY="owner_street">456 My Street</FIELD> + <FIELD KEY="owner_street2">Apt 1</FIELD> + <FIELD KEY="owner_city">Ottawa</FIELD> + <FIELD KEY="owner_state">ON</FIELD> + <FIELD KEY="owner_zip">K1C2N6</FIELD> + <FIELD KEY="owner_country">CA</FIELD> + <FIELD KEY="owner_phone">(555)555-5555</FIELD> + <FIELD KEY="transaction_center_id">1264</FIELD> + <FIELD KEY="gateway_id">a91c38c3-7d7f-4d29-acc7-927b4dca0dbe</FIELD> + <FIELD KEY="operation_type">sale</FIELD> + </FIELDS> +</RESPONSE>) + end + + def post_scrubbed + %(<RESPONSE> + <FIELDS> + <FIELD KEY=\"order_id\">77b61bfe08510e00852f2f20011e7952d80f9a4be17d27cf</FIELD> + <FIELD KEY=\"total\">1.00</FIELD><FIELD KEY=\"card_name\">visa</FIELD> + <FIELD KEY=\"card_number[FILTERED]</FIELD> + <FIELD KEY=\"card_exp\">0919</FIELD> + <FIELD KEY=\"cvv2[FILTERED]</FIELD> + <FIELD KEY=\"owner_name\">Jim Smith</FIELD> + <FIELD KEY=\"owner_street\">456 My Street</FIELD> + <FIELD KEY=\"owner_street2\">Apt 1</FIELD> + <FIELD KEY=\"owner_city\">Ottawa</FIELD> + <FIELD KEY=\"owner_state\">ON</FIELD> + <FIELD KEY=\"owner_zip\">K1C2N6</FIELD> + <FIELD KEY=\"owner_country\">CA</FIELD> + <FIELD KEY=\"owner_phone\">(555)555-5555</FIELD> + <FIELD KEY=\"transaction_center_id\">1264</FIELD> + <FIELD KEY=\"gateway_id[FILTERED]</FIELD> + <FIELD KEY=\"operation_type\">sale</FIELD> + </FIELDS> </RESPONSE>) end end From 58673ca6dac74eca05bf747da9018259161874bc Mon Sep 17 00:00:00 2001 From: Michael Elfassy <michaelelfassy@gmail.com> Date: Thu, 30 Aug 2018 08:33:26 -0400 Subject: [PATCH 518/677] Release 1.83.0 --- CHANGELOG | 17 ++++++++++------- lib/active_merchant/version.rb | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8d3d21c4ca9..cfc8d11137b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,13 +1,8 @@ = ActiveMerchant CHANGELOG == HEAD -== Version 1.82.0 (August 13, 2018) -* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946 -* BlueSnap: Handle 403 responses [curiousepic] #2948 -* BlueSnap: Add StoreCard Field [nfarve] #2953 -* Worldpay: support installments [bpollack] #2957 -* Paymentez: support partial refunds [bpollack] #2959 -* Payflow: allow support for partial captures [pi3r] #2952 + +== Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 * Adyen: Add RecurringProcessingModel [nfarve] #2951 * Optimal Payments: update country list [bpollack] #2961 @@ -21,6 +16,14 @@ * Adyen: allow custom routing [bpollack] #2969 * First Pay: Adds scrubbing [deedeelavinder] #2972 +== Version 1.82.0 (August 13, 2018) +* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946 +* BlueSnap: Handle 403 responses [curiousepic] #2948 +* BlueSnap: Add StoreCard Field [nfarve] #2953 +* Worldpay: support installments [bpollack] #2957 +* Paymentez: support partial refunds [bpollack] #2959 +* Payflow: allow support for partial captures [pi3r] #2952 + == Version 1.81.0 (July 30, 2018) * GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915 * Pin Payments: Pass reference for statement desc [curiousepic] #2919 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index c3ac04fa8c8..e0f40471379 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = '1.82.0' + VERSION = '1.83.0' end From 0061962c749b2c05d4f103b98c35720834645912 Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Fri, 24 Aug 2018 18:24:58 -0400 Subject: [PATCH 519/677] Adyen: Add support for GooglePay Unit: 24 tests, 113 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 36 tests, 90 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 1 + test/remote/gateways/remote_adyen_test.rb | 14 ++++++++++++++ test/unit/gateways/adyen_test.rb | 6 ++++-- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cfc8d11137b..a2d8271ef2a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * Adyen: allow overriding card brands [bpollack] #2968 * Adyen: allow custom routing [bpollack] #2969 * First Pay: Adds scrubbing [deedeelavinder] #2972 +* Adyen: Add support for GooglePay [dtykocki] #2971 == Version 1.82.0 (August 13, 2018) * FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index 09961e936e1..d7fb3a94042 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -121,6 +121,7 @@ def add_extra_data(post, payment, options) post[:additionalData] ||= {} post[:additionalData][:overwriteBrand] = normalize(options[:overwrite_brand]) if options[:overwrite_brand] post[:additionalData][:customRoutingFlag] = options[:custom_routing_flag] if options[:custom_routing_flag] + post[:additionalData]['paymentdatasource.type'] = NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard) end def add_shopper_interaction(post, payment, options={}) diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb index b717292cba3..0ba48c81be2 100644 --- a/test/remote/gateways/remote_adyen_test.rb +++ b/test/remote/gateways/remote_adyen_test.rb @@ -35,6 +35,14 @@ def setup :verification_value => nil ) + @google_pay_card = network_tokenization_credit_card('4111111111111111', + :payment_cryptogram => 'YwAAAAAABaYcCMX/OhNRQAAAAAA=', + :month => '08', + :year => '2018', + :source => :google_pay, + :verification_value => nil + ) + @options = { reference: '345123', shopper_email: 'john.smith@test.com', @@ -91,6 +99,12 @@ def test_succesful_purchase_with_brand_override assert_equal '[capture-received]', response.message end + def test_successful_purchase_with_google_pay + response = @gateway.purchase(@amount, @google_pay_card, @options) + assert_success response + assert_equal '[capture-received]', response.message + end + def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index c989b1d45b9..053b160516a 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -261,8 +261,10 @@ def test_authorize_with_network_tokenization_credit_card response = stub_comms do @gateway.authorize(@amount, @apple_pay_card, @options) end.check_request do |endpoint, data, headers| - assert_equal 'YwAAAAAABaYcCMX/OhNRQAAAAAA=', JSON.parse(data)['mpiData']['cavv'] - assert_equal '07', JSON.parse(data)['mpiData']['eci'] + parsed = JSON.parse(data) + assert_equal 'YwAAAAAABaYcCMX/OhNRQAAAAAA=', parsed['mpiData']['cavv'] + assert_equal '07', parsed['mpiData']['eci'] + assert_equal 'applepay', parsed['additionalData']['paymentdatasource.type'] end.respond_with(successful_authorize_response) assert_success response end From 00287a262d0607b206e0682a789dc368e3fbc2d8 Mon Sep 17 00:00:00 2001 From: "Matt R. Wilson" <mwilson@shutterstock.com> Date: Thu, 30 Aug 2018 10:37:54 -0600 Subject: [PATCH 520/677] Check if using SSL before getting SSL conn info. Was getting this error in a project when running its acceptance tests against a mocking service that used a `http` schema. ``` undefined method `ssl_version' for #<TCPSocket:(closed)> $GEMS/bundler/gems/active_merchant-f3d11caabc66/lib/active_merchant/net_http_ssl_connection.rb:7:in `ssl_connection' $GEMS/bundler/gems/active_merchant-f3d11caabc66/lib/active_merchant/connection.rb:82:in `block (2 levels) in request' ``` --- lib/active_merchant/net_http_ssl_connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_merchant/net_http_ssl_connection.rb b/lib/active_merchant/net_http_ssl_connection.rb index d0764cbc615..c0ae5ce1080 100644 --- a/lib/active_merchant/net_http_ssl_connection.rb +++ b/lib/active_merchant/net_http_ssl_connection.rb @@ -3,7 +3,7 @@ module NetHttpSslConnection refine Net::HTTP do def ssl_connection - return {} unless @socket.present? + return {} unless use_ssl? && @socket.present? { version: @socket.io.ssl_version, cipher: @socket.io.cipher[0] } end end From 85c57a6c2d15ae86ab3713120bf9d2277260cd26 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 30 Aug 2018 11:51:29 -0400 Subject: [PATCH 521/677] PayU Latam: add partial capture support Note that PayU Latam's sandbox does not support capture, so while I added remote tests, they're more...let's call it hypothetical. Failing remote tests are unrelated to this change Unit: 28 tests, 104 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 30 tests, 68 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 86.6667% passed --- CHANGELOG | 1 + .../billing/gateways/payu_latam.rb | 11 ++++++- .../remote/gateways/remote_payu_latam_test.rb | 30 ++++++++++++++++++- test/unit/gateways/payu_latam_test.rb | 8 +++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a2d8271ef2a..4e989e3cd3c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* PayU Latam: support partial captures [bpollack] #2974 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index a3192fe79e7..5d3dc1af6b5 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -52,6 +52,11 @@ def capture(amount, authorization, options={}) add_transaction_elements(post, 'CAPTURE', options) add_reference(post, authorization) + if !amount.nil? && amount.to_f != 0.0 + post[:transaction][:additionalValues] ||= {} + post[:transaction][:additionalValues][:TX_VALUE] = invoice_for(amount, options)[:TX_VALUE] + end + commit('capture', post) end @@ -220,6 +225,10 @@ def shipping_address_fields(options) end def add_invoice(post, money, options) + post[:transaction][:order][:additionalValues] = invoice_for(money, options) + end + + def invoice_for(money, options) tx_value = {} tx_value[:value] = amount(money) tx_value[:currency] = options[:currency] || currency(money) @@ -237,7 +246,7 @@ def add_invoice(post, money, options) additional_values[:TX_TAX] = tx_tax if @options[:payment_country] == 'CO' additional_values[:TX_TAX_RETURN_BASE] = tx_tax_return_base if @options[:payment_country] == 'CO' - post[:transaction][:order][:additionalValues] = additional_values + additional_values end def add_signature(post) diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index a33a22558dd..316aaee30a4 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -251,6 +251,34 @@ def test_failed_authorize_with_specified_language assert_equal 'Credenciales inválidas', response.message end + # As noted above, capture transactions are currently not supported, but in the hope + # they will one day be, here you go + + # def test_successful_capture + # response = @gateway.authorize(@amount, @credit_card, @options) + # assert_success response + # assert_equal 'APPROVED', response.message + # assert_match %r(^\d+\|(\w|-)+$), response.authorization + + # capture = @gateway.capture(@amount, response.authorization, @options) + # assert_success capture + # assert_equal 'APPROVED', response.message + # assert response.test? + # end + + # def test_successful_partial_capture + # response = @gateway.authorize(@amount, @credit_card, @options) + # assert_success response + # assert_equal 'APPROVED', response.message + # assert_match %r(^\d+\|(\w|-)+$), response.authorization + + # capture = @gateway.capture(@amount - 1, response.authorization, @options) + # assert_success capture + # assert_equal 'APPROVED', response.message + # assert_equal '39.99', response.params['TX_VALUE']['value'] + # assert response.test? + # end + def test_well_formed_refund_fails_as_expected purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase @@ -298,7 +326,7 @@ def test_unsupported_test_capture_fails_as_expected auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert capture = @gateway.capture(@amount, auth.authorization) + assert capture = @gateway.capture(@amount, auth.authorization, @options) assert_failure capture assert_equal 'Internal payment provider error. ', capture.message end diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb index 897cf82be56..68e76b9ef2e 100644 --- a/test/unit/gateways/payu_latam_test.rb +++ b/test/unit/gateways/payu_latam_test.rb @@ -207,6 +207,14 @@ def test_successful_capture_with_specified_language end.respond_with(successful_purchase_response) end + def test_successful_partial_capture + stub_comms do + @gateway.capture(@amount - 1, '4000|authorization', @options) + end.check_request do |endpoint, data, headers| + assert_equal '39.99', JSON.parse(data)['transaction']['additionalValues']['TX_VALUE']['value'] + end.respond_with(successful_purchase_response) + end + def test_failed_capture @gateway.expects(:ssl_post).returns(failed_void_response) From bd4c616348e208ad28fa7b0204e2de0136e1ca2a Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 30 Aug 2018 16:38:04 -0400 Subject: [PATCH 522/677] Rubocop: fix Layout/ClosingParenthesisIndentation --- .rubocop_todo.yml | 5 ---- .../billing/gateways/balanced.rb | 12 +++++----- .../billing/gateways/braintree_blue.rb | 6 +++-- .../billing/gateways/card_stream.rb | 15 ++++++------ .../billing/gateways/global_collect.rb | 12 +++++----- .../billing/gateways/modern_payments_cim.rb | 2 +- .../billing/gateways/paystation.rb | 4 ++-- .../billing/gateways/quantum.rb | 8 +++---- lib/active_merchant/billing/gateways/sage.rb | 9 ++++--- .../billing/gateways/trexle.rb | 10 ++++---- .../gateways/remote_authorize_net_cim_test.rb | 14 +++++------ .../remote_barclaycard_smartpay_test.rb | 6 ++--- .../gateways/remote_braintree_blue_test.rb | 2 +- test/remote/gateways/remote_card_save_test.rb | 4 ++-- test/remote/gateways/remote_jetpay_v2_test.rb | 2 +- test/remote/gateways/remote_litle_test.rb | 21 ++++++++-------- .../remote/gateways/remote_payflow_uk_test.rb | 16 ++++++------- test/remote/gateways/remote_quickpay_test.rb | 4 ++-- .../gateways/remote_quickpay_v4_test.rb | 4 ++-- .../gateways/remote_quickpay_v5_test.rb | 4 ++-- .../gateways/remote_quickpay_v6_test.rb | 4 ++-- .../gateways/remote_quickpay_v7_test.rb | 4 ++-- test/remote/gateways/remote_sage_pay_test.rb | 2 +- test/unit/gateways/authorize_net_arb_test.rb | 2 +- test/unit/gateways/blue_pay_test.rb | 2 +- test/unit/gateways/kushki_test.rb | 24 +++++++++---------- test/unit/gateways/linkpoint_test.rb | 9 ++++--- test/unit/gateways/opp_test.rb | 8 +++---- test/unit/gateways/optimal_payment_test.rb | 10 ++++---- test/unit/gateways/paybox_direct_test.rb | 2 +- test/unit/gateways/payflow_test.rb | 7 +++--- test/unit/gateways/sage_pay_test.rb | 2 +- 32 files changed, 120 insertions(+), 116 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b5e9ff77717..8713b83ec64 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -42,11 +42,6 @@ Layout/CaseIndentation: Layout/ClosingHeredocIndentation: Enabled: false -# Offense count: 35 -# Cop supports --auto-correct. -Layout/ClosingParenthesisIndentation: - Enabled: false - # Offense count: 20 # Cop supports --auto-correct. Layout/CommentIndentation: diff --git a/lib/active_merchant/billing/gateways/balanced.rb b/lib/active_merchant/billing/gateways/balanced.rb index 50a3dfcd2c0..c755bedf209 100644 --- a/lib/active_merchant/billing/gateways/balanced.rb +++ b/lib/active_merchant/billing/gateways/balanced.rb @@ -236,12 +236,12 @@ def post_data(params) def headers @@ua ||= JSON.dump( - bindings_version: ActiveMerchant::VERSION, - lang: 'ruby', - lang_version: "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})", - lib_version: BalancedGateway::VERSION, - platform: RUBY_PLATFORM, - publisher: 'active_merchant' + bindings_version: ActiveMerchant::VERSION, + lang: 'ruby', + lang_version: "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})", + lib_version: BalancedGateway::VERSION, + platform: RUBY_PLATFORM, + publisher: 'active_merchant' ) { diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 7f0dbcaacbf..25043306b51 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -347,10 +347,12 @@ def message_from_result(result) end def response_from_result(result) - Response.new(result.success?, message_from_result(result), + Response.new( + result.success?, + message_from_result(result), { braintree_transaction: transaction_hash(result) }, { authorization: (result.transaction.id if result.transaction) } - ) + ) end def response_params(result) diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb index dd929a56d2e..3659ef360a9 100644 --- a/lib/active_merchant/billing/gateways/card_stream.rb +++ b/lib/active_merchant/billing/gateways/card_stream.rb @@ -327,13 +327,14 @@ def commit(action, parameters) response = parse(ssl_post(self.live_url, post_data(action, parameters))) - Response.new(response[:responseCode] == '0', - response[:responseCode] == '0' ? 'APPROVED' : response[:responseMessage], - response, - :test => test?, - :authorization => response[:xref], - :cvv_result => CVV_CODE[response[:avscv2ResponseCode].to_s[0, 1]], - :avs_result => avs_from(response) + Response.new( + response[:responseCode] == '0', + response[:responseCode] == '0' ? 'APPROVED' : response[:responseMessage], + response, + :test => test?, + :authorization => response[:xref], + :cvv_result => CVV_CODE[response[:avscv2ResponseCode].to_s[0, 1]], + :avs_result => avs_from(response) ) end diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 7942dbcec76..66f4634841d 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -239,12 +239,12 @@ def commit(action, post, authorization = nil) succeeded = success_from(response) Response.new( - succeeded, - message_from(succeeded, response), - response, - authorization: authorization_from(succeeded, response), - error_code: error_code_from(succeeded, response), - test: test? + succeeded, + message_from(succeeded, response), + response, + authorization: authorization_from(succeeded, response), + error_code: error_code_from(succeeded, response), + test: test? ) end diff --git a/lib/active_merchant/billing/gateways/modern_payments_cim.rb b/lib/active_merchant/billing/gateways/modern_payments_cim.rb index 688598fd8d9..7939387dd00 100644 --- a/lib/active_merchant/billing/gateways/modern_payments_cim.rb +++ b/lib/active_merchant/billing/gateways/modern_payments_cim.rb @@ -148,7 +148,7 @@ def commit(action, params) data = ssl_post(url(action), build_request(action, params), { 'Content-Type' =>'text/xml; charset=utf-8', 'SOAPAction' => "#{xmlns(action)}#{action}" } - ) + ) response = parse(action, data) Response.new(successful?(action, response), message_from(action, response), response, diff --git a/lib/active_merchant/billing/gateways/paystation.rb b/lib/active_merchant/billing/gateways/paystation.rb index da9ff63c15d..44d64dce8ae 100644 --- a/lib/active_merchant/billing/gateways/paystation.rb +++ b/lib/active_merchant/billing/gateways/paystation.rb @@ -179,8 +179,8 @@ def commit(post) message = message_from(response) PaystationResponse.new(success?(response), message, response, - :test => (response[:tm] && response[:tm].downcase == 't'), - :authorization => response[:paystation_transaction_id] + :test => (response[:tm] && response[:tm].downcase == 't'), + :authorization => response[:paystation_transaction_id] ) end diff --git a/lib/active_merchant/billing/gateways/quantum.rb b/lib/active_merchant/billing/gateways/quantum.rb index 65e7b9e6dcb..280bdcd87c8 100644 --- a/lib/active_merchant/billing/gateways/quantum.rb +++ b/lib/active_merchant/billing/gateways/quantum.rb @@ -216,10 +216,10 @@ def commit(request, options) end Response.new(success, message, response, - :test => test?, - :authorization => authorization, - :avs_result => { :code => response[:AVSResponseCode] }, - :cvv_result => response[:CVV2ResponseCode] + :test => test?, + :authorization => authorization, + :avs_result => { :code => response[:AVSResponseCode] }, + :cvv_result => response[:CVV2ResponseCode] ) end diff --git a/lib/active_merchant/billing/gateways/sage.rb b/lib/active_merchant/billing/gateways/sage.rb index f4a029284dc..7a83ede6731 100644 --- a/lib/active_merchant/billing/gateways/sage.rb +++ b/lib/active_merchant/billing/gateways/sage.rb @@ -364,9 +364,12 @@ def exp_date(credit_card) end def commit(action, request) - response = parse(@gateway.ssl_post(@live_url, - build_soap_request(action, request), - build_headers(action)) + response = parse( + @gateway.ssl_post( + @live_url, + build_soap_request(action, request), + build_headers(action) + ) ) case action diff --git a/lib/active_merchant/billing/gateways/trexle.rb b/lib/active_merchant/billing/gateways/trexle.rb index b4601860b27..2be948b4940 100644 --- a/lib/active_merchant/billing/gateways/trexle.rb +++ b/lib/active_merchant/billing/gateways/trexle.rb @@ -170,11 +170,11 @@ def success_response(body) response = body['response'] Response.new( - true, - response['status_message'], - body, - authorization: token(response), - test: test? + true, + response['status_message'], + body, + authorization: token(response), + test: test? ) end diff --git a/test/remote/gateways/remote_authorize_net_cim_test.rb b/test/remote/gateways/remote_authorize_net_cim_test.rb index 8f7f000b54a..545a9f96942 100644 --- a/test/remote/gateways/remote_authorize_net_cim_test.rb +++ b/test/remote/gateways/remote_authorize_net_cim_test.rb @@ -850,17 +850,17 @@ def get_and_validate_auth_only_response assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id) @customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id'] assert response = @gateway.create_customer_profile_transaction( - :transaction => { - :customer_profile_id => @customer_profile_id, - :customer_payment_profile_id => @customer_payment_profile_id, - :type => :auth_only, - :order => { + :transaction => { + :customer_profile_id => @customer_profile_id, + :customer_payment_profile_id => @customer_payment_profile_id, + :type => :auth_only, + :order => { :invoice_number => key.to_s, :description => "Test Order Description #{key.to_s}", :purchase_order_number => key.to_s }, - :amount => @amount - } + :amount => @amount + } ) assert response.test? diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index 104808183d1..01dc18c8609 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -261,9 +261,9 @@ def test_unsuccessful_verify def test_invalid_login gateway = BarclaycardSmartpayGateway.new( - company: '', - merchant: '', - password: '' + company: '', + merchant: '', + password: '' ) response = gateway.purchase(@amount, @credit_card, @options) assert_failure response diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index 5f48f9ee313..16ef4891a3d 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -371,7 +371,7 @@ def test_successful_purchase_with_addresses def test_successful_purchase_with_three_d_secure_pass_thru three_d_secure_params = { eci: '05', cavv: 'cavv', xid: 'xid' } assert response = @gateway.purchase(@amount, @credit_card, - three_d_secure: three_d_secure_params + three_d_secure: three_d_secure_params ) assert_success response end diff --git a/test/remote/gateways/remote_card_save_test.rb b/test/remote/gateways/remote_card_save_test.rb index 5774414fc17..23af62ab582 100644 --- a/test/remote/gateways/remote_card_save_test.rb +++ b/test/remote/gateways/remote_card_save_test.rb @@ -49,8 +49,8 @@ def test_failed_capture def test_invalid_login gateway = CardSaveGateway.new( - :login => '', - :password => '' + :login => '', + :password => '' ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response diff --git a/test/remote/gateways/remote_jetpay_v2_test.rb b/test/remote/gateways/remote_jetpay_v2_test.rb index aa01fb19c6b..cffb44cafe6 100644 --- a/test/remote/gateways/remote_jetpay_v2_test.rb +++ b/test/remote/gateways/remote_jetpay_v2_test.rb @@ -49,7 +49,7 @@ def test_successful_purchase_with_additional_options ud_field_1: 'Value1', ud_field_2: 'Value2', ud_field_3: 'Value3' - ) + ) assert response = @gateway.purchase(@amount_approved, @credit_card, options) assert_success response end diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb index 966acfc125e..b4b2e1dccb2 100644 --- a/test/remote/gateways/remote_litle_test.rb +++ b/test/remote/gateways/remote_litle_test.rb @@ -199,17 +199,16 @@ def test_successful_purchase_with_echeck def test_unsuccessful_purchase assert response = @gateway.purchase(60060, @credit_card2, { - :order_id=>'6', - :billing_address=>{ - :name => 'Joe Green', - :address1 => '6 Main St.', - :city => 'Derry', - :state => 'NH', - :zip => '03038', - :country => 'US' - }, - } - ) + :order_id=>'6', + :billing_address=>{ + :name => 'Joe Green', + :address1 => '6 Main St.', + :city => 'Derry', + :state => 'NH', + :zip => '03038', + :country => 'US' + }, + }) assert_failure response assert_equal 'Insufficient Funds', response.message end diff --git a/test/remote/gateways/remote_payflow_uk_test.rb b/test/remote/gateways/remote_payflow_uk_test.rb index ae2eafd0caa..3cf7d5ede1d 100644 --- a/test/remote/gateways/remote_payflow_uk_test.rb +++ b/test/remote/gateways/remote_payflow_uk_test.rb @@ -28,14 +28,14 @@ def setup ) @switch = CreditCard.new( - :brand => 'switch', - :number => '5641820000000005', - :verification_value => '000', - :month => 1, - :year => 2008, - :first_name => 'Fred', - :last_name => 'Brooks' - ) + :brand => 'switch', + :number => '5641820000000005', + :verification_value => '000', + :month => 1, + :year => 2008, + :first_name => 'Fred', + :last_name => 'Brooks' + ) @options = { :billing_address => { diff --git a/test/remote/gateways/remote_quickpay_test.rb b/test/remote/gateways/remote_quickpay_test.rb index c7c9c22cc1f..760c71f096e 100644 --- a/test/remote/gateways/remote_quickpay_test.rb +++ b/test/remote/gateways/remote_quickpay_test.rb @@ -188,8 +188,8 @@ def test_failed_store def test_invalid_login gateway = QuickpayGateway.new( - :login => '', - :password => '' + :login => '', + :password => '' ) assert response = gateway.purchase(@amount, @visa, @options) assert_equal 'Invalid merchant id', response.message diff --git a/test/remote/gateways/remote_quickpay_v4_test.rb b/test/remote/gateways/remote_quickpay_v4_test.rb index 06fab13d6e8..8e1035c8c61 100644 --- a/test/remote/gateways/remote_quickpay_v4_test.rb +++ b/test/remote/gateways/remote_quickpay_v4_test.rb @@ -199,8 +199,8 @@ def test_successful_store_and_reference_purchase def test_invalid_login gateway = QuickpayGateway.new( - :login => '999999999', - :password => '' + :login => '999999999', + :password => '' ) assert response = gateway.purchase(@amount, @visa, @options) assert_equal 'Invalid merchant id', response.message diff --git a/test/remote/gateways/remote_quickpay_v5_test.rb b/test/remote/gateways/remote_quickpay_v5_test.rb index 4d458e47a66..83ea83bb645 100644 --- a/test/remote/gateways/remote_quickpay_v5_test.rb +++ b/test/remote/gateways/remote_quickpay_v5_test.rb @@ -199,8 +199,8 @@ def test_successful_store_and_reference_purchase def test_invalid_login gateway = QuickpayGateway.new( - :login => '999999999', - :password => '' + :login => '999999999', + :password => '' ) assert response = gateway.purchase(@amount, @visa, @options) assert_equal 'Invalid merchant id', response.message diff --git a/test/remote/gateways/remote_quickpay_v6_test.rb b/test/remote/gateways/remote_quickpay_v6_test.rb index 7e4d31cde22..6566f5a0900 100644 --- a/test/remote/gateways/remote_quickpay_v6_test.rb +++ b/test/remote/gateways/remote_quickpay_v6_test.rb @@ -199,8 +199,8 @@ def test_successful_store_and_reference_purchase def test_invalid_login gateway = QuickpayGateway.new( - :login => '999999999', - :password => '' + :login => '999999999', + :password => '' ) assert response = gateway.purchase(@amount, @visa, @options) assert_equal 'Invalid merchant id', response.message diff --git a/test/remote/gateways/remote_quickpay_v7_test.rb b/test/remote/gateways/remote_quickpay_v7_test.rb index 9edfc2189b2..8b8def4f168 100644 --- a/test/remote/gateways/remote_quickpay_v7_test.rb +++ b/test/remote/gateways/remote_quickpay_v7_test.rb @@ -219,8 +219,8 @@ def test_successful_store_sans_description def test_invalid_login gateway = QuickpayGateway.new( - :login => '999999999', - :password => '' + :login => '999999999', + :password => '' ) assert response = gateway.purchase(@amount, @visa, @options) assert_equal 'Invalid merchant id', response.message diff --git a/test/remote/gateways/remote_sage_pay_test.rb b/test/remote/gateways/remote_sage_pay_test.rb index d4450ecda49..3abd17c88d5 100644 --- a/test/remote/gateways/remote_sage_pay_test.rb +++ b/test/remote/gateways/remote_sage_pay_test.rb @@ -331,7 +331,7 @@ def test_invalid_login message = SagePayGateway.simulate ? 'VSP Simulator cannot find your vendor name. Ensure you have have supplied a Vendor field with your VSP Vendor name assigned to it.' : '3034 : The Vendor or VendorName value is required.' gateway = SagePayGateway.new( - :login => '' + :login => '' ) assert response = gateway.purchase(@amount, @mastercard, @options) assert_equal message, response.message diff --git a/test/unit/gateways/authorize_net_arb_test.rb b/test/unit/gateways/authorize_net_arb_test.rb index 1757c7c74b6..5c18ff468ff 100644 --- a/test/unit/gateways/authorize_net_arb_test.rb +++ b/test/unit/gateways/authorize_net_arb_test.rb @@ -28,7 +28,7 @@ def test_successful_recurring :start_date => Time.now.strftime('%Y-%m-%d'), :occurrences => 30 } - ) + ) assert_instance_of Response, response assert response.success? diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb index ce498445007..811b121450e 100644 --- a/test/unit/gateways/blue_pay_test.rb +++ b/test/unit/gateways/blue_pay_test.rb @@ -197,7 +197,7 @@ def test_successful_recurring :rebill_expression => '14 DAYS', :rebill_cycles => '24', :rebill_amount => @amount * 4 - ) + ) end assert_instance_of Response, response diff --git a/test/unit/gateways/kushki_test.rb b/test/unit/gateways/kushki_test.rb index 4020f3cbf6f..861d82f8354 100644 --- a/test/unit/gateways/kushki_test.rb +++ b/test/unit/gateways/kushki_test.rb @@ -60,10 +60,10 @@ def test_taxes_are_excluded_when_not_provided } amount = 100 * ( - options[:amount][:subtotal_iva_0].to_f + - options[:amount][:subtotal_iva].to_f + - options[:amount][:iva].to_f + - options[:amount][:ice].to_f + options[:amount][:subtotal_iva_0].to_f + + options[:amount][:subtotal_iva].to_f + + options[:amount][:iva].to_f + + options[:amount][:ice].to_f ) response = stub_comms do @@ -93,10 +93,10 @@ def test_partial_taxes_do_not_error } amount = 100 * ( - options[:amount][:subtotal_iva_0].to_f + - options[:amount][:subtotal_iva].to_f + - options[:amount][:iva].to_f + - options[:amount][:ice].to_f + options[:amount][:subtotal_iva_0].to_f + + options[:amount][:subtotal_iva].to_f + + options[:amount][:iva].to_f + + options[:amount][:ice].to_f ) response = stub_comms do @@ -130,10 +130,10 @@ def test_taxes_are_included_when_provided } amount = 100 * ( - options[:amount][:subtotal_iva_0].to_f + - options[:amount][:subtotal_iva].to_f + - options[:amount][:iva].to_f + - options[:amount][:ice].to_f + options[:amount][:subtotal_iva_0].to_f + + options[:amount][:subtotal_iva].to_f + + options[:amount][:iva].to_f + + options[:amount][:ice].to_f ) response = stub_comms do diff --git a/test/unit/gateways/linkpoint_test.rb b/test/unit/gateways/linkpoint_test.rb index 71d5e683317..8de27a522f8 100644 --- a/test/unit/gateways/linkpoint_test.rb +++ b/test/unit/gateways/linkpoint_test.rb @@ -79,7 +79,8 @@ def test_amount_style end def test_purchase_is_valid_xml - @gateway.send(:parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1004, + @gateway.send( + :parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1004, :billing_address => { :address1 => '1313 lucky lane', :city => 'Lost Angeles', @@ -93,7 +94,8 @@ def test_purchase_is_valid_xml end def test_recurring_is_valid_xml - @gateway.send(:parameters, 1000, @credit_card, :ordertype => 'SALE', :action => 'SUBMIT', :installments => 12, :startdate => 'immediate', :periodicity => 'monthly', :order_id => 1006, + @gateway.send( + :parameters, 1000, @credit_card, :ordertype => 'SALE', :action => 'SUBMIT', :installments => 12, :startdate => 'immediate', :periodicity => 'monthly', :order_id => 1006, :billing_address => { :address1 => '1313 lucky lane', :city => 'Lost Angeles', @@ -125,7 +127,8 @@ def test_line_items_are_valid_xml def test_declined_purchase_is_valid_xml @gateway = LinkpointGateway.new(:login => 123123, :pem => 'PEM') - @gateway.send(:parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1005, + @gateway.send( + :parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1005, :billing_address => { :address1 => '1313 lucky lane', :city => 'Lost Angeles', diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb index c955eb75d1e..e74552d7ade 100644 --- a/test/unit/gateways/opp_test.rb +++ b/test/unit/gateways/opp_test.rb @@ -188,10 +188,10 @@ def post_scrubbed def successful_response(type, id) OppMockResponse.new(200, - JSON.generate({'id' => id,'paymentType' => type,'paymentBrand' => 'VISA','amount' => '1.00','currency' => 'EUR',"des - criptor" => '5410.9959.0306 OPP_Channel ','result' => {'code' => '000.100.110','description' => "Request successfully processed in 'Merchant in Integrator Test Mode'"},'card' => {"bin - " => '420000','last4Digits' => '0000','holder' => 'Longbob Longsen','expiryMonth' => '05','expiryYear' => '2018'},'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage',"time - stamp" => '2015-06-20 19:31:01+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_4453edbc001f405da557c05cb3c3add9'}) + JSON.generate({'id' => id,'paymentType' => type,'paymentBrand' => 'VISA','amount' => '1.00','currency' => 'EUR',"des + criptor" => '5410.9959.0306 OPP_Channel ','result' => {'code' => '000.100.110','description' => "Request successfully processed in 'Merchant in Integrator Test Mode'"},'card' => {"bin + " => '420000','last4Digits' => '0000','holder' => 'Longbob Longsen','expiryMonth' => '05','expiryYear' => '2018'},'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage',"time + stamp" => '2015-06-20 19:31:01+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_4453edbc001f405da557c05cb3c3add9'}) ) end diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb index d2c255dfe61..f2c10a753a3 100644 --- a/test/unit/gateways/optimal_payment_test.rb +++ b/test/unit/gateways/optimal_payment_test.rb @@ -175,11 +175,11 @@ def test_in_production_with_test_param_sends_request_to_test_server begin ActiveMerchant::Billing::Base.mode = :production @gateway = OptimalPaymentGateway.new( - :account_number => '12345678', - :store_id => 'login', - :password => 'password', - :test => true - ) + :account_number => '12345678', + :store_id => 'login', + :password => 'password', + :test => true + ) @gateway.expects(:ssl_post).with('https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1', anything).returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) diff --git a/test/unit/gateways/paybox_direct_test.rb b/test/unit/gateways/paybox_direct_test.rb index 23ec8124b59..89f5f7d435b 100644 --- a/test/unit/gateways/paybox_direct_test.rb +++ b/test/unit/gateways/paybox_direct_test.rb @@ -10,7 +10,7 @@ def setup ) @credit_card = credit_card('1111222233334444', - :brand => 'visa' + :brand => 'visa' ) @amount = 100 diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb index b85956a69b5..2c7c86c9095 100644 --- a/test/unit/gateways/payflow_test.rb +++ b/test/unit/gateways/payflow_test.rb @@ -379,9 +379,10 @@ def test_format_issue_number def test_add_credit_card_with_three_d_secure xml = Builder::XmlMarkup.new - credit_card = credit_card('5641820000000005', - :brand => 'switch', - :issue_number => 1 + credit_card = credit_card( + '5641820000000005', + :brand => 'switch', + :issue_number => 1 ) @gateway.send(:add_credit_card, xml, credit_card, @options.merge(three_d_secure_option)) diff --git a/test/unit/gateways/sage_pay_test.rb b/test/unit/gateways/sage_pay_test.rb index 256af606eff..aae37768a48 100644 --- a/test/unit/gateways/sage_pay_test.rb +++ b/test/unit/gateways/sage_pay_test.rb @@ -319,7 +319,7 @@ def test_successful_authorization_and_capture_and_refund @gateway.refund(@amount, capture.authorization, order_id: generate_unique_id, description: 'Refund txn' - ) + ) end.respond_with(successful_refund_response) assert_success refund end From e46fbafbce4eb1e26faee2457d8ae4c095bf700a Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 30 Aug 2018 16:40:56 -0400 Subject: [PATCH 523/677] Rubocop: fix Layout/DefEndAlignment --- .rubocop_todo.yml | 11 ----------- test/remote/gateways/remote_moneris_test.rb | 2 +- test/remote/gateways/remote_pay_conex_test.rb | 2 +- test/remote/gateways/remote_payflow_uk_test.rb | 2 +- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8713b83ec64..12207a15850 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -57,17 +57,6 @@ Layout/CommentIndentation: - 'test/unit/gateways/eway_managed_test.rb' - 'test/unit/gateways/opp_test.rb' -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. -# SupportedStylesAlignWith: start_of_line, def -Layout/DefEndAlignment: - Exclude: - - 'test/remote/gateways/remote_moneris_test.rb' - - 'test/remote/gateways/remote_pay_conex_test.rb' - - 'test/remote/gateways/remote_payflow_uk_test.rb' - - 'test/unit/gateways/optimal_payment_test.rb' - # Offense count: 513 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/test/remote/gateways/remote_moneris_test.rb b/test/remote/gateways/remote_moneris_test.rb index 6cd0cd8e993..060ad177255 100644 --- a/test/remote/gateways/remote_moneris_test.rb +++ b/test/remote/gateways/remote_moneris_test.rb @@ -233,7 +233,7 @@ def test_avs_result_nil_when_efraud_disabled }) end - def test_purchase_scrubbing + def test_purchase_scrubbing transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) end diff --git a/test/remote/gateways/remote_pay_conex_test.rb b/test/remote/gateways/remote_pay_conex_test.rb index 0299a43c0f0..22ed010bcbd 100644 --- a/test/remote/gateways/remote_pay_conex_test.rb +++ b/test/remote/gateways/remote_pay_conex_test.rb @@ -27,7 +27,7 @@ def test_transcript_scrubbing assert_scrubbed(@credit_card.number, transcript) assert_scrubbed(@credit_card.verification_value, transcript) assert_scrubbed(@gateway.options[:api_accesskey], transcript) - end + end def test_successful_purchase response = @gateway.purchase(@amount, @credit_card, @options) diff --git a/test/remote/gateways/remote_payflow_uk_test.rb b/test/remote/gateways/remote_payflow_uk_test.rb index 3cf7d5ede1d..5db52700d1b 100644 --- a/test/remote/gateways/remote_payflow_uk_test.rb +++ b/test/remote/gateways/remote_payflow_uk_test.rb @@ -72,7 +72,7 @@ def test_successful_purchase_solo assert_success response assert response.test? assert_not_nil response.authorization - end + end def test_no_card_issue_or_card_start_with_switch assert response = @gateway.purchase(100000, @switch, @options) From af23389934f424f8404ede0781301c75a38175d5 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 30 Aug 2018 16:49:47 -0400 Subject: [PATCH 524/677] Rubocop: fix several empty line issues In particular, this fixes: Layout/EmptyLineAfterMagicComment Layout/EmptyLinesAroundArguments Layout/EmptyLinesAroundBlockBody Layout/EmptyLinesAroundExceptionHandlingKeywords Layout/EmptyLinesAroundModuleBody --- .rubocop_todo.yml | 76 ------------------- .../billing/credit_card_formatting.rb | 1 - .../billing/gateways/barclaycard_smartpay.rb | 1 - .../gateways/beanstream/beanstream_core.rb | 1 - lib/active_merchant/billing/gateways/cc5.rb | 1 - .../billing/gateways/cecabank.rb | 1 - .../billing/gateways/data_cash.rb | 1 - .../billing/gateways/efsnet.rb | 3 - lib/active_merchant/billing/gateways/exact.rb | 1 - lib/active_merchant/billing/gateways/ezic.rb | 1 - .../billing/gateways/linkpoint.rb | 1 - .../billing/gateways/mastercard.rb | 2 - .../billing/gateways/moneris.rb | 1 - .../billing/gateways/moneris_us.rb | 1 - lib/active_merchant/billing/gateways/ogone.rb | 1 + .../billing/gateways/pay_conex.rb | 1 - .../billing/gateways/payflow_express.rb | 1 - .../billing/gateways/payment_express.rb | 1 - lib/active_merchant/billing/gateways/pin.rb | 1 - .../gateways/quickpay/quickpay_common.rb | 2 - .../billing/gateways/quickpay/quickpay_v10.rb | 2 - .../billing/gateways/redsys.rb | 1 + .../billing/gateways/sage_pay.rb | 1 - lib/active_merchant/billing/gateways/telr.rb | 1 - .../billing/gateways/trans_first.rb | 1 - .../billing/gateways/usa_epay_transaction.rb | 1 - lib/active_merchant/billing/gateways/wepay.rb | 1 - .../billing/gateways/worldpay.rb | 1 - .../gateways/worldpay_online_payments.rb | 1 - lib/active_merchant/connection.rb | 1 - lib/active_merchant/posts_data.rb | 2 - test/remote/gateways/remote_banwire_test.rb | 1 + .../remote_barclays_epdq_extra_plus_test.rb | 1 + .../remote/gateways/remote_finansbank_test.rb | 1 + test/remote/gateways/remote_ogone_test.rb | 1 + .../remote/gateways/remote_paystation_test.rb | 8 +- test/remote/gateways/remote_realex_test.rb | 6 -- test/remote/gateways/remote_webpay_test.rb | 1 + test/remote/gateways/remote_wirecard_test.rb | 1 + test/unit/gateways/cardknox_test.rb | 2 - test/unit/gateways/finansbank_test.rb | 1 + test/unit/gateways/usa_epay_advanced_test.rb | 1 + .../gateways/usa_epay_transaction_test.rb | 2 - test/unit/gateways/wirecard_test.rb | 1 + test/unit/gateways/worldpay_test.rb | 1 - 45 files changed, 14 insertions(+), 126 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 12207a15850..5ddf8499436 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -82,22 +82,6 @@ Layout/ElseAlignment: - 'lib/active_merchant/billing/gateways/trust_commerce.rb' - 'lib/active_merchant/billing/response.rb' -# Offense count: 11 -# Cop supports --auto-correct. -Layout/EmptyLineAfterMagicComment: - Exclude: - - 'lib/active_merchant/billing/gateways/ogone.rb' - - 'lib/active_merchant/billing/gateways/redsys.rb' - - 'test/remote/gateways/remote_banwire_test.rb' - - 'test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb' - - 'test/remote/gateways/remote_finansbank_test.rb' - - 'test/remote/gateways/remote_ogone_test.rb' - - 'test/remote/gateways/remote_webpay_test.rb' - - 'test/remote/gateways/remote_wirecard_test.rb' - - 'test/unit/gateways/finansbank_test.rb' - - 'test/unit/gateways/usa_epay_advanced_test.rb' - - 'test/unit/gateways/wirecard_test.rb' - # Offense count: 66 # Cop supports --auto-correct. # Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. @@ -114,29 +98,6 @@ Layout/EmptyLines: Layout/EmptyLinesAroundAccessModifier: Enabled: false -# Offense count: 2 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundArguments: - Exclude: - - 'test/unit/gateways/cardknox_test.rb' - - 'test/unit/gateways/usa_epay_transaction_test.rb' - -# Offense count: 15 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Exclude: - - 'lib/active_merchant/billing/gateways/cc5.rb' - - 'lib/active_merchant/billing/gateways/data_cash.rb' - - 'lib/active_merchant/billing/gateways/efsnet.rb' - - 'lib/active_merchant/billing/gateways/payflow_express.rb' - - 'lib/active_merchant/billing/gateways/telr.rb' - - 'test/remote/gateways/remote_paystation_test.rb' - - 'test/remote/gateways/remote_realex_test.rb' - - 'test/unit/gateways/cardknox_test.rb' - - 'test/unit/gateways/usa_epay_transaction_test.rb' - # Offense count: 165 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. @@ -144,48 +105,11 @@ Layout/EmptyLinesAroundBlockBody: Layout/EmptyLinesAroundClassBody: Enabled: false -# Offense count: 10 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundExceptionHandlingKeywords: - Exclude: - - 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb' - - 'lib/active_merchant/billing/gateways/cecabank.rb' - - 'lib/active_merchant/billing/gateways/exact.rb' - - 'lib/active_merchant/billing/gateways/pay_conex.rb' - - 'lib/active_merchant/billing/gateways/pin.rb' - - 'lib/active_merchant/billing/gateways/wepay.rb' - - 'lib/active_merchant/billing/gateways/worldpay.rb' - - 'lib/active_merchant/billing/gateways/worldpay_online_payments.rb' - - 'lib/active_merchant/connection.rb' - - 'test/unit/gateways/worldpay_test.rb' - # Offense count: 64 # Cop supports --auto-correct. Layout/EmptyLinesAroundMethodBody: Enabled: false -# Offense count: 18 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines -Layout/EmptyLinesAroundModuleBody: - Exclude: - - 'lib/active_merchant/billing/credit_card_formatting.rb' - - 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb' - - 'lib/active_merchant/billing/gateways/efsnet.rb' - - 'lib/active_merchant/billing/gateways/ezic.rb' - - 'lib/active_merchant/billing/gateways/linkpoint.rb' - - 'lib/active_merchant/billing/gateways/mastercard.rb' - - 'lib/active_merchant/billing/gateways/moneris.rb' - - 'lib/active_merchant/billing/gateways/moneris_us.rb' - - 'lib/active_merchant/billing/gateways/payment_express.rb' - - 'lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb' - - 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb' - - 'lib/active_merchant/billing/gateways/sage_pay.rb' - - 'lib/active_merchant/billing/gateways/trans_first.rb' - - 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb' - - 'lib/active_merchant/posts_data.rb' - # Offense count: 40 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. diff --git a/lib/active_merchant/billing/credit_card_formatting.rb b/lib/active_merchant/billing/credit_card_formatting.rb index 65078d04e6f..74837bebac0 100644 --- a/lib/active_merchant/billing/credit_card_formatting.rb +++ b/lib/active_merchant/billing/credit_card_formatting.rb @@ -1,7 +1,6 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: module CreditCardFormatting - def expdate(credit_card) "#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}" end diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index 33e4945a434..5a639ecd2b6 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -141,7 +141,6 @@ def commit(action, post) avs_result: AVSResult.new(:code => parse_avs_code(response)), authorization: response['recurringDetailReference'] || authorization_from(post, response) ) - rescue ResponseError => e case e.response.code when '401' diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index 3a8a36fc8de..2800effb333 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -467,7 +467,6 @@ def post_data(params, use_profile_api) params.reject{|k, v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end - end end end diff --git a/lib/active_merchant/billing/gateways/cc5.rb b/lib/active_merchant/billing/gateways/cc5.rb index 869296dcfb9..e9c5dac6e00 100644 --- a/lib/active_merchant/billing/gateways/cc5.rb +++ b/lib/active_merchant/billing/gateways/cc5.rb @@ -70,7 +70,6 @@ def build_sale_request(type, money, creditcard, options = {}) add_address(xml, address) end end - end xml.target! diff --git a/lib/active_merchant/billing/gateways/cecabank.rb b/lib/active_merchant/billing/gateways/cecabank.rb index 8bb644aa847..ea93d83e973 100644 --- a/lib/active_merchant/billing/gateways/cecabank.rb +++ b/lib/active_merchant/billing/gateways/cecabank.rb @@ -152,7 +152,6 @@ def parse(body) end return response - rescue REXML::ParseException => e response[:success] = false response[:message] = 'Unable to parse the response.' diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb index 5c94454e2ad..5c628a1343a 100644 --- a/lib/active_merchant/billing/gateways/data_cash.rb +++ b/lib/active_merchant/billing/gateways/data_cash.rb @@ -216,7 +216,6 @@ def add_authentication(xml) def add_credit_card(xml, credit_card, address) xml.tag! :Card do - # DataCash calls the CC number 'pan' xml.tag! :pan, credit_card.number xml.tag! :expirydate, format_date(credit_card.month, credit_card.year) diff --git a/lib/active_merchant/billing/gateways/efsnet.rb b/lib/active_merchant/billing/gateways/efsnet.rb index da3d95ae0be..e9785556819 100644 --- a/lib/active_merchant/billing/gateways/efsnet.rb +++ b/lib/active_merchant/billing/gateways/efsnet.rb @@ -2,7 +2,6 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: - class EfsnetGateway < Gateway self.supported_countries = ['US'] self.supported_cardtypes = [:visa, :master, :american_express, :discover] @@ -169,9 +168,7 @@ def parse(xml) xml = REXML::Document.new(xml) xml.elements.each('//Reply//TransactionReply/*') do |node| - response[node.name.underscore.to_sym] = normalize(node.text) - end unless xml.root.nil? response diff --git a/lib/active_merchant/billing/gateways/exact.rb b/lib/active_merchant/billing/gateways/exact.rb index f72ba4247af..a5d073a76ab 100644 --- a/lib/active_merchant/billing/gateways/exact.rb +++ b/lib/active_merchant/billing/gateways/exact.rb @@ -169,7 +169,6 @@ def commit(action, request) :avs_result => { :code => response[:avs] }, :cvv_result => response[:cvv2] ) - rescue ResponseError => e case e.response.code when '401' diff --git a/lib/active_merchant/billing/gateways/ezic.rb b/lib/active_merchant/billing/gateways/ezic.rb index 15f81847ef4..3bfe469c857 100644 --- a/lib/active_merchant/billing/gateways/ezic.rb +++ b/lib/active_merchant/billing/gateways/ezic.rb @@ -191,6 +191,5 @@ def headers } end end - end end diff --git a/lib/active_merchant/billing/gateways/linkpoint.rb b/lib/active_merchant/billing/gateways/linkpoint.rb index 9c63d503254..5b0553c3dfd 100644 --- a/lib/active_merchant/billing/gateways/linkpoint.rb +++ b/lib/active_merchant/billing/gateways/linkpoint.rb @@ -2,7 +2,6 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: - # Initialization Options # :login Your store number # :pem The text of your linkpoint PEM file. Note diff --git a/lib/active_merchant/billing/gateways/mastercard.rb b/lib/active_merchant/billing/gateways/mastercard.rb index d15bb6cbfc6..10fb51ba589 100644 --- a/lib/active_merchant/billing/gateways/mastercard.rb +++ b/lib/active_merchant/billing/gateways/mastercard.rb @@ -1,7 +1,6 @@ module ActiveMerchant module Billing module MastercardGateway - def initialize(options={}) requires!(options, :userid, :password) super @@ -262,7 +261,6 @@ def next_authorization(authorization) next_transactionid = SecureRandom.uuid [orderid, next_transactionid, prev_transactionid] end - end end end diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb index 5ce35929532..2a632811ed5 100644 --- a/lib/active_merchant/billing/gateways/moneris.rb +++ b/lib/active_merchant/billing/gateways/moneris.rb @@ -2,7 +2,6 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: - # To learn more about the Moneris gateway, please contact # eselectplus@moneris.com for a copy of their integration guide. For # information on remote testing, please see "Test Environment Penny Value diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb index e9e5ed3d476..35696ea43b5 100644 --- a/lib/active_merchant/billing/gateways/moneris_us.rb +++ b/lib/active_merchant/billing/gateways/moneris_us.rb @@ -2,7 +2,6 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: - # To learn more about the Moneris (US) gateway, please contact # ussales@moneris.com for a copy of their integration guide. For # information on remote testing, please see "Test Environment Penny Value diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb index ef81e22b14e..882dacf5f12 100644 --- a/lib/active_merchant/billing/gateways/ogone.rb +++ b/lib/active_merchant/billing/gateways/ogone.rb @@ -1,4 +1,5 @@ # coding: utf-8 + require 'rexml/document' module ActiveMerchant #:nodoc: diff --git a/lib/active_merchant/billing/gateways/pay_conex.rb b/lib/active_merchant/billing/gateways/pay_conex.rb index bb97a65cde7..0095bcfc29b 100644 --- a/lib/active_merchant/billing/gateways/pay_conex.rb +++ b/lib/active_merchant/billing/gateways/pay_conex.rb @@ -213,7 +213,6 @@ def commit(action, params) :cvv_result => CVVResult.new(response['cvv2_response']), test: test? ) - rescue JSON::ParserError unparsable_response(raw_response) end diff --git a/lib/active_merchant/billing/gateways/payflow_express.rb b/lib/active_merchant/billing/gateways/payflow_express.rb index a8fee1d6476..4a967812181 100644 --- a/lib/active_merchant/billing/gateways/payflow_express.rb +++ b/lib/active_merchant/billing/gateways/payflow_express.rb @@ -180,7 +180,6 @@ def add_pay_data(xml, money, options) end xml.tag! 'DiscountAmt', amount(options[:discount]) if options[:discount] xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money) - end xml.tag! 'Tender' do diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb index 688a49a3001..3495c029fca 100644 --- a/lib/active_merchant/billing/gateways/payment_express.rb +++ b/lib/active_merchant/billing/gateways/payment_express.rb @@ -2,7 +2,6 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: - # In NZ DPS supports ANZ, Westpac, National Bank, ASB and BNZ. # In Australia DPS supports ANZ, NAB, Westpac, CBA, St George and Bank of South Australia. # The Maybank in Malaysia is supported and the Citibank for Singapore. diff --git a/lib/active_merchant/billing/gateways/pin.rb b/lib/active_merchant/billing/gateways/pin.rb index 3d8af8a56b1..a7e11dd16bb 100644 --- a/lib/active_merchant/billing/gateways/pin.rb +++ b/lib/active_merchant/billing/gateways/pin.rb @@ -173,7 +173,6 @@ def commit(method, action, params, options) elsif body['error'] error_response(body) end - rescue JSON::ParserError return unparsable_response(raw_response) end diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb index b1b2c5e0099..50d0fb44932 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb @@ -1,6 +1,5 @@ module QuickpayCommon - MD5_CHECK_FIELDS = { 3 => { :authorize => %w(protocol msgtype merchant ordernumber amount @@ -184,5 +183,4 @@ def expdate(credit_card) "#{year}#{month}" end - end diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb index f321a7c33b8..ce4fec9a480 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb @@ -292,8 +292,6 @@ def json_error(raw_response) def synchronized_path(path) "#{path}?synchronized" end - end - end end diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb index 2fb8ecfcd02..8fbe07af636 100644 --- a/lib/active_merchant/billing/gateways/redsys.rb +++ b/lib/active_merchant/billing/gateways/redsys.rb @@ -1,4 +1,5 @@ # coding: utf-8 + require 'nokogiri' module ActiveMerchant #:nodoc: diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index 97282fc835f..b78c2d6f6b6 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -436,6 +436,5 @@ def past_purchase_reference?(payment_method) payment_method.split(';').last == 'purchase' end end - end end diff --git a/lib/active_merchant/billing/gateways/telr.rb b/lib/active_merchant/billing/gateways/telr.rb index 9d8085fb175..7a31114f364 100644 --- a/lib/active_merchant/billing/gateways/telr.rb +++ b/lib/active_merchant/billing/gateways/telr.rb @@ -190,7 +190,6 @@ def root_attributes def build_xml_request builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml| xml.remote do |doc| - add_authentication(doc) yield(doc) end diff --git a/lib/active_merchant/billing/gateways/trans_first.rb b/lib/active_merchant/billing/gateways/trans_first.rb index 337a4f03d9b..8b2c579683f 100644 --- a/lib/active_merchant/billing/gateways/trans_first.rb +++ b/lib/active_merchant/billing/gateways/trans_first.rb @@ -1,5 +1,4 @@ module ActiveMerchant #:nodoc: - module Billing #:nodoc: class TransFirstGateway < Gateway self.test_url = 'https://ws.cert.transfirst.com' diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb index b2f4a7fb590..83ac01b3cc9 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb @@ -1,6 +1,5 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: - class UsaEpayTransactionGateway < Gateway self.live_url = 'https://www.usaepay.com/gate' self.test_url = 'https://sandbox.usaepay.com/gate' diff --git a/lib/active_merchant/billing/gateways/wepay.rb b/lib/active_merchant/billing/gateways/wepay.rb index 4ae60420421..9ec05da7f7f 100644 --- a/lib/active_merchant/billing/gateways/wepay.rb +++ b/lib/active_merchant/billing/gateways/wepay.rb @@ -190,7 +190,6 @@ def commit(action, params, options={}) authorization: authorization_from(response, params), test: test? ) - rescue JSON::ParserError return unparsable_response(response) end diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index 4ef6f38eb1a..10ea603a8ff 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -362,7 +362,6 @@ def commit(action, request, *success_criteria, options) :authorization => authorization_from(raw), :error_code => error_code_from(success, raw), :test => test?) - rescue ActiveMerchant::ResponseError => e if e.response.code.to_s == '401' return Response.new(false, 'Invalid credentials', {}, :test => test?) diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb index 4d4490efb9e..a4a61f1483b 100644 --- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb @@ -160,7 +160,6 @@ def commit(method, url, parameters=nil, options = {}, type = false) success = true response = {} end - rescue ResponseError => e raw_response = e.response.body response = response_error(raw_response) diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index 5df801ca301..489130ee1b9 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -117,7 +117,6 @@ def request(method, body, headers = {}) result end end - ensure info 'connection_request_total_time=%.4fs' % [Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start], tag http.finish if http.started? diff --git a/lib/active_merchant/posts_data.rb b/lib/active_merchant/posts_data.rb index 9930f2635e4..857efa9b162 100644 --- a/lib/active_merchant/posts_data.rb +++ b/lib/active_merchant/posts_data.rb @@ -1,6 +1,5 @@ module ActiveMerchant #:nodoc: module PostsData #:nodoc: - def self.included(base) base.class_attribute :ssl_strict base.ssl_strict = true @@ -89,6 +88,5 @@ def handle_response(response) raise ResponseError.new(response) end end - end end diff --git a/test/remote/gateways/remote_banwire_test.rb b/test/remote/gateways/remote_banwire_test.rb index 2f908d3ea9f..0bac529ec67 100644 --- a/test/remote/gateways/remote_banwire_test.rb +++ b/test/remote/gateways/remote_banwire_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 + require 'test_helper' class RemoteBanwireTest < Test::Unit::TestCase diff --git a/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb b/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb index 5996436a96a..dd06e16d724 100644 --- a/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb +++ b/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb @@ -1,4 +1,5 @@ # coding: utf-8 + require 'test_helper' class RemoteBarclaysEpdqExtraPlusTest < Test::Unit::TestCase diff --git a/test/remote/gateways/remote_finansbank_test.rb b/test/remote/gateways/remote_finansbank_test.rb index a59bac99a27..753df513fe9 100644 --- a/test/remote/gateways/remote_finansbank_test.rb +++ b/test/remote/gateways/remote_finansbank_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 + require 'test_helper' class RemoteFinansbankTest < Test::Unit::TestCase diff --git a/test/remote/gateways/remote_ogone_test.rb b/test/remote/gateways/remote_ogone_test.rb index 6f62cd8f0ce..3d2b878db33 100644 --- a/test/remote/gateways/remote_ogone_test.rb +++ b/test/remote/gateways/remote_ogone_test.rb @@ -1,4 +1,5 @@ # coding: utf-8 + require 'test_helper' class RemoteOgoneTest < Test::Unit::TestCase diff --git a/test/remote/gateways/remote_paystation_test.rb b/test/remote/gateways/remote_paystation_test.rb index 0225ee25e4c..84285905003 100644 --- a/test/remote/gateways/remote_paystation_test.rb +++ b/test/remote/gateways/remote_paystation_test.rb @@ -40,11 +40,9 @@ def test_failed_purchases ['expired_card', @expired_card_amount, 'Expired Card'], ['bank_error', @bank_error_amount, 'Error Communicating with Bank'] ].each do |name, amount, message| - - assert response = @gateway.purchase(amount, @credit_card, @options) - assert_failure response - assert_equal message, response.message - + assert response = @gateway.purchase(amount, @credit_card, @options) + assert_failure response + assert_equal message, response.message end end diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb index 0e9c466fbc3..5549f5715df 100644 --- a/test/remote/gateways/remote_realex_test.rb +++ b/test/remote/gateways/remote_realex_test.rb @@ -40,7 +40,6 @@ def card_fixtures(name) def test_realex_purchase [ @visa, @mastercard ].each do |card| - response = @gateway.purchase(@amount, card, :order_id => generate_unique_id, :description => 'Test Realex Purchase', @@ -96,7 +95,6 @@ def test_realex_purchase_with_apple_pay def test_realex_purchase_declined [ @visa_declined, @mastercard_declined ].each do |card| - response = @gateway.purchase(@amount, card, :order_id => generate_unique_id, :description => 'Test Realex purchase declined' @@ -120,7 +118,6 @@ def test_realex_purchase_with_apple_pay_declined def test_realex_purchase_referral_b [ @visa_referral_b, @mastercard_referral_b ].each do |card| - response = @gateway.purchase(@amount, card, :order_id => generate_unique_id, :description => 'Test Realex Referral B' @@ -135,7 +132,6 @@ def test_realex_purchase_referral_b def test_realex_purchase_referral_a [ @visa_referral_a, @mastercard_referral_a ].each do |card| - response = @gateway.purchase(@amount, card, :order_id => generate_unique_id, :description => 'Test Realex Rqeferral A' @@ -150,7 +146,6 @@ def test_realex_purchase_referral_a def test_realex_purchase_coms_error [ @visa_coms_error, @mastercard_coms_error ].each do |card| - response = @gateway.purchase(@amount, card, :order_id => generate_unique_id, :description => 'Test Realex coms error' @@ -338,7 +333,6 @@ def test_realex_purchase_then_refund def test_maps_avs_and_cvv_response_codes [ @visa, @mastercard ].each do |card| - response = @gateway.purchase(@amount, card, :order_id => generate_unique_id, :description => 'Test Realex Purchase', diff --git a/test/remote/gateways/remote_webpay_test.rb b/test/remote/gateways/remote_webpay_test.rb index 26e084f49e0..3b0e099ea33 100644 --- a/test/remote/gateways/remote_webpay_test.rb +++ b/test/remote/gateways/remote_webpay_test.rb @@ -1,4 +1,5 @@ # coding: utf-8 + require 'test_helper' class RemoteWebpayTest < Test::Unit::TestCase diff --git a/test/remote/gateways/remote_wirecard_test.rb b/test/remote/gateways/remote_wirecard_test.rb index f47eff22762..15783d552d5 100644 --- a/test/remote/gateways/remote_wirecard_test.rb +++ b/test/remote/gateways/remote_wirecard_test.rb @@ -1,4 +1,5 @@ # encoding: UTF-8 + require 'test_helper' class RemoteWirecardTest < Test::Unit::TestCase diff --git a/test/unit/gateways/cardknox_test.rb b/test/unit/gateways/cardknox_test.rb index e4270ba97b2..cbddf0b4d46 100644 --- a/test/unit/gateways/cardknox_test.rb +++ b/test/unit/gateways/cardknox_test.rb @@ -67,10 +67,8 @@ def test_manual_entry_is_properly_indicated_on_purchase response = stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| - assert_match %r{xCardNum=4242424242424242}, data assert_match %r{xCardPresent=true}, data - end.respond_with(successful_purchase_response) assert_success response diff --git a/test/unit/gateways/finansbank_test.rb b/test/unit/gateways/finansbank_test.rb index 4d4553366fd..9cb280aac30 100644 --- a/test/unit/gateways/finansbank_test.rb +++ b/test/unit/gateways/finansbank_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 + require 'test_helper' class FinansbankTest < Test::Unit::TestCase diff --git a/test/unit/gateways/usa_epay_advanced_test.rb b/test/unit/gateways/usa_epay_advanced_test.rb index ad96353bc4e..24220cf514f 100644 --- a/test/unit/gateways/usa_epay_advanced_test.rb +++ b/test/unit/gateways/usa_epay_advanced_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 + require 'test_helper' require 'logger' diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb index 7138a6e5b52..d8eb617c41b 100644 --- a/test/unit/gateways/usa_epay_transaction_test.rb +++ b/test/unit/gateways/usa_epay_transaction_test.rb @@ -396,10 +396,8 @@ def test_manual_entry_is_properly_indicated_on_purchase response = stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| - assert_match %r{UMcard=4242424242424242}, data assert_match %r{UMcardpresent=true}, data - end.respond_with(successful_purchase_response) assert_success response diff --git a/test/unit/gateways/wirecard_test.rb b/test/unit/gateways/wirecard_test.rb index b5ee72ebbc7..5ae3f487d86 100644 --- a/test/unit/gateways/wirecard_test.rb +++ b/test/unit/gateways/wirecard_test.rb @@ -1,4 +1,5 @@ # encoding: UTF-8 + require 'test_helper' class WirecardTest < Test::Unit::TestCase diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index 02a6eca5834..d73a991418f 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -437,7 +437,6 @@ def test_request_respects_test_mode_on_gateway_instance end.check_request do |endpoint, data, headers| assert_equal WorldpayGateway.test_url, endpoint end.respond_with(successful_authorize_response, successful_capture_response) - ensure ActiveMerchant::Billing::Base.mode = :test end From 8d488568aa5bec467f994d22cf8fa47807242073 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Fri, 31 Aug 2018 15:30:33 -0400 Subject: [PATCH 525/677] FirstPay: Expose error code Closes #2979 Remote: 14 tests, 33 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 13 tests, 122 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/first_pay.rb | 5 ++++ test/remote/gateways/remote_first_pay_test.rb | 1 + test/unit/gateways/first_pay_test.rb | 23 +++++++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 4e989e3cd3c..01cafca1b66 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * PayU Latam: support partial captures [bpollack] #2974 +* FirstPay: Expose error code [curiousepic] #2979 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb index 08b4f417986..9a21f24562d 100644 --- a/lib/active_merchant/billing/gateways/first_pay.rb +++ b/lib/active_merchant/billing/gateways/first_pay.rb @@ -134,6 +134,7 @@ def commit(action, parameters) message_from(response), response, authorization: authorization_from(response), + error_code: error_code_from(response), test: test? ) end @@ -151,6 +152,10 @@ def message_from(response) msg.downcase.capitalize if msg end + def error_code_from(response) + response['error'] + end + def authorization_from(response) response['reference_number'] || response['reference_number1'] end diff --git a/test/remote/gateways/remote_first_pay_test.rb b/test/remote/gateways/remote_first_pay_test.rb index 3edab642a57..f30fc4223b0 100644 --- a/test/remote/gateways/remote_first_pay_test.rb +++ b/test/remote/gateways/remote_first_pay_test.rb @@ -108,6 +108,7 @@ def test_invalid_login ) response = gateway.purchase(@amount, @credit_card, @options) assert_failure response + assert_match /Merchant: 1234 has encountered error #DTO-200-TC./, response.error_code end def test_recurring_payment diff --git a/test/unit/gateways/first_pay_test.rb b/test/unit/gateways/first_pay_test.rb index 1e0bab16e96..b761e884938 100644 --- a/test/unit/gateways/first_pay_test.rb +++ b/test/unit/gateways/first_pay_test.rb @@ -199,6 +199,14 @@ def test_recurring_payments assert_success response end + def test_error_message + @gateway.stubs(:ssl_post).returns(failed_login_response) + response = @gateway.void('1') + + assert_failure response + assert response.error_code.include?('Merchant: 1234 has encountered error #DTO-200-TC.') + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed @@ -370,6 +378,21 @@ def failed_void_response </RESPONSE>) end + def failed_login_response + %(<RESPONSE> + <FIELDS> + <FIELD KEY="status">0</FIELD> + <FIELD KEY="auth_code"></FIELD> + <FIELD KEY="auth_response"></FIELD> + <FIELD KEY="avs_code"></FIELD> + <FIELD KEY="cvv2_code"></FIELD> + <FIELD KEY="reference_number"></FIELD> + <FIELD KEY="order_id">a0d2560dda18631ce325c07dcbda2a9880fd17fb344fd233</FIELD> + <FIELD KEY="error">Merchant: 1234 has encountered error #DTO-200-TC. Please call 888-638-7867 if you feel this is in error.</FIELD> + </FIELDS> +</RESPONSE>) + end + def pre_scrubbed %(<RESPONSE> <FIELDS> From d2c8199ca04279fac928a74af044e013e033b868 Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Wed, 5 Sep 2018 10:58:07 -0400 Subject: [PATCH 526/677] Barclaycard: Pass device_fingerprint when specified Unit: 25 tests, 115 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 30 tests, 63 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/barclaycard_smartpay.rb | 1 + test/remote/gateways/remote_barclaycard_smartpay_test.rb | 6 ++++++ test/unit/gateways/barclaycard_smartpay_test.rb | 3 ++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 01cafca1b66..49dc4840a87 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * PayU Latam: support partial captures [bpollack] #2974 * FirstPay: Expose error code [curiousepic] #2979 +* Barclaycard Smartpay: Pass device_fingerprint when specified [dtykocki] #2981 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index 5a639ecd2b6..6df4b68ecfa 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -307,6 +307,7 @@ def payment_request(money, options) hash[:shopperIP] = options[:ip] if options[:ip] hash[:shopperReference] = options[:customer] if options[:customer] hash[:shopperInteraction] = options[:shopper_interaction] if options[:shopper_interaction] + hash[:deviceFingerprint] = options[:device_fingerprint] if options[:device_fingerprint] hash.keep_if { |_, v| v } end diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index 01dc18c8609..d605c62f4c1 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -159,6 +159,12 @@ def test_successful_purchase_with_shopper_interaction assert_equal '[capture-received]', response.message end + def test_successful_purchase_with_device_fingerprint + response = @gateway.purchase(@amount, @credit_card, @options.merge(device_fingerprint: 'abcde1123')) + assert_success response + assert_equal '[capture-received]', response.message + end + def test_successful_authorize_with_3ds assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @options.merge(execute_threed: true)) assert_equal 'RedirectShopper', response.message diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb index 08d4f38efb0..bac4a277b3e 100644 --- a/test/unit/gateways/barclaycard_smartpay_test.rb +++ b/test/unit/gateways/barclaycard_smartpay_test.rb @@ -159,9 +159,10 @@ def test_successful_authorize_with_shipping_house_number_and_street def test_successful_authorize_with_extra_options response = stub_comms do - @gateway.authorize(@amount, @credit_card, @options.merge(shopper_interaction: 'ContAuth')) + @gateway.authorize(@amount, @credit_card, @options.merge(shopper_interaction: 'ContAuth', device_fingerprint: 'abcde123')) end.check_request do |endpoint, data, headers| assert_match(/shopperInteraction=ContAuth/, data) + assert_match(/deviceFingerprint=abcde123/, data) end.respond_with(successful_authorize_response) assert_success response From 7aa9bda55c6fb874e004c07be60da78e2ec08b0e Mon Sep 17 00:00:00 2001 From: Michael Elfassy <michaelelfassy@gmail.com> Date: Wed, 5 Sep 2018 12:57:50 -0400 Subject: [PATCH 527/677] reflect correct test mode in braintree responses (#2980) --- CHANGELOG | 1 + .../billing/gateways/braintree_blue.rb | 8 +++- test/unit/gateways/braintree_blue_test.rb | 45 ++++++++++++++++++- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 49dc4840a87..9aa0f8d7686 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * PayU Latam: support partial captures [bpollack] #2974 +* Braintree: Reflect correct test mode in Braintree responses [elfassy] [#2980] * FirstPay: Expose error code [curiousepic] #2979 * Barclaycard Smartpay: Pass device_fingerprint when specified [dtykocki] #2981 diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 25043306b51..b6fe5e8e431 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -347,11 +347,14 @@ def message_from_result(result) end def response_from_result(result) + response_hash = { braintree_transaction: transaction_hash(result) } + Response.new( result.success?, message_from_result(result), - { braintree_transaction: transaction_hash(result) }, - { authorization: (result.transaction.id if result.transaction) } + response_hash, + authorization: (result.transaction.id if result.transaction), + test: test? ) end @@ -369,6 +372,7 @@ def response_options(result) options[:avs_result] = { code: avs_code_from(result.transaction) } options[:cvv_result] = result.transaction.cvv_response_code end + options[:test] = test? options end diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index 194c7552176..721ec2f5e9e 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -7,7 +7,8 @@ def setup @gateway = BraintreeBlueGateway.new( :merchant_id => 'test', :public_key => 'test', - :private_key => 'test' + :private_key => 'test', + :test => true ) @internal_gateway = @gateway.instance_variable_get( :@braintree_gateway ) @@ -63,13 +64,53 @@ def test_transaction_uses_payment_method_nonce_when_option assert_success response end + def test_authorize_transaction + Braintree::TransactionGateway.any_instance.expects(:sale). + returns(braintree_result) + + response = @gateway.authorize(100, credit_card('41111111111111111111')) + + assert_equal 'transaction_id', response.authorization + assert_equal true, response.test + end + + def test_purchase_transaction + Braintree::TransactionGateway.any_instance.expects(:sale). + returns(braintree_result) + + response = @gateway.purchase(100, credit_card('41111111111111111111')) + + assert_equal 'transaction_id', response.authorization + assert_equal true, response.test + end + + def test_capture_transaction + Braintree::TransactionGateway.any_instance.expects(:submit_for_settlement). + returns(braintree_result(:id => 'capture_transaction_id')) + + response = @gateway.capture(100, 'transaction_id') + + assert_equal 'capture_transaction_id', response.authorization + assert_equal true, response.test + end + + def test_refund_transaction + Braintree::TransactionGateway.any_instance.expects(:refund). + returns(braintree_result(:id => 'refund_transaction_id')) + + response = @gateway.refund(1000, 'transaction_id') + assert_equal 'refund_transaction_id', response.authorization + assert_equal true, response.test + end + def test_void_transaction Braintree::TransactionGateway.any_instance.expects(:void). with('transaction_id'). returns(braintree_result(:id => 'void_transaction_id')) - response = @gateway.void('transaction_id', :test => true) + response = @gateway.void('transaction_id') assert_equal 'void_transaction_id', response.authorization + assert_equal true, response.test end def test_verify_good_credentials From e93070c32534c7c4aa44419b9081fef9173c0305 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 31 Aug 2018 13:00:08 -0400 Subject: [PATCH 528/677] RuboCop: fix Layout/RescueEnsureAlignment --- .rubocop_todo.yml | 7 ------- .../billing/gateways/checkout_v2.rb | 10 +++++----- .../billing/gateways/mundipagg.rb | 18 +++++++++--------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5ddf8499436..f9b05ac9482 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -241,13 +241,6 @@ Layout/MultilineOperationIndentation: - 'test/unit/gateways/ogone_test.rb' - 'test/unit/gateways/skip_jack_test.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Layout/RescueEnsureAlignment: - Exclude: - - 'lib/active_merchant/billing/gateways/checkout_v2.rb' - - 'lib/active_merchant/billing/gateways/mundipagg.rb' - # Offense count: 2 # Cop supports --auto-correct. Layout/SpaceAfterColon: diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb index 7d1f688f971..93a5c9f69d8 100644 --- a/lib/active_merchant/billing/gateways/checkout_v2.rb +++ b/lib/active_merchant/billing/gateways/checkout_v2.rb @@ -180,11 +180,11 @@ def cvv_result(response) def parse(body) JSON.parse(body) - rescue JSON::ParserError - { - 'message' => 'Invalid JSON response received from CheckoutV2Gateway. Please contact CheckoutV2Gateway if you continue to receive this message.', - 'raw_response' => scrub(body) - } + rescue JSON::ParserError + { + 'message' => 'Invalid JSON response received from CheckoutV2Gateway. Please contact CheckoutV2Gateway if you continue to receive this message.', + 'raw_response' => scrub(body) + } end def success_from(response) diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb index 7aefce004e4..89d895cea7b 100644 --- a/lib/active_merchant/billing/gateways/mundipagg.rb +++ b/lib/active_merchant/billing/gateways/mundipagg.rb @@ -247,15 +247,15 @@ def commit(action, parameters, auth = nil) test: test?, error_code: error_code_from(response) ) - rescue ResponseError => e - message = get_error_message(e) - return Response.new( - false, - "#{STANDARD_ERROR_MESSAGE_MAPPING[e.response.code]} #{message}", - parse(e.response.body), - test: test?, - error_code: STANDARD_ERROR_CODE_MAPPING[e.response.code], - ) + rescue ResponseError => e + message = get_error_message(e) + return Response.new( + false, + "#{STANDARD_ERROR_MESSAGE_MAPPING[e.response.code]} #{message}", + parse(e.response.body), + test: test?, + error_code: STANDARD_ERROR_CODE_MAPPING[e.response.code], + ) end def success_from(response) From 602359fe48314a598717fdabd55f97a973eb1cd2 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 31 Aug 2018 13:20:04 -0400 Subject: [PATCH 529/677] RuboCop: fix Layout/MultilineMethodCallIndentation --- .rubocop_todo.yml | 17 ---------------- .../billing/gateways/balanced.rb | 4 ++-- lib/active_merchant/billing/gateways/ogone.rb | 8 ++++---- .../billing/gateways/realex.rb | 4 ++-- lib/active_merchant/billing/gateways/sage.rb | 20 +++++++++---------- lib/active_merchant/billing/gateways/telr.rb | 6 +++--- test/unit/connection_test.rb | 9 ++++++--- test/unit/gateways/braintree_blue_test.rb | 4 ++-- test/unit/gateways/jetpay_v2_test.rb | 10 +++++----- test/unit/gateways/wirecard_test.rb | 9 +++++---- test/unit/network_connection_retries_test.rb | 9 ++++++--- 11 files changed, 45 insertions(+), 55 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f9b05ac9482..d998631ae7f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -206,23 +206,6 @@ Layout/MultilineHashBraceLayout: Layout/MultilineMethodCallBraceLayout: Enabled: false -# Offense count: 34 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Exclude: - - 'lib/active_merchant/billing/gateways/balanced.rb' - - 'lib/active_merchant/billing/gateways/ogone.rb' - - 'lib/active_merchant/billing/gateways/realex.rb' - - 'lib/active_merchant/billing/gateways/sage.rb' - - 'lib/active_merchant/billing/gateways/telr.rb' - - 'test/unit/connection_test.rb' - - 'test/unit/gateways/braintree_blue_test.rb' - - 'test/unit/gateways/jetpay_v2_test.rb' - - 'test/unit/gateways/wirecard_test.rb' - - 'test/unit/network_connection_retries_test.rb' - # Offense count: 35 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. diff --git a/lib/active_merchant/billing/gateways/balanced.rb b/lib/active_merchant/billing/gateways/balanced.rb index c755bedf209..e5629dd7820 100644 --- a/lib/active_merchant/billing/gateways/balanced.rb +++ b/lib/active_merchant/billing/gateways/balanced.rb @@ -117,8 +117,8 @@ def reference_identifier_from(identifier) case identifier when %r{\|} uri = identifier. - split('|'). - detect{|part| part.size > 0} + split('|'). + detect{|part| part.size > 0} uri.split('/')[2] when %r{\/} identifier.split('/')[5] diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb index 882dacf5f12..d3906c1e1c9 100644 --- a/lib/active_merchant/billing/gateways/ogone.rb +++ b/lib/active_merchant/billing/gateways/ogone.rb @@ -227,10 +227,10 @@ def supports_scrubbing? def scrub(transcript) transcript. - gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). - gsub(%r((&?cardno=)[^&]*)i, '\1[FILTERED]'). - gsub(%r((&?cvc=)[^&]*)i, '\1[FILTERED]'). - gsub(%r((&?pswd=)[^&]*)i, '\1[FILTERED]') + gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). + gsub(%r((&?cardno=)[^&]*)i, '\1[FILTERED]'). + gsub(%r((&?cvc=)[^&]*)i, '\1[FILTERED]'). + gsub(%r((&?pswd=)[^&]*)i, '\1[FILTERED]') end private diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index 08280b4b76b..feec62cb5b1 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -89,8 +89,8 @@ def supports_scrubbing def scrub(transcript) transcript. - gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). - gsub(%r((<number>)\d+(</number>))i, '\1[FILTERED]\2') + gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). + gsub(%r((<number>)\d+(</number>))i, '\1[FILTERED]\2') end private diff --git a/lib/active_merchant/billing/gateways/sage.rb b/lib/active_merchant/billing/gateways/sage.rb index 7a83ede6731..2c44e92eeed 100644 --- a/lib/active_merchant/billing/gateways/sage.rb +++ b/lib/active_merchant/billing/gateways/sage.rb @@ -98,16 +98,16 @@ def supports_scrubbing? def scrub(transcript) force_utf8(transcript). - gsub(%r((M_id=)[^&]*), '\1[FILTERED]'). - gsub(%r((M_key=)[^&]*), '\1[FILTERED]'). - gsub(%r((C_cardnumber=)[^&]*), '\1[FILTERED]'). - gsub(%r((C_cvv=)[^&]*), '\1[FILTERED]'). - gsub(%r((C_rte=)[^&]*), '\1[FILTERED]'). - gsub(%r((C_acct=)[^&]*), '\1[FILTERED]'). - gsub(%r((C_ssn=)[^&]*), '\1[FILTERED]'). - gsub(%r((<ns1:CARDNUMBER>).+(</ns1:CARDNUMBER>)), '\1[FILTERED]\2'). - gsub(%r((<ns1:M_ID>).+(</ns1:M_ID>)), '\1[FILTERED]\2'). - gsub(%r((<ns1:M_KEY>).+(</ns1:M_KEY>)), '\1[FILTERED]\2') + gsub(%r((M_id=)[^&]*), '\1[FILTERED]'). + gsub(%r((M_key=)[^&]*), '\1[FILTERED]'). + gsub(%r((C_cardnumber=)[^&]*), '\1[FILTERED]'). + gsub(%r((C_cvv=)[^&]*), '\1[FILTERED]'). + gsub(%r((C_rte=)[^&]*), '\1[FILTERED]'). + gsub(%r((C_acct=)[^&]*), '\1[FILTERED]'). + gsub(%r((C_ssn=)[^&]*), '\1[FILTERED]'). + gsub(%r((<ns1:CARDNUMBER>).+(</ns1:CARDNUMBER>)), '\1[FILTERED]\2'). + gsub(%r((<ns1:M_ID>).+(</ns1:M_ID>)), '\1[FILTERED]\2'). + gsub(%r((<ns1:M_KEY>).+(</ns1:M_KEY>)), '\1[FILTERED]\2') end private diff --git a/lib/active_merchant/billing/gateways/telr.rb b/lib/active_merchant/billing/gateways/telr.rb index 7a31114f364..f1c34063c9a 100644 --- a/lib/active_merchant/billing/gateways/telr.rb +++ b/lib/active_merchant/billing/gateways/telr.rb @@ -87,9 +87,9 @@ def supports_scrubbing? def scrub(transcript) transcript. - gsub(%r((<Number>)[^<]+(<))i, '\1[FILTERED]\2'). - gsub(%r((<CVV>)[^<]+(<))i, '\1[FILTERED]\2'). - gsub(%r((<Key>)[^<]+(<))i, '\1[FILTERED]\2') + gsub(%r((<Number>)[^<]+(<))i, '\1[FILTERED]\2'). + gsub(%r((<CVV>)[^<]+(<))i, '\1[FILTERED]\2'). + gsub(%r((<Key>)[^<]+(<))i, '\1[FILTERED]\2') end private diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index c33797de2a0..ac8c29a4f1d 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -215,9 +215,12 @@ def test_failure_then_success_with_retry_safe_enabled end def test_mixture_of_failures_with_retry_safe_enabled - Net::HTTP.any_instance.expects(:start).times(3).raises(Errno::ECONNRESET). - raises(Errno::ECONNREFUSED). - raises(EOFError) + Net::HTTP.any_instance. + expects(:start). + times(3). + raises(Errno::ECONNRESET). + raises(Errno::ECONNREFUSED). + raises(EOFError) @connection.retry_safe = true diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index 721ec2f5e9e..e6986cae2c5 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -562,8 +562,8 @@ def test_three_d_secure_pass_thru_handling cavv: 'cavv', eci_flag: 'eci', xid: 'xid', - })). - returns(braintree_result) + })). + returns(braintree_result) @gateway.purchase(100, credit_card('41111111111111111111'), three_d_secure: {cavv: 'cavv', eci: 'eci', xid: 'xid'}) end diff --git a/test/unit/gateways/jetpay_v2_test.rb b/test/unit/gateways/jetpay_v2_test.rb index d135ddc7f0a..8129bf5eb11 100644 --- a/test/unit/gateways/jetpay_v2_test.rb +++ b/test/unit/gateways/jetpay_v2_test.rb @@ -163,11 +163,11 @@ def test_transcript_scrubbing def test_purchase_sends_additional_options @gateway.expects(:ssl_post). - with(anything, regexp_matches(/<TaxAmount ExemptInd=\"false\">777<\/TaxAmount>/)). - with(anything, regexp_matches(/<UDField1>Value1<\/UDField1>/)). - with(anything, regexp_matches(/<UDField2>Value2<\/UDField2>/)). - with(anything, regexp_matches(/<UDField3>Value3<\/UDField3>/)). - returns(successful_purchase_response) + with(anything, regexp_matches(/<TaxAmount ExemptInd=\"false\">777<\/TaxAmount>/)). + with(anything, regexp_matches(/<UDField1>Value1<\/UDField1>/)). + with(anything, regexp_matches(/<UDField2>Value2<\/UDField2>/)). + with(anything, regexp_matches(/<UDField3>Value3<\/UDField3>/)). + returns(successful_purchase_response) @gateway.purchase(@amount, @credit_card, {:tax => '777', :ud_field_1 => 'Value1', :ud_field_2 => 'Value2', :ud_field_3 => 'Value3'}) end diff --git a/test/unit/gateways/wirecard_test.rb b/test/unit/gateways/wirecard_test.rb index 5ae3f487d86..03b82b41b98 100644 --- a/test/unit/gateways/wirecard_test.rb +++ b/test/unit/gateways/wirecard_test.rb @@ -368,10 +368,11 @@ def wrong_creditcard_authorization_response XML result_node = '</FunctionResult>' auth = 'AuthorizationCode' - successful_authorization_response.gsub('ACK', 'NOK') \ - .gsub(result_node, result_node + error) \ - .gsub(/<#{auth}>\w+<\/#{auth}>/, "<#{auth}><\/#{auth}>") \ - .gsub(/<Info>.+<\/Info>/, '') + successful_authorization_response. + gsub('ACK', 'NOK'). + gsub(result_node, result_node + error). + gsub(/<#{auth}>\w+<\/#{auth}>/, "<#{auth}><\/#{auth}>"). + gsub(/<Info>.+<\/Info>/, '') end # Capture success diff --git a/test/unit/network_connection_retries_test.rb b/test/unit/network_connection_retries_test.rb index 84fbfac2c08..b071c4e9ede 100644 --- a/test/unit/network_connection_retries_test.rb +++ b/test/unit/network_connection_retries_test.rb @@ -133,9 +133,12 @@ def test_failure_then_success_logs_success end def test_mixture_of_failures_with_retry_safe_enabled - @requester.expects(:post).times(3).raises(Errno::ECONNRESET). - raises(Errno::ECONNREFUSED). - raises(EOFError) + @requester. + expects(:post). + times(3). + raises(Errno::ECONNRESET). + raises(Errno::ECONNREFUSED). + raises(EOFError) assert_raises(ActiveMerchant::ConnectionError) do retry_exceptions :retry_safe => true do From 8db0ba8ce8e742b28080b0dd64eb17f3bd0284ec Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 31 Aug 2018 14:09:33 -0400 Subject: [PATCH 530/677] RuboCop: fix Layout/SpaceAfterColon --- .rubocop_todo.yml | 7 ------- test/remote/gateways/remote_micropayment_test.rb | 2 +- test/remote/gateways/remote_payu_latam_test.rb | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d998631ae7f..c4387d3f797 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -224,13 +224,6 @@ Layout/MultilineOperationIndentation: - 'test/unit/gateways/ogone_test.rb' - 'test/unit/gateways/skip_jack_test.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Layout/SpaceAfterColon: - Exclude: - - 'test/remote/gateways/remote_micropayment_test.rb' - - 'test/remote/gateways/remote_payu_latam_test.rb' - # Offense count: 315 # Cop supports --auto-correct. Layout/SpaceAfterComma: diff --git a/test/remote/gateways/remote_micropayment_test.rb b/test/remote/gateways/remote_micropayment_test.rb index 29b3a3fdcd1..fb4589e7d71 100644 --- a/test/remote/gateways/remote_micropayment_test.rb +++ b/test/remote/gateways/remote_micropayment_test.rb @@ -16,7 +16,7 @@ def setup end def test_invalid_login - gateway = MicropaymentGateway.new(access_key: 'invalid', api_key:'invalid') + gateway = MicropaymentGateway.new(access_key: 'invalid', api_key: 'invalid') response = gateway.purchase(@amount, @credit_card, @options) assert_failure response assert_equal 'Authorization failed - Reason: api accesskey wrong', response.message diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index 316aaee30a4..b15d9fce5c1 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -118,7 +118,7 @@ def test_successful_purchase_brazil zip: '01019-030', phone: '(11)756312633' ), - buyer:{ + buyer: { cnpj: '32593371000110' } } From aec3b8e4c1f18d5bd6c91f88f8204ce6556b2b2d Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 31 Aug 2018 14:20:30 -0400 Subject: [PATCH 531/677] RuboCop: fix interpolation and quoting These correspond to Style/UnneededInterpolation and Style/UnneededPercentQ. I lumped them together because they are hitting on the same basic issue of not interpolating when we don't need to. Unit: 3922 tests, 68179 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- .rubocop_todo.yml | 33 ------------ lib/active_merchant/billing/base.rb | 2 +- lib/active_merchant/billing/compatibility.rb | 2 +- .../billing/gateways/banwire.rb | 2 +- .../billing/gateways/cardknox.rb | 2 +- .../billing/gateways/conekta.rb | 4 +- .../billing/gateways/digitzs.rb | 2 +- .../billing/gateways/eway_managed.rb | 4 +- .../billing/gateways/first_giving.rb | 4 +- .../billing/gateways/merchant_one.rb | 2 +- .../billing/gateways/openpay.rb | 4 +- .../billing/gateways/pay_junction_v2.rb | 2 +- .../billing/gateways/safe_charge.rb | 2 +- lib/active_merchant/billing/gateways/telr.rb | 2 +- lib/support/gateway_support.rb | 6 +-- .../gateways/remote_cyber_source_test.rb | 6 +-- test/unit/gateways/clearhaus_test.rb | 2 +- test/unit/gateways/forte_test.rb | 48 ++++++++--------- test/unit/gateways/merchant_warrior_test.rb | 4 +- test/unit/gateways/nmi_test.rb | 8 +-- test/unit/gateways/orbital_test.rb | 6 +-- test/unit/gateways/payex_test.rb | 52 +++++++++---------- test/unit/gateways/paymentez_test.rb | 32 ++++++------ test/unit/gateways/world_net_test.rb | 52 +++++++++---------- 24 files changed, 125 insertions(+), 158 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c4387d3f797..a14183adddd 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1533,39 +1533,6 @@ Style/TrailingCommaInHashLiteral: Style/TrailingUnderscoreVariable: Enabled: false -# Offense count: 26 -# Cop supports --auto-correct. -Style/UnneededInterpolation: - Exclude: - - 'lib/active_merchant/billing/base.rb' - - 'lib/active_merchant/billing/compatibility.rb' - - 'lib/active_merchant/billing/gateways/banwire.rb' - - 'lib/active_merchant/billing/gateways/cardknox.rb' - - 'lib/active_merchant/billing/gateways/conekta.rb' - - 'lib/active_merchant/billing/gateways/digitzs.rb' - - 'lib/active_merchant/billing/gateways/eway_managed.rb' - - 'lib/active_merchant/billing/gateways/first_giving.rb' - - 'lib/active_merchant/billing/gateways/merchant_one.rb' - - 'lib/active_merchant/billing/gateways/openpay.rb' - - 'lib/active_merchant/billing/gateways/pay_junction_v2.rb' - - 'lib/active_merchant/billing/gateways/safe_charge.rb' - - 'lib/active_merchant/billing/gateways/telr.rb' - - 'lib/support/gateway_support.rb' - - 'test/remote/gateways/remote_cyber_source_test.rb' - -# Offense count: 54 -# Cop supports --auto-correct. -Style/UnneededPercentQ: - Exclude: - - 'test/unit/gateways/clearhaus_test.rb' - - 'test/unit/gateways/forte_test.rb' - - 'test/unit/gateways/merchant_warrior_test.rb' - - 'test/unit/gateways/nmi_test.rb' - - 'test/unit/gateways/orbital_test.rb' - - 'test/unit/gateways/payex_test.rb' - - 'test/unit/gateways/paymentez_test.rb' - - 'test/unit/gateways/world_net_test.rb' - # Offense count: 117 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinSize, WordRegex. diff --git a/lib/active_merchant/billing/base.rb b/lib/active_merchant/billing/base.rb index 2248e6f9c39..5392189e46b 100644 --- a/lib/active_merchant/billing/base.rb +++ b/lib/active_merchant/billing/base.rb @@ -49,7 +49,7 @@ def self.gateway(name) # notification = chronopay.notification(raw_post) # def self.integration(name) - Billing::Integrations.const_get("#{name.to_s.downcase}".camelize) + Billing::Integrations.const_get(name.to_s.downcase.camelize) end # A check to see if we're in test mode diff --git a/lib/active_merchant/billing/compatibility.rb b/lib/active_merchant/billing/compatibility.rb index b32cb6ca4f4..740cc3d0906 100644 --- a/lib/active_merchant/billing/compatibility.rb +++ b/lib/active_merchant/billing/compatibility.rb @@ -102,7 +102,7 @@ def full_messages self.each do |key, messages| next unless(messages && !messages.empty?) if key == 'base' - result << "#{messages.first}" + result << messages.first.to_s else result << "#{Compatibility.humanize(key)} #{messages.first}" end diff --git a/lib/active_merchant/billing/gateways/banwire.rb b/lib/active_merchant/billing/gateways/banwire.rb index 09aeb583fe2..d0e23302c00 100644 --- a/lib/active_merchant/billing/gateways/banwire.rb +++ b/lib/active_merchant/billing/gateways/banwire.rb @@ -63,7 +63,7 @@ def add_creditcard(post, creditcard) post[:card_num] = creditcard.number post[:card_name] = creditcard.name post[:card_type] = card_brand(creditcard) - post[:card_exp] = "#{sprintf("%02d", creditcard.month)}/#{"#{creditcard.year}"[-2, 2]}" + post[:card_exp] = "#{sprintf("%02d", creditcard.month)}/#{creditcard.year.to_s[-2, 2]}" post[:card_ccv2] = creditcard.verification_value end diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb index afafc938d9e..f133cf33c41 100644 --- a/lib/active_merchant/billing/gateways/cardknox.rb +++ b/lib/active_merchant/billing/gateways/cardknox.rb @@ -312,7 +312,7 @@ def post_data(command, parameters = {}) Key: @options[:api_key], Version: '4.5.4', SoftwareName: 'Active Merchant', - SoftwareVersion: "#{ActiveMerchant::VERSION}", + SoftwareVersion: ActiveMerchant::VERSION.to_s, Command: command, } diff --git a/lib/active_merchant/billing/gateways/conekta.rb b/lib/active_merchant/billing/gateways/conekta.rb index 6b3dccd915e..2e38d54c43c 100644 --- a/lib/active_merchant/billing/gateways/conekta.rb +++ b/lib/active_merchant/billing/gateways/conekta.rb @@ -162,8 +162,8 @@ def add_payment_source(post, payment_source, options) post[:card][:name] = payment_source.name post[:card][:cvc] = payment_source.verification_value post[:card][:number] = payment_source.number - post[:card][:exp_month] = "#{sprintf("%02d", payment_source.month)}" - post[:card][:exp_year] = "#{"#{payment_source.year}"[-2, 2]}" + post[:card][:exp_month] = sprintf('%02d', payment_source.month) + post[:card][:exp_year] = payment_source.year.to_s[-2, 2] add_address(post[:card], options) end end diff --git a/lib/active_merchant/billing/gateways/digitzs.rb b/lib/active_merchant/billing/gateways/digitzs.rb index 80510bf8e0a..b8b7d96fcb5 100644 --- a/lib/active_merchant/billing/gateways/digitzs.rb +++ b/lib/active_merchant/billing/gateways/digitzs.rb @@ -163,7 +163,7 @@ def create_customer_request(payment, options) post[:data][:attributes] = { merchantId: options[:merchant_id], name: payment.name, - externalId: "#{SecureRandom.hex(16)}" + externalId: SecureRandom.hex(16) } post diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb index 72e45021922..c08ebcd4285 100644 --- a/lib/active_merchant/billing/gateways/eway_managed.rb +++ b/lib/active_merchant/billing/gateways/eway_managed.rb @@ -253,9 +253,9 @@ def soap_request(arguments, action) end end xml.tag! 'soap12:Body' do |x| - x.tag! "#{action}", {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do |y| + x.tag! action, {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do |y| post.each do |key, value| - y.tag! "#{key}", "#{value}" + y.tag! key, value end end end diff --git a/lib/active_merchant/billing/gateways/first_giving.rb b/lib/active_merchant/billing/gateways/first_giving.rb index 3adb5ab8d85..29514f4334f 100644 --- a/lib/active_merchant/billing/gateways/first_giving.rb +++ b/lib/active_merchant/billing/gateways/first_giving.rb @@ -133,8 +133,8 @@ def creditcard_brand(brand) def headers { 'User-Agent' => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}", - 'JG_APPLICATIONKEY' => "#{@options[:application_key]}", - 'JG_SECURITYTOKEN' => "#{@options[:security_token]}" + 'JG_APPLICATIONKEY' => @options[:application_key].to_s, + 'JG_SECURITYTOKEN' => @options[:security_token].to_s } end end diff --git a/lib/active_merchant/billing/gateways/merchant_one.rb b/lib/active_merchant/billing/gateways/merchant_one.rb index 1a2c457fec5..c65149bed62 100644 --- a/lib/active_merchant/billing/gateways/merchant_one.rb +++ b/lib/active_merchant/billing/gateways/merchant_one.rb @@ -77,7 +77,7 @@ def add_address(post, creditcard, options) def add_creditcard(post, creditcard) post['cvv'] = creditcard.verification_value post['ccnumber'] = creditcard.number - post['ccexp'] = "#{sprintf("%02d", creditcard.month)}#{"#{creditcard.year}"[-2, 2]}" + post['ccexp'] = "#{sprintf("%02d", creditcard.month)}#{creditcard.year.to_s[-2, 2]}" end def commit(action, money, parameters={}) diff --git a/lib/active_merchant/billing/gateways/openpay.rb b/lib/active_merchant/billing/gateways/openpay.rb index 42db1200b97..83c64de6258 100644 --- a/lib/active_merchant/billing/gateways/openpay.rb +++ b/lib/active_merchant/billing/gateways/openpay.rb @@ -126,8 +126,8 @@ def add_creditcard(post, creditcard, options) elsif creditcard.respond_to?(:number) card = { card_number: creditcard.number, - expiration_month: "#{sprintf("%02d", creditcard.month)}", - expiration_year: "#{"#{creditcard.year}"[-2, 2]}", + expiration_month: sprintf('%02d', creditcard.month), + expiration_year: creditcard.year.to_s[-2, 2], cvv2: creditcard.verification_value, holder_name: creditcard.name } diff --git a/lib/active_merchant/billing/gateways/pay_junction_v2.rb b/lib/active_merchant/billing/gateways/pay_junction_v2.rb index 9cac25e238a..f05d335b8e8 100644 --- a/lib/active_merchant/billing/gateways/pay_junction_v2.rb +++ b/lib/active_merchant/billing/gateways/pay_junction_v2.rb @@ -141,7 +141,7 @@ def headers 'Authorization' => 'Basic ' + Base64.encode64("#{@options[:api_login]}:#{@options[:api_password]}").strip, 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8', 'Accept' => 'application/json', - 'X-PJ-Application-Key' => "#{@options[:api_key]}" + 'X-PJ-Application-Key' => @options[:api_key].to_s } end diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index 684f1c3d468..82aab0e2113 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -181,7 +181,7 @@ def childnode_to_response(response, childnode) end def element_name_to_symbol(response, childnode) - name = "#{childnode.name.downcase}" + name = childnode.name.downcase response[name.to_sym] = childnode.text end diff --git a/lib/active_merchant/billing/gateways/telr.rb b/lib/active_merchant/billing/gateways/telr.rb index f1c34063c9a..b7cff295ac8 100644 --- a/lib/active_merchant/billing/gateways/telr.rb +++ b/lib/active_merchant/billing/gateways/telr.rb @@ -219,7 +219,7 @@ def parse(xml) response[node.name.downcase.to_sym] = node.text else node.elements.each do |childnode| - name = "#{childnode.name.downcase}" + name = childnode.name.downcase response[name.to_sym] = childnode.text end end diff --git a/lib/support/gateway_support.rb b/lib/support/gateway_support.rb index 29b3fc05a8e..c811e7d04fe 100644 --- a/lib/support/gateway_support.rb +++ b/lib/support/gateway_support.rb @@ -32,13 +32,13 @@ def features width = 15 print 'Name'.center(width + 20) - ACTIONS.each{|f| print "#{f.to_s.capitalize.center(width)}" } + ACTIONS.each{|f| print f.to_s.capitalize.center(width) } puts each_gateway do |g| - print "#{g.display_name.ljust(width + 20)}" + print g.display_name.ljust(width + 20) ACTIONS.each do |f| - print "#{(g.instance_methods.include?(f.to_s) ? "Y" : "N").center(width)}" + print((g.instance_methods.include?(f.to_s) ? 'Y' : 'N').center(width)) end puts end diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb index 106a3cf3a0d..48fc84c0443 100644 --- a/test/remote/gateways/remote_cyber_source_test.rb +++ b/test/remote/gateways/remote_cyber_source_test.rb @@ -12,19 +12,19 @@ def setup @three_ds_unenrolled_card = credit_card('4000000000000051', verification_value: '321', month: '12', - year: "#{Time.now.year + 2}", + year: (Time.now.year + 2).to_s, brand: :visa ) @three_ds_enrolled_card = credit_card('4000000000000002', verification_value: '321', month: '12', - year: "#{Time.now.year + 2}", + year: (Time.now.year + 2).to_s, brand: :visa ) @three_ds_invalid_card = credit_card('4000000000000010', verification_value: '321', month: '12', - year: "#{Time.now.year + 2}", + year: (Time.now.year + 2).to_s, brand: :visa ) diff --git a/test/unit/gateways/clearhaus_test.rb b/test/unit/gateways/clearhaus_test.rb index a30a5b3894c..0794d356bdc 100644 --- a/test/unit/gateways/clearhaus_test.rb +++ b/test/unit/gateways/clearhaus_test.rb @@ -355,7 +355,7 @@ def post_scrubbed end def test_private_key - %Q{-----BEGIN RSA PRIVATE KEY-----\nMIIBOwIBAAJBALYK0zmwuYkH3YWcFNLLddx5cwDxEY7Gi1xITuQqRrU4yD3uSw+J\nWYKknb4Tbndb6iEHY+e6gIGD+49TojnNeIUCAwEAAQJARyuYRRe4kcBHdPL+mSL+\nY0IAGkAlUyKAXYXPghidKD/v/oLrFaZWALGM2clv6UoYYpPnInSgbcud4sTcfeUm\nQQIhAN2JZ2qv0WGcbIopBpwpQ5jDxMGVkmkVVUEWWABGF8+pAiEA0lySxTELZm8b\nGx9UEDRghN+Qv/OuIKFldu1Ba4f8W30CIQCaQFIBtunTTVdF28r+cLzgYW9eWwbW\npEP4TdZ4WlW6AQIhAMDCTUdeUpjxlH/87BXROORozAXocBW8bvJUI486U5ctAiAd\nInviQqJd1KTGRDmWIGrE5YACVmW2JSszD9t5VKxkAA==\n-----END RSA PRIVATE KEY-----} + "-----BEGIN RSA PRIVATE KEY-----\nMIIBOwIBAAJBALYK0zmwuYkH3YWcFNLLddx5cwDxEY7Gi1xITuQqRrU4yD3uSw+J\nWYKknb4Tbndb6iEHY+e6gIGD+49TojnNeIUCAwEAAQJARyuYRRe4kcBHdPL+mSL+\nY0IAGkAlUyKAXYXPghidKD/v/oLrFaZWALGM2clv6UoYYpPnInSgbcud4sTcfeUm\nQQIhAN2JZ2qv0WGcbIopBpwpQ5jDxMGVkmkVVUEWWABGF8+pAiEA0lySxTELZm8b\nGx9UEDRghN+Qv/OuIKFldu1Ba4f8W30CIQCaQFIBtunTTVdF28r+cLzgYW9eWwbW\npEP4TdZ4WlW6AQIhAMDCTUdeUpjxlH/87BXROORozAXocBW8bvJUI486U5ctAiAd\nInviQqJd1KTGRDmWIGrE5YACVmW2JSszD9t5VKxkAA==\n-----END RSA PRIVATE KEY-----" end def failed_purchase_response diff --git a/test/unit/gateways/forte_test.rb b/test/unit/gateways/forte_test.rb index 124d2b3a17f..c7ca564cc65 100644 --- a/test/unit/gateways/forte_test.rb +++ b/test/unit/gateways/forte_test.rb @@ -193,7 +193,7 @@ def post_scrubbed end def successful_purchase_response - %q( + ' { "transaction_id":"trn_bb7687a7-3d3a-40c2-8fa9-90727a814249", "account_id":"act_300111", @@ -227,11 +227,11 @@ def successful_purchase_response "settlements":"https://sandbox.forte.net/API/v2/transactions/trn_bb7687a7-3d3a-40c2-8fa9-90727a814249/settlements" } } - ) + ' end def failed_purchase_response - %q( + ' { "transaction_id":"trn_e9ea64c4-5c2c-43dd-9138-f2661b59947c", "account_id":"act_300111", @@ -261,11 +261,11 @@ def failed_purchase_response "settlements":"https://sandbox.forte.net/API/v2/transactions/trn_e9ea64c4-5c2c-43dd-9138-f2661b59947c/settlements" } } - ) + ' end def successful_echeck_purchase_response - %q( + ' { "transaction_id":"trn_bb7687a7-3d3a-40c2-8fa9-90727a814249", "account_id":"act_300111", @@ -306,11 +306,11 @@ def successful_echeck_purchase_response "settlements":"https://sandbox.forte.net/API/v2/transactions/trn_bb7687a7-3d3a-40c2-8fa9-90727a814249/settlements" } } - ) + ' end def failed_echeck_purchase_response - %q( + ' { "transaction_id":"trn_bb7687a7-3d3a-40c2-8fa9-90727a814249", "account_id":"act_300111", @@ -348,11 +348,11 @@ def failed_echeck_purchase_response "settlements":"https://sandbox.forte.net/API/v2/transactions/trn_bb7687a7-3d3a-40c2-8fa9-90727a814249/settlements" } } - ) + ' end def successful_authorize_response - %q( + ' { "transaction_id":"trn_527fdc8a-d3d0-4680-badc-bfa784c63c13", "account_id":"act_300111", @@ -386,11 +386,11 @@ def successful_authorize_response "settlements":"https://sandbox.forte.net/API/v2/transactions/trn_527fdc8a-d3d0-4680-badc-bfa784c63c13/settlements" } } - ) + ' end def failed_authorize_response - %q( + ' { "transaction_id":"trn_7c045645-98b3-4c8a-88d6-e8d686884564", "account_id":"act_300111", @@ -420,11 +420,11 @@ def failed_authorize_response "settlements":"https://sandbox.forte.net/API/v2/transactions/trn_7c045645-98b3-4c8a-88d6-e8d686884564/settlements" } } - ) + ' end def successful_capture_response - %q( + ' { "transaction_id":"trn_94a04a97-c847-4420-820b-fb153a1f0f64", "account_id":"act_300111", @@ -444,11 +444,11 @@ def successful_capture_response "settlements":"https://sandbox.forte.net/API/v2/transactions/trn_94a04a97-c847-4420-820b-fb153a1f0f64/settlements" } } - ) + ' end def failed_capture_response - %q( + ' { "account_id":"act_300111", "location_id":"loc_176008", @@ -459,11 +459,11 @@ def failed_capture_response "response_desc":"The field transaction_id is required." } } - ) + ' end def successful_credit_response - %q( + ' { "transaction_id":"trn_357b284e-1dde-42ba-b0a5-5f66e08c7d9f", "account_id":"act_300111", @@ -497,11 +497,11 @@ def successful_credit_response "settlements":"https://sandbox.forte.net/API/v2/transactions/trn_357b284e-1dde-42ba-b0a5-5f66e08c7d9f/settlements" } } - ) + ' end def failed_credit_response - %q( + ' { "transaction_id":"trn_ce70ce9a-6265-4892-9a83-5825cb869ed5", "account_id":"act_300111", @@ -523,11 +523,11 @@ def failed_credit_response "settlements":"https://sandbox.forte.net/API/v2/transactions/trn_ce70ce9a-6265-4892-9a83-5825cb869ed5/settlements" } } - ) + ' end def successful_void_response - %q( + ' { "transaction_id":"trn_6c9d049e-1971-45fb-a4da-a0c35c4ed274", "account_id":"act_300111", @@ -546,11 +546,11 @@ def successful_void_response "settlements":"https://sandbox.forte.net/API/v2/transactions/trn_6c9d049e-1971-45fb-a4da-a0c35c4ed274/settlements" } } - ) + ' end def failed_void_response - %q( + ' { "account_id":"act_300111", "location_id":"loc_176008", @@ -561,7 +561,7 @@ def failed_void_response "response_desc":"The field transaction_id is required." } } - ) + ' end def successful_refund_response diff --git a/test/unit/gateways/merchant_warrior_test.rb b/test/unit/gateways/merchant_warrior_test.rb index 8eb0e1e85f2..2d718e7da74 100644 --- a/test/unit/gateways/merchant_warrior_test.rb +++ b/test/unit/gateways/merchant_warrior_test.rb @@ -223,10 +223,10 @@ def successful_store_response end def pre_scrubbed - %q(transactionAmount=1.00&transactionCurrency=AUD&hash=adb50f6ff360f861e6f525e8daae76b5&transactionProduct=98fc25d40a47f3d24da460c0ca307c&customerName=Longbob+Longsen&customerCountry=AU&customerState=Queensland&customerCity=Brisbane&customerAddress=123+test+st&customerPostCode=4000&customerIP=&customerPhone=&customerEmail=&paymentCardNumber=5123456789012346&paymentCardName=Longbob+Longsen&paymentCardExpiry=0520&paymentCardCSC=123&merchantUUID=51f7da294af8f&apiKey=nooudtd0&method=processCard) + 'transactionAmount=1.00&transactionCurrency=AUD&hash=adb50f6ff360f861e6f525e8daae76b5&transactionProduct=98fc25d40a47f3d24da460c0ca307c&customerName=Longbob+Longsen&customerCountry=AU&customerState=Queensland&customerCity=Brisbane&customerAddress=123+test+st&customerPostCode=4000&customerIP=&customerPhone=&customerEmail=&paymentCardNumber=5123456789012346&paymentCardName=Longbob+Longsen&paymentCardExpiry=0520&paymentCardCSC=123&merchantUUID=51f7da294af8f&apiKey=nooudtd0&method=processCard' end def post_scrubbed - %q(transactionAmount=1.00&transactionCurrency=AUD&hash=adb50f6ff360f861e6f525e8daae76b5&transactionProduct=98fc25d40a47f3d24da460c0ca307c&customerName=Longbob+Longsen&customerCountry=AU&customerState=Queensland&customerCity=Brisbane&customerAddress=123+test+st&customerPostCode=4000&customerIP=&customerPhone=&customerEmail=&paymentCardNumber=[FILTERED]&paymentCardName=Longbob+Longsen&paymentCardExpiry=0520&paymentCardCSC=[FILTERED]&merchantUUID=51f7da294af8f&apiKey=[FILTERED]&method=processCard) + 'transactionAmount=1.00&transactionCurrency=AUD&hash=adb50f6ff360f861e6f525e8daae76b5&transactionProduct=98fc25d40a47f3d24da460c0ca307c&customerName=Longbob+Longsen&customerCountry=AU&customerState=Queensland&customerCity=Brisbane&customerAddress=123+test+st&customerPostCode=4000&customerIP=&customerPhone=&customerEmail=&paymentCardNumber=[FILTERED]&paymentCardName=Longbob+Longsen&paymentCardExpiry=0520&paymentCardCSC=[FILTERED]&merchantUUID=51f7da294af8f&apiKey=[FILTERED]&method=processCard' end end diff --git a/test/unit/gateways/nmi_test.rb b/test/unit/gateways/nmi_test.rb index 8512e3d9ba1..f7f7d3c0030 100644 --- a/test/unit/gateways/nmi_test.rb +++ b/test/unit/gateways/nmi_test.rb @@ -444,20 +444,20 @@ def successful_echeck_store_response end def transcript - %q( + ' amount=1.00&orderid=c9f2fb356d2a839d315aa6e8d7ed2404&orderdescription=Store+purchase&currency=USD&payment=creditcard&firstname=Longbob&lastname=Longsen&ccnumber=4111111111111111&cvv=917&ccexp=0916&email=&ipaddress=&company=Widgets+Inc&address1=456+My+Street&address2=Apt+1&city=Ottawa&state=ON&country=CA&zip=K1C2N6&phone=%28555%29555-5555&type=sale&username=demo&password=password response=1&responsetext=SUCCESS&authcode=123456&transactionid=2767466670&avsresponse=N&cvvresponse=N&orderid=c9f2fb356d2a839d315aa6e8d7ed2404&type=sale&response_code=100 amount=1.00&orderid=e88df316d8ba3c8c6b98aa93b78facc0&orderdescription=Store+purchase&currency=USD&payment=check&checkname=Jim+Smith&checkaba=123123123&checkaccount=123123123&account_holder_type=personal&account_type=checking&sec_code=WEB&email=&ipaddress=&company=Widgets+Inc&address1=456+My+Street&address2=Apt+1&city=Ottawa&state=ON&country=CA&zip=K1C2N6&phone=%28555%29555-5555&type=sale&username=demo&password=password response=1&responsetext=SUCCESS&authcode=123456&transactionid=2767467157&avsresponse=&cvvresponse=&orderid=e88df316d8ba3c8c6b98aa93b78facc0&type=sale&response_code=100 - ) + ' end def scrubbed_transcript - %q( + ' amount=1.00&orderid=c9f2fb356d2a839d315aa6e8d7ed2404&orderdescription=Store+purchase&currency=USD&payment=creditcard&firstname=Longbob&lastname=Longsen&ccnumber=[FILTERED]&cvv=[FILTERED]&ccexp=0916&email=&ipaddress=&company=Widgets+Inc&address1=456+My+Street&address2=Apt+1&city=Ottawa&state=ON&country=CA&zip=K1C2N6&phone=%28555%29555-5555&type=sale&username=demo&password=[FILTERED] response=1&responsetext=SUCCESS&authcode=123456&transactionid=2767466670&avsresponse=N&cvvresponse=N&orderid=c9f2fb356d2a839d315aa6e8d7ed2404&type=sale&response_code=100 amount=1.00&orderid=e88df316d8ba3c8c6b98aa93b78facc0&orderdescription=Store+purchase&currency=USD&payment=check&checkname=Jim+Smith&checkaba=[FILTERED]&checkaccount=[FILTERED]&account_holder_type=personal&account_type=checking&sec_code=WEB&email=&ipaddress=&company=Widgets+Inc&address1=456+My+Street&address2=Apt+1&city=Ottawa&state=ON&country=CA&zip=K1C2N6&phone=%28555%29555-5555&type=sale&username=demo&password=[FILTERED] response=1&responsetext=SUCCESS&authcode=123456&transactionid=2767467157&avsresponse=&cvvresponse=&orderid=e88df316d8ba3c8c6b98aa93b78facc0&type=sale&response_code=100 - ) + ' end end diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index aac02cff291..5a23c6d072c 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -753,15 +753,15 @@ def successful_purchase_response(resp_code = '00') end def failed_purchase_response - %q{<?xml version="1.0" encoding="UTF-8"?><Response><NewOrderResp><IndustryType></IndustryType><MessageType>AC</MessageType><MerchantID>700000000000</MerchantID><TerminalID>001</TerminalID><CardBrand>VI</CardBrand><AccountNum>4000300011112220</AccountNum><OrderID>1</OrderID><TxRefNum>4A5398CF9B87744GG84A1D30F2F2321C66249416</TxRefNum><TxRefIdx>0</TxRefIdx><ProcStatus>0</ProcStatus><ApprovalStatus>0</ApprovalStatus><RespCode>05</RespCode><AVSRespCode>G </AVSRespCode><CVV2RespCode>N</CVV2RespCode><AuthCode></AuthCode><RecurringAdviceCd></RecurringAdviceCd><CAVVRespCode></CAVVRespCode><StatusMsg>Do Not Honor</StatusMsg><RespMsg>AUTH DECLINED 12001</RespMsg><HostRespCode>05</HostRespCode><HostAVSRespCode>N</HostAVSRespCode><HostCVV2RespCode>N</HostCVV2RespCode><CustomerRefNum></CustomerRefNum><CustomerName></CustomerName><ProfileProcStatus></ProfileProcStatus><CustomerProfileMessage></CustomerProfileMessage><RespTime>150214</RespTime></NewOrderResp></Response>} + '<?xml version="1.0" encoding="UTF-8"?><Response><NewOrderResp><IndustryType></IndustryType><MessageType>AC</MessageType><MerchantID>700000000000</MerchantID><TerminalID>001</TerminalID><CardBrand>VI</CardBrand><AccountNum>4000300011112220</AccountNum><OrderID>1</OrderID><TxRefNum>4A5398CF9B87744GG84A1D30F2F2321C66249416</TxRefNum><TxRefIdx>0</TxRefIdx><ProcStatus>0</ProcStatus><ApprovalStatus>0</ApprovalStatus><RespCode>05</RespCode><AVSRespCode>G </AVSRespCode><CVV2RespCode>N</CVV2RespCode><AuthCode></AuthCode><RecurringAdviceCd></RecurringAdviceCd><CAVVRespCode></CAVVRespCode><StatusMsg>Do Not Honor</StatusMsg><RespMsg>AUTH DECLINED 12001</RespMsg><HostRespCode>05</HostRespCode><HostAVSRespCode>N</HostAVSRespCode><HostCVV2RespCode>N</HostCVV2RespCode><CustomerRefNum></CustomerRefNum><CustomerName></CustomerName><ProfileProcStatus></ProfileProcStatus><CustomerProfileMessage></CustomerProfileMessage><RespTime>150214</RespTime></NewOrderResp></Response>' end def successful_profile_response - %q{<?xml version="1.0" encoding="UTF-8"?><Response><ProfileResp><CustomerBin>000001</CustomerBin><CustomerMerchantID>700000000000</CustomerMerchantID><CustomerName>Longbob Longsen</CustomerName><CustomerRefNum>ABC</CustomerRefNum><CustomerProfileAction>CREATE</CustomerProfileAction><ProfileProcStatus>0</ProfileProcStatus><CustomerProfileMessage>Profile Request Processed</CustomerProfileMessage><CustomerAccountType>CC</CustomerAccountType><Status>A</Status><CCAccountNum>4111111111111111</CCAccountNum><RespTime/></ProfileResp></Response>} + '<?xml version="1.0" encoding="UTF-8"?><Response><ProfileResp><CustomerBin>000001</CustomerBin><CustomerMerchantID>700000000000</CustomerMerchantID><CustomerName>Longbob Longsen</CustomerName><CustomerRefNum>ABC</CustomerRefNum><CustomerProfileAction>CREATE</CustomerProfileAction><ProfileProcStatus>0</ProfileProcStatus><CustomerProfileMessage>Profile Request Processed</CustomerProfileMessage><CustomerAccountType>CC</CustomerAccountType><Status>A</Status><CCAccountNum>4111111111111111</CCAccountNum><RespTime/></ProfileResp></Response>' end def successful_void_response - %q{<?xml version="1.0" encoding="UTF-8"?><Response><ReversalResp><MerchantID>700000208761</MerchantID><TerminalID>001</TerminalID><OrderID>2</OrderID><TxRefNum>50FB1C41FEC9D016FF0BEBAD0884B174AD0853B0</TxRefNum><TxRefIdx>1</TxRefIdx><OutstandingAmt>0</OutstandingAmt><ProcStatus>0</ProcStatus><StatusMsg></StatusMsg><RespTime>01192013172049</RespTime></ReversalResp></Response>} + '<?xml version="1.0" encoding="UTF-8"?><Response><ReversalResp><MerchantID>700000208761</MerchantID><TerminalID>001</TerminalID><OrderID>2</OrderID><TxRefNum>50FB1C41FEC9D016FF0BEBAD0884B174AD0853B0</TxRefNum><TxRefIdx>1</TxRefIdx><OutstandingAmt>0</OutstandingAmt><ProcStatus>0</ProcStatus><StatusMsg></StatusMsg><RespTime>01192013172049</RespTime></ReversalResp></Response>' end def pre_scrubbed diff --git a/test/unit/gateways/payex_test.rb b/test/unit/gateways/payex_test.rb index c948304954a..a567c1a08c1 100644 --- a/test/unit/gateways/payex_test.rb +++ b/test/unit/gateways/payex_test.rb @@ -125,7 +125,7 @@ def test_successful_purchase_with_stored_card private def successful_initialize_response - %q{<?xml version="1.0" encoding="utf-8"?> + '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <Initialize8Response xmlns="http://external.payex.com/PxOrder/"> @@ -133,12 +133,12 @@ def successful_initialize_response </Initialize8Response> </soap:Body> </soap:Envelope> - } + ' end # Place raw successful response from gateway here def successful_purchase_response - %q{<?xml version="1.0" encoding="utf-8"?> + '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <PurchaseCCResponse xmlns="http://confined.payex.com/PxOrder/"> @@ -146,11 +146,11 @@ def successful_purchase_response </PurchaseCCResponse> </soap:Body> </soap:Envelope> - } + ' end def failed_purchase_response - %q{<?xml version="1.0" encoding="utf-8"?> + '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <PurchaseCCResponse xmlns="http://confined.payex.com/PxOrder/"> @@ -159,11 +159,11 @@ def failed_purchase_response </PurchaseCCResponse> </soap:Body> </soap:Envelope> - } + ' end def successful_authorize_response - %q{<?xml version="1.0" encoding="utf-8"?> + '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <PurchaseCCResponse xmlns="http://confined.payex.com/PxOrder/"> @@ -171,11 +171,11 @@ def successful_authorize_response </PurchaseCCResponse> </soap:Body> </soap:Envelope> - } + ' end def successful_capture_response - %q{<?xml version="1.0" encoding="utf-8"?> + '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <Capture5Response xmlns="http://external.payex.com/PxOrder/"> @@ -183,11 +183,11 @@ def successful_capture_response </Capture5Response> </soap:Body> </soap:Envelope> - } + ' end def failed_capture_response - %q{<?xml version="1.0" encoding="utf-8"?> + '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <Capture5Response xmlns="http://external.payex.com/PxOrder/"> @@ -195,11 +195,11 @@ def failed_capture_response </Capture5Response> </soap:Body> </soap:Envelope> - } + ' end def successful_void_response - %q{<?xml version="1.0" encoding="utf-8"?> + '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <Cancel2Response xmlns="http://external.payex.com/PxOrder/"> @@ -207,11 +207,11 @@ def successful_void_response </Cancel2Response> </soap:Body> </soap:Envelope> - } + ' end def unsuccessful_void_response - %q{<?xml version="1.0" encoding="utf-8"?> + '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <Cancel2Response xmlns="http://external.payex.com/PxOrder/"> @@ -219,11 +219,11 @@ def unsuccessful_void_response </Cancel2Response> </soap:Body> </soap:Envelope> - } + ' end def successful_refund_response - %q{<?xml version="1.0" encoding="utf-8"?> + '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <Credit5Response xmlns="http://external.payex.com/PxOrder/"> @@ -231,11 +231,11 @@ def successful_refund_response </Credit5Response> </soap:Body> </soap:Envelope> - } + ' end def unsuccessful_refund_response - %q{<?xml version="1.0" encoding="utf-8"?> + '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <Credit5Response xmlns="http://external.payex.com/PxOrder/"> @@ -243,11 +243,11 @@ def unsuccessful_refund_response </Credit5Response> </soap:Body> </soap:Envelope> - } + ' end def successful_store_response - %q{<?xml version="1.0" encoding="utf-8"?> + '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <CreateAgreement3Response xmlns="http://external.payex.com/PxAgreement/"> @@ -255,11 +255,11 @@ def successful_store_response </CreateAgreement3Response> </soap:Body> </soap:Envelope> - } + ' end def successful_unstore_response - %q{<?xml version="1.0" encoding="utf-8"?> + '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <DeleteAgreementResponse xmlns="http://external.payex.com/PxAgreement/"> @@ -267,11 +267,11 @@ def successful_unstore_response </DeleteAgreementResponse> </soap:Body> </soap:Envelope> - } + ' end def successful_autopay_response - %q{<?xml version="1.0" encoding="utf-8"?> + '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <AutoPay3Response xmlns="http://external.payex.com/PxAgreement/"> @@ -279,6 +279,6 @@ def successful_autopay_response </AutoPay3Response> </soap:Body> </soap:Envelope> - } + ' end end diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb index 166ab7ebcf0..331c283b417 100644 --- a/test/unit/gateways/paymentez_test.rb +++ b/test/unit/gateways/paymentez_test.rb @@ -226,7 +226,7 @@ def post_scrubbed end def successful_purchase_response - %q( + ' { "transaction": { "status": "success", @@ -249,11 +249,11 @@ def successful_purchase_response "number": "1111" } } - ) + ' end def failed_purchase_response - %q( + ' { "transaction": { "status": "failure", @@ -276,11 +276,11 @@ def failed_purchase_response "number": "4242" } } - ) + ' end def successful_authorize_response - %q( + ' { "transaction": { "status": "success", @@ -305,11 +305,11 @@ def successful_authorize_response "number": "1111" } } - ) + ' end def failed_authorize_response - %q( + ' { "transaction": { "status": "failure", @@ -335,11 +335,11 @@ def failed_authorize_response "origin": "Paymentez" } } - ) + ' end def successful_capture_response - %q( + ' { "transaction": { "status": "success", @@ -364,7 +364,7 @@ def successful_capture_response "number": "1111" } } - ) + ' end def failed_capture_response @@ -395,7 +395,7 @@ def successful_store_response end def failed_store_response - %q( + ' { "card": { "bin": "424242", @@ -409,11 +409,11 @@ def failed_store_response "number": "4242" } } - ) + ' end def expired_card_response - %q( + ' { "transaction":{ "status":"failure", @@ -437,11 +437,11 @@ def expired_card_response "origin":"Paymentez" } } - ) + ' end def crash_response - %q( + ' <html> <head> <title>Internal Server Error</title> @@ -451,6 +451,6 @@ def crash_response </body> </html> - ) + ' end end diff --git a/test/unit/gateways/world_net_test.rb b/test/unit/gateways/world_net_test.rb index d668b615cf6..c32728f69b9 100644 --- a/test/unit/gateways/world_net_test.rb +++ b/test/unit/gateways/world_net_test.rb @@ -191,70 +191,70 @@ def post_scrubbed end def successful_purchase_response - %q(<?xml version="1.0" encoding="UTF-8"?> -<PAYMENTRESPONSE><UNIQUEREF>GZG6IG6VXI</UNIQUEREF><RESPONSECODE>A</RESPONSECODE><RESPONSETEXT>APPROVAL</RESPONSETEXT><APPROVALCODE>475318</APPROVALCODE><DATETIME>2015-09-14T21:22:12</DATETIME><AVSRESPONSE>X</AVSRESPONSE><CVVRESPONSE>M</CVVRESPONSE><HASH>f8642d613c56628371a579443ce8d895</HASH></PAYMENTRESPONSE>) + '<?xml version="1.0" encoding="UTF-8"?> +<PAYMENTRESPONSE><UNIQUEREF>GZG6IG6VXI</UNIQUEREF><RESPONSECODE>A</RESPONSECODE><RESPONSETEXT>APPROVAL</RESPONSETEXT><APPROVALCODE>475318</APPROVALCODE><DATETIME>2015-09-14T21:22:12</DATETIME><AVSRESPONSE>X</AVSRESPONSE><CVVRESPONSE>M</CVVRESPONSE><HASH>f8642d613c56628371a579443ce8d895</HASH></PAYMENTRESPONSE>' end def failed_purchase_response - %q(<?xml version="1.0" encoding="UTF-8"?> -<PAYMENTRESPONSE><UNIQUEREF>JQU1810S4E</UNIQUEREF><RESPONSECODE>D</RESPONSECODE><RESPONSETEXT>DECLINED</RESPONSETEXT><APPROVALCODE></APPROVALCODE><DATETIME>2015-09-14T21:40:07</DATETIME><AVSRESPONSE></AVSRESPONSE><CVVRESPONSE></CVVRESPONSE><HASH>c0ba33a10a6388b12c8fad79a107f2b5</HASH></PAYMENTRESPONSE>) + '<?xml version="1.0" encoding="UTF-8"?> +<PAYMENTRESPONSE><UNIQUEREF>JQU1810S4E</UNIQUEREF><RESPONSECODE>D</RESPONSECODE><RESPONSETEXT>DECLINED</RESPONSETEXT><APPROVALCODE></APPROVALCODE><DATETIME>2015-09-14T21:40:07</DATETIME><AVSRESPONSE></AVSRESPONSE><CVVRESPONSE></CVVRESPONSE><HASH>c0ba33a10a6388b12c8fad79a107f2b5</HASH></PAYMENTRESPONSE>' end def successful_authorize_response - %q(<?xml version="1.0" encoding="UTF-8"?> -<PREAUTHRESPONSE><UNIQUEREF>BF4CNN6WXP</UNIQUEREF><RESPONSECODE>A</RESPONSECODE><RESPONSETEXT>APPROVAL</RESPONSETEXT><APPROVALCODE>450848</APPROVALCODE><DATETIME>2015-09-14T21:53:10</DATETIME><AVSRESPONSE></AVSRESPONSE><CVVRESPONSE></CVVRESPONSE><HASH>e80c52476af1dd969f3bf89ed02fe16f</HASH></PREAUTHRESPONSE>) + '<?xml version="1.0" encoding="UTF-8"?> +<PREAUTHRESPONSE><UNIQUEREF>BF4CNN6WXP</UNIQUEREF><RESPONSECODE>A</RESPONSECODE><RESPONSETEXT>APPROVAL</RESPONSETEXT><APPROVALCODE>450848</APPROVALCODE><DATETIME>2015-09-14T21:53:10</DATETIME><AVSRESPONSE></AVSRESPONSE><CVVRESPONSE></CVVRESPONSE><HASH>e80c52476af1dd969f3bf89ed02fe16f</HASH></PREAUTHRESPONSE>' end def failed_authorize_response - %q(<?xml version="1.0" encoding="UTF-8"?> -<PREAUTHRESPONSE><UNIQUEREF>IP0PUDDXG5</UNIQUEREF><RESPONSECODE>D</RESPONSECODE><RESPONSETEXT>DECLINED</RESPONSETEXT><APPROVALCODE></APPROVALCODE><DATETIME>2015-09-15T14:21:37</DATETIME><AVSRESPONSE></AVSRESPONSE><CVVRESPONSE></CVVRESPONSE><HASH>05dfa85163ee8d8afa8711019f64acb3</HASH></PREAUTHRESPONSE>) + '<?xml version="1.0" encoding="UTF-8"?> +<PREAUTHRESPONSE><UNIQUEREF>IP0PUDDXG5</UNIQUEREF><RESPONSECODE>D</RESPONSECODE><RESPONSETEXT>DECLINED</RESPONSETEXT><APPROVALCODE></APPROVALCODE><DATETIME>2015-09-15T14:21:37</DATETIME><AVSRESPONSE></AVSRESPONSE><CVVRESPONSE></CVVRESPONSE><HASH>05dfa85163ee8d8afa8711019f64acb3</HASH></PREAUTHRESPONSE>' end def successful_capture_response - %q(<?xml version="1.0" encoding="UTF-8"?> -<PREAUTHCOMPLETIONRESPONSE><UNIQUEREF>BF4CNN6WXP</UNIQUEREF><RESPONSECODE>A</RESPONSECODE><RESPONSETEXT>APPROVAL</RESPONSETEXT><APPROVALCODE>450848</APPROVALCODE><DATETIME>2015-09-14T21:53:10</DATETIME><AVSRESPONSE></AVSRESPONSE><CVVRESPONSE></CVVRESPONSE><HASH>e80c52476af1dd969f3bf89ed02fe16f</HASH></PREAUTHCOMPLETIONRESPONSE>) + '<?xml version="1.0" encoding="UTF-8"?> +<PREAUTHCOMPLETIONRESPONSE><UNIQUEREF>BF4CNN6WXP</UNIQUEREF><RESPONSECODE>A</RESPONSECODE><RESPONSETEXT>APPROVAL</RESPONSETEXT><APPROVALCODE>450848</APPROVALCODE><DATETIME>2015-09-14T21:53:10</DATETIME><AVSRESPONSE></AVSRESPONSE><CVVRESPONSE></CVVRESPONSE><HASH>e80c52476af1dd969f3bf89ed02fe16f</HASH></PREAUTHCOMPLETIONRESPONSE>' end def failed_capture_response - %q(<?xml version="1.0" encoding="UTF-8"?> -<ERROR><ERRORSTRING>cvc-minLength-valid: Value &apos;&apos; with length = &apos;0&apos; is not facet-valid with respect to minLength &apos;10&apos; for type &apos;UID&apos;.</ERRORSTRING></ERROR>) + '<?xml version="1.0" encoding="UTF-8"?> +<ERROR><ERRORSTRING>cvc-minLength-valid: Value &apos;&apos; with length = &apos;0&apos; is not facet-valid with respect to minLength &apos;10&apos; for type &apos;UID&apos;.</ERRORSTRING></ERROR>' end def successful_refund_response - %q(<?xml version="1.0" encoding="UTF-8"?> -<REFUNDRESPONSE><RESPONSECODE>A</RESPONSECODE><RESPONSETEXT>SUCCESS</RESPONSETEXT><UNIQUEREF>GIOH10II2J</UNIQUEREF><DATETIME>15-09-2015:14:44:17:999</DATETIME><HASH>aebd69e9db6e4b0db7ecbae79a2970a0</HASH></REFUNDRESPONSE>) + '<?xml version="1.0" encoding="UTF-8"?> +<REFUNDRESPONSE><RESPONSECODE>A</RESPONSECODE><RESPONSETEXT>SUCCESS</RESPONSETEXT><UNIQUEREF>GIOH10II2J</UNIQUEREF><DATETIME>15-09-2015:14:44:17:999</DATETIME><HASH>aebd69e9db6e4b0db7ecbae79a2970a0</HASH></REFUNDRESPONSE>' end def failed_refund_response - %q(<?xml version="1.0" encoding="UTF-8"?> -<ERROR><ERRORSTRING>cvc-minLength-valid: Value &apos;&apos; with length = &apos;0&apos; is not facet-valid with respect to minLength &apos;10&apos; for type &apos;UID&apos;.</ERRORSTRING></ERROR>) + '<?xml version="1.0" encoding="UTF-8"?> +<ERROR><ERRORSTRING>cvc-minLength-valid: Value &apos;&apos; with length = &apos;0&apos; is not facet-valid with respect to minLength &apos;10&apos; for type &apos;UID&apos;.</ERRORSTRING></ERROR>' end def successful_void_response end def successful_store_response - %q(<?xml version="1.0" encoding="UTF-8"?> -<SECURECARDREGISTRATIONRESPONSE><MERCHANTREF>146304412401</MERCHANTREF><CARDREFERENCE>2967530956419033</CARDREFERENCE><DATETIME>12-05-2016:10:08:46:269</DATETIME><HASH>b2e497d14014ad9f4770edbf7716435e</HASH></SECURECARDREGISTRATIONRESPONSE>) + '<?xml version="1.0" encoding="UTF-8"?> +<SECURECARDREGISTRATIONRESPONSE><MERCHANTREF>146304412401</MERCHANTREF><CARDREFERENCE>2967530956419033</CARDREFERENCE><DATETIME>12-05-2016:10:08:46:269</DATETIME><HASH>b2e497d14014ad9f4770edbf7716435e</HASH></SECURECARDREGISTRATIONRESPONSE>' end def failed_store_response - %q(<?xml version="1.0" encoding="UTF-8"?> -<ERROR><ERRORCODE>E11</ERRORCODE><ERRORSTRING>INVALID CARDEXPIRY</ERRORSTRING></ERROR>) + '<?xml version="1.0" encoding="UTF-8"?> +<ERROR><ERRORCODE>E11</ERRORCODE><ERRORSTRING>INVALID CARDEXPIRY</ERRORSTRING></ERROR>' end def successful_unstore_response - %q(<?xml version="1.0" encoding="UTF-8"?> -<SECURECARDREMOVALRESPONSE><MERCHANTREF>146304412401</MERCHANTREF><DATETIME>12-05-2016:10:08:48:399</DATETIME><HASH>7f755e185be8066a535699755f709646</HASH></SECURECARDREMOVALRESPONSE>) + '<?xml version="1.0" encoding="UTF-8"?> +<SECURECARDREMOVALRESPONSE><MERCHANTREF>146304412401</MERCHANTREF><DATETIME>12-05-2016:10:08:48:399</DATETIME><HASH>7f755e185be8066a535699755f709646</HASH></SECURECARDREMOVALRESPONSE>' end def failed_unstore_response - %q(<?xml version="1.0" encoding="UTF-8"?> -<ERROR><ERRORCODE>E04</ERRORCODE><ERRORSTRING>INVALID REFERENCE DETAILS</ERRORSTRING></ERROR>) + '<?xml version="1.0" encoding="UTF-8"?> +<ERROR><ERRORCODE>E04</ERRORCODE><ERRORSTRING>INVALID REFERENCE DETAILS</ERRORSTRING></ERROR>' end def failed_void_response - %q(<?xml version="1.0" encoding="UTF-8"?> -<ERROR><ERRORSTRING>cvc-elt.1: Cannot find the declaration of element &apos;VOID&apos;.</ERRORSTRING></ERROR>) + '<?xml version="1.0" encoding="UTF-8"?> +<ERROR><ERRORSTRING>cvc-elt.1: Cannot find the declaration of element &apos;VOID&apos;.</ERRORSTRING></ERROR>' end end From 32121207d636bd3f2095a26ca092b4b64b68fad2 Mon Sep 17 00:00:00 2001 From: "shingo.miyazawa" <miyazawa@degica.com> Date: Fri, 14 Sep 2018 11:17:29 +0900 Subject: [PATCH 532/677] Modify Komoju gateway test url Komoju abolished the sandbox environment, but instead supports a test mode in their production environment. Change the URL appropriately. Closes #2987 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/komoju.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 9aa0f8d7686..db43b145c8c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Braintree: Reflect correct test mode in Braintree responses [elfassy] [#2980] * FirstPay: Expose error code [curiousepic] #2979 * Barclaycard Smartpay: Pass device_fingerprint when specified [dtykocki] #2981 +* Komoju: remove no-longer-relevant sandbox URL [miyazawadegica] #2987 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 diff --git a/lib/active_merchant/billing/gateways/komoju.rb b/lib/active_merchant/billing/gateways/komoju.rb index 8aa3fc1b636..d53ab5f5165 100644 --- a/lib/active_merchant/billing/gateways/komoju.rb +++ b/lib/active_merchant/billing/gateways/komoju.rb @@ -3,7 +3,7 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class KomojuGateway < Gateway - self.test_url = 'https://sandbox.komoju.com/api/v1' + self.test_url = 'https://komoju.com/api/v1' self.live_url = 'https://komoju.com/api/v1' self.supported_countries = ['JP'] self.default_currency = 'JPY' From a2e4dcbf794bb80a03667e546600c72029bd06ec Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Wed, 12 Sep 2018 16:17:17 -0400 Subject: [PATCH 533/677] Rubocop changes that effect the indention of comments --- .rubocop_todo.yml | 15 -- .../billing/gateways/firstdata_e4.rb | 4 +- lib/active_merchant/billing/gateways/ogone.rb | 10 +- lib/active_merchant/billing/gateways/opp.rb | 212 +++++++++--------- .../billing/gateways/payflow_express.rb | 106 ++++----- test/remote/gateways/remote_itransact_test.rb | 40 ++-- test/remote/gateways/remote_opp_test.rb | 10 +- test/remote/gateways/remote_paypal_test.rb | 2 +- test/remote/gateways/remote_world_net_test.rb | 6 +- test/unit/gateways/eway_managed_test.rb | 2 +- test/unit/gateways/opp_test.rb | 8 +- 11 files changed, 199 insertions(+), 216 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a14183adddd..b31f60d0e0d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -42,21 +42,6 @@ Layout/CaseIndentation: Layout/ClosingHeredocIndentation: Enabled: false -# Offense count: 20 -# Cop supports --auto-correct. -Layout/CommentIndentation: - Exclude: - - 'lib/active_merchant/billing/gateways/firstdata_e4.rb' - - 'lib/active_merchant/billing/gateways/ogone.rb' - - 'lib/active_merchant/billing/gateways/opp.rb' - - 'lib/active_merchant/billing/gateways/payflow_express.rb' - - 'test/remote/gateways/remote_itransact_test.rb' - - 'test/remote/gateways/remote_opp_test.rb' - - 'test/remote/gateways/remote_paypal_test.rb' - - 'test/remote/gateways/remote_world_net_test.rb' - - 'test/unit/gateways/eway_managed_test.rb' - - 'test/unit/gateways/opp_test.rb' - # Offense count: 513 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index 58d18a49a52..b18bbfb1294 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -43,7 +43,7 @@ class FirstdataE4Gateway < Gateway self.display_name = 'FirstData Global Gateway e4' STANDARD_ERROR_CODE_MAPPING = { - # Bank error codes: https://firstdata.zendesk.com/entries/471297-First-Data-Global-Gateway-e4-Bank-Response-Codes + # Bank error codes: https://firstdata.zendesk.com/entries/471297-First-Data-Global-Gateway-e4-Bank-Response-Codes '201' => STANDARD_ERROR_CODE[:incorrect_number], '531' => STANDARD_ERROR_CODE[:invalid_cvc], '503' => STANDARD_ERROR_CODE[:invalid_cvc], @@ -55,7 +55,7 @@ class FirstdataE4Gateway < Gateway '401' => STANDARD_ERROR_CODE[:call_issuer], '402' => STANDARD_ERROR_CODE[:call_issuer], '501' => STANDARD_ERROR_CODE[:pickup_card], - # Ecommerce error codes -- https://firstdata.zendesk.com/entries/451980-ecommerce-response-codes-etg-codes + # Ecommerce error codes -- https://firstdata.zendesk.com/entries/451980-ecommerce-response-codes-etg-codes '22' => STANDARD_ERROR_CODE[:invalid_number], '25' => STANDARD_ERROR_CODE[:invalid_expiry_date], '31' => STANDARD_ERROR_CODE[:incorrect_cvc], diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb index d3906c1e1c9..0ac3b015f75 100644 --- a/lib/active_merchant/billing/gateways/ogone.rb +++ b/lib/active_merchant/billing/gateways/ogone.rb @@ -122,12 +122,10 @@ class OgoneGateway < Gateway SUCCESS_MESSAGE = 'The transaction was successful' - THREE_D_SECURE_DISPLAY_WAYS = { :main_window => 'MAINW', # display the identification page in the main window - # (default value). - :pop_up => 'POPUP', # display the identification page in a pop-up window - # and return to the main window at the end. - :pop_ix => 'POPIX' } # display the identification page in a pop-up window - # and remain in the pop-up window. + THREE_D_SECURE_DISPLAY_WAYS = { :main_window => 'MAINW', # display the identification page in the main window (default value). + + :pop_up => 'POPUP', # display the identification page in a pop-up window and return to the main window at the end. + :pop_ix => 'POPIX' } # display the identification page in a pop-up window and remain in the pop-up window. OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE = 'Signature usage will be the default for a future release of ActiveMerchant. You should either begin using it, or update your configuration to explicitly disable it (signature_encryptor: none)' OGONE_STORE_OPTION_DEPRECATION_MESSAGE = "The 'store' option has been renamed to 'billing_id', and its usage is deprecated." diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb index f685d70ee9b..956fcec81cc 100644 --- a/lib/active_merchant/billing/gateways/opp.rb +++ b/lib/active_merchant/billing/gateways/opp.rb @@ -1,112 +1,112 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class OppGateway < Gateway - # = Open Payment Platform - # - # The Open Payment Platform includes a powerful omni-channel transaction processing API, - # enabling you to quickly and flexibly build new applications and services on the platform. - # - # This plugin enables connectivity to the Open Payment Platform for activemerchant. - # - # For any questions or comments please contact support@payon.com - # - # == Usage - # - # gateway = ActiveMerchant::Billing::OppGateway.new( - # user_id: 'merchant user id', - # password: 'password', - # entity_id: 'entity id', - # ) - # - # # set up credit card object as in main ActiveMerchant example - # creditcard = ActiveMerchant::Billing::CreditCard.new( - # :type => 'visa', - # :number => '4242424242424242', - # :month => 8, - # :year => 2009, - # :first_name => 'Bob', - # :last_name => 'Bobsen' - # :verification_value: '123') - # - # # Request: complete example, including address, billing address, shipping address - # complete_request_options = { - # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId - # merchant_transaction_id: "your merchant/shop transaction id", - # address: address, - # description: 'Store Purchase - Books', - # risk_workflow: false, - # test_mode: 'EXTERNAL' # or 'INTERNAL', valid only for test system - # create_registration: false, # payment details will be stored on the server an latter can be referenced - # - # billing_address: { - # address1: '123 Test Street', - # city: 'Test', - # state: 'TE', - # zip: 'AB12CD', - # country: 'GB', - # }, - # shipping_address: { - # name: 'Muton DeMicelis', - # address1: 'My Street On Upiter, Apt 3.14/2.78', - # city: 'Munich', - # state: 'Bov', - # zip: '81675', - # country: 'DE', - # }, - # customer: { - # merchant_customer_id: "your merchant/customer id", - # givenname: 'Jane', - # surname: 'Jones', - # birth_date: '1965-05-01', - # phone: '(?!?)555-5555', - # mobile: '(?!?)234-23423', - # email: 'jane@jones.com', - # company_name: 'JJ Ltd.', - # identification_doctype: 'PASSPORT', - # identification_docid: 'FakeID2342431234123', - # ip: 101.102.103.104, - # }, - # } - # - # # Request: minimal example - # minimal_request_options = { - # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId - # description: 'Store Purchase - Books', - # } - # - # options = - # # run request - # response = gateway.purchase(754, creditcard, options) # charge 7,54 EUR - # - # response.success? # Check whether the transaction was successful - # response.error_code # Retrieve the error message - it's mapped to Gateway::STANDARD_ERROR_CODE - # response.message # Retrieve the message returned by opp - # response.authorization # Retrieve the unique transaction ID returned by opp - # response.params['result']['code'] # Retrieve original return code returned by opp server - # - # == Errors - # If transaction is not successful, response.error_code contains mapped to Gateway::STANDARD_ERROR_CODE error message. - # Complete list of opp error codes can be viewed on https://docs.oppwa.com/ - # Because this list is much bigger than Gateway::STANDARD_ERROR_CODE, only fraction is mapped to Gateway::STANDARD_ERROR_CODE. - # All other codes are mapped as Gateway::STANDARD_ERROR_CODE[:processing_error], so if this is the case, - # you may check the original result code from OPP that can be found in response.params['result']['code'] - # - # == Special features - # For purchase method risk check can be forced when options[:risk_workflow] = true - # This will split (on OPP server side) the transaction into two separate transactions: authorize and capture, - # but capture will be executed only if risk checks are successful. - # - # For testing you may use the test account details listed fixtures.yml under opp. It is important to note that there are two test modes available: - # options[:test_mode]='EXTERNAL' causes test transactions to be forwarded to the processor's test system for 'end-to-end' testing - # options[:test_mode]='INTERNAL' causes transactions to be sent to opp simulators, which is useful when switching to the live endpoint for connectivity testing. - # If no test_mode parameter is sent, test_mode=INTERNAL is the default behaviour. - # - # Billing Address, Shipping Address, Custom Parameters are supported as described under https://docs.oppwa.com/parameters - # See complete example above for details. - # - # == Tokenization - # When create_registration is set to true, the payment details will be stored and a token will be returned in registrationId response field, - # which can subsequently be used to reference the stored payment. + # = Open Payment Platform + # + # The Open Payment Platform includes a powerful omni-channel transaction processing API, + # enabling you to quickly and flexibly build new applications and services on the platform. + # + # This plugin enables connectivity to the Open Payment Platform for activemerchant. + # + # For any questions or comments please contact support@payon.com + # + # == Usage + # + # gateway = ActiveMerchant::Billing::OppGateway.new( + # user_id: 'merchant user id', + # password: 'password', + # entity_id: 'entity id', + # ) + # + # # set up credit card object as in main ActiveMerchant example + # creditcard = ActiveMerchant::Billing::CreditCard.new( + # :type => 'visa', + # :number => '4242424242424242', + # :month => 8, + # :year => 2009, + # :first_name => 'Bob', + # :last_name => 'Bobsen' + # :verification_value: '123') + # + # # Request: complete example, including address, billing address, shipping address + # complete_request_options = { + # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId + # merchant_transaction_id: "your merchant/shop transaction id", + # address: address, + # description: 'Store Purchase - Books', + # risk_workflow: false, + # test_mode: 'EXTERNAL' # or 'INTERNAL', valid only for test system + # create_registration: false, # payment details will be stored on the server an latter can be referenced + # + # billing_address: { + # address1: '123 Test Street', + # city: 'Test', + # state: 'TE', + # zip: 'AB12CD', + # country: 'GB', + # }, + # shipping_address: { + # name: 'Muton DeMicelis', + # address1: 'My Street On Upiter, Apt 3.14/2.78', + # city: 'Munich', + # state: 'Bov', + # zip: '81675', + # country: 'DE', + # }, + # customer: { + # merchant_customer_id: "your merchant/customer id", + # givenname: 'Jane', + # surname: 'Jones', + # birth_date: '1965-05-01', + # phone: '(?!?)555-5555', + # mobile: '(?!?)234-23423', + # email: 'jane@jones.com', + # company_name: 'JJ Ltd.', + # identification_doctype: 'PASSPORT', + # identification_docid: 'FakeID2342431234123', + # ip: 101.102.103.104, + # }, + # } + # + # # Request: minimal example + # minimal_request_options = { + # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId + # description: 'Store Purchase - Books', + # } + # + # options = + # # run request + # response = gateway.purchase(754, creditcard, options) # charge 7,54 EUR + # + # response.success? # Check whether the transaction was successful + # response.error_code # Retrieve the error message - it's mapped to Gateway::STANDARD_ERROR_CODE + # response.message # Retrieve the message returned by opp + # response.authorization # Retrieve the unique transaction ID returned by opp + # response.params['result']['code'] # Retrieve original return code returned by opp server + # + # == Errors + # If transaction is not successful, response.error_code contains mapped to Gateway::STANDARD_ERROR_CODE error message. + # Complete list of opp error codes can be viewed on https://docs.oppwa.com/ + # Because this list is much bigger than Gateway::STANDARD_ERROR_CODE, only fraction is mapped to Gateway::STANDARD_ERROR_CODE. + # All other codes are mapped as Gateway::STANDARD_ERROR_CODE[:processing_error], so if this is the case, + # you may check the original result code from OPP that can be found in response.params['result']['code'] + # + # == Special features + # For purchase method risk check can be forced when options[:risk_workflow] = true + # This will split (on OPP server side) the transaction into two separate transactions: authorize and capture, + # but capture will be executed only if risk checks are successful. + # + # For testing you may use the test account details listed fixtures.yml under opp. It is important to note that there are two test modes available: + # options[:test_mode]='EXTERNAL' causes test transactions to be forwarded to the processor's test system for 'end-to-end' testing + # options[:test_mode]='INTERNAL' causes transactions to be sent to opp simulators, which is useful when switching to the live endpoint for connectivity testing. + # If no test_mode parameter is sent, test_mode=INTERNAL is the default behaviour. + # + # Billing Address, Shipping Address, Custom Parameters are supported as described under https://docs.oppwa.com/parameters + # See complete example above for details. + # + # == Tokenization + # When create_registration is set to true, the payment details will be stored and a token will be returned in registrationId response field, + # which can subsequently be used to reference the stored payment. self.test_url = 'https://test.oppwa.com/v1/payments' self.live_url = 'https://oppwa.com/v1/payments' diff --git a/lib/active_merchant/billing/gateways/payflow_express.rb b/lib/active_merchant/billing/gateways/payflow_express.rb index 4a967812181..a5061c6a931 100644 --- a/lib/active_merchant/billing/gateways/payflow_express.rb +++ b/lib/active_merchant/billing/gateways/payflow_express.rb @@ -4,59 +4,59 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: - # ==General Parameters - # The following parameters are supported for #setup_authorization, #setup_purchase, #authorize and #purchase transactions. I've read - # in the docs that they recommend you pass the exact same parameters to both setup and authorize/purchase. - # - # This information was gleaned from a mix of: - # * {PayFlow documentation}[https://developer.paypal.com/docs/classic/payflow/integration-guide/] - # * previous ActiveMerchant code - # * trial & error - # - # The following parameters are currently supported. - # [<tt>:ip</tt>] (opt) Customer IP Address - # [<tt>:order_id</tt>] (opt) An order or invoice number. This will be passed through to the Payflow backend at manager.paypal.com, and show up as "Supplier Reference #" - # [<tt>:description</tt>] (opt) Order description, shown to buyer (after redirected to PayPal). If Order Line Items are used (see below), then the description is suppressed. This will not be passed through to the Payflow backend. - # [<tt>:billing_address</tt>] (opt) See ActiveMerchant::Billing::Gateway for details - # [<tt>:shipping_address</tt>] (opt) See ActiveMerchant::Billing::Gateway for details - # [<tt>:currency</tt>] (req) Currency of transaction, will be set to USD by default for PayFlow Express if not specified - # [<tt>:email</tt>] (opt) Email of buyer; used to pre-fill PayPal login screen - # [<tt>:payer_id</tt>] (opt) Unique PayPal buyer account identification number, as returned by details_for request - # [<tt>:token</tt>] (req for #authorize & #purchase) Token returned by setup transaction - # [<tt>:no_shipping</tt>] (opt) Boolean for whether or not to display shipping address to buyer - # [<tt>:address_override</tt>] (opt) Boolean. If true, display shipping address passed by parameters, rather than shipping address on file with PayPal - # [<tt>:allow_note</tt>] (opt) Boolean for permitting buyer to add note during checkout. Note contents can be retrieved with details_for transaction - # [<tt>:return_url</tt>] (req) URL to which the buyer’s browser is returned after choosing to pay. - # [<tt>:cancel_return_url</tt>] (req) URL to which the buyer is returned if the buyer cancels the order. - # [<tt>:notify_url</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. - # [<tt>:comment</tt>] (opt) Comment field which will be reported to Payflow backend (at manager.paypal.com) as Comment1 - # [<tt>:comment2</tt>] (opt) Comment field which will be reported to Payflow backend (at manager.paypal.com) as Comment2 - # [<tt>:discount</tt>] (opt) Total discounts in cents - # - # ==Line Items - # Support for order line items is available, but has to be enabled on the PayFlow backend. This is what I was told by Todd Sieber at Technical Support: - # - # <em>You will need to call Payflow Support at 1-888-883-9770, choose option #2. Request that they update your account in "Pandora" under Product Settings >> PayPal Mark and update the Features Bitmap to 1111111111111112. This is 15 ones and a two.</em> - # - # See here[https://www.x.com/message/206214#206214] for the forum discussion (requires login to {x.com}[https://x.com] - # - # [<tt>:items</tt>] (opt) Array of Order Line Items hashes. These are shown to the buyer after redirect to PayPal. - # - # - # - # The following keys are supported for line items: - # [<tt>:name</tt>] Name of line item - # [<tt>:description</tt>] Description of line item - # [<tt>:amount</tt>] Line Item Amount in Cents (as Integer) - # [<tt>:quantity</tt>] Line Item Quantity (default to 1 if left blank) - # - # ====Customization of Payment Page - # [<tt>:page_style</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. - # [<tt>:header_image</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. - # [<tt>:background_color</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. - # ====Additional options for old Checkout Experience, being phased out in 2010 and 2011 - # [<tt>:header_background_color</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. - # [<tt>:header_border_color</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. + # ==General Parameters + # The following parameters are supported for #setup_authorization, #setup_purchase, #authorize and #purchase transactions. I've read + # in the docs that they recommend you pass the exact same parameters to both setup and authorize/purchase. + # + # This information was gleaned from a mix of: + # * {PayFlow documentation}[https://developer.paypal.com/docs/classic/payflow/integration-guide/] + # * previous ActiveMerchant code + # * trial & error + # + # The following parameters are currently supported. + # [<tt>:ip</tt>] (opt) Customer IP Address + # [<tt>:order_id</tt>] (opt) An order or invoice number. This will be passed through to the Payflow backend at manager.paypal.com, and show up as "Supplier Reference #" + # [<tt>:description</tt>] (opt) Order description, shown to buyer (after redirected to PayPal). If Order Line Items are used (see below), then the description is suppressed. This will not be passed through to the Payflow backend. + # [<tt>:billing_address</tt>] (opt) See ActiveMerchant::Billing::Gateway for details + # [<tt>:shipping_address</tt>] (opt) See ActiveMerchant::Billing::Gateway for details + # [<tt>:currency</tt>] (req) Currency of transaction, will be set to USD by default for PayFlow Express if not specified + # [<tt>:email</tt>] (opt) Email of buyer; used to pre-fill PayPal login screen + # [<tt>:payer_id</tt>] (opt) Unique PayPal buyer account identification number, as returned by details_for request + # [<tt>:token</tt>] (req for #authorize & #purchase) Token returned by setup transaction + # [<tt>:no_shipping</tt>] (opt) Boolean for whether or not to display shipping address to buyer + # [<tt>:address_override</tt>] (opt) Boolean. If true, display shipping address passed by parameters, rather than shipping address on file with PayPal + # [<tt>:allow_note</tt>] (opt) Boolean for permitting buyer to add note during checkout. Note contents can be retrieved with details_for transaction + # [<tt>:return_url</tt>] (req) URL to which the buyer’s browser is returned after choosing to pay. + # [<tt>:cancel_return_url</tt>] (req) URL to which the buyer is returned if the buyer cancels the order. + # [<tt>:notify_url</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. + # [<tt>:comment</tt>] (opt) Comment field which will be reported to Payflow backend (at manager.paypal.com) as Comment1 + # [<tt>:comment2</tt>] (opt) Comment field which will be reported to Payflow backend (at manager.paypal.com) as Comment2 + # [<tt>:discount</tt>] (opt) Total discounts in cents + # + # ==Line Items + # Support for order line items is available, but has to be enabled on the PayFlow backend. This is what I was told by Todd Sieber at Technical Support: + # + # <em>You will need to call Payflow Support at 1-888-883-9770, choose option #2. Request that they update your account in "Pandora" under Product Settings >> PayPal Mark and update the Features Bitmap to 1111111111111112. This is 15 ones and a two.</em> + # + # See here[https://www.x.com/message/206214#206214] for the forum discussion (requires login to {x.com}[https://x.com] + # + # [<tt>:items</tt>] (opt) Array of Order Line Items hashes. These are shown to the buyer after redirect to PayPal. + # + # + # + # The following keys are supported for line items: + # [<tt>:name</tt>] Name of line item + # [<tt>:description</tt>] Description of line item + # [<tt>:amount</tt>] Line Item Amount in Cents (as Integer) + # [<tt>:quantity</tt>] Line Item Quantity (default to 1 if left blank) + # + # ====Customization of Payment Page + # [<tt>:page_style</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. + # [<tt>:header_image</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. + # [<tt>:background_color</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. + # ====Additional options for old Checkout Experience, being phased out in 2010 and 2011 + # [<tt>:header_background_color</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. + # [<tt>:header_border_color</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. class PayflowExpressGateway < Gateway diff --git a/test/remote/gateways/remote_itransact_test.rb b/test/remote/gateways/remote_itransact_test.rb index 3ec0172e6b8..6456398e292 100644 --- a/test/remote/gateways/remote_itransact_test.rb +++ b/test/remote/gateways/remote_itransact_test.rb @@ -23,14 +23,14 @@ def test_successful_purchase assert_nil response.message end -# As of March 8, 2012, iTransact does not provide a way to generate unsuccessful transactions through use of a -# production gateway account in test mode. -# def test_unsuccessful_purchase -# assert response = @gateway.purchase(@amount, @credit_card, @options) -# assert_failure response -# assert_equal 'DECLINE', response.params['error_category'] -# assert_equal 'Code: NBE001 Your credit card was declined by the credit card processing network. Please use another card and resubmit your transaction.', response.message -# end + # As of March 8, 2012, iTransact does not provide a way to generate unsuccessful transactions through use of a + # production gateway account in test mode. + # def test_unsuccessful_purchase + # assert response = @gateway.purchase(@amount, @credit_card, @options) + # assert_failure response + # assert_equal 'DECLINE', response.params['error_category'] + # assert_equal 'Code: NBE001 Your credit card was declined by the credit card processing network. Please use another card and resubmit your transaction.', response.message + # end def test_authorize_and_capture amount = @amount @@ -42,13 +42,13 @@ def test_authorize_and_capture assert_success capture end -# As of March 8, 2012, iTransact does not provide a way to generate unsuccessful transactions through use of a -# production gateway account in test mode. -# def test_failed_capture -# assert response = @gateway.capture(@amount, '9999999999') -# assert_failure response -# assert_equal 'REPLACE WITH GATEWAY FAILURE MESSAGE', response.message -# end + # As of March 8, 2012, iTransact does not provide a way to generate unsuccessful transactions through use of a + # production gateway account in test mode. + # def test_failed_capture + # assert response = @gateway.capture(@amount, '9999999999') + # assert_failure response + # assert_equal 'REPLACE WITH GATEWAY FAILURE MESSAGE', response.message + # end def test_authorize_and_void amount = @amount @@ -65,11 +65,11 @@ def test_void assert_success void end -# As of Sep 19, 2012, iTransact REQUIRES the total amount for the refund. -# def test_refund -# assert refund = @gateway.refund(nil, '9999999999') -# assert_success refund -# end + # As of Sep 19, 2012, iTransact REQUIRES the total amount for the refund. + # def test_refund + # assert refund = @gateway.refund(nil, '9999999999') + # assert_success refund + # end def test_refund_partial assert refund = @gateway.refund(555, '9999999999') # $5.55 in cents diff --git a/test/remote/gateways/remote_opp_test.rb b/test/remote/gateways/remote_opp_test.rb index 2652c756ad4..8dbdd9d3970 100644 --- a/test/remote/gateways/remote_opp_test.rb +++ b/test/remote/gateways/remote_opp_test.rb @@ -18,8 +18,8 @@ def setup merchant_transaction_id: "active_merchant_test_complete #{time}", address: address, description: 'Store Purchase - Books', -# riskWorkflow: true, -# testMode: 'EXTERNAL' # or 'INTERNAL', valid only for test system + # riskWorkflow: true, + # testMode: 'EXTERNAL' # or 'INTERNAL', valid only for test system billing_address: { address1: '123 Test Street', @@ -67,7 +67,7 @@ def setup @options = @complete_request_options if request_type == 'complete' end -# ****************************************** SUCCESSFUL TESTS ****************************************** + # ****************************************** SUCCESSFUL TESTS ****************************************** def test_successful_purchase @options[:description] = __method__ @@ -162,7 +162,7 @@ def test_successful_verify assert_match %r{Request successfully processed}, response.message end -# ****************************************** FAILURE TESTS ****************************************** + # ****************************************** FAILURE TESTS ****************************************** def test_failed_purchase @options[:description] = __method__ @@ -199,7 +199,7 @@ def test_failed_void assert_match %r{reversal needs at least one successful transaction}, response.message end -# ************************************** TRANSCRIPT SCRUB ****************************************** + # ************************************** TRANSCRIPT SCRUB ****************************************** def test_transcript_scrubbing assert @gateway.supports_scrubbing? diff --git a/test/remote/gateways/remote_paypal_test.rb b/test/remote/gateways/remote_paypal_test.rb index 0e07e911d9f..44ef35493fb 100644 --- a/test/remote/gateways/remote_paypal_test.rb +++ b/test/remote/gateways/remote_paypal_test.rb @@ -194,7 +194,7 @@ def test_successful_transfer end def test_failed_transfer - # paypal allows a max transfer of $10,000 + # paypal allows a max transfer of $10,000 response = @gateway.transfer(1000001, 'joe@example.com') assert_failure response end diff --git a/test/remote/gateways/remote_world_net_test.rb b/test/remote/gateways/remote_world_net_test.rb index ece5f935926..14986a28487 100644 --- a/test/remote/gateways/remote_world_net_test.rb +++ b/test/remote/gateways/remote_world_net_test.rb @@ -110,9 +110,9 @@ def test_successful_void assert_success auth assert void = @gateway.void(auth.authorization) - # UNSUPPORTED - # assert_success void - # assert_equal 'REPLACE WITH SUCCESSFUL VOID MESSAGE', response.message + # UNSUPPORTED + # assert_success void + # assert_equal 'REPLACE WITH SUCCESSFUL VOID MESSAGE', response.message end def test_failed_void diff --git a/test/unit/gateways/eway_managed_test.rb b/test/unit/gateways/eway_managed_test.rb index 5e8c914b611..abcfa3dd6e0 100644 --- a/test/unit/gateways/eway_managed_test.rb +++ b/test/unit/gateways/eway_managed_test.rb @@ -396,7 +396,7 @@ def expected_purchase_request XML end - # Documented here: https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?op=QueryCustomer + # Documented here: https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?op=QueryCustomer def expected_retrieve_request <<-XML <?xml version="1.0" encoding="utf-8"?> diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb index e74552d7ade..5b830c28faa 100644 --- a/test/unit/gateways/opp_test.rb +++ b/test/unit/gateways/opp_test.rb @@ -18,8 +18,8 @@ def setup merchant_transaction_id: "active_merchant_test_complete #{time}", address: address, description: 'Store Purchase - Books', -# risk_workflow: true, -# test_mode: 'EXTERNAL' # or 'INTERNAL', valid only for test system + # risk_workflow: true, + # test_mode: 'EXTERNAL' # or 'INTERNAL', valid only for test system billing_address: { name: 'Billy Billing', @@ -67,7 +67,7 @@ def setup @options = @complete_request_options if request_type == 'complete' end -# ****************************************** SUCCESSFUL TESTS ****************************************** + # ****************************************** SUCCESSFUL TESTS ****************************************** def test_successful_purchase @gateway.expects(:raw_ssl_request).returns(successful_response('DB', @test_success_id)) response = @gateway.purchase(@amount, @valid_card, @options) @@ -121,7 +121,7 @@ def test_successful_void assert void.test? end -# ****************************************** FAILURE TESTS ****************************************** + # ****************************************** FAILURE TESTS ****************************************** def test_failed_purchase @gateway.expects(:raw_ssl_request).returns(failed_response('DB', @test_failure_id)) response = @gateway.purchase(@amount, @invalid_card, @options) From c8a8d954ab72c13e94efc601b868568ca06b51bf Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 6 Sep 2018 17:00:43 -0400 Subject: [PATCH 534/677] Decide CC brand by lambda, not regex Previously, we were using pure regexes to determine a credit card brand based on its BIN. The problem is that you can't reliably determine BINs based on regexes: Maestro overlaps with MasterCard, Electron just has a pile of buckets, and so on. As a first step, remove any reliance on raw regexes, and instead switch to using lambdas. For now, this is functionally equivalent, but will allow more precise brand determination in a follow-up commit. Unit: 3927 tests, 68196 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/credit_card.rb | 2 +- .../billing/credit_card_methods.rb | 52 ++++++++++--------- .../billing/gateways/inspire.rb | 2 +- .../billing/gateways/smart_ps.rb | 2 +- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb index 5a808b6b5b5..caf0903cdf2 100644 --- a/lib/active_merchant/billing/credit_card.rb +++ b/lib/active_merchant/billing/credit_card.rb @@ -350,7 +350,7 @@ def validate_card_brand_and_number #:nodoc: errors = [] if !empty?(brand) - errors << [:brand, 'is invalid'] if !CreditCard.card_companies.keys.include?(brand) + errors << [:brand, 'is invalid'] if !CreditCard.card_companies.include?(brand) end if empty?(number) diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb index e61ee859070..4498e68f05e 100644 --- a/lib/active_merchant/billing/credit_card_methods.rb +++ b/lib/active_merchant/billing/credit_card_methods.rb @@ -2,21 +2,21 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: # Convenience methods that can be included into a custom Credit Card object, such as an ActiveRecord based Credit Card object. module CreditCardMethods - CARD_COMPANIES = { - 'visa' => /^4\d{12}(\d{3})?(\d{3})?$/, - 'master' => /^(5[1-5]\d{4}|677189|222[1-9]\d{2}|22[3-9]\d{3}|2[3-6]\d{4}|27[01]\d{3}|2720\d{2})\d{10}$/, - 'discover' => /^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/, - 'american_express' => /^3[47]\d{13}$/, - 'diners_club' => /^3(0[0-5]|[68]\d)\d{11}$/, - 'jcb' => /^35(28|29|[3-8]\d)\d{12}$/, - 'switch' => /^6759\d{12}(\d{2,3})?$/, - 'solo' => /^6767\d{12}(\d{2,3})?$/, - 'dankort' => /^5019\d{12}$/, - 'maestro' => /^(5[06-8]|6\d)\d{10,17}$/, - 'forbrugsforeningen' => /^600722\d{10}$/, - 'laser' => /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/, - 'sodexo' => /^(606071|603389|606070|606069|606068|600818)\d{8}$/, - 'vr' => /^(627416|637036)\d{8}$/ + CARD_COMPANY_DETECTORS = { + 'visa' => ->(num) { num =~ /^4\d{12}(\d{3})?(\d{3})?$/ }, + 'master' => ->(num) { num =~ /^(5[1-5]\d{4}|677189|222[1-9]\d{2}|22[3-9]\d{3}|2[3-6]\d{4}|27[01]\d{3}|2720\d{2})\d{10}$/ }, + 'discover' => ->(num) { num =~ /^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/ }, + 'american_express' => ->(num) { num =~ /^3[47]\d{13}$/ }, + 'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ }, + 'jcb' => ->(num) { num =~ /^35(28|29|[3-8]\d)\d{12}$/ }, + 'switch' => ->(num) { num =~ /^6759\d{12}(\d{2,3})?$/ }, + 'solo' => ->(num) { num =~ /^6767\d{12}(\d{2,3})?$/ }, + 'dankort' => ->(num) { num =~ /^5019\d{12}$/ }, + 'maestro' => ->(num) { num =~ /^(5[06-8]|6\d)\d{10,17}$/ }, + 'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ }, + 'laser' => ->(num) { num =~ /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/ }, + 'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ }, + 'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ } } # http://www.barclaycard.co.uk/business/files/bin_rules.pdf @@ -77,7 +77,14 @@ def valid_card_verification_value?(cvv, brand) end def card_verification_value_length(brand) - brand == 'american_express' ? 4 : 3 + case brand + when 'american_express' + 4 + when 'maestro' + 0 + else + 3 + end end def valid_issue_number?(number) @@ -103,13 +110,8 @@ def valid_number?(number) valid_checksum?(number) end - # Regular expressions for the known card companies. - # - # References: - # - http://en.wikipedia.org/wiki/Credit_card_number - # - http://www.barclaycardbusiness.co.uk/information_zone/processing/bin_rules.html def card_companies - CARD_COMPANIES + CARD_COMPANY_DETECTORS.keys end # Returns a string containing the brand of card from the list of known information below. @@ -128,11 +130,11 @@ def card_companies def brand?(number) return 'bogus' if valid_test_mode_card_number?(number) - card_companies.reject { |c,p| c == 'maestro' }.each do |company, pattern| - return company.dup if number =~ pattern + CARD_COMPANY_DETECTORS.reject { |c, f| c == 'maestro' }.each do |company, func| + return company.dup if func.call(number) end - return 'maestro' if number =~ card_companies['maestro'] + return 'maestro' if CARD_COMPANY_DETECTORS['maestro'].call(number) return nil end diff --git a/lib/active_merchant/billing/gateways/inspire.rb b/lib/active_merchant/billing/gateways/inspire.rb index 52122d4d0b6..6c9fae8e265 100644 --- a/lib/active_merchant/billing/gateways/inspire.rb +++ b/lib/active_merchant/billing/gateways/inspire.rb @@ -208,7 +208,7 @@ def post_data(action, parameters = {}) def determine_funding_source(source) case when source.is_a?(String) then :vault - when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card + when CreditCard.card_companies.include?(card_brand(source)) then :credit_card when card_brand(source) == 'check' then :check else raise ArgumentError, 'Unsupported funding source provided' end diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb index 2b572aaa9d5..b95c4d685e7 100644 --- a/lib/active_merchant/billing/gateways/smart_ps.rb +++ b/lib/active_merchant/billing/gateways/smart_ps.rb @@ -272,7 +272,7 @@ def post_data(action, parameters = {}) def determine_funding_source(source) case when source.is_a?(String) then :vault - when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card + when CreditCard.card_companies.include?(card_brand(source)) then :credit_card when card_brand(source) == 'check' then :check else raise ArgumentError, 'Unsupported funding source provided' end From 7d1adde3f773382265c21c42f60a15b4e6ba01a6 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 7 Sep 2018 09:37:25 -0400 Subject: [PATCH 535/677] Remove support for Laser Laser has been shuttered since 2014, and its BIN ranges overlap with mdoern Maestro and MasterCard ranges. In prep for fixing up those ranges, remove support for Laser entirely. --- lib/active_merchant/billing/credit_card.rb | 2 -- .../billing/credit_card_methods.rb | 1 - .../billing/gateways/citrus_pay.rb | 2 +- .../billing/gateways/data_cash.rb | 2 +- .../billing/gateways/realex.rb | 3 +- lib/active_merchant/billing/gateways/tns.rb | 2 +- .../billing/gateways/worldpay.rb | 3 +- .../gateways/worldpay_online_payments.rb | 2 +- test/unit/credit_card_methods_test.rb | 29 ------------------- test/unit/gateways/data_cash_test.rb | 2 +- test/unit/gateways/realex_test.rb | 2 +- 11 files changed, 8 insertions(+), 42 deletions(-) diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb index caf0903cdf2..bfbd7875b16 100644 --- a/lib/active_merchant/billing/credit_card.rb +++ b/lib/active_merchant/billing/credit_card.rb @@ -20,7 +20,6 @@ module Billing #:nodoc: # * Dankort # * Maestro # * Forbrugsforeningen - # * Laser # # For testing purposes, use the 'bogus' credit card brand. This skips the vast majority of # validations, allowing you to focus on your core concerns until you're ready to be more concerned @@ -93,7 +92,6 @@ def number=(value) # * +'dankort'+ # * +'maestro'+ # * +'forbrugsforeningen'+ - # * +'laser'+ # # Or, if you wish to test your implementation, +'bogus'+. # diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb index 4498e68f05e..5ea809ee412 100644 --- a/lib/active_merchant/billing/credit_card_methods.rb +++ b/lib/active_merchant/billing/credit_card_methods.rb @@ -14,7 +14,6 @@ module CreditCardMethods 'dankort' => ->(num) { num =~ /^5019\d{12}$/ }, 'maestro' => ->(num) { num =~ /^(5[06-8]|6\d)\d{10,17}$/ }, 'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ }, - 'laser' => ->(num) { num =~ /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/ }, 'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ }, 'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ } } diff --git a/lib/active_merchant/billing/gateways/citrus_pay.rb b/lib/active_merchant/billing/gateways/citrus_pay.rb index f8661e23e1d..3b12c5deaf6 100644 --- a/lib/active_merchant/billing/gateways/citrus_pay.rb +++ b/lib/active_merchant/billing/gateways/citrus_pay.rb @@ -15,7 +15,7 @@ class CitrusPayGateway < Gateway self.homepage_url = 'http://www.citruspay.com/' self.supported_countries = %w(AR AU BR FR DE HK MX NZ SG GB US) self.default_currency = 'USD' - self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :laser] + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro] end end diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb index 5c628a1343a..307495c1f3a 100644 --- a/lib/active_merchant/billing/gateways/data_cash.rb +++ b/lib/active_merchant/billing/gateways/data_cash.rb @@ -6,7 +6,7 @@ class DataCashGateway < Gateway self.default_currency = 'GBP' self.supported_countries = ['GB'] - self.supported_cardtypes = [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo, :laser ] + self.supported_cardtypes = [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo ] self.homepage_url = 'http://www.datacash.com/' self.display_name = 'DataCash' diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index feec62cb5b1..31ad1aee6d3 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -28,13 +28,12 @@ class RealexGateway < Gateway 'diners_club' => 'DINERS', 'switch' => 'SWITCH', 'solo' => 'SWITCH', - 'laser' => 'LASER', 'maestro' => 'MC' } self.money_format = :cents self.default_currency = 'EUR' - self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ] + self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :switch, :solo ] self.supported_countries = %w(IE GB FR BE NL LU IT US CA ES) self.homepage_url = 'http://www.realexpayments.com/' self.display_name = 'Realex' diff --git a/lib/active_merchant/billing/gateways/tns.rb b/lib/active_merchant/billing/gateways/tns.rb index 0aa15904050..25ed79306a9 100644 --- a/lib/active_merchant/billing/gateways/tns.rb +++ b/lib/active_merchant/billing/gateways/tns.rb @@ -15,7 +15,7 @@ class TnsGateway < Gateway self.homepage_url = 'http://www.tnsi.com/' self.supported_countries = %w(AR AU BR FR DE HK MX NZ SG GB US) self.default_currency = 'USD' - self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :laser] + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro] end end diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index 10ea603a8ff..2fe80cf9691 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -7,7 +7,7 @@ class WorldpayGateway < Gateway self.default_currency = 'GBP' self.money_format = :cents self.supported_countries = %w(HK GB AU AD AR BE BR CA CH CN CO CR CY CZ DE DK ES FI FR GI GR HU IE IN IT JP LI LU MC MT MY MX NL NO NZ PA PE PL PT SE SG SI SM TR UM VA) - self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :laser, :switch] + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :switch] self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW) self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND) self.homepage_url = 'http://www.worldpay.com/' @@ -20,7 +20,6 @@ class WorldpayGateway < Gateway 'american_express' => 'AMEX-SSL', 'jcb' => 'JCB-SSL', 'maestro' => 'MAESTRO-SSL', - 'laser' => 'LASER-SSL', 'diners_club' => 'DINERS-SSL', 'switch' => 'MAESTRO-SSL' } diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb index a4a61f1483b..af7b2bd7aec 100644 --- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb @@ -8,7 +8,7 @@ class WorldpayOnlinePaymentsGateway < Gateway self.money_format = :cents self.supported_countries = %w(HK US GB BE CH CZ DE DK ES FI FR GR HU IE IT LU MT NL NO PL PT SE SG TR) - self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :laser, :switch] + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :switch] self.homepage_url = 'http://online.worldpay.com' self.display_name = 'Worldpay Online Payments' diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb index 0854a059065..03dc41f78f2 100644 --- a/test/unit/credit_card_methods_test.rb +++ b/test/unit/credit_card_methods_test.rb @@ -125,35 +125,6 @@ def test_should_detect_forbrugsforeningen assert_equal 'forbrugsforeningen', CreditCard.brand?('6007221000000000') end - def test_should_detect_laser_card - # 16 digits - assert_equal 'laser', CreditCard.brand?('6304985028090561') - - # 18 digits - assert_equal 'laser', CreditCard.brand?('630498502809056151') - - # 19 digits - assert_equal 'laser', CreditCard.brand?('6304985028090561515') - - # 17 digits - assert_not_equal 'laser', CreditCard.brand?('63049850280905615') - - # 15 digits - assert_not_equal 'laser', CreditCard.brand?('630498502809056') - - # Alternate format - assert_equal 'laser', CreditCard.brand?('6706950000000000000') - - # Alternate format (16 digits) - assert_equal 'laser', CreditCard.brand?('6706123456789012') - - # New format (16 digits) - assert_equal 'laser', CreditCard.brand?('6709123456789012') - - # Ulster bank (Ireland) with 12 digits - assert_equal 'laser', CreditCard.brand?('677117111234') - end - def test_should_detect_sodexo_card assert_equal 'sodexo', CreditCard.brand?('60606944957644') end diff --git a/test/unit/gateways/data_cash_test.rb b/test/unit/gateways/data_cash_test.rb index 58049ea6724..d5f31a3079d 100644 --- a/test/unit/gateways/data_cash_test.rb +++ b/test/unit/gateways/data_cash_test.rb @@ -83,7 +83,7 @@ def test_supported_countries end def test_supported_card_types - assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo, :laser ], DataCashGateway.supported_cardtypes + assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo ], DataCashGateway.supported_cardtypes end def test_purchase_with_missing_order_id_option diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb index 4830137b271..5671331fc0d 100644 --- a/test/unit/gateways/realex_test.rb +++ b/test/unit/gateways/realex_test.rb @@ -99,7 +99,7 @@ def test_supported_countries end def test_supported_card_types - assert_equal [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ], RealexGateway.supported_cardtypes + assert_equal [ :visa, :master, :american_express, :diners_club, :switch, :solo ], RealexGateway.supported_cardtypes end def test_avs_result_not_supported From 5d9291cb226a82543afa73f349ad9e078438b923 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 7 Sep 2018 09:40:41 -0400 Subject: [PATCH 536/677] Fix Maestro and MasterCard detection There are two pieces to this. First, some of the old Maestro range is simply wrong at this point (the 50 BIN appears dead), so remove tests for those ranges and alter the detection not to pick them up. Secondly, as continuing prep for adding new card types and handling BIN detection better, convert both MasterCard and Maestro over to proper range detection, rather than some overly exciting regexes. Source: https://www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 73. Unit: 3926 tests, 68184 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- .../billing/credit_card_methods.rb | 41 +++++++++++-------- test/unit/credit_card_methods_test.rb | 13 +++--- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb index 5ea809ee412..10878af0395 100644 --- a/lib/active_merchant/billing/credit_card_methods.rb +++ b/lib/active_merchant/billing/credit_card_methods.rb @@ -4,7 +4,7 @@ module Billing #:nodoc: module CreditCardMethods CARD_COMPANY_DETECTORS = { 'visa' => ->(num) { num =~ /^4\d{12}(\d{3})?(\d{3})?$/ }, - 'master' => ->(num) { num =~ /^(5[1-5]\d{4}|677189|222[1-9]\d{2}|22[3-9]\d{3}|2[3-6]\d{4}|27[01]\d{3}|2720\d{2})\d{10}$/ }, + 'master' => ->(num) { num.to_s.size == 16 && in_bin_range?(num.to_s.slice(0, 6), MASTERCARD_RANGES) }, 'discover' => ->(num) { num =~ /^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/ }, 'american_express' => ->(num) { num =~ /^3[47]\d{13}$/ }, 'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ }, @@ -12,7 +12,7 @@ module CreditCardMethods 'switch' => ->(num) { num =~ /^6759\d{12}(\d{2,3})?$/ }, 'solo' => ->(num) { num =~ /^6767\d{12}(\d{2,3})?$/ }, 'dankort' => ->(num) { num =~ /^5019\d{12}$/ }, - 'maestro' => ->(num) { num =~ /^(5[06-8]|6\d)\d{10,17}$/ }, + 'maestro' => ->(num) { (12..19).include?(num.to_s.size) && in_bin_range?(num.to_s.slice(0, 6), MAESTRO_RANGES) }, 'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ }, 'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ }, 'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ } @@ -38,12 +38,31 @@ module CreditCardMethods (491730..491759), ] + # https://www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 73 + MASTERCARD_RANGES = [ + (222100..272099), + (510000..559999), + ] + + # https://www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 73 + MAESTRO_RANGES = [ + (639000..639099), + (670000..679999), + ] + def self.included(base) base.extend(ClassMethods) end + def self.in_bin_range?(number, ranges) + bin = number.to_i + ranges.any? do |range| + range.cover?(bin) + end + end + def valid_month?(month) - (1..12).include?(month.to_i) + (1..12).cover?(month.to_i) end def credit_card? @@ -114,27 +133,13 @@ def card_companies end # Returns a string containing the brand of card from the list of known information below. - # Need to check the cards in a particular order, as there is some overlap of the allowable ranges - #-- - # TODO Refactor this method. We basically need to tighten up the Maestro Regexp. - # - # Right now the Maestro regexp overlaps with the MasterCard regexp (IIRC). If we can tighten - # things up, we can boil this whole thing down to something like... - # - # def brand?(number) - # return 'visa' if valid_test_mode_card_number?(number) - # card_companies.find([nil]) { |brand, regexp| number =~ regexp }.first.dup - # end - # def brand?(number) return 'bogus' if valid_test_mode_card_number?(number) - CARD_COMPANY_DETECTORS.reject { |c, f| c == 'maestro' }.each do |company, func| + CARD_COMPANY_DETECTORS.each do |company, func| return company.dup if func.call(number) end - return 'maestro' if CARD_COMPANY_DETECTORS['maestro'].call(number) - return nil end diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb index 03dc41f78f2..52ace9f1e9c 100644 --- a/test/unit/credit_card_methods_test.rb +++ b/test/unit/credit_card_methods_test.rb @@ -9,9 +9,8 @@ class CreditCard def maestro_card_numbers %w[ - 5000000000000000 5099999999999999 5600000000000000 - 5899999999999999 6000000000000000 6999999999999999 - 6761999999999999 6763000000000000 5038999999999999 + 6390000000000000 6390700000000000 6390990000000000 + 6761999999999999 6763000000000000 6799999999999999 ] end @@ -110,14 +109,14 @@ def test_should_detect_maestro_dk_as_maestro end def test_should_detect_maestro_cards - assert_equal 'maestro', CreditCard.brand?('5020100000000000') + assert_equal 'maestro', CreditCard.brand?('675675000000000') maestro_card_numbers.each { |number| assert_equal 'maestro', CreditCard.brand?(number) } non_maestro_card_numbers.each { |number| assert_not_equal 'maestro', CreditCard.brand?(number) } end def test_should_detect_mastercard - assert_equal 'master', CreditCard.brand?('6771890000000000') + assert_equal 'master', CreditCard.brand?('2720890000000000') assert_equal 'master', CreditCard.brand?('5413031000000000') end @@ -139,14 +138,14 @@ def test_should_detect_when_an_argument_brand_does_not_match_calculated_brand end def test_detecting_full_range_of_maestro_card_numbers - maestro = '50000000000' + maestro = '63900000000' assert_equal 11, maestro.length assert_not_equal 'maestro', CreditCard.brand?(maestro) while maestro.length < 19 maestro << '0' - assert_equal 'maestro', CreditCard.brand?(maestro) + assert_equal 'maestro', CreditCard.brand?(maestro), "Failed for bin #{maestro}" end assert_equal 19, maestro.length From b4cff8afbf243bca012e6223cc9e9bebaa36ca14 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 17 Sep 2018 10:22:01 -0400 Subject: [PATCH 537/677] Add CHANGELOGs for new credit card behavior --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index db43b145c8c..9dcf9eb4e7b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,9 @@ * FirstPay: Expose error code [curiousepic] #2979 * Barclaycard Smartpay: Pass device_fingerprint when specified [dtykocki] #2981 * Komoju: remove no-longer-relevant sandbox URL [miyazawadegica] #2987 +* [POSSIBLE BREAKAGE] Determine credit cards via functions [bpollack] #2983 +* Drop support for Laser cards [bpollack] #2983 +* Improve Maestro card detection [bpollack] #2983 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 From 26f1fe5e65c383e6962e2eae4008ee9873b6490a Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Mon, 17 Sep 2018 11:43:49 -0400 Subject: [PATCH 538/677] Add ROU alpha3 code for Romania --- CHANGELOG | 1 + lib/active_merchant/country.rb | 1 + test/unit/country_test.rb | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 9dcf9eb4e7b..8673884f165 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * [POSSIBLE BREAKAGE] Determine credit cards via functions [bpollack] #2983 * Drop support for Laser cards [bpollack] #2983 * Improve Maestro card detection [bpollack] #2983 +* Add ROU alpha3 code for Romania [dtykocki] #2989 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 diff --git a/lib/active_merchant/country.rb b/lib/active_merchant/country.rb index 46349e63123..82c333fef74 100644 --- a/lib/active_merchant/country.rb +++ b/lib/active_merchant/country.rb @@ -246,6 +246,7 @@ def to_s { alpha2: 'QA', name: 'Qatar', alpha3: 'QAT', numeric: '634' }, { alpha2: 'RE', name: 'Reunion', alpha3: 'REU', numeric: '638' }, { alpha2: 'RO', name: 'Romania', alpha3: 'ROM', numeric: '642' }, + { alpha2: 'RO', name: 'Romania', alpha3: 'ROU', numeric: '642' }, { alpha2: 'RU', name: 'Russian Federation', alpha3: 'RUS', numeric: '643' }, { alpha2: 'RW', name: 'Rwanda', alpha3: 'RWA', numeric: '646' }, { alpha2: 'BL', name: 'Saint Barthélemy', alpha3: 'BLM', numeric: '652' }, diff --git a/test/unit/country_test.rb b/test/unit/country_test.rb index a48e73fa36f..3fce8ff16c5 100644 --- a/test/unit/country_test.rb +++ b/test/unit/country_test.rb @@ -59,6 +59,14 @@ def test_find_united_kingdom assert_equal 'GB', country.code(:alpha2).value end + def test_find_romania + country = ActiveMerchant::Country.find('ROM') + assert_equal 'RO', country.code(:alpha2).value + + country = ActiveMerchant::Country.find('ROU') + assert_equal 'RO', country.code(:alpha2).value + end + def test_raise_on_nil_name assert_raises(ActiveMerchant::InvalidCountryCodeError) do ActiveMerchant::Country.find(nil) From fa8b8ba5776b841c462449de3015d826beb66c9b Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 17 Sep 2018 13:35:03 -0400 Subject: [PATCH 539/677] Begin removing Solo and Switch Both Switch[1] and Solo[2] were purchased by Maestro, and haven't been issued since 2002 and 2011, respectively. That's good, because their old bin ranges overlap with Maestro's current ones (surprise). We should fully remove Solo and Switch, but some oddities about them (such as having start dates) has special handling in AM. Some gateways also run remote tests with old Switch/Solo cards. As a result, fully removing all Solo and Switch support *immediately* is counterproductive. This is the minimal amount of change required to properly handle modern Maestro cards. [1]: https://en.wikipedia.org/wiki/Switch_(debit_card) [2]: https://en.wikipedia.org/wiki/Solo_(debit_card) 3922 tests, 68171 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- .../billing/credit_card_methods.rb | 2 - test/unit/credit_card_methods_test.rb | 6 +-- test/unit/credit_card_test.rb | 54 ++----------------- 3 files changed, 8 insertions(+), 54 deletions(-) diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb index 10878af0395..75ce78d25b1 100644 --- a/lib/active_merchant/billing/credit_card_methods.rb +++ b/lib/active_merchant/billing/credit_card_methods.rb @@ -9,8 +9,6 @@ module CreditCardMethods 'american_express' => ->(num) { num =~ /^3[47]\d{13}$/ }, 'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ }, 'jcb' => ->(num) { num =~ /^35(28|29|[3-8]\d)\d{12}$/ }, - 'switch' => ->(num) { num =~ /^6759\d{12}(\d{2,3})?$/ }, - 'solo' => ->(num) { num =~ /^6767\d{12}(\d{2,3})?$/ }, 'dankort' => ->(num) { num =~ /^5019\d{12}$/ }, 'maestro' => ->(num) { (12..19).include?(num.to_s.size) && in_bin_range?(num.to_s.slice(0, 6), MAESTRO_RANGES) }, 'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ }, diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb index 52ace9f1e9c..829eb0214c2 100644 --- a/test/unit/credit_card_methods_test.rb +++ b/test/unit/credit_card_methods_test.rb @@ -172,19 +172,19 @@ def test_matching_invalid_card def test_16_digit_maestro_uk number = '6759000000000000' assert_equal 16, number.length - assert_equal 'switch', CreditCard.brand?(number) + assert_equal 'maestro', CreditCard.brand?(number) end def test_18_digit_maestro_uk number = '675900000000000000' assert_equal 18, number.length - assert_equal 'switch', CreditCard.brand?(number) + assert_equal 'maestro', CreditCard.brand?(number) end def test_19_digit_maestro_uk number = '6759000000000000000' assert_equal 19, number.length - assert_equal 'switch', CreditCard.brand?(number) + assert_equal 'maestro', CreditCard.brand?(number) end def test_electron_cards diff --git a/test/unit/credit_card_test.rb b/test/unit/credit_card_test.rb index b39600376c9..eb3c77d648b 100644 --- a/test/unit/credit_card_test.rb +++ b/test/unit/credit_card_test.rb @@ -3,8 +3,8 @@ class CreditCardTest < Test::Unit::TestCase def setup CreditCard.require_verification_value = false - @visa = credit_card('4779139500118580', :brand => 'visa') - @solo = credit_card('676700000000000000', :brand => 'solo', :issue_number => '01') + @visa = credit_card('4779139500118580', brand: 'visa') + @maestro = credit_card('676700000000000000', brand: 'maestro', verification_value: '') end def teardown @@ -32,8 +32,8 @@ def test_should_be_a_valid_visa_card assert_valid @visa end - def test_should_be_a_valid_solo_card - assert_valid @solo + def test_should_be_a_valid_maestro_card + assert_valid @maestro end def test_cards_with_empty_names_should_not_be_valid @@ -167,12 +167,6 @@ def test_expired_card_should_have_one_error_on_year assert_match(/expired/, errors[:year].first) end - def test_should_be_valid_with_start_month_and_year_as_string - @solo.start_month = '2' - @solo.start_year = '2007' - assert_valid @solo - end - def test_should_identify_wrong_card_brand c = credit_card(:brand => 'master') assert_not_valid c @@ -242,44 +236,6 @@ def test_bogus_cards_are_not_valid_without_verification_value assert_not_valid card end - def test_should_require_valid_start_date_for_solo_or_switch - @solo.start_month = nil - @solo.start_year = nil - @solo.issue_number = nil - - errors = assert_not_valid @solo - assert errors[:start_month] - assert errors[:start_year] - assert errors[:issue_number] - - @solo.start_month = 2 - @solo.start_year = 2007 - assert_valid @solo - end - - def test_should_require_a_valid_issue_number_for_solo_or_switch - @solo.start_month = nil - @solo.start_year = 2005 - @solo.issue_number = nil - - errors = assert_not_valid @solo - assert errors[:start_month] - assert_equal ['cannot be empty'], errors[:issue_number] - - @solo.issue_number = 3 - assert_valid @solo - end - - def test_should_require_a_validate_non_empty_issue_number_for_solo_or_switch - @solo.issue_number = 'invalid' - - errors = assert_not_valid @solo - assert_equal ['is invalid'], errors[:issue_number] - - @solo.issue_number = 3 - assert_valid @solo - end - def test_should_return_last_four_digits_of_card_number ccn = CreditCard.new(:number => '4779139500118580') assert_equal '8580', ccn.last_digits @@ -437,7 +393,7 @@ def test_brand_is_aliased_as_type assert_equal @visa.type, @visa.brand end assert_deprecation_warning('CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead.') do - assert_equal @solo.type, @solo.brand + assert_equal @maestro.type, @maestro.brand end end From 094c141dd15c538f423c8532229e9f602b22c6a8 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 17 Sep 2018 13:51:20 -0400 Subject: [PATCH 540/677] Remove the rest of Solo and Sripe support 3922 tests, 68169 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/credit_card.rb | 32 +------------------ .../billing/gateways/axcessms.rb | 2 +- .../billing/gateways/card_save.rb | 2 +- .../billing/gateways/card_stream.rb | 2 +- .../billing/gateways/data_cash.rb | 12 +------ lib/active_merchant/billing/gateways/dibs.rb | 4 --- .../billing/gateways/iridium.rb | 2 +- .../billing/gateways/optimal_payment.rb | 4 +-- .../gateways/payflow/payflow_common_api.rb | 2 -- .../billing/gateways/payflow_uk.rb | 2 +- .../billing/gateways/paypal.rb | 8 ----- .../billing/gateways/psl_card.rb | 4 +-- .../billing/gateways/realex.rb | 6 ++-- .../billing/gateways/sage_pay.rb | 4 +-- .../billing/gateways/so_easy_pay.rb | 2 +- lib/active_merchant/billing/gateways/telr.rb | 2 +- .../remote/gateways/remote_payflow_uk_test.rb | 20 ------------ test/unit/credit_card_test.rb | 5 --- test/unit/gateways/data_cash_test.rb | 2 +- test/unit/gateways/payflow_test.rb | 16 +--------- test/unit/gateways/payflow_uk_test.rb | 2 +- test/unit/gateways/payment_express_test.rb | 2 +- test/unit/gateways/psl_card_test.rb | 2 +- test/unit/gateways/realex_test.rb | 2 +- 25 files changed, 22 insertions(+), 120 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8673884f165..6ddf07f77f4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * Drop support for Laser cards [bpollack] #2983 * Improve Maestro card detection [bpollack] #2983 * Add ROU alpha3 code for Romania [dtykocki] #2989 +* [POSSIBLE BREAKAGE] Drop support for Solo and Switch cards [bpollack] #2991 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb index bfbd7875b16..98ca5a522cc 100644 --- a/lib/active_merchant/billing/credit_card.rb +++ b/lib/active_merchant/billing/credit_card.rb @@ -15,8 +15,6 @@ module Billing #:nodoc: # * American Express # * Diner's Club # * JCB - # * Switch - # * Solo # * Dankort # * Maestro # * Forbrugsforeningen @@ -87,8 +85,6 @@ def number=(value) # * +'american_express'+ # * +'diners_club'+ # * +'jcb'+ - # * +'switch'+ - # * +'solo'+ # * +'dankort'+ # * +'maestro'+ # * +'forbrugsforeningen'+ @@ -119,10 +115,6 @@ def brand=(value) # @return [String] attr_accessor :last_name - # Required for Switch / Solo cards - attr_reader :start_month, :start_year - attr_accessor :issue_number - # Returns or sets the card verification value. # # This attribute is optional but recommended. The verification value is @@ -301,8 +293,7 @@ def validate errors_hash( errors + - validate_card_brand_and_number + - validate_switch_or_solo_attributes + validate_card_brand_and_number ) end @@ -377,27 +368,6 @@ def validate_verification_value #:nodoc: errors end - def validate_switch_or_solo_attributes #:nodoc: - errors = [] - - if %w[switch solo].include?(brand) - valid_start_month = valid_month?(start_month) - valid_start_year = valid_start_year?(start_year) - - if((!valid_start_month || !valid_start_year) && !valid_issue_number?(issue_number)) - if empty?(issue_number) - errors << [:issue_number, 'cannot be empty'] - errors << [:start_month, 'is invalid'] if !valid_start_month - errors << [:start_year, 'is invalid'] if !valid_start_year - else - errors << [:issue_number, 'is invalid'] if !valid_issue_number?(issue_number) - end - end - end - - errors - end - class ExpiryDate #:nodoc: attr_reader :month, :year def initialize(month, year) diff --git a/lib/active_merchant/billing/gateways/axcessms.rb b/lib/active_merchant/billing/gateways/axcessms.rb index d45dde62713..59c8edaa4ea 100644 --- a/lib/active_merchant/billing/gateways/axcessms.rb +++ b/lib/active_merchant/billing/gateways/axcessms.rb @@ -8,7 +8,7 @@ class AxcessmsGateway < Gateway GI GR HR HU IE IL IM IS IT LI LT LU LV MC MT MX NL NO PL PT RO RU SE SI SK TR US VA) - self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :solo] + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro] self.homepage_url = 'http://www.axcessms.com/' self.display_name = 'Axcess MS' diff --git a/lib/active_merchant/billing/gateways/card_save.rb b/lib/active_merchant/billing/gateways/card_save.rb index 7bd9ee8e4d2..2e7b29b304d 100644 --- a/lib/active_merchant/billing/gateways/card_save.rb +++ b/lib/active_merchant/billing/gateways/card_save.rb @@ -6,7 +6,7 @@ class CardSaveGateway < IridiumGateway self.money_format = :cents self.default_currency = 'GBP' - self.supported_cardtypes = [ :visa, :switch, :maestro, :master, :solo, :american_express, :jcb ] + self.supported_cardtypes = [ :visa, :switch, :maestro, :master, :american_express, :jcb ] self.supported_countries = [ 'GB' ] self.homepage_url = 'http://www.cardsave.net/' self.display_name = 'CardSave' diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb index 3659ef360a9..32766f81ddb 100644 --- a/lib/active_merchant/billing/gateways/card_stream.rb +++ b/lib/active_merchant/billing/gateways/card_stream.rb @@ -8,7 +8,7 @@ class CardStreamGateway < Gateway self.money_format = :cents self.default_currency = 'GBP' self.supported_countries = ['GB', 'US', 'CH', 'SE', 'SG', 'NO', 'JP', 'IS', 'HK', 'NL', 'CZ', 'CA', 'AU'] - self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro, :solo, :switch] + self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro] self.homepage_url = 'http://www.cardstream.com/' self.display_name = 'CardStream' diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb index 307495c1f3a..179aa12e194 100644 --- a/lib/active_merchant/billing/gateways/data_cash.rb +++ b/lib/active_merchant/billing/gateways/data_cash.rb @@ -6,7 +6,7 @@ class DataCashGateway < Gateway self.default_currency = 'GBP' self.supported_countries = ['GB'] - self.supported_cardtypes = [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo ] + self.supported_cardtypes = [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro ] self.homepage_url = 'http://www.datacash.com/' self.display_name = 'DataCash' @@ -220,16 +220,6 @@ def add_credit_card(xml, credit_card, address) xml.tag! :pan, credit_card.number xml.tag! :expirydate, format_date(credit_card.month, credit_card.year) - # optional values - for Solo etc - if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s) - - xml.tag! :issuenumber, credit_card.issue_number unless credit_card.issue_number.blank? - - if !credit_card.start_month.blank? && !credit_card.start_year.blank? - xml.tag! :startdate, format_date(credit_card.start_month, credit_card.start_year) - end - end - xml.tag! :Cv2Avs do xml.tag! :cv2, credit_card.verification_value if credit_card.verification_value? if address diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb index ef5dfd425c2..5505a34f774 100644 --- a/lib/active_merchant/billing/gateways/dibs.rb +++ b/lib/active_merchant/billing/gateways/dibs.rb @@ -110,10 +110,6 @@ def add_payment_method(post, payment_method, options) post[:cvc] = payment_method.verification_value if payment_method.verification_value post[:expYear] = format(payment_method.year, :two_digits) post[:expMonth] = payment_method.month - - post[:startMonth] = payment_method.start_month if payment_method.start_month - post[:startYear] = payment_method.start_year if payment_method.start_year - post[:issueNumber] = payment_method.issue_number if payment_method.issue_number post[:clientIp] = options[:ip] || '127.0.0.1' post[:test] = true if test? end diff --git a/lib/active_merchant/billing/gateways/iridium.rb b/lib/active_merchant/billing/gateways/iridium.rb index 102a1677029..95c25379ec3 100644 --- a/lib/active_merchant/billing/gateways/iridium.rb +++ b/lib/active_merchant/billing/gateways/iridium.rb @@ -15,7 +15,7 @@ class IridiumGateway < Gateway self.money_format = :cents # The card types supported by the payment gateway - self.supported_cardtypes = [:visa, :master, :american_express, :discover, :maestro, :jcb, :solo, :diners_club] + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :maestro, :jcb, :diners_club] # The homepage URL of the gateway self.homepage_url = 'http://www.iridiumcorp.co.uk/' diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb index 2641cf7994a..c4ff212c018 100644 --- a/lib/active_merchant/billing/gateways/optimal_payment.rb +++ b/lib/active_merchant/billing/gateways/optimal_payment.rb @@ -10,7 +10,7 @@ class OptimalPaymentGateway < Gateway 'NL', 'NO', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'CH'] # The card types supported by the payment gateway - self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :solo] # :switch? + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club] # The homepage URL of the gateway self.homepage_url = 'http://www.optimalpayments.com/' @@ -320,8 +320,6 @@ def card_type(key) 'american_express'=> 'AM', 'discover' => 'DI', 'diners_club' => 'DC', - #'switch' => '', - 'solo' => 'SO' }[key] end diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb index e8258844aec..8aec158e79c 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb @@ -43,8 +43,6 @@ def self.included(base) :american_express => 'Amex', :jcb => 'JCB', :diners_club => 'DinersClub', - :switch => 'Switch', - :solo => 'Solo' } TRANSACTIONS = { diff --git a/lib/active_merchant/billing/gateways/payflow_uk.rb b/lib/active_merchant/billing/gateways/payflow_uk.rb index b8c3a711a44..7d67610438f 100644 --- a/lib/active_merchant/billing/gateways/payflow_uk.rb +++ b/lib/active_merchant/billing/gateways/payflow_uk.rb @@ -11,7 +11,7 @@ def express @express ||= PayflowExpressUkGateway.new(@options) end - self.supported_cardtypes = [:visa, :master, :american_express, :discover, :solo, :switch] + self.supported_cardtypes = [:visa, :master, :american_express, :discover] self.supported_countries = ['GB'] self.homepage_url = 'https://www.paypal.com/uk/webapps/mpp/pro' self.display_name = 'PayPal Payments Pro (UK)' diff --git a/lib/active_merchant/billing/gateways/paypal.rb b/lib/active_merchant/billing/gateways/paypal.rb index 4ca95d13f48..74769690810 100644 --- a/lib/active_merchant/billing/gateways/paypal.rb +++ b/lib/active_merchant/billing/gateways/paypal.rb @@ -81,12 +81,6 @@ def add_credit_card(xml, credit_card, address, options) xml.tag! 'n2:ExpYear', format(credit_card.year, :four_digits) xml.tag! 'n2:CVV2', credit_card.verification_value unless credit_card.verification_value.blank? - if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s) - xml.tag! 'n2:StartMonth', format(credit_card.start_month, :two_digits) unless credit_card.start_month.blank? - xml.tag! 'n2:StartYear', format(credit_card.start_year, :four_digits) unless credit_card.start_year.blank? - xml.tag! 'n2:IssueNumber', format(credit_card.issue_number, :two_digits) unless credit_card.issue_number.blank? - end - xml.tag! 'n2:CardOwner' do xml.tag! 'n2:PayerName' do xml.tag! 'n2:FirstName', credit_card.first_name @@ -110,8 +104,6 @@ def credit_card_type(type) when 'master' then 'MasterCard' when 'discover' then 'Discover' when 'american_express' then 'Amex' - when 'switch' then 'Switch' - when 'solo' then 'Solo' end end diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb index 4bd7f56f977..78fa1a97c60 100644 --- a/lib/active_merchant/billing/gateways/psl_card.rb +++ b/lib/active_merchant/billing/gateways/psl_card.rb @@ -17,11 +17,11 @@ class PslCardGateway < Gateway self.default_currency = 'GBP' self.supported_countries = ['GB'] - # Visa Credit, Visa Debit, Mastercard, Maestro, Solo, Electron, + # Visa Credit, Visa Debit, Mastercard, Maestro, Electron, # American Express, Diners Club, JCB, International Maestro, # Style, Clydesdale Financial Services, Other - self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb, :switch, :solo, :maestro ] + self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb, :maestro ] self.homepage_url = 'http://www.paymentsolutionsltd.com/' self.display_name = 'PSL Payment Solutions' diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index 31ad1aee6d3..deb1e2556a3 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -26,14 +26,12 @@ class RealexGateway < Gateway 'visa' => 'VISA', 'american_express' => 'AMEX', 'diners_club' => 'DINERS', - 'switch' => 'SWITCH', - 'solo' => 'SWITCH', 'maestro' => 'MC' } self.money_format = :cents self.default_currency = 'EUR' - self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :switch, :solo ] + self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club ] self.supported_countries = %w(IE GB FR BE NL LU IT US CA ES) self.homepage_url = 'http://www.realexpayments.com/' self.display_name = 'Realex' @@ -244,7 +242,7 @@ def add_card(xml, credit_card) xml.tag! 'expdate', expiry_date(credit_card) xml.tag! 'chname', credit_card.name xml.tag! 'type', CARD_MAPPING[card_brand(credit_card).to_s] - xml.tag! 'issueno', credit_card.issue_number + xml.tag! 'issueno', '' xml.tag! 'cvn' do xml.tag! 'number', credit_card.verification_value xml.tag! 'presind', (options['presind'] || (credit_card.verification_value? ? 1 : nil)) diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index b78c2d6f6b6..d46d338a741 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -28,8 +28,6 @@ class SagePayGateway < Gateway :visa => 'VISA', :master => 'MC', :delta => 'DELTA', - :solo => 'SOLO', - :switch => 'MAESTRO', :maestro => 'MAESTRO', :american_express => 'AMEX', :electron => 'UKE', @@ -71,7 +69,7 @@ class SagePayGateway < Gateway recipient_dob: :FIRecipientDoB } - self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :switch, :solo, :maestro, :diners_club] + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :diners_club] self.supported_countries = ['GB', 'IE'] self.default_currency = 'GBP' diff --git a/lib/active_merchant/billing/gateways/so_easy_pay.rb b/lib/active_merchant/billing/gateways/so_easy_pay.rb index cb80073bff0..5cc6eeaa1c6 100644 --- a/lib/active_merchant/billing/gateways/so_easy_pay.rb +++ b/lib/active_merchant/billing/gateways/so_easy_pay.rb @@ -10,7 +10,7 @@ class SoEasyPayGateway < Gateway 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB', 'IS', 'NO', 'CH' ] - self.supported_cardtypes = [:visa, :master, :american_express, :discover, :maestro, :jcb, :solo, :diners_club] + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :maestro, :jcb, :diners_club] self.homepage_url = 'http://www.soeasypay.com/' self.display_name = 'SoEasyPay' diff --git a/lib/active_merchant/billing/gateways/telr.rb b/lib/active_merchant/billing/gateways/telr.rb index b7cff295ac8..f1a38ef889d 100644 --- a/lib/active_merchant/billing/gateways/telr.rb +++ b/lib/active_merchant/billing/gateways/telr.rb @@ -11,7 +11,7 @@ class TelrGateway < Gateway self.supported_countries = ['AE', 'IN', 'SA'] self.default_currency = 'AED' self.money_format = :dollars - self.supported_cardtypes = [:visa, :master, :american_express, :maestro, :solo, :jcb] + self.supported_cardtypes = [:visa, :master, :american_express, :maestro, :jcb] CVC_CODE_TRANSLATOR = { 'Y' => 'M', diff --git a/test/remote/gateways/remote_payflow_uk_test.rb b/test/remote/gateways/remote_payflow_uk_test.rb index 5db52700d1b..5242f8f813a 100644 --- a/test/remote/gateways/remote_payflow_uk_test.rb +++ b/test/remote/gateways/remote_payflow_uk_test.rb @@ -16,26 +16,6 @@ def setup :verification_value => '000', :brand => 'master' ) - - @solo = CreditCard.new( - :brand => 'solo', - :number => '6334900000000005', - :month => Time.now.month, - :year => Time.now.year + 1, - :first_name => 'Test', - :last_name => 'Mensch', - :issue_number => '01' - ) - - @switch = CreditCard.new( - :brand => 'switch', - :number => '5641820000000005', - :verification_value => '000', - :month => 1, - :year => 2008, - :first_name => 'Fred', - :last_name => 'Brooks' - ) @options = { :billing_address => { diff --git a/test/unit/credit_card_test.rb b/test/unit/credit_card_test.rb index eb3c77d648b..5c2f1eb6b50 100644 --- a/test/unit/credit_card_test.rb +++ b/test/unit/credit_card_test.rb @@ -414,11 +414,6 @@ def test_month_and_year_are_immediately_converted_to_integers assert_nil card.month card.year = nil assert_nil card.year - - card.start_month = '1' - assert_equal 1, card.start_month - card.start_year = '1' - assert_equal 1, card.start_year end def test_should_report_as_emv_if_icc_data_present diff --git a/test/unit/gateways/data_cash_test.rb b/test/unit/gateways/data_cash_test.rb index d5f31a3079d..e7443c2d195 100644 --- a/test/unit/gateways/data_cash_test.rb +++ b/test/unit/gateways/data_cash_test.rb @@ -83,7 +83,7 @@ def test_supported_countries end def test_supported_card_types - assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo ], DataCashGateway.supported_cardtypes + assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro ], DataCashGateway.supported_cardtypes end def test_purchase_with_missing_order_id_option diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb index 2c7c86c9095..ef6e449fbce 100644 --- a/test/unit/gateways/payflow_test.rb +++ b/test/unit/gateways/payflow_test.rb @@ -364,25 +364,11 @@ def test_recurring_profile_payment_history_inquiry_contains_the_proper_xml assert_match %r(<PaymentHistory>Y</PaymentHistory), request end - def test_format_issue_number - xml = Builder::XmlMarkup.new - credit_card = credit_card('5641820000000005', - :brand => 'switch', - :issue_number => 1 - ) - - @gateway.send(:add_credit_card, xml, credit_card) - doc = REXML::Document.new(xml.target!) - node = REXML::XPath.first(doc, '/Card/ExtData') - assert_equal '01', node.attributes['Value'] - end - def test_add_credit_card_with_three_d_secure xml = Builder::XmlMarkup.new credit_card = credit_card( '5641820000000005', - :brand => 'switch', - :issue_number => 1 + :brand => 'maestro' ) @gateway.send(:add_credit_card, xml, credit_card, @options.merge(three_d_secure_option)) diff --git a/test/unit/gateways/payflow_uk_test.rb b/test/unit/gateways/payflow_uk_test.rb index 53c41fcfd20..e7adc1b7fd9 100644 --- a/test/unit/gateways/payflow_uk_test.rb +++ b/test/unit/gateways/payflow_uk_test.rb @@ -25,6 +25,6 @@ def test_supported_countries end def test_supported_card_types - assert_equal [:visa, :master, :american_express, :discover, :solo, :switch], PayflowUkGateway.supported_cardtypes + assert_equal [:visa, :master, :american_express, :discover], PayflowUkGateway.supported_cardtypes end end diff --git a/test/unit/gateways/payment_express_test.rb b/test/unit/gateways/payment_express_test.rb index 5b8b9dfbebe..54489838560 100644 --- a/test/unit/gateways/payment_express_test.rb +++ b/test/unit/gateways/payment_express_test.rb @@ -11,7 +11,7 @@ def setup @visa = credit_card - @solo = credit_card('6334900000000005', :brand => 'solo', :issue_number => '01') + @solo = credit_card('6334900000000005', :brand => 'maestro') @options = { :order_id => generate_unique_id, diff --git a/test/unit/gateways/psl_card_test.rb b/test/unit/gateways/psl_card_test.rb index 64d62400301..c37f92531ed 100644 --- a/test/unit/gateways/psl_card_test.rb +++ b/test/unit/gateways/psl_card_test.rb @@ -36,7 +36,7 @@ def test_supported_countries end def test_supported_card_types - assert_equal [ :visa, :master, :american_express, :diners_club, :jcb, :switch, :solo, :maestro ], PslCardGateway.supported_cardtypes + assert_equal [ :visa, :master, :american_express, :diners_club, :jcb, :maestro ], PslCardGateway.supported_cardtypes end def test_avs_result diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb index 5671331fc0d..abb11a2c16b 100644 --- a/test/unit/gateways/realex_test.rb +++ b/test/unit/gateways/realex_test.rb @@ -99,7 +99,7 @@ def test_supported_countries end def test_supported_card_types - assert_equal [ :visa, :master, :american_express, :diners_club, :switch, :solo ], RealexGateway.supported_cardtypes + assert_equal [ :visa, :master, :american_express, :diners_club ], RealexGateway.supported_cardtypes end def test_avs_result_not_supported From 2bc749340f8988adaa8a7c90db5dd81d413a2a5e Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 17 Sep 2018 11:31:53 -0400 Subject: [PATCH 541/677] Assume CC numbers are strings We honestly should be doing this anyway; now, enforce it, and take advantage of it to cut down on string conversions. Follow-up to conversation in #2983 3926 tests, 68184 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- .../billing/credit_card_methods.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb index 75ce78d25b1..032514bac57 100644 --- a/lib/active_merchant/billing/credit_card_methods.rb +++ b/lib/active_merchant/billing/credit_card_methods.rb @@ -4,13 +4,13 @@ module Billing #:nodoc: module CreditCardMethods CARD_COMPANY_DETECTORS = { 'visa' => ->(num) { num =~ /^4\d{12}(\d{3})?(\d{3})?$/ }, - 'master' => ->(num) { num.to_s.size == 16 && in_bin_range?(num.to_s.slice(0, 6), MASTERCARD_RANGES) }, + 'master' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), MASTERCARD_RANGES) }, 'discover' => ->(num) { num =~ /^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/ }, 'american_express' => ->(num) { num =~ /^3[47]\d{13}$/ }, 'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ }, 'jcb' => ->(num) { num =~ /^35(28|29|[3-8]\d)\d{12}$/ }, 'dankort' => ->(num) { num =~ /^5019\d{12}$/ }, - 'maestro' => ->(num) { (12..19).include?(num.to_s.size) && in_bin_range?(num.to_s.slice(0, 6), MAESTRO_RANGES) }, + 'maestro' => ->(num) { (12..19).include?(num&.size) && in_bin_range?(num.slice(0, 6), MAESTRO_RANGES) }, 'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ }, 'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ }, 'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ } @@ -158,11 +158,12 @@ def type?(number) end def first_digits(number) - number.to_s.slice(0,6) + number.slice(0,6) end def last_digits(number) - number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1) + return '' if number.nil? + number.length <= 4 ? number : number.slice(-4..-1) end def mask(number) @@ -182,16 +183,16 @@ def matching_type?(number, brand) private def valid_card_number_length?(number) #:nodoc: - number.to_s.length >= 12 + number.length >= 12 end def valid_card_number_characters?(number) #:nodoc: - !number.to_s.match(/\D/) + !number.match(/\D/) end def valid_test_mode_card_number?(number) #:nodoc: ActiveMerchant::Billing::Base.test? && - %w[1 2 3 success failure error].include?(number.to_s) + %w[1 2 3 success failure error].include?(number) end ODD_LUHN_VALUE = { From fce72791585a21deb68a914c856c86d6fd9ad458 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 17 Sep 2018 11:51:37 -0400 Subject: [PATCH 542/677] Add support for Carnet Carnet is only used in Mexico, and the only test number I could find I found by googling pictures of Carnet cards until I found someone who didn't blur out the number (although the test number here was mutated to be in the same bin range but have different subsequent digits). So there are definitely fewer test numbers than I'd like. 3927 tests, 68186 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/credit_card_methods.rb | 20 ++++++++++++++++++- test/unit/credit_card_methods_test.rb | 13 ++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 6ddf07f77f4..1129d82ac34 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Improve Maestro card detection [bpollack] #2983 * Add ROU alpha3 code for Romania [dtykocki] #2989 * [POSSIBLE BREAKAGE] Drop support for Solo and Switch cards [bpollack] #2991 +* Add support for Carnet cards [bpollack] #2992 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb index 032514bac57..1d79d9a2e1c 100644 --- a/lib/active_merchant/billing/credit_card_methods.rb +++ b/lib/active_merchant/billing/credit_card_methods.rb @@ -13,7 +13,13 @@ module CreditCardMethods 'maestro' => ->(num) { (12..19).include?(num&.size) && in_bin_range?(num.slice(0, 6), MAESTRO_RANGES) }, 'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ }, 'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ }, - 'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ } + 'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ }, + 'carnet' => lambda { |num| + num&.size == 16 && ( + in_bin_range?(num.slice(0, 6), CARNET_RANGES) || + CARNET_BINS.any? { |bin| num.slice(0, bin.size) == bin } + ) + } } # http://www.barclaycard.co.uk/business/files/bin_rules.pdf @@ -36,6 +42,18 @@ module CreditCardMethods (491730..491759), ] + CARNET_RANGES = [ + (506199..506499), + ] + + CARNET_BINS = Set.new( + [ + '286900', '502275', '606333', '627535', '636318', '636379', '639388', + '639484', '639559', '50633601', '50633606', '58877274', '62753500', + '60462203', '60462204', '588772' + ] + ) + # https://www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 73 MASTERCARD_RANGES = [ (222100..272099), diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb index 829eb0214c2..e38775a135e 100644 --- a/test/unit/credit_card_methods_test.rb +++ b/test/unit/credit_card_methods_test.rb @@ -187,6 +187,19 @@ def test_19_digit_maestro_uk assert_equal 'maestro', CreditCard.brand?(number) end + def test_carnet_cards + numbers = [ + '5062280000000000', + '6046220312312312', + '6393889871239871', + '5022751231231231', + ] + numbers.each do |num| + assert_equal 16, num.length + assert_equal 'carnet', CreditCard.brand?(num) + end + end + def test_electron_cards # return the card number so assert failures are easy to isolate electron_test = Proc.new do |card_number| From 5ad6212b708abaae6ea7cb788f54098f38b786e6 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 18 Sep 2018 15:00:29 -0400 Subject: [PATCH 543/677] Fix build breakage from RuboCop --- test/unit/credit_card_methods_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb index e38775a135e..831359b9636 100644 --- a/test/unit/credit_card_methods_test.rb +++ b/test/unit/credit_card_methods_test.rb @@ -192,7 +192,7 @@ def test_carnet_cards '5062280000000000', '6046220312312312', '6393889871239871', - '5022751231231231', + '5022751231231231' ] numbers.each do |num| assert_equal 16, num.length From 1ec4f30937396b284a20988d199cde591ef9c6bc Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 20 Sep 2018 07:55:01 -0400 Subject: [PATCH 544/677] Remove Switch from the last few gateways I missed a couple gateways in the last patch series (specifically, ones that only had Switch, not both Switch and Solo). Remove Switch from those as well. --- lib/active_merchant/billing/gateways/card_save.rb | 2 +- lib/active_merchant/billing/gateways/cyber_source.rb | 3 +-- lib/active_merchant/billing/gateways/wirecard.rb | 2 +- lib/active_merchant/billing/gateways/worldpay.rb | 3 +-- .../billing/gateways/worldpay_online_payments.rb | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/active_merchant/billing/gateways/card_save.rb b/lib/active_merchant/billing/gateways/card_save.rb index 2e7b29b304d..633ad3ea7cc 100644 --- a/lib/active_merchant/billing/gateways/card_save.rb +++ b/lib/active_merchant/billing/gateways/card_save.rb @@ -6,7 +6,7 @@ class CardSaveGateway < IridiumGateway self.money_format = :cents self.default_currency = 'GBP' - self.supported_cardtypes = [ :visa, :switch, :maestro, :master, :american_express, :jcb ] + self.supported_cardtypes = [ :visa, :maestro, :master, :american_express, :jcb ] self.supported_countries = [ 'GB' ] self.homepage_url = 'http://www.cardsave.net/' self.display_name = 'CardSave' diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 02e81821aed..190094e838a 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -26,7 +26,7 @@ class CyberSourceGateway < Gateway XSD_VERSION = '1.121' - self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :switch, :dankort, :maestro] + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro] self.supported_countries = %w(US BR CA CN DK FI FR DE JP MX NO SE GB SG LB) self.default_currency = 'USD' @@ -42,7 +42,6 @@ class CyberSourceGateway < Gateway :discover => '004', :diners_club => '005', :jcb => '007', - :switch => '024', :dankort => '034', :maestro => '042' } diff --git a/lib/active_merchant/billing/gateways/wirecard.rb b/lib/active_merchant/billing/gateways/wirecard.rb index 321cd379565..4b964770e15 100644 --- a/lib/active_merchant/billing/gateways/wirecard.rb +++ b/lib/active_merchant/billing/gateways/wirecard.rb @@ -26,7 +26,7 @@ class WirecardGateway < Gateway # number 5551234 within area code 202 (country code 1). VALID_PHONE_FORMAT = /\+\d{1,3}(\(?\d{3}\)?)?\d{3}-\d{4}-\d{3}/ - self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb, :switch ] + self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb ] self.supported_countries = %w(AD CY GI IM MT RO CH AT DK GR IT MC SM TR BE EE HU LV NL SK GB BG FI IS LI NO SI VA FR IL LT PL ES CZ DE IE LU PT SE) self.homepage_url = 'http://www.wirecard.com' self.display_name = 'Wirecard' diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index 2fe80cf9691..7d817e61a9b 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -7,7 +7,7 @@ class WorldpayGateway < Gateway self.default_currency = 'GBP' self.money_format = :cents self.supported_countries = %w(HK GB AU AD AR BE BR CA CH CN CO CR CY CZ DE DK ES FI FR GI GR HU IE IN IT JP LI LU MC MT MY MX NL NO NZ PA PE PL PT SE SG SI SM TR UM VA) - self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :switch] + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro] self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW) self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND) self.homepage_url = 'http://www.worldpay.com/' @@ -21,7 +21,6 @@ class WorldpayGateway < Gateway 'jcb' => 'JCB-SSL', 'maestro' => 'MAESTRO-SSL', 'diners_club' => 'DINERS-SSL', - 'switch' => 'MAESTRO-SSL' } def initialize(options = {}) diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb index af7b2bd7aec..a23f3f041a0 100644 --- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb @@ -8,7 +8,7 @@ class WorldpayOnlinePaymentsGateway < Gateway self.money_format = :cents self.supported_countries = %w(HK US GB BE CH CZ DE DK ES FI FR GR HU IE IT LU MT NL NO PL PT SE SG TR) - self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :switch] + self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro] self.homepage_url = 'http://online.worldpay.com' self.display_name = 'Worldpay Online Payments' From aa572339863aaa51e817f07223c71f5eefe983e1 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 20 Sep 2018 07:55:38 -0400 Subject: [PATCH 545/677] Remove last bits of Switch and Solo functionality --- lib/active_merchant/billing/gateway.rb | 7 ------- lib/active_merchant/billing/gateways/card_stream.rb | 9 --------- lib/active_merchant/billing/gateways/payflow.rb | 4 ---- lib/active_merchant/billing/gateways/payment_express.rb | 5 ----- lib/active_merchant/billing/gateways/psl_card.rb | 6 ------ lib/active_merchant/billing/gateways/sage_pay.rb | 5 ----- 6 files changed, 36 deletions(-) diff --git a/lib/active_merchant/billing/gateway.rb b/lib/active_merchant/billing/gateway.rb index d6596a810e9..c3f3ba2c90c 100644 --- a/lib/active_merchant/billing/gateway.rb +++ b/lib/active_merchant/billing/gateway.rb @@ -56,8 +56,6 @@ class Gateway include PostsData include CreditCardFormatting - DEBIT_CARDS = [ :switch, :solo ] - CREDIT_DEPRECATION_MESSAGE = 'Support for using credit to refund existing transactions is deprecated and will be removed from a future release of ActiveMerchant. Please use the refund method instead.' RECURRING_DEPRECATION_MESSAGE = 'Recurring functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it.' @@ -305,11 +303,6 @@ def split_names(full_name) [first_name, last_name] end - def requires_start_date_or_issue_number?(credit_card) - return false if card_brand(credit_card).blank? - DEBIT_CARDS.include?(card_brand(credit_card).to_sym) - end - def requires!(hash, *params) params.each do |param| if param.is_a?(Array) diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb index 32766f81ddb..993c61f027a 100644 --- a/lib/active_merchant/billing/gateways/card_stream.rb +++ b/lib/active_merchant/billing/gateways/card_stream.rb @@ -272,17 +272,8 @@ def add_reference(post, reference) def add_credit_card(post, credit_card) add_pair(post, :customerName, credit_card.name, :required => true) add_pair(post, :cardNumber, credit_card.number, :required => true) - add_pair(post, :cardExpiryMonth, format(credit_card.month, :two_digits), :required => true) add_pair(post, :cardExpiryYear, format(credit_card.year, :two_digits), :required => true) - - if requires_start_date_or_issue_number?(credit_card) - add_pair(post, :cardStartMonth, format(credit_card.start_month, :two_digits)) - add_pair(post, :cardStartYear, format(credit_card.start_year, :two_digits)) - - add_pair(post, :cardIssueNumber, credit_card.issue_number) - end - add_pair(post, :cardCVV, credit_card.verification_value) end diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb index da13e3a1d40..db7ac1cbe11 100644 --- a/lib/active_merchant/billing/gateways/payflow.rb +++ b/lib/active_merchant/billing/gateways/payflow.rb @@ -237,10 +237,6 @@ def add_credit_card(xml, credit_card, options = {}) end end - if requires_start_date_or_issue_number?(credit_card) - xml.tag!('ExtData', 'Name' => 'CardStart', 'Value' => startdate(credit_card)) unless credit_card.start_month.blank? || credit_card.start_year.blank? - xml.tag!('ExtData', 'Name' => 'CardIssue', 'Value' => format(credit_card.issue_number, :two_digits)) unless credit_card.issue_number.blank? - end xml.tag! 'ExtData', 'Name' => 'LASTNAME', 'Value' => credit_card.last_name end end diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb index 3495c029fca..f0ce2bb5556 100644 --- a/lib/active_merchant/billing/gateways/payment_express.rb +++ b/lib/active_merchant/billing/gateways/payment_express.rb @@ -193,11 +193,6 @@ def add_credit_card(xml, credit_card) xml.add_element('Cvc2').text = credit_card.verification_value xml.add_element('Cvc2Presence').text = '1' end - - if requires_start_date_or_issue_number?(credit_card) - xml.add_element('DateStart').text = format_date(credit_card.start_month, credit_card.start_year) unless credit_card.start_month.blank? || credit_card.start_year.blank? - xml.add_element('IssueNumber').text = credit_card.issue_number unless credit_card.issue_number.blank? - end end def add_billing_token(xml, token) diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb index 78fa1a97c60..9a213ea4088 100644 --- a/lib/active_merchant/billing/gateways/psl_card.rb +++ b/lib/active_merchant/billing/gateways/psl_card.rb @@ -174,12 +174,6 @@ def add_credit_card(post, credit_card) post[:ExpMonth] = credit_card.month post[:ExpYear] = credit_card.year - if requires_start_date_or_issue_number?(credit_card) - post[:IssueNumber] = credit_card.issue_number unless credit_card.issue_number.blank? - post[:StartMonth] = credit_card.start_month unless credit_card.start_month.blank? - post[:StartYear] = credit_card.start_year unless credit_card.start_year.blank? - end - # CV2 check post[:AVSCV2Check] = credit_card.verification_value? ? 'YES' : 'NO' post[:CV2] = credit_card.verification_value if credit_card.verification_value? diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index d46d338a741..313bdb88c72 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -289,11 +289,6 @@ def add_credit_card(post, credit_card) add_pair(post, :CardNumber, credit_card.number, :required => true) add_pair(post, :ExpiryDate, format_date(credit_card.month, credit_card.year), :required => true) - - if requires_start_date_or_issue_number?(credit_card) - add_pair(post, :StartDate, format_date(credit_card.start_month, credit_card.start_year)) - add_pair(post, :IssueNumber, credit_card.issue_number) - end add_pair(post, :CardType, map_card_type(credit_card)) add_pair(post, :CV2, credit_card.verification_value) From 19b45172ca2307e8c4512368e42b946689e5fc13 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 18 Sep 2018 11:50:18 -0400 Subject: [PATCH 546/677] RuboCop: fix Style/TrailingCommaInArguments --- .rubocop_todo.yml | 7 ------- lib/active_merchant/billing/gateways/balanced.rb | 2 +- lib/active_merchant/billing/gateways/blue_snap.rb | 2 +- lib/active_merchant/billing/gateways/braintree_blue.rb | 2 +- lib/active_merchant/billing/gateways/first_giving.rb | 2 +- lib/active_merchant/billing/gateways/ipp.rb | 2 +- lib/active_merchant/billing/gateways/mundipagg.rb | 2 +- lib/active_merchant/billing/gateways/opp.rb | 2 +- test/remote/gateways/remote_bank_frick_test.rb | 2 +- test/remote/gateways/remote_ipp_test.rb | 2 +- test/remote/gateways/remote_litle_test.rb | 2 +- test/remote/gateways/remote_paybox_direct_test.rb | 2 +- test/unit/gateways/authorize_net_test.rb | 6 +++--- test/unit/gateways/bank_frick_test.rb | 2 +- test/unit/gateways/beanstream_test.rb | 2 +- test/unit/gateways/checkout_v2_test.rb | 2 +- test/unit/gateways/firstdata_e4_test.rb | 6 +++--- test/unit/gateways/firstdata_e4_v27_test.rb | 6 +++--- test/unit/gateways/ipp_test.rb | 2 +- test/unit/gateways/merchant_e_solutions_test.rb | 2 +- test/unit/gateways/omise_test.rb | 2 +- test/unit/gateways/orbital_test.rb | 2 +- test/unit/gateways/quickbooks_test.rb | 2 +- test/unit/gateways/securion_pay_test.rb | 2 +- test/unit/gateways/transact_pro_test.rb | 2 +- 25 files changed, 30 insertions(+), 37 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b31f60d0e0d..b458e40724c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1487,13 +1487,6 @@ Style/TernaryParentheses: - 'lib/active_merchant/billing/gateways/payeezy.rb' - 'lib/active_merchant/billing/gateways/visanet_peru.rb' -# Offense count: 27 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInArguments: - Enabled: false - # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline. diff --git a/lib/active_merchant/billing/gateways/balanced.rb b/lib/active_merchant/billing/gateways/balanced.rb index e5629dd7820..dcc931d7e45 100644 --- a/lib/active_merchant/billing/gateways/balanced.rb +++ b/lib/active_merchant/billing/gateways/balanced.rb @@ -172,7 +172,7 @@ def commit(entity_name, path, post, method=:post) message_from(raw_response), raw_response, authorization: authorization_from(entity_name, raw_response), - test: test?, + test: test? ) end diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb index 95cab53ca27..cfd9d210434 100644 --- a/lib/active_merchant/billing/gateways/blue_snap.rb +++ b/lib/active_merchant/billing/gateways/blue_snap.rb @@ -258,7 +258,7 @@ def commit(action, verb = :post) avs_result: avs_result(parsed), cvv_result: cvv_result(parsed), error_code: error_code_from(parsed), - test: test?, + test: test? ) end diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index b6fe5e8e431..ca663c05d58 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -66,7 +66,7 @@ def initialize(options = {}) :private_key => options[:private_key], :environment => (options[:environment] || (test? ? :sandbox : :production)).to_sym, :custom_user_agent => "ActiveMerchant #{ActiveMerchant::VERSION}", - :logger => options[:logger] || logger, + :logger => options[:logger] || logger ) @braintree_gateway = Braintree::Gateway.new( @configuration ) diff --git a/lib/active_merchant/billing/gateways/first_giving.rb b/lib/active_merchant/billing/gateways/first_giving.rb index 29514f4334f..65bd5256104 100644 --- a/lib/active_merchant/billing/gateways/first_giving.rb +++ b/lib/active_merchant/billing/gateways/first_giving.rb @@ -107,7 +107,7 @@ def commit(action, post=nil) (response['friendlyErrorMessage'] || response['verboseErrorMessage'] || response['acknowledgement']), response, authorization: response['transactionId'], - test: test?, + test: test? ) end diff --git a/lib/active_merchant/billing/gateways/ipp.rb b/lib/active_merchant/billing/gateways/ipp.rb index a7595b82388..7813de28e1c 100644 --- a/lib/active_merchant/billing/gateways/ipp.rb +++ b/lib/active_merchant/billing/gateways/ipp.rb @@ -130,7 +130,7 @@ def commit(action, &block) response, authorization: authorization_from(response), error_code: error_code_from(response), - test: test?, + test: test? ) end diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb index 89d895cea7b..fc8b10982e2 100644 --- a/lib/active_merchant/billing/gateways/mundipagg.rb +++ b/lib/active_merchant/billing/gateways/mundipagg.rb @@ -254,7 +254,7 @@ def commit(action, parameters, auth = nil) "#{STANDARD_ERROR_MESSAGE_MAPPING[e.response.code]} #{message}", parse(e.response.body), test: test?, - error_code: STANDARD_ERROR_CODE_MAPPING[e.response.code], + error_code: STANDARD_ERROR_CODE_MAPPING[e.response.code] ) end diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb index 956fcec81cc..ebc3a5bc959 100644 --- a/lib/active_merchant/billing/gateways/opp.rb +++ b/lib/active_merchant/billing/gateways/opp.rb @@ -313,7 +313,7 @@ def commit(post, authorization, options) response, authorization: authorization_from(response), test: test?, - error_code: success ? nil : error_code_from(response), + error_code: success ? nil : error_code_from(response) ) end diff --git a/test/remote/gateways/remote_bank_frick_test.rb b/test/remote/gateways/remote_bank_frick_test.rb index a7202c677d4..d1bb6447d4e 100644 --- a/test/remote/gateways/remote_bank_frick_test.rb +++ b/test/remote/gateways/remote_bank_frick_test.rb @@ -123,7 +123,7 @@ def test_invalid_login sender: '', channel: '', userid: '', - userpwd: '', + userpwd: '' ) response = gateway.purchase(@amount, @credit_card, @options) assert_failure response diff --git a/test/remote/gateways/remote_ipp_test.rb b/test/remote/gateways/remote_ipp_test.rb index 16e17ce473b..f7e62cad46b 100644 --- a/test/remote/gateways/remote_ipp_test.rb +++ b/test/remote/gateways/remote_ipp_test.rb @@ -76,7 +76,7 @@ def test_failed_refund def test_invalid_login gateway = IppGateway.new( username: '', - password: '', + password: '' ) response = gateway.purchase(200, @credit_card, @options) assert_failure response diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb index b4b2e1dccb2..73d71064585 100644 --- a/test/remote/gateways/remote_litle_test.rb +++ b/test/remote/gateways/remote_litle_test.rb @@ -398,7 +398,7 @@ def test_unsuccessful_verify def test_successful_purchase_with_dynamic_descriptors assert response = @gateway.purchase(10010, @credit_card1, @options.merge( descriptor_name: 'SuperCompany', - descriptor_phone: '9193341121', + descriptor_phone: '9193341121' )) assert_success response assert_equal 'Approved', response.message diff --git a/test/remote/gateways/remote_paybox_direct_test.rb b/test/remote/gateways/remote_paybox_direct_test.rb index e1d718056bb..8ee4639b8fb 100644 --- a/test/remote/gateways/remote_paybox_direct_test.rb +++ b/test/remote/gateways/remote_paybox_direct_test.rb @@ -103,7 +103,7 @@ def test_invalid_login def test_invalid_login_without_rang gateway = PayboxDirectGateway.new( login: '199988899', - password: '1999888F', + password: '1999888F' ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 3c7eac296e5..f80be4fbb8f 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -1031,7 +1031,7 @@ def test_includes_shipping_name_when_passed_as_options def test_truncation card = credit_card('4242424242424242', first_name: 'a' * 51, - last_name: 'a' * 51, + last_name: 'a' * 51 ) options = { @@ -1043,7 +1043,7 @@ def test_truncation city: 'a' * 41, state: 'a' * 41, zip: 'a' * 21, - country: 'a' * 61, + country: 'a' * 61 ), shipping_address: address( name: ['a' * 51, 'a' * 51].join(' '), @@ -1052,7 +1052,7 @@ def test_truncation city: 'a' * 41, state: 'a' * 41, zip: 'a' * 21, - country: 'a' * 61, + country: 'a' * 61 ) } diff --git a/test/unit/gateways/bank_frick_test.rb b/test/unit/gateways/bank_frick_test.rb index 8ab20b5e9be..4c49abc68c5 100644 --- a/test/unit/gateways/bank_frick_test.rb +++ b/test/unit/gateways/bank_frick_test.rb @@ -6,7 +6,7 @@ def setup sender: 'sender-uuid', channel: 'channel-uuid', userid: 'user-uuid', - userpwd: 'password', + userpwd: 'password' ) @credit_card = credit_card diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb index 37787acfc7c..92866caab82 100644 --- a/test/unit/gateways/beanstream_test.rb +++ b/test/unit/gateways/beanstream_test.rb @@ -22,7 +22,7 @@ def setup number: '4030000010001234', payment_cryptogram: 'cryptogram goes here', eci: 'an ECI value', - transaction_id: 'transaction ID', + transaction_id: 'transaction ID' ) @check = check( diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb index d6189454c5f..bb3f1eda89a 100644 --- a/test/unit/gateways/checkout_v2_test.rb +++ b/test/unit/gateways/checkout_v2_test.rb @@ -5,7 +5,7 @@ class CheckoutV2Test < Test::Unit::TestCase def setup @gateway = CheckoutV2Gateway.new( - secret_key: '1111111111111', + secret_key: '1111111111111' ) @credit_card = credit_card diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb index e7e6e6c9fc4..5a5258ba58e 100755 --- a/test/unit/gateways/firstdata_e4_test.rb +++ b/test/unit/gateways/firstdata_e4_test.rb @@ -225,7 +225,7 @@ def test_network_tokenization_requests_with_amex brand: 'american_express', transaction_id: '123', eci: '05', - payment_cryptogram: 'whatever_the_cryptogram_of_at_least_20_characters_is', + payment_cryptogram: 'whatever_the_cryptogram_of_at_least_20_characters_is' ) @gateway.purchase(@amount, credit_card, @options) @@ -244,7 +244,7 @@ def test_network_tokenization_requests_with_discover brand: 'discover', transaction_id: '123', eci: '05', - payment_cryptogram: 'whatever_the_cryptogram_is', + payment_cryptogram: 'whatever_the_cryptogram_is' ) @gateway.purchase(@amount, credit_card, @options) @@ -264,7 +264,7 @@ def test_network_tokenization_requests_with_other_brands brand: brand, transaction_id: '123', eci: '05', - payment_cryptogram: 'whatever_the_cryptogram_is', + payment_cryptogram: 'whatever_the_cryptogram_is' ) @gateway.purchase(@amount, credit_card, @options) diff --git a/test/unit/gateways/firstdata_e4_v27_test.rb b/test/unit/gateways/firstdata_e4_v27_test.rb index 305faf51efb..fbee6ed84cf 100644 --- a/test/unit/gateways/firstdata_e4_v27_test.rb +++ b/test/unit/gateways/firstdata_e4_v27_test.rb @@ -207,7 +207,7 @@ def test_network_tokenization_requests_with_amex brand: 'american_express', transaction_id: '123', eci: '05', - payment_cryptogram: 'whatever_the_cryptogram_of_at_least_20_characters_is', + payment_cryptogram: 'whatever_the_cryptogram_of_at_least_20_characters_is' ) @gateway.purchase(@amount, credit_card, @options) @@ -226,7 +226,7 @@ def test_network_tokenization_requests_with_discover brand: 'discover', transaction_id: '123', eci: '05', - payment_cryptogram: 'whatever_the_cryptogram_is', + payment_cryptogram: 'whatever_the_cryptogram_is' ) @gateway.purchase(@amount, credit_card, @options) @@ -246,7 +246,7 @@ def test_network_tokenization_requests_with_other_brands brand: brand, transaction_id: '123', eci: '05', - payment_cryptogram: 'whatever_the_cryptogram_is', + payment_cryptogram: 'whatever_the_cryptogram_is' ) @gateway.purchase(@amount, credit_card, @options) diff --git a/test/unit/gateways/ipp_test.rb b/test/unit/gateways/ipp_test.rb index f338efad9e8..40b8035b37b 100644 --- a/test/unit/gateways/ipp_test.rb +++ b/test/unit/gateways/ipp_test.rb @@ -6,7 +6,7 @@ class IppTest < Test::Unit::TestCase def setup @gateway = IppGateway.new( username: 'username', - password: 'password', + password: 'password' ) @amount = 100 diff --git a/test/unit/gateways/merchant_e_solutions_test.rb b/test/unit/gateways/merchant_e_solutions_test.rb index 26b932d25a0..9e073026c41 100644 --- a/test/unit/gateways/merchant_e_solutions_test.rb +++ b/test/unit/gateways/merchant_e_solutions_test.rb @@ -42,7 +42,7 @@ def test_purchase_with_long_order_id_truncates_id @gateway.expects(:ssl_post).with( anything, all_of( - includes('invoice_number=thisislongerthan1'), + includes('invoice_number=thisislongerthan1') ) ).returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, options) diff --git a/test/unit/gateways/omise_test.rb b/test/unit/gateways/omise_test.rb index 52eb9cd22e0..c3e99f0d83c 100644 --- a/test/unit/gateways/omise_test.rb +++ b/test/unit/gateways/omise_test.rb @@ -4,7 +4,7 @@ class OmiseTest < Test::Unit::TestCase def setup @gateway = OmiseGateway.new( public_key: 'pkey_test_abc', - secret_key: 'skey_test_123', + secret_key: 'skey_test_123' ) @credit_card = credit_card diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index 5a23c6d072c..bc8e811be61 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -237,7 +237,7 @@ def test_address_format :dest_address2 => 'L%u%xury S|u^i\\t/e', :dest_city => '/Winn/i%p|e^g\\', :dest_zip => 'A1A 2B2', - :dest_state => '^MB', + :dest_state => '^MB' ) response = stub_comms do diff --git a/test/unit/gateways/quickbooks_test.rb b/test/unit/gateways/quickbooks_test.rb index bf6bc9d2017..7d59f157ba5 100644 --- a/test/unit/gateways/quickbooks_test.rb +++ b/test/unit/gateways/quickbooks_test.rb @@ -9,7 +9,7 @@ def setup consumer_secret: 'consumer_secret', access_token: 'access_token', token_secret: 'token_secret', - realm: 'realm_ID', + realm: 'realm_ID' ) @credit_card = credit_card diff --git a/test/unit/gateways/securion_pay_test.rb b/test/unit/gateways/securion_pay_test.rb index ea2a5d85025..2880ca98a15 100644 --- a/test/unit/gateways/securion_pay_test.rb +++ b/test/unit/gateways/securion_pay_test.rb @@ -5,7 +5,7 @@ class SecurionPayTest < Test::Unit::TestCase def setup @gateway = SecurionPayGateway.new( - secret_key: 'pr_test_SyMyCpIJosFIAESEsZUd3TgN', + secret_key: 'pr_test_SyMyCpIJosFIAESEsZUd3TgN' ) @credit_card = credit_card diff --git a/test/unit/gateways/transact_pro_test.rb b/test/unit/gateways/transact_pro_test.rb index 6590b82cb2a..6323dc78536 100644 --- a/test/unit/gateways/transact_pro_test.rb +++ b/test/unit/gateways/transact_pro_test.rb @@ -5,7 +5,7 @@ def setup @gateway = TransactProGateway.new( guid: 'login', password: 'password', - terminal: 'terminal', + terminal: 'terminal' ) @credit_card = credit_card From 2dc98f37eb681b751d054495a74d9e592212d332 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 18 Sep 2018 11:54:41 -0400 Subject: [PATCH 547/677] RuboCop: fix Style/SymbolProc --- .rubocop_todo.yml | 16 ---------------- lib/active_merchant/billing/compatibility.rb | 4 +--- .../billing/gateways/braintree_blue.rb | 2 +- lib/active_merchant/billing/gateways/cenpos.rb | 2 +- .../billing/gateways/checkout_v2.rb | 2 +- .../billing/gateways/creditcall.rb | 2 +- lib/active_merchant/billing/gateways/mercury.rb | 2 +- .../billing/gateways/payflow/payflow_response.rb | 2 +- lib/active_merchant/billing/gateways/psl_card.rb | 2 +- lib/active_merchant/billing/gateways/realex.rb | 2 +- 10 files changed, 9 insertions(+), 27 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b458e40724c..0302cacdff1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1453,22 +1453,6 @@ Style/StringLiteralsInInterpolation: Style/SymbolArray: Enabled: false -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: IgnoredMethods. -# IgnoredMethods: respond_to, define_method -Style/SymbolProc: - Exclude: - - 'lib/active_merchant/billing/compatibility.rb' - - 'lib/active_merchant/billing/gateways/braintree_blue.rb' - - 'lib/active_merchant/billing/gateways/cenpos.rb' - - 'lib/active_merchant/billing/gateways/checkout_v2.rb' - - 'lib/active_merchant/billing/gateways/creditcall.rb' - - 'lib/active_merchant/billing/gateways/mercury.rb' - - 'lib/active_merchant/billing/gateways/payflow/payflow_response.rb' - - 'lib/active_merchant/billing/gateways/psl_card.rb' - - 'lib/active_merchant/billing/gateways/realex.rb' - # Offense count: 15 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, AllowSafeAssignment. diff --git a/lib/active_merchant/billing/compatibility.rb b/lib/active_merchant/billing/compatibility.rb index 740cc3d0906..8161ef320f0 100644 --- a/lib/active_merchant/billing/compatibility.rb +++ b/lib/active_merchant/billing/compatibility.rb @@ -29,9 +29,7 @@ def self.humanize(lower_case_and_underscored_word) result = lower_case_and_underscored_word.to_s.dup result.gsub!(/_id$/, '') result.gsub!(/_/, ' ') - result.gsub(/([a-z\d]*)/i) { |match| - match.downcase - }.gsub(/^\w/) { $&.upcase } + result.gsub(/([a-z\d]*)/i, &:downcase).gsub(/^\w/) { $&.upcase } end end end diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index ca663c05d58..1f3726827bf 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -140,7 +140,7 @@ def store(creditcard, options = {}) def update(vault_id, creditcard, options = {}) braintree_credit_card = nil commit do - braintree_credit_card = @braintree_gateway.customer.find(vault_id).credit_cards.detect { |cc| cc.default? } + braintree_credit_card = @braintree_gateway.customer.find(vault_id).credit_cards.detect(&:default?) return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil? options.merge!(:update_existing_token => braintree_credit_card.token) diff --git a/lib/active_merchant/billing/gateways/cenpos.rb b/lib/active_merchant/billing/gateways/cenpos.rb index f6030e64f5c..2a36063982f 100644 --- a/lib/active_merchant/billing/gateways/cenpos.rb +++ b/lib/active_merchant/billing/gateways/cenpos.rb @@ -313,7 +313,7 @@ def validation_result_element(xml, name) def validation_result_element_text(element) result_text = element.elements.detect { |elem| elem.name == 'Result' - }.children.detect { |elem| elem.text }.text + }.children.detect(&:text).text result_text.split(';').collect(&:strip) end diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb index 93a5c9f69d8..6289c2a0811 100644 --- a/lib/active_merchant/billing/gateways/checkout_v2.rb +++ b/lib/active_merchant/billing/gateways/checkout_v2.rb @@ -22,7 +22,7 @@ def purchase(amount, payment_method, options={}) r.process { capture(amount, r.authorization, options) } end - merged_params = multi.responses.map { |r| r.params }.reduce({}, :merge) + merged_params = multi.responses.map(&:params).reduce({}, :merge) succeeded = success_from(merged_params) response(:purchase, succeeded, merged_params) diff --git a/lib/active_merchant/billing/gateways/creditcall.rb b/lib/active_merchant/billing/gateways/creditcall.rb index f55c4960812..a140cbfa4a2 100644 --- a/lib/active_merchant/billing/gateways/creditcall.rb +++ b/lib/active_merchant/billing/gateways/creditcall.rb @@ -52,7 +52,7 @@ def purchase(money, payment_method, options={}) r.process { capture(money, r.authorization, options) } end - merged_params = multi_response.responses.map { |r| r.params }.reduce({}, :merge) + merged_params = multi_response.responses.map(&:params).reduce({}, :merge) Response.new( multi_response.primary_response.success?, diff --git a/lib/active_merchant/billing/gateways/mercury.rb b/lib/active_merchant/billing/gateways/mercury.rb index 090ffaad3f1..1a8fbe6be57 100644 --- a/lib/active_merchant/billing/gateways/mercury.rb +++ b/lib/active_merchant/billing/gateways/mercury.rb @@ -319,7 +319,7 @@ def message_from(response) end def authorization_from(response) - dollars, cents = (response[:purchase] || '').split('.').collect{|e| e.to_i} + dollars, cents = (response[:purchase] || '').split('.').collect(&:to_i) dollars ||= 0 cents ||= 0 [ diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_response.rb b/lib/active_merchant/billing/gateways/payflow/payflow_response.rb index d2b6e670009..21f6b5cb868 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_response.rb @@ -6,7 +6,7 @@ def profile_id end def payment_history - @payment_history ||= @params['rp_payment_result'].collect{ |result| result.stringify_keys } rescue [] + @payment_history ||= @params['rp_payment_result'].collect(&:stringify_keys) rescue [] end end end diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb index 9a213ea4088..1abe0b9e55e 100644 --- a/lib/active_merchant/billing/gateways/psl_card.rb +++ b/lib/active_merchant/billing/gateways/psl_card.rb @@ -183,7 +183,7 @@ def add_address(post, options) address = options[:billing_address] || options[:address] return if address.nil? - post[:QAAddress] = [:address1, :address2, :city, :state].collect{|a| address[a]}.reject{|a| a.blank?}.join(' ') + post[:QAAddress] = [:address1, :address2, :city, :state].collect{|a| address[a]}.reject(&:blank?).join(' ') post[:QAPostcode] = address[:zip] end diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index deb1e2556a3..3b5c86b1b52 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -264,7 +264,7 @@ def add_network_tokenization_card(xml, payment) def format_address_code(address) code = [address[:zip].to_s, address[:address1].to_s + address[:address2].to_s] - code.collect{|e| e.gsub(/\D/, '')}.reject{|e| e.empty?}.join('|') + code.collect{|e| e.gsub(/\D/, '')}.reject(&:empty?).join('|') end def new_timestamp From 65921608b6e6edbd27403a08d12bae700f968552 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 18 Sep 2018 12:04:58 -0400 Subject: [PATCH 548/677] RuboCop: fix Style/RedundantConditional --- .rubocop_todo.yml | 8 -------- lib/active_merchant/billing/gateways/pin.rb | 2 +- lib/active_merchant/billing/gateways/usa_epay_advanced.rb | 2 +- .../billing/gateways/worldpay_online_payments.rb | 2 +- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0302cacdff1..2d5dea1d4a1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1339,14 +1339,6 @@ Style/RandomWithOffset: Style/RedundantBegin: Enabled: false -# Offense count: 3 -# Cop supports --auto-correct. -Style/RedundantConditional: - Exclude: - - 'lib/active_merchant/billing/gateways/pin.rb' - - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' - - 'lib/active_merchant/billing/gateways/worldpay_online_payments.rb' - # Offense count: 1 # Cop supports --auto-correct. Style/RedundantException: diff --git a/lib/active_merchant/billing/gateways/pin.rb b/lib/active_merchant/billing/gateways/pin.rb index a7e11dd16bb..289e8e33501 100644 --- a/lib/active_merchant/billing/gateways/pin.rb +++ b/lib/active_merchant/billing/gateways/pin.rb @@ -120,7 +120,7 @@ def add_invoice(post, options) def add_capture(post, options) capture = options[:capture] - post[:capture] = capture == false ? false : true + post[:capture] = capture != false end def add_creditcard(post, creditcard) diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb index d831807ec29..1db1f42a779 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb @@ -1568,7 +1568,7 @@ def parse(action, soap) if response.respond_to?(:[]) && p = response["#{action}_return"] if p.respond_to?(:key?) && p.key?('result_code') - success = p['result_code'] == 'A' ? true : false + success = p['result_code'] == 'A' authorization = p['ref_num'] avs = AVS_RESULTS[p['avs_result_code']] cvv = p['card_code_result_code'] diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb index a23f3f041a0..c8b985a334a 100644 --- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb @@ -187,7 +187,7 @@ def commit(method, url, parameters=nil, options = {}, type = false) end def test? - @service_key[0]=='T' ? true : false + @service_key[0] == 'T' end def response_error(raw_response) From ada8f128547f92f1cb9647c4eae03e6caaae7ba5 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 18 Sep 2018 12:07:58 -0400 Subject: [PATCH 549/677] RuboCop: fix Style/RedundantParentheses --- .rubocop_todo.yml | 5 ----- lib/active_merchant/billing/gateways/blue_snap.rb | 2 +- lib/active_merchant/billing/gateways/ct_payment.rb | 2 +- lib/active_merchant/billing/gateways/dibs.rb | 2 +- lib/active_merchant/billing/gateways/element.rb | 2 +- .../billing/gateways/federated_canada.rb | 2 +- lib/active_merchant/billing/gateways/iveri.rb | 2 +- lib/active_merchant/billing/gateways/litle.rb | 2 +- lib/active_merchant/billing/gateways/moneris_us.rb | 2 +- lib/active_merchant/billing/gateways/money_movers.rb | 2 +- lib/active_merchant/billing/gateways/nmi.rb | 2 +- lib/active_merchant/billing/gateways/orbital.rb | 2 +- lib/active_merchant/billing/gateways/safe_charge.rb | 6 +++--- lib/active_merchant/billing/gateways/skip_jack.rb | 4 ++-- lib/active_merchant/billing/gateways/spreedly_core.rb | 2 +- .../billing/gateways/usa_epay_advanced.rb | 2 +- lib/active_merchant/billing/gateways/vanco.rb | 2 +- test/remote/gateways/remote_payu_latam_test.rb | 10 +++++----- test/unit/gateways/optimal_payment_test.rb | 4 ++-- 19 files changed, 26 insertions(+), 31 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2d5dea1d4a1..8edb950986b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1345,11 +1345,6 @@ Style/RedundantException: Exclude: - 'lib/active_merchant/billing/gateway.rb' -# Offense count: 27 -# Cop supports --auto-correct. -Style/RedundantParentheses: - Enabled: false - # Offense count: 87 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb index cfd9d210434..d79f6ac4a7d 100644 --- a/lib/active_merchant/billing/gateways/blue_snap.rb +++ b/lib/active_merchant/billing/gateways/blue_snap.rb @@ -215,7 +215,7 @@ def parse(response) parsed = {} doc = Nokogiri::XML(response.body) doc.root.xpath('*').each do |node| - if (node.elements.empty?) + if node.elements.empty? parsed[node.name.downcase] = node.text else node.elements.each do |childnode| diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb index 18b111f0a12..c29f8c30630 100644 --- a/lib/active_merchant/billing/gateways/ct_payment.rb +++ b/lib/active_merchant/billing/gateways/ct_payment.rb @@ -172,7 +172,7 @@ def add_customer_data(post, options) def add_address(post, creditcard, options) if address = options[:billing_address] || options[:address] - post[:CardHolderAddress] = ("#{address[:address1]} #{address[:address2]} #{address[:city]} #{address[:state]}").rjust(20, ' ') + post[:CardHolderAddress] = "#{address[:address1]} #{address[:address2]} #{address[:city]} #{address[:state]}".rjust(20, ' ') post[:CardHolderPostalCode] = address[:zip].gsub(/\s+/, '').rjust(9, ' ') end end diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb index 5505a34f774..5379b738107 100644 --- a/lib/active_merchant/billing/gateways/dibs.rb +++ b/lib/active_merchant/billing/gateways/dibs.rb @@ -27,7 +27,7 @@ def authorize(amount, payment_method, options={}) post = {} add_amount(post, amount) add_invoice(post, amount, options) - if (payment_method.respond_to?(:number)) + if payment_method.respond_to?(:number) add_payment_method(post, payment_method, options) commit(:authorize, post) else diff --git a/lib/active_merchant/billing/gateways/element.rb b/lib/active_merchant/billing/gateways/element.rb index 163402df436..248626e5802 100644 --- a/lib/active_merchant/billing/gateways/element.rb +++ b/lib/active_merchant/billing/gateways/element.rb @@ -251,7 +251,7 @@ def parse(xml) end root.each do |node| - if (node.elements.empty?) + if node.elements.empty? response[node.name.downcase] = node.text else node_name = node.name.downcase diff --git a/lib/active_merchant/billing/gateways/federated_canada.rb b/lib/active_merchant/billing/gateways/federated_canada.rb index d434f8307d2..404e8bebd60 100644 --- a/lib/active_merchant/billing/gateways/federated_canada.rb +++ b/lib/active_merchant/billing/gateways/federated_canada.rb @@ -134,7 +134,7 @@ def success?(response) end def test? - (@options[:login].eql?('demo')) && (@options[:password].eql?('password')) + @options[:login].eql?('demo') && @options[:password].eql?('password') end def message_from(response) diff --git a/lib/active_merchant/billing/gateways/iveri.rb b/lib/active_merchant/billing/gateways/iveri.rb index 64f08999b39..808966879c2 100644 --- a/lib/active_merchant/billing/gateways/iveri.rb +++ b/lib/active_merchant/billing/gateways/iveri.rb @@ -187,7 +187,7 @@ def parse(body) vxml = Nokogiri::XML(body).remove_namespaces!.xpath('//Envelope/Body/ExecuteResponse/ExecuteResult').inner_text doc = Nokogiri::XML(vxml) doc.xpath('*').each do |node| - if (node.elements.empty?) + if node.elements.empty? parsed[underscore(node.name)] = node.text else node.elements.each do |childnode| diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index e702dc297ed..4365a3884c5 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -364,7 +364,7 @@ def parse(kind, xml) doc = Nokogiri::XML(xml).remove_namespaces! doc.xpath("//litleOnlineResponse/#{kind}Response/*").each do |node| - if (node.elements.empty?) + if node.elements.empty? parsed[node.name.to_sym] = node.text else node.elements.each do |childnode| diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb index 35696ea43b5..dd625fe0a96 100644 --- a/lib/active_merchant/billing/gateways/moneris_us.rb +++ b/lib/active_merchant/billing/gateways/moneris_us.rb @@ -57,7 +57,7 @@ def authorize(money, creditcard_or_datakey, options = {}) post[:order_id] = options[:order_id] post[:address] = options[:billing_address] || options[:address] post[:crypt_type] = options[:crypt_type] || @options[:crypt_type] - action = (post[:data_key].blank?) ? 'us_preauth' : 'us_res_preauth_cc' + action = post[:data_key].blank? ? 'us_preauth' : 'us_res_preauth_cc' commit(action, post) end diff --git a/lib/active_merchant/billing/gateways/money_movers.rb b/lib/active_merchant/billing/gateways/money_movers.rb index 95165a42479..a41b57abeb5 100644 --- a/lib/active_merchant/billing/gateways/money_movers.rb +++ b/lib/active_merchant/billing/gateways/money_movers.rb @@ -126,7 +126,7 @@ def success?(response) end def test? - (@options[:login].eql?('demo')) && (@options[:password].eql?('password')) + @options[:login].eql?('demo') && @options[:password].eql?('password') end def message_from(response) diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb index 7ed61265c54..63180931889 100644 --- a/lib/active_merchant/billing/gateways/nmi.rb +++ b/lib/active_merchant/billing/gateways/nmi.rb @@ -140,7 +140,7 @@ def add_invoice(post, money, options) def add_payment_method(post, payment_method, options) if(payment_method.is_a?(String)) post[:customer_vault_id] = payment_method - elsif (payment_method.is_a?(NetworkTokenizationCreditCard)) + elsif payment_method.is_a?(NetworkTokenizationCreditCard) post[:ccnumber] = payment_method.number post[:ccexp] = exp_date(payment_method) post[:token_cryptogram] = payment_method.payment_cryptogram diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index 27402de05be..9f0ba09eca7 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -398,7 +398,7 @@ def add_address(xml, creditcard, options) end xml.tag! :AVSname, ((creditcard && creditcard.name) ? creditcard.name[0..29] : nil) - xml.tag! :AVScountryCode, (avs_supported ? (byte_limit(format_address_field(address[:country]), 2)) : '') + xml.tag! :AVScountryCode, (avs_supported ? byte_limit(format_address_field(address[:country]), 2) : '') # Needs to come after AVScountryCode add_destination_address(xml, address) if avs_supported diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index 82aab0e2113..7a3c64f7a27 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -43,7 +43,7 @@ def authorize(money, payment, options={}) def capture(money, authorization, options={}) post = {} auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split('|') - add_transaction_data('Settle', post, money, (options.merge!({currency: original_currency}))) + add_transaction_data('Settle', post, money, options.merge!({currency: original_currency})) post[:sg_AuthCode] = auth post[:sg_TransactionID] = transaction_id post[:sg_CCToken] = token @@ -56,7 +56,7 @@ def capture(money, authorization, options={}) def refund(money, authorization, options={}) post = {} auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split('|') - add_transaction_data('Credit', post, money, (options.merge!({currency: original_currency}))) + add_transaction_data('Credit', post, money, options.merge!({currency: original_currency})) post[:sg_CreditType] = 2 post[:sg_AuthCode] = auth post[:sg_TransactionID] = transaction_id @@ -79,7 +79,7 @@ def credit(money, payment, options={}) def void(authorization, options={}) post = {} auth, transaction_id, token, exp_month, exp_year, original_amount, original_currency = authorization.split('|') - add_transaction_data('Void', post, (original_amount.to_f * 100), (options.merge!({currency: original_currency}))) + add_transaction_data('Void', post, (original_amount.to_f * 100), options.merge!({currency: original_currency})) post[:sg_CreditType] = 2 post[:sg_AuthCode] = auth post[:sg_TransactionID] = transaction_id diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb index 6de7356d1de..563a169ba8d 100644 --- a/lib/active_merchant/billing/gateways/skip_jack.rb +++ b/lib/active_merchant/billing/gateways/skip_jack.rb @@ -318,7 +318,7 @@ def split_line(line) def authorize_response_map(body) lines = split_lines(body) keys, values = split_line(lines[0]), split_line(lines[1]) - Hash[*(keys.zip(values).flatten)].symbolize_keys + Hash[*keys.zip(values).flatten].symbolize_keys end def parse_authorization_response(body) @@ -333,7 +333,7 @@ def parse_status_response(body, response_keys) keys = [ :szSerialNumber, :szErrorCode, :szNumberRecords] values = split_line(lines[0])[0..2] - result = Hash[*(keys.zip(values).flatten)] + result = Hash[*keys.zip(values).flatten] result[:szErrorMessage] = '' result[:success] = (result[:szErrorCode] == '0') diff --git a/lib/active_merchant/billing/gateways/spreedly_core.rb b/lib/active_merchant/billing/gateways/spreedly_core.rb index 20a92886494..7c365fb2f68 100644 --- a/lib/active_merchant/billing/gateways/spreedly_core.rb +++ b/lib/active_merchant/billing/gateways/spreedly_core.rb @@ -231,7 +231,7 @@ def parse(xml) doc = Nokogiri::XML(xml) doc.root.xpath('*').each do |node| - if (node.elements.empty?) + if node.elements.empty? response[node.name.downcase.to_sym] = node.text else node.elements.each do |childnode| diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb index 1db1f42a779..1744dcc1306 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb @@ -1563,7 +1563,7 @@ def parse(action, soap) success, message, authorization, avs, cvv = false, FAILURE_MESSAGE, nil, nil, nil - fault = (!response) || (response.length < 1) || response.has_key?('faultcode') + fault = !response || (response.length < 1) || response.has_key?('faultcode') return [response, success, response['faultstring'], authorization, avs, cvv] if fault if response.respond_to?(:[]) && p = response["#{action}_return"] diff --git a/lib/active_merchant/billing/gateways/vanco.rb b/lib/active_merchant/billing/gateways/vanco.rb index 8f9925bb946..38e2f2aef87 100644 --- a/lib/active_merchant/billing/gateways/vanco.rb +++ b/lib/active_merchant/billing/gateways/vanco.rb @@ -52,7 +52,7 @@ def parse(xml) doc = Nokogiri::XML(xml) doc.root.xpath('*').each do |node| - if (node.elements.empty?) + if node.elements.empty? response[node.name.downcase.to_sym] = node.text else node.elements.each do |childnode| diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index b15d9fce5c1..e1fa12362d6 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -290,13 +290,13 @@ def test_well_formed_refund_fails_as_expected def test_failed_refund response = @gateway.refund(@amount, '') assert_failure response - assert_match (/property: parentTransactionId, message: must not be null/), response.message + assert_match /property: parentTransactionId, message: must not be null/, response.message end def test_failed_refund_with_specified_language response = @gateway.refund(@amount, '', language: 'es') assert_failure response - assert_match (/property: parentTransactionId, message: No puede ser vacio/), response.message + assert_match /property: parentTransactionId, message: No puede ser vacio/, response.message end # If this test fails, support for void may have been added to the sandbox @@ -312,13 +312,13 @@ def test_unsupported_test_void_fails_as_expected def test_failed_void response = @gateway.void('') assert_failure response - assert_match (/property: parentTransactionId, message: must not be null/), response.message + assert_match /property: parentTransactionId, message: must not be null/, response.message end def test_failed_void_with_specified_language response = @gateway.void('', language: 'es') assert_failure response - assert_match (/property: parentTransactionId, message: No puede ser vacio/), response.message + assert_match /property: parentTransactionId, message: No puede ser vacio/, response.message end # If this test fails, support for captures may have been added to the sandbox @@ -334,7 +334,7 @@ def test_unsupported_test_capture_fails_as_expected def test_failed_capture response = @gateway.capture(@amount, '') assert_failure response - assert_match (/must not be null/), response.message + assert_match /must not be null/, response.message end def test_verify_credentials diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb index f2c10a753a3..35faf61a2b4 100644 --- a/test/unit/gateways/optimal_payment_test.rb +++ b/test/unit/gateways/optimal_payment_test.rb @@ -132,7 +132,7 @@ def test_cvd_fields_pass_correctly stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| - assert_match (/cvdIndicator%3E1%3C\/cvdIndicator%3E%0A%20%20%20%20%3Ccvd%3E123%3C\/cvd/), data + assert_match(/cvdIndicator%3E1%3C\/cvdIndicator%3E%0A%20%20%20%20%3Ccvd%3E123%3C\/cvd/, data) end.respond_with(successful_purchase_response) credit_card = CreditCard.new( @@ -147,7 +147,7 @@ def test_cvd_fields_pass_correctly stub_comms do @gateway.purchase(@amount, credit_card, @options) end.check_request do |endpoint, data, headers| - assert_match (/cvdIndicator%3E0%3C\/cvdIndicator%3E%0A%20%20%3C\/card/), data + assert_match(/cvdIndicator%3E0%3C\/cvdIndicator%3E%0A%20%20%3C\/card/, data) end.respond_with(failed_purchase_response) end From e5a75456e6cfab301d14984db0d29f0cc4dfdcbf Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 18 Sep 2018 12:09:42 -0400 Subject: [PATCH 550/677] RuboCop: fix Style/RedundantException --- .rubocop_todo.yml | 6 ------ lib/active_merchant/billing/gateway.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8edb950986b..3910dab8e6b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1339,12 +1339,6 @@ Style/RandomWithOffset: Style/RedundantBegin: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -Style/RedundantException: - Exclude: - - 'lib/active_merchant/billing/gateway.rb' - # Offense count: 87 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. diff --git a/lib/active_merchant/billing/gateway.rb b/lib/active_merchant/billing/gateway.rb index c3f3ba2c90c..9db7133d6b2 100644 --- a/lib/active_merchant/billing/gateway.rb +++ b/lib/active_merchant/billing/gateway.rb @@ -193,7 +193,7 @@ def supports_scrubbing? end def scrub(transcript) - raise RuntimeError.new('This gateway does not support scrubbing.') + raise 'This gateway does not support scrubbing.' end def supports_network_tokenization? From 2fcf51d140a02c09bd172f485cf4b5559793f148 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 18 Sep 2018 12:43:37 -0400 Subject: [PATCH 551/677] RuboCop: fix Style/RedundantBegin --- .rubocop_todo.yml | 5 -- lib/active_merchant/billing/credit_card.rb | 8 +-- .../billing/gateways/blue_snap.rb | 8 +-- .../billing/gateways/conekta.rb | 8 +-- lib/active_merchant/billing/gateways/culqi.rb | 18 +++--- .../billing/gateways/fat_zebra.rb | 20 +++--- .../billing/gateways/kushki.rb | 16 +++-- .../billing/gateways/latitude19.rb | 62 +++++++++---------- .../billing/gateways/openpay.rb | 8 +-- lib/active_merchant/billing/gateways/opp.rb | 8 +-- .../billing/gateways/pagarme.rb | 8 +-- .../billing/gateways/pay_junction_v2.rb | 20 +++--- .../billing/gateways/payu_latam.rb | 58 ++++++++--------- .../billing/gateways/quickpay/quickpay_v10.rb | 8 +-- .../billing/gateways/securion_pay.rb | 8 +-- .../billing/gateways/stripe.rb | 8 +-- .../billing/gateways/visanet_peru.rb | 60 +++++++++--------- .../gateways/worldpay_online_payments.rb | 8 +-- test/unit/gateways/optimal_payment_test.rb | 32 +++++----- 19 files changed, 162 insertions(+), 209 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3910dab8e6b..46332a97372 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1334,11 +1334,6 @@ Style/RandomWithOffset: - 'test/remote/gateways/remote_pay_junction_test.rb' - 'test/unit/gateways/beanstream_test.rb' -# Offense count: 21 -# Cop supports --auto-correct. -Style/RedundantBegin: - Enabled: false - # Offense count: 87 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb index 98ca5a522cc..4d1afcae1bf 100644 --- a/lib/active_merchant/billing/credit_card.rb +++ b/lib/active_merchant/billing/credit_card.rb @@ -380,11 +380,9 @@ def expired? #:nodoc: end def expiration #:nodoc: - begin - Time.utc(year, month, month_days, 23, 59, 59) - rescue ArgumentError - Time.at(0).utc - end + Time.utc(year, month, month_days, 23, 59, 59) + rescue ArgumentError + Time.at(0).utc end private diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb index d79f6ac4a7d..441d0e4b763 100644 --- a/lib/active_merchant/billing/gateways/blue_snap.rb +++ b/lib/active_merchant/billing/gateways/blue_snap.rb @@ -237,11 +237,9 @@ def parse_element(parsed, node) end def api_request(action, request, verb) - begin - ssl_request(verb, url(action), request, headers) - rescue ResponseError => e - e.response - end + ssl_request(verb, url(action), request, headers) + rescue ResponseError => e + e.response end def commit(action, verb = :post) diff --git a/lib/active_merchant/billing/gateways/conekta.rb b/lib/active_merchant/billing/gateways/conekta.rb index 2e38d54c43c..dfa9d484a20 100644 --- a/lib/active_merchant/billing/gateways/conekta.rb +++ b/lib/active_merchant/billing/gateways/conekta.rb @@ -211,11 +211,9 @@ def commit(method, url, parameters, options = {}) end def response_error(raw_response) - begin - parse(raw_response) - rescue JSON::ParserError - json_error(raw_response) - end + parse(raw_response) + rescue JSON::ParserError + json_error(raw_response) end def json_error(raw_response) diff --git a/lib/active_merchant/billing/gateways/culqi.rb b/lib/active_merchant/billing/gateways/culqi.rb index d7dde785353..7b0e078207a 100644 --- a/lib/active_merchant/billing/gateways/culqi.rb +++ b/lib/active_merchant/billing/gateways/culqi.rb @@ -243,16 +243,14 @@ def url end def parse(body) - begin - JSON.parse(body) - rescue JSON::ParserError - message = 'Invalid JSON response received from CulqiGateway. Please contact CulqiGateway if you continue to receive this message.' - message += "(The raw response returned by the API was #{body.inspect})" - { - 'status' => 'N', - 'statusdescription' => message - } - end + JSON.parse(body) + rescue JSON::ParserError + message = 'Invalid JSON response received from CulqiGateway. Please contact CulqiGateway if you continue to receive this message.' + message += "(The raw response returned by the API was #{body.inspect})" + { + 'status' => 'N', + 'statusdescription' => message + } end def success_from(response) diff --git a/lib/active_merchant/billing/gateways/fat_zebra.rb b/lib/active_merchant/billing/gateways/fat_zebra.rb index aa64f4dad68..93d25df692a 100644 --- a/lib/active_merchant/billing/gateways/fat_zebra.rb +++ b/lib/active_merchant/billing/gateways/fat_zebra.rb @@ -172,17 +172,15 @@ def message_from(response) end def parse(response) - begin - JSON.parse(response) - rescue JSON::ParserError - msg = 'Invalid JSON response received from Fat Zebra. Please contact support@fatzebra.com.au if you continue to receive this message.' - msg += " (The raw response returned by the API was #{response.inspect})" - { - 'successful' => false, - 'response' => {}, - 'errors' => [msg] - } - end + JSON.parse(response) + rescue JSON::ParserError + msg = 'Invalid JSON response received from Fat Zebra. Please contact support@fatzebra.com.au if you continue to receive this message.' + msg += " (The raw response returned by the API was #{response.inspect})" + { + 'successful' => false, + 'response' => {}, + 'errors' => [msg] + } end def get_url(uri) diff --git a/lib/active_merchant/billing/gateways/kushki.rb b/lib/active_merchant/billing/gateways/kushki.rb index 14598237a74..c97bd2e6f38 100644 --- a/lib/active_merchant/billing/gateways/kushki.rb +++ b/lib/active_merchant/billing/gateways/kushki.rb @@ -186,15 +186,13 @@ def url(action, params) end def parse(body) - begin - JSON.parse(body) - rescue JSON::ParserError - message = 'Invalid JSON response received from KushkiGateway. Please contact KushkiGateway if you continue to receive this message.' - message += " (The raw response returned by the API was #{body.inspect})" - { - 'message' => message - } - end + JSON.parse(body) + rescue JSON::ParserError + message = 'Invalid JSON response received from KushkiGateway. Please contact KushkiGateway if you continue to receive this message.' + message += " (The raw response returned by the API was #{body.inspect})" + { + 'message' => message + } end def success_from(response) diff --git a/lib/active_merchant/billing/gateways/latitude19.rb b/lib/active_merchant/billing/gateways/latitude19.rb index b380d1a1c17..f430f16f852 100644 --- a/lib/active_merchant/billing/gateways/latitude19.rb +++ b/lib/active_merchant/billing/gateways/latitude19.rb @@ -302,27 +302,25 @@ def reverse_or_void(method, pgwTID, options={}) end def commit(endpoint, post) - begin - raw_response = ssl_post(url() + endpoint, post_data(post), headers) - response = parse(raw_response) - rescue ResponseError => e - raw_response = e.response.body - response_error(raw_response) - rescue JSON::ParserError - unparsable_response(raw_response) - else - success = success_from(response) - Response.new( - success, - message_from(response), - response, - authorization: success ? authorization_from(response, post[:method]) : nil, - avs_result: success ? avs_from(response) : nil, - cvv_result: success ? cvv_from(response) : nil, - error_code: success ? nil : error_from(response), - test: test? - ) - end + raw_response = ssl_post(url() + endpoint, post_data(post), headers) + response = parse(raw_response) + rescue ResponseError => e + raw_response = e.response.body + response_error(raw_response) + rescue JSON::ParserError + unparsable_response(raw_response) + else + success = success_from(response) + Response.new( + success, + message_from(response), + response, + authorization: success ? authorization_from(response, post[:method]) : nil, + avs_result: success ? avs_from(response) : nil, + cvv_result: success ? cvv_from(response) : nil, + error_code: success ? nil : error_from(response), + test: test? + ) end def headers @@ -392,18 +390,16 @@ def cvv_from(response) end def response_error(raw_response) - begin - response = parse(raw_response) - rescue JSON::ParserError - unparsable_response(raw_response) - else - return Response.new( - false, - message_from(response), - response, - :test => test? - ) - end + response = parse(raw_response) + rescue JSON::ParserError + unparsable_response(raw_response) + else + return Response.new( + false, + message_from(response), + response, + :test => test? + ) end def unparsable_response(raw_response) diff --git a/lib/active_merchant/billing/gateways/openpay.rb b/lib/active_merchant/billing/gateways/openpay.rb index 83c64de6258..fda4d7801ff 100644 --- a/lib/active_merchant/billing/gateways/openpay.rb +++ b/lib/active_merchant/billing/gateways/openpay.rb @@ -208,11 +208,9 @@ def error?(response) end def response_error(raw_response) - begin - parse(raw_response) - rescue JSON::ParserError - json_error(raw_response) - end + parse(raw_response) + rescue JSON::ParserError + json_error(raw_response) end def json_error(raw_response) diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb index ebc3a5bc959..11f8c4c8efa 100644 --- a/lib/active_merchant/billing/gateways/opp.rb +++ b/lib/active_merchant/billing/gateways/opp.rb @@ -318,11 +318,9 @@ def commit(post, authorization, options) end def parse(body) - begin - JSON.parse(body) - rescue JSON::ParserError - json_error(body) - end + JSON.parse(body) + rescue JSON::ParserError + json_error(body) end def json_error(body) diff --git a/lib/active_merchant/billing/gateways/pagarme.rb b/lib/active_merchant/billing/gateways/pagarme.rb index 77786486739..7dfabd6f56d 100644 --- a/lib/active_merchant/billing/gateways/pagarme.rb +++ b/lib/active_merchant/billing/gateways/pagarme.rb @@ -175,11 +175,9 @@ def commit(method, url, parameters, options = {}) end def response_error(raw_response) - begin - parse(raw_response) - rescue JSON::ParserError - json_error(raw_response) - end + parse(raw_response) + rescue JSON::ParserError + json_error(raw_response) end def json_error(raw_response) diff --git a/lib/active_merchant/billing/gateways/pay_junction_v2.rb b/lib/active_merchant/billing/gateways/pay_junction_v2.rb index f05d335b8e8..f453d1b5e75 100644 --- a/lib/active_merchant/billing/gateways/pay_junction_v2.rb +++ b/lib/active_merchant/billing/gateways/pay_junction_v2.rb @@ -154,17 +154,15 @@ def url(params={}) end def parse(body) - begin - JSON.parse(body) - rescue JSON::ParserError - message = 'Invalid JSON response received from PayJunctionV2Gateway. Please contact PayJunctionV2Gateway if you continue to receive this message.' - message += " (The raw response returned by the API was #{body.inspect})" - { - 'errors' => [{ - 'message' => message - }] - } - end + JSON.parse(body) + rescue JSON::ParserError + message = 'Invalid JSON response received from PayJunctionV2Gateway. Please contact PayJunctionV2Gateway if you continue to receive this message.' + message += " (The raw response returned by the API was #{body.inspect})" + { + 'errors' => [{ + 'message' => message + }] + } end def success_from(response) diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index 5d3dc1af6b5..bb5d16e085b 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -319,25 +319,23 @@ def add_payment_method_to_be_tokenized(post, payment_method) end def commit(action, params) - begin - raw_response = ssl_post(url, post_data(params), headers) - response = parse(raw_response) - rescue ResponseError => e - raw_response = e.response.body - response_error(raw_response) - rescue JSON::ParserError - unparsable_response(raw_response) - else - success = success_from(action, response) - Response.new( - success, - message_from(action, success, response), - response, - authorization: success ? authorization_from(action, response) : nil, - error_code: success ? nil : error_from(action, response), - test: test? - ) - end + raw_response = ssl_post(url, post_data(params), headers) + response = parse(raw_response) + rescue ResponseError => e + raw_response = e.response.body + response_error(raw_response) + rescue JSON::ParserError + unparsable_response(raw_response) + else + success = success_from(action, response) + Response.new( + success, + message_from(action, success, response), + response, + authorization: success ? authorization_from(action, response) : nil, + error_code: success ? nil : error_from(action, response), + test: test? + ) end def headers @@ -425,18 +423,16 @@ def error_from(action, response) end def response_error(raw_response) - begin - response = parse(raw_response) - rescue JSON::ParserError - unparsable_response(raw_response) - else - return Response.new( - false, - message_from('', false, response), - response, - :test => test? - ) - end + response = parse(raw_response) + rescue JSON::ParserError + unparsable_response(raw_response) + else + return Response.new( + false, + message_from('', false, response), + response, + :test => test? + ) end def unparsable_response(raw_response) diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb index ce4fec9a480..f26ed7eda57 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb @@ -276,11 +276,9 @@ def headers end def response_error(raw_response) - begin - parse(raw_response) - rescue JSON::ParserError - json_error(raw_response) - end + parse(raw_response) + rescue JSON::ParserError + json_error(raw_response) end def json_error(raw_response) diff --git a/lib/active_merchant/billing/gateways/securion_pay.rb b/lib/active_merchant/billing/gateways/securion_pay.rb index 4d3035d3336..c883c938230 100644 --- a/lib/active_merchant/billing/gateways/securion_pay.rb +++ b/lib/active_merchant/billing/gateways/securion_pay.rb @@ -205,11 +205,9 @@ def headers(options = {}) end def response_error(raw_response) - begin - parse(raw_response) - rescue JSON::ParserError - json_error(raw_response) - end + parse(raw_response) + rescue JSON::ParserError + json_error(raw_response) end def post_data(params) diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index d680dfaf353..4f6dd03fe3b 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -589,11 +589,9 @@ def success_from(response) end def response_error(raw_response) - begin - parse(raw_response) - rescue JSON::ParserError - json_error(raw_response) - end + parse(raw_response) + rescue JSON::ParserError + json_error(raw_response) end def json_error(raw_response) diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb index cc84e95f9c1..c8ba88f8b16 100644 --- a/lib/active_merchant/billing/gateways/visanet_peru.rb +++ b/lib/active_merchant/billing/gateways/visanet_peru.rb @@ -140,24 +140,22 @@ def split_authorization(authorization) end def commit(action, params, options={}) - begin - raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers) - response = parse(raw_response) - rescue ResponseError => e - raw_response = e.response.body - response_error(raw_response, options, action) - rescue JSON::ParserError - unparsable_response(raw_response) - else - Response.new( - success_from(response), - message_from(response, options, action), - response, - :test => test?, - :authorization => authorization_from(params, response, options), - :error_code => response['errorCode'] - ) - end + raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers) + response = parse(raw_response) + rescue ResponseError => e + raw_response = e.response.body + response_error(raw_response, options, action) + rescue JSON::ParserError + unparsable_response(raw_response) + else + Response.new( + success_from(response), + message_from(response, options, action), + response, + :test => test?, + :authorization => authorization_from(params, response, options), + :error_code => response['errorCode'] + ) end def headers @@ -211,20 +209,18 @@ def message_from(response, options, action) end def response_error(raw_response, options, action) - begin - response = parse(raw_response) - rescue JSON::ParserError - unparsable_response(raw_response) - else - return Response.new( - false, - message_from(response, options, action), - response, - :test => test?, - :authorization => response['transactionUUID'], - :error_code => response['errorCode'] - ) - end + response = parse(raw_response) + rescue JSON::ParserError + unparsable_response(raw_response) + else + return Response.new( + false, + message_from(response, options, action), + response, + :test => test?, + :authorization => response['transactionUUID'], + :error_code => response['errorCode'] + ) end def unparsable_response(raw_response) diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb index c8b985a334a..519bef0b41a 100644 --- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb @@ -191,11 +191,9 @@ def test? end def response_error(raw_response) - begin - parse(raw_response) - rescue JSON::ParserError - json_error(raw_response) - end + parse(raw_response) + rescue JSON::ParserError + json_error(raw_response) end def json_error(raw_response) diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb index 35faf61a2b4..7f1eceb5a08 100644 --- a/test/unit/gateways/optimal_payment_test.rb +++ b/test/unit/gateways/optimal_payment_test.rb @@ -172,23 +172,21 @@ def test_unsuccessful_request end def test_in_production_with_test_param_sends_request_to_test_server - begin - ActiveMerchant::Billing::Base.mode = :production - @gateway = OptimalPaymentGateway.new( - :account_number => '12345678', - :store_id => 'login', - :password => 'password', - :test => true - ) - @gateway.expects(:ssl_post).with('https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1', anything).returns(successful_purchase_response) - - assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_instance_of Response, response - assert_success response - assert response.test? - ensure - ActiveMerchant::Billing::Base.mode = :test - end + ActiveMerchant::Billing::Base.mode = :production + @gateway = OptimalPaymentGateway.new( + :account_number => '12345678', + :store_id => 'login', + :password => 'password', + :test => true + ) + @gateway.expects(:ssl_post).with('https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1', anything).returns(successful_purchase_response) + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_instance_of Response, response + assert_success response + assert response.test? + ensure + ActiveMerchant::Billing::Base.mode = :test end def test_avs_result_in_response From cf70eb87b41a987c54f807c3c15e9755a82f316e Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Thu, 20 Sep 2018 10:30:54 -0400 Subject: [PATCH 552/677] Rubocop: Layout/AlignParameters Set standard for indention. --- .rubocop.yml | 4 +++ .rubocop_todo.yml | 7 ----- lib/active_merchant/billing/check.rb | 4 +-- .../billing/gateways/banwire.rb | 8 ++--- .../billing/gateways/card_connect.rb | 4 +-- .../billing/gateways/cardknox.rb | 14 ++++----- .../billing/gateways/data_cash.rb | 30 +++++++++---------- lib/active_merchant/billing/gateways/epay.rb | 16 +++++----- .../billing/gateways/garanti.rb | 8 ++--- .../billing/gateways/iats_payments.rb | 2 +- .../billing/gateways/iridium.rb | 4 +-- .../billing/gateways/merchant_ware.rb | 6 ++-- .../gateways/merchant_ware_version_four.rb | 6 ++-- .../billing/gateways/modern_payments_cim.rb | 6 ++-- lib/active_merchant/billing/gateways/payex.rb | 10 +++---- .../billing/gateways/so_easy_pay.rb | 8 ++--- .../remote_barclaycard_smartpay_test.rb | 18 +++++------ .../gateways/remote_braintree_blue_test.rb | 4 +-- .../remote_merchant_ware_version_four_test.rb | 4 +-- .../gateways/remote_net_registry_test.rb | 4 +-- .../gateways/remote_pay_junction_test.rb | 14 ++++----- test/remote/gateways/remote_realex_test.rb | 14 ++++----- test/remote/gateways/remote_skipjack_test.rb | 4 +-- test/unit/gateways/banwire_test.rb | 14 ++++----- .../gateways/barclaycard_smartpay_test.rb | 8 ++--- test/unit/gateways/blue_pay_test.rb | 2 +- test/unit/gateways/epay_test.rb | 4 +-- test/unit/gateways/exact_test.rb | 2 +- test/unit/gateways/firstdata_e4_test.rb | 2 +- test/unit/gateways/orbital_test.rb | 10 +++---- test/unit/gateways/paybox_direct_test.rb | 4 +-- .../gateways/paypal/paypal_common_api_test.rb | 6 ++-- test/unit/gateways/paypal_express_test.rb | 18 +++++------ test/unit/gateways/worldpay_test.rb | 8 ++--- 34 files changed, 137 insertions(+), 140 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index bf6cd8ae418..e4141aba185 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,3 +23,7 @@ Metrics/ClassLength: Metrics/ModuleLength: Enabled: false + + +Layout/AlignParameters: + EnforcedStyle: with_fixed_indentation diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 46332a97372..fb937502eb4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -23,13 +23,6 @@ Gemspec/OrderedDependencies: Layout/AlignHash: Enabled: false -# Offense count: 275 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_parameter, with_fixed_indentation -Layout/AlignParameters: - Enabled: false - # Offense count: 113 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. diff --git a/lib/active_merchant/billing/check.rb b/lib/active_merchant/billing/check.rb index 561f7b54615..410359c41b6 100644 --- a/lib/active_merchant/billing/check.rb +++ b/lib/active_merchant/billing/check.rb @@ -7,8 +7,8 @@ module Billing #:nodoc: # You may use Check in place of CreditCard with any gateway that supports it. class Check < Model attr_accessor :first_name, :last_name, - :bank_name, :routing_number, :account_number, - :account_holder_type, :account_type, :number + :bank_name, :routing_number, :account_number, + :account_holder_type, :account_type, :number # Used for Canadian bank accounts attr_accessor :institution_number, :transit_number diff --git a/lib/active_merchant/billing/gateways/banwire.rb b/lib/active_merchant/billing/gateways/banwire.rb index d0e23302c00..99d3e683e34 100644 --- a/lib/active_merchant/billing/gateways/banwire.rb +++ b/lib/active_merchant/billing/gateways/banwire.rb @@ -90,10 +90,10 @@ def commit(money, parameters) end Response.new(success?(response), - response['message'], - response, - :test => test?, - :authorization => response['code_auth']) + response['message'], + response, + :test => test?, + :authorization => response['code_auth']) end def success?(response) diff --git a/lib/active_merchant/billing/gateways/card_connect.rb b/lib/active_merchant/billing/gateways/card_connect.rb index 40444cade8c..6c4e8064c55 100644 --- a/lib/active_merchant/billing/gateways/card_connect.rb +++ b/lib/active_merchant/billing/gateways/card_connect.rb @@ -141,8 +141,8 @@ def store(payment, options = {}) def unstore(authorization, options = {}) account_id, profile_id = authorization.split('|') commit('profile', {}, - verb: :delete, - path: "/#{profile_id}/#{account_id}/#{@options[:merchant_id]}") + verb: :delete, + path: "/#{profile_id}/#{account_id}/#{@options[:merchant_id]}") end def supports_scrubbing? diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb index f133cf33c41..0345173d4f6 100644 --- a/lib/active_merchant/billing/gateways/cardknox.rb +++ b/lib/active_merchant/billing/gateways/cardknox.rb @@ -284,13 +284,13 @@ def commit(action, source_type, parameters) response = parse(ssl_post(live_url, post_data(COMMANDS[source_type][action], parameters))) Response.new( - (response[:status] == 'Approved'), - message_from(response), - response, - authorization: authorization_from(response, source_type), - avs_result: { code: response[:avs_result_code] }, - cvv_result: response[:cvv_result_code] - ) + (response[:status] == 'Approved'), + message_from(response), + response, + authorization: authorization_from(response, source_type), + avs_result: { code: response[:avs_result_code] }, + cvv_result: response[:cvv_result_code] + ) end def message_from(response) diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb index 179aa12e194..1e31db78dc5 100644 --- a/lib/active_merchant/billing/gateways/data_cash.rb +++ b/lib/active_merchant/billing/gateways/data_cash.rb @@ -238,23 +238,23 @@ def add_credit_card(xml, credit_card, address) # a predefined one xml.tag! :ExtendedPolicy do xml.tag! :cv2_policy, - :notprovided => POLICY_REJECT, - :notchecked => POLICY_REJECT, - :matched => POLICY_ACCEPT, - :notmatched => POLICY_REJECT, - :partialmatch => POLICY_REJECT + :notprovided => POLICY_REJECT, + :notchecked => POLICY_REJECT, + :matched => POLICY_ACCEPT, + :notmatched => POLICY_REJECT, + :partialmatch => POLICY_REJECT xml.tag! :postcode_policy, - :notprovided => POLICY_ACCEPT, - :notchecked => POLICY_ACCEPT, - :matched => POLICY_ACCEPT, - :notmatched => POLICY_REJECT, - :partialmatch => POLICY_ACCEPT + :notprovided => POLICY_ACCEPT, + :notchecked => POLICY_ACCEPT, + :matched => POLICY_ACCEPT, + :notmatched => POLICY_REJECT, + :partialmatch => POLICY_ACCEPT xml.tag! :address_policy, - :notprovided => POLICY_ACCEPT, - :notchecked => POLICY_ACCEPT, - :matched => POLICY_ACCEPT, - :notmatched => POLICY_REJECT, - :partialmatch => POLICY_ACCEPT + :notprovided => POLICY_ACCEPT, + :notchecked => POLICY_ACCEPT, + :matched => POLICY_ACCEPT, + :notmatched => POLICY_REJECT, + :partialmatch => POLICY_ACCEPT end end end diff --git a/lib/active_merchant/billing/gateways/epay.rb b/lib/active_merchant/billing/gateways/epay.rb index 937589eda90..19ddbf5365a 100644 --- a/lib/active_merchant/billing/gateways/epay.rb +++ b/lib/active_merchant/billing/gateways/epay.rb @@ -164,16 +164,16 @@ def commit(action, params) if action == :authorize Response.new response['accept'].to_i == 1, - response['errortext'], - response, - :test => test?, - :authorization => response['tid'] + response['errortext'], + response, + :test => test?, + :authorization => response['tid'] else Response.new response['result'] == 'true', - messages(response['epay'], response['pbs']), - response, - :test => test?, - :authorization => params[:transaction] + messages(response['epay'], response['pbs']), + response, + :test => test?, + :authorization => params[:transaction] end end diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb index cd567c73d6c..eb77b969a47 100644 --- a/lib/active_merchant/billing/gateways/garanti.rb +++ b/lib/active_merchant/billing/gateways/garanti.rb @@ -223,10 +223,10 @@ def commit(money,request) success = success?(response) Response.new(success, - success ? 'Approved' : "Declined (Reason: #{response[:reason_code]} - #{response[:error_msg]} - #{response[:sys_err_msg]})", - response, - :test => test?, - :authorization => response[:order_id]) + success ? 'Approved' : "Declined (Reason: #{response[:reason_code]} - #{response[:error_msg]} - #{response[:sys_err_msg]})", + response, + :test => test?, + :authorization => response[:order_id]) end def parse(body) diff --git a/lib/active_merchant/billing/gateways/iats_payments.rb b/lib/active_merchant/billing/gateways/iats_payments.rb index dcc43765847..c2d4505dfb9 100644 --- a/lib/active_merchant/billing/gateways/iats_payments.rb +++ b/lib/active_merchant/billing/gateways/iats_payments.rb @@ -165,7 +165,7 @@ def creditcard_brand(brand) def commit(action, parameters) response = parse(ssl_post(url(action), post_data(action, parameters), - { 'Content-Type' => 'application/soap+xml; charset=utf-8'})) + { 'Content-Type' => 'application/soap+xml; charset=utf-8'})) Response.new( success_from(response), diff --git a/lib/active_merchant/billing/gateways/iridium.rb b/lib/active_merchant/billing/gateways/iridium.rb index 95c25379ec3..3723f287e43 100644 --- a/lib/active_merchant/billing/gateways/iridium.rb +++ b/lib/active_merchant/billing/gateways/iridium.rb @@ -377,8 +377,8 @@ def add_merchant_data(xml, options) def commit(request, options) requires!(options, :action) response = parse(ssl_post(test? ? self.test_url : self.live_url, request, - {'SOAPAction' => 'https://www.thepaymentgateway.net/' + options[:action], - 'Content-Type' => 'text/xml; charset=utf-8' })) + {'SOAPAction' => 'https://www.thepaymentgateway.net/' + options[:action], + 'Content-Type' => 'text/xml; charset=utf-8' })) success = response[:transaction_result][:status_code] == '0' message = response[:transaction_result][:message] diff --git a/lib/active_merchant/billing/gateways/merchant_ware.rb b/lib/active_merchant/billing/gateways/merchant_ware.rb index 3b8d4a20b0e..a6d73a2130c 100644 --- a/lib/active_merchant/billing/gateways/merchant_ware.rb +++ b/lib/active_merchant/billing/gateways/merchant_ware.rb @@ -293,9 +293,9 @@ def url(v4 = false) def commit(action, request, v4 = false) begin data = ssl_post(url(v4), request, - 'Content-Type' => 'text/xml; charset=utf-8', - 'SOAPAction' => soap_action(action, v4) - ) + 'Content-Type' => 'text/xml; charset=utf-8', + 'SOAPAction' => soap_action(action, v4) + ) response = parse(action, data) rescue ActiveMerchant::ResponseError => e response = parse_error(e.response) diff --git a/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb b/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb index 109d00fce00..4b1667334a4 100644 --- a/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +++ b/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb @@ -262,9 +262,9 @@ def url def commit(action, request) begin data = ssl_post(url, request, - 'Content-Type' => 'text/xml; charset=utf-8', - 'SOAPAction' => soap_action(action) - ) + 'Content-Type' => 'text/xml; charset=utf-8', + 'SOAPAction' => soap_action(action) + ) response = parse(action, data) rescue ActiveMerchant::ResponseError => e response = parse_error(e.response, action) diff --git a/lib/active_merchant/billing/gateways/modern_payments_cim.rb b/lib/active_merchant/billing/gateways/modern_payments_cim.rb index 7939387dd00..1f1e5beb04b 100644 --- a/lib/active_merchant/billing/gateways/modern_payments_cim.rb +++ b/lib/active_merchant/billing/gateways/modern_payments_cim.rb @@ -146,9 +146,9 @@ def url(action) def commit(action, params) data = ssl_post(url(action), build_request(action, params), - { 'Content-Type' =>'text/xml; charset=utf-8', - 'SOAPAction' => "#{xmlns(action)}#{action}" } - ) + { 'Content-Type' =>'text/xml; charset=utf-8', + 'SOAPAction' => "#{xmlns(action)}#{action}" } + ) response = parse(action, data) Response.new(successful?(action, response), message_from(action, response), response, diff --git a/lib/active_merchant/billing/gateways/payex.rb b/lib/active_merchant/billing/gateways/payex.rb index 3a63f379872..22478d87d2a 100644 --- a/lib/active_merchant/billing/gateways/payex.rb +++ b/lib/active_merchant/billing/gateways/payex.rb @@ -387,11 +387,11 @@ def commit(soap_action, request) } response = parse(ssl_post(url, request, headers)) Response.new(success?(response), - message_from(response), - response, - test: test?, - authorization: build_authorization(response) - ) + message_from(response), + response, + test: test?, + authorization: build_authorization(response) + ) end def build_authorization(response) diff --git a/lib/active_merchant/billing/gateways/so_easy_pay.rb b/lib/active_merchant/billing/gateways/so_easy_pay.rb index 5cc6eeaa1c6..7b5198b7be7 100644 --- a/lib/active_merchant/billing/gateways/so_easy_pay.rb +++ b/lib/active_merchant/billing/gateways/so_easy_pay.rb @@ -162,10 +162,10 @@ def commit(soap_action, soap, options) response_string = ssl_post(test? ? self.test_url : self.live_url, soap, headers) response = parse(response_string, soap_action) return Response.new(response['errorcode'] == '000', - response['errormessage'], - response, - :test => test?, - :authorization => response['transaction_id']) + response['errormessage'], + response, + :test => test?, + :authorization => response['transaction_id']) end def build_soap(request) diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index d605c62f4c1..eaa3f7288ae 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -97,9 +97,9 @@ def setup } @avs_credit_card = credit_card('4400000000000008', - :month => 8, - :year => 2018, - :verification_value => 737) + :month => 8, + :year => 2018, + :verification_value => 737) @avs_address = @options.clone @avs_address.update(billing_address: { @@ -131,24 +131,24 @@ def test_failed_purchase def test_successful_purchase_with_unusual_address response = @gateway.purchase(@amount, - @credit_card, - @options_with_alternate_address) + @credit_card, + @options_with_alternate_address) assert_success response assert_equal '[capture-received]', response.message end def test_successful_purchase_with_house_number_and_street response = @gateway.purchase(@amount, - @credit_card, - @options.merge(street: 'Top Level Drive', house_number: '100')) + @credit_card, + @options.merge(street: 'Top Level Drive', house_number: '100')) assert_success response assert_equal '[capture-received]', response.message end def test_successful_purchase_with_no_address response = @gateway.purchase(@amount, - @credit_card, - @options_with_no_address) + @credit_card, + @options_with_no_address) assert_success response assert_equal '[capture-received]', response.message end diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index 16ef4891a3d..27bf4083ff4 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -371,8 +371,8 @@ def test_successful_purchase_with_addresses def test_successful_purchase_with_three_d_secure_pass_thru three_d_secure_params = { eci: '05', cavv: 'cavv', xid: 'xid' } assert response = @gateway.purchase(@amount, @credit_card, - three_d_secure: three_d_secure_params - ) + three_d_secure: three_d_secure_params + ) assert_success response end diff --git a/test/remote/gateways/remote_merchant_ware_version_four_test.rb b/test/remote/gateways/remote_merchant_ware_version_four_test.rb index f1c538cc470..98bb62a166d 100644 --- a/test/remote/gateways/remote_merchant_ware_version_four_test.rb +++ b/test/remote/gateways/remote_merchant_ware_version_four_test.rb @@ -70,8 +70,8 @@ def test_purchase_and_reference_purchase assert purchase.authorization assert reference_purchase = @gateway.purchase(@amount, - purchase.authorization, - @reference_purchase_options) + purchase.authorization, + @reference_purchase_options) assert_success reference_purchase assert_not_nil reference_purchase.authorization end diff --git a/test/remote/gateways/remote_net_registry_test.rb b/test/remote/gateways/remote_net_registry_test.rb index c97ddc7dd91..aeadc59b83d 100644 --- a/test/remote/gateways/remote_net_registry_test.rb +++ b/test/remote/gateways/remote_net_registry_test.rb @@ -58,8 +58,8 @@ def test_successful_authorization_and_capture assert_match(/\A\d{6}\z/, response.authorization) response = @gateway.capture(@amount, - response.authorization, - :credit_card => @valid_creditcard) + response.authorization, + :credit_card => @valid_creditcard) assert_success response assert_equal 'approved', response.params['status'] end diff --git a/test/remote/gateways/remote_pay_junction_test.rb b/test/remote/gateways/remote_pay_junction_test.rb index bd0ff583733..79cea0c85b4 100644 --- a/test/remote/gateways/remote_pay_junction_test.rb +++ b/test/remote/gateways/remote_pay_junction_test.rb @@ -72,7 +72,7 @@ def test_successful_capture assert_success response assert_equal 'capture', response.params['posture'], 'Should be a capture' assert_equal auth.authorization, response.authorization, - 'Should maintain transaction ID across request' + 'Should maintain transaction ID across request' end def test_successful_credit @@ -94,7 +94,7 @@ def test_successful_void assert_success response assert_equal 'void', response.params['posture'], 'Should be a capture' assert_equal purchase.authorization, response.authorization, - 'Should maintain transaction ID across request' + 'Should maintain transaction ID across request' end def test_successful_instant_purchase @@ -111,17 +111,17 @@ def test_successful_instant_purchase assert_equal 'capture', response.params['posture'], 'Should be captured funds' assert_equal 'charge', response.params['transaction_action'] assert_not_equal purchase.authorization, response.authorization, - 'Should have recieved new transaction ID' + 'Should have recieved new transaction ID' assert_success response end def test_successful_recurring assert response = @gateway.recurring(AMOUNT, @credit_card, - :periodicity => :monthly, - :payments => 12, - :order_id => generate_unique_id[0..15] - ) + :periodicity => :monthly, + :payments => 12, + :order_id => generate_unique_id[0..15] + ) assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message assert_equal 'charge', response.params['transaction_action'] diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb index 5549f5715df..7cff61befad 100644 --- a/test/remote/gateways/remote_realex_test.rb +++ b/test/remote/gateways/remote_realex_test.rb @@ -351,13 +351,13 @@ def test_maps_avs_and_cvv_response_codes def test_transcript_scrubbing transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @visa_declined, - :order_id => generate_unique_id, - :description => 'Test Realex Purchase', - :billing_address => { - :zip => '90210', - :country => 'US' - } - ) + :order_id => generate_unique_id, + :description => 'Test Realex Purchase', + :billing_address => { + :zip => '90210', + :country => 'US' + } + ) end clean_transcript = @gateway.scrub(transcript) diff --git a/test/remote/gateways/remote_skipjack_test.rb b/test/remote/gateways/remote_skipjack_test.rb index 2c8d070dcbf..d8ec78f732b 100644 --- a/test/remote/gateways/remote_skipjack_test.rb +++ b/test/remote/gateways/remote_skipjack_test.rb @@ -7,8 +7,8 @@ def setup @gateway = SkipJackGateway.new(fixtures(:skip_jack)) @credit_card = credit_card('4445999922225', - :verification_value => '999' - ) + :verification_value => '999' + ) @amount = 100 diff --git a/test/unit/gateways/banwire_test.rb b/test/unit/gateways/banwire_test.rb index e7466ba51bc..7f65c6c7277 100644 --- a/test/unit/gateways/banwire_test.rb +++ b/test/unit/gateways/banwire_test.rb @@ -9,9 +9,9 @@ def setup :currency => 'MXN') @credit_card = credit_card('5204164299999999', - :month => 11, - :year => 2012, - :verification_value => '999') + :month => 11, + :year => 2012, + :verification_value => '999') @amount = 100 @options = { @@ -22,10 +22,10 @@ def setup } @amex_credit_card = credit_card('375932134599999', - :month => 3, - :year => 2017, - :first_name => 'Banwire', - :last_name => 'Test Card') + :month => 3, + :year => 2017, + :first_name => 'Banwire', + :last_name => 'Test Card') @amex_options = { :order_id => '2', :email => 'test@email.com', diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb index bac4a277b3e..4763dfa6813 100644 --- a/test/unit/gateways/barclaycard_smartpay_test.rb +++ b/test/unit/gateways/barclaycard_smartpay_test.rb @@ -128,8 +128,8 @@ def test_successful_authorize_with_alternate_address def test_successful_authorize_with_house_number_and_street response = stub_comms do @gateway.authorize(@amount, - @credit_card, - @options_with_house_number_and_street) + @credit_card, + @options_with_house_number_and_street) end.check_request do |endpoint, data, headers| assert_match(/billingAddress.street=Top\+Level\+Drive/, data) assert_match(/billingAddress.houseNumberOrName=1000/, data) @@ -143,8 +143,8 @@ def test_successful_authorize_with_house_number_and_street def test_successful_authorize_with_shipping_house_number_and_street response = stub_comms do @gateway.authorize(@amount, - @credit_card, - @options_with_shipping_house_number_and_shipping_street) + @credit_card, + @options_with_shipping_house_number_and_shipping_street) end.check_request do |endpoint, data, headers| assert_match(/billingAddress.street=Top\+Level\+Drive/, data) assert_match(/billingAddress.houseNumberOrName=1000/, data) diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb index 811b121450e..713b387278c 100644 --- a/test/unit/gateways/blue_pay_test.rb +++ b/test/unit/gateways/blue_pay_test.rb @@ -183,7 +183,7 @@ def get_msg(query) end assert_equal 'CVV does not match', get_msg('STATUS=2&CVV2=N&AVS=A&MESSAGE=FAILURE') assert_equal 'Street address matches, but 5-digit and 9-digit postal code do not match.', - get_msg('STATUS=2&CVV2=M&AVS=A&MESSAGE=FAILURE') + get_msg('STATUS=2&CVV2=M&AVS=A&MESSAGE=FAILURE') end # Recurring Billing Unit Tests diff --git a/test/unit/gateways/epay_test.rb b/test/unit/gateways/epay_test.rb index 462ecf1cbf4..6c4554f5969 100644 --- a/test/unit/gateways/epay_test.rb +++ b/test/unit/gateways/epay_test.rb @@ -26,7 +26,7 @@ def test_failed_purchase assert response = @gateway.authorize(100, @credit_card) assert_failure response assert_equal 'The payment was declined. Try again in a moment or try with another credit card.', - response.message + response.message end def test_invalid_characters_in_response @@ -35,7 +35,7 @@ def test_invalid_characters_in_response assert response = @gateway.authorize(100, @credit_card) assert_failure response assert_equal 'The payment was declined of unknown reasons. For more information contact the bank. E.g. try with another credit card.<br />Denied - Call your bank for information', - response.message + response.message end def test_failed_response_on_purchase diff --git a/test/unit/gateways/exact_test.rb b/test/unit/gateways/exact_test.rb index 0c33fd415c3..1566816809e 100644 --- a/test/unit/gateways/exact_test.rb +++ b/test/unit/gateways/exact_test.rb @@ -52,7 +52,7 @@ def test_failed_purchase def test_expdate assert_equal( '%02d%s' % [ @credit_card.month, @credit_card.year.to_s[-2..-1] ], - @gateway.send(:expdate, @credit_card) ) + @gateway.send(:expdate, @credit_card) ) end def test_soap_fault diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb index 5a5258ba58e..a970aaccff8 100755 --- a/test/unit/gateways/firstdata_e4_test.rb +++ b/test/unit/gateways/firstdata_e4_test.rb @@ -64,7 +64,7 @@ def test_successful_purchase_with_specified_currency_and_token options_with_specified_currency = @options.merge({currency: 'GBP'}) @gateway.expects(:ssl_post).returns(successful_purchase_with_specified_currency_response) assert response = @gateway.purchase(@amount, '8938737759041111;visa;Longbob;Longsen;9;2014', - options_with_specified_currency) + options_with_specified_currency) assert_success response assert_equal 'GBP', response.params['currency'] end diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index bc8e811be61..8bcffb2ccc5 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -181,8 +181,8 @@ def test_truncates_address def test_truncates_name card = credit_card('4242424242424242', - :first_name => 'John', - :last_name => 'Jacob Jingleheimer Smith-Jones') + :first_name => 'John', + :last_name => 'Jacob Jingleheimer Smith-Jones') response = stub_comms do @gateway.purchase(50, card, :order_id => 1, :billing_address => address) @@ -270,8 +270,8 @@ def test_address_format def test_truncates_by_byte_length card = credit_card('4242424242424242', - :first_name => 'John', - :last_name => 'Jacob Jingleheimer Smith-Jones') + :first_name => 'John', + :last_name => 'Jacob Jingleheimer Smith-Jones') long_address = address( :address1 => '456 Stréêt Name is Really Long', @@ -689,7 +689,7 @@ def test_cc_account_num_is_removed_from_response assert_deprecation_warning do response = @gateway.add_customer_profile(credit_card, - :billing_address => address) + :billing_address => address) end assert_instance_of Response, response diff --git a/test/unit/gateways/paybox_direct_test.rb b/test/unit/gateways/paybox_direct_test.rb index 89f5f7d435b..e6e29d1ad93 100644 --- a/test/unit/gateways/paybox_direct_test.rb +++ b/test/unit/gateways/paybox_direct_test.rb @@ -10,8 +10,8 @@ def setup ) @credit_card = credit_card('1111222233334444', - :brand => 'visa' - ) + :brand => 'visa' + ) @amount = 100 @options = { diff --git a/test/unit/gateways/paypal/paypal_common_api_test.rb b/test/unit/gateways/paypal/paypal_common_api_test.rb index 7428848a955..2f53c97fad3 100644 --- a/test/unit/gateways/paypal/paypal_common_api_test.rb +++ b/test/unit/gateways/paypal/paypal_common_api_test.rb @@ -153,9 +153,9 @@ def test_build_reference_transaction_request def test_build_reference_transaction_gets_ip request = REXML::Document.new(@gateway.send(:build_reference_transaction_request, - 100, - :reference_id => 'id', - :ip => '127.0.0.1')) + 100, + :reference_id => 'id', + :ip => '127.0.0.1')) assert_equal '100', REXML::XPath.first(request, '//n2:PaymentDetails/n2:OrderTotal').text assert_equal 'id', REXML::XPath.first(request, '//DoReferenceTransactionReq/DoReferenceTransactionRequest/n2:DoReferenceTransactionRequestDetails/n2:ReferenceID').text assert_equal '127.0.0.1', REXML::XPath.first(request, '//DoReferenceTransactionReq/DoReferenceTransactionRequest/n2:DoReferenceTransactionRequestDetails/n2:IPAddress').text diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb index 6ac936f3023..445dace38f4 100644 --- a/test/unit/gateways/paypal_express_test.rb +++ b/test/unit/gateways/paypal_express_test.rb @@ -508,18 +508,18 @@ def test_reference_transaction_requires_fields def test_error_code_for_single_error @gateway.expects(:ssl_post).returns(response_with_error) response = @gateway.setup_authorization(100, - :return_url => 'http://example.com', - :cancel_return_url => 'http://example.com' - ) + :return_url => 'http://example.com', + :cancel_return_url => 'http://example.com' + ) assert_equal '10736', response.params['error_codes'] end def test_ensure_only_unique_error_codes @gateway.expects(:ssl_post).returns(response_with_duplicate_errors) response = @gateway.setup_authorization(100, - :return_url => 'http://example.com', - :cancel_return_url => 'http://example.com' - ) + :return_url => 'http://example.com', + :cancel_return_url => 'http://example.com' + ) assert_equal '10736' , response.params['error_codes'] end @@ -527,9 +527,9 @@ def test_ensure_only_unique_error_codes def test_error_codes_for_multiple_errors @gateway.expects(:ssl_post).returns(response_with_errors) response = @gateway.setup_authorization(100, - :return_url => 'http://example.com', - :cancel_return_url => 'http://example.com' - ) + :return_url => 'http://example.com', + :cancel_return_url => 'http://example.com' + ) assert_equal ['10736', '10002'] , response.params['error_codes'].split(',') end diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index d73a991418f..37fcef0e548 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -209,7 +209,7 @@ def test_capture_time if data =~ /capture/ t = Time.now assert_tag_with_attributes 'date', - {'dayOfMonth' => t.day.to_s, 'month' => t.month.to_s, 'year' => t.year.to_s}, + {'dayOfMonth' => t.day.to_s, 'month' => t.month.to_s, 'year' => t.year.to_s}, data end end.respond_with(successful_inquiry_response, successful_capture_response) @@ -220,7 +220,7 @@ def test_amount_handling @gateway.authorize(100, @credit_card, @options) end.check_request do |endpoint, data, headers| assert_tag_with_attributes 'amount', - {'value' => '100', 'exponent' => '2', 'currencyCode' => 'GBP'}, + {'value' => '100', 'exponent' => '2', 'currencyCode' => 'GBP'}, data end.respond_with(successful_authorize_response) end @@ -230,7 +230,7 @@ def test_currency_exponent_handling @gateway.authorize(10000, @credit_card, @options.merge(currency: :JPY)) end.check_request do |endpoint, data, headers| assert_tag_with_attributes 'amount', - {'value' => '100', 'exponent' => '0', 'currencyCode' => 'JPY'}, + {'value' => '100', 'exponent' => '0', 'currencyCode' => 'JPY'}, data end.respond_with(successful_authorize_response) @@ -238,7 +238,7 @@ def test_currency_exponent_handling @gateway.authorize(10000, @credit_card, @options.merge(currency: :OMR)) end.check_request do |endpoint, data, headers| assert_tag_with_attributes 'amount', - {'value' => '10000', 'exponent' => '3', 'currencyCode' => 'OMR'}, + {'value' => '10000', 'exponent' => '3', 'currencyCode' => 'OMR'}, data end.respond_with(successful_authorize_response) end From 385ddd19eab4caf373e90dabbb7daae9b75f5539 Mon Sep 17 00:00:00 2001 From: David Whitby <whitby3001@gmail.com> Date: Mon, 27 Mar 2017 12:57:15 +0100 Subject: [PATCH 553/677] Stripe: support reason for voiding Closes #2378 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/stripe.rb | 1 + test/remote/gateways/remote_stripe_test.rb | 11 +++++++++++ test/unit/gateways/stripe_test.rb | 9 +++++++++ 4 files changed, 22 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 1129d82ac34..29d3b368ef3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * Add ROU alpha3 code for Romania [dtykocki] #2989 * [POSSIBLE BREAKAGE] Drop support for Solo and Switch cards [bpollack] #2991 * Add support for Carnet cards [bpollack] #2992 +* Stripe: support a reason for voiding a transaction [whitby3001] #2378 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 4f6dd03fe3b..2e80ab70041 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -136,6 +136,7 @@ def capture(money, authorization, options = {}) def void(identification, options = {}) post = {} post[:metadata] = options[:metadata] if options[:metadata] + post[:reason] = options[:reason] if options[:reason] post[:expand] = [:charge] commit(:post, "charges/#{CGI.escape(identification)}/refunds", post, options) end diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb index 3d34ae2c75a..cf1948cb7a0 100644 --- a/test/remote/gateways/remote_stripe_test.rb +++ b/test/remote/gateways/remote_stripe_test.rb @@ -194,6 +194,17 @@ def test_successful_void_with_metadata assert_equal '123', void.params['metadata']['test_metadata'] end + def test_successful_void_with_reason + assert response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + assert response.authorization + + assert void = @gateway.void(response.authorization, reason: 'fraudulent') + assert void.test? + assert_success void + assert_equal 'fraudulent', void.params['reason'] + end + def test_unsuccessful_void assert void = @gateway.void('active_merchant_fake_charge') assert_failure void diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index 4839433bd48..8708f9b4867 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -537,6 +537,15 @@ def test_successful_void_with_metadata assert_success response end + def test_successful_void_with_reason + @gateway.expects(:ssl_request).with do |_, _, post, _| + post.include?('reason=fraudulent') + end.returns(successful_purchase_response(true)) + + assert response = @gateway.void('ch_test_charge', {reason: 'fraudulent'}) + assert_success response + end + def test_successful_refund @gateway.expects(:ssl_request).returns(successful_partially_refunded_response) From 3ca6b05fd192711a5b81c26611cd370e31d3cab5 Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Fri, 21 Sep 2018 06:21:05 -0400 Subject: [PATCH 554/677] Payeezy: Add reversal_id in support of timeout reversals The `reversal_id` field can be added to any auth or purchase transaction. In the event of a timeout, the same `reversal_id` can then be specified via `void` to reverse the transaction. According to Payeezy's documentation, this API is only available in production, but the remote tests demonstrate that the API may function on the sandbox. Ref: https://developer.payeezy.com/payeezy-api/apis/post/transactions-1 Unit: 33 tests, 156 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 33 tests, 131 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/payeezy.rb | 19 +++++++++--- test/remote/gateways/remote_payeezy_test.rb | 31 +++++++++++++++++++ test/unit/gateways/payeezy_test.rb | 19 ++++++++++-- 4 files changed, 64 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 29d3b368ef3..c0ecdcfe057 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * [POSSIBLE BREAKAGE] Drop support for Solo and Switch cards [bpollack] #2991 * Add support for Carnet cards [bpollack] #2992 * Stripe: support a reason for voiding a transaction [whitby3001] #2378 +* Payeezy: Add reversal_id in support of timeout reversals [dtykocki] #2997 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index fb8609b526a..dad7cbebd69 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -34,6 +34,7 @@ def purchase(amount, payment_method, options = {}) params = payment_method.is_a?(String) ? { transaction_type: 'recurring' } : { transaction_type: 'purchase' } add_invoice(params, options) + add_reversal_id(params, options) add_payment_method(params, payment_method, options) add_address(params, options) add_amount(params, amount, options) @@ -46,6 +47,7 @@ def authorize(amount, payment_method, options = {}) params = {transaction_type: 'authorize'} add_invoice(params, options) + add_reversal_id(params, options) add_payment_method(params, payment_method, options) add_address(params, options) add_amount(params, amount, options) @@ -84,7 +86,7 @@ def store(payment_method, options = {}) def void(authorization, options = {}) params = {transaction_type: 'void'} - add_authorization_info(params, authorization) + add_authorization_info(params, authorization, options) add_amount(params, amount_from_authorization(authorization), options) commit(params, options) @@ -123,15 +125,24 @@ def add_invoice(params, options) params[:merchant_ref] = options[:order_id] end + def add_reversal_id(params, options) + params[:reversal_id] = options[:reversal_id] if options[:reversal_id] + end + def amount_from_authorization(authorization) authorization.split('|').last.to_i end - def add_authorization_info(params, authorization) + def add_authorization_info(params, authorization, options = {}) transaction_id, transaction_tag, method, _ = authorization.split('|') - params[:transaction_id] = transaction_id - params[:transaction_tag] = transaction_tag params[:method] = (method == 'token') ? 'credit_card' : method + + if options[:reversal_id] + params[:reversal_id] = options[:reversal_id] + else + params[:transaction_id] = transaction_id + params[:transaction_tag] = transaction_tag + end end def add_creditcard_for_tokenization(params, payment_method, options) diff --git a/test/remote/gateways/remote_payeezy_test.rb b/test/remote/gateways/remote_payeezy_test.rb index 497332317ac..2580c070dbe 100644 --- a/test/remote/gateways/remote_payeezy_test.rb +++ b/test/remote/gateways/remote_payeezy_test.rb @@ -7,6 +7,7 @@ def setup @bad_credit_card = credit_card('4111111111111113') @check = check @amount = 100 + @reversal_id = "REV-#{SecureRandom.random_number(1000000)}" @options = { :billing_address => address, :merchant_ref => 'Store Purchase', @@ -178,6 +179,36 @@ def test_successful_void assert_equal 'Transaction Normal - Approved', void.message end + def test_successful_auth_void_with_reversal_id + auth = @gateway.authorize(@amount, @credit_card, @options.merge(reversal_id: @reversal_id)) + assert_success auth + + assert void = @gateway.void(auth.authorization, reversal_id: @reversal_id) + assert_success void + assert_equal 'Transaction Normal - Approved', void.message + end + + def test_successful_void_purchase_with_reversal_id + response = @gateway.purchase(@amount, @credit_card, @options.merge(reversal_id: @reversal_id)) + assert_success response + + assert void = @gateway.void(response.authorization, reversal_id: @reversal_id) + assert_success void + assert_equal 'Transaction Normal - Approved', void.message + end + + def test_successful_void_with_stored_card_and_reversal_id + response = @gateway.store(@credit_card, @options) + assert_success response + + auth = @gateway.authorize(@amount, response.authorization, @options.merge(reversal_id: @reversal_id)) + assert_success auth + + assert void = @gateway.void(auth.authorization, reversal_id: @reversal_id) + assert_success void + assert_equal 'Transaction Normal - Approved', void.message + end + def test_successful_void_with_stored_card response = @gateway.store(@credit_card, @options) assert_success response diff --git a/test/unit/gateways/payeezy_test.rb b/test/unit/gateways/payeezy_test.rb index 87c61922b34..6d95954c196 100644 --- a/test/unit/gateways/payeezy_test.rb +++ b/test/unit/gateways/payeezy_test.rb @@ -16,6 +16,7 @@ def setup :ta_token => '123' } @authorization = 'ET1700|106625152|credit_card|4738' + @reversal_id = SecureRandom.random_number(1000000).to_s end def test_invalid_credentials @@ -174,11 +175,25 @@ def test_failed_refund end def test_successful_void - @gateway.expects(:ssl_post).returns(successful_void_response) - assert response = @gateway.void(@authorization, @options) + response = stub_comms do + @gateway.void(@authorization, @options) + end.check_request do |endpoint, data, headers| + json = '{"transaction_type":"void","method":"credit_card","transaction_tag":"106625152","currency_code":"USD","amount":"4738"}' + assert_match json, data + end.respond_with(successful_void_response) + assert_success response end + def test_successful_void_with_reversal_id + stub_comms do + @gateway.void(@authorization, @options.merge(reversal_id: @reversal_id)) + end.check_request do |endpoint, data, headers| + json = "{\"transaction_type\":\"void\",\"method\":\"credit_card\",\"reversal_id\":\"#{@reversal_id}\",\"currency_code\":\"USD\",\"amount\":\"4738\"}" + assert_match json, data + end.respond_with(successful_void_response) + end + def test_failed_void @gateway.expects(:ssl_post).raises(failed_void_response) assert response = @gateway.void(@authorization, @options) From 5850497a01d7d08dbfddcaf00f25659196ff3fde Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 20 Sep 2018 16:00:39 -0400 Subject: [PATCH 555/677] Stripe: handle much more complicated post structures Previously, we couldn't handle Stripe endpoints that had arrays of hashes, among other things. This fixes that. In the process, this also switches from implicit to explicit array indices, which allows supporting an upcoming feature. Unit: 129 tests, 682 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 65 tests, 298 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- .../billing/gateways/stripe.rb | 34 +++++++++++++------ test/unit/gateways/stripe_test.rb | 18 +++++----- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 2e80ab70041..5aeaadc7d35 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -491,25 +491,39 @@ def parse(body) def post_data(params) return nil unless params + flatten_params([], params).join('&') + end - params.map do |key, value| + def flatten_params(flattened, params, prefix = nil) + params.each do |key, value| next if value != false && value.blank? + flattened_key = prefix.nil? ? key : "#{prefix}[#{key}]" if value.is_a?(Hash) - h = {} - value.each do |k, v| - h["#{key}[#{k}]"] = v unless v.blank? - end - post_data(h) + flatten_params(flattened, value, flattened_key) elsif value.is_a?(Array) - value.map { |v| "#{key}[]=#{CGI.escape(v.to_s)}" }.join('&') + flatten_array(flattened, value, flattened_key) + else + flattened << "#{flattened_key}=#{CGI.escape(value.to_s)}" + end + end + flattened + end + + def flatten_array(flattened, array, prefix) + array.each_with_index do |item, idx| + key = "#{prefix}[#{idx}]" + if item.is_a?(Hash) + flatten_params(flattened, item, key) + elsif item.is_a?(Array) + flatten_array(flattened, item, key) else - "#{key}=#{CGI.escape(value.to_s)}" + flattened << "#{key}=#{CGI.escape(item.to_s)}" end - end.compact.join('&') + end end def headers(options = {}) - key = options[:key] || @api_key + key = options[:key] || @api_key idempotency_key = options[:idempotency_key] headers = { diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index 8708f9b4867..0315822770e 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -501,7 +501,7 @@ def test_successful_void def test_void_contains_charge_expand @gateway.expects(:ssl_request).with do |_, _, post, _| - post.include?('expand[]=charge') + post.include?('expand[0]=charge') end.returns(successful_purchase_response(true)) assert response = @gateway.void('ch_test_charge') @@ -511,7 +511,8 @@ def test_void_contains_charge_expand def test_void_with_additional_expand_contains_two_expands @gateway.expects(:ssl_request).with do |_, _, post, _| parsed = CGI.parse(post) - parsed['expand[]'].sort == ['balance_transaction', 'charge'].sort + parsed['expand[0]'] = 'balance_transaction' + parsed['expand[1]'] = 'charge' end.returns(successful_purchase_response(true)) assert response = @gateway.void('ch_test_charge', expand: :balance_transaction) @@ -521,7 +522,7 @@ def test_void_with_additional_expand_contains_two_expands def test_void_with_expand_charge_only_sends_one_charge_expand @gateway.expects(:ssl_request).with do |_, _, post, _| parsed = CGI.parse(post) - parsed['expand[]'] == ['charge'] + parsed['expand[0]'] == ['charge'] end.returns(successful_purchase_response(true)) assert response = @gateway.void('ch_test_charge', expand: ['charge']) @@ -573,7 +574,7 @@ def test_successful_refund_with_refund_application_fee def test_refund_contains_charge_expand @gateway.expects(:ssl_request).with do |_, _, post, _| - post.include?('expand[]=charge') + post.include?('expand[0]=charge') end.returns(successful_partially_refunded_response) assert response = @gateway.refund(@refund_amount, 'ch_test_charge') @@ -583,7 +584,8 @@ def test_refund_contains_charge_expand def test_refund_with_additional_expand_contains_two_expands @gateway.expects(:ssl_request).with do |_, _, post, _| parsed = CGI.parse(post) - parsed['expand[]'].sort == ['balance_transaction', 'charge'].sort + parsed['expand[0]'] = 'balance_transaction' + parsed['expand[1]'] = 'charge' end.returns(successful_partially_refunded_response) assert response = @gateway.refund(@refund_amount, 'ch_test_charge', expand: :balance_transaction) @@ -593,7 +595,7 @@ def test_refund_with_additional_expand_contains_two_expands def test_refund_with_expand_charge_only_sends_one_charge_expand @gateway.expects(:ssl_request).with do |_, _, post, _| parsed = CGI.parse(post) - parsed['expand[]'] == ['charge'] + parsed['expand[0]'] == ['charge'] end.returns(successful_partially_refunded_response) assert response = @gateway.refund(@refund_amount, 'ch_test_charge', expand: ['charge']) @@ -1152,7 +1154,7 @@ def generate_options_should_allow_key def test_passing_expand_parameters @gateway.expects(:ssl_request).with do |method, url, post, headers| - post.include?('expand[]=balance_transaction') + post.include?('expand[0]=balance_transaction') end.returns(successful_authorization_response) @options.merge!(:expand => :balance_transaction) @@ -1162,7 +1164,7 @@ def test_passing_expand_parameters def test_passing_expand_parameters_as_array @gateway.expects(:ssl_request).with do |method, url, post, headers| - post.include?('expand[]=balance_transaction&expand[]=customer') + post.include?('expand[0]=balance_transaction&expand[1]=customer') end.returns(successful_authorization_response) @options.merge!(:expand => [:balance_transaction, :customer]) From 3348aca387ebbf646f59d015af3d0fd808ef0258 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 20 Sep 2018 17:51:00 -0400 Subject: [PATCH 556/677] Stripe: add full Level 3 support Unit: 129 tests, 693 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 66 tests, 305 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/stripe.rb | 32 +++++++++++++++ test/remote/gateways/remote_stripe_test.rb | 32 +++++++++++++++ test/unit/gateways/stripe_test.rb | 40 +++++++++++++++++++ 4 files changed, 105 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index c0ecdcfe057..7394938edba 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * Add support for Carnet cards [bpollack] #2992 * Stripe: support a reason for voiding a transaction [whitby3001] #2378 * Payeezy: Add reversal_id in support of timeout reversals [dtykocki] #2997 +* Stripe: support Level 3 transaction fields [bpollack] #2996 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 5aeaadc7d35..49c7077a2a8 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -324,6 +324,7 @@ def create_post_for_auth_or_purchase(money, payment, options) add_application_fee(post, options) add_exchange_rate(post, options) add_destination(post, options) + add_level_three(post, options) post end @@ -349,6 +350,21 @@ def add_destination(post, options) end end + def add_level_three(post, options) + level_three = {} + + copy_when_present(level_three, [:merchant_reference], options) + copy_when_present(level_three, [:customer_reference], options) + copy_when_present(level_three, [:shipping_address_zip], options) + copy_when_present(level_three, [:shipping_from_zip], options) + copy_when_present(level_three, [:shipping_amount], options) + copy_when_present(level_three, [:line_items], options) + + unless level_three.empty? + post[:level3] = level_three + end + end + def add_expand_parameters(post, options) post[:expand] ||= [] post[:expand].concat(Array.wrap(options[:expand]).map(&:to_sym)).uniq! @@ -695,6 +711,22 @@ def auth_minimum_amount(options) return 100 unless options[:currency] return MINIMUM_AUTHORIZE_AMOUNTS[options[:currency].upcase] || 100 end + + def copy_when_present(dest, dest_path, source, source_path = nil) + source_path ||= dest_path + source_path.each do |key| + return nil unless source[key] + source = source[key] + end + + if source + dest_path.first(dest_path.size - 1).each do |key| + dest[key] ||= {} + dest = dest[key] + end + dest[dest_path.last] = source + end + end end end end diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb index cf1948cb7a0..cbc94e8ab52 100644 --- a/test/remote/gateways/remote_stripe_test.rb +++ b/test/remote/gateways/remote_stripe_test.rb @@ -90,6 +90,38 @@ def test_successful_purchase_with_destination_and_amount assert_equal 'wow@example.com', response.params['metadata']['email'] end + def test_successful_purchase_with_level3_data + @options[:merchant_reference] = 123 + @options[:customer_reference] = 456 + @options[:shipping_address_zip] = 98765 + @options[:shipping_from_zip] = 54321 + @options[:shipping_amount] = 10 + @options[:line_items] = [ + { + 'product_code' => 1234, + 'product_description' => 'An item', + 'unit_cost' => 15, + 'quantity' => 2, + 'tax_amount' => 0 + }, + { + 'product_code' => 999, + 'product_description' => 'A totes different item', + 'tax_amount' => 10, + 'unit_cost' => 50, + 'quantity' => 1, + } + ] + + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'charge', response.params['object'] + assert_equal response.authorization, response.params['id'] + assert response.params['paid'] + assert_equal 'ActiveMerchant Test Purchase', response.params['description'] + assert_equal 'wow@example.com', response.params['metadata']['email'] + end + def test_unsuccessful_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index 0315822770e..f6a99162f3b 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -429,6 +429,46 @@ def test_successful_purchase_with_apple_pay_token_exchange assert response.test? end + def test_successful_purchase_with_level3_data + @gateway.expects(:add_creditcard) + + @options[:merchant_reference] = 123 + @options[:customer_reference] = 456 + @options[:shipping_address_zip] = 98765 + @options[:shipping_from_zip] = 54321 + @options[:shipping_amount] = 40 + @options[:line_items] = [ + { + 'product_code' => 1234, + 'product_description' => 'An item', + 'unit_cost' => 60, + 'quantity' => 7, + 'tax_amount' => 0 + }, + { + 'product_code' => 999, + 'tax_amount' => 888 + } + ] + + response = stub_comms(@gateway, :ssl_request) do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |_method, endpoint, data, _headers| + if %r{/charges} =~ endpoint + assert_match('level3[merchant_reference]=123', data) + assert_match('level3[customer_reference]=456', data) + assert_match('level3[shipping_address_zip]=98765', data) + assert_match('level3[shipping_amount]=40', data) + assert_match('level3[shipping_from_zip]=54321', data) + assert_match('level3[line_items][0][product_description]=An+item', data) + assert_match('level3[line_items][1][product_code]=999', data) + end + end.respond_with(successful_purchase_response) + + assert_success response + assert response.test? + end + def test_amount_localization @gateway.expects(:ssl_request).returns(successful_purchase_response(true)) @gateway.expects(:post_data).with do |params| From d4d927e42a6ac7c0ce15be7e9a14f6c2f00a0ff5 Mon Sep 17 00:00:00 2001 From: David Whitby <whitby3001@gmail.com> Date: Mon, 27 Mar 2017 16:49:52 +0100 Subject: [PATCH 557/677] Stripe: support shipping info in purchases Closes #2379 --- CHANGELOG | 1 + .../billing/gateways/stripe.rb | 23 +++++++++++++++++++ test/remote/gateways/remote_stripe_test.rb | 18 +++++++++++++++ test/unit/gateways/stripe_test.rb | 20 +++++++++++++++- 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7394938edba..66a94d43280 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * Stripe: support a reason for voiding a transaction [whitby3001] #2378 * Payeezy: Add reversal_id in support of timeout reversals [dtykocki] #2997 * Stripe: support Level 3 transaction fields [bpollack] #2996 +* Stripe: support passing shipping info for purchases [whitby3001] #2379 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 49c7077a2a8..0424cde6b42 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -321,6 +321,7 @@ def create_post_for_auth_or_purchase(money, payment, options) end add_metadata(post, options) + add_shipping_info(post, options) add_application_fee(post, options) add_exchange_rate(post, options) add_destination(post, options) @@ -489,6 +490,28 @@ def add_emv_metadata(post, creditcard) post[:metadata] ||= {} post[:metadata][:card_read_method] = creditcard.read_method if creditcard.respond_to?(:read_method) end + + def add_shipping_info(post, options = {}) + post[:shipping] = {} + + if address = options[:shipping_address] + address_params = {} + address_params[:line1] = address[:address1] if address[:address1] + address_params[:line2] = address[:address2] if address[:address2] + address_params[:city] = address[:city] if address[:city] + address_params[:state] = address[:state] if address[:state] + address_params[:postal_code] = address[:zip] if address[:zip] + address_params[:country] = address[:country] if address[:country] + post[:shipping][:address] = address_params unless address_params.empty? + post[:shipping][:name] = address[:name] if address[:name] + post[:shipping][:phone] = address[:phone] if address[:phone] + end + + post[:shipping][:carrier] = options[:carrier] if options[:carrier] + post[:shipping][:tracking_number] = options[:tracking_number] if options[:tracking_number] + + post.delete(:shipping) if post[:shipping].empty? + end def fetch_application_fee(identification, options = {}) options.merge!(:key => @fee_refund_api_key) diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb index cbc94e8ab52..3fecb1ba64d 100644 --- a/test/remote/gateways/remote_stripe_test.rb +++ b/test/remote/gateways/remote_stripe_test.rb @@ -122,6 +122,24 @@ def test_successful_purchase_with_level3_data assert_equal 'wow@example.com', response.params['metadata']['email'] end + def test_successful_purchase_with_shipping_info + custom_options = @options.merge(:shipping_address => address(), :carrier => 'UPS', :tracking_number => '12345') + assert response = @gateway.purchase(@amount, @credit_card, custom_options) + assert_success response + assert_equal 'charge', response.params['object'] + assert response.params['paid'] + assert_equal custom_options[:shipping_address][:name], response.params['shipping']['name'] + assert_equal custom_options[:shipping_address][:address1], response.params['shipping']['address']['line1'] + assert_equal custom_options[:shipping_address][:address2], response.params['shipping']['address']['line2'] + assert_equal custom_options[:shipping_address][:city], response.params['shipping']['address']['city'] + assert_equal custom_options[:shipping_address][:state], response.params['shipping']['address']['state'] + assert_equal custom_options[:shipping_address][:zip], response.params['shipping']['address']['postal_code'] + assert_equal custom_options[:shipping_address][:country], response.params['shipping']['address']['country'] + assert_equal custom_options[:shipping_address][:phone], response.params['shipping']['phone'] + assert_equal custom_options[:carrier], response.params['shipping']['carrier'] + assert_equal custom_options[:tracking_number], response.params['shipping']['tracking_number'] + end + def test_unsuccessful_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index f6a99162f3b..84c43f52a05 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -13,7 +13,10 @@ def setup @options = { :billing_address => address(), :statement_address => statement_address(), - :description => 'Test Purchase' + :description => 'Test Purchase', + :shipping_address => address(), + :carrier => 'UPS', + :tracking_number => '12345' } @apple_pay_payment_token = apple_pay_payment_token @@ -1060,6 +1063,21 @@ def test_add_statement_address_returns_nil_if_required_fields_missing end end + def test_add_shipping_info + post = {:card => {}} + @gateway.send(:add_shipping_info, post, @options) + assert_equal @options[:shipping_address][:zip], post[:shipping][:address][:postal_code] + assert_equal @options[:shipping_address][:state], post[:shipping][:address][:state] + assert_equal @options[:shipping_address][:address1], post[:shipping][:address][:line1] + assert_equal @options[:shipping_address][:address2], post[:shipping][:address][:line2] + assert_equal @options[:shipping_address][:country], post[:shipping][:address][:country] + assert_equal @options[:shipping_address][:city], post[:shipping][:address][:city] + assert_equal @options[:shipping_address][:name], post[:shipping][:name] + assert_equal @options[:shipping_address][:phone], post[:shipping][:phone] + assert_equal @options[:carrier], post[:shipping][:carrier] + assert_equal @options[:tracking_number], post[:shipping][:tracking_number] + end + def test_ensure_does_not_respond_to_credit assert !@gateway.respond_to?(:credit) end From c45a369fe02f69cd6847198c6a4808f3a0587539 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 21 Sep 2018 13:50:02 -0400 Subject: [PATCH 558/677] RuboCop: fix most EmptyLines* rules This explicitly skips Layout/EmptyLinesAroundClassBody because it needs some discussion. The rest is straightforward and are pretty solid readability improvements. --- .rubocop_todo.yml | 21 ------------------- lib/active_merchant/billing/check.rb | 1 + lib/active_merchant/billing/credit_card.rb | 1 + lib/active_merchant/billing/gateways/adyen.rb | 1 - .../billing/gateways/allied_wallet.rb | 1 - .../billing/gateways/authorize_net.rb | 1 - .../billing/gateways/beanstream.rb | 1 + .../billing/gateways/bridge_pay.rb | 1 - .../billing/gateways/card_stream.rb | 1 - .../billing/gateways/cardknox.rb | 1 - .../billing/gateways/commercegate.rb | 1 - .../billing/gateways/creditcall.rb | 1 - .../billing/gateways/data_cash.rb | 2 -- lib/active_merchant/billing/gateways/dibs.rb | 2 -- .../billing/gateways/efsnet.rb | 1 - lib/active_merchant/billing/gateways/epay.rb | 1 - lib/active_merchant/billing/gateways/eway.rb | 1 + .../billing/gateways/eway_managed.rb | 1 - lib/active_merchant/billing/gateways/exact.rb | 1 - .../billing/gateways/garanti.rb | 1 - .../billing/gateways/global_collect.rb | 1 - .../billing/gateways/inspire.rb | 2 +- .../billing/gateways/latitude19.rb | 1 - .../billing/gateways/linkpoint.rb | 3 +-- .../billing/gateways/mastercard.rb | 1 + .../billing/gateways/mercado_pago.rb | 1 - .../billing/gateways/merchant_e_solutions.rb | 1 - .../billing/gateways/micropayment.rb | 2 -- .../billing/gateways/modern_payments.rb | 1 + .../billing/gateways/modern_payments_cim.rb | 1 + .../billing/gateways/nab_transact.rb | 1 - .../billing/gateways/net_registry.rb | 1 + lib/active_merchant/billing/gateways/nmi.rb | 1 - .../billing/gateways/openpay.rb | 1 + .../billing/gateways/optimal_payment.rb | 1 - .../billing/gateways/orbital.rb | 1 - .../billing/gateways/pay_secure.rb | 2 +- .../billing/gateways/paybox_direct.rb | 1 - lib/active_merchant/billing/gateways/payex.rb | 1 - .../gateways/payflow/payflow_common_api.rb | 1 + .../billing/gateways/payflow_express.rb | 2 +- .../billing/gateways/paymill.rb | 2 -- .../billing/gateways/payscout.rb | 1 - lib/active_merchant/billing/gateways/pin.rb | 1 + .../billing/gateways/plugnpay.rb | 1 + .../billing/gateways/psl_card.rb | 1 - .../gateways/quickpay/quickpay_common.rb | 1 - .../billing/gateways/realex.rb | 1 + lib/active_merchant/billing/gateways/s5.rb | 1 - .../billing/gateways/sage_pay.rb | 1 + .../billing/gateways/secure_net.rb | 1 - .../billing/gateways/securion_pay.rb | 1 - .../billing/gateways/smart_ps.rb | 4 +--- .../billing/gateways/spreedly_core.rb | 1 - .../billing/gateways/trexle.rb | 1 + .../billing/gateways/trust_commerce.rb | 1 + .../billing/gateways/viaklix.rb | 1 + .../billing/gateways/wirecard.rb | 1 + lib/active_merchant/connection.rb | 1 - .../network_connection_retries.rb | 1 + lib/active_merchant/post_data.rb | 1 + lib/support/gateway_support.rb | 1 - lib/support/ssl_verify.rb | 1 - .../remote_authorize_net_apple_pay_test.rb | 1 - .../gateways/remote_authorize_net_cim_test.rb | 1 - test/remote/gateways/remote_banwire_test.rb | 1 - test/remote/gateways/remote_blue_snap_test.rb | 1 - .../gateways/remote_braintree_blue_test.rb | 2 +- test/remote/gateways/remote_cardknox_test.rb | 1 - test/remote/gateways/remote_cecabank_test.rb | 1 - .../remote/gateways/remote_creditcall_test.rb | 1 - .../gateways/remote_cyber_source_test.rb | 1 - .../gateways/remote_first_giving_test.rb | 1 - test/remote/gateways/remote_forte_test.rb | 1 - test/remote/gateways/remote_iveri_test.rb | 1 - test/remote/gateways/remote_jetpay_test.rb | 2 -- test/remote/gateways/remote_jetpay_v2_test.rb | 1 - test/remote/gateways/remote_linkpoint_test.rb | 1 - .../remote_litle_certification_test.rb | 3 --- .../gateways/remote_modern_payments_test.rb | 1 - test/remote/gateways/remote_nmi_test.rb | 1 - .../gateways/remote_pay_junction_test.rb | 1 + test/remote/gateways/remote_payscout_test.rb | 2 -- .../gateways/remote_quickpay_v4_test.rb | 2 -- .../gateways/remote_quickpay_v5_test.rb | 2 -- .../gateways/remote_quickpay_v6_test.rb | 2 -- test/remote/gateways/remote_realex_test.rb | 3 --- .../gateways/remote_redsys_sha256_test.rb | 1 + test/remote/gateways/remote_redsys_test.rb | 1 + .../gateways/remote_so_easy_pay_test.rb | 1 - ...te_trans_first_transaction_express_test.rb | 1 - test/remote/gateways/remote_worldpay_test.rb | 1 - test/test_helper.rb | 4 +++- test/unit/gateways/allied_wallet_test.rb | 2 -- test/unit/gateways/authorize_net_test.rb | 2 -- test/unit/gateways/balanced_test.rb | 1 - test/unit/gateways/banwire_test.rb | 1 - test/unit/gateways/beanstream_test.rb | 1 - test/unit/gateways/blue_pay_test.rb | 2 -- test/unit/gateways/card_connect_test.rb | 1 - test/unit/gateways/card_stream_test.rb | 1 - test/unit/gateways/cashnet_test.rb | 1 + test/unit/gateways/cecabank_test.rb | 1 - test/unit/gateways/cenpos_test.rb | 1 - test/unit/gateways/commercegate_test.rb | 1 - test/unit/gateways/cyber_source_test.rb | 1 - test/unit/gateways/data_cash_test.rb | 1 + test/unit/gateways/digitzs_test.rb | 1 - test/unit/gateways/efsnet_test.rb | 2 +- test/unit/gateways/element_test.rb | 1 + test/unit/gateways/eway_managed_test.rb | 1 - test/unit/gateways/eway_test.rb | 1 + test/unit/gateways/exact_test.rb | 4 ++-- test/unit/gateways/fat_zebra_test.rb | 1 + test/unit/gateways/federated_canada_test.rb | 6 ++---- test/unit/gateways/firstdata_e4_test.rb | 3 +++ test/unit/gateways/gateway_test.rb | 1 - test/unit/gateways/iridium_test.rb | 3 --- test/unit/gateways/jetpay_test.rb | 1 + test/unit/gateways/linkpoint_test.rb | 2 +- test/unit/gateways/litle_test.rb | 1 - test/unit/gateways/maxipago_test.rb | 1 - test/unit/gateways/merchant_partners_test.rb | 1 - test/unit/gateways/metrics_global_test.rb | 1 - test/unit/gateways/moneris_us_test.rb | 3 --- test/unit/gateways/ncr_secure_pay_test.rb | 8 ------- test/unit/gateways/net_registry_test.rb | 1 + test/unit/gateways/netbanx_test.rb | 1 - test/unit/gateways/netbilling_test.rb | 1 + test/unit/gateways/netpay_test.rb | 1 - test/unit/gateways/optimal_payment_test.rb | 1 - test/unit/gateways/pay_gate_xml_test.rb | 2 -- test/unit/gateways/pay_junction_test.rb | 3 +-- test/unit/gateways/pay_secure_test.rb | 1 + test/unit/gateways/payflow_express_uk_test.rb | 1 + test/unit/gateways/paymill_test.rb | 1 + .../gateways/paypal/paypal_common_api_test.rb | 3 ++- .../gateways/paypal_digital_goods_test.rb | 3 --- test/unit/gateways/paypal_express_test.rb | 4 ---- test/unit/gateways/paypal_test.rb | 1 - test/unit/gateways/payscout_test.rb | 1 - test/unit/gateways/paystation_test.rb | 2 -- test/unit/gateways/payway_test.rb | 1 - test/unit/gateways/plugnpay_test.rb | 2 +- test/unit/gateways/psl_card_test.rb | 1 + test/unit/gateways/realex_test.rb | 3 --- test/unit/gateways/sage_pay_test.rb | 2 -- test/unit/gateways/sage_test.rb | 1 + test/unit/gateways/secure_pay_au_test.rb | 1 - test/unit/gateways/secure_pay_tech_test.rb | 1 + test/unit/gateways/secure_pay_test.rb | 1 - test/unit/gateways/skip_jack_test.rb | 2 +- test/unit/gateways/stripe_test.rb | 1 - .../gateways/usa_epay_transaction_test.rb | 1 - test/unit/gateways/verifi_test.rb | 2 -- test/unit/gateways/wirecard_test.rb | 1 - .../gateways/worldpay_online_payments_test.rb | 2 ++ test/unit/network_connection_retries_test.rb | 1 - 158 files changed, 62 insertions(+), 185 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index fb937502eb4..99cea84dfd4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -60,22 +60,6 @@ Layout/ElseAlignment: - 'lib/active_merchant/billing/gateways/trust_commerce.rb' - 'lib/active_merchant/billing/response.rb' -# Offense count: 66 -# Cop supports --auto-correct. -# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. -Layout/EmptyLineBetweenDefs: - Enabled: false - -# Offense count: 97 -# Cop supports --auto-correct. -Layout/EmptyLines: - Enabled: false - -# Offense count: 49 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundAccessModifier: - Enabled: false - # Offense count: 165 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. @@ -83,11 +67,6 @@ Layout/EmptyLinesAroundAccessModifier: Layout/EmptyLinesAroundClassBody: Enabled: false -# Offense count: 64 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundMethodBody: - Enabled: false - # Offense count: 40 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. diff --git a/lib/active_merchant/billing/check.rb b/lib/active_merchant/billing/check.rb index 410359c41b6..9d73819560a 100644 --- a/lib/active_merchant/billing/check.rb +++ b/lib/active_merchant/billing/check.rb @@ -53,6 +53,7 @@ def type def credit_card? false end + # Routing numbers may be validated by calculating a checksum and dividing it by 10. The # formula is: # (3(d1 + d4 + d7) + 7(d2 + d5 + d8) + 1(d3 + d6 + d9))mod 10 = 0 diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb index 4d1afcae1bf..19dcbec394a 100644 --- a/lib/active_merchant/billing/credit_card.rb +++ b/lib/active_merchant/billing/credit_card.rb @@ -386,6 +386,7 @@ def expiration #:nodoc: end private + def month_days mdays = [nil,31,28,31,30,31,30,31,31,30,31,30,31] mdays[2] = 29 if Date.leap?(year) diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index d7fb3a94042..c73db70be52 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -249,7 +249,6 @@ def commit(action, parameters) test: test?, error_code: success ? nil : error_code_from(response) ) - end def url diff --git a/lib/active_merchant/billing/gateways/allied_wallet.rb b/lib/active_merchant/billing/gateways/allied_wallet.rb index a7f359849c1..55181e90d30 100644 --- a/lib/active_merchant/billing/gateways/allied_wallet.rb +++ b/lib/active_merchant/billing/gateways/allied_wallet.rb @@ -128,7 +128,6 @@ def add_reference(post, authorization, action) post[transactions[action]] = authorization end - ACTIONS = { purchase: 'SALE', authorize: 'AUTHORIZE', diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index 12df74d02bc..db7367210b4 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -604,7 +604,6 @@ def add_shipping_address(xml, options, root_node='shipTo') xml.zip(truncate(address[:zip], 20)) xml.country(truncate(address[:country], 60)) end - end def add_order_id(xml, options) diff --git a/lib/active_merchant/billing/gateways/beanstream.rb b/lib/active_merchant/billing/gateways/beanstream.rb index 3530ddfd167..d42209db38d 100644 --- a/lib/active_merchant/billing/gateways/beanstream.rb +++ b/lib/active_merchant/billing/gateways/beanstream.rb @@ -205,6 +205,7 @@ def scrub(transcript) end private + def build_response(*args) Response.new(*args) end diff --git a/lib/active_merchant/billing/gateways/bridge_pay.rb b/lib/active_merchant/billing/gateways/bridge_pay.rb index 091d8ac1a65..ae2e653f4b6 100644 --- a/lib/active_merchant/billing/gateways/bridge_pay.rb +++ b/lib/active_merchant/billing/gateways/bridge_pay.rb @@ -13,7 +13,6 @@ class BridgePayGateway < Gateway self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb] - def initialize(options={}) requires!(options, :user_name, :password) super diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb index 993c61f027a..c049b2dff57 100644 --- a/lib/active_merchant/billing/gateways/card_stream.rb +++ b/lib/active_merchant/billing/gateways/card_stream.rb @@ -350,7 +350,6 @@ def avs_from(response) }) end - def currency_code(currency) CURRENCY_CODES[currency] end diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb index 0345173d4f6..aa61d77dc77 100644 --- a/lib/active_merchant/billing/gateways/cardknox.rb +++ b/lib/active_merchant/billing/gateways/cardknox.rb @@ -279,7 +279,6 @@ def parse(body) }.delete_if{|k, v| v.nil?} end - def commit(action, source_type, parameters) response = parse(ssl_post(live_url, post_data(COMMANDS[source_type][action], parameters))) diff --git a/lib/active_merchant/billing/gateways/commercegate.rb b/lib/active_merchant/billing/gateways/commercegate.rb index 77aede1e9de..c831141b0c8 100644 --- a/lib/active_merchant/billing/gateways/commercegate.rb +++ b/lib/active_merchant/billing/gateways/commercegate.rb @@ -76,7 +76,6 @@ def add_auth_purchase_options(post, money, options) post[:email] = options[:email] || 'unknown@example.com' post[:currencyCode]= options[:currency] || currency(money) post[:merchAcct] = options[:merchant] - end def add_creditcard(params, creditcard) diff --git a/lib/active_merchant/billing/gateways/creditcall.rb b/lib/active_merchant/billing/gateways/creditcall.rb index a140cbfa4a2..4ce8a1f916d 100644 --- a/lib/active_merchant/billing/gateways/creditcall.rb +++ b/lib/active_merchant/billing/gateways/creditcall.rb @@ -214,7 +214,6 @@ def parse(body) end end - response end diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb index 1e31db78dc5..f943a330d01 100644 --- a/lib/active_merchant/billing/gateways/data_cash.rb +++ b/lib/active_merchant/billing/gateways/data_cash.rb @@ -214,7 +214,6 @@ def add_authentication(xml) end def add_credit_card(xml, credit_card, address) - xml.tag! :Card do # DataCash calls the CC number 'pan' xml.tag! :pan, credit_card.number @@ -274,7 +273,6 @@ def format_date(month, year) end def parse(body) - response = {} xml = REXML::Document.new(body) root = REXML::XPath.first(xml, '//Response') diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb index 5379b738107..647d749bdae 100644 --- a/lib/active_merchant/billing/gateways/dibs.rb +++ b/lib/active_merchant/billing/gateways/dibs.rb @@ -34,7 +34,6 @@ def authorize(amount, payment_method, options={}) add_ticket_id(post, payment_method) commit(:authorize_ticket, post) end - end def capture(amount, authorization, options={}) @@ -114,7 +113,6 @@ def add_payment_method(post, payment_method, options) post[:test] = true if test? end - def add_reference(post, authorization) post[:transactionId] = authorization end diff --git a/lib/active_merchant/billing/gateways/efsnet.rb b/lib/active_merchant/billing/gateways/efsnet.rb index e9785556819..a7e428b1eff 100644 --- a/lib/active_merchant/billing/gateways/efsnet.rb +++ b/lib/active_merchant/billing/gateways/efsnet.rb @@ -142,7 +142,6 @@ def add_creditcard(post, creditcard) post[:expiration_year] = sprintf('%.4i', creditcard.year)[-2..-1] end - def commit(action, parameters) response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(action, parameters), 'Content-Type' => 'text/xml')) diff --git a/lib/active_merchant/billing/gateways/epay.rb b/lib/active_merchant/billing/gateways/epay.rb index 19ddbf5365a..7f351623253 100644 --- a/lib/active_merchant/billing/gateways/epay.rb +++ b/lib/active_merchant/billing/gateways/epay.rb @@ -120,7 +120,6 @@ def scrub(transcript) gsub(%r((&?cvc=)\d*(&?)), '\1[FILTERED]\2') end - private def add_amount(post, money, options) diff --git a/lib/active_merchant/billing/gateways/eway.rb b/lib/active_merchant/billing/gateways/eway.rb index 1c24fb8032f..a45db4bf881 100644 --- a/lib/active_merchant/billing/gateways/eway.rb +++ b/lib/active_merchant/billing/gateways/eway.rb @@ -64,6 +64,7 @@ def scrub(transcript) end private + def requires_address!(options) raise ArgumentError.new('Missing eWay required parameters: address or billing_address') unless (options.has_key?(:address) or options.has_key?(:billing_address)) end diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb index c08ebcd4285..bd5281511c3 100644 --- a/lib/active_merchant/billing/gateways/eway_managed.rb +++ b/lib/active_merchant/billing/gateways/eway_managed.rb @@ -136,7 +136,6 @@ def add_invoice(post, options) post[:invoiceDescription] = options[:description] end - # add credit card details to be stored by eway. NOTE eway requires "title" field def add_creditcard(post, creditcard) post[:CCNumber] = creditcard.number diff --git a/lib/active_merchant/billing/gateways/exact.rb b/lib/active_merchant/billing/gateways/exact.rb index a5d073a76ab..915a1a82c5d 100644 --- a/lib/active_merchant/billing/gateways/exact.rb +++ b/lib/active_merchant/billing/gateways/exact.rb @@ -13,7 +13,6 @@ class ExactGateway < Gateway :capture => '32', :credit => '34' } - ENVELOPE_NAMESPACES = { 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance' diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb index eb77b969a47..fbd202ceee6 100644 --- a/lib/active_merchant/billing/gateways/garanti.rb +++ b/lib/active_merchant/billing/gateways/garanti.rb @@ -30,7 +30,6 @@ class GarantiGateway < Gateway 'JPY' => 392 } - def initialize(options = {}) requires!(options, :login, :password, :terminal_id, :merchant_id) super diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 66f4634841d..6a82e2807e5 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -246,7 +246,6 @@ def commit(action, post, authorization = nil) error_code: error_code_from(succeeded, response), test: test? ) - end def headers(action, post, authorization = nil) diff --git a/lib/active_merchant/billing/gateways/inspire.rb b/lib/active_merchant/billing/gateways/inspire.rb index 6c9fae8e265..324f1f8bb5f 100644 --- a/lib/active_merchant/billing/gateways/inspire.rb +++ b/lib/active_merchant/billing/gateways/inspire.rb @@ -99,6 +99,7 @@ def store(creditcard, options = {}) alias_method :unstore, :delete private + def add_customer_data(post, options) if options.has_key? :email post[:email] = options[:email] @@ -181,7 +182,6 @@ def commit(action, money, parameters) :cvv_result => response['cvvresponse'], :avs_result => { :code => response['avsresponse'] } ) - end def message_from(response) diff --git a/lib/active_merchant/billing/gateways/latitude19.rb b/lib/active_merchant/billing/gateways/latitude19.rb index f430f16f852..89d3d8f50df 100644 --- a/lib/active_merchant/billing/gateways/latitude19.rb +++ b/lib/active_merchant/billing/gateways/latitude19.rb @@ -147,7 +147,6 @@ def scrub(transcript) gsub(%r((\"cvv\\\":\\\")\d+), '\1[FILTERED]') end - private def add_request_id(post) diff --git a/lib/active_merchant/billing/gateways/linkpoint.rb b/lib/active_merchant/billing/gateways/linkpoint.rb index 5b0553c3dfd..cf4d3cf28de 100644 --- a/lib/active_merchant/billing/gateways/linkpoint.rb +++ b/lib/active_merchant/billing/gateways/linkpoint.rb @@ -258,6 +258,7 @@ def scrub(transcript) end private + # Commit the transaction by posting the XML file to the LinkPoint server def commit(money, creditcard, options = {}) response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(money, creditcard, options))) @@ -323,7 +324,6 @@ def build_items(element, items) # Set up the parameters hash just once so we don't have to do it # for every action. def parameters(money, creditcard, options = {}) - params = { :payment => { :subtotal => amount(options[:subtotal]), @@ -417,7 +417,6 @@ def parameters(money, creditcard, options = {}) end def parse(xml) - # For reference, a typical response... # <r_csp></r_csp> # <r_time></r_time> diff --git a/lib/active_merchant/billing/gateways/mastercard.rb b/lib/active_merchant/billing/gateways/mastercard.rb index 10fb51ba589..609039cb9e3 100644 --- a/lib/active_merchant/billing/gateways/mastercard.rb +++ b/lib/active_merchant/billing/gateways/mastercard.rb @@ -80,6 +80,7 @@ def scrub(transcript) end private + def new_post { order: {}, diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index ad5f4a555d8..ad6f931aade 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -119,7 +119,6 @@ def add_additional_data(post, options) ip_address: options[:ip_address] }.merge(options[:additional_info] || {}) - add_address(post, options) add_shipping_address(post, options) end diff --git a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb index 8af50c307e6..f1306ce3db9 100644 --- a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +++ b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb @@ -158,7 +158,6 @@ def commit(action, money, parameters) url = test? ? self.test_url : self.live_url parameters[:transaction_amount] = amount(money) if money unless action == 'V' - response = begin parse( ssl_post(url, post_data(action,parameters)) ) rescue ActiveMerchant::ResponseError => e diff --git a/lib/active_merchant/billing/gateways/micropayment.rb b/lib/active_merchant/billing/gateways/micropayment.rb index 3172e3ec4f1..17a3750fb95 100644 --- a/lib/active_merchant/billing/gateways/micropayment.rb +++ b/lib/active_merchant/billing/gateways/micropayment.rb @@ -12,7 +12,6 @@ class MicropaymentGateway < Gateway self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express] - def initialize(options={}) requires!(options, :access_key) super @@ -57,7 +56,6 @@ def refund(amount, authorization, options={}) end def verify(credit_card, options={}) - MultiResponse.run(:use_first_response) do |r| r.process { authorize(250, credit_card, options) } r.process(:ignore_result) { void(r.authorization, options) } diff --git a/lib/active_merchant/billing/gateways/modern_payments.rb b/lib/active_merchant/billing/gateways/modern_payments.rb index 340e3e7a0c7..d94d12cb6d9 100644 --- a/lib/active_merchant/billing/gateways/modern_payments.rb +++ b/lib/active_merchant/billing/gateways/modern_payments.rb @@ -28,6 +28,7 @@ def purchase(money, credit_card, options = {}) end private + def cim @cim ||= ModernPaymentsCimGateway.new(@options) end diff --git a/lib/active_merchant/billing/gateways/modern_payments_cim.rb b/lib/active_merchant/billing/gateways/modern_payments_cim.rb index 1f1e5beb04b..7420ff6cd23 100644 --- a/lib/active_merchant/billing/gateways/modern_payments_cim.rb +++ b/lib/active_merchant/billing/gateways/modern_payments_cim.rb @@ -66,6 +66,7 @@ def create_payment(customer_id, amount, options = {}) end private + def add_payment_details(post, options) post[:pmtDate] = (options[:payment_date] || Time.now.utc).strftime('%Y-%m-%dT%H:%M:%SZ') post[:pmtType] = PAYMENT_METHOD[options[:payment_method] || :credit_card] diff --git a/lib/active_merchant/billing/gateways/nab_transact.rb b/lib/active_merchant/billing/gateways/nab_transact.rb index 85123a13ebd..389653cf523 100644 --- a/lib/active_merchant/billing/gateways/nab_transact.rb +++ b/lib/active_merchant/billing/gateways/nab_transact.rb @@ -41,7 +41,6 @@ class NabTransactGateway < Gateway SUCCESS_CODES = [ '00', '08', '11', '16', '77' ] - def initialize(options = {}) requires!(options, :login, :password) super diff --git a/lib/active_merchant/billing/gateways/net_registry.rb b/lib/active_merchant/billing/gateways/net_registry.rb index f3767e1be66..a1e4ee183ef 100644 --- a/lib/active_merchant/billing/gateways/net_registry.rb +++ b/lib/active_merchant/billing/gateways/net_registry.rb @@ -122,6 +122,7 @@ def status(identification) end private + def add_request_details(params, options) params['COMMENT'] = options[:description] unless options[:description].blank? end diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb index 63180931889..0b6910ba82a 100644 --- a/lib/active_merchant/billing/gateways/nmi.rb +++ b/lib/active_merchant/billing/gateways/nmi.rb @@ -214,7 +214,6 @@ def exp_date(payment_method) end def commit(action, params) - params[action == 'add_customer' ? :customer_vault : :type] = action params[:username] = @options[:login] params[:password] = @options[:password] diff --git a/lib/active_merchant/billing/gateways/openpay.rb b/lib/active_merchant/billing/gateways/openpay.rb index fda4d7801ff..1d44beb6036 100644 --- a/lib/active_merchant/billing/gateways/openpay.rb +++ b/lib/active_merchant/billing/gateways/openpay.rb @@ -104,6 +104,7 @@ def scrub(transcript) gsub(%r((cvv2\\?":\\?")\\?"), '\1[BLANK]"'). gsub(%r((cvv2\\?":\\?")\s+), '\1[BLANK]') end + private def create_post_for_auth_or_purchase(money, creditcard, options) diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb index c4ff212c018..2684c76e84f 100644 --- a/lib/active_merchant/billing/gateways/optimal_payment.rb +++ b/lib/active_merchant/billing/gateways/optimal_payment.rb @@ -19,7 +19,6 @@ class OptimalPaymentGateway < Gateway self.display_name = 'Optimal Payments' def initialize(options = {}) - if(options[:login]) ActiveMerchant.deprecated("The 'login' option is deprecated in favor of 'store_id' and will be removed in a future version.") options[:store_id] = options[:login] diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index 9f0ba09eca7..f41a9801775 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -251,7 +251,6 @@ def void(authorization, options = {}, deprecated = {}) commit(order, :void, options[:trace_number]) end - # ==== Customer Profiles # :customer_ref_num should be set unless you're happy with Orbital providing one # diff --git a/lib/active_merchant/billing/gateways/pay_secure.rb b/lib/active_merchant/billing/gateways/pay_secure.rb index 10dcbfbed57..72be0071d10 100644 --- a/lib/active_merchant/billing/gateways/pay_secure.rb +++ b/lib/active_merchant/billing/gateways/pay_secure.rb @@ -39,6 +39,7 @@ def purchase(money, credit_card, options = {}) end private + # Used for capturing, which is currently not supported. def add_reference(post, identification) auth, trans_id = identification.split(';') @@ -71,7 +72,6 @@ def commit(action, money, parameters) :test => test_response?(response), :authorization => authorization_from(response) ) - end def successful?(response) diff --git a/lib/active_merchant/billing/gateways/paybox_direct.rb b/lib/active_merchant/billing/gateways/paybox_direct.rb index 4e51c84ba0c..c66933c5baa 100644 --- a/lib/active_merchant/billing/gateways/paybox_direct.rb +++ b/lib/active_merchant/billing/gateways/paybox_direct.rb @@ -174,7 +174,6 @@ def message_from(response) end def post_data(action, parameters = {}) - parameters.update( :version => API_VERSION, :type => TRANSACTIONS[action.to_sym], diff --git a/lib/active_merchant/billing/gateways/payex.rb b/lib/active_merchant/billing/gateways/payex.rb index 22478d87d2a..b35038ca239 100644 --- a/lib/active_merchant/billing/gateways/payex.rb +++ b/lib/active_merchant/billing/gateways/payex.rb @@ -70,7 +70,6 @@ def authorize(amount, payment_method, options = {}) # stored authorization send_autopay(amount, payment_method, true, options) end - end # Public: Send a purchase Payex request diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb index 8aec158e79c..319c56bb64b 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb @@ -78,6 +78,7 @@ def void(authorization, options = {}) end private + def build_request(body, options = {}) xml = Builder::XmlMarkup.new xml.instruct! diff --git a/lib/active_merchant/billing/gateways/payflow_express.rb b/lib/active_merchant/billing/gateways/payflow_express.rb index a5061c6a931..c2970b6e052 100644 --- a/lib/active_merchant/billing/gateways/payflow_express.rb +++ b/lib/active_merchant/billing/gateways/payflow_express.rb @@ -58,7 +58,6 @@ module Billing #:nodoc: # [<tt>:header_background_color</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. # [<tt>:header_border_color</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction. - class PayflowExpressGateway < Gateway include PayflowCommonAPI include PaypalExpressCommon @@ -109,6 +108,7 @@ def details_for(token) end private + def build_get_express_details_request(token) xml = Builder::XmlMarkup.new :indent => 2 xml.tag! 'GetExpressCheckout' do diff --git a/lib/active_merchant/billing/gateways/paymill.rb b/lib/active_merchant/billing/gateways/paymill.rb index 95b4028b670..ff2f8268484 100644 --- a/lib/active_merchant/billing/gateways/paymill.rb +++ b/lib/active_merchant/billing/gateways/paymill.rb @@ -240,7 +240,6 @@ def transaction_id(authorization) 31203 => 'Pending due to currency conflict (accept manually)', 31204 => 'Pending due to fraud filters (accept manually)', - 40000 => 'Problem with transaction data', 40001 => 'Problem with payment data', 40002 => 'Invalid checksum', @@ -321,7 +320,6 @@ def response_message(parsed_response) RESPONSE_CODES[code] || code.to_s end - class ResponseParser attr_reader :raw_response, :parsed, :succeeded, :message, :options diff --git a/lib/active_merchant/billing/gateways/payscout.rb b/lib/active_merchant/billing/gateways/payscout.rb index f0f9602e4fc..108d8725aa7 100644 --- a/lib/active_merchant/billing/gateways/payscout.rb +++ b/lib/active_merchant/billing/gateways/payscout.rb @@ -41,7 +41,6 @@ def capture(money, authorization, options = {}) commit('capture', money, post) end - def refund(money, authorization, options = {}) post = {} post[:transactionid] = authorization diff --git a/lib/active_merchant/billing/gateways/pin.rb b/lib/active_merchant/billing/gateways/pin.rb index 289e8e33501..676ffb6f7af 100644 --- a/lib/active_merchant/billing/gateways/pin.rb +++ b/lib/active_merchant/billing/gateways/pin.rb @@ -84,6 +84,7 @@ def scrub(transcript) gsub(/(number\\?":\\?")(\d*)/, '\1[FILTERED]'). gsub(/(cvc\\?":\\?")(\d*)/, '\1[FILTERED]') end + private def add_amount(post, money, options) diff --git a/lib/active_merchant/billing/gateways/plugnpay.rb b/lib/active_merchant/billing/gateways/plugnpay.rb index 1b78b25c299..634c1294189 100644 --- a/lib/active_merchant/billing/gateways/plugnpay.rb +++ b/lib/active_merchant/billing/gateways/plugnpay.rb @@ -172,6 +172,7 @@ def refund(money, reference, options = {}) end private + def commit(action, post) response = parse( ssl_post(self.live_url, post_data(action, post)) ) success = SUCCESS_CODES.include?(response[:finalstatus]) diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb index 1abe0b9e55e..8154add4944 100644 --- a/lib/active_merchant/billing/gateways/psl_card.rb +++ b/lib/active_merchant/billing/gateways/psl_card.rb @@ -240,7 +240,6 @@ def currency_code(currency) # -a hash with all of the values returned in the PSL response # def parse(body) - fields = {} for line in body.split('&') key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb index 50d0fb44932..43545c02294 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb @@ -174,7 +174,6 @@ def self.included(base) base.supported_countries = ['DE', 'DK', 'ES', 'FI', 'FR', 'FO', 'GB', 'IS', 'NO', 'SE'] base.homepage_url = 'http://quickpay.net/' base.display_name = 'QuickPay' - end def expdate(credit_card) diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index 3b5c86b1b52..cb97ac7bb87 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -91,6 +91,7 @@ def scrub(transcript) end private + def commit(request) response = parse(ssl_post(self.live_url, request)) diff --git a/lib/active_merchant/billing/gateways/s5.rb b/lib/active_merchant/billing/gateways/s5.rb index 6e5ec5e80a7..2be4007ba63 100644 --- a/lib/active_merchant/billing/gateways/s5.rb +++ b/lib/active_merchant/billing/gateways/s5.rb @@ -96,7 +96,6 @@ def verify(credit_card, options={}) end end - def supports_scrubbing? true end diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index 313bdb88c72..4eee27bb932 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -181,6 +181,7 @@ def scrub(transcript) end private + def truncate(value, max_size) return nil unless value return value.to_s if CGI.escape(value.to_s).length <= max_size diff --git a/lib/active_merchant/billing/gateways/secure_net.rb b/lib/active_merchant/billing/gateways/secure_net.rb index 0bf4f8ff55b..66ccc07dc00 100644 --- a/lib/active_merchant/billing/gateways/secure_net.rb +++ b/lib/active_merchant/billing/gateways/secure_net.rb @@ -189,7 +189,6 @@ def add_address(xml, creditcard, options) xml.tag!('CUSTOMER_SHIP', NIL_ATTRIBUTE) do end end - end def add_merchant_key(xml, options) diff --git a/lib/active_merchant/billing/gateways/securion_pay.rb b/lib/active_merchant/billing/gateways/securion_pay.rb index c883c938230..3c56fce55ad 100644 --- a/lib/active_merchant/billing/gateways/securion_pay.rb +++ b/lib/active_merchant/billing/gateways/securion_pay.rb @@ -4,7 +4,6 @@ class SecurionPayGateway < Gateway self.test_url = 'https://api.securionpay.com/' self.live_url = 'https://api.securionpay.com/' - self.supported_countries = %w(AL AD AT BY BE BG HR CY CZ RE DK EE IS FI FR DE GI GR HU IS IE IT IL LV LI LT LU MK MT MD MC NL NO PL PT RO RU MA RS SK SI ES SE CH UA GB KI CI ME) diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb index b95c4d685e7..0b9841189e9 100644 --- a/lib/active_merchant/billing/gateways/smart_ps.rb +++ b/lib/active_merchant/billing/gateways/smart_ps.rb @@ -106,7 +106,6 @@ def amend(auth, options = {}) commit('update', nil, post) end - def delete(vault_id) post = {} post[:customer_vault] = 'delete_customer' @@ -128,6 +127,7 @@ def store(payment_source, options = {}) alias_method :unstore, :delete private + def add_customer_data(post, options) if options.has_key? :email post[:email] = options[:email] @@ -237,7 +237,6 @@ def commit(action, money, parameters) :cvv_result => response['cvvresponse'], :avs_result => { :code => response['avsresponse'] } ) - end def expdate(creditcard) @@ -247,7 +246,6 @@ def expdate(creditcard) "#{month}#{year[-2..-1]}" end - def message_from(response) case response['responsetext'] when 'SUCCESS', 'Approved', nil # This is dubious, but responses from UPDATE are nil. diff --git a/lib/active_merchant/billing/gateways/spreedly_core.rb b/lib/active_merchant/billing/gateways/spreedly_core.rb index 7c365fb2f68..d3d3e91af87 100644 --- a/lib/active_merchant/billing/gateways/spreedly_core.rb +++ b/lib/active_merchant/billing/gateways/spreedly_core.rb @@ -88,7 +88,6 @@ def void(authorization, options={}) commit("transactions/#{authorization}/void.xml", '') end - # Public: Determine whether a credit card is chargeable card and available for purchases. # # payment_method - The CreditCard or the Spreedly payment method token. diff --git a/lib/active_merchant/billing/gateways/trexle.rb b/lib/active_merchant/billing/gateways/trexle.rb index 2be948b4940..f7f98e21766 100644 --- a/lib/active_merchant/billing/gateways/trexle.rb +++ b/lib/active_merchant/billing/gateways/trexle.rb @@ -90,6 +90,7 @@ def scrub(transcript) gsub(/(number\\?":\\?")(\d*)/, '\1[FILTERED]'). gsub(/(cvc\\?":\\?")(\d*)/, '\1[FILTERED]') end + private def add_amount(post, money, options) diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb index 87872c59122..4908df12cde 100644 --- a/lib/active_merchant/billing/gateways/trust_commerce.rb +++ b/lib/active_merchant/billing/gateways/trust_commerce.rb @@ -304,6 +304,7 @@ def scrub(transcript) end private + def add_payment_source(params, source) if source.is_a?(String) add_billing_id(params, source) diff --git a/lib/active_merchant/billing/gateways/viaklix.rb b/lib/active_merchant/billing/gateways/viaklix.rb index c2e800b9b4c..4e82980e7f1 100644 --- a/lib/active_merchant/billing/gateways/viaklix.rb +++ b/lib/active_merchant/billing/gateways/viaklix.rb @@ -63,6 +63,7 @@ def credit(money, creditcard, options = {}) end private + def add_test_mode(form, options) form[:test_mode] = 'TRUE' if options[:test_mode] end diff --git a/lib/active_merchant/billing/gateways/wirecard.rb b/lib/active_merchant/billing/gateways/wirecard.rb index 4b964770e15..d04ddc569e5 100644 --- a/lib/active_merchant/billing/gateways/wirecard.rb +++ b/lib/active_merchant/billing/gateways/wirecard.rb @@ -138,6 +138,7 @@ def scrub(transcript) end private + def clean_description(description) description.to_s.slice(0,32).encode('US-ASCII', invalid: :replace, undef: :replace, replace: '?') end diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index 489130ee1b9..d7067b98636 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -161,7 +161,6 @@ def configure_ssl(http) else http.verify_mode = OpenSSL::SSL::VERIFY_NONE end - end def configure_cert(http) diff --git a/lib/active_merchant/network_connection_retries.rb b/lib/active_merchant/network_connection_retries.rb index 772e8617936..db0187ffa33 100644 --- a/lib/active_merchant/network_connection_retries.rb +++ b/lib/active_merchant/network_connection_retries.rb @@ -69,6 +69,7 @@ def self.log(logger, level, message, tag=nil) end private + def log_with_retry_details(logger, attempts, time, message, tag) NetworkConnectionRetries.log(logger, :info, 'connection_attempt=%d connection_request_time=%.4fs connection_msg="%s"' % [attempts, time, message], tag) end diff --git a/lib/active_merchant/post_data.rb b/lib/active_merchant/post_data.rb index b1c715b0108..c95b85244d2 100644 --- a/lib/active_merchant/post_data.rb +++ b/lib/active_merchant/post_data.rb @@ -17,6 +17,7 @@ def to_post_data alias_method :to_s, :to_post_data private + def required?(key) required_fields.include?(key) end diff --git a/lib/support/gateway_support.rb b/lib/support/gateway_support.rb index c811e7d04fe..1ae661a6375 100644 --- a/lib/support/gateway_support.rb +++ b/lib/support/gateway_support.rb @@ -2,7 +2,6 @@ require 'active_support' require 'active_merchant' - class GatewaySupport #:nodoc: ACTIONS = [:purchase, :authorize, :capture, :void, :credit, :recurring] diff --git a/lib/support/ssl_verify.rb b/lib/support/ssl_verify.rb index 94dbf618695..28189db7837 100644 --- a/lib/support/ssl_verify.rb +++ b/lib/support/ssl_verify.rb @@ -60,7 +60,6 @@ def test_gateways puts d.name end end - end def try_host(http, path) diff --git a/test/remote/gateways/remote_authorize_net_apple_pay_test.rb b/test/remote/gateways/remote_authorize_net_apple_pay_test.rb index 6b8a632743f..cf430b4a975 100644 --- a/test/remote/gateways/remote_authorize_net_apple_pay_test.rb +++ b/test/remote/gateways/remote_authorize_net_apple_pay_test.rb @@ -60,7 +60,6 @@ def test_failed_apple_pay_purchase assert_equal 'processing_error', response.error_code end - private def apple_pay_payment_token(options = {}) diff --git a/test/remote/gateways/remote_authorize_net_cim_test.rb b/test/remote/gateways/remote_authorize_net_cim_test.rb index 545a9f96942..bbd6d60eea4 100644 --- a/test/remote/gateways/remote_authorize_net_cim_test.rb +++ b/test/remote/gateways/remote_authorize_net_cim_test.rb @@ -873,5 +873,4 @@ def get_and_validate_auth_only_response return response end - end diff --git a/test/remote/gateways/remote_banwire_test.rb b/test/remote/gateways/remote_banwire_test.rb index 0bac529ec67..cb8331a5661 100644 --- a/test/remote/gateways/remote_banwire_test.rb +++ b/test/remote/gateways/remote_banwire_test.rb @@ -37,7 +37,6 @@ def test_successful_purchase_with_extra_options assert_success response end - def test_unsuccessful_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb index 8530b92dba5..9934855f3de 100644 --- a/test/remote/gateways/remote_blue_snap_test.rb +++ b/test/remote/gateways/remote_blue_snap_test.rb @@ -196,7 +196,6 @@ def test_verify_credentials assert !gateway.verify_credentials end - def test_transcript_scrubbing transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index 27bf4083ff4..46a6610cc6f 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -705,8 +705,8 @@ def test_verify_credentials assert !gateway.verify_credentials end - private + def assert_avs(address1, zip, expected_avs_code) response = @gateway.purchase(@amount, @credit_card, billing_address: {address1: address1, zip: zip}) diff --git a/test/remote/gateways/remote_cardknox_test.rb b/test/remote/gateways/remote_cardknox_test.rb index e3c375aa324..457c0928f27 100644 --- a/test/remote/gateways/remote_cardknox_test.rb +++ b/test/remote/gateways/remote_cardknox_test.rb @@ -149,7 +149,6 @@ def test_failed_credit_card_authorize_partial_refund assert refund = @gateway.refund(@amount-1, auth.authorization) assert_failure refund assert_equal 'Refund not allowed on non-captured auth.', refund.message - end def test_failed_partial_check_refund # the gate way does not support this transaction diff --git a/test/remote/gateways/remote_cecabank_test.rb b/test/remote/gateways/remote_cecabank_test.rb index 1a6c0131cd2..108fb3ea106 100644 --- a/test/remote/gateways/remote_cecabank_test.rb +++ b/test/remote/gateways/remote_cecabank_test.rb @@ -26,7 +26,6 @@ def test_unsuccessful_purchase assert_equal 'ERROR', response.message end - def test_successful_refund purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase diff --git a/test/remote/gateways/remote_creditcall_test.rb b/test/remote/gateways/remote_creditcall_test.rb index d84c8695f10..527d60979a6 100644 --- a/test/remote/gateways/remote_creditcall_test.rb +++ b/test/remote/gateways/remote_creditcall_test.rb @@ -167,6 +167,5 @@ def test_transcript_scrubbing assert_scrubbed(@credit_card.number, transcript) assert_scrubbed(@credit_card.verification_value, transcript) assert_scrubbed(@gateway.options[:transaction_key], transcript) - end end diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb index 48fc84c0443..d3af9274365 100644 --- a/test/remote/gateways/remote_cyber_source_test.rb +++ b/test/remote/gateways/remote_cyber_source_test.rb @@ -300,7 +300,6 @@ def test_successful_subscription_purchase assert response.test? end - def test_successful_subscription_credit assert response = @gateway.store(@credit_card, @subscription_options) assert_equal 'Successful transaction', response.message diff --git a/test/remote/gateways/remote_first_giving_test.rb b/test/remote/gateways/remote_first_giving_test.rb index f884bcc8c04..9c689eb81c1 100644 --- a/test/remote/gateways/remote_first_giving_test.rb +++ b/test/remote/gateways/remote_first_giving_test.rb @@ -2,7 +2,6 @@ class RemoteFirstGivingTest < Test::Unit::TestCase - def setup @gateway = FirstGivingGateway.new(fixtures(:first_giving)) diff --git a/test/remote/gateways/remote_forte_test.rb b/test/remote/gateways/remote_forte_test.rb index 4fdc41bb801..4be212bd5c7 100644 --- a/test/remote/gateways/remote_forte_test.rb +++ b/test/remote/gateways/remote_forte_test.rb @@ -24,7 +24,6 @@ def setup description: 'Store Purchase', order_id: '1' } - end def test_invalid_login diff --git a/test/remote/gateways/remote_iveri_test.rb b/test/remote/gateways/remote_iveri_test.rb index 11935d75858..16733284a46 100644 --- a/test/remote/gateways/remote_iveri_test.rb +++ b/test/remote/gateways/remote_iveri_test.rb @@ -48,7 +48,6 @@ def test_successful_purchase_with_3ds_params assert_equal 'Succeeded', response.message end - def test_failed_purchase response = @gateway.purchase(@amount, @bad_card, @options) assert_failure response diff --git a/test/remote/gateways/remote_jetpay_test.rb b/test/remote/gateways/remote_jetpay_test.rb index 29f0c40b01b..d5d331a72f1 100644 --- a/test/remote/gateways/remote_jetpay_test.rb +++ b/test/remote/gateways/remote_jetpay_test.rb @@ -75,7 +75,6 @@ def test_ud_fields_on_capture assert_success capture end - def test_void # must void a valid auth assert auth = @gateway.authorize(9900, @credit_card, @options) @@ -84,7 +83,6 @@ def test_void assert_not_nil auth.authorization assert_not_nil auth.params['approval'] - assert void = @gateway.void(auth.authorization) assert_success void end diff --git a/test/remote/gateways/remote_jetpay_v2_test.rb b/test/remote/gateways/remote_jetpay_v2_test.rb index cffb44cafe6..10f1ea6322f 100644 --- a/test/remote/gateways/remote_jetpay_v2_test.rb +++ b/test/remote/gateways/remote_jetpay_v2_test.rb @@ -100,7 +100,6 @@ def test_successful_void assert_not_nil auth.authorization assert_not_nil auth.params['approval'] - assert void = @gateway.void(auth.authorization, @options) assert_success void end diff --git a/test/remote/gateways/remote_linkpoint_test.rb b/test/remote/gateways/remote_linkpoint_test.rb index d7a14b214f7..3b2e78e9fb6 100644 --- a/test/remote/gateways/remote_linkpoint_test.rb +++ b/test/remote/gateways/remote_linkpoint_test.rb @@ -96,7 +96,6 @@ def test_successfull_purchase_with_item_entity {:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'}]}) assert purchase = @gateway.purchase(1500, @credit_card, @options) assert_success purchase - end def test_successful_recurring_payment diff --git a/test/remote/gateways/remote_litle_certification_test.rb b/test/remote/gateways/remote_litle_certification_test.rb index 94ed48e24e9..90335ac3a7b 100644 --- a/test/remote/gateways/remote_litle_certification_test.rb +++ b/test/remote/gateways/remote_litle_certification_test.rb @@ -170,13 +170,11 @@ def test6 assert_equal 'P', response.cvv_result['code'] puts "Test #{options[:order_id]} Sale: #{txn_id(response)}" - # 6A. void assert response = @gateway.void(response.authorization, {:order_id => '6A'}) assert_equal '360', response.params['response'] assert_equal 'No transaction found with specified transaction Id', response.message puts "Test #{options[:order_id]}A: #{txn_id(response)}" - end def test7 @@ -1208,7 +1206,6 @@ def sale_assertions(amount, card, options, assertions={}) assert_equal auth_code(options[:order_id]), response.params['authCode'] puts "Test #{options[:order_id]} Sale: #{txn_id(response)}" - # 1B: credit assert response = @gateway.credit(amount, response.authorization, {:id => transaction_id}) assert_equal 'Approved', response.message diff --git a/test/remote/gateways/remote_modern_payments_test.rb b/test/remote/gateways/remote_modern_payments_test.rb index c0ec1040d63..cb5d594afa7 100644 --- a/test/remote/gateways/remote_modern_payments_test.rb +++ b/test/remote/gateways/remote_modern_payments_test.rb @@ -14,7 +14,6 @@ def setup :billing_address => address, :description => 'Store Purchase' } - end def test_successful_purchase diff --git a/test/remote/gateways/remote_nmi_test.rb b/test/remote/gateways/remote_nmi_test.rb index c98b29dcaac..e6d3701994a 100644 --- a/test/remote/gateways/remote_nmi_test.rb +++ b/test/remote/gateways/remote_nmi_test.rb @@ -160,7 +160,6 @@ def test_successful_refund_with_echeck assert_equal 'Succeeded', response.message end - def test_successful_credit response = @gateway.credit(@amount, @credit_card, @options) assert_success response diff --git a/test/remote/gateways/remote_pay_junction_test.rb b/test/remote/gateways/remote_pay_junction_test.rb index 79cea0c85b4..7514b3c8a5a 100644 --- a/test/remote/gateways/remote_pay_junction_test.rb +++ b/test/remote/gateways/remote_pay_junction_test.rb @@ -136,6 +136,7 @@ def test_should_send_invoice end private + def success_price 200 + rand(200) end diff --git a/test/remote/gateways/remote_payscout_test.rb b/test/remote/gateways/remote_payscout_test.rb index d212f32845b..ce0a0768a1e 100644 --- a/test/remote/gateways/remote_payscout_test.rb +++ b/test/remote/gateways/remote_payscout_test.rb @@ -21,13 +21,11 @@ def test_cvv_fail_purchase @credit_card = credit_card('4111111111111111') assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_success response assert_equal 'The transaction has been approved', response.message assert_equal 'N', response.cvv_result['code'] end - def test_approved_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response diff --git a/test/remote/gateways/remote_quickpay_v4_test.rb b/test/remote/gateways/remote_quickpay_v4_test.rb index 8e1035c8c61..9eb4ca69970 100644 --- a/test/remote/gateways/remote_quickpay_v4_test.rb +++ b/test/remote/gateways/remote_quickpay_v4_test.rb @@ -51,8 +51,6 @@ def test_successful_purchase_with_all_fraud_parameters assert !response.authorization.blank? end - - def test_successful_usd_purchase assert response = @gateway.purchase(@amount, @visa, @options.update(:currency => 'USD')) assert_equal 'OK', response.message diff --git a/test/remote/gateways/remote_quickpay_v5_test.rb b/test/remote/gateways/remote_quickpay_v5_test.rb index 83ea83bb645..02838bf2bb8 100644 --- a/test/remote/gateways/remote_quickpay_v5_test.rb +++ b/test/remote/gateways/remote_quickpay_v5_test.rb @@ -51,8 +51,6 @@ def test_successful_purchase_with_all_fraud_parameters assert !response.authorization.blank? end - - def test_successful_usd_purchase assert response = @gateway.purchase(@amount, @visa, @options.update(:currency => 'USD')) assert_equal 'OK', response.message diff --git a/test/remote/gateways/remote_quickpay_v6_test.rb b/test/remote/gateways/remote_quickpay_v6_test.rb index 6566f5a0900..2d113657c0c 100644 --- a/test/remote/gateways/remote_quickpay_v6_test.rb +++ b/test/remote/gateways/remote_quickpay_v6_test.rb @@ -51,8 +51,6 @@ def test_successful_purchase_with_all_fraud_parameters assert !response.authorization.blank? end - - def test_successful_usd_purchase assert response = @gateway.purchase(@amount, @visa, @options.update(:currency => 'USD')) assert_equal 'OK', response.message diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb index 7cff61befad..73ec653e86f 100644 --- a/test/remote/gateways/remote_realex_test.rb +++ b/test/remote/gateways/remote_realex_test.rb @@ -105,7 +105,6 @@ def test_realex_purchase_declined assert_equal '101', response.params['result'] assert_equal response.params['message'], response.message end - end def test_realex_purchase_with_apple_pay_declined @@ -141,7 +140,6 @@ def test_realex_purchase_referral_a assert_equal '103', response.params['result'] assert_equal RealexGateway::DECLINED, response.message end - end def test_realex_purchase_coms_error @@ -157,7 +155,6 @@ def test_realex_purchase_coms_error assert_equal '200', response.params['result'] assert_equal RealexGateway::BANK_ERROR, response.message end - end def test_realex_expiry_month_error diff --git a/test/remote/gateways/remote_redsys_sha256_test.rb b/test/remote/gateways/remote_redsys_sha256_test.rb index 28e95aad071..8d3a2bbf8f1 100644 --- a/test/remote/gateways/remote_redsys_sha256_test.rb +++ b/test/remote/gateways/remote_redsys_sha256_test.rb @@ -177,6 +177,7 @@ def test_whitespace_string_cvv_transcript_scrubbing assert_equal clean_transcript.include?('[BLANK]'), true end + private def generate_order_id diff --git a/test/remote/gateways/remote_redsys_test.rb b/test/remote/gateways/remote_redsys_test.rb index 5cc9ae08273..0dcaf5a017e 100644 --- a/test/remote/gateways/remote_redsys_test.rb +++ b/test/remote/gateways/remote_redsys_test.rb @@ -179,6 +179,7 @@ def test_whitespace_string_cvv_transcript_scrubbing assert_equal clean_transcript.include?('[BLANK]'), true end + private def generate_order_id diff --git a/test/remote/gateways/remote_so_easy_pay_test.rb b/test/remote/gateways/remote_so_easy_pay_test.rb index 8803620f610..791a5343505 100644 --- a/test/remote/gateways/remote_so_easy_pay_test.rb +++ b/test/remote/gateways/remote_so_easy_pay_test.rb @@ -2,7 +2,6 @@ class RemoteSoEasyPayTest < Test::Unit::TestCase - def setup @gateway = SoEasyPayGateway.new(fixtures(:so_easy_pay)) diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb index ed32f7e9f1d..f2045dcd4e1 100644 --- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb +++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb @@ -76,7 +76,6 @@ def test_successful_purchase_with_only_required assert_equal 'CVV matches', response.cvv_result['message'] end - def test_successful_purchase_without_cvv credit_card_opts = { :number => 4485896261017708, diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index ae768a760d5..f32933a1010 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -240,7 +240,6 @@ def test_transcript_scrubbing assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript) end - # Worldpay has a delay between asking for a transaction to be captured and actually marking it as captured # These 2 tests work if you get authorizations from a purchase, wait some time and then perform the refund/void operation. diff --git a/test/test_helper.rb b/test/test_helper.rb index 1f1159493c5..dbfeb798930 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -127,6 +127,7 @@ def assert_scrubbed(unexpected_value, transcript) end private + def clean_backtrace(&block) yield rescue AssertionClass => e @@ -141,6 +142,7 @@ module Fixtures DEFAULT_CREDENTIALS = File.join(File.dirname(__FILE__), 'fixtures.yml') unless defined?(DEFAULT_CREDENTIALS) private + def default_expiration_date @default_expiration_date ||= Date.new((Time.now.year + 1), 9, 30) end @@ -325,12 +327,12 @@ def url_for(options, *parameters_for_method_reference) end protected + def protect_against_forgery? false end end - class MockResponse attr_reader :code, :body, :message attr_accessor :headers diff --git a/test/unit/gateways/allied_wallet_test.rb b/test/unit/gateways/allied_wallet_test.rb index c3d1d390fd9..fb291c7c4b4 100644 --- a/test/unit/gateways/allied_wallet_test.rb +++ b/test/unit/gateways/allied_wallet_test.rb @@ -278,7 +278,6 @@ def failed_refund_response ) end - def empty_purchase_response %( { @@ -297,7 +296,6 @@ def invalid_json_response ) end - def transcript %( <- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer AAEAAHwXaLTYs2APKJW_4TpTDwCw_h9oDx9rA58FR78AFuYCX82Izes1nz9qGBXELGUN_EukKcP5T78Th5guDz4Rw5dQ4Gf0suKw7pz9vWrqa1NpZhrD9Lj9T-SFtOJgfodiwVaBBeSgbJLKA7MOzC9q2dv91HBNP69DygL1oX2L2mtt8fWlKSWhQmtG040E1I43jTueX3L3L9YA7iO6pIwO7CGybE5LnjkQ65KB2K4oYKfXRZosF77hgMJIh-KprFy9cYY3EjfupHeLon9im1BGafrda2N5wj_A_LvdMzfLAD1l1dgj82KlvM_gAzNJ4S19gAicRo9zIbsq36Apt-8jFjS0AQAAAAEAAA9Zr_lVLKMmmtKSo6T_9ulzMCRbYs798EpFD2wMlkb1NCQtA65VrNcM20Ka2FjNQfwOcSMWqDl9zFQhPyFl-npsG1Ww2oyyavA6HSe1HLRLtE_1hNBAlTBPQnLJ6hBf8eR_NTiVa-aQdV2l92-eSwCS59CzrOYGGCY1pLdNMDr_r66kg9l-l94154kRoMBRQSCqZV9iM9M-f3adLJqG6Q79zz1oJpGrH-Zv1kuv8eLaJJNOEFYARb0JbnAC5G1l9-aqxGvBrNkd4sAJIe23XrRx2XJCBIABxuGSQ1xJBTINVlXBXq1mvvd8B1uiYiDNia3c_vIGuSGIjZE0VbUN3oJppfCt1joGdePeUaC2Pyb2vuUN00EBEOaD9RF8IBWMLVJaF9cW2OewDOfBQg94MuOKLdXB_IisRx1ed25VQDVyv0f0CxmkAidvoDN0vvRIJZJr-bgBuL5FZM7gETAeYeiGlh7-Mf2Hzgy7236YNxcC9OnWFEcKEU50nlqog1bJnk8wJgoJWNqG0NUEK4DUzYqknmZ98qQv6rYrg5V-Hey-jAQp_KNf3h-vFHVZdP26Yg\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n" diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index f80be4fbb8f..1ceaefd3d56 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -879,7 +879,6 @@ def test_avs_result assert_equal 'Y', response.avs_result['street_match'] assert_equal 'Y', response.avs_result['postal_match'] - @gateway.expects(:ssl_post).returns(address_not_provided_avs_response) response = @gateway.purchase(@amount, @credit_card) @@ -2209,7 +2208,6 @@ def failed_refund_using_stored_card_response </messages> </createCustomerProfileTransactionResponse> eos - end def successful_void_using_stored_card_response diff --git a/test/unit/gateways/balanced_test.rb b/test/unit/gateways/balanced_test.rb index 652b27fd084..f405a513edf 100644 --- a/test/unit/gateways/balanced_test.rb +++ b/test/unit/gateways/balanced_test.rb @@ -539,7 +539,6 @@ def authorized_partial_debits_response RESPONSE end - def declined_response <<-RESPONSE { diff --git a/test/unit/gateways/banwire_test.rb b/test/unit/gateways/banwire_test.rb index 7f65c6c7277..77207753a74 100644 --- a/test/unit/gateways/banwire_test.rb +++ b/test/unit/gateways/banwire_test.rb @@ -89,7 +89,6 @@ def test_transcript_scrubbing assert_equal scrubbed_transcript, @gateway.scrub(transcript) end - private def failed_purchase_response diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb index 92866caab82..a140fed4317 100644 --- a/test/unit/gateways/beanstream_test.rb +++ b/test/unit/gateways/beanstream_test.rb @@ -162,7 +162,6 @@ def test_failed_verify assert_equal 'DECLINE', response.message end - # Testing Non-American countries def test_german_address_sets_state_to_the_required_dummy_value diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb index 713b387278c..089efee347b 100644 --- a/test/unit/gateways/blue_pay_test.rb +++ b/test/unit/gateways/blue_pay_test.rb @@ -68,7 +68,6 @@ def test_add_address assert_equal 'AK', result[:STATE] assert_equal '123 Test St.', result[:ADDR1] assert_equal 'US', result[:COUNTRY] - end def test_name_comes_from_payment_method @@ -177,7 +176,6 @@ def test_cvv_result end def test_message_from - def get_msg(query) @gateway.send(:parse, query).message end diff --git a/test/unit/gateways/card_connect_test.rb b/test/unit/gateways/card_connect_test.rb index 704a89ec6ef..d0e424e7be2 100644 --- a/test/unit/gateways/card_connect_test.rb +++ b/test/unit/gateways/card_connect_test.rb @@ -192,7 +192,6 @@ def test_successful_unstore end def test_failed_unstore - end def test_scrub diff --git a/test/unit/gateways/card_stream_test.rb b/test/unit/gateways/card_stream_test.rb index 8eab0ad4030..340f954a5e7 100644 --- a/test/unit/gateways/card_stream_test.rb +++ b/test/unit/gateways/card_stream_test.rb @@ -196,7 +196,6 @@ def test_failed_verify end def test_purchase_options - # Default purchase = stub_comms do @gateway.purchase(142, @visacreditcard, @visacredit_options) diff --git a/test/unit/gateways/cashnet_test.rb b/test/unit/gateways/cashnet_test.rb index a3e00477a0e..af7ab9fa0bd 100644 --- a/test/unit/gateways/cashnet_test.rb +++ b/test/unit/gateways/cashnet_test.rb @@ -147,6 +147,7 @@ def test_scrub end private + def expected_expiration_date '%02d%02d' % [@credit_card.month, @credit_card.year.to_s[2..4]] end diff --git a/test/unit/gateways/cecabank_test.rb b/test/unit/gateways/cecabank_test.rb index e21446ea95e..3ed551400fe 100644 --- a/test/unit/gateways/cecabank_test.rb +++ b/test/unit/gateways/cecabank_test.rb @@ -77,7 +77,6 @@ def test_transcript_scrubbing assert_equal scrubbed_transcript, @gateway.scrub(transcript) end - private def successful_purchase_response diff --git a/test/unit/gateways/cenpos_test.rb b/test/unit/gateways/cenpos_test.rb index e43caa1a1a4..950701578bd 100644 --- a/test/unit/gateways/cenpos_test.rb +++ b/test/unit/gateways/cenpos_test.rb @@ -307,7 +307,6 @@ def failed_refund_response ) end - def successful_credit_response %( <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><ProcessCreditCardResponse xmlns="http://tempuri.org/"><ProcessCreditCardResult i:type="a:ProcessRecurringSaleResponse" xmlns:a="http://schemas.datacontract.org/2004/07/Acriter.ABI.CenPOS.EPayment.VirtualTerminal.v6.Common" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Message xmlns="http://schemas.datacontract.org/2004/07/Acriter.ABI.CenPOS.EPayment.VirtualTerminal.Common">Approved</Message><Result xmlns="http://schemas.datacontract.org/2004/07/Acriter.ABI.CenPOS.EPayment.VirtualTerminal.Common">0</Result><a:AccountBalanceAmount i:nil="true"/><a:Amount>91.13</a:Amount><a:AutorizationNumber i:nil="true"/><a:CardType>VISA</a:CardType><a:Discount>0</a:Discount><a:DiscountAmount>0</a:DiscountAmount><a:EmvData i:nil="true"/><a:OriginalAmount>91.13</a:OriginalAmount><a:ParameterValidationResultList/><a:PartiallyAuthorizedAmount i:nil="true"/><a:ReferenceNumber>1609996211</a:ReferenceNumber><a:Surcharge>0</a:Surcharge><a:SurchargeAmount>0</a:SurchargeAmount><a:TraceNumber i:nil="true"/><a:ProtectedCardNumber i:nil="true"/><a:RecurringSaleTokenId i:nil="true"/></ProcessCreditCardResult></ProcessCreditCardResponse></s:Body></s:Envelope> diff --git a/test/unit/gateways/commercegate_test.rb b/test/unit/gateways/commercegate_test.rb index 5fe0e065ba0..eeb2f2e13ea 100644 --- a/test/unit/gateways/commercegate_test.rb +++ b/test/unit/gateways/commercegate_test.rb @@ -59,7 +59,6 @@ def test_successful_refund assert_equal 'EUR', response.params['currencyCode'] end - def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) assert response = @gateway.void('100130291412', @options) diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index e0765ea00fa..96dce2add49 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -88,7 +88,6 @@ def test_authorize_includes_mdd_fields end.respond_with(successful_authorization_response) end - def test_successful_check_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) diff --git a/test/unit/gateways/data_cash_test.rb b/test/unit/gateways/data_cash_test.rb index e7443c2d195..a4f24b4a457 100644 --- a/test/unit/gateways/data_cash_test.rb +++ b/test/unit/gateways/data_cash_test.rb @@ -122,6 +122,7 @@ def test_capture_method_is_ecomm end private + def failed_purchase_response <<-XML <Response> diff --git a/test/unit/gateways/digitzs_test.rb b/test/unit/gateways/digitzs_test.rb index ede14ff24f2..99b57ddc432 100644 --- a/test/unit/gateways/digitzs_test.rb +++ b/test/unit/gateways/digitzs_test.rb @@ -231,7 +231,6 @@ def successful_split_purchase_response ) end - def failed_purchase_response %( {\"meta\":{},\"errors\":[{\"status\":\"400\",\"source\":{\"pointer\":\"/payments\"},\"title\":\"Bad Request\",\"detail\":\"Partner error: Credit card declined (transaction element shows reason for decline)\",\"code\":\"58\",\"meta\":{\"debug\":{\"message\":\"Include debug info with support request.\",\"resource\":\"/payments POST\",\"log\":\"2017/02/02/[23]eb325f3ca78b4f7eb2178a0d1e635a0e\",\"request\":\"73c22dc3-e980-11e6-9390-69c24d5ed1f4\"},\"transaction\":{\"code\":\"51\",\"message\":\"Insufficient funds\",\"invoice\":\"3d1f247d9112349e3db252f9f3327047\",\"authCode\":\"A11111\",\"avsResult\":\"T\"}}}]} diff --git a/test/unit/gateways/efsnet_test.rb b/test/unit/gateways/efsnet_test.rb index 1a3528186ef..e437e2aa422 100644 --- a/test/unit/gateways/efsnet_test.rb +++ b/test/unit/gateways/efsnet_test.rb @@ -22,7 +22,6 @@ def test_successful_purchase assert response.test? assert_equal '100018347764;1.00', response.authorization assert_equal 'Approved', response.message - end def test_unsuccessful_purchase @@ -92,6 +91,7 @@ def test_cvv_result end private + def successful_purchase_response <<-XML <?xml version="1.0"?> diff --git a/test/unit/gateways/element_test.rb b/test/unit/gateways/element_test.rb index c731345435d..253cfcdccbf 100644 --- a/test/unit/gateways/element_test.rb +++ b/test/unit/gateways/element_test.rb @@ -61,6 +61,7 @@ def test_failed_purchase_with_payment_account_token response = @gateway.purchase(@amount, 'bad-payment-account-token-id', @options) assert_failure response end + def test_successful_authorize @gateway.expects(:ssl_post).returns(successful_authorize_response) diff --git a/test/unit/gateways/eway_managed_test.rb b/test/unit/gateways/eway_managed_test.rb index abcfa3dd6e0..b8f0f421e7a 100644 --- a/test/unit/gateways/eway_managed_test.rb +++ b/test/unit/gateways/eway_managed_test.rb @@ -125,7 +125,6 @@ def test_purchase_invoice_reference_comes_from_order_id_or_invoice request_hash['Envelope']['Body']['ProcessPayment']['invoiceReference'] == 'order_id' }.returns(successful_purchase_response) @gateway.purchase(@amount, @valid_customer_id, options) - end def test_invalid_customer_id diff --git a/test/unit/gateways/eway_test.rb b/test/unit/gateways/eway_test.rb index 5dbe984051a..bae6c709504 100644 --- a/test/unit/gateways/eway_test.rb +++ b/test/unit/gateways/eway_test.rb @@ -97,6 +97,7 @@ def test_transcript_scrubbing end private + def successful_purchase_response <<-XML <?xml version="1.0"?> diff --git a/test/unit/gateways/exact_test.rb b/test/unit/gateways/exact_test.rb index 1566816809e..b48a4170d74 100644 --- a/test/unit/gateways/exact_test.rb +++ b/test/unit/gateways/exact_test.rb @@ -48,7 +48,6 @@ def test_failed_purchase assert_failure response end - def test_expdate assert_equal( '%02d%s' % [ @credit_card.month, @credit_card.year.to_s[-2..-1] ], @@ -85,8 +84,8 @@ def test_cvv_result assert_equal 'M', response.cvv_result['code'] end - private + def successful_purchase_response <<-RESPONSE <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/" xmlns:types="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><q1:SendAndCommitResponse xmlns:q1="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/Response"><SendAndCommitResult href="#id1" /></q1:SendAndCommitResponse><types:TransactionResult id="id1" xsi:type="types:TransactionResult"><ExactID xsi:type="xsd:string">A00427-01</ExactID><Password xsi:type="xsd:string">#######</Password><Transaction_Type xsi:type="xsd:string">00</Transaction_Type><DollarAmount xsi:type="xsd:string">1</DollarAmount><SurchargeAmount xsi:type="xsd:string">0</SurchargeAmount><Card_Number xsi:type="xsd:string">4242424242424242</Card_Number><Transaction_Tag xsi:type="xsd:string">106625152</Transaction_Tag><Authorization_Num xsi:type="xsd:string">ET1700</Authorization_Num><Expiry_Date xsi:type="xsd:string">0909</Expiry_Date><CardHoldersName xsi:type="xsd:string">Longbob Longsen</CardHoldersName><VerificationStr2 xsi:type="xsd:string">123</VerificationStr2><CVD_Presence_Ind xsi:type="xsd:string">1</CVD_Presence_Ind><Secure_AuthRequired xsi:type="xsd:string">0</Secure_AuthRequired><Secure_AuthResult xsi:type="xsd:string">0</Secure_AuthResult><Ecommerce_Flag xsi:type="xsd:string">0</Ecommerce_Flag><CAVV_Algorithm xsi:type="xsd:string">0</CAVV_Algorithm><Reference_No xsi:type="xsd:string">1</Reference_No><Reference_3 xsi:type="xsd:string">Store Purchase</Reference_3><Language xsi:type="xsd:string">0</Language><LogonMessage xsi:type="xsd:string">Processed by: @@ -122,6 +121,7 @@ def successful_purchase_response </CTR></types:TransactionResult></soap:Body></soap:Envelope> RESPONSE end + def successful_refund_response <<-RESPONSE <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/" xmlns:types="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><q1:SendAndCommitResponse xmlns:q1="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/Response"><SendAndCommitResult href="#id1" /></q1:SendAndCommitResponse><types:TransactionResult id="id1" xsi:type="types:TransactionResult"><ExactID xsi:type="xsd:string">A00427-01</ExactID><Password xsi:type="xsd:string">#######</Password><Transaction_Type xsi:type="xsd:string">00</Transaction_Type><DollarAmount xsi:type="xsd:string">1</DollarAmount><SurchargeAmount xsi:type="xsd:string">0</SurchargeAmount><Card_Number xsi:type="xsd:string">4242424242424242</Card_Number><Transaction_Tag xsi:type="xsd:string">106625152</Transaction_Tag><Authorization_Num xsi:type="xsd:string">ET1700</Authorization_Num><Expiry_Date xsi:type="xsd:string">0909</Expiry_Date><CardHoldersName xsi:type="xsd:string">Longbob Longsen</CardHoldersName><VerificationStr2 xsi:type="xsd:string">123</VerificationStr2><CVD_Presence_Ind xsi:type="xsd:string">1</CVD_Presence_Ind><Secure_AuthRequired xsi:type="xsd:string">0</Secure_AuthRequired><Secure_AuthResult xsi:type="xsd:string">0</Secure_AuthResult><Ecommerce_Flag xsi:type="xsd:string">0</Ecommerce_Flag><CAVV_Algorithm xsi:type="xsd:string">0</CAVV_Algorithm><Reference_No xsi:type="xsd:string">1</Reference_No><Reference_3 xsi:type="xsd:string">Store Purchase</Reference_3><Language xsi:type="xsd:string">0</Language><LogonMessage xsi:type="xsd:string">Processed by: diff --git a/test/unit/gateways/fat_zebra_test.rb b/test/unit/gateways/fat_zebra_test.rb index 2251655ff70..e802111c648 100644 --- a/test/unit/gateways/fat_zebra_test.rb +++ b/test/unit/gateways/fat_zebra_test.rb @@ -236,6 +236,7 @@ def post_scrubbed Conn close POST_SCRUBBED end + # Place raw successful response from gateway here def successful_purchase_response { diff --git a/test/unit/gateways/federated_canada_test.rb b/test/unit/gateways/federated_canada_test.rb index 2e7daeb5718..0e9497ae03c 100644 --- a/test/unit/gateways/federated_canada_test.rb +++ b/test/unit/gateways/federated_canada_test.rb @@ -26,8 +26,7 @@ def test_successful_authorization assert_success response assert_equal '1355694937', response.authorization assert_equal 'auth', response.params['type'] - end - + end def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) @@ -69,8 +68,7 @@ def test_purchase_is_valid_csv assert data = @gateway.send(:post_data, 'auth', params) assert_equal post_data_fixture.size, data.size - end - + end def test_purchase_meets_minimum_requirements params = {:amount => @amount} diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb index a970aaccff8..7758d68a0e1 100755 --- a/test/unit/gateways/firstdata_e4_test.rb +++ b/test/unit/gateways/firstdata_e4_test.rb @@ -481,6 +481,7 @@ def successful_purchase_response </TransactionResult> RESPONSE end + def successful_purchase_with_specified_currency_response <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?> @@ -569,6 +570,7 @@ def successful_purchase_with_specified_currency_response </TransactionResult> RESPONSE end + def successful_purchase_response_without_transarmor <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?> @@ -657,6 +659,7 @@ def successful_purchase_response_without_transarmor </TransactionResult> RESPONSE end + def successful_refund_response <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?> diff --git a/test/unit/gateways/gateway_test.rb b/test/unit/gateways/gateway_test.rb index 3334a916a07..f8f29c235be 100644 --- a/test/unit/gateways/gateway_test.rb +++ b/test/unit/gateways/gateway_test.rb @@ -116,7 +116,6 @@ def test_split_names_with_empty_names assert_equal [nil, nil], @gateway.send(:split_names, ' ') end - def test_supports_scrubbing? gateway = Gateway.new refute gateway.supports_scrubbing? diff --git a/test/unit/gateways/iridium_test.rb b/test/unit/gateways/iridium_test.rb index b772f91408e..055afb50653 100644 --- a/test/unit/gateways/iridium_test.rb +++ b/test/unit/gateways/iridium_test.rb @@ -36,7 +36,6 @@ def test_unsuccessful_request assert response.test? end - def test_successful_authorize @gateway.expects(:ssl_post).returns(successful_authorize_response) @@ -110,12 +109,10 @@ def test_use_ducktyping_for_credit_card end end - def test_transcript_scrubbing assert_equal post_scrubbed, @gateway.scrub(pre_scrubbed) end - private # Place raw successful response from gateway here diff --git a/test/unit/gateways/jetpay_test.rb b/test/unit/gateways/jetpay_test.rb index aafc7966e83..91069432c3e 100644 --- a/test/unit/gateways/jetpay_test.rb +++ b/test/unit/gateways/jetpay_test.rb @@ -141,6 +141,7 @@ def test_purchase_sends_order_origin end private + def successful_purchase_response <<-EOF <JetPayResponse> diff --git a/test/unit/gateways/linkpoint_test.rb b/test/unit/gateways/linkpoint_test.rb index 8de27a522f8..9cbbd9897b0 100644 --- a/test/unit/gateways/linkpoint_test.rb +++ b/test/unit/gateways/linkpoint_test.rb @@ -119,7 +119,6 @@ def test_line_items_are_valid_xml '12.00', :quantity => '1', :options => [{:name => 'Color', :value => 'Red'}, {:name => 'Size', :value => 'XL'}]},{:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'}]} - assert data = @gateway.send(:post_data, @amount, @credit_card, options) assert REXML::Document.new(data) end @@ -191,6 +190,7 @@ def test_transcript_scrubbing end private + def successful_authorization_response '<r_csp>CSI</r_csp><r_time>Sun Jan 6 21:41:31 2008</r_time><r_ref>0004486182</r_ref><r_error/><r_ordernum>1000</r_ordernum><r_message>APPROVED</r_message><r_code>1234560004486182:NNNM:100018312899:</r_code><r_tdate>1199680890</r_tdate><r_score/><r_authresponse/><r_approved>APPROVED</r_approved><r_avs>NNNM</r_avs>' end diff --git a/test/unit/gateways/litle_test.rb b/test/unit/gateways/litle_test.rb index 59cd7af5969..652ea34eb84 100644 --- a/test/unit/gateways/litle_test.rb +++ b/test/unit/gateways/litle_test.rb @@ -396,7 +396,6 @@ def test_supports_scrubbing? assert @gateway.supports_scrubbing? end - private def successful_purchase_response diff --git a/test/unit/gateways/maxipago_test.rb b/test/unit/gateways/maxipago_test.rb index 04215332445..b437bcda00a 100644 --- a/test/unit/gateways/maxipago_test.rb +++ b/test/unit/gateways/maxipago_test.rb @@ -74,7 +74,6 @@ def test_successful_void void = @gateway.void(auth.authorization) assert_success void assert_equal 'VOIDED', void.params['response_message'] - end def test_failed_void diff --git a/test/unit/gateways/merchant_partners_test.rb b/test/unit/gateways/merchant_partners_test.rb index 77930e9830d..3307fa37d61 100644 --- a/test/unit/gateways/merchant_partners_test.rb +++ b/test/unit/gateways/merchant_partners_test.rb @@ -628,7 +628,6 @@ def failed_credit_response ) end - def successful_store_response %(<?xml version="1.0"?><interface_driver> <trans_catalog> diff --git a/test/unit/gateways/metrics_global_test.rb b/test/unit/gateways/metrics_global_test.rb index e16afd5dd8f..5082a40facc 100644 --- a/test/unit/gateways/metrics_global_test.rb +++ b/test/unit/gateways/metrics_global_test.rb @@ -61,7 +61,6 @@ def test_add_address assert_equal 'CO', result[:state] assert_equal '164 Waverley Street', result[:address] assert_equal 'US', result[:country] - end def test_add_invoice diff --git a/test/unit/gateways/moneris_us_test.rb b/test/unit/gateways/moneris_us_test.rb index 9d358635147..46aa128e20b 100644 --- a/test/unit/gateways/moneris_us_test.rb +++ b/test/unit/gateways/moneris_us_test.rb @@ -98,7 +98,6 @@ def test_amount_style end def test_preauth_is_valid_xml - params = { :order_id => 'order1', :amount => '1.01', @@ -113,7 +112,6 @@ def test_preauth_is_valid_xml end def test_purchase_is_valid_xml - params = { :order_id => 'order1', :amount => '1.01', @@ -128,7 +126,6 @@ def test_purchase_is_valid_xml end def test_capture_is_valid_xml - params = { :order_id => 'order1', :amount => '1.01', diff --git a/test/unit/gateways/ncr_secure_pay_test.rb b/test/unit/gateways/ncr_secure_pay_test.rb index f1b8de1eccd..4fabb3b8779 100644 --- a/test/unit/gateways/ncr_secure_pay_test.rb +++ b/test/unit/gateways/ncr_secure_pay_test.rb @@ -16,7 +16,6 @@ def setup end def test_successful_purchase - response = stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| @@ -42,7 +41,6 @@ def test_failed_purchase end def test_successful_authorize - response = stub_comms do @gateway.authorize(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| @@ -67,7 +65,6 @@ def test_failed_authorize end def test_successful_capture - response = stub_comms do @gateway.capture(@amount, '12345', @options) end.check_request do |endpoint, data, headers| @@ -91,7 +88,6 @@ def test_failed_capture end def test_successful_refund - response = stub_comms do @gateway.refund(@amount, '12345', @options) end.check_request do |endpoint, data, headers| @@ -115,7 +111,6 @@ def test_failed_refund end def test_successful_void - response = stub_comms do @gateway.void('12345', @options) end.check_request do |endpoint, data, headers| @@ -138,7 +133,6 @@ def test_failed_void end def test_successful_verify - response = stub_comms do @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, successful_void_response) @@ -148,7 +142,6 @@ def test_successful_verify end def test_successful_verify_with_failed_void - response = stub_comms do @gateway.verify(@credit_card, @options) end.respond_with(successful_authorize_response, failed_void_response) @@ -158,7 +151,6 @@ def test_successful_verify_with_failed_void end def test_failed_verify - response = stub_comms do @gateway.verify(@credit_card, @options) end.respond_with(failed_authorize_response, failed_void_response) diff --git a/test/unit/gateways/net_registry_test.rb b/test/unit/gateways/net_registry_test.rb index e478e8d6151..0d6c50e2f63 100644 --- a/test/unit/gateways/net_registry_test.rb +++ b/test/unit/gateways/net_registry_test.rb @@ -105,6 +105,7 @@ def test_bad_login end private + def successful_purchase_response <<-RESPONSE approved diff --git a/test/unit/gateways/netbanx_test.rb b/test/unit/gateways/netbanx_test.rb index 56a74c156aa..ba464b8eac2 100644 --- a/test/unit/gateways/netbanx_test.rb +++ b/test/unit/gateways/netbanx_test.rb @@ -151,7 +151,6 @@ def test_successful_unstore assert response.test? end - def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed diff --git a/test/unit/gateways/netbilling_test.rb b/test/unit/gateways/netbilling_test.rb index 1230046dfe1..724e3037542 100644 --- a/test/unit/gateways/netbilling_test.rb +++ b/test/unit/gateways/netbilling_test.rb @@ -114,6 +114,7 @@ def test_transcript_scrubbing end private + def successful_purchase_response 'avs_code=X&cvv2_code=M&status_code=1&auth_code=999999&trans_id=110270311543&auth_msg=TEST+APPROVED&auth_date=2008-01-25+16:43:54' end diff --git a/test/unit/gateways/netpay_test.rb b/test/unit/gateways/netpay_test.rb index 42a47d8b3da..6b107d2e9f5 100644 --- a/test/unit/gateways/netpay_test.rb +++ b/test/unit/gateways/netpay_test.rb @@ -76,7 +76,6 @@ def test_unsuccessful_purchase assert response.test? end - def test_successful_authorize @gateway.expects(:ssl_post).with( anything, diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb index 7f1eceb5a08..b88d15665f7 100644 --- a/test/unit/gateways/optimal_payment_test.rb +++ b/test/unit/gateways/optimal_payment_test.rb @@ -212,7 +212,6 @@ def test_avs_results_not_in_response end def test_deprecated_options - assert_deprecation_warning("The 'account' option is deprecated in favor of 'account_number' and will be removed in a future version.") do @gateway = OptimalPaymentGateway.new( :account => '12345678', diff --git a/test/unit/gateways/pay_gate_xml_test.rb b/test/unit/gateways/pay_gate_xml_test.rb index c8ee14c5e70..157cd2bd89b 100644 --- a/test/unit/gateways/pay_gate_xml_test.rb +++ b/test/unit/gateways/pay_gate_xml_test.rb @@ -30,7 +30,6 @@ def test_successful_authorization assert response.test? end - def test_successful_settlement @gateway.expects(:ssl_post).returns(successful_settlement_response) @@ -103,5 +102,4 @@ def successful_refund_response ENDOFXML end - end diff --git a/test/unit/gateways/pay_junction_test.rb b/test/unit/gateways/pay_junction_test.rb index 1a94fd2a77b..16a3139be79 100644 --- a/test/unit/gateways/pay_junction_test.rb +++ b/test/unit/gateways/pay_junction_test.rb @@ -20,7 +20,6 @@ def setup @amount = 100 end - def test_detect_test_credentials_when_in_production Base.mode = :production @@ -95,8 +94,8 @@ def test_add_creditcard_with_track_data end.respond_with(successful_authorization_response) end - private + def successful_authorization_response <<-RESPONSE dc_merchant_name=PayJunction - (demo)dc_merchant_address=3 W. Carrillodc_merchant_city=Santa Barbaradc_merchant_state=CAdc_merchant_zip=93101dc_merchant_phone=800-601-0230dc_device_id=1174dc_transaction_date=2007-11-28 19:22:33.791634dc_transaction_action=chargedc_approval_code=TAS193dc_response_code=00dc_response_message=APPROVAL TAS193 dc_transaction_id=3144302dc_posture=holddc_invoice_number=9f76c4e4bd66a36dc5aeb4bd7b3a02fadc_notes=--START QUICK-LINK DEBUG-- diff --git a/test/unit/gateways/pay_secure_test.rb b/test/unit/gateways/pay_secure_test.rb index 78ea5b7b56f..32ba6132b64 100644 --- a/test/unit/gateways/pay_secure_test.rb +++ b/test/unit/gateways/pay_secure_test.rb @@ -49,6 +49,7 @@ def test_cvv_result_not_supported end private + def successful_purchase_response <<-RESPONSE Status: Accepted diff --git a/test/unit/gateways/payflow_express_uk_test.rb b/test/unit/gateways/payflow_express_uk_test.rb index 6c40fa8aca9..60a18a88be8 100644 --- a/test/unit/gateways/payflow_express_uk_test.rb +++ b/test/unit/gateways/payflow_express_uk_test.rb @@ -63,6 +63,7 @@ def test_get_express_details_with_ship_to_name end private + def successful_get_express_details_response <<-RESPONSE <?xml version="1.0"?> diff --git a/test/unit/gateways/paymill_test.rb b/test/unit/gateways/paymill_test.rb index 816b6198213..546a98b9125 100644 --- a/test/unit/gateways/paymill_test.rb +++ b/test/unit/gateways/paymill_test.rb @@ -224,6 +224,7 @@ def test_transcript_scrubbing end private + def successful_store_response MockResponse.new 200, %[jsonPFunction({"transaction":{"mode":"CONNECTOR_TEST","channel":"57313835619696ac361dc591bc973626","response":"SYNC","payment":{"code":"CC.DB"},"processing":{"code":"CC.DB.90.00","reason":{"code":"00","message":"Successful Processing"},"result":"ACK","return":{"code":"000.100.112","message":"Request successfully processed in 'Merchant in Connector Test Mode'"},"timestamp":"2013-02-12 21:33:43"},"identification":{"shortId":"1998.1832.1612","uniqueId":"tok_4f9a571b39bd8d0b4db5"}}})] end diff --git a/test/unit/gateways/paypal/paypal_common_api_test.rb b/test/unit/gateways/paypal/paypal_common_api_test.rb index 2f53c97fad3..93ecc4ce2f2 100644 --- a/test/unit/gateways/paypal/paypal_common_api_test.rb +++ b/test/unit/gateways/paypal/paypal_common_api_test.rb @@ -6,7 +6,9 @@ class CommonPaypalGateway < ActiveMerchant::Billing::Gateway include ActiveMerchant::Billing::PaypalCommonAPI def currency(code); 'USD'; end + def localized_amount(num, code); num; end + def commit(a, b); end end @@ -120,7 +122,6 @@ def test_build_do_authorize_request assert_equal '1.00', REXML::XPath.first(request, '//DoAuthorizationReq/DoAuthorizationRequest/Amount').text end - def test_build_manage_pending_transaction_status_request request = REXML::Document.new(@gateway.send(:build_manage_pending_transaction_status,123, 'Accept')) assert_equal '123', REXML::XPath.first(request, '//ManagePendingTransactionStatusReq/ManagePendingTransactionStatusRequest/TransactionID').text diff --git a/test/unit/gateways/paypal_digital_goods_test.rb b/test/unit/gateways/paypal_digital_goods_test.rb index ba8e05f12a8..cef8d773b49 100644 --- a/test/unit/gateways/paypal_digital_goods_test.rb +++ b/test/unit/gateways/paypal_digital_goods_test.rb @@ -74,7 +74,6 @@ def test_setup_request_invalid_requests end end - def test_build_setup_request_valid @gateway.expects(:ssl_post).returns(successful_setup_response) @@ -89,10 +88,8 @@ def test_build_setup_request_valid :amount => 100, :description => 'Description', :category => 'Digital' } ] ) - end - private def successful_setup_response diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb index 445dace38f4..c88f0291630 100644 --- a/test/unit/gateways/paypal_express_test.rb +++ b/test/unit/gateways/paypal_express_test.rb @@ -374,7 +374,6 @@ def test_items_are_included_if_specified_in_build_sale_or_authorization_request {:name => 'item two', :description => 'item two description', :amount => 20000, :number => 2, :quantity => 4} ]})) - assert_equal 'item one', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Name').text assert_equal 'item one description', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Description').text assert_equal '100.00', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Amount').text @@ -447,7 +446,6 @@ def test_agreement_details_failure assert_equal '11451', response.params['error_codes'] end - def test_build_reference_transaction_test PaypalExpressGateway.application_id = 'ActiveMerchant_FOO' xml = REXML::Document.new(@gateway.send(:build_reference_transaction_request, 'Sale', 2000, { @@ -666,7 +664,6 @@ def successful_create_billing_agreement_response RESPONSE end - def successful_authorize_reference_transaction_response <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?> @@ -763,7 +760,6 @@ def successful_reference_transaction_response RESPONSE end - def successful_details_response <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?> diff --git a/test/unit/gateways/paypal_test.rb b/test/unit/gateways/paypal_test.rb index 0dc0926f0ca..1b129b30330 100644 --- a/test/unit/gateways/paypal_test.rb +++ b/test/unit/gateways/paypal_test.rb @@ -1380,7 +1380,6 @@ def successful_details_response RESPONSE end - def successful_update_recurring_payment_profile_response <<-RESPONSE <?xml version=\"1.0\" encoding=\"UTF-8\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:cc=\"urn:ebay:apis:CoreComponentTypes\" xmlns:wsu=\"http://schemas.xmlsoap.org/ws/2002/07/utility\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xmlns:ed=\"urn:ebay:apis:EnhancedDataTypes\" xmlns:ebl=\"urn:ebay:apis:eBLBaseComponents\" xmlns:ns=\"urn:ebay:api:PayPalAPI\"><SOAP-ENV:Header><Security xmlns=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xsi:type=\"wsse:SecurityType\"></Security><RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\" xsi:type=\"ebl:CustomSecurityHeaderType\"><Credentials xmlns=\"urn:ebay:apis:eBLBaseComponents\" xsi:type=\"ebl:UserIdPasswordType\"><Username xsi:type=\"xs:string\"></Username><Password xsi:type=\"xs:string\"></Password><Signature xsi:type=\"xs:string\"></Signature><Subject xsi:type=\"xs:string\"></Subject></Credentials></RequesterCredentials></SOAP-ENV:Header><SOAP-ENV:Body id=\"_0\"> diff --git a/test/unit/gateways/payscout_test.rb b/test/unit/gateways/payscout_test.rb index 7e84b6e4b29..fcf69767329 100644 --- a/test/unit/gateways/payscout_test.rb +++ b/test/unit/gateways/payscout_test.rb @@ -214,7 +214,6 @@ def test_shipping_address assert_equal address[:email], post[:shipping_email] end - def test_add_currency_from_options post = {} @gateway.send(:add_currency, post, 100, { currency: 'CAD' }) diff --git a/test/unit/gateways/paystation_test.rb b/test/unit/gateways/paystation_test.rb index f49d013b5ce..1ed768b1186 100644 --- a/test/unit/gateways/paystation_test.rb +++ b/test/unit/gateways/paystation_test.rb @@ -3,7 +3,6 @@ class PaystationTest < Test::Unit::TestCase include CommStub def setup - @gateway = PaystationGateway.new( :paystation_id => 'some_id_number', :gateway_id => 'another_id_number' @@ -80,7 +79,6 @@ def test_successful_capture end def test_successful_refund - response = stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.respond_with(successful_purchase_response) diff --git a/test/unit/gateways/payway_test.rb b/test/unit/gateways/payway_test.rb index 86ae5139140..d72f7a849b0 100644 --- a/test/unit/gateways/payway_test.rb +++ b/test/unit/gateways/payway_test.rb @@ -50,7 +50,6 @@ def test_succesful_purchase_visa_from_register_user assert_match '0', response.params['summary_code'] assert_match '08', response.params['response_code'] assert_match 'VISA', response.params['card_scheme_name'] - end def test_successful_purchase_master_card diff --git a/test/unit/gateways/plugnpay_test.rb b/test/unit/gateways/plugnpay_test.rb index 5591e435414..c815b9fe251 100644 --- a/test/unit/gateways/plugnpay_test.rb +++ b/test/unit/gateways/plugnpay_test.rb @@ -80,7 +80,6 @@ def test_add_address_outsite_north_america assert_equal result[:card_address1], '164 Waverley Street' assert_equal result[:card_country], 'DE' - end def test_add_address @@ -108,6 +107,7 @@ def test_cvv_result end private + def successful_purchase_response "FinalStatus=success&IPaddress=72%2e138%2e32%2e216&MStatus=success&User_Agent=&acct_code3=newcard&address1=1234%20My%20Street&address2=Apt%201&app_level=5&auth_code=TSTAUT&auth_date=20080125&auth_msg=%20&authtype=authpostauth&avs_code=X&card_address1=1234%20My%20Street&card_amount=1%2e00&card_city=Ottawa&card_country=CA&card_name=Longbob%20Longsen&card_state=ON&card_type=VISA&card_zip=K1C2N6&city=Ottawa&convert=underscores&country=CA&currency=usd&cvvresp=M&dontsndmail=yes&easycart=0&merchant=pnpdemo2&merchfraudlev=&mode=auth&orderID=2008012522252119738&phone=555%2d555%2d5555&publisher_email=trash%40plugnpay%2ecom&publisher_name=pnpdemo2&publisher_password=pnpdemo222&resp_code=00&shipinfo=0&shipname=Jim%20Smith&sresp=A&state=ON&success=yes&zip=K1C2N6&a=b\n" end diff --git a/test/unit/gateways/psl_card_test.rb b/test/unit/gateways/psl_card_test.rb index c37f92531ed..8e31f389338 100644 --- a/test/unit/gateways/psl_card_test.rb +++ b/test/unit/gateways/psl_card_test.rb @@ -54,6 +54,7 @@ def test_cvv_result end private + def successful_purchase_response 'ResponseCode=00&Message=AUTHCODE:01256&CrossReference=08012522454901256086&First4=4543&Last4=9982&ExpMonth=12&ExpYear=2010&AVSCV2Check=ALL MATCH&Amount=1000&QAAddress=76 Roseby Avenue Manchester&QAPostcode=M63X 7TH&MerchantName=Merchant Name&QAName=John Smith' end diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb index abb11a2c16b..e30172fa1ed 100644 --- a/test/unit/gateways/realex_test.rb +++ b/test/unit/gateways/realex_test.rb @@ -242,7 +242,6 @@ def test_refund_xml SRC assert_xml_equal valid_refund_request_xml, @gateway.build_refund_request(@amount, '1;4321;1234', {}) - end def test_refund_with_rebate_secret_xml @@ -265,7 +264,6 @@ def test_refund_with_rebate_secret_xml SRC assert_xml_equal valid_refund_request_xml, gateway.build_refund_request(@amount, '1;4321;1234', {}) - end def test_auth_with_address @@ -283,7 +281,6 @@ def test_auth_with_address assert_instance_of Response, response assert_success response assert response.test? - end def test_zip_in_shipping_address diff --git a/test/unit/gateways/sage_pay_test.rb b/test/unit/gateways/sage_pay_test.rb index aae37768a48..da8ed24674b 100644 --- a/test/unit/gateways/sage_pay_test.rb +++ b/test/unit/gateways/sage_pay_test.rb @@ -470,7 +470,6 @@ def transcript ExpiryDate=0616 BankAuthCode=999777 TRANSCRIPT - end def scrubbed_transcript @@ -492,6 +491,5 @@ def scrubbed_transcript ExpiryDate=0616 BankAuthCode=999777 TRANSCRIPT - end end diff --git a/test/unit/gateways/sage_test.rb b/test/unit/gateways/sage_test.rb index 9d7b2707929..b6faa1761c6 100644 --- a/test/unit/gateways/sage_test.rb +++ b/test/unit/gateways/sage_test.rb @@ -324,6 +324,7 @@ def test_supports_scrubbing? end private + def successful_authorization_response "\002A911911APPROVED 00MX001234567890\0341000\0340\034\003" end diff --git a/test/unit/gateways/secure_pay_au_test.rb b/test/unit/gateways/secure_pay_au_test.rb index 163c41fe0fa..e99997f6d4e 100644 --- a/test/unit/gateways/secure_pay_au_test.rb +++ b/test/unit/gateways/secure_pay_au_test.rb @@ -27,7 +27,6 @@ def test_supported_card_types assert_equal [:visa, :master, :american_express, :diners_club, :jcb], SecurePayAuGateway.supported_cardtypes end - def test_successful_purchase_with_live_data @gateway.expects(:ssl_post).returns(successful_live_purchase_response) diff --git a/test/unit/gateways/secure_pay_tech_test.rb b/test/unit/gateways/secure_pay_tech_test.rb index 008f447cbc7..90847f8e9d6 100644 --- a/test/unit/gateways/secure_pay_tech_test.rb +++ b/test/unit/gateways/secure_pay_tech_test.rb @@ -34,6 +34,7 @@ def test_unsuccessful_purchase end private + def successful_purchase_response "1,4--120119220646821,000000014511,23284,014511,20080125\r\n" end diff --git a/test/unit/gateways/secure_pay_test.rb b/test/unit/gateways/secure_pay_test.rb index 2a897b6a2fd..0fdc3b08493 100644 --- a/test/unit/gateways/secure_pay_test.rb +++ b/test/unit/gateways/secure_pay_test.rb @@ -48,7 +48,6 @@ def test_successful_purchase assert response.authorization end - def test_avs_result @gateway.expects(:ssl_post).returns(successful_purchase_response) diff --git a/test/unit/gateways/skip_jack_test.rb b/test/unit/gateways/skip_jack_test.rb index 10cc562bbfa..d1faca21da2 100644 --- a/test/unit/gateways/skip_jack_test.rb +++ b/test/unit/gateways/skip_jack_test.rb @@ -193,7 +193,6 @@ def test_paymentech_authorization_failure assert_failure response end - def test_serial_number_is_added_before_developer_serial_number_for_authorization expected ="Year=#{Time.now.year + 1}&TransactionAmount=1.00&ShipToPhone=&SerialNumber=X&SJName=Longbob+Longsen&OrderString=1~None~0.00~0~N~%7C%7C&OrderNumber=1&OrderDescription=&Month=9&InvoiceNumber=&Email=cody%40example.com&DeveloperSerialNumber=Y&CustomerCode=&CVV2=123&AccountNumber=4242424242424242" expected = expected.gsub('~', '%7E') if RUBY_VERSION < '2.5.0' @@ -235,6 +234,7 @@ def test_dont_send_blank_state end private + def successful_authorization_response <<-CSV "AUTHCODE","szSerialNumber","szTransactionAmount","szAuthorizationDeclinedMessage","szAVSResponseCode","szAVSResponseMessage","szOrderNumber","szAuthorizationResponseCode","szIsApproved","szCVV2ResponseCode","szCVV2ResponseMessage","szReturnCode","szTransactionFileName","szCAVVResponseCode" diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index 84c43f52a05..e3b9d93af5f 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -1413,7 +1413,6 @@ def test_authorization_with_emv_payment_application_fee_included assert_success response end - def test_passing_stripe_account_header @gateway.expects(:ssl_request).with do |method, url, post, headers| headers.include?('Stripe-Account') diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb index d8eb617c41b..e80a0323cc5 100644 --- a/test/unit/gateways/usa_epay_transaction_test.rb +++ b/test/unit/gateways/usa_epay_transaction_test.rb @@ -493,7 +493,6 @@ def successful_void_response_echeck 'UMversion=2.9&UMstatus=Approved&UMauthCode=TM80A5&UMrefNum=133134971&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled' end - def pre_scrubbed <<-EOS opening connection to sandbox.usaepay.com:443... diff --git a/test/unit/gateways/verifi_test.rb b/test/unit/gateways/verifi_test.rb index 028c623a996..7debaabf3cd 100644 --- a/test/unit/gateways/verifi_test.rb +++ b/test/unit/gateways/verifi_test.rb @@ -69,7 +69,6 @@ def test_add_description result = {} @gateway.send(:add_invoice_data, result, :description => 'My Purchase is great') assert_equal 'My Purchase is great', result[:orderdescription] - end def test_purchase_meets_minimum_requirements @@ -83,7 +82,6 @@ def test_purchase_meets_minimum_requirements minimum_requirements.each do |key| assert_not_nil(data =~ /#{key}=/) end - end def test_avs_result diff --git a/test/unit/gateways/wirecard_test.rb b/test/unit/gateways/wirecard_test.rb index 03b82b41b98..f8f3e2d2b90 100644 --- a/test/unit/gateways/wirecard_test.rb +++ b/test/unit/gateways/wirecard_test.rb @@ -579,7 +579,6 @@ def failed_void_response XML end - # Purchase failure def wrong_creditcard_purchase_response <<-XML diff --git a/test/unit/gateways/worldpay_online_payments_test.rb b/test/unit/gateways/worldpay_online_payments_test.rb index e97d3b457e0..697ac11aba0 100644 --- a/test/unit/gateways/worldpay_online_payments_test.rb +++ b/test/unit/gateways/worldpay_online_payments_test.rb @@ -198,9 +198,11 @@ def test_invalid_login def successful_token_response %({"token": "TEST_RU_8fcc4f2f-8c0d-483d-a0a3-eaad7356623e","paymentMethod": {"type": "ObfuscatedCard","name": "Longbob Longsen","expiryMonth": 10,"expiryYear": 2016,"cardType": "VISA","maskedCardNumber": "**** **** **** 1111"},"reusable": true}) end + def successful_authorize_response %({"orderCode": "a46502d0-80ba-425b-a6db-2c57e9de91da","token": "TEST_RU_8fcc4f2f-8c0d-483d-a0a3-eaad7356623e","orderDescription": "Test Purchase","amount": 0,"currencyCode": "GBP","authorizeOnly": true,"paymentStatus": "AUTHORIZED","paymentResponse": {"type": "ObfuscatedCard","name": "Longbob Longsen","expiryMonth": 10,"expiryYear": 2016,"cardType": "VISA_CREDIT","maskedCardNumber": "**** **** **** 1111"},"environment": "TEST","authorizedAmount": 1000}) end + def failed_authorize_response %({"httpStatusCode":400,"customCode":"BAD_REQUEST","message":"CVC can't be null/empty","description":"Some of request parameters are invalid, please check your request. For more information please refer to Json schema.","errorHelpUrl":null,"originalRequest":"{'reusable':false,'paymentMethod':{'type':'Card','name':'Example Name','expiryMonth':'**','expiryYear':'****','cardNumber':'**** **** **** 1111','cvc':''},'clientKey':'T_C_845d39f4-f33c-430c-8fca-ad89bf1e5810'}"} ) end diff --git a/test/unit/network_connection_retries_test.rb b/test/unit/network_connection_retries_test.rb index b071c4e9ede..49ce4b3d8e6 100644 --- a/test/unit/network_connection_retries_test.rb +++ b/test/unit/network_connection_retries_test.rb @@ -67,7 +67,6 @@ def test_ssl_errors_raise_correctly end end - def test_invalid_response_error assert_raises(ActiveMerchant::InvalidResponseError) do retry_exceptions do From 28eb2a8113653b8b0e0f283f95ede6e3f18c99f4 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 24 Sep 2018 10:21:50 -0400 Subject: [PATCH 559/677] Revert "Stripe: support shipping info in purchases" This reverts commit d4d927e42a6ac7c0ce15be7e9a14f6c2f00a0ff5. As-written, this could cause transaction to fail in some situations: Stripe will validate *all* shipping parameters if *any* are present, so attempting a purchase with some but not all shipping params could cause the entire purchase to be rejected. The proper fix is to not include any shipping details unless all are present, but for now, simply remove the functionality entirely. --- CHANGELOG | 1 - .../billing/gateways/stripe.rb | 23 ------------------- test/remote/gateways/remote_stripe_test.rb | 18 --------------- test/unit/gateways/stripe_test.rb | 20 +--------------- 4 files changed, 1 insertion(+), 61 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 66a94d43280..7394938edba 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,7 +15,6 @@ * Stripe: support a reason for voiding a transaction [whitby3001] #2378 * Payeezy: Add reversal_id in support of timeout reversals [dtykocki] #2997 * Stripe: support Level 3 transaction fields [bpollack] #2996 -* Stripe: support passing shipping info for purchases [whitby3001] #2379 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 0424cde6b42..49c7077a2a8 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -321,7 +321,6 @@ def create_post_for_auth_or_purchase(money, payment, options) end add_metadata(post, options) - add_shipping_info(post, options) add_application_fee(post, options) add_exchange_rate(post, options) add_destination(post, options) @@ -490,28 +489,6 @@ def add_emv_metadata(post, creditcard) post[:metadata] ||= {} post[:metadata][:card_read_method] = creditcard.read_method if creditcard.respond_to?(:read_method) end - - def add_shipping_info(post, options = {}) - post[:shipping] = {} - - if address = options[:shipping_address] - address_params = {} - address_params[:line1] = address[:address1] if address[:address1] - address_params[:line2] = address[:address2] if address[:address2] - address_params[:city] = address[:city] if address[:city] - address_params[:state] = address[:state] if address[:state] - address_params[:postal_code] = address[:zip] if address[:zip] - address_params[:country] = address[:country] if address[:country] - post[:shipping][:address] = address_params unless address_params.empty? - post[:shipping][:name] = address[:name] if address[:name] - post[:shipping][:phone] = address[:phone] if address[:phone] - end - - post[:shipping][:carrier] = options[:carrier] if options[:carrier] - post[:shipping][:tracking_number] = options[:tracking_number] if options[:tracking_number] - - post.delete(:shipping) if post[:shipping].empty? - end def fetch_application_fee(identification, options = {}) options.merge!(:key => @fee_refund_api_key) diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb index 3fecb1ba64d..cbc94e8ab52 100644 --- a/test/remote/gateways/remote_stripe_test.rb +++ b/test/remote/gateways/remote_stripe_test.rb @@ -122,24 +122,6 @@ def test_successful_purchase_with_level3_data assert_equal 'wow@example.com', response.params['metadata']['email'] end - def test_successful_purchase_with_shipping_info - custom_options = @options.merge(:shipping_address => address(), :carrier => 'UPS', :tracking_number => '12345') - assert response = @gateway.purchase(@amount, @credit_card, custom_options) - assert_success response - assert_equal 'charge', response.params['object'] - assert response.params['paid'] - assert_equal custom_options[:shipping_address][:name], response.params['shipping']['name'] - assert_equal custom_options[:shipping_address][:address1], response.params['shipping']['address']['line1'] - assert_equal custom_options[:shipping_address][:address2], response.params['shipping']['address']['line2'] - assert_equal custom_options[:shipping_address][:city], response.params['shipping']['address']['city'] - assert_equal custom_options[:shipping_address][:state], response.params['shipping']['address']['state'] - assert_equal custom_options[:shipping_address][:zip], response.params['shipping']['address']['postal_code'] - assert_equal custom_options[:shipping_address][:country], response.params['shipping']['address']['country'] - assert_equal custom_options[:shipping_address][:phone], response.params['shipping']['phone'] - assert_equal custom_options[:carrier], response.params['shipping']['carrier'] - assert_equal custom_options[:tracking_number], response.params['shipping']['tracking_number'] - end - def test_unsuccessful_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index e3b9d93af5f..0dd7f51097c 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -13,10 +13,7 @@ def setup @options = { :billing_address => address(), :statement_address => statement_address(), - :description => 'Test Purchase', - :shipping_address => address(), - :carrier => 'UPS', - :tracking_number => '12345' + :description => 'Test Purchase' } @apple_pay_payment_token = apple_pay_payment_token @@ -1063,21 +1060,6 @@ def test_add_statement_address_returns_nil_if_required_fields_missing end end - def test_add_shipping_info - post = {:card => {}} - @gateway.send(:add_shipping_info, post, @options) - assert_equal @options[:shipping_address][:zip], post[:shipping][:address][:postal_code] - assert_equal @options[:shipping_address][:state], post[:shipping][:address][:state] - assert_equal @options[:shipping_address][:address1], post[:shipping][:address][:line1] - assert_equal @options[:shipping_address][:address2], post[:shipping][:address][:line2] - assert_equal @options[:shipping_address][:country], post[:shipping][:address][:country] - assert_equal @options[:shipping_address][:city], post[:shipping][:address][:city] - assert_equal @options[:shipping_address][:name], post[:shipping][:name] - assert_equal @options[:shipping_address][:phone], post[:shipping][:phone] - assert_equal @options[:carrier], post[:shipping][:carrier] - assert_equal @options[:tracking_number], post[:shipping][:tracking_number] - end - def test_ensure_does_not_respond_to_credit assert !@gateway.respond_to?(:credit) end From 668432c33efc8c7828b356b837aa993888e6170f Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 24 Sep 2018 09:48:34 -0400 Subject: [PATCH 560/677] Enable Carnet for Conekta and Openpay Unit: 3927 tests, 68207 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- CHANGELOG | 2 ++ lib/active_merchant/billing/gateways/conekta.rb | 2 +- lib/active_merchant/billing/gateways/openpay.rb | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7394938edba..72ee8ab8fd0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,8 @@ * Stripe: support a reason for voiding a transaction [whitby3001] #2378 * Payeezy: Add reversal_id in support of timeout reversals [dtykocki] #2997 * Stripe: support Level 3 transaction fields [bpollack] #2996 +* Conekta: support Carnet cards [bpollack] #2999 +* Openpay: support Carnet cards [bpollack] #2999 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 diff --git a/lib/active_merchant/billing/gateways/conekta.rb b/lib/active_merchant/billing/gateways/conekta.rb index dfa9d484a20..06aad777b09 100644 --- a/lib/active_merchant/billing/gateways/conekta.rb +++ b/lib/active_merchant/billing/gateways/conekta.rb @@ -4,7 +4,7 @@ class ConektaGateway < Gateway self.live_url = 'https://api.conekta.io/' self.supported_countries = ['MX'] - self.supported_cardtypes = [:visa, :master, :american_express] + self.supported_cardtypes = [:visa, :master, :american_express, :carnet] self.homepage_url = 'https://conekta.io/' self.display_name = 'Conekta Gateway' self.money_format = :cents diff --git a/lib/active_merchant/billing/gateways/openpay.rb b/lib/active_merchant/billing/gateways/openpay.rb index 1d44beb6036..778729f4cbd 100644 --- a/lib/active_merchant/billing/gateways/openpay.rb +++ b/lib/active_merchant/billing/gateways/openpay.rb @@ -5,7 +5,7 @@ class OpenpayGateway < Gateway self.test_url = 'https://sandbox-api.openpay.mx/v1/' self.supported_countries = ['MX'] - self.supported_cardtypes = [:visa, :master, :american_express] + self.supported_cardtypes = [:visa, :master, :american_express, :carnet] self.homepage_url = 'http://www.openpay.mx/' self.display_name = 'Openpay' self.default_currency = 'MXN' From a168b2440fee70dc8549875c4d36b7dbe7d1fce7 Mon Sep 17 00:00:00 2001 From: Anna Gyergyai <anna.gyergyai@shopify.com> Date: Thu, 27 Sep 2018 11:42:52 -0400 Subject: [PATCH 561/677] Release v1.84.0 --- CHANGELOG | 4 +++- lib/active_merchant/version.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 72ee8ab8fd0..1b989f251b4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ = ActiveMerchant CHANGELOG == HEAD + +== Version 1.84.0 (September 27, 2018) * PayU Latam: support partial captures [bpollack] #2974 * Braintree: Reflect correct test mode in Braintree responses [elfassy] [#2980] * FirstPay: Expose error code [curiousepic] #2979 @@ -17,6 +19,7 @@ * Stripe: support Level 3 transaction fields [bpollack] #2996 * Conekta: support Carnet cards [bpollack] #2999 * Openpay: support Carnet cards [bpollack] #2999 +* Adyen: Add support for GooglePay [dtykocki] #2971 == Version 1.83.0 (August 30, 2018) * CT Payment: Update How Address is Passed [nfarve] #2960 @@ -31,7 +34,6 @@ * Adyen: allow overriding card brands [bpollack] #2968 * Adyen: allow custom routing [bpollack] #2969 * First Pay: Adds scrubbing [deedeelavinder] #2972 -* Adyen: Add support for GooglePay [dtykocki] #2971 == Version 1.82.0 (August 13, 2018) * FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index e0f40471379..df77bd3ec8f 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = '1.83.0' + VERSION = '1.84.0' end From f360cf6cf6fc71f94334942dabcd2f784a019224 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Thu, 27 Sep 2018 14:56:22 -0400 Subject: [PATCH 562/677] Authorize.Net: Support custom delimiter for cim By default, cim transaction responses have a field delimiter of ',' but fields themselves can easily contain unescaped commas, causing bad parsing. Providing a custom delimiter option can prevent this. Remote: 68 tests, 234 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 93 tests, 536 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/authorize_net.rb | 40 +++++++++++-------- .../gateways/remote_authorize_net_test.rb | 10 +++++ test/unit/gateways/authorize_net_test.rb | 35 ++++++++++++++++ 4 files changed, 70 insertions(+), 16 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1b989f251b4..e2a2d1cfd1b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001] == Version 1.84.0 (September 27, 2018) * PayU Latam: support partial captures [bpollack] #2974 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index db7367210b4..0c4c4c0c8a0 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -101,7 +101,7 @@ def initialize(options={}) def purchase(amount, payment, options = {}) if payment.is_a?(String) - commit(:cim_purchase) do |xml| + commit(:cim_purchase, options) do |xml| add_cim_auth_purchase(xml, 'profileTransAuthCapture', amount, payment, options) end else @@ -113,7 +113,7 @@ def purchase(amount, payment, options = {}) def authorize(amount, payment, options={}) if payment.is_a?(String) - commit(:cim_authorize) do |xml| + commit(:cim_authorize, options) do |xml| add_cim_auth_purchase(xml, 'profileTransAuthOnly', amount, payment, options) end else @@ -273,10 +273,11 @@ def add_cim_auth_purchase(xml, transaction_type, amount, payment, options) add_tax_exempt_status(xml, options) end end + add_extra_options_for_cim(xml, options) end def cim_capture(amount, authorization, options) - commit(:cim_capture) do |xml| + commit(:cim_capture, options) do |xml| add_order_id(xml, options) xml.transaction do xml.profileTransPriorAuthCapture do @@ -287,6 +288,7 @@ def cim_capture(amount, authorization, options) xml.transId(transaction_id_from(authorization)) end end + add_extra_options_for_cim(xml, options) end end @@ -311,7 +313,7 @@ def normal_capture(amount, authorization, options) def cim_refund(amount, authorization, options) transaction_id, card_number, _ = split_authorization(authorization) - commit(:cim_refund) do |xml| + commit(:cim_refund, options) do |xml| add_order_id(xml, options) xml.transaction do xml.profileTransRefund do @@ -324,6 +326,7 @@ def cim_refund(amount, authorization, options) xml.transId(transaction_id) end end + add_extra_options_for_cim(xml, options) end end @@ -355,13 +358,14 @@ def normal_refund(amount, authorization, options) end def cim_void(authorization, options) - commit(:cim_void) do |xml| + commit(:cim_void, options) do |xml| add_order_id(xml, options) xml.transaction do xml.profileTransVoid do xml.transId(transaction_id_from(authorization)) end end + add_extra_options_for_cim(xml, options) end end @@ -672,8 +676,12 @@ def add_po_number(xml, options) xml.poNumber(options[:po_number]) if options[:po_number] end + def add_extra_options_for_cim(xml, options) + xml.extraOptions("x_delim_char=#{options[:delimiter]}") if options[:delimiter] + end + def create_customer_payment_profile(credit_card, options) - commit(:cim_store_update) do |xml| + commit(:cim_store_update, options) do |xml| xml.customerProfileId options[:customer_profile_id] xml.paymentProfile do add_billing_address(xml, credit_card, options) @@ -689,7 +697,7 @@ def create_customer_payment_profile(credit_card, options) end def create_customer_profile(credit_card, options) - commit(:cim_store) do |xml| + commit(:cim_store, options) do |xml| xml.profile do xml.merchantCustomerId(truncate(options[:merchant_customer_id], 20) || SecureRandom.hex(10)) xml.description(truncate(options[:description], 255)) unless empty?(options[:description]) @@ -712,7 +720,7 @@ def create_customer_profile(credit_card, options) end def delete_customer_profile(customer_profile_id) - commit(:cim_store_delete_customer) do |xml| + commit(:cim_store_delete_customer, options) do |xml| xml.customerProfileId(customer_profile_id) end end @@ -742,17 +750,17 @@ def url test? ? test_url : live_url end - def parse(action, raw_response) + def parse(action, raw_response, options = {}) if is_cim_action?(action) || action == :verify_credentials - parse_cim(raw_response) + parse_cim(raw_response, options) else parse_normal(action, raw_response) end end - def commit(action, &payload) + def commit(action, options = {}, &payload) raw_response = ssl_post(url, post_data(action, &payload), headers) - response = parse(action, raw_response) + response = parse(action, raw_response, options) avs_result_code = response[:avs_result_code].upcase if response[:avs_result_code] avs_result = AVSResult.new(code: STANDARD_AVS_CODE_MAPPING[avs_result_code]) @@ -869,7 +877,7 @@ def parse_normal(action, body) response end - def parse_cim(body) + def parse_cim(body, options) response = {} doc = Nokogiri::XML(body).remove_namespaces! @@ -904,7 +912,7 @@ def parse_cim(body) (empty?(element.content) ? nil : element.content) end - response.merge!(parse_direct_response_elements(response)) + response.merge!(parse_direct_response_elements(response, options)) response end @@ -967,11 +975,11 @@ def auth_was_for_cim?(authorization) action && is_cim_action?(action) end - def parse_direct_response_elements(response) + def parse_direct_response_elements(response, options) params = response[:direct_response] return {} unless params - parts = params.split(',') + parts = params.split(options[:delimiter] || ',') { response_code: parts[0].to_i, response_subcode: parts[1], diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb index 57b24453e07..034e0f92cc8 100644 --- a/test/remote/gateways/remote_authorize_net_test.rb +++ b/test/remote/gateways/remote_authorize_net_test.rb @@ -322,6 +322,16 @@ def test_successful_purchase_using_stored_card assert_equal 'This transaction has been approved.', response.message end + def test_successful_purchase_using_stored_card_with_delimiter + response = @gateway.store(@credit_card, @options.merge(delimiter: '|')) + assert_success response + + response = @gateway.purchase(@amount, response.authorization, @options.merge(delimiter: '|', description: 'description, with, commas')) + assert_success response + assert_equal 'This transaction has been approved.', response.message + assert_equal 'description, with, commas', response.params['order_description'] + end + def test_failed_purchase_using_stored_card response = @gateway.store(@declined_card) assert_success response diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 1ceaefd3d56..358124ae04f 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -394,6 +394,24 @@ def test_successful_purchase_using_stored_card assert_equal 'Street address and 5-digit postal code match.', response.avs_result['message'] end + def test_successful_purchase_using_stored_card_and_custom_delimiter + @gateway.expects(:ssl_post).returns(successful_store_response) + store = @gateway.store(@credit_card, @options) + assert_success store + + @gateway.expects(:ssl_post).returns(successful_purchase_using_stored_card_response_with_pipe_delimiter) + + response = @gateway.purchase(@amount, store.authorization, {delimiter: '|', description: 'description, with, commas'}) + assert_success response + + assert_equal '2235700270#XXXX2224#cim_purchase', response.authorization + assert_equal 'Y', response.avs_result['code'] + assert response.avs_result['street_match'] + assert response.avs_result['postal_match'] + assert_equal 'Street address and 5-digit postal code match.', response.avs_result['message'] + assert_equal 'description, with, commas', response.params['order_description'] + end + def test_failed_purchase_using_stored_card @gateway.expects(:ssl_post).returns(successful_store_response) store = @gateway.store(@credit_card, @options) @@ -2109,6 +2127,23 @@ def successful_purchase_using_stored_card_response eos end + def successful_purchase_using_stored_card_response_with_pipe_delimiter + <<-eos + <?xml version="1.0" encoding="UTF-8"?> + <createCustomerProfileTransactionResponse xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <refId>1</refId> + <messages> + <resultCode>Ok</resultCode> + <message> + <code>I00001</code> + <text>Successful.</text> + </message> + </messages> + <directResponse>1|1|1|This transaction has been approved.|8HUT72|Y|2235700270|1|description, with, commas|1.01|CC|auth_capture|e385c780422f4bd182c4|Longbob|Longsen||||n/a|||||||||||||||||||4A20EEAF89018FF075899DDB332E9D35||2|||||||||||XXXX2224|Visa||||||||||||||||</directResponse> + </createCustomerProfileTransactionResponse> + eos + end + def failed_purchase_using_stored_card_response <<-eos <?xml version="1.0" encoding="UTF-8"?> From a6a2e5e7e1a0a7abcfc8e06edb58f1baa5c3a6f1 Mon Sep 17 00:00:00 2001 From: Filipe Costa <filipebarcos@gmail.com> Date: Fri, 28 Sep 2018 10:21:34 -0400 Subject: [PATCH 563/677] Release v1.85.0 --- CHANGELOG | 1 + lib/active_merchant/version.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index e2a2d1cfd1b..f0ec80bccb2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +== Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001] == Version 1.84.0 (September 27, 2018) diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index df77bd3ec8f..6f6f680ff1c 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = '1.84.0' + VERSION = '1.85.0' end From 7f134e4e7d747a9d057b40c76ff8f9ae9d78ae92 Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Fri, 28 Sep 2018 09:27:24 -0400 Subject: [PATCH 564/677] UsaEpayTransaction: Support UMcheckformat option for echecks Remote: 26 tests, 101 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 46 tests, 270 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 2 ++ .../billing/gateways/usa_epay_transaction.rb | 5 +++-- .../gateways/remote_usa_epay_transaction_test.rb | 7 +++++++ test/unit/gateways/usa_epay_transaction_test.rb | 13 +++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f0ec80bccb2..f62c0e12f1f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ = ActiveMerchant CHANGELOG == HEAD +* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] [#3002] + == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001] diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb index 83ac01b3cc9..bb9b41d7fcb 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb @@ -64,7 +64,7 @@ def purchase(money, payment, options = {}) add_amount(post, money) add_invoice(post, options) - add_payment(post, payment) + add_payment(post, payment, options) unless payment.respond_to?(:track_data) && payment.track_data.present? add_address(post, payment, options) add_customer_data(post, options) @@ -195,8 +195,9 @@ def add_invoice(post, options) post[:description] = options[:description] end - def add_payment(post, payment) + def add_payment(post, payment, options={}) if payment.respond_to?(:routing_number) + post[:checkformat] = options[:check_format] if options[:check_format] post[:account] = payment.account_number post[:routing] = payment.routing_number post[:name] = payment.name unless payment.name.blank? diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb index ac553b144de..b4760f3f387 100644 --- a/test/remote/gateways/remote_usa_epay_transaction_test.rb +++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb @@ -29,6 +29,13 @@ def test_successful_purchase_with_echeck assert_success response end + def test_successful_purchase_with_echeck_and_extra_options + extra_options = @options.merge(check_format: 'ARC') + assert response = @gateway.purchase(@amount, @check, extra_options) + assert_equal 'Success', response.message + assert_success response + end + def test_successful_authorization_with_manual_entry @credit_card.manual_entry = true assert response = @gateway.authorize(@amount, @credit_card, @options) diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb index e80a0323cc5..753e74ba13b 100644 --- a/test/unit/gateways/usa_epay_transaction_test.rb +++ b/test/unit/gateways/usa_epay_transaction_test.rb @@ -53,6 +53,19 @@ def test_successful_request_with_echeck assert response.test? end + def test_successful_purchase_with_echeck_and_extra_options + response = stub_comms do + @gateway.purchase(@amount, @check, @options.merge(check_format: 'ARC')) + end.check_request do |endpoint, data, headers| + assert_match(/UMcheckformat=ARC/, data) + end.respond_with(successful_purchase_response_echeck) + + assert_equal 'Success', response.message + assert_equal '133134803', response.authorization + assert_success response + assert response.test? + end + def test_unsuccessful_request @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response) From 39602f2276ff490c1a8e82869f9c4625046e2845 Mon Sep 17 00:00:00 2001 From: molbrown <molly@spreedly.com> Date: Thu, 27 Sep 2018 14:56:38 -0400 Subject: [PATCH 565/677] Global Collect: handle internal server errors Ingenico returns HTML when it has a 500 error, which this gateway has not handled and would crash on a JSON parse error. New rescue provides a more informative error and prevents crashing in this situation. Remote: 16 tests, 38 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 19 tests, 85 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #3005 --- .rubocop_todo.yml | 6 ++ CHANGELOG | 1 + .../billing/gateways/global_collect.rb | 27 +++++++-- test/unit/gateways/global_collect_test.rb | 57 +++++++++++++++++++ 4 files changed, 85 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 99cea84dfd4..989a1398236 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1394,6 +1394,10 @@ Style/SpecialGlobalVars: Style/StringLiteralsInInterpolation: Enabled: false +Style/StringLiterals: + Exclude: + - 'test/unit/gateways/global_collect_test.rb' + # Offense count: 307 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinSize. @@ -1460,3 +1464,5 @@ Style/ZeroLengthPredicate: # URISchemes: http, https Metrics/LineLength: Max: 2484 + Exclude: + - 'test/unit/gateways/global_collect_test.rb' diff --git a/CHANGELOG b/CHANGELOG index f62c0e12f1f..e3f05b6311b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] [#3002] +* Global Collect: handle internal server errors [molbrown] [#3005] == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001] diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 6a82e2807e5..a6f0135921e 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -72,8 +72,8 @@ def supports_scrubbing? def scrub(transcript) transcript. gsub(%r((Authorization: )[^\\]*)i, '\1[FILTERED]'). - gsub(%r(("cardNumber\\":\\")\d+), '\1[FILTERED]'). - gsub(%r(("cvv\\":\\")\d+), '\1[FILTERED]') + gsub(%r(("cardNumber\\+":\\+")\d+), '\1[FILTERED]'). + gsub(%r(("cvv\\+":\\+")\d+), '\1[FILTERED]') end private @@ -230,11 +230,14 @@ def uri(action, authorization) def commit(action, post, authorization = nil) begin - response = parse(ssl_post(url(action, authorization), post.to_json, headers(action, post, authorization))) + raw_response = ssl_post(url(action, authorization), post.to_json, headers(action, post, authorization)) + response = parse(raw_response) rescue ResponseError => e if e.response.code.to_i >= 400 response = parse(e.response.body) end + rescue JSON::ParserError + response = json_error(raw_response) end succeeded = success_from(response) @@ -248,6 +251,14 @@ def commit(action, post, authorization = nil) ) end + def json_error(raw_response) + { + 'error_message' => 'Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message.' \ + " (The raw response returned by the API was #{raw_response.inspect})", + 'status' => 'REJECTED' + } + end + def headers(action, post, authorization = nil) { 'Content-Type' => content_type, @@ -286,8 +297,10 @@ def message_from(succeeded, response) else if errors = response['errors'] errors.first.try(:[], 'message') - elsif status = response['status'] - 'Status: ' + status + elsif response['error_message'] + response['error_message'] + elsif response['status'] + 'Status: ' + response['status'] else 'No message available' end @@ -297,8 +310,10 @@ def message_from(succeeded, response) def authorization_from(succeeded, response) if succeeded response['id'] || response['payment']['id'] || response['paymentResult']['payment']['id'] - else + elsif response['errorId'] response['errorId'] + else + 'GATEWAY ERROR' end end diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb index 5a5c7df22c4..8ad5d5a1c02 100644 --- a/test/unit/gateways/global_collect_test.rb +++ b/test/unit/gateways/global_collect_test.rb @@ -212,11 +212,28 @@ def test_rejected_refund assert_equal 'Status: REJECTED', response.message end + def test_invalid_raw_response + response = stub_comms do + @gateway.purchase(@accepted_amount, @credit_card, @options) + end.respond_with(invalid_json_response) + + assert_failure response + assert_match %r{^Invalid response received from the Ingenico ePayments}, response.message + end + def test_scrub assert @gateway.supports_scrubbing? assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed end + def test_scrub_invalid_response + response = stub_comms do + @gateway.purchase(@accepted_amount, @credit_card, @options) + end.respond_with(invalid_json_plus_card_data).message + + assert_equal @gateway.scrub(response), scrubbed_invalid_json_plus + end + private def pre_scrubbed @@ -374,4 +391,44 @@ def successful_verify_response def failed_verify_response %({\n \"errorId\" : \"cee09c50-5d9d-41b8-b740-8c7bf06d2c66\",\n \"errors\" : [ {\n \"code\" : \"430330\",\n \"message\" : \"Not authorised\"\n } ],\n \"paymentResult\" : {\n \"creationOutput\" : {\n \"additionalReference\" : \"00000014280000000134\",\n \"externalReference\" : \"000000142800000000920000100001\"\n },\n \"payment\" : {\n \"id\" : \"000000142800000000920000100001\",\n \"paymentOutput\" : {\n \"amountOfMoney\" : {\n \"amount\" : 100,\n \"currencyCode\" : \"USD\"\n },\n \"references\" : {\n \"paymentReference\" : \"0\"\n },\n \"paymentMethod\" : \"card\",\n \"cardPaymentMethodSpecificOutput\" : {\n \"paymentProductId\" : 1\n }\n },\n \"status\" : \"REJECTED\",\n \"statusOutput\" : {\n \"errors\" : [ {\n \"code\" : \"430330\",\n \"requestId\" : \"64357\",\n \"message\" : \"Not authorised\"\n } ],\n \"isCancellable\" : false,\n \"statusCode\" : 100,\n \"statusCodeChangeDateTime\" : \"20160318170253\",\n \"isAuthorized\" : false\n }\n }\n }\n}) end + + def invalid_json_response + '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> + <html><head> + <title>502 Proxy Error</title> + </head><body> + <h1>Proxy Error</h1> + <p>The proxy server received an invalid + response from an upstream server.<br /> + The proxy server could not handle the request <em><a href="/v1/9040/payments">POST&nbsp;/v1/9040/payments</a></em>.<p> + Reason: <strong>Error reading from remote server</strong></p></p> + </body></html>' + end + + def invalid_json_plus_card_data + %q(<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> + <html><head> + <title>502 Proxy Error</title> + </head></html> + opening connection to api-sandbox.globalcollect.com:443... + opened + starting SSL for api-sandbox.globalcollect.com:443... + SSL established + <- "POST //v1/1428/payments HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: GCS v1HMAC:96f16a41890565d0:Bqv5QtSXi+SdqXUyoBBeXUDlRvi5DzSm49zWuJTLX9s=\r\nDate: Tue, 15 Mar 2016 14:32:13 GMT\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api-sandbox.globalcollect.com\r\nContent-Length: 560\r\n\r\n" + <- "{\"order\":{\"amountOfMoney\":{\"amount\":\"100\",\"currencyCode\":\"USD\"},\"customer\":{\"merchantCustomerId\":null,\"personalInformation\":{\"name\":{\"firstName\":null,\"surname\":null}},\"billingAddress\":{\"street\":\"456 My Street\",\"additionalInfo\":\"Apt 1\",\"zip\":\"K1C2N6\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryCode\":\"CA\"}},\"contactDetails\":{\"emailAddress\":null}},\"cardPaymentMethodSpecificInput\":{\"paymentProductId\":\"1\",\"skipAuthentication\":\"true\",\"skipFraudService\":\"true\",\"card\":{\"cvv\":\"123\",\"cardNumber\":\"4567350000427977\",\"expiryDate\":\"0917\",\"cardholderName\":\"Longbob Longsen\"}}}" + -> "HTTP/1.1 201 Created\r\n" + -> "Date: Tue, 15 Mar 2016 18:32:14 GMT\r\n" + -> "Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1p\r\n" + -> "Location: https://api-sandbox.globalcollect.com:443/v1/1428/payments/000000142800000000300000100001\r\n" + -> "X-Powered-By: Servlet/3.0 JSP/2.2\r\n" + -> "Connection: close\r\n" + -> "Transfer-Encoding: chunked\r\n" + -> "Content-Type: application/json\r\n" + -> "\r\n" + -> "457\r\n") + end + + def scrubbed_invalid_json_plus + "Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message. (The raw response returned by the API was \"<!DOCTYPE HTML PUBLIC \\\"-//IETF//DTD HTML 2.0//EN\\\"> \\n <html><head> \\n <title>502 Proxy Error</title> \\n </head></html>\\n opening connection to api-sandbox.globalcollect.com:443...\\n opened\\n starting SSL for api-sandbox.globalcollect.com:443...\\n SSL established\\n <- \\\"POST //v1/1428/payments HTTP/1.1\\\\r\\\\nContent-Type: application/json\\\\r\\\\nAuthorization: [FILTERED]\\\\r\\\\nDate: Tue, 15 Mar 2016 14:32:13 GMT\\\\r\\\\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\\\\r\\\\nAccept: */*\\\\r\\\\nUser-Agent: Ruby\\\\r\\\\nConnection: close\\\\r\\\\nHost: api-sandbox.globalcollect.com\\\\r\\\\nContent-Length: 560\\\\r\\\\n\\\\r\\\\n\\\"\\n <- \\\"{\\\\\\\"order\\\\\\\":{\\\\\\\"amountOfMoney\\\\\\\":{\\\\\\\"amount\\\\\\\":\\\\\\\"100\\\\\\\",\\\\\\\"currencyCode\\\\\\\":\\\\\\\"USD\\\\\\\"},\\\\\\\"customer\\\\\\\":{\\\\\\\"merchantCustomerId\\\\\\\":null,\\\\\\\"personalInformation\\\\\\\":{\\\\\\\"name\\\\\\\":{\\\\\\\"firstName\\\\\\\":null,\\\\\\\"surname\\\\\\\":null}},\\\\\\\"billingAddress\\\\\\\":{\\\\\\\"street\\\\\\\":\\\\\\\"456 My Street\\\\\\\",\\\\\\\"additionalInfo\\\\\\\":\\\\\\\"Apt 1\\\\\\\",\\\\\\\"zip\\\\\\\":\\\\\\\"K1C2N6\\\\\\\",\\\\\\\"city\\\\\\\":\\\\\\\"Ottawa\\\\\\\",\\\\\\\"state\\\\\\\":\\\\\\\"ON\\\\\\\",\\\\\\\"countryCode\\\\\\\":\\\\\\\"CA\\\\\\\"}},\\\\\\\"contactDetails\\\\\\\":{\\\\\\\"emailAddress\\\\\\\":null}},\\\\\\\"cardPaymentMethodSpecificInput\\\\\\\":{\\\\\\\"paymentProductId\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"skipAuthentication\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"skipFraudService\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"card\\\\\\\":{\\\\\\\"cvv\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"cardNumber\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"expiryDate\\\\\\\":\\\\\\\"0917\\\\\\\",\\\\\\\"cardholderName\\\\\\\":\\\\\\\"Longbob Longsen\\\\\\\"}}}\\\"\\n -> \\\"HTTP/1.1 201 Created\\\\r\\\\n\\\"\\n -> \\\"Date: Tue, 15 Mar 2016 18:32:14 GMT\\\\r\\\\n\\\"\\n -> \\\"Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1p\\\\r\\\\n\\\"\\n -> \\\"Location: https://api-sandbox.globalcollect.com:443/v1/1428/payments/000000142800000000300000100001\\\\r\\\\n\\\"\\n -> \\\"X-Powered-By: Servlet/3.0 JSP/2.2\\\\r\\\\n\\\"\\n -> \\\"Connection: close\\\\r\\\\n\\\"\\n -> \\\"Transfer-Encoding: chunked\\\\r\\\\n\\\"\\n -> \\\"Content-Type: application/json\\\\r\\\\n\\\"\\n -> \\\"\\\\r\\\\n\\\"\\n -> \\\"457\\\\r\\\\n\\\"\")" + end end From 74fe0b2cdbce0a6a87f90ad3db5f1c1919806849 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 25 Jul 2018 15:09:39 -0400 Subject: [PATCH 566/677] Barclaycard Smartpay: add third-party payout support This is fully opt-in and requires additional account parameters to operate correctly. Unit: 26 tests, 127 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 31 tests, 64 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/barclaycard_smartpay.rb | 67 +++++++++++++------ .../remote_barclaycard_smartpay_test.rb | 9 ++- .../gateways/barclaycard_smartpay_test.rb | 29 ++++++++ 4 files changed, 82 insertions(+), 24 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e3f05b6311b..cfe49500d9b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] [#3002] * Global Collect: handle internal server errors [molbrown] [#3005] +* Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001] diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index 6df4b68ecfa..1ea7ee14dce 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -68,7 +68,27 @@ def credit(money, creditcard, options = {}) post[:nationality] = options[:nationality] if options[:nationality] post[:shopperName] = options[:shopper_name] if options[:shopper_name] - commit('refundWithData', post) + if options[:third_party_payout] + post[:recurring] = options[:recurring_contract] || {contract: 'PAYOUT'} + MultiResponse.run do |r| + r.process { + commit( + 'storeDetailAndSubmitThirdParty', + post, + @options[:store_payout_account], + @options[:store_payout_password]) + } + r.process { + commit( + 'confirmThirdParty', + modification_request(r.authorization, @options), + @options[:review_payout_account], + @options[:review_payout_password]) + } + end + else + commit('refundWithData', post) + end end def void(identification, options = {}) @@ -128,9 +148,10 @@ def scrub(transcript) '18' => 'I' # Neither postal code nor address were checked } - def commit(action, post) + def commit(action, post, account = 'ws', password = @options[:password]) request = post_data(flatten_hash(post)) - raw_response = ssl_post(build_url(action), request, headers) + request_headers = headers(account, password) + raw_response = ssl_post(build_url(action), request, request_headers) response = parse(raw_response) Response.new( @@ -181,10 +202,10 @@ def flatten_hash(hash, prefix = nil) flat_hash end - def headers + def headers(account, password) { 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8', - 'Authorization' => 'Basic ' + Base64.strict_encode64("ws@Company.#{@options[:company]}:#{@options[:password]}").strip + 'Authorization' => 'Basic ' + Base64.strict_encode64("#{account}@Company.#{@options[:company]}:#{password}").strip } end @@ -214,10 +235,10 @@ def message_from(response) def success_from(response) return true if response['result'] == 'Success' - return true if response['resultCode'] == 'Authorised' - return true if response['resultCode'] == 'Received' - successful_responses = %w([capture-received] [cancel-received] [refund-received]) - successful_responses.include?(response['response']) + + successful_results = %w(Authorised Received [payout-submit-received]) + successful_responses = %w([capture-received] [cancel-received] [refund-received] [payout-confirm-received]) + successful_results.include?(response['resultCode']) || successful_responses.include?(response['response']) end def build_url(action) @@ -226,6 +247,8 @@ def build_url(action) "#{test? ? self.test_url : self.live_url}/Recurring/#{API_VERSION}/storeToken" when 'finalize3ds' "#{test? ? self.test_url : self.live_url}/Payment/#{API_VERSION}/authorise3d" + when 'storeDetailAndSubmitThirdParty', 'confirmThirdParty' + "#{test? ? self.test_url : self.live_url}/Payout/#{API_VERSION}/#{action}" else "#{test? ? self.test_url : self.live_url}/Payment/#{API_VERSION}/#{action}" end @@ -263,11 +286,11 @@ def create_address_hash(address, house, street) hash = {} hash[:houseNumberOrName] = house hash[:street] = street - hash[:city] = address[:city] if address[:city] - hash[:stateOrProvince] = address[:state] if address[:state] - hash[:postalCode] = address[:zip] if address[:zip] - hash[:country] = address[:country] if address[:country] - hash + hash[:city] = address[:city] + hash[:stateOrProvince] = address[:state] + hash[:postalCode] = address[:zip] + hash[:country] = address[:country] + hash.keep_if { |_, v| v } end def amount_hash(money, currency) @@ -301,20 +324,20 @@ def psp_reference_from(authorization) def payment_request(money, options) hash = {} - hash[:merchantAccount] = @options[:merchant] - hash[:reference] = options[:order_id] if options[:order_id] - hash[:shopperEmail] = options[:email] if options[:email] - hash[:shopperIP] = options[:ip] if options[:ip] - hash[:shopperReference] = options[:customer] if options[:customer] - hash[:shopperInteraction] = options[:shopper_interaction] if options[:shopper_interaction] - hash[:deviceFingerprint] = options[:device_fingerprint] if options[:device_fingerprint] + hash[:merchantAccount] = @options[:merchant] + hash[:reference] = options[:order_id] + hash[:shopperEmail] = options[:email] + hash[:shopperIP] = options[:ip] + hash[:shopperReference] = options[:customer] + hash[:shopperInteraction] = options[:shopper_interaction] + hash[:deviceFingerprint] = options[:device_fingerprint] hash.keep_if { |_, v| v } end def store_request(options) hash = {} hash[:merchantAccount] = @options[:merchant] - hash[:shopperEmail] = options[:email] if options[:email] + hash[:shopperEmail] = options[:email] hash[:shopperReference] = options[:customer] if options[:customer] hash.keep_if { |_, v| v } end diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index eaa3f7288ae..105166a2250 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -6,8 +6,8 @@ def setup BarclaycardSmartpayGateway.ssl_strict = false @amount = 100 - @credit_card = credit_card('4111111111111111', :month => 8, :year => 2018, :verification_value => 737) - @declined_card = credit_card('4000300011112220', :month => 8, :year => 2018, :verification_value => 737) + @credit_card = credit_card('4111111111111111', :month => 10, :year => 2020, :verification_value => 737) + @declined_card = credit_card('4000300011112220', :month => 3, :year => 2030, :verification_value => 737) @three_ds_enrolled_card = credit_card('4212345678901237', brand: :visa) @options = { @@ -238,6 +238,11 @@ def test_failed_credit_insufficient_validation # assert_failure response end + def test_successful_third_party_payout + response = @gateway.credit(@amount, @credit_card, @options_with_credit_fields.merge({third_party_payout: true})) + assert_success response + end + def test_successful_void auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb index 4763dfa6813..e88dd36bdea 100644 --- a/test/unit/gateways/barclaycard_smartpay_test.rb +++ b/test/unit/gateways/barclaycard_smartpay_test.rb @@ -263,6 +263,7 @@ def test_credit_contains_all_fields response = stub_comms do @gateway.credit(@amount, @credit_card, @options_with_credit_fields) end.check_request do |endpoint, data, headers| + assert_match(%r{/refundWithData}, endpoint) assert_match(/dateOfBirth=1990-10-11&/, data) assert_match(/entityType=NaturalPerson&/, data) assert_match(/nationality=US&/, data) @@ -273,6 +274,26 @@ def test_credit_contains_all_fields assert response.test? end + def test_successful_third_party_payout + response = stub_comms do + @gateway.credit(@amount, @credit_card, @options_with_credit_fields.merge({third_party_payout: true})) + end.check_request do |endpoint, data, headers| + if /storeDetailAndSubmitThirdParty/ =~ endpoint + assert_match(%r{/storeDetailAndSubmitThirdParty}, endpoint) + assert_match(/dateOfBirth=1990-10-11&/, data) + assert_match(/entityType=NaturalPerson&/, data) + assert_match(/nationality=US&/, data) + assert_match(/shopperName.firstName=Longbob&/, data) + assert_match(/recurring\.contract=PAYOUT/, data) + else + assert_match(/originalReference=/, data) + end + end.respond_with(successful_payout_store_response, successful_payout_confirm_response) + + assert_success response + assert response.test? + end + def test_successful_void @gateway.expects(:ssl_post).returns(successful_void_response) @@ -380,6 +401,14 @@ def successful_credit_response 'fraudResult.accountScore=70&fraudResult.results.0.accountScore=20&fraudResult.results.0.checkId=2&fraudResult.results.0.name=CardChunkUsage&fraudResult.results.1.accountScore=25&fraudResult.results.1.checkId=4&fraudResult.results.1.name=HolderNameUsage&fraudResult.results.2.accountScore=25&fraudResult.results.2.checkId=8&fraudResult.results.2.name=ShopperEmailUsage&fraudResult.results.3.accountScore=0&fraudResult.results.3.checkId=1&fraudResult.results.3.name=PaymentDetailRefCheck&fraudResult.results.4.accountScore=0&fraudResult.results.4.checkId=13&fraudResult.results.4.name=IssuerRefCheck&fraudResult.results.5.accountScore=0&fraudResult.results.5.checkId=15&fraudResult.results.5.name=IssuingCountryReferral&fraudResult.results.6.accountScore=0&fraudResult.results.6.checkId=26&fraudResult.results.6.name=ShopperEmailRefCheck&fraudResult.results.7.accountScore=0&fraudResult.results.7.checkId=27&fraudResult.results.7.name=PmOwnerRefCheck&fraudResult.results.8.accountScore=0&fraudResult.results.8.checkId=56&fraudResult.results.8.name=ShopperReferenceTrustCheck&fraudResult.results.9.accountScore=0&fraudResult.results.9.checkId=10&fraudResult.results.9.name=HolderNameContainsNumber&fraudResult.results.10.accountScore=0&fraudResult.results.10.checkId=11&fraudResult.results.10.name=HolderNameIsOneWord&fraudResult.results.11.accountScore=0&fraudResult.results.11.checkId=21&fraudResult.results.11.name=EmailDomainValidation&pspReference=8514743049239955&resultCode=Received' end + def successful_payout_store_response + 'pspReference=8815391117417347&resultCode=%5Bpayout-submit-received%5D' + end + + def successful_payout_confirm_response + 'pspReference=8815391117421182&response=%5Bpayout-confirm-received%5D' + end + def failed_credit_response 'errorType=validation&errorCode=137&message=Invalid+amount+specified&status=422' end From d62d60e356207e1c00f696b5d02985235f64c16e Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Tue, 2 Oct 2018 09:31:22 -0400 Subject: [PATCH 567/677] RuboCop: AlignHash Rubocop fix to align all hashes. --- .rubocop_todo.yml | 9 - CHANGELOG | 1 + .../billing/gateways/usa_epay_advanced.rb | 2 +- .../gateways/worldpay_online_payments.rb | 30 +- .../gateways/remote_firstdata_e4_v27_test.rb | 6 +- test/remote/gateways/remote_opp_test.rb | 62 ++--- .../gateways/remote_payflow_express_test.rb | 105 ++++--- .../gateways/remote_paypal_express_test.rb | 16 +- test/remote/gateways/remote_paypal_test.rb | 16 +- .../remote/gateways/remote_secure_pay_test.rb | 3 +- test/unit/gateways/cyber_source_test.rb | 36 +-- test/unit/gateways/eway_managed_test.rb | 33 +-- test/unit/gateways/linkpoint_test.rb | 52 +++- test/unit/gateways/opp_test.rb | 2 +- test/unit/gateways/orbital_test.rb | 18 +- .../gateways/paypal/paypal_common_api_test.rb | 25 +- test/unit/gateways/paypal_express_test.rb | 262 +++++++++++++----- test/unit/gateways/quickpay_v10_test.rb | 12 +- test/unit/gateways/sage_pay_test.rb | 4 +- 19 files changed, 438 insertions(+), 256 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 989a1398236..3e0bb88d4c3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -14,15 +14,6 @@ Gemspec/OrderedDependencies: Exclude: - 'activemerchant.gemspec' -# Offense count: 139 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/AlignHash: - Enabled: false - # Offense count: 113 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. diff --git a/CHANGELOG b/CHANGELOG index cfe49500d9b..471a6603a47 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] [#3002] * Global Collect: handle internal server errors [molbrown] [#3005] * Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009 +* RuboCop: AlignHash [nfarve] #3004 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001] diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb index 1744dcc1306..2f756c0979e 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb @@ -1310,7 +1310,7 @@ def build_customer_payments(soap, options) if options[:payment_methods] length = options[:payment_methods].length soap.PaymentMethods 'SOAP-ENC:arrayType' => "ns1:PaymentMethod[#{length}]", - 'xsi:type' =>'ns1:PaymentMethodArray' do + 'xsi:type' =>'ns1:PaymentMethodArray' do build_customer_payment_methods soap, options end end diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb index 519bef0b41a..ede932554ba 100644 --- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb @@ -92,21 +92,21 @@ def create_token(reusable, name, exp_month, exp_year, number, cvc) end def create_post_for_auth_or_purchase(token, money, options) - { - 'token' => token, - 'orderDescription' => options[:description] || 'Worldpay Order', - 'amount' => money, - 'currencyCode' => options[:currency] || default_currency, - 'name' => options[:billing_address]&&options[:billing_address][:name] ? options[:billing_address][:name] : '', - 'billingAddress' => { - 'address1'=>options[:billing_address]&&options[:billing_address][:address1] ? options[:billing_address][:address1] : '', - 'address2'=>options[:billing_address]&&options[:billing_address][:address2] ? options[:billing_address][:address2] : '', - 'address3'=>'', - 'postalCode'=>options[:billing_address]&&options[:billing_address][:zip] ? options[:billing_address][:zip] : '', - 'city'=>options[:billing_address]&&options[:billing_address][:city] ? options[:billing_address][:city] : '', - 'state'=>options[:billing_address]&&options[:billing_address][:state] ? options[:billing_address][:state] : '', - 'countryCode'=>options[:billing_address]&&options[:billing_address][:country] ? options[:billing_address][:country] : '' - }, + { + 'token' => token, + 'orderDescription' => options[:description] || 'Worldpay Order', + 'amount' => money, + 'currencyCode' => options[:currency] || default_currency, + 'name' => options[:billing_address]&&options[:billing_address][:name] ? options[:billing_address][:name] : '', + 'billingAddress' => { + 'address1'=>options[:billing_address]&&options[:billing_address][:address1] ? options[:billing_address][:address1] : '', + 'address2'=>options[:billing_address]&&options[:billing_address][:address2] ? options[:billing_address][:address2] : '', + 'address3'=>'', + 'postalCode'=>options[:billing_address]&&options[:billing_address][:zip] ? options[:billing_address][:zip] : '', + 'city'=>options[:billing_address]&&options[:billing_address][:city] ? options[:billing_address][:city] : '', + 'state'=>options[:billing_address]&&options[:billing_address][:state] ? options[:billing_address][:state] : '', + 'countryCode'=>options[:billing_address]&&options[:billing_address][:country] ? options[:billing_address][:country] : '' + }, 'customerOrderCode' => options[:order_id], 'orderType' => 'ECOM', 'authorizeOnly' => options[:authorizeOnly] ? true : false diff --git a/test/remote/gateways/remote_firstdata_e4_v27_test.rb b/test/remote/gateways/remote_firstdata_e4_v27_test.rb index 464f8d87f56..0832c159edc 100644 --- a/test/remote/gateways/remote_firstdata_e4_v27_test.rb +++ b/test/remote/gateways/remote_firstdata_e4_v27_test.rb @@ -160,9 +160,9 @@ def test_failed_verify def test_invalid_login gateway = FirstdataE4V27Gateway.new(:login => 'NotARealUser', - :password => 'NotARealPassword', - :key_id => 'NotARealKey', - :hmac_key => 'NotARealHMAC' ) + :password => 'NotARealPassword', + :key_id => 'NotARealKey', + :hmac_key => 'NotARealHMAC' ) assert response = gateway.purchase(@amount, @credit_card, @options) assert_match %r{Unauthorized Request}, response.message assert_failure response diff --git a/test/remote/gateways/remote_opp_test.rb b/test/remote/gateways/remote_opp_test.rb index 8dbdd9d3970..652059e87ad 100644 --- a/test/remote/gateways/remote_opp_test.rb +++ b/test/remote/gateways/remote_opp_test.rb @@ -18,37 +18,37 @@ def setup merchant_transaction_id: "active_merchant_test_complete #{time}", address: address, description: 'Store Purchase - Books', - # riskWorkflow: true, - # testMode: 'EXTERNAL' # or 'INTERNAL', valid only for test system - - billing_address: { - address1: '123 Test Street', - city: 'Test', - state: 'TE', - zip: 'AB12CD', - country: 'GB', - }, - shipping_address: { - name: 'Muton DeMicelis', - address1: 'My Street On Upiter, Apt 3.14/2.78', - city: 'Munich', - state: 'Bov', - zip: '81675', - country: 'DE', - }, - customer: { - merchant_customer_id: 'your merchant/customer id', - givenName: 'Jane', - surname: 'Jones', - birthDate: '1965-05-01', - phone: '(?!?)555-5555', - mobile: '(?!?)234-23423', - email: 'jane@jones.com', - company_name: 'JJ Ltd.', - identification_doctype: 'PASSPORT', - identification_docid: 'FakeID2342431234123', - ip: ip, - }, + # riskWorkflow: true, + # testMode: 'EXTERNAL' # or 'INTERNAL', valid only for test system + + billing_address: { + address1: '123 Test Street', + city: 'Test', + state: 'TE', + zip: 'AB12CD', + country: 'GB', + }, + shipping_address: { + name: 'Muton DeMicelis', + address1: 'My Street On Upiter, Apt 3.14/2.78', + city: 'Munich', + state: 'Bov', + zip: '81675', + country: 'DE', + }, + customer: { + merchant_customer_id: 'your merchant/customer id', + givenName: 'Jane', + surname: 'Jones', + birthDate: '1965-05-01', + phone: '(?!?)555-5555', + mobile: '(?!?)234-23423', + email: 'jane@jones.com', + company_name: 'JJ Ltd.', + identification_doctype: 'PASSPORT', + identification_docid: 'FakeID2342431234123', + ip: ip, + }, } @minimal_request_options = { diff --git a/test/remote/gateways/remote_payflow_express_test.rb b/test/remote/gateways/remote_payflow_express_test.rb index c2a2cbfe2c0..b25c566df9a 100644 --- a/test/remote/gateways/remote_payflow_express_test.rb +++ b/test/remote/gateways/remote_payflow_express_test.rb @@ -6,17 +6,19 @@ def setup @gateway = PayflowExpressGateway.new(fixtures(:payflow)) - @options = { :billing_address => { - :name => 'Cody Fauser', - :address1 => '1234 Shady Brook Lane', - :city => 'Ottawa', - :state => 'ON', - :country => 'CA', - :zip => '90210', - :phone => '555-555-5555' - }, - :email => 'cody@example.com' - } + @options = { + :billing_address => + { + :name => 'Cody Fauser', + :address1 => '1234 Shady Brook Lane', + :city => 'Ottawa', + :state => 'ON', + :country => 'CA', + :zip => '90210', + :phone => '555-555-5555' + }, + :email => 'cody@example.com' + } end # Only works with a Payflow 2.0 account or by requesting the addition @@ -50,7 +52,8 @@ def test_set_express_purchase def test_setup_authorization_discount_taxes_included_free_shipping amount = 2518 - options = {:ip=>'127.0.0.1', + options = { + :ip=>'127.0.0.1', :return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1', :cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1', :customer=>'test6@test.com', @@ -59,20 +62,25 @@ def test_setup_authorization_discount_taxes_included_free_shipping :currency=>'USD', :subtotal=>2798, :items => [ - {:name => 'test4', + { + :name => 'test4', :description => 'test4', :quantity=>2 , :amount=> 1399 , - :url=>'http://localhost:3000/products/test4'}], + :url=>'http://localhost:3000/products/test4' + } + ], :discount=>280, - :no_shipping=>true} + :no_shipping=>true + } response = @gateway.setup_authorization(amount, options) assert response.success?, response.message end def test_setup_authorization_with_discount_taxes_additional amount = 2518 - options = {:ip=>'127.0.0.1', + options = { + :ip=>'127.0.0.1', :return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1', :cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1', :customer=>'test6@test.com', @@ -81,20 +89,25 @@ def test_setup_authorization_with_discount_taxes_additional :currency=>'USD', :subtotal=>2798, :items => [ - {:name => 'test4', + { + :name => 'test4', :description => 'test4', :quantity=>2 , :amount=> 1399 , - :url=>'http://localhost:3000/products/test4'}], + :url=>'http://localhost:3000/products/test4' + } + ], :discount=>280, - :no_shipping=>true} + :no_shipping=>true + } response = @gateway.setup_authorization(amount, options) assert response.success?, response.message end def test_setup_authorization_with_discount_taxes_and_shipping_addtiional amount = 2518 - options = {:ip=>'127.0.0.1', + options = { + :ip=>'127.0.0.1', :return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1', :cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1', :customer=>'test6@test.com', @@ -103,13 +116,17 @@ def test_setup_authorization_with_discount_taxes_and_shipping_addtiional :currency=>'USD', :subtotal=>2798, :items => [ - {:name => 'test4', + { + :name => 'test4', :description => 'test4', :quantity=>2 , :amount=> 1399 , - :url=>'http://localhost:3000/products/test4'}], + :url=>'http://localhost:3000/products/test4' + } + ], :discount=>280, - :no_shipping=>false} + :no_shipping=>false + } response = @gateway.setup_authorization(amount, options) assert response.success?, response.message end @@ -123,7 +140,8 @@ def setup def test_setup_authorization_discount_taxes_included_free_shipping amount = 2518 - options = {:ip=>'127.0.0.1', + options = { + :ip=>'127.0.0.1', :return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1', :cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1', :customer=>'test6@test.com', @@ -132,21 +150,25 @@ def test_setup_authorization_discount_taxes_included_free_shipping :currency=>'GBP', :subtotal=>2798, :items=> [ - {:name=>'test4', + { + :name=>'test4', :description=>'test4', :quantity=>2, :amount=>1399, - :url=>'http://localhost:3000/products/test4'}, - ], + :url=>'http://localhost:3000/products/test4' + } + ], :discount=>280, - :no_shipping=>true} + :no_shipping=>true + } response = @gateway.setup_authorization(amount, options) assert response.success?, response.message end def test_setup_authorization_with_discount_taxes_additional amount = 2518 - options = {:ip=>'127.0.0.1', + options = { + :ip=>'127.0.0.1', :return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1', :cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1', :customer=>'test6@test.com', @@ -155,21 +177,25 @@ def test_setup_authorization_with_discount_taxes_additional :currency=>'GBP', :subtotal=>2798, :items=> [ - {:name=>'test4', + { + :name=>'test4', :description=>'test4', :quantity=>2, :amount=>1399, - :url=>'http://localhost:3000/products/test4'}, - ], + :url=>'http://localhost:3000/products/test4' + } + ], :discount=>280, - :no_shipping=>true} + :no_shipping=>true + } response = @gateway.setup_authorization(amount, options) assert response.success?, response.message end def test_setup_authorization_with_discount_taxes_and_shipping_addtiional amount = 2518 - options = {:ip=>'127.0.0.1', + options = { + :ip=>'127.0.0.1', :return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1', :cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1', :customer=>'test6@test.com', @@ -178,14 +204,17 @@ def test_setup_authorization_with_discount_taxes_and_shipping_addtiional :currency=>'GBP', :subtotal=>2798, :items=> [ - {:name=>'test4', + { + :name=>'test4', :description=>'test4', :quantity=>2, :amount=>1399, - :url=>'http://localhost:3000/products/test4'}, - ], + :url=>'http://localhost:3000/products/test4' + } + ], :discount=>280, - :no_shipping=>false} + :no_shipping=>false + } response = @gateway.setup_authorization(amount, options) assert response.success?, response.message end diff --git a/test/remote/gateways/remote_paypal_express_test.rb b/test/remote/gateways/remote_paypal_express_test.rb index 938bd0f9c14..e5a4ff50364 100644 --- a/test/remote/gateways/remote_paypal_express_test.rb +++ b/test/remote/gateways/remote_paypal_express_test.rb @@ -9,13 +9,15 @@ def setup @options = { :order_id => '230000', :email => 'buyer@jadedpallet.com', - :billing_address => { :name => 'Fred Brooks', - :address1 => '1234 Penny Lane', - :city => 'Jonsetown', - :state => 'NC', - :country => 'US', - :zip => '23456' - } , + :billing_address => + { + :name => 'Fred Brooks', + :address1 => '1234 Penny Lane', + :city => 'Jonsetown', + :state => 'NC', + :country => 'US', + :zip => '23456' + } , :description => 'Stuff that you purchased, yo!', :ip => '10.0.0.1', :return_url => 'http://example.com/return', diff --git a/test/remote/gateways/remote_paypal_test.rb b/test/remote/gateways/remote_paypal_test.rb index 44ef35493fb..7901d34024a 100644 --- a/test/remote/gateways/remote_paypal_test.rb +++ b/test/remote/gateways/remote_paypal_test.rb @@ -10,13 +10,15 @@ def setup @params = { :order_id => generate_unique_id, :email => 'buyer@jadedpallet.com', - :billing_address => { :name => 'Longbob Longsen', - :address1 => '4321 Penny Lane', - :city => 'Jonsetown', - :state => 'NC', - :country => 'US', - :zip => '23456' - } , + :billing_address => + { + :name => 'Longbob Longsen', + :address1 => '4321 Penny Lane', + :city => 'Jonsetown', + :state => 'NC', + :country => 'US', + :zip => '23456' + }, :description => 'Stuff that you purchased, yo!', :ip => '10.0.0.1' } diff --git a/test/remote/gateways/remote_secure_pay_test.rb b/test/remote/gateways/remote_secure_pay_test.rb index 5806fd0ab72..c739e1cc9f4 100644 --- a/test/remote/gateways/remote_secure_pay_test.rb +++ b/test/remote/gateways/remote_secure_pay_test.rb @@ -10,7 +10,8 @@ def setup :year => '2014' ) - @options = { :order_id => generate_unique_id, + @options = { + :order_id => generate_unique_id, :description => 'Store purchase', :billing_address => address } diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index 96dce2add49..82dbff6dd06 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -19,24 +19,24 @@ def setup @check = check() @options = { - :ip => @customer_ip, - :order_id => '1000', - :line_items => [ - { - :declared_value => @amount, - :quantity => 2, - :code => 'default', - :description => 'Giant Walrus', - :sku => 'WA323232323232323' - }, - { - :declared_value => @amount, - :quantity => 2, - :description => 'Marble Snowcone', - :sku => 'FAKE1232132113123' - } - ], - :currency => 'USD' + :ip => @customer_ip, + :order_id => '1000', + :line_items => [ + { + :declared_value => @amount, + :quantity => 2, + :code => 'default', + :description => 'Giant Walrus', + :sku => 'WA323232323232323' + }, + { + :declared_value => @amount, + :quantity => 2, + :description => 'Marble Snowcone', + :sku => 'FAKE1232132113123' + } + ], + :currency => 'USD' } @subscription_options = { diff --git a/test/unit/gateways/eway_managed_test.rb b/test/unit/gateways/eway_managed_test.rb index b8f0f421e7a..c322e223579 100644 --- a/test/unit/gateways/eway_managed_test.rb +++ b/test/unit/gateways/eway_managed_test.rb @@ -14,22 +14,23 @@ def setup @amount = 100 - @options = { :billing_address => { - :address1 => '1234 My Street', - :address2 => 'Apt 1', - :company => 'Widgets Inc', - :city => 'Ottawa', - :state => 'ON', - :zip => 'K1C2N6', - :country => 'au', - :title => 'Mr.', - :phone => '(555)555-5555' - }, - :email => 'someguy1232@fakeemail.net', - :order_id => '1000', - :customer => 'mycustomerref', - :description => 'My Description', - :invoice => 'invoice-4567' + @options = { + :billing_address => { + :address1 => '1234 My Street', + :address2 => 'Apt 1', + :company => 'Widgets Inc', + :city => 'Ottawa', + :state => 'ON', + :zip => 'K1C2N6', + :country => 'au', + :title => 'Mr.', + :phone => '(555)555-5555' + }, + :email => 'someguy1232@fakeemail.net', + :order_id => '1000', + :customer => 'mycustomerref', + :description => 'My Description', + :invoice => 'invoice-4567' } end diff --git a/test/unit/gateways/linkpoint_test.rb b/test/unit/gateways/linkpoint_test.rb index 9cbbd9897b0..50639eb460a 100644 --- a/test/unit/gateways/linkpoint_test.rb +++ b/test/unit/gateways/linkpoint_test.rb @@ -80,7 +80,9 @@ def test_amount_style def test_purchase_is_valid_xml @gateway.send( - :parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1004, + :parameters, 1000, @credit_card, + :ordertype => 'SALE', + :order_id => 1004, :billing_address => { :address1 => '1313 lucky lane', :city => 'Lost Angeles', @@ -95,7 +97,13 @@ def test_purchase_is_valid_xml def test_recurring_is_valid_xml @gateway.send( - :parameters, 1000, @credit_card, :ordertype => 'SALE', :action => 'SUBMIT', :installments => 12, :startdate => 'immediate', :periodicity => 'monthly', :order_id => 1006, + :parameters, 1000, @credit_card, + :ordertype => 'SALE', + :action => 'SUBMIT', + :installments => 12, + :startdate => 'immediate', + :periodicity => 'monthly', + :order_id => 1006, :billing_address => { :address1 => '1313 lucky lane', :city => 'Lost Angeles', @@ -108,16 +116,42 @@ def test_recurring_is_valid_xml end def test_line_items_are_valid_xml - options = {:ordertype => 'SALE', :action => 'SUBMIT', :installments => 12, :startdate => 'immediate', :periodicity => 'monthly', :order_id => 1006, + options = { + :ordertype => 'SALE', + :action => 'SUBMIT', + :installments => 12, + :startdate => 'immediate', + :periodicity => 'monthly', + :order_id => 1006, :billing_address => { :address1 => '1313 lucky lane', :city => 'Lost Angeles', :state => 'CA', :zip => '90210' - }, - :line_items => [{:id => '123456', :description => 'Logo T-Shirt', :price => - '12.00', :quantity => '1', :options => [{:name => 'Color', :value => - 'Red'}, {:name => 'Size', :value => 'XL'}]},{:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'}]} + }, + :line_items => [ + { + :id => '123456', + :description => 'Logo T-Shirt', + :price => '12.00', + :quantity => '1', + :options => [ + { + :name => 'Color', + :value => 'Red'}, + { + :name => 'Size', + :value => 'XL'} + ] + }, + { + :id => '111', + :description => 'keychain', + :price => '3.00', + :quantity => '1' + } + ] + } assert data = @gateway.send(:post_data, @amount, @credit_card, options) assert REXML::Document.new(data) @@ -127,7 +161,9 @@ def test_declined_purchase_is_valid_xml @gateway = LinkpointGateway.new(:login => 123123, :pem => 'PEM') @gateway.send( - :parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1005, + :parameters, 1000, @credit_card, + :ordertype => 'SALE', + :order_id => 1005, :billing_address => { :address1 => '1313 lucky lane', :city => 'Lost Angeles', diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb index 5b830c28faa..93d33190471 100644 --- a/test/unit/gateways/opp_test.rb +++ b/test/unit/gateways/opp_test.rb @@ -199,7 +199,7 @@ def failed_response(type, id, code='100.100.101') OppMockResponse.new(400, JSON.generate({'id' => id,'paymentType' => type,'paymentBrand' => 'VISA','result' => {'code' => code,"des cription" => 'invalid creditcard, bank account number or bank name'},'card' => {'bin' => '444444','last4Digits' => '4444','holder' => 'Longbob Longsen','expiryMonth' => '05','expiryYear' => '2018'}, - 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage','timestamp' => '2015-06-20 20:40:26+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d'}) + 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage','timestamp' => '2015-06-20 20:40:26+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d'}) ) end diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index 8bcffb2ccc5..b79fdac439e 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -242,7 +242,7 @@ def test_address_format response = stub_comms do @gateway.purchase(50, credit_card, :order_id => 1, - :billing_address => address_with_invalid_chars) + :billing_address => address_with_invalid_chars) end.check_request do |endpoint, data, headers| assert_match(/456 Main Street</, data) assert_match(/Apt. Number One</, data) @@ -289,7 +289,7 @@ def test_truncates_by_byte_length response = stub_comms do @gateway.purchase(50, card, :order_id => 1, - :billing_address => long_address) + :billing_address => long_address) end.check_request do |endpoint, data, headers| assert_match(/456 Stréêt Name is Really Lo</, data) assert_match(/Apårtmeñt 123456789012345678</, data) @@ -350,7 +350,7 @@ def test_dest_address response = stub_comms do @gateway.purchase(50, credit_card, :order_id => 1, - :billing_address => billing_address) + :billing_address => billing_address) end.check_request do |endpoint, data, headers| assert_match(/<AVSDestzip>90001/, data) assert_match(/<AVSDestaddress1>456 Main St./, data) @@ -366,7 +366,7 @@ def test_dest_address # non-AVS country response = stub_comms do @gateway.purchase(50, credit_card, :order_id => 1, - :billing_address => billing_address.merge(:dest_country => 'BR')) + :billing_address => billing_address.merge(:dest_country => 'BR')) end.check_request do |endpoint, data, headers| assert_match(/<AVSDestcountryCode></, data) end.respond_with(successful_purchase_response) @@ -393,10 +393,12 @@ def test_managed_billing response = stub_comms do assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do assert_deprecation_warning do - @gateway.add_customer_profile(credit_card, :managed_billing => {:start_date => '10-10-2014', - :end_date => '10-10-2015', - :max_dollar_value => 1500, - :max_transactions => 12}) + @gateway.add_customer_profile(credit_card, + :managed_billing => { + :start_date => '10-10-2014', + :end_date => '10-10-2015', + :max_dollar_value => 1500, + :max_transactions => 12}) end end end.check_request do |endpoint, data, headers| diff --git a/test/unit/gateways/paypal/paypal_common_api_test.rb b/test/unit/gateways/paypal/paypal_common_api_test.rb index 93ecc4ce2f2..5193e20846b 100644 --- a/test/unit/gateways/paypal/paypal_common_api_test.rb +++ b/test/unit/gateways/paypal/paypal_common_api_test.rb @@ -23,15 +23,16 @@ def setup :pem => 'PEM' ) - @address = { :address1 => '1234 My Street', - :address2 => 'Apt 1', - :company => 'Widgets Inc', - :city => 'Ottawa', - :state => 'ON', - :zip => 'K1C2N6', - :country => 'Canada', - :phone => '(555)555-5555' - } + @address = { + :address1 => '1234 My Street', + :address2 => 'Apt 1', + :company => 'Widgets Inc', + :city => 'Ottawa', + :state => 'ON', + :zip => 'K1C2N6', + :country => 'Canada', + :phone => '(555)555-5555' + } end def xml_builder @@ -135,10 +136,12 @@ def test_transaction_search_requires end def test_build_transaction_search_request - options = {:start_date => DateTime.new(2012, 2, 21, 0), + options = { + :start_date => DateTime.new(2012, 2, 21, 0), :end_date => DateTime.new(2012, 3, 21, 0), :receiver => 'foo@example.com', - :first_name => 'Robert'} + :first_name => 'Robert' + } request = REXML::Document.new(@gateway.send(:build_transaction_search, options)) assert_match %r{^2012-02-21T\d{2}:00:00Z$}, REXML::XPath.first(request, '//TransactionSearchReq/TransactionSearchRequest/StartDate').text assert_match %r{^2012-03-21T\d{2}:00:00Z$}, REXML::XPath.first(request, '//TransactionSearchReq/TransactionSearchRequest/EndDate').text diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb index c88f0291630..bed1c4be532 100644 --- a/test/unit/gateways/paypal_express_test.rb +++ b/test/unit/gateways/paypal_express_test.rb @@ -19,15 +19,16 @@ def setup :pem => 'PEM' ) - @address = { :address1 => '1234 My Street', - :address2 => 'Apt 1', - :company => 'Widgets Inc', - :city => 'Ottawa', - :state => 'ON', - :zip => 'K1C2N6', - :country => 'Canada', - :phone => '(555)555-5555' - } + @address = { + :address1 => '1234 My Street', + :address2 => 'Apt 1', + :company => 'Widgets Inc', + :city => 'Ottawa', + :state => 'ON', + :zip => 'K1C2N6', + :country => 'Canada', + :phone => '(555)555-5555' + } Base.mode = :test end @@ -165,10 +166,24 @@ def test_does_not_include_items_if_not_specified end def test_items_are_included_if_specified_in_build_setup_request - xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, {:currency => 'GBP', :items => [ - {:name => 'item one', :description => 'item one description', :amount => 10000, :number => 1, :quantity => 3}, - {:name => 'item two', :description => 'item two description', :amount => 20000, :number => 2, :quantity => 4} - ]})) + xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, { + :currency => 'GBP', + :items => [ + { + :name => 'item one', + :description => 'item one description', + :amount => 10000, + :number => 1, + :quantity => 3 + }, + { :name => 'item two', + :description => 'item two description', + :amount => 20000, + :number => 2, + :quantity => 4 + } + ] + })) assert_equal 'item one', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Name').text assert_equal 'item one description', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Description').text @@ -228,16 +243,22 @@ def test_does_not_include_flatrate_shipping_options_if_not_specified end def test_flatrate_shipping_options_are_included_if_specified_in_build_setup_request - xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, {:currency => 'AUD', :shipping_options => [ - {:default => true, + xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, + { + :currency => 'AUD', + :shipping_options => [ + { + :default => true, :name => 'first one', :amount => 1000 - }, - {:default => false, - :name => 'second one', - :amount => 2000 - } - ]})) + }, + { + :default => false, + :name => 'second one', + :amount => 2000 + } + ] + })) assert_equal 'true', REXML::XPath.first(xml, '//n2:FlatRateShippingOptions/n2:ShippingOptionIsDefault').text assert_equal 'first one', REXML::XPath.first(xml, '//n2:FlatRateShippingOptions/n2:ShippingOptionName').text @@ -251,14 +272,18 @@ def test_flatrate_shipping_options_are_included_if_specified_in_build_setup_requ end def test_address_is_included_if_specified - xml = REXML::Document.new(@gateway.send(:build_setup_request, 'Sale', 0, {:currency => 'GBP', :address => { - :name => 'John Doe', - :address1 => '123 somewhere', - :city => 'Townville', - :country => 'Canada', - :zip => 'k1l4p2', - :phone => '1231231231' - }})) + xml = REXML::Document.new(@gateway.send(:build_setup_request, 'Sale', 0, + { + :currency => 'GBP', + :address => { + :name => 'John Doe', + :address1 => '123 somewhere', + :city => 'Townville', + :country => 'Canada', + :zip => 'k1l4p2', + :phone => '1231231231' + } + })) assert_equal 'John Doe', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:ShipToAddress/n2:Name').text assert_equal '123 somewhere', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:ShipToAddress/n2:Street1').text @@ -287,10 +312,30 @@ def test_removes_fractional_amounts_with_twd_currency end def test_fractional_discounts_are_correctly_calculated_with_jpy_currency - xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 14250, { :items => - [{:name => 'item one', :description => 'description', :amount => 15000, :number => 1, :quantity => 1}, - {:name => 'Discount', :description => 'Discount', :amount => -750, :number => 2, :quantity => 1}], - :subtotal => 14250, :currency => 'JPY', :shipping => 0, :handling => 0, :tax => 0 })) + xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 14250, + { + :items => [ + { + :name => 'item one', + :description => 'description', + :amount => 15000, + :number => 1, + :quantity => 1 + }, + { + :name => 'Discount', + :description => 'Discount', + :amount => -750, + :number => 2, + :quantity => 1 + } + ], + :subtotal => 14250, + :currency => 'JPY', + :shipping => 0, + :handling => 0, + :tax => 0 + })) assert_equal '142', REXML::XPath.first(xml, '//n2:OrderTotal').text assert_equal '142', REXML::XPath.first(xml, '//n2:ItemTotal').text @@ -300,10 +345,30 @@ def test_fractional_discounts_are_correctly_calculated_with_jpy_currency end def test_non_fractional_discounts_are_correctly_calculated_with_jpy_currency - xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 14300, { :items => - [{:name => 'item one', :description => 'description', :amount => 15000, :number => 1, :quantity => 1}, - {:name => 'Discount', :description => 'Discount', :amount => -700, :number => 2, :quantity => 1}], - :subtotal => 14300, :currency => 'JPY', :shipping => 0, :handling => 0, :tax => 0 })) + xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 14300, + { + :items => [ + { + :name => 'item one', + :description => 'description', + :amount => 15000, + :number => 1, + :quantity => 1 + }, + { + :name => 'Discount', + :description => 'Discount', + :amount => -700, + :number => 2, + :quantity => 1 + } + ], + :subtotal => 14300, + :currency => 'JPY', + :shipping => 0, + :handling => 0, + :tax => 0 + })) assert_equal '143', REXML::XPath.first(xml, '//n2:OrderTotal').text assert_equal '143', REXML::XPath.first(xml, '//n2:ItemTotal').text @@ -313,10 +378,30 @@ def test_non_fractional_discounts_are_correctly_calculated_with_jpy_currency end def test_fractional_discounts_are_correctly_calculated_with_usd_currency - xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 14250, { :items => - [{:name => 'item one', :description => 'description', :amount => 15000, :number => 1, :quantity => 1}, - {:name => 'Discount', :description => 'Discount', :amount => -750, :number => 2, :quantity => 1}], - :subtotal => 14250, :currency => 'USD', :shipping => 0, :handling => 0, :tax => 0 })) + xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 14250, + { + :items => [ + { + :name => 'item one', + :description => 'description', + :amount => 15000, + :number => 1, + :quantity => 1 + }, + { + :name => 'Discount', + :description => 'Discount', + :amount => -750, + :number => 2, + :quantity => 1 + } + ], + :subtotal => 14250, + :currency => 'USD', + :shipping => 0, + :handling => 0, + :tax => 0 + })) assert_equal '142.50', REXML::XPath.first(xml, '//n2:OrderTotal').text assert_equal '142.50', REXML::XPath.first(xml, '//n2:ItemTotal').text @@ -369,10 +454,25 @@ def test_button_source end def test_items_are_included_if_specified_in_build_sale_or_authorization_request - xml = REXML::Document.new(@gateway.send(:build_sale_or_authorization_request, 'Sale', 100, {:items => [ - {:name => 'item one', :description => 'item one description', :amount => 10000, :number => 1, :quantity => 3}, - {:name => 'item two', :description => 'item two description', :amount => 20000, :number => 2, :quantity => 4} - ]})) + xml = REXML::Document.new(@gateway.send(:build_sale_or_authorization_request, 'Sale', 100, + { + :items => [ + { + :name => 'item one', + :description => 'item one description', + :amount => 10000, + :number => 1, + :quantity => 3 + }, + { + :name => 'item two', + :description => 'item two description', + :amount => 20000, + :number => 2, + :quantity => 4 + } + ] + })) assert_equal 'item one', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Name').text assert_equal 'item one description', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Description').text @@ -448,12 +548,14 @@ def test_agreement_details_failure def test_build_reference_transaction_test PaypalExpressGateway.application_id = 'ActiveMerchant_FOO' - xml = REXML::Document.new(@gateway.send(:build_reference_transaction_request, 'Sale', 2000, { - :reference_id => 'ref_id', - :payment_type => 'Any', - :invoice_id => 'invoice_id', - :description => 'Description', - :ip => '127.0.0.1' })) + xml = REXML::Document.new(@gateway.send(:build_reference_transaction_request, 'Sale', 2000, + { + :reference_id => 'ref_id', + :payment_type => 'Any', + :invoice_id => 'invoice_id', + :description => 'Description', + :ip => '127.0.0.1' + })) assert_equal '124', REXML::XPath.first(xml, '//DoReferenceTransactionReq/DoReferenceTransactionRequest/n2:Version').text assert_equal 'ref_id', REXML::XPath.first(xml, '//DoReferenceTransactionReq/DoReferenceTransactionRequest/n2:DoReferenceTransactionRequestDetails/n2:ReferenceID').text @@ -475,12 +577,13 @@ def test_build_details_billing_agreement_request_test def test_authorize_reference_transaction @gateway.expects(:ssl_post).returns(successful_authorize_reference_transaction_response) - response = @gateway.authorize_reference_transaction(2000, { - :reference_id => 'ref_id', - :payment_type => 'Any', - :invoice_id => 'invoice_id', - :description => 'Description', - :ip => '127.0.0.1' }) + response = @gateway.authorize_reference_transaction(2000, + { + :reference_id => 'ref_id', + :payment_type => 'Any', + :invoice_id => 'invoice_id', + :description => 'Description', + :ip => '127.0.0.1' }) assert_equal 'Success', response.params['ack'] assert_equal 'Success', response.message @@ -598,27 +701,38 @@ def test_structure_correct :handling => 0, :tax => 5, :total_type => 'EstimatedTotal', - :items => [{:name => 'item one', - :number => 'number 1', - :quantity => 3, - :amount => 35, - :description => 'one description', - :url => 'http://example.com/number_1'}], - :address => {:name => 'John Doe', - :address1 => 'Apartment 1', - :address2 => '1 Road St', - :city => 'First City', - :state => 'NSW', - :country => 'AU', - :zip => '2000', - :phone => '555 5555'}, + :items => [ + { + :name => 'item one', + :number => 'number 1', + :quantity => 3, + :amount => 35, + :description => 'one description', + :url => 'http://example.com/number_1' + } + ], + :address => + { + :name => 'John Doe', + :address1 => 'Apartment 1', + :address2 => '1 Road St', + :city => 'First City', + :state => 'NSW', + :country => 'AU', + :zip => '2000', + :phone => '555 5555' + }, :callback_url => 'http://example.com/update_callback', :callback_timeout => 2, :callback_version => '53.0', :funding_sources => {:source => 'BML'}, - :shipping_options => [{:default => true, - :name => 'first one', - :amount => 10}] + :shipping_options => [ + { + :default => true, + :name => 'first one', + :amount => 10 + } + ] } doc = Nokogiri::XML(@gateway.send(:build_setup_request, 'Sale', 10, all_options_enabled)) diff --git a/test/unit/gateways/quickpay_v10_test.rb b/test/unit/gateways/quickpay_v10_test.rb index aac4bdb1e10..f2db1f727ec 100644 --- a/test/unit/gateways/quickpay_v10_test.rb +++ b/test/unit/gateways/quickpay_v10_test.rb @@ -182,9 +182,9 @@ def successful_authorization_response 'customer_ip' =>nil, 'customer_country' =>nil }, - 'created_at' => '2015-03-30T16:56:17Z', - 'balance' => 0, - 'currency' => 'DKK' + 'created_at' => '2015-03-30T16:56:17Z', + 'balance' => 0, + 'currency' => 'DKK' }.to_json end @@ -226,9 +226,9 @@ def succesful_refund_response 'customer_ip' =>nil, 'customer_country' =>nil }, - 'created_at' =>'2015-03-30T16:56:17Z', - 'balance' =>100, - 'currency' =>'DKK' + 'created_at' =>'2015-03-30T16:56:17Z', + 'balance' =>100, + 'currency' =>'DKK' }.to_json end diff --git a/test/unit/gateways/sage_pay_test.rb b/test/unit/gateways/sage_pay_test.rb index da8ed24674b..034d563e448 100644 --- a/test/unit/gateways/sage_pay_test.rb +++ b/test/unit/gateways/sage_pay_test.rb @@ -223,8 +223,8 @@ def test_website_is_submitted def test_FIxxxx_optional_fields_are_submitted stub_comms(@gateway, :ssl_request) do purchase_with_options(recipient_account_number: '1234567890', - recipient_surname: 'Withnail', recipient_postcode: 'AB11AB', - recipient_dob: '19701223') + recipient_surname: 'Withnail', recipient_postcode: 'AB11AB', + recipient_dob: '19701223') end.check_request do |method, endpoint, data, headers| assert_match(/FIRecipientAcctNumber=1234567890/, data) assert_match(/FIRecipientSurname=Withnail/, data) From bda5ba22360d9505587406193102396c1847b578 Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Thu, 11 Oct 2018 15:15:55 -0400 Subject: [PATCH 568/677] Beanstream: Switch `recurringPayment` flag from boolean to integer Remote: 42 tests, 189 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 95.2381% passed Unit: 23 tests, 108 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/beanstream/beanstream_core.rb | 2 +- test/remote/gateways/remote_beanstream_test.rb | 8 +++++++- test/unit/gateways/beanstream_test.rb | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 471a6603a47..029ce1e6d0d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Global Collect: handle internal server errors [molbrown] [#3005] * Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009 * RuboCop: AlignHash [nfarve] #3004 +* Beanstream: Switch `recurringPayment` flag from boolean to integer [dtykocki] #3011 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001] diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index 2800effb333..bbc548de702 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -266,7 +266,7 @@ def prepare_address_for_non_american_countries(options) end def add_recurring_payment(post, options) - post[:recurringPayment] = true if options[:recurring].to_s == 'true' + post[:recurringPayment] = 1 if options[:recurring].to_s == 'true' end def add_invoice(post, options) diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb index 67abd08ff7d..7041bd6ca9a 100644 --- a/test/remote/gateways/remote_beanstream_test.rb +++ b/test/remote/gateways/remote_beanstream_test.rb @@ -79,12 +79,18 @@ def test_successful_visa_purchase_with_recurring end def test_successful_visa_purchase_no_cvv - assert response = @gateway.purchase(@amount, @visa_no_cvv, @options) + assert response = @gateway.purchase(@amount, @visa_no_cvv, @options.merge(recurring: true)) assert_success response assert_false response.authorization.blank? assert_equal 'Approved', response.message end + def test_unsuccessful_visa_purchase_with_no_cvv + assert response = @gateway.purchase(@amount, @visa_no_cvv, @options) + assert_failure response + assert_equal 'Card CVD is invalid.', response.message + end + def test_unsuccessful_visa_purchase assert response = @gateway.purchase(@amount, @declined_visa, @options) assert_failure response diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb index a140fed4317..985748dfd03 100644 --- a/test/unit/gateways/beanstream_test.rb +++ b/test/unit/gateways/beanstream_test.rb @@ -72,7 +72,7 @@ def test_successful_purchase_with_recurring response = stub_comms(@gateway, :ssl_request) do @gateway.purchase(@amount, @decrypted_credit_card, @options.merge(recurring: true)) end.check_request do |method, endpoint, data, headers| - assert_match(/recurringPayment=true/, data) + assert_match(/recurringPayment=1/, data) end.respond_with(successful_purchase_response) assert_success response @@ -82,7 +82,7 @@ def test_successful_authorize_with_recurring response = stub_comms(@gateway, :ssl_request) do @gateway.authorize(@amount, @decrypted_credit_card, @options.merge(recurring: true)) end.check_request do |method, endpoint, data, headers| - assert_match(/recurringPayment=true/, data) + assert_match(/recurringPayment=1/, data) end.respond_with(successful_purchase_response) assert_success response From 1c637d26080a86ddc8dc890b1ac67cf640fc78d2 Mon Sep 17 00:00:00 2001 From: Bart de Water <bart.dewater@shopify.com> Date: Sat, 13 Oct 2018 20:19:20 -0400 Subject: [PATCH 569/677] Update Swipe HQ endpoints --- .../billing/gateways/swipe_checkout.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/active_merchant/billing/gateways/swipe_checkout.rb b/lib/active_merchant/billing/gateways/swipe_checkout.rb index 802a033188f..ea0bbc3b925 100644 --- a/lib/active_merchant/billing/gateways/swipe_checkout.rb +++ b/lib/active_merchant/billing/gateways/swipe_checkout.rb @@ -6,10 +6,7 @@ class SwipeCheckoutGateway < Gateway TRANSACTION_APPROVED_MSG = 'Transaction approved' TRANSACTION_DECLINED_MSG = 'Transaction declined' - LIVE_URLS = { - 'NZ' => 'https://api.swipehq.com', - 'CA' => 'https://api.swipehq.ca' - } + self.live_url = 'https://api.swipehq.com' self.test_url = 'https://api.swipehq.com' TRANSACTION_API = '/createShopifyTransaction.php' @@ -135,11 +132,11 @@ def call_api(api, params=nil) # ssl_post() returns the response body as a string on success, # or raises a ResponseError exception on failure - JSON.parse(ssl_post(url(@options[:region], api), params.to_query)) + JSON.parse(ssl_post(url(api), params.to_query)) end - def url(region, api) - ((test? ? self.test_url : LIVE_URLS[region]) + api) + def url(api) + (test? ? self.test_url : self.live_url) + api end def build_error_response(message, params={}) From eab1096504695b9e529feb082fb1eb244f873541 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 15 Oct 2018 16:20:06 -0400 Subject: [PATCH 570/677] RuboCop: fix Layout/DotPosition This is dramatically the smaller of the two possibilties. trailing: 10 files changed, 43 insertions(+), 43 deletions(-) leading: 127 files changed, 699 insertions(+), 699 deletions(-) --- .rubocop.yml | 4 +++- .rubocop_todo.yml | 7 ------- lib/active_merchant/billing/gateways/card_connect.rb | 12 ++++++------ lib/active_merchant/billing/gateways/cardprocess.rb | 8 ++++---- lib/active_merchant/billing/gateways/cashnet.rb | 8 ++++---- lib/active_merchant/billing/gateways/firstdata_e4.rb | 12 ++++++------ .../billing/gateways/firstdata_e4_v27.rb | 12 ++++++------ lib/active_merchant/billing/gateways/migs.rb | 10 +++++----- lib/active_merchant/billing/gateways/mundipagg.rb | 8 ++++---- lib/active_merchant/billing/gateways/paymentez.rb | 8 ++++---- lib/active_merchant/billing/gateways/world_net.rb | 6 +++--- 11 files changed, 45 insertions(+), 50 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e4141aba185..d101dfec1a3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -24,6 +24,8 @@ Metrics/ClassLength: Metrics/ModuleLength: Enabled: false - Layout/AlignParameters: EnforcedStyle: with_fixed_indentation + +Layout/DotPosition: + EnforcedStyle: trailing diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3e0bb88d4c3..cf878044205 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -26,13 +26,6 @@ Layout/CaseIndentation: Layout/ClosingHeredocIndentation: Enabled: false -# Offense count: 513 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: leading, trailing -Layout/DotPosition: - Enabled: false - # Offense count: 24 # Cop supports --auto-correct. Layout/ElseAlignment: diff --git a/lib/active_merchant/billing/gateways/card_connect.rb b/lib/active_merchant/billing/gateways/card_connect.rb index 6c4e8064c55..c4630cf0697 100644 --- a/lib/active_merchant/billing/gateways/card_connect.rb +++ b/lib/active_merchant/billing/gateways/card_connect.rb @@ -150,12 +150,12 @@ def supports_scrubbing? end def scrub(transcript) - transcript - .gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]') - .gsub(%r(("cvv2\\":\\")\d*), '\1[FILTERED]') - .gsub(%r(("merchid\\":\\")\d*), '\1[FILTERED]') - .gsub(%r((&?"account\\":\\")\d*), '\1[FILTERED]') - .gsub(%r((&?"token\\":\\")\d*), '\1[FILTERED]') + transcript. + gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). + gsub(%r(("cvv2\\":\\")\d*), '\1[FILTERED]'). + gsub(%r(("merchid\\":\\")\d*), '\1[FILTERED]'). + gsub(%r((&?"account\\":\\")\d*), '\1[FILTERED]'). + gsub(%r((&?"token\\":\\")\d*), '\1[FILTERED]') end private diff --git a/lib/active_merchant/billing/gateways/cardprocess.rb b/lib/active_merchant/billing/gateways/cardprocess.rb index 020a39ec17f..42824ccf952 100644 --- a/lib/active_merchant/billing/gateways/cardprocess.rb +++ b/lib/active_merchant/billing/gateways/cardprocess.rb @@ -99,10 +99,10 @@ def supports_scrubbing? end def scrub(transcript) - transcript - .gsub(%r{(authentication\.[^=]+=)[^&]+}, '\1[FILTERED]') - .gsub(%r{(card\.number=)\d+}, '\1[FILTERED]') - .gsub(%r{(cvv=)\d{3,4}}, '\1[FILTERED]\2') + transcript. + gsub(%r{(authentication\.[^=]+=)[^&]+}, '\1[FILTERED]'). + gsub(%r{(card\.number=)\d+}, '\1[FILTERED]'). + gsub(%r{(cvv=)\d{3,4}}, '\1[FILTERED]\2') end private diff --git a/lib/active_merchant/billing/gateways/cashnet.rb b/lib/active_merchant/billing/gateways/cashnet.rb index f3ae7dc87f5..9632d273383 100644 --- a/lib/active_merchant/billing/gateways/cashnet.rb +++ b/lib/active_merchant/billing/gateways/cashnet.rb @@ -60,10 +60,10 @@ def supports_scrubbing? end def scrub(transcript) - transcript - .gsub(%r{(password=)[^&]+}, '\1[FILTERED]') - .gsub(%r{(cardno=)[^&]+}, '\1[FILTERED]') - .gsub(%r{(cid=)[^&]+}, '\1[FILTERED]') + transcript. + gsub(%r{(password=)[^&]+}, '\1[FILTERED]'). + gsub(%r{(cardno=)[^&]+}, '\1[FILTERED]'). + gsub(%r{(cid=)[^&]+}, '\1[FILTERED]') end private diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index b18bbfb1294..803f0c0a591 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -141,12 +141,12 @@ def supports_scrubbing? end def scrub(transcript) - transcript - .gsub(%r((<Card_Number>).+(</Card_Number>)), '\1[FILTERED]\2') - .gsub(%r((<VerificationStr2>).+(</VerificationStr2>)), '\1[FILTERED]\2') - .gsub(%r((<Password>).+(</Password>))i, '\1[FILTERED]\2') - .gsub(%r((<CAVV>).+(</CAVV>)), '\1[FILTERED]\2') - .gsub(%r((Card Number : ).*\d)i, '\1[FILTERED]') + transcript. + gsub(%r((<Card_Number>).+(</Card_Number>)), '\1[FILTERED]\2'). + gsub(%r((<VerificationStr2>).+(</VerificationStr2>)), '\1[FILTERED]\2'). + gsub(%r((<Password>).+(</Password>))i, '\1[FILTERED]\2'). + gsub(%r((<CAVV>).+(</CAVV>)), '\1[FILTERED]\2'). + gsub(%r((Card Number : ).*\d)i, '\1[FILTERED]') end def supports_network_tokenization? diff --git a/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb index 7f5fde83f3e..31c16f7d1e5 100644 --- a/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb @@ -112,12 +112,12 @@ def supports_scrubbing? end def scrub(transcript) - transcript - .gsub(%r((<Card_Number>).+(</Card_Number>)), '\1[FILTERED]\2') - .gsub(%r((<CVDCode>).+(</CVDCode>)), '\1[FILTERED]\2') - .gsub(%r((<Password>).+(</Password>))i, '\1[FILTERED]\2') - .gsub(%r((<CAVV>).+(</CAVV>)), '\1[FILTERED]\2') - .gsub(%r((CARD NUMBER\s+: )#+\d+), '\1[FILTERED]') + transcript. + gsub(%r((<Card_Number>).+(</Card_Number>)), '\1[FILTERED]\2'). + gsub(%r((<CVDCode>).+(</CVDCode>)), '\1[FILTERED]\2'). + gsub(%r((<Password>).+(</Password>))i, '\1[FILTERED]\2'). + gsub(%r((<CAVV>).+(</CAVV>)), '\1[FILTERED]\2'). + gsub(%r((CARD NUMBER\s+: )#+\d+), '\1[FILTERED]') end def supports_network_tokenization? diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb index d0fa0d72411..27c13eee3b6 100644 --- a/lib/active_merchant/billing/gateways/migs.rb +++ b/lib/active_merchant/billing/gateways/migs.rb @@ -314,11 +314,11 @@ def add_secure_hash(post) end def calculate_secure_hash(post, secure_hash) - input = post - .reject { |k| %i[SecureHash SecureHashType].include?(k) } - .sort - .map { |(k, v)| "vpc_#{k}=#{v}" } - .join('&') + input = post. + reject { |k| %i[SecureHash SecureHashType].include?(k) }. + sort. + map { |(k, v)| "vpc_#{k}=#{v}" }. + join('&') OpenSSL::HMAC.hexdigest('SHA256', [secure_hash].pack('H*'), input).upcase end end diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb index fc8b10982e2..fa9c882c6d2 100644 --- a/lib/active_merchant/billing/gateways/mundipagg.rb +++ b/lib/active_merchant/billing/gateways/mundipagg.rb @@ -89,10 +89,10 @@ def supports_scrubbing? end def scrub(transcript) - transcript - .gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]') - .gsub(%r(("cvv\\":\\")\d*), '\1[FILTERED]') - .gsub(%r((card\\":{\\"number\\":\\")\d*), '\1[FILTERED]') + transcript. + gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). + gsub(%r(("cvv\\":\\")\d*), '\1[FILTERED]'). + gsub(%r((card\\":{\\"number\\":\\")\d*), '\1[FILTERED]') end private diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index db72d1da65e..af73e15b31c 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -119,10 +119,10 @@ def supports_scrubbing? end def scrub(transcript) - transcript - .gsub(%r{(\\?"number\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]') - .gsub(%r{(\\?"cvc\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]') - .gsub(%r{(Auth-Token: )([A-Za-z0-9=]+)}, '\1[FILTERED]') + transcript. + gsub(%r{(\\?"number\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]'). + gsub(%r{(\\?"cvc\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]'). + gsub(%r{(Auth-Token: )([A-Za-z0-9=]+)}, '\1[FILTERED]') end private diff --git a/lib/active_merchant/billing/gateways/world_net.rb b/lib/active_merchant/billing/gateways/world_net.rb index fc7eb38f9fc..70699b1a139 100644 --- a/lib/active_merchant/billing/gateways/world_net.rb +++ b/lib/active_merchant/billing/gateways/world_net.rb @@ -113,9 +113,9 @@ def supports_scrubbing? end def scrub(transcript) - transcript - .gsub(%r{(<CARDNUMBER>\d{6})\d+(\d{4}</CARDNUMBER>)}, '\1...\2') - .gsub(%r{(<CVV>)\d+(</CVV)}, '\1...\2') + transcript. + gsub(%r{(<CARDNUMBER>\d{6})\d+(\d{4}</CARDNUMBER>)}, '\1...\2'). + gsub(%r{(<CVV>)\d+(</CVV)}, '\1...\2') end private From d7a06ca136fde4385e945ff98a3ce916c30010ad Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 16 Oct 2018 13:56:15 -0400 Subject: [PATCH 571/677] RuboCop: fix Layout/LeadingBlankLines --- .rubocop_todo.yml | 7 ------- .../billing/gateways/quickpay/quickpay_common.rb | 1 - test/unit/gateways/quickpay_test.rb | 1 - 3 files changed, 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cf878044205..7d14df1557a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -110,13 +110,6 @@ Layout/IndentationConsistency: Layout/IndentationWidth: Enabled: false -# Offense count: 2 -# Cop supports --auto-correct. -Layout/LeadingBlankLines: - Exclude: - - 'lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb' - - 'test/unit/gateways/quickpay_test.rb' - # Offense count: 68 # Cop supports --auto-correct. Layout/LeadingCommentSpace: diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb index 43545c02294..904c03d8c26 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb @@ -1,4 +1,3 @@ - module QuickpayCommon MD5_CHECK_FIELDS = { 3 => { diff --git a/test/unit/gateways/quickpay_test.rb b/test/unit/gateways/quickpay_test.rb index 4eb99dcf7ed..3ce28fd9070 100644 --- a/test/unit/gateways/quickpay_test.rb +++ b/test/unit/gateways/quickpay_test.rb @@ -1,4 +1,3 @@ - require 'test_helper' class QuickpayTest < Test::Unit::TestCase From c31b131503caffb92795c8446a0922eba10a9118 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 18 Oct 2018 13:39:04 -0400 Subject: [PATCH 572/677] RuboCop: fix Layout/IndentArray --- .rubocop_todo.yml | 12 -------- .../billing/gateways/firstdata_e4.rb | 2 +- test/remote/gateways/remote_linkpoint_test.rb | 10 ++++--- test/unit/gateways/paypal_express_test.rb | 28 +++++++++---------- 4 files changed, 21 insertions(+), 31 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7d14df1557a..d9f84e9857a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -71,18 +71,6 @@ Layout/ExtraSpacing: Layout/FirstParameterIndentation: Enabled: false -# Offense count: 13 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/IndentArray: - Exclude: - - 'lib/active_merchant/billing/gateways/firstdata_e4.rb' - - 'test/remote/gateways/remote_linkpoint_test.rb' - - 'test/remote/gateways/remote_payflow_express_test.rb' - - 'test/unit/gateways/cyber_source_test.rb' - - 'test/unit/gateways/paypal_express_test.rb' - # Offense count: 253 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index 803f0c0a591..fa5781da07c 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -394,7 +394,7 @@ def store_authorization_from(response, credit_card) credit_card.last_name, credit_card.month, credit_card.year - ].map { |value| value.to_s.gsub(/;/, '') }.join(';') + ].map { |value| value.to_s.gsub(/;/, '') }.join(';') else raise StandardError, "TransArmor support is not enabled on your #{display_name} account" end diff --git a/test/remote/gateways/remote_linkpoint_test.rb b/test/remote/gateways/remote_linkpoint_test.rb index 3b2e78e9fb6..722b17d6ef7 100644 --- a/test/remote/gateways/remote_linkpoint_test.rb +++ b/test/remote/gateways/remote_linkpoint_test.rb @@ -90,10 +90,12 @@ def test_successfull_purchase_and_credit end def test_successfull_purchase_with_item_entity - @options.merge!({:line_items => [ - {:id => '123456', :description => 'Logo T-Shirt', :price => '12.00', :quantity => '1', :options => - [{:name => 'Color', :value => 'Red'}, {:name => 'Size', :value => 'XL'}]}, - {:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'}]}) + @options.merge!({:line_items => + [ + {:id => '123456', :description => 'Logo T-Shirt', :price => '12.00', :quantity => '1', + :options => [{:name => 'Color', :value => 'Red'}, {:name => 'Size', :value => 'XL'}]}, + {:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'} + ]}) assert purchase = @gateway.purchase(1500, @credit_card, @options) assert_success purchase end diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb index bed1c4be532..6bd01c9eb93 100644 --- a/test/unit/gateways/paypal_express_test.rb +++ b/test/unit/gateways/paypal_express_test.rb @@ -169,20 +169,20 @@ def test_items_are_included_if_specified_in_build_setup_request xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, { :currency => 'GBP', :items => [ - { - :name => 'item one', - :description => 'item one description', - :amount => 10000, - :number => 1, - :quantity => 3 - }, - { :name => 'item two', - :description => 'item two description', - :amount => 20000, - :number => 2, - :quantity => 4 - } - ] + { + :name => 'item one', + :description => 'item one description', + :amount => 10000, + :number => 1, + :quantity => 3 + }, + { :name => 'item two', + :description => 'item two description', + :amount => 20000, + :number => 2, + :quantity => 4 + } + ] })) assert_equal 'item one', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Name').text From c95a15ea7a91e4771937e5998ba4b711f7293200 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 18 Oct 2018 13:46:53 -0400 Subject: [PATCH 573/677] RuboCop: fix Layout/SpaceBeforeFirstArg --- .rubocop_todo.yml | 15 --------------- lib/active_merchant/billing/gateways/checkout.rb | 16 ++++++++-------- .../billing/gateways/cyber_source.rb | 2 +- lib/active_merchant/billing/gateways/s5.rb | 2 +- .../gateways/remote_braintree_orange_test.rb | 2 +- test/remote/gateways/remote_payflow_test.rb | 2 +- test/unit/gateways/bogus_test.rb | 10 +++++----- test/unit/gateways/instapay_test.rb | 4 ++-- test/unit/gateways/quickpay_v10_test.rb | 2 +- test/unit/gateways/quickpay_v4to7_test.rb | 2 +- 10 files changed, 21 insertions(+), 36 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d9f84e9857a..5bc923d347c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -210,21 +210,6 @@ Layout/SpaceBeforeComment: Exclude: - 'test/remote/gateways/remote_usa_epay_advanced_test.rb' -# Offense count: 16 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Layout/SpaceBeforeFirstArg: - Exclude: - - 'lib/active_merchant/billing/gateways/checkout.rb' - - 'lib/active_merchant/billing/gateways/cyber_source.rb' - - 'lib/active_merchant/billing/gateways/s5.rb' - - 'test/remote/gateways/remote_braintree_orange_test.rb' - - 'test/remote/gateways/remote_payflow_test.rb' - - 'test/unit/gateways/bogus_test.rb' - - 'test/unit/gateways/instapay_test.rb' - - 'test/unit/gateways/quickpay_v10_test.rb' - - 'test/unit/gateways/quickpay_v4to7_test.rb' - # Offense count: 118 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. diff --git a/lib/active_merchant/billing/gateways/checkout.rb b/lib/active_merchant/billing/gateways/checkout.rb index 51cf3919292..cd6692a37d8 100644 --- a/lib/active_merchant/billing/gateways/checkout.rb +++ b/lib/active_merchant/billing/gateways/checkout.rb @@ -125,13 +125,13 @@ def add_billing_info(xml, options) def add_shipping_info(xml, options) if options[:shipping_address] - xml.ship_address_ options[:shipping_address][:address1] - xml.ship_address2_ options[:shipping_address][:address2] - xml.ship_city_ options[:shipping_address][:city] - xml.ship_state_ options[:shipping_address][:state] - xml.ship_postal_ options[:shipping_address][:zip] - xml.ship_country_ options[:shipping_address][:country] - xml.ship_phone_ options[:shipping_address][:phone] + xml.ship_address_ options[:shipping_address][:address1] + xml.ship_address2_ options[:shipping_address][:address2] + xml.ship_city_ options[:shipping_address][:city] + xml.ship_state_ options[:shipping_address][:state] + xml.ship_postal_ options[:shipping_address][:zip] + xml.ship_country_ options[:shipping_address][:country] + xml.ship_phone_ options[:shipping_address][:phone] end end @@ -144,7 +144,7 @@ def add_user_defined_fields(xml, options) end def add_other_fields(xml, options) - xml.bill_email_ options[:email] + xml.bill_email_ options[:email] xml.bill_customerip_ options[:ip] xml.merchantcustomerid_ options[:customer] xml.descriptor_name options[:descriptor_name] diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 190094e838a..77c4dc03630 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -663,7 +663,7 @@ def add_payment_method_or_subscription(xml, money, payment_method_or_reference, end def add_validate_pinless_debit_service(xml) - xml.tag!'pinlessDebitValidateService', {'run' => 'true'} + xml.tag! 'pinlessDebitValidateService', {'run' => 'true'} end def add_threeds_services(xml, options) diff --git a/lib/active_merchant/billing/gateways/s5.rb b/lib/active_merchant/billing/gateways/s5.rb index 2be4007ba63..9f36a91e54e 100644 --- a/lib/active_merchant/billing/gateways/s5.rb +++ b/lib/active_merchant/billing/gateways/s5.rb @@ -136,7 +136,7 @@ def add_account(xml, payment_method) xml.Holder "#{payment_method.first_name} #{payment_method.last_name}" xml.Brand payment_method.brand xml.Expiry(year: payment_method.year, month: payment_method.month) - xml.Verification payment_method.verification_value + xml.Verification payment_method.verification_value end end end diff --git a/test/remote/gateways/remote_braintree_orange_test.rb b/test/remote/gateways/remote_braintree_orange_test.rb index 6f6fb6bd842..4f2b3f171f3 100644 --- a/test/remote/gateways/remote_braintree_orange_test.rb +++ b/test/remote/gateways/remote_braintree_orange_test.rb @@ -139,7 +139,7 @@ def test_authorize_and_void def test_failed_capture assert response = @gateway.capture(@amount, '') assert_failure response - assert response.message.match(/Invalid Transaction ID \/ Object ID specified:/) + assert response.message.match(/Invalid Transaction ID \/ Object ID specified:/) end def test_authorize_with_three_d_secure_pass_thru diff --git a/test/remote/gateways/remote_payflow_test.rb b/test/remote/gateways/remote_payflow_test.rb index 1ec03b627a2..6104f8e45bd 100644 --- a/test/remote/gateways/remote_payflow_test.rb +++ b/test/remote/gateways/remote_payflow_test.rb @@ -213,7 +213,7 @@ def test_duplicate_request_id SecureRandom.expects(:hex).times(2).returns(request_id) response1 = @gateway.purchase(100, @credit_card, @options) - assert response1.success? + assert response1.success? assert_nil response1.params['duplicate'] response2 = @gateway.purchase(100, @credit_card, @options) diff --git a/test/unit/gateways/bogus_test.rb b/test/unit/gateways/bogus_test.rb index ddd8a1dcd31..e6978d828e1 100644 --- a/test/unit/gateways/bogus_test.rb +++ b/test/unit/gateways/bogus_test.rb @@ -18,7 +18,7 @@ def setup end def test_authorize - assert @gateway.authorize(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success? + assert @gateway.authorize(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success? response = @gateway.authorize(1000, credit_card(CC_FAILURE_PLACEHOLDER)) refute response.success? assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code @@ -34,7 +34,7 @@ def test_authorize_using_credit_card_token end def test_purchase - assert @gateway.purchase(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success? + assert @gateway.purchase(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success? response = @gateway.purchase(1000, credit_card(CC_FAILURE_PLACEHOLDER)) refute response.success? assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code @@ -56,7 +56,7 @@ def test_capture end def test_credit - assert @gateway.credit(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success? + assert @gateway.credit(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success? response = @gateway.credit(1000, credit_card(CC_FAILURE_PLACEHOLDER)) refute response.success? assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code @@ -97,7 +97,7 @@ def test_void end def test_store - assert @gateway.store(credit_card(CC_SUCCESS_PLACEHOLDER)).success? + assert @gateway.store(credit_card(CC_SUCCESS_PLACEHOLDER)).success? response = @gateway.store(credit_card(CC_FAILURE_PLACEHOLDER)) refute response.success? assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code @@ -184,7 +184,7 @@ def test_authorize_emv end def test_purchase_emv - assert @gateway.purchase(1000, credit_card('123', {icc_data: 'DEADBEEF'})).success? + assert @gateway.purchase(1000, credit_card('123', {icc_data: 'DEADBEEF'})).success? response = @gateway.purchase(1005, credit_card('123', {icc_data: 'DEADBEEF'})) refute response.success? assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code diff --git a/test/unit/gateways/instapay_test.rb b/test/unit/gateways/instapay_test.rb index 2f8af425809..acd35d3027b 100644 --- a/test/unit/gateways/instapay_test.rb +++ b/test/unit/gateways/instapay_test.rb @@ -11,7 +11,7 @@ def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card) - assert_instance_of Response, response + assert_instance_of Response, response assert_success response assert_equal '118583850', response.authorization end @@ -29,7 +29,7 @@ def test_successful_auth @gateway.expects(:ssl_post).returns(successful_purchase_response) assert response = @gateway.authorize(@amount, @credit_card) - assert_instance_of Response, response + assert_instance_of Response, response assert_success response assert_equal '118583850', response.authorization end diff --git a/test/unit/gateways/quickpay_v10_test.rb b/test/unit/gateways/quickpay_v10_test.rb index f2db1f727ec..8a5404a3207 100644 --- a/test/unit/gateways/quickpay_v10_test.rb +++ b/test/unit/gateways/quickpay_v10_test.rb @@ -129,7 +129,7 @@ def test_supported_countries def test_supported_card_types klass = @gateway.class - assert_equal [:dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro ], klass.supported_cardtypes + assert_equal [:dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro ], klass.supported_cardtypes end def test_successful_capture diff --git a/test/unit/gateways/quickpay_v4to7_test.rb b/test/unit/gateways/quickpay_v4to7_test.rb index e666efbadb3..a01c4b5315c 100644 --- a/test/unit/gateways/quickpay_v4to7_test.rb +++ b/test/unit/gateways/quickpay_v4to7_test.rb @@ -129,7 +129,7 @@ def test_supported_countries def test_supported_card_types klass = @gateway.class - assert_equal [ :dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro ], klass.supported_cardtypes + assert_equal [ :dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro ], klass.supported_cardtypes end def test_add_testmode_does_not_add_testmode_if_transaction_id_present From b373b445c890696c291256e9c1e2635ecd02076f Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 18 Oct 2018 13:52:15 -0400 Subject: [PATCH 574/677] RuboCop: fix Layout/SpaceBeforeComma Some of this was undoing attempted alignment in net_registry.rb, but the keyword there is "attempted"; it didn't line up before this patch, and fixing it would've had higher churn. Everything else seemed like straight-up typos. --- .rubocop_todo.yml | 18 ----------- .../billing/gateways/cyber_source.rb | 6 ++-- .../billing/gateways/instapay.rb | 2 +- .../billing/gateways/net_registry.rb | 2 +- .../billing/gateways/optimal_payment.rb | 32 +++++++++---------- .../billing/gateways/psigate.rb | 2 +- .../billing/gateways/sage_pay.rb | 10 +++--- test/remote/gateways/remote_eway_test.rb | 2 +- .../gateways/remote_payflow_express_test.rb | 12 +++---- .../gateways/remote_paypal_express_test.rb | 2 +- test/unit/gateways/checkout_test.rb | 2 +- test/unit/gateways/paypal_express_test.rb | 4 +-- 12 files changed, 38 insertions(+), 56 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5bc923d347c..dbfe421e0ce 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -186,24 +186,6 @@ Layout/SpaceAroundOperators: Layout/SpaceBeforeBlockBraces: Enabled: false -# Offense count: 39 -# Cop supports --auto-correct. -Layout/SpaceBeforeComma: - Exclude: - - 'lib/active_merchant/billing/gateways/cyber_source.rb' - - 'lib/active_merchant/billing/gateways/ideal/ideal_base.rb' - - 'lib/active_merchant/billing/gateways/instapay.rb' - - 'lib/active_merchant/billing/gateways/net_registry.rb' - - 'lib/active_merchant/billing/gateways/optimal_payment.rb' - - 'lib/active_merchant/billing/gateways/psigate.rb' - - 'lib/active_merchant/billing/gateways/sage_pay.rb' - - 'test/remote/gateways/remote_eway_test.rb' - - 'test/remote/gateways/remote_payflow_express_test.rb' - - 'test/remote/gateways/remote_paypal_express_test.rb' - - 'test/remote/gateways/remote_paypal_test.rb' - - 'test/unit/gateways/checkout_test.rb' - - 'test/unit/gateways/paypal_express_test.rb' - # Offense count: 1 # Cop supports --auto-correct. Layout/SpaceBeforeComment: diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 77c4dc03630..0bc2693ff1e 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -48,7 +48,7 @@ class CyberSourceGateway < Gateway @@response_codes = { :r100 => 'Successful transaction', - :r101 => 'Request is missing one or more required fields' , + :r101 => 'Request is missing one or more required fields', :r102 => 'One or more fields contains invalid data', :r150 => 'General failure', :r151 => 'The request was received but a server time-out occurred', @@ -432,9 +432,9 @@ def add_line_item_data(xml, options) def add_merchant_data(xml, options) xml.tag! 'merchantID', @options[:login] xml.tag! 'merchantReferenceCode', options[:order_id] || generate_unique_id - xml.tag! 'clientLibrary' ,'Ruby Active Merchant' + xml.tag! 'clientLibrary','Ruby Active Merchant' xml.tag! 'clientLibraryVersion', VERSION - xml.tag! 'clientEnvironment' , RUBY_PLATFORM + xml.tag! 'clientEnvironment', RUBY_PLATFORM end def add_purchase_data(xml, money = 0, include_grand_total = false, options={}) diff --git a/lib/active_merchant/billing/gateways/instapay.rb b/lib/active_merchant/billing/gateways/instapay.rb index 13a41a76593..d2ef3f9d13b 100644 --- a/lib/active_merchant/billing/gateways/instapay.rb +++ b/lib/active_merchant/billing/gateways/instapay.rb @@ -140,7 +140,7 @@ def commit(action, parameters) data = ssl_post self.live_url, post_data(action, parameters) response = parse(data) - Response.new(response[:success] , response[:message], response, + Response.new(response[:success], response[:message], response, :authorization => response[:transaction_id], :avs_result => { :code => response[:avs_result] }, :cvv_result => response[:cvv_result] diff --git a/lib/active_merchant/billing/gateways/net_registry.rb b/lib/active_merchant/billing/gateways/net_registry.rb index a1e4ee183ef..62a2e8c9ba9 100644 --- a/lib/active_merchant/billing/gateways/net_registry.rb +++ b/lib/active_merchant/billing/gateways/net_registry.rb @@ -131,7 +131,7 @@ def add_request_details(params, options) # format for a command. def expiry(credit_card) month = format(credit_card.month, :two_digits) - year = format(credit_card.year , :two_digits) + year = format(credit_card.year, :two_digits) "#{month}/#{year}" end diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb index 2684c76e84f..6a2716c2813 100644 --- a/lib/active_merchant/billing/gateways/optimal_payment.rb +++ b/lib/active_merchant/billing/gateways/optimal_payment.rb @@ -255,27 +255,27 @@ def schema def build_merchant_account(xml) xml.tag! 'merchantAccount' do - xml.tag! 'accountNum' , @options[:account_number] - xml.tag! 'storeID' , @options[:store_id] - xml.tag! 'storePwd' , @options[:password] + xml.tag! 'accountNum', @options[:account_number] + xml.tag! 'storeID', @options[:store_id] + xml.tag! 'storePwd', @options[:password] end end def build_card(xml, opts) xml.tag! 'card' do - xml.tag! 'cardNum' , @credit_card.number + xml.tag! 'cardNum', @credit_card.number xml.tag! 'cardExpiry' do - xml.tag! 'month' , @credit_card.month - xml.tag! 'year' , @credit_card.year + xml.tag! 'month', @credit_card.month + xml.tag! 'year', @credit_card.year end if brand = card_type(@credit_card.brand) - xml.tag! 'cardType' , brand + xml.tag! 'cardType', brand end if @credit_card.verification_value? - xml.tag! 'cvdIndicator' , '1' # Value Provided - xml.tag! 'cvd' , @credit_card.verification_value + xml.tag! 'cvdIndicator', '1' # Value Provided + xml.tag! 'cvd', @credit_card.verification_value else - xml.tag! 'cvdIndicator' , '0' + xml.tag! 'cvdIndicator', '0' end end end @@ -299,18 +299,18 @@ def build_address(xml, addr) if addr[:name] first_name, last_name = split_names(addr[:name]) xml.tag! 'firstName', first_name - xml.tag! 'lastName' , last_name + xml.tag! 'lastName', last_name end - xml.tag! 'street' , addr[:address1] if addr[:address1].present? + xml.tag! 'street', addr[:address1] if addr[:address1].present? xml.tag! 'street2', addr[:address2] if addr[:address2].present? - xml.tag! 'city' , addr[:city] if addr[:city].present? + xml.tag! 'city', addr[:city] if addr[:city].present? if addr[:state].present? state_tag = %w(US CA).include?(addr[:country]) ? 'state' : 'region' xml.tag! state_tag, addr[:state] end - xml.tag! 'country', addr[:country] if addr[:country].present? - xml.tag! 'zip' , addr[:zip] if addr[:zip].present? - xml.tag! 'phone' , addr[:phone] if addr[:phone].present? + xml.tag! 'country', addr[:country] if addr[:country].present? + xml.tag! 'zip', addr[:zip] if addr[:zip].present? + xml.tag! 'phone', addr[:phone] if addr[:phone].present? end def card_type(key) diff --git a/lib/active_merchant/billing/gateways/psigate.rb b/lib/active_merchant/billing/gateways/psigate.rb index e83b86c2c86..f8dfbc67a5c 100644 --- a/lib/active_merchant/billing/gateways/psigate.rb +++ b/lib/active_merchant/billing/gateways/psigate.rb @@ -104,7 +104,7 @@ def commit(money, creditcard, options = {}) Response.new(successful?(response), message_from(response), response, :test => test?, - :authorization => build_authorization(response) , + :authorization => build_authorization(response), :avs_result => { :code => response[:avsresult] }, :cvv_result => response[:cardidresult] ) diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index 4eee27bb932..81506b77007 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -52,8 +52,8 @@ class SagePayGateway < Gateway OPTIONAL_REQUEST_FIELDS = { paypal_callback_url: :PayPalCallbackURL, basket: :Basket, - gift_aid_payment: :GiftAidPayment , - apply_avscv2: :ApplyAVSCV2 , + gift_aid_payment: :GiftAidPayment, + apply_avscv2: :ApplyAVSCV2, apply_3d_secure: :Apply3DSecure, account_type: :AccountType, billing_agreement: :BillingAgreement, @@ -63,9 +63,9 @@ class SagePayGateway < Gateway vendor_data: :VendorData, language: :Language, website: :Website, - recipient_account_number: :FIRecipientAcctNumber , - recipient_surname: :FIRecipientSurname , - recipient_postcode: :FIRecipientPostcode , + recipient_account_number: :FIRecipientAcctNumber, + recipient_surname: :FIRecipientSurname, + recipient_postcode: :FIRecipientPostcode, recipient_dob: :FIRecipientDoB } diff --git a/test/remote/gateways/remote_eway_test.rb b/test/remote/gateways/remote_eway_test.rb index 693a51282e5..a8d7d583874 100644 --- a/test/remote/gateways/remote_eway_test.rb +++ b/test/remote/gateways/remote_eway_test.rb @@ -17,7 +17,7 @@ def setup :state => 'WA', :country => 'AU', :zip => '2000' - } , + }, :description => 'purchased items' } end diff --git a/test/remote/gateways/remote_payflow_express_test.rb b/test/remote/gateways/remote_payflow_express_test.rb index b25c566df9a..5c8978d6802 100644 --- a/test/remote/gateways/remote_payflow_express_test.rb +++ b/test/remote/gateways/remote_payflow_express_test.rb @@ -65,8 +65,8 @@ def test_setup_authorization_discount_taxes_included_free_shipping { :name => 'test4', :description => 'test4', - :quantity=>2 , - :amount=> 1399 , + :quantity=>2, + :amount=> 1399, :url=>'http://localhost:3000/products/test4' } ], @@ -92,8 +92,8 @@ def test_setup_authorization_with_discount_taxes_additional { :name => 'test4', :description => 'test4', - :quantity=>2 , - :amount=> 1399 , + :quantity=>2, + :amount=> 1399, :url=>'http://localhost:3000/products/test4' } ], @@ -119,8 +119,8 @@ def test_setup_authorization_with_discount_taxes_and_shipping_addtiional { :name => 'test4', :description => 'test4', - :quantity=>2 , - :amount=> 1399 , + :quantity=>2, + :amount=> 1399, :url=>'http://localhost:3000/products/test4' } ], diff --git a/test/remote/gateways/remote_paypal_express_test.rb b/test/remote/gateways/remote_paypal_express_test.rb index e5a4ff50364..c599649a814 100644 --- a/test/remote/gateways/remote_paypal_express_test.rb +++ b/test/remote/gateways/remote_paypal_express_test.rb @@ -17,7 +17,7 @@ def setup :state => 'NC', :country => 'US', :zip => '23456' - } , + }, :description => 'Stuff that you purchased, yo!', :ip => '10.0.0.1', :return_url => 'http://example.com/return', diff --git a/test/unit/gateways/checkout_test.rb b/test/unit/gateways/checkout_test.rb index bc12cd16476..ab70056694e 100644 --- a/test/unit/gateways/checkout_test.rb +++ b/test/unit/gateways/checkout_test.rb @@ -55,7 +55,7 @@ def test_unsuccessful_authorize def test_unsuccessful_capture @gateway.expects(:ssl_post).returns(failed_capture_response) - assert response = @gateway.capture(100, '||||' , @options) + assert response = @gateway.capture(100, '||||', @options) assert_failure response assert_equal 'EGP00173', response.params['error_code_tag'] assert response.test? diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb index 6bd01c9eb93..67145530893 100644 --- a/test/unit/gateways/paypal_express_test.rb +++ b/test/unit/gateways/paypal_express_test.rb @@ -622,7 +622,7 @@ def test_ensure_only_unique_error_codes :cancel_return_url => 'http://example.com' ) - assert_equal '10736' , response.params['error_codes'] + assert_equal '10736', response.params['error_codes'] end def test_error_codes_for_multiple_errors @@ -632,7 +632,7 @@ def test_error_codes_for_multiple_errors :cancel_return_url => 'http://example.com' ) - assert_equal ['10736', '10002'] , response.params['error_codes'].split(',') + assert_equal ['10736', '10002'], response.params['error_codes'].split(',') end def test_allow_guest_checkout From c61df87dfee957ddb9f76c28fd523c21e4ac45e7 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 18 Oct 2018 14:14:42 -0400 Subject: [PATCH 575/677] RuboCop: fix Layout/SpaceBeforeComment --- .rubocop_todo.yml | 6 ------ test/remote/gateways/remote_usa_epay_advanced_test.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index dbfe421e0ce..6c559d1caca 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -186,12 +186,6 @@ Layout/SpaceAroundOperators: Layout/SpaceBeforeBlockBraces: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -Layout/SpaceBeforeComment: - Exclude: - - 'test/remote/gateways/remote_usa_epay_advanced_test.rb' - # Offense count: 118 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. diff --git a/test/remote/gateways/remote_usa_epay_advanced_test.rb b/test/remote/gateways/remote_usa_epay_advanced_test.rb index 2f7bc1fc264..01ec1523690 100644 --- a/test/remote/gateways/remote_usa_epay_advanced_test.rb +++ b/test/remote/gateways/remote_usa_epay_advanced_test.rb @@ -271,7 +271,7 @@ def test_run_customer_transaction response = @gateway.add_customer(@options.merge(@customer_options)) customer_number = response.params['add_customer_return'] - response = @gateway.run_customer_transaction(:customer_number => customer_number,# :method_id => 0, # optional + response = @gateway.run_customer_transaction(:customer_number => customer_number, # :method_id => 0, # optional :command => 'Sale', :amount => 3000) assert response.params['run_customer_transaction_return'] end From 2073abda0b6b4552dab58f0b235e5d09e3ad60f2 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 18 Oct 2018 14:17:08 -0400 Subject: [PATCH 576/677] RuboCop: fix Layout/SpaceAroundBlockParameters --- .rubocop_todo.yml | 9 --------- lib/active_merchant/billing/gateways/payscout.rb | 2 +- test/unit/country_test.rb | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6c559d1caca..bd3b97b53c2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -151,15 +151,6 @@ Layout/MultilineOperationIndentation: Layout/SpaceAfterComma: Enabled: false -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleInsidePipes. -# SupportedStylesInsidePipes: space, no_space -Layout/SpaceAroundBlockParameters: - Exclude: - - 'lib/active_merchant/billing/gateways/payscout.rb' - - 'test/unit/country_test.rb' - # Offense count: 638 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/active_merchant/billing/gateways/payscout.rb b/lib/active_merchant/billing/gateways/payscout.rb index 108d8725aa7..7596dddccbc 100644 --- a/lib/active_merchant/billing/gateways/payscout.rb +++ b/lib/active_merchant/billing/gateways/payscout.rb @@ -102,7 +102,7 @@ def add_creditcard(post, creditcard) end def parse(body) - Hash[body.split('&').map{|x|x.split('=')}] + Hash[body.split('&').map{|x| x.split('=')}] end def commit(action, money, parameters) diff --git a/test/unit/country_test.rb b/test/unit/country_test.rb index 3fce8ff16c5..d9dcae71b07 100644 --- a/test/unit/country_test.rb +++ b/test/unit/country_test.rb @@ -74,7 +74,7 @@ def test_raise_on_nil_name end def test_country_names_are_alphabetized - country_names = ActiveMerchant::Country::COUNTRIES.map { | each | each[:name] } + country_names = ActiveMerchant::Country::COUNTRIES.map { |each| each[:name] } assert_equal(country_names.sort, country_names) end From 3f6c3ab49543bde093cae0eed8c223c53b0d1978 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 18 Oct 2018 14:24:20 -0400 Subject: [PATCH 577/677] Remove a pile of bad/invalid/confusing comments --- lib/active_merchant/billing/gateways/authorize_net_cim.rb | 1 - lib/active_merchant/billing/gateways/netpay.rb | 1 - lib/active_merchant/billing/gateways/opp.rb | 1 - lib/active_merchant/billing/gateways/secure_pay_au.rb | 1 - test/remote/gateways/remote_payment_express_test.rb | 2 +- test/unit/gateways/blue_pay_test.rb | 1 - 6 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb index bfde6385998..ca774b3f1c3 100644 --- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb +++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb @@ -671,7 +671,6 @@ def add_transaction(xml, transaction) tag_unless_blank(xml,'customerShippingAddressId', transaction[:customer_shipping_address_id]) xml.tag!('transId', transaction[:trans_id]) when :refund - #TODO - add lineItems field xml.tag!('amount', transaction[:amount]) tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id]) tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id]) diff --git a/lib/active_merchant/billing/gateways/netpay.rb b/lib/active_merchant/billing/gateways/netpay.rb index 5068fa894c6..7b660cefe98 100644 --- a/lib/active_merchant/billing/gateways/netpay.rb +++ b/lib/active_merchant/billing/gateways/netpay.rb @@ -110,7 +110,6 @@ def refund(money, authorization, options = {}) add_order_id(post, order_id_from(authorization)) add_amount(post, money, options) - #commit('Refund', post, options) commit('Credit', post, options) end diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb index 11f8c4c8efa..19d3a11477f 100644 --- a/lib/active_merchant/billing/gateways/opp.rb +++ b/lib/active_merchant/billing/gateways/opp.rb @@ -244,7 +244,6 @@ def add_invoice(post, money, options) def add_payment_method(post, payment, options) if options[:registrationId] - #post[:recurringType] = 'REPEATED' post[:card] = { cvv: payment.verification_value, } diff --git a/lib/active_merchant/billing/gateways/secure_pay_au.rb b/lib/active_merchant/billing/gateways/secure_pay_au.rb index f4e569253a3..3a6aa76775f 100644 --- a/lib/active_merchant/billing/gateways/secure_pay_au.rb +++ b/lib/active_merchant/billing/gateways/secure_pay_au.rb @@ -238,7 +238,6 @@ def build_periodic_request(body) def commit_periodic(request) my_request = build_periodic_request(request) - #puts my_request response = parse(ssl_post(test? ? self.test_periodic_url : self.live_periodic_url, my_request)) Response.new(success?(response), message_from(response), response, diff --git a/test/remote/gateways/remote_payment_express_test.rb b/test/remote/gateways/remote_payment_express_test.rb index 8fb5bfc22b7..cca036a49cb 100644 --- a/test/remote/gateways/remote_payment_express_test.rb +++ b/test/remote/gateways/remote_payment_express_test.rb @@ -88,7 +88,7 @@ def test_store_credit_card end def test_store_with_custom_token - token = Time.now.to_i.to_s #hehe + token = Time.now.to_i.to_s assert response = @gateway.store(@credit_card, :billing_id => token) assert_success response assert_equal 'The Transaction was approved', response.message diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb index 089efee347b..b7947bfc02f 100644 --- a/test/unit/gateways/blue_pay_test.rb +++ b/test/unit/gateways/blue_pay_test.rb @@ -23,7 +23,6 @@ def setup end def test_successful_authorization - #@gateway.expects(:ssl_post).returns(successful_authorization_response) @gateway.expects(:ssl_post).returns(RSP[:approved_auth]) assert response = @gateway.authorize(@amount, @credit_card) assert_instance_of Response, response From 3894b87621a29a9d9ecc76bb6254d2d728673ef9 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 18 Oct 2018 14:24:29 -0400 Subject: [PATCH 578/677] RuboCop: fix Layout/LeadingCommentSpace --- .rubocop_todo.yml | 5 ----- .../billing/gateways/beanstream.rb | 4 ++-- .../billing/gateways/card_save.rb | 4 ++-- lib/active_merchant/billing/gateways/cecabank.rb | 2 +- .../billing/gateways/eway_managed.rb | 2 +- .../billing/gateways/linkpoint.rb | 2 +- lib/active_merchant/billing/gateways/mercury.rb | 2 +- .../billing/gateways/nab_transact.rb | 16 ++++++++-------- lib/active_merchant/billing/gateways/omise.rb | 2 +- .../billing/gateways/optimal_payment.rb | 6 +++--- .../billing/gateways/payment_express.rb | 2 +- lib/active_merchant/billing/gateways/psl_card.rb | 12 ++++++------ .../billing/gateways/securion_pay.rb | 6 +++--- .../gateways/remote_authorize_net_cim_test.rb | 4 ++-- .../remote_ct_payment_certification_test.rb | 4 ++-- test/remote/gateways/remote_data_cash_test.rb | 14 +++++++------- test/remote/gateways/remote_nab_transact_test.rb | 8 ++++---- test/remote/gateways/remote_paypal_test.rb | 4 ++-- .../remote/gateways/remote_secure_pay_au_test.rb | 8 ++++---- test/remote/gateways/remote_wirecard_test.rb | 2 +- test/unit/gateways/authorize_net_cim_test.rb | 2 +- test/unit/gateways/banwire_test.rb | 4 ++-- test/unit/gateways/garanti_test.rb | 2 +- test/unit/gateways/iats_payments_test.rb | 2 +- test/unit/gateways/paypal_express_test.rb | 2 +- test/unit/gateways/usa_epay_advanced_test.rb | 10 +++++----- 26 files changed, 63 insertions(+), 68 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bd3b97b53c2..b6411de3752 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -98,11 +98,6 @@ Layout/IndentationConsistency: Layout/IndentationWidth: Enabled: false -# Offense count: 68 -# Cop supports --auto-correct. -Layout/LeadingCommentSpace: - Enabled: false - # Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/active_merchant/billing/gateways/beanstream.rb b/lib/active_merchant/billing/gateways/beanstream.rb index d42209db38d..0c1b42ed7b4 100644 --- a/lib/active_merchant/billing/gateways/beanstream.rb +++ b/lib/active_merchant/billing/gateways/beanstream.rb @@ -167,8 +167,8 @@ def store(payment_method, options = {}) commit(post, true) end - #can't actually delete a secure profile with the supplicated API. This function sets the status of the profile to closed (C). - #Closed profiles will have to removed manually. + # can't actually delete a secure profile with the supplicated API. This function sets the status of the profile to closed (C). + # Closed profiles will have to removed manually. def delete(vault_id) update(vault_id, false, {:status => 'C'}) end diff --git a/lib/active_merchant/billing/gateways/card_save.rb b/lib/active_merchant/billing/gateways/card_save.rb index 633ad3ea7cc..48c7decf336 100644 --- a/lib/active_merchant/billing/gateways/card_save.rb +++ b/lib/active_merchant/billing/gateways/card_save.rb @@ -1,8 +1,8 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class CardSaveGateway < IridiumGateway - #CardSave lets you handle failovers on payments by providing 3 gateways in case one happens to be down - #URLS = ['https://gw1.cardsaveonlinepayments.com:4430/','https://gw2.cardsaveonlinepayments.com:4430/','https://gw3.cardsaveonlinepayments.com:4430/'] + # CardSave lets you handle failovers on payments by providing 3 gateways in case one happens to be down + # URLS = ['https://gw1.cardsaveonlinepayments.com:4430/','https://gw2.cardsaveonlinepayments.com:4430/','https://gw3.cardsaveonlinepayments.com:4430/'] self.money_format = :cents self.default_currency = 'GBP' diff --git a/lib/active_merchant/billing/gateways/cecabank.rb b/lib/active_merchant/billing/gateways/cecabank.rb index ea93d83e973..0b7cf8bc86d 100644 --- a/lib/active_merchant/billing/gateways/cecabank.rb +++ b/lib/active_merchant/billing/gateways/cecabank.rb @@ -19,7 +19,7 @@ class CecabankGateway < Gateway CECA_UI_LESS_LANGUAGE = 'XML' CECA_UI_LESS_LANGUAGE_REFUND = '1' CECA_UI_LESS_REFUND_PAGE = 'anulacion_xml' - CECA_ACTION_REFUND = 'tpvanularparcialmente' #use partial refund's URL to avoid time frame limitations and decision logic on client side + CECA_ACTION_REFUND = 'tpvanularparcialmente' # use partial refund's URL to avoid time frame limitations and decision logic on client side CECA_ACTION_PURCHASE = 'tpv' CECA_CURRENCIES_DICTIONARY = {'EUR' => 978, 'USD' => 840, 'GBP' => 826} diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb index bd5281511c3..85616ed0b74 100644 --- a/lib/active_merchant/billing/gateways/eway_managed.rb +++ b/lib/active_merchant/billing/gateways/eway_managed.rb @@ -12,7 +12,7 @@ class EwayManagedGateway < Gateway self.default_currency = 'AUD' - #accepted money format + # accepted money format self.money_format = :cents # The homepage URL of the gateway diff --git a/lib/active_merchant/billing/gateways/linkpoint.rb b/lib/active_merchant/billing/gateways/linkpoint.rb index cf4d3cf28de..79ac53d3298 100644 --- a/lib/active_merchant/billing/gateways/linkpoint.rb +++ b/lib/active_merchant/billing/gateways/linkpoint.rb @@ -340,7 +340,7 @@ def parameters(money, creditcard, options = {}) :terminaltype => options[:terminaltype], :ip => options[:ip], :reference_number => options[:reference_number], - :recurring => options[:recurring] || 'NO', #DO NOT USE if you are using the periodic billing option. + :recurring => options[:recurring] || 'NO', # DO NOT USE if you are using the periodic billing option. :tdate => options[:tdate] }, :orderoptions => { diff --git a/lib/active_merchant/billing/gateways/mercury.rb b/lib/active_merchant/billing/gateways/mercury.rb index 1a8fbe6be57..9580630d773 100644 --- a/lib/active_merchant/billing/gateways/mercury.rb +++ b/lib/active_merchant/billing/gateways/mercury.rb @@ -212,7 +212,7 @@ def add_credit_card(xml, credit_card, action) # Track 1 and 2 have identical end sentinels (ETX) of '?' # Tracks may or may not have checksum (LRC) after the ETX # If the track has no STX or is corrupt, we send it as track 1, to let Mercury - #handle with the validation error as it sees fit. + # handle with the validation error as it sees fit. # Track 2 requires having the STX and ETX stripped. Track 1 does not. # Max-length track 1s require having the STX and ETX stripped. Max is 79 bytes including LRC. is_track_2 = credit_card.track_data[0] == ';' diff --git a/lib/active_merchant/billing/gateways/nab_transact.rb b/lib/active_merchant/billing/gateways/nab_transact.rb index 389653cf523..d09cf7ffc9d 100644 --- a/lib/active_merchant/billing/gateways/nab_transact.rb +++ b/lib/active_merchant/billing/gateways/nab_transact.rb @@ -23,14 +23,14 @@ class NabTransactGateway < Gateway self.money_format = :cents self.default_currency = 'AUD' - #Transactions currently accepted by NAB Transact XML API + # Transactions currently accepted by NAB Transact XML API TRANSACTIONS = { - :purchase => 0, #Standard Payment - :refund => 4, #Refund - :void => 6, #Client Reversal (Void) - :unmatched_refund => 666, #Unmatched Refund - :authorization => 10, #Preauthorise - :capture => 11 #Preauthorise Complete (Advice) + :purchase => 0, # Standard Payment + :refund => 4, # Refund + :void => 6, # Client Reversal (Void) + :unmatched_refund => 666, # Unmatched Refund + :authorization => 10, # Preauthorise + :capture => 11 # Preauthorise Complete (Advice) } PERIODIC_TYPES = { @@ -134,7 +134,7 @@ def build_reference_request(money, reference, options) xml.target! end - #Generate payment request XML + # Generate payment request XML # - API is set to allow multiple Txn's but currently only allows one # - txnSource = 23 - (XML) def build_request(action, body) diff --git a/lib/active_merchant/billing/gateways/omise.rb b/lib/active_merchant/billing/gateways/omise.rb index 2d37f1dd5de..30ff0845778 100644 --- a/lib/active_merchant/billing/gateways/omise.rb +++ b/lib/active_merchant/billing/gateways/omise.rb @@ -19,7 +19,7 @@ class OmiseGateway < Gateway self.default_currency = 'THB' self.money_format = :cents - #Country supported by Omise + # Country supported by Omise # * Thailand self.supported_countries = %w( TH JP ) diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb index 6a2716c2813..d85b5cbdaa3 100644 --- a/lib/active_merchant/billing/gateways/optimal_payment.rb +++ b/lib/active_merchant/billing/gateways/optimal_payment.rb @@ -99,11 +99,11 @@ def commit(action, money, post) cc_stored_data_request(money, post) when 'ccAuthorizeReversal' cc_auth_reversal_request(post) - #when 'ccCancelSettle', 'ccCancelCredit', 'ccCancelPayment' + # when 'ccCancelSettle', 'ccCancelCredit', 'ccCancelPayment' # cc_cancel_request(money, post) - #when 'ccPayment' + # when 'ccPayment' # cc_payment_request(money, post) - #when 'ccAuthenticate' + # when 'ccAuthenticate' # cc_authenticate_request(money, post) else raise 'Unknown Action' diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb index f0ce2bb5556..347f423fac7 100644 --- a/lib/active_merchant/billing/gateways/payment_express.rb +++ b/lib/active_merchant/billing/gateways/payment_express.rb @@ -169,7 +169,7 @@ def build_capture_or_credit_request(money, identification, options) def build_token_request(credit_card, options) result = new_transaction add_credit_card(result, credit_card) - add_amount(result, 100, options) #need to make an auth request for $1 + add_amount(result, 100, options) # need to make an auth request for $1 add_token_request(result, options) add_optional_elements(result, options) result diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb index 8154add4944..827a5cc11a4 100644 --- a/lib/active_merchant/billing/gateways/psl_card.rb +++ b/lib/active_merchant/billing/gateways/psl_card.rb @@ -46,20 +46,20 @@ class PslCardGateway < Gateway 'USD' => 840 } - #The terminal used - only for swipe transactions, so hard coded to 32 for online + # The terminal used - only for swipe transactions, so hard coded to 32 for online EMV_TERMINAL_TYPE = 32 - #Different Dispatch types + # Different Dispatch types DISPATCH_LATER = 'LATER' DISPATCH_NOW = 'NOW' # Return codes APPROVED = '00' - #Nominal amount to authorize for a 'dispatch later' type - #The nominal amount is held straight away, when the goods are ready - #to be dispatched, PSL is informed and the full amount is the - #taken. + # Nominal amount to authorize for a 'dispatch later' type + # The nominal amount is held straight away, when the goods are ready + # to be dispatched, PSL is informed and the full amount is the + # taken. NOMINAL_AMOUNT = 101 AVS_CODE = { diff --git a/lib/active_merchant/billing/gateways/securion_pay.rb b/lib/active_merchant/billing/gateways/securion_pay.rb index 3c56fce55ad..8624ca0a6b8 100644 --- a/lib/active_merchant/billing/gateways/securion_pay.rb +++ b/lib/active_merchant/billing/gateways/securion_pay.rb @@ -73,11 +73,11 @@ def verify(credit_card, options={}) def store(credit_card, options = {}) if options[:customer_id].blank? MultiResponse.run() do |r| - #create charge object + # create charge object r.process { authorize(100, credit_card, options) } - #create customer and save card + # create customer and save card r.process { create_customer_add_card(r.authorization, options) } - #void the charge + # void the charge r.process(:ignore_result) { void(r.params['metadata']['chargeId'], options) } end else diff --git a/test/remote/gateways/remote_authorize_net_cim_test.rb b/test/remote/gateways/remote_authorize_net_cim_test.rb index bbd6d60eea4..b0c5e09f7d4 100644 --- a/test/remote/gateways/remote_authorize_net_cim_test.rb +++ b/test/remote/gateways/remote_authorize_net_cim_test.rb @@ -466,7 +466,7 @@ def test_successful_update_customer_payment_profile_request_with_credit_card_las new_billing_address.update(:first_name => 'Frank', :last_name => 'Brown') # Initialize credit card with only last 4 digits as the number - last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => '4242') #Credit card with only last four digits + last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => '4242') # Credit card with only last four digits # Update only the billing address with a card with the last 4 digits and expiration date assert response = @gateway.update_customer_payment_profile( @@ -515,7 +515,7 @@ def test_successful_update_customer_shipping_address_request ) new_address.delete(:phone_number) - #Update the shipping address + # Update the shipping address assert response = @gateway.update_customer_shipping_address( :customer_profile_id => @customer_profile_id, :address => new_address diff --git a/test/remote/gateways/remote_ct_payment_certification_test.rb b/test/remote/gateways/remote_ct_payment_certification_test.rb index 97ac2d6073b..b2a9784e416 100644 --- a/test/remote/gateways/remote_ct_payment_certification_test.rb +++ b/test/remote/gateways/remote_ct_payment_certification_test.rb @@ -128,7 +128,7 @@ def test19 end def test20 - #requires editing the model to run with a 3 digit expiration date + # requires editing the model to run with a 3 digit expiration date @credit_card = credit_card('4501161107217214', month: '07', year: 2) response = @gateway.purchase(@amount, @credit_card, @options) print_result(20, response) @@ -204,7 +204,7 @@ def test32 end def test33 - #requires edit to model to make 3 digit expiration date + # requires edit to model to make 3 digit expiration date @credit_card = credit_card('4501161107217214', month: '07', year: 2) response = @gateway.credit(@amount, @credit_card, @options) print_result(33, response) diff --git a/test/remote/gateways/remote_data_cash_test.rb b/test/remote/gateways/remote_data_cash_test.rb index 9ff6635e5f9..9fb77b19a6f 100644 --- a/test/remote/gateways/remote_data_cash_test.rb +++ b/test/remote/gateways/remote_data_cash_test.rb @@ -72,8 +72,8 @@ def test_successful_purchase assert response.test? end - #the amount is changed to £1.99 - the DC test server won't check the - #address details - this is more a check on the passed ExtendedPolicy + # the amount is changed to £1.99 - the DC test server won't check the + # address details - this is more a check on the passed ExtendedPolicy def test_successful_purchase_without_address_check response = @gateway.purchase(199, @mastercard, @params) assert_success response @@ -109,7 +109,7 @@ def test_successful_purchase_with_account_set_up_and_repeat_payments assert !response.authorization.to_s.split(';')[2].blank? assert response.test? - #Make second payment on the continuous authorization that was set up in the first purchase + # Make second payment on the continuous authorization that was set up in the first purchase second_order_params = { :order_id => generate_unique_id } purchase = @gateway.purchase(201, response.authorization, second_order_params) assert_success purchase @@ -121,7 +121,7 @@ def test_successful_purchase_with_account_set_up_and_repeat_payments_with_visa_d assert_success response assert !response.authorization.to_s.split(';')[2].blank? - #Make second payment on the continuous authorization that was set up in the first purchase + # Make second payment on the continuous authorization that was set up in the first purchase second_order_params = { :order_id => generate_unique_id } purchase = @gateway.purchase(201, response.authorization, second_order_params) assert_success purchase @@ -135,19 +135,19 @@ def test_purchase_with_account_set_up_for_repeat_payments_fails_for_solo_card end def test_successful_authorization_and_capture_with_account_set_up_and_second_purchase - #Authorize first payment + # Authorize first payment @params[:set_up_continuous_authority] = true first_authorization = @gateway.authorize(@amount, @mastercard, @params) assert_success first_authorization assert !first_authorization.authorization.to_s.split(';')[2].blank? assert first_authorization.test? - #Capture first payment + # Capture first payment capture = @gateway.capture(@amount, first_authorization.authorization, @params) assert_success capture assert capture.test? - #Collect second purchase + # Collect second purchase second_order_params = { :order_id => generate_unique_id } purchase = @gateway.purchase(201, first_authorization.authorization, second_order_params) assert_success purchase diff --git a/test/remote/gateways/remote_nab_transact_test.rb b/test/remote/gateways/remote_nab_transact_test.rb index 71cfe58cdb2..ce7ce019ec5 100644 --- a/test/remote/gateways/remote_nab_transact_test.rb +++ b/test/remote/gateways/remote_nab_transact_test.rb @@ -31,16 +31,16 @@ def test_successful_purchase end def test_unsuccessful_purchase_insufficient_funds - #Any total not ending in 00/08/11/16 - failing_amount = 151 #Specifically tests 'Insufficient Funds' + # Any total not ending in 00/08/11/16 + failing_amount = 151 # Specifically tests 'Insufficient Funds' assert response = @gateway.purchase(failing_amount, @credit_card, @options) assert_failure response assert_equal 'Insufficient Funds', response.message end def test_unsuccessful_purchase_do_not_honour - #Any total not ending in 00/08/11/16 - failing_amount = 105 #Specifically tests 'do not honour' + # Any total not ending in 00/08/11/16 + failing_amount = 105 # Specifically tests 'do not honour' assert response = @gateway.purchase(failing_amount, @credit_card, @options) assert_failure response assert_equal 'Do Not Honour', response.message diff --git a/test/remote/gateways/remote_paypal_test.rb b/test/remote/gateways/remote_paypal_test.rb index 7901d34024a..3cb88a8ed96 100644 --- a/test/remote/gateways/remote_paypal_test.rb +++ b/test/remote/gateways/remote_paypal_test.rb @@ -29,8 +29,8 @@ def setup # each auth-id can only be reauthorized and tested once. # leave it commented if you don't want to test reauthorization. # - #@three_days_old_auth_id = "9J780651TU4465545" - #@three_days_old_auth_id2 = "62503445A3738160X" + # @three_days_old_auth_id = "9J780651TU4465545" + # @three_days_old_auth_id2 = "62503445A3738160X" end def test_transcript_scrubbing diff --git a/test/remote/gateways/remote_secure_pay_au_test.rb b/test/remote/gateways/remote_secure_pay_au_test.rb index 56958b29afd..fc99db2ef81 100644 --- a/test/remote/gateways/remote_secure_pay_au_test.rb +++ b/test/remote/gateways/remote_secure_pay_au_test.rb @@ -130,7 +130,7 @@ def test_successful_unstore end def test_repeat_unstore - @gateway.unstore('test1234') rescue nil #Ensure it is already missing + @gateway.unstore('test1234') rescue nil # Ensure it is already missing response = @gateway.unstore('test1234') @@ -147,7 +147,7 @@ def test_successful_store end def test_failed_store - @gateway.store(@credit_card, {:billing_id => 'test1234', :amount => 15000}) rescue nil #Ensure it already exists + @gateway.store(@credit_card, {:billing_id => 'test1234', :amount => 15000}) rescue nil # Ensure it already exists assert response = @gateway.store(@credit_card, {:billing_id => 'test1234', :amount => 15000}) assert_failure response @@ -156,7 +156,7 @@ def test_failed_store end def test_successful_triggered_payment - @gateway.store(@credit_card, {:billing_id => 'test1234', :amount => 15000}) rescue nil #Ensure it already exists + @gateway.store(@credit_card, {:billing_id => 'test1234', :amount => 15000}) rescue nil # Ensure it already exists assert response = @gateway.purchase(12300, 'test1234', @options) assert_success response @@ -166,7 +166,7 @@ def test_successful_triggered_payment end def test_failure_triggered_payment - @gateway.unstore('test1234') rescue nil #Ensure its no longer there + @gateway.unstore('test1234') rescue nil # Ensure its no longer there assert response = @gateway.purchase(12300, 'test1234', @options) assert_failure response diff --git a/test/remote/gateways/remote_wirecard_test.rb b/test/remote/gateways/remote_wirecard_test.rb index 15783d552d5..b58b05ee05b 100644 --- a/test/remote/gateways/remote_wirecard_test.rb +++ b/test/remote/gateways/remote_wirecard_test.rb @@ -58,7 +58,7 @@ def test_successful_authorize_and_partial_capture assert_match %r{THIS IS A DEMO}, auth.message assert auth.authorization - #Capture some of the authorized amount + # Capture some of the authorized amount assert capture = @gateway.capture(@amount - 10, auth.authorization, @options) assert_success capture end diff --git a/test/unit/gateways/authorize_net_cim_test.rb b/test/unit/gateways/authorize_net_cim_test.rb index 64f09efd42f..1d9bd462192 100644 --- a/test/unit/gateways/authorize_net_cim_test.rb +++ b/test/unit/gateways/authorize_net_cim_test.rb @@ -420,7 +420,7 @@ def test_should_update_customer_payment_profile_request end def test_should_update_customer_payment_profile_request_with_last_four_digits - last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => '4242') #Credit card with only last four digits + last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => '4242') # Credit card with only last four digits response = stub_comms do @gateway.update_customer_payment_profile( diff --git a/test/unit/gateways/banwire_test.rb b/test/unit/gateways/banwire_test.rb index 77207753a74..faa341c1f97 100644 --- a/test/unit/gateways/banwire_test.rb +++ b/test/unit/gateways/banwire_test.rb @@ -61,7 +61,7 @@ def test_invalid_json assert_match %r{Invalid response received from the Banwire API}, response.message end - #American Express requires address and zipcode + # American Express requires address and zipcode def test_successful_amex_purchase response = stub_comms do @gateway.purchase(@amount, @amex_credit_card, @amex_options) @@ -75,7 +75,7 @@ def test_successful_amex_purchase assert response.test? end - #American Express requires address and zipcode + # American Express requires address and zipcode def test_unsuccessful_amex_request @gateway.expects(:ssl_post).returns(failed_purchase_amex_response) diff --git a/test/unit/gateways/garanti_test.rb b/test/unit/gateways/garanti_test.rb index 5b8287bb018..46e7ce79e87 100644 --- a/test/unit/gateways/garanti_test.rb +++ b/test/unit/gateways/garanti_test.rb @@ -10,7 +10,7 @@ def setup @gateway = GarantiGateway.new(:login => 'a', :password => 'b', :terminal_id => 'c', :merchant_id => 'd') @credit_card = credit_card(4242424242424242) - @amount = 1000 #1000 cents, 10$ + @amount = 1000 # 1000 cents, 10$ @options = { :order_id => 'db4af18c5222503d845180350fbda516', diff --git a/test/unit/gateways/iats_payments_test.rb b/test/unit/gateways/iats_payments_test.rb index 0a063e2d2b4..ac94ec90912 100644 --- a/test/unit/gateways/iats_payments_test.rb +++ b/test/unit/gateways/iats_payments_test.rb @@ -225,7 +225,7 @@ def test_region_urls @gateway = IatsPaymentsGateway.new( :agent_code => 'code', :password => 'password', - :region => 'na' #North america + :region => 'na' # North america ) response = stub_comms do diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb index 67145530893..0c4f89d6641 100644 --- a/test/unit/gateways/paypal_express_test.rb +++ b/test/unit/gateways/paypal_express_test.rb @@ -736,7 +736,7 @@ def test_structure_correct } doc = Nokogiri::XML(@gateway.send(:build_setup_request, 'Sale', 10, all_options_enabled)) - #Strip back to the SetExpressCheckoutRequestDetails element - this is where the base component xsd starts + # Strip back to the SetExpressCheckoutRequestDetails element - this is where the base component xsd starts xml = doc.xpath('//base:SetExpressCheckoutRequestDetails', 'base' => 'urn:ebay:apis:eBLBaseComponents').first sub_doc = Nokogiri::XML::Document.new sub_doc.root = xml diff --git a/test/unit/gateways/usa_epay_advanced_test.rb b/test/unit/gateways/usa_epay_advanced_test.rb index 24220cf514f..5f37ec88899 100644 --- a/test/unit/gateways/usa_epay_advanced_test.rb +++ b/test/unit/gateways/usa_epay_advanced_test.rb @@ -79,7 +79,7 @@ def setup @standard_transaction_options = { :method_id => 0, :command => 'Sale', - :amount => 2000 #20.00 + :amount => 2000 # 20.00 } @get_payment_options = { @@ -421,7 +421,7 @@ def test_successful_run_check_credit end # TODO get post_auth response - #def test_successful_post_auth + # def test_successful_post_auth # @options.merge!(:authorization_code => 'bogus') # @gateway.expects(:ssl_post).returns(successful_post_auth_response) @@ -433,7 +433,7 @@ def test_successful_run_check_credit # #assert_equal '47568732', response.authorization # puts response.inspect - #end + # end def test_successful_run_quick_sale @options.merge!(@transaction_options) @@ -495,7 +495,7 @@ def test_successful_refund_transaction end # TODO get override_transaction response - #def test_successful_override_transaction + # def test_successful_override_transaction # @gateway.expects(:ssl_post).returns(successful_override_transaction_response) # assert response = @gateway.override_transaction(@options) @@ -504,7 +504,7 @@ def test_successful_refund_transaction # assert response.test? # puts response.inspect - #end + # end # Transaction Status ================================================ From b9d58ea50723572210819aad864e51f37b09ccc9 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 19 Oct 2018 09:16:23 -0400 Subject: [PATCH 579/677] MercadoPago: fix remote tests There are two main issues here: first, the behavior of failed refunds has changed, potentially allowing the requests to appear successful when they were not. Refunds are now checked for success against the new behavior. Second, failed captures and voids, which previously returned JSON, now simply return an HTML page showing an HTTP 405 error code, which would crash Active Merchant. The parse method now recovers from that situation and generates a bogus return value. Unit: 19 tests, 90 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 17 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/mercado_pago.rb | 8 +++++++- test/remote/gateways/remote_mercado_pago_test.rb | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index ad6f931aade..3c841fccc53 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -186,6 +186,12 @@ def add_payment(post, options) def parse(body) JSON.parse(body) + rescue JSON::ParserError + { + 'status' => 'error', + 'status_detail' => 'json_parse_error', + 'message' => "A non-JSON response was received from Mercado Pago where one was expected. The raw response was:\n\n#{body}" + } end def commit(action, path, parameters) @@ -207,7 +213,7 @@ def commit(action, path, parameters) def success_from(action, response) if action == 'refund' - response['error'].nil? + response['status'] != 404 && response['error'].nil? else ['active', 'approved', 'authorized', 'cancelled', 'in_process'].include?(response['status']) end diff --git a/test/remote/gateways/remote_mercado_pago_test.rb b/test/remote/gateways/remote_mercado_pago_test.rb index aeda0a15172..54ddaa50072 100644 --- a/test/remote/gateways/remote_mercado_pago_test.rb +++ b/test/remote/gateways/remote_mercado_pago_test.rb @@ -71,7 +71,7 @@ def test_partial_capture def test_failed_capture response = @gateway.capture(@amount, '') assert_failure response - assert_equal 'Method not allowed', response.message + assert_equal 'json_parse_error', response.message end def test_successful_refund @@ -94,7 +94,7 @@ def test_partial_refund def test_failed_refund response = @gateway.refund(@amount, '') assert_failure response - assert_equal 'Resource /payments/refunds not found.', response.message + assert_equal 'Not Found', response.message end def test_successful_void @@ -109,7 +109,7 @@ def test_successful_void def test_failed_void response = @gateway.void('') assert_failure response - assert_equal 'Method not allowed', response.message + assert_equal 'json_parse_error', response.message end def test_successful_verify From 2feafae92919c014a40255b95eda6150ef21d662 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder <deedeelavinder@gmail.com> Date: Thu, 11 Oct 2018 16:34:37 -0400 Subject: [PATCH 580/677] Braintree: Adds device_data According to Braintree docs, `device_data` can be sent as a top-level parameter when creating a `transaction`, `payment_method`, or `customer`. And after chatting with their support, there is no way to test this from the server-side. Deploying this with the hope that a customer will give us some feedback about its efficacy. Unit tests: 54 tests, 137 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote tests: 63 tests, 361 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/braintree_blue.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 1f3726827bf..b1bafda2fc3 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -159,7 +159,7 @@ def update(vault_id, creditcard, options = {}) :last_name => creditcard.last_name, :email => scrub_email(options[:email]), :phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] && - options[:billing_address][:phone]), + options[:billing_address][:phone]), :credit_card => credit_card_params ) Response.new(result.success?, message_from_result(result), @@ -233,6 +233,7 @@ def add_customer_with_credit_card(creditcard, options) :phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] && options[:billing_address][:phone]), :id => options[:customer], + :device_data => options[:device_data], }.merge credit_card_params result = @braintree_gateway.customer.create(merge_credit_card_options(parameters, options)) Response.new(result.success?, message_from_result(result), @@ -256,6 +257,7 @@ def add_credit_card_to_customer(credit_card, options) cvv: credit_card.verification_value, expiration_month: credit_card.month.to_s.rjust(2, '0'), expiration_year: credit_card.year.to_s, + device_data: options[:device_data], } parameters[:billing_address] = map_address(options[:billing_address]) if options[:billing_address] From cfce5f199c192458d0584978c275f8a486f5a7f9 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@bitquabit.com> Date: Mon, 22 Oct 2018 15:07:36 -0400 Subject: [PATCH 581/677] RuboCop: fix Style/SafeNavigation --- .rubocop_todo.yml | 7 ------- lib/active_merchant/billing/compatibility.rb | 2 +- lib/active_merchant/billing/gateways/adyen.rb | 2 +- lib/active_merchant/billing/gateways/authorize_net_cim.rb | 2 +- .../billing/gateways/beanstream/beanstream_core.rb | 8 +++----- lib/active_merchant/billing/gateways/blue_pay.rb | 2 +- lib/active_merchant/billing/gateways/braintree_blue.rb | 2 +- lib/active_merchant/billing/gateways/bridge_pay.rb | 6 +++--- lib/active_merchant/billing/gateways/ct_payment.rb | 2 +- lib/active_merchant/billing/gateways/cyber_source.rb | 2 +- lib/active_merchant/billing/gateways/elavon.rb | 8 +++----- lib/active_merchant/billing/gateways/first_pay.rb | 6 +++--- lib/active_merchant/billing/gateways/hps.rb | 2 +- lib/active_merchant/billing/gateways/jetpay.rb | 2 +- lib/active_merchant/billing/gateways/jetpay_v2.rb | 2 +- lib/active_merchant/billing/gateways/linkpoint.rb | 4 ++-- lib/active_merchant/billing/gateways/litle.rb | 2 +- lib/active_merchant/billing/gateways/optimal_payment.rb | 2 +- lib/active_merchant/billing/gateways/orbital.rb | 2 +- lib/active_merchant/billing/gateways/pay_junction_v2.rb | 2 +- lib/active_merchant/billing/gateways/payeezy.rb | 2 +- lib/active_merchant/billing/gateways/payex.rb | 4 ++-- lib/active_merchant/billing/gateways/quickbooks.rb | 2 +- lib/active_merchant/billing/gateways/securion_pay.rb | 4 ++-- lib/active_merchant/billing/gateways/stripe.rb | 2 +- lib/active_merchant/billing/gateways/telr.rb | 4 ++-- lib/active_merchant/connection.rb | 4 ++-- lib/active_merchant/network_connection_retries.rb | 2 +- lib/active_merchant/posts_data.rb | 4 ++-- test/comm_stub.rb | 2 +- 30 files changed, 43 insertions(+), 54 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b6411de3752..9be5fbc942b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1259,13 +1259,6 @@ Style/RescueStandardError: Exclude: - 'lib/active_merchant/billing/base.rb' -# Offense count: 33 -# Cop supports --auto-correct. -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist. -# Whitelist: present?, blank?, presence, try, try! -Style/SafeNavigation: - Enabled: false - # Offense count: 2 # Cop supports --auto-correct. Style/SelfAssignment: diff --git a/lib/active_merchant/billing/compatibility.rb b/lib/active_merchant/billing/compatibility.rb index 8161ef320f0..87b7790440f 100644 --- a/lib/active_merchant/billing/compatibility.rb +++ b/lib/active_merchant/billing/compatibility.rb @@ -75,7 +75,7 @@ def []=(key, value) end def empty? - all?{|k, v| v && v.empty?} + all?{|k, v| v&.empty?} end def on(field) diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index c73db70be52..cef696b8d8f 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -135,7 +135,7 @@ def add_shopper_interaction(post, payment, options={}) end def add_address(post, options) - return unless post[:card] && post[:card].kind_of?(Hash) + return unless post[:card]&.kind_of?(Hash) if (address = options[:billing_address] || options[:address]) && address[:country] post[:card][:billingAddress] = {} post[:card][:billingAddress][:street] = address[:address1] || 'N/A' diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb index ca774b3f1c3..af7c4a769b1 100644 --- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb +++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb @@ -878,7 +878,7 @@ def tag_unless_blank(xml, tag_name, data) end def format_extra_options(options) - options.map{ |k, v| "#{k}=#{v}" }.join('&') unless options.nil? + options&.map{ |k, v| "#{k}=#{v}" }&.join('&') end def parse_direct_response(params) diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index bbc548de702..d1d7b2b75c4 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -375,11 +375,9 @@ def interval(options) def parse(body) results = {} - if !body.nil? - body.split(/&/).each do |pair| - key, val = pair.split(/\=/) - results[key.to_sym] = val.nil? ? nil : CGI.unescape(val) - end + body&.split(/&/)&.each do |pair| + key, val = pair.split(/\=/) + results[key.to_sym] = val.nil? ? nil : CGI.unescape(val) end # Clean up the message text if there is any diff --git a/lib/active_merchant/billing/gateways/blue_pay.rb b/lib/active_merchant/billing/gateways/blue_pay.rb index 5e708624538..063434a150f 100644 --- a/lib/active_merchant/billing/gateways/blue_pay.rb +++ b/lib/active_merchant/billing/gateways/blue_pay.rb @@ -173,7 +173,7 @@ def refund(money, identification, options = {}) end def credit(money, payment_object, options = {}) - if(payment_object && payment_object.kind_of?(String)) + if payment_object&.kind_of?(String) ActiveMerchant.deprecated 'credit should only be used to credit a payment method' return refund(money, payment_object, options) end diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index b1bafda2fc3..6295c80164c 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -355,7 +355,7 @@ def response_from_result(result) result.success?, message_from_result(result), response_hash, - authorization: (result.transaction.id if result.transaction), + authorization: result.transaction&.id, test: test? ) end diff --git a/lib/active_merchant/billing/gateways/bridge_pay.rb b/lib/active_merchant/billing/gateways/bridge_pay.rb index ae2e653f4b6..3e12f5b11d6 100644 --- a/lib/active_merchant/billing/gateways/bridge_pay.rb +++ b/lib/active_merchant/billing/gateways/bridge_pay.rb @@ -166,8 +166,8 @@ def parse(xml) response = {} doc = Nokogiri::XML(xml) - doc.root.xpath('*').each do |node| - if (node.elements.size == 0) + doc.root&.xpath('*')&.each do |node| + if node.elements.size == 0 response[node.name.downcase.to_sym] = node.text else node.elements.each do |childnode| @@ -175,7 +175,7 @@ def parse(xml) response[name.to_sym] = childnode.text end end - end unless doc.root.nil? + end response end diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb index c29f8c30630..dd0c1ae2599 100644 --- a/lib/active_merchant/billing/gateways/ct_payment.rb +++ b/lib/active_merchant/billing/gateways/ct_payment.rb @@ -242,7 +242,7 @@ def success_from(response) end def message_from(response) - response['errorDescription'] || (response['terminalDisp'].strip if response['terminalDisp']) + response['errorDescription'] || response['terminalDisp']&.strip end def authorization_from(response) diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 0bc2693ff1e..60a0fd3caef 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -677,7 +677,7 @@ def add_threeds_services(xml, options) def lookup_country_code(country_field) country_code = Country.find(country_field) rescue nil - country_code.code(:alpha2) if country_code + country_code&.code(:alpha2) end # Where we actually build the full SOAP request using builder diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb index 9814d760966..1800d17b373 100644 --- a/lib/active_merchant/billing/gateways/elavon.rb +++ b/lib/active_merchant/billing/gateways/elavon.rb @@ -191,10 +191,8 @@ def add_customer_data(form, options) form[:email] = truncate(options[:email], 100) unless empty?(options[:email]) form[:customer_code] = truncate(options[:customer], 10) unless empty?(options[:customer]) form[:customer_number] = options[:customer_number] unless empty?(options[:customer_number]) - if options[:custom_fields] - options[:custom_fields].each do |key, value| - form[key.to_s] = value - end + options[:custom_fields]&.each do |key, value| + form[key.to_s] = value end end @@ -283,7 +281,7 @@ def post_data_string(key, value, options) end def custom_field?(field_name, options) - return true if options[:custom_fields] && options[:custom_fields].include?(field_name.to_sym) + return true if options[:custom_fields]&.include?(field_name.to_sym) field_name == :customer_number end diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb index 9a21f24562d..3c197f0d79e 100644 --- a/lib/active_merchant/billing/gateways/first_pay.rb +++ b/lib/active_merchant/billing/gateways/first_pay.rb @@ -119,9 +119,9 @@ def parse(xml) response = {} doc = Nokogiri::XML(xml) - doc.root.xpath('//RESPONSE/FIELDS/FIELD').each do |field| + doc.root&.xpath('//RESPONSE/FIELDS/FIELD')&.each do |field| response[field['KEY']] = field.text - end unless doc.root.nil? + end response end @@ -149,7 +149,7 @@ def success_from(response) def message_from(response) # Silly inconsistent gateway. Always make capitalized (but not all caps) msg = (response['auth_response'] || response['response1']) - msg.downcase.capitalize if msg + msg&.downcase&.capitalize end def error_code_from(response) diff --git a/lib/active_merchant/billing/gateways/hps.rb b/lib/active_merchant/billing/gateways/hps.rb index 07f4fb26597..5572924d1c7 100644 --- a/lib/active_merchant/billing/gateways/hps.rb +++ b/lib/active_merchant/billing/gateways/hps.rb @@ -274,7 +274,7 @@ def authorization_from(response) end def test? - (@options[:secret_api_key] && @options[:secret_api_key].include?('_cert_')) + @options[:secret_api_key]&.include?('_cert_') end ISSUER_MESSAGES = { diff --git a/lib/active_merchant/billing/gateways/jetpay.rb b/lib/active_merchant/billing/gateways/jetpay.rb index 948c4799941..f6c631c4421 100644 --- a/lib/active_merchant/billing/gateways/jetpay.rb +++ b/lib/active_merchant/billing/gateways/jetpay.rb @@ -395,7 +395,7 @@ def add_user_defined_fields(xml, options) def lookup_country_code(code) country = Country.find(code) rescue nil - country && country.code(:alpha3) + country&.code(:alpha3) end end end diff --git a/lib/active_merchant/billing/gateways/jetpay_v2.rb b/lib/active_merchant/billing/gateways/jetpay_v2.rb index 0eb900d2aea..ff136384912 100644 --- a/lib/active_merchant/billing/gateways/jetpay_v2.rb +++ b/lib/active_merchant/billing/gateways/jetpay_v2.rb @@ -430,7 +430,7 @@ def add_user_defined_fields(xml, options) def lookup_country_code(code) country = Country.find(code) rescue nil - country && country.code(:alpha3) + country&.code(:alpha3) end end end diff --git a/lib/active_merchant/billing/gateways/linkpoint.rb b/lib/active_merchant/billing/gateways/linkpoint.rb index 79ac53d3298..37f0b3ab0b5 100644 --- a/lib/active_merchant/billing/gateways/linkpoint.rb +++ b/lib/active_merchant/billing/gateways/linkpoint.rb @@ -434,9 +434,9 @@ def parse(xml) response = {:message => 'Global Error Receipt', :complete => false} xml = REXML::Document.new("<response>#{xml}</response>") - xml.root.elements.each do |node| + xml.root&.elements&.each do |node| response[node.name.downcase.sub(/^r_/, '').to_sym] = normalize(node.text) - end unless xml.root.nil? + end response end diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index 4365a3884c5..61be3eedaa7 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -284,7 +284,7 @@ def add_payment_method(doc, payment_method, options) doc.cardholderAuthentication do doc.authenticationValue(payment_method.payment_cryptogram) end - elsif options[:order_source] && options[:order_source].start_with?('3ds') + elsif options[:order_source]&.start_with?('3ds') doc.cardholderAuthentication do doc.authenticationValue(options[:cavv]) if options[:cavv] doc.authenticationTransactionId(options[:xid]) if options[:xid] diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb index d85b5cbdaa3..7dd2427ac33 100644 --- a/lib/active_merchant/billing/gateways/optimal_payment.rb +++ b/lib/active_merchant/billing/gateways/optimal_payment.rb @@ -178,7 +178,7 @@ def xml_document(root_tag) def get_text_from_document(document, node) node = REXML::XPath.first(document, node) - node && node.text + node&.text end def cc_auth_request(money, opts) diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index f41a9801775..53ac7b2ac25 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -396,7 +396,7 @@ def add_address(xml, creditcard, options) xml.tag! :AVSphoneNum, (address[:phone] ? address[:phone].scan(/\d/).join.to_s[0..13] : nil) end - xml.tag! :AVSname, ((creditcard && creditcard.name) ? creditcard.name[0..29] : nil) + xml.tag! :AVSname, (creditcard&.name ? creditcard.name[0..29] : nil) xml.tag! :AVScountryCode, (avs_supported ? byte_limit(format_address_field(address[:country]), 2) : '') # Needs to come after AVScountryCode diff --git a/lib/active_merchant/billing/gateways/pay_junction_v2.rb b/lib/active_merchant/billing/gateways/pay_junction_v2.rb index f453d1b5e75..669188c9d48 100644 --- a/lib/active_merchant/billing/gateways/pay_junction_v2.rb +++ b/lib/active_merchant/billing/gateways/pay_junction_v2.rb @@ -173,7 +173,7 @@ def success_from(response) def message_from(response) return response['response']['message'] if response['response'] - response['errors'].inject(''){ |message,error| error['message'] + '|' + message } if response['errors'] + response['errors']&.inject(''){ |message,error| error['message'] + '|' + message } end def authorization_from(response) diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index dad7cbebd69..fc14df47d07 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -374,7 +374,7 @@ def authorization_from(params, response) response['transaction_id'], response['transaction_tag'], params[:method], - (response['amount'] && response['amount'].to_i) + response['amount']&.to_i ].join('|') end end diff --git a/lib/active_merchant/billing/gateways/payex.rb b/lib/active_merchant/billing/gateways/payex.rb index b35038ca239..82a40a46ab9 100644 --- a/lib/active_merchant/billing/gateways/payex.rb +++ b/lib/active_merchant/billing/gateways/payex.rb @@ -363,7 +363,7 @@ def parse(xml) doc = Nokogiri::XML(body) - doc.root.xpath('*').each do |node| + doc.root&.xpath('*')&.each do |node| if (node.elements.size == 0) response[node.name.downcase.to_sym] = node.text else @@ -372,7 +372,7 @@ def parse(xml) response[name.to_sym] = childnode.text end end - end unless doc.root.nil? + end response end diff --git a/lib/active_merchant/billing/gateways/quickbooks.rb b/lib/active_merchant/billing/gateways/quickbooks.rb index ed51d7266dd..c81ab1deeda 100644 --- a/lib/active_merchant/billing/gateways/quickbooks.rb +++ b/lib/active_merchant/billing/gateways/quickbooks.rb @@ -118,7 +118,7 @@ def add_charge_data(post, payment, options = {}) end def add_address(post, options) - return unless post[:card] && post[:card].kind_of?(Hash) + return unless post[:card]&.kind_of?(Hash) card_address = {} if address = options[:billing_address] || options[:address] diff --git a/lib/active_merchant/billing/gateways/securion_pay.rb b/lib/active_merchant/billing/gateways/securion_pay.rb index 8624ca0a6b8..c59370bad4d 100644 --- a/lib/active_merchant/billing/gateways/securion_pay.rb +++ b/lib/active_merchant/billing/gateways/securion_pay.rb @@ -165,7 +165,7 @@ def add_creditcard(post, creditcard, options) end def add_address(post, options) - return unless post[:card] && post[:card].kind_of?(Hash) + return unless post[:card]&.kind_of?(Hash) if address = options[:billing_address] post[:card][:addressLine1] = address[:address1] if address[:address1] post[:card][:addressLine2] = address[:address2] if address[:address2] @@ -257,7 +257,7 @@ def json_error(raw_response) end def test? - (@options[:secret_key] && @options[:secret_key].include?('_test_')) + (@options[:secret_key]&.include?('_test_')) end end end diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 49c7077a2a8..81c2fd982cc 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -386,7 +386,7 @@ def add_customer_data(post, options) end def add_address(post, options) - return unless post[:card] && post[:card].kind_of?(Hash) + return unless post[:card]&.kind_of?(Hash) if address = options[:billing_address] || options[:address] post[:card][:address_line1] = address[:address1] if address[:address1] post[:card][:address_line2] = address[:address2] if address[:address2] diff --git a/lib/active_merchant/billing/gateways/telr.rb b/lib/active_merchant/billing/gateways/telr.rb index f1a38ef889d..f3938d89c9a 100644 --- a/lib/active_merchant/billing/gateways/telr.rb +++ b/lib/active_merchant/billing/gateways/telr.rb @@ -214,7 +214,7 @@ def parse(xml) response = {} doc = Nokogiri::XML(xml) - doc.root.xpath('*').each do |node| + doc.root&.xpath('*')&.each do |node| if (node.elements.size == 0) response[node.name.downcase.to_sym] = node.text else @@ -223,7 +223,7 @@ def parse(xml) response[name.to_sym] = childnode.text end end - end unless doc.root.nil? + end response end diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb index d7067b98636..e6731ed8566 100644 --- a/lib/active_merchant/connection.rb +++ b/lib/active_merchant/connection.rb @@ -61,7 +61,7 @@ def initialize(endpoint) end def wiredump_device=(device) - raise ArgumentError, "can't wiredump to frozen #{device.class}" if device && device.frozen? + raise ArgumentError, "can't wiredump to frozen #{device.class}" if device&.frozen? @wiredump_device = device end @@ -189,7 +189,7 @@ def error(message, tag = nil) def log(level, message, tag) message = "[#{tag}] #{message}" if tag - logger.send(level, message) if logger + logger&.send(level, message) end end end diff --git a/lib/active_merchant/network_connection_retries.rb b/lib/active_merchant/network_connection_retries.rb index db0187ffa33..0bce98f7619 100644 --- a/lib/active_merchant/network_connection_retries.rb +++ b/lib/active_merchant/network_connection_retries.rb @@ -65,7 +65,7 @@ def retry_network_exceptions(options = {}) def self.log(logger, level, message, tag=nil) tag ||= self.class.to_s message = "[#{tag}] #{message}" - logger.send(level, message) if logger + logger&.send(level, message) end private diff --git a/lib/active_merchant/posts_data.rb b/lib/active_merchant/posts_data.rb index 857efa9b162..15446c09fd8 100644 --- a/lib/active_merchant/posts_data.rb +++ b/lib/active_merchant/posts_data.rb @@ -45,8 +45,8 @@ def ssl_request(method, endpoint, data, headers) end def raw_ssl_request(method, endpoint, data, headers = {}) - logger.warn "#{self.class} using ssl_strict=false, which is insecure" if logger unless ssl_strict - logger.warn "#{self.class} posting to plaintext endpoint, which is insecure" if logger unless endpoint.to_s =~ /^https:/ + logger&.warn "#{self.class} using ssl_strict=false, which is insecure" unless ssl_strict + logger&.warn "#{self.class} posting to plaintext endpoint, which is insecure" unless endpoint.to_s =~ /^https:/ connection = new_connection(endpoint) connection.open_timeout = open_timeout diff --git a/test/comm_stub.rb b/test/comm_stub.rb index 2d4c95013b4..9293ef77955 100644 --- a/test/comm_stub.rb +++ b/test/comm_stub.rb @@ -19,7 +19,7 @@ def respond_with(*responses) singleton_class = (class << @gateway; self; end) singleton_class.send(:undef_method, @method_to_stub) singleton_class.send(:define_method, @method_to_stub) do |*args| - check.call(*args) if check + check&.call(*args) (responses.size == 1 ? responses.last : responses.shift) end @action.call From 17271aef2caff95820472e23f0ad393af55351e9 Mon Sep 17 00:00:00 2001 From: Filipe Costa <filipebarcos@users.noreply.github.com> Date: Mon, 22 Oct 2018 22:50:15 -0400 Subject: [PATCH 582/677] [Payflow Express] Use phone returned from payload on Response (#3003) --- CHANGELOG | 1 + .../billing/gateways/payflow/payflow_express_response.rb | 6 +++++- test/unit/gateways/payflow_express_test.rb | 6 ++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 029ce1e6d0d..a80da434731 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009 * RuboCop: AlignHash [nfarve] #3004 * Beanstream: Switch `recurringPayment` flag from boolean to integer [dtykocki] #3011 +* Payflow Express: Add phone to returned Response [filipebarcos] [#3003] == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001] diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb b/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb index 0c01ee481b2..3c43642265f 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb @@ -22,6 +22,10 @@ def payer_country address['country'] end + def phone + @params['phone'] + end + def address { 'name' => @params['shiptoname'] || full_name, 'company' => nil, @@ -31,7 +35,7 @@ def address 'state' => @params['state'], 'country' => @params['country'], 'zip' => @params['zip'], - 'phone' => nil + 'phone' => phone, } end end diff --git a/test/unit/gateways/payflow_express_test.rb b/test/unit/gateways/payflow_express_test.rb index a78238a6a3a..ef8fab1fcb4 100644 --- a/test/unit/gateways/payflow_express_test.rb +++ b/test/unit/gateways/payflow_express_test.rb @@ -114,7 +114,7 @@ def test_get_express_details assert_equal 'CA', address['state'] assert_equal '95100', address['zip'] assert_equal 'US', address['country'] - assert_nil address['phone'] + assert_equal '555-555-5555', address['phone'] end def test_get_express_details_with_ship_to_name @@ -139,7 +139,7 @@ def test_get_express_details_with_ship_to_name assert_equal 'CA', address['state'] assert_equal '95100', address['zip'] assert_equal 'US', address['country'] - assert_nil address['phone'] + assert_equal '555-555-5555', address['phone'] end def test_get_express_details_with_invalid_xml @@ -179,6 +179,7 @@ def successful_get_express_details_response(options={:street => '111 Main St.'}) <FeeAmount>0</FeeAmount> <PayerStatus>verified</PayerStatus> <Name>Joe</Name> + <Phone>555-555-5555</Phone> <ShipTo> <Address> <Street>#{options[:street]}</Street> @@ -215,6 +216,7 @@ def successful_get_express_details_response_with_ship_to_name <FeeAmount>0</FeeAmount> <PayerStatus>verified</PayerStatus> <Name>Joe</Name> + <Phone>555-555-5555</Phone> <ShipTo> <Address> <Street>111 Main St.</Street> From 8d47d02a628abefa642a043b4ecf327528992abe Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 23 Oct 2018 09:12:36 -0400 Subject: [PATCH 583/677] Mercado Pago: tighten brand testing in unit tests This patch as-is amounts to a no-op, but is getting added so that the subsequent patch will *fail*, making it clearer what the upcoming patch does. Unit: 19 tests, 92 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- test/unit/gateways/mercado_pago_test.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb index 1f6d043b612..7b29e5252c8 100644 --- a/test/unit/gateways/mercado_pago_test.rb +++ b/test/unit/gateways/mercado_pago_test.rb @@ -155,8 +155,8 @@ def test_sends_american_express_as_amex response = stub_comms do @gateway.purchase(@amount, credit_card, @options) end.check_request do |endpoint, data, headers| - if data =~ /"payment_method_id"/ - assert_match(%r(amex), data) + if endpoint =~ /payments/ + assert_match(%r("payment_method_id":"amex"), data) end end.respond_with(successful_purchase_response) @@ -170,8 +170,8 @@ def test_sends_diners_club_as_diners response = stub_comms do @gateway.purchase(@amount, credit_card, @options) end.check_request do |endpoint, data, headers| - if data =~ /"payment_method_id"/ - assert_match(%r(diners), data) + if endpoint =~ /payments/ + assert_match(%r("payment_method_id":"diners"), data) end end.respond_with(successful_purchase_response) @@ -185,8 +185,8 @@ def test_sends_mastercard_as_master response = stub_comms do @gateway.purchase(@amount, credit_card, @options) end.check_request do |endpoint, data, headers| - if data =~ /"payment_method_id"/ - assert_match(%r(master), data) + if endpoint =~ /payments/ + assert_match(%r("payment_method_id":"master"), data) end end.respond_with(successful_purchase_response) From d9c5a1a011263c5677e7d0dc084d5fc2d16193ff Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 19 Oct 2018 12:22:18 -0400 Subject: [PATCH 584/677] Mercado Pago: do not infer card type Allow the card type to be passed in explicitly instead via the :payment_method_id option. Additionally, allow sending the :issuer_id. Unit: 19 tests, 93 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 17 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- .../billing/gateways/mercado_pago.rb | 10 +---- test/unit/gateways/mercado_pago_test.rb | 38 +++++++++---------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index 3c841fccc53..51aafc8f457 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -10,11 +10,6 @@ class MercadoPagoGateway < Gateway self.display_name = 'Mercado Pago' self.money_format = :dollars - CARD_BRAND = { - 'american_express' => 'amex', - 'diners_club' => 'diners' - } - def initialize(options={}) requires!(options, :access_token) super @@ -23,7 +18,6 @@ def initialize(options={}) def purchase(money, payment, options={}) MultiResponse.run do |r| r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) } - options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand)) options.merge!(card_token: r.authorization.split('|').first) r.process { commit('purchase', 'payments', purchase_request(money, payment, options) ) } end @@ -32,7 +26,6 @@ def purchase(money, payment, options={}) def authorize(money, payment, options={}) MultiResponse.run do |r| r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) } - options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand)) options.merge!(card_token: r.authorization.split('|').first) r.process { commit('authorize', 'payments', authorize_request(money, payment, options) ) } end @@ -181,7 +174,8 @@ def add_invoice(post, money, options) def add_payment(post, options) post[:token] = options[:card_token] - post[:payment_method_id] = options[:card_brand] + post[:issuer_id] = options[:issuer_id] if options[:issuer_id] + post[:payment_method_id] = options[:payment_method_id] if options[:payment_method_id] end def parse(body) diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb index 7b29e5252c8..1e53016dde3 100644 --- a/test/unit/gateways/mercado_pago_test.rb +++ b/test/unit/gateways/mercado_pago_test.rb @@ -149,14 +149,14 @@ def test_scrub assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed end - def test_sends_american_express_as_amex + def test_does_not_send_brand credit_card = credit_card('378282246310005', brand: 'american_express') response = stub_comms do @gateway.purchase(@amount, credit_card, @options) end.check_request do |endpoint, data, headers| if endpoint =~ /payments/ - assert_match(%r("payment_method_id":"amex"), data) + assert_not_match(%r("payment_method_id":"amex"), data) end end.respond_with(successful_purchase_response) @@ -164,11 +164,11 @@ def test_sends_american_express_as_amex assert_equal '4141491|1.0', response.authorization end - def test_sends_diners_club_as_diners - credit_card = credit_card('30569309025904', brand: 'diners_club') + def test_sends_payment_method_id + credit_card = credit_card('30569309025904') response = stub_comms do - @gateway.purchase(@amount, credit_card, @options) + @gateway.purchase(@amount, credit_card, @options.merge(payment_method_id: 'diners')) end.check_request do |endpoint, data, headers| if endpoint =~ /payments/ assert_match(%r("payment_method_id":"diners"), data) @@ -179,21 +179,6 @@ def test_sends_diners_club_as_diners assert_equal '4141491|1.0', response.authorization end - def test_sends_mastercard_as_master - credit_card = credit_card('5555555555554444', brand: 'master') - - response = stub_comms do - @gateway.purchase(@amount, credit_card, @options) - end.check_request do |endpoint, data, headers| - if endpoint =~ /payments/ - assert_match(%r("payment_method_id":"master"), data) - end - end.respond_with(successful_purchase_response) - - assert_success response - assert_equal '4141491|1.0', response.authorization - end - def test_includes_deviceid_header @options[:device_id] = '1a2b3c' @gateway.expects(:ssl_post).with(anything, anything, headers = {'Content-Type' => 'application/json'}).returns(successful_purchase_response) @@ -217,6 +202,19 @@ def test_includes_additional_data assert_success response end + def test_includes_issuer_id + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(issuer_id: '1a2b3c4d')) + end.check_request do |endpoint, data, headers| + if endpoint =~ /payments/ + assert_match(%r("issuer_id":"1a2b3c4d"), data) + end + end.respond_with(successful_purchase_response) + + assert_success response + assert_equal '4141491|1.0', response.authorization + end + private def pre_scrubbed From 7b4d1ac805d3396a8cb8b37a4d82735dbf7df311 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@bitquabit.com> Date: Mon, 22 Oct 2018 16:35:20 -0400 Subject: [PATCH 585/677] RuboCop: fix Layout/TrailingBlankLines --- .rubocop_todo.yml | 7 ------- lib/active_merchant/billing/compatibility.rb | 1 - lib/active_merchant/billing/gateways/beanstream_interac.rb | 1 - lib/active_merchant/billing/gateways/card_save.rb | 1 - lib/active_merchant/billing/gateways/citrus_pay.rb | 1 - lib/active_merchant/billing/gateways/exact.rb | 1 - lib/active_merchant/billing/gateways/federated_canada.rb | 1 - lib/active_merchant/billing/gateways/finansbank.rb | 1 - lib/active_merchant/billing/gateways/first_giving.rb | 1 - lib/active_merchant/billing/gateways/garanti.rb | 1 - lib/active_merchant/billing/gateways/hdfc.rb | 1 - lib/active_merchant/billing/gateways/inspire.rb | 1 - lib/active_merchant/billing/gateways/instapay.rb | 1 - lib/active_merchant/billing/gateways/itransact.rb | 1 - lib/active_merchant/billing/gateways/merchant_one.rb | 1 - lib/active_merchant/billing/gateways/modern_payments.rb | 1 - .../billing/gateways/modern_payments_cim.rb | 1 - lib/active_merchant/billing/gateways/money_movers.rb | 1 - lib/active_merchant/billing/gateways/netaxept.rb | 1 - lib/active_merchant/billing/gateways/network_merchants.rb | 1 - lib/active_merchant/billing/gateways/pac_net_raven.rb | 1 - lib/active_merchant/billing/gateways/pay_gate_xml.rb | 2 +- lib/active_merchant/billing/gateways/pay_secure.rb | 1 - lib/active_merchant/billing/gateways/payex.rb | 1 - .../billing/gateways/payflow/payflow_response.rb | 2 +- lib/active_merchant/billing/gateways/payflow_express_uk.rb | 1 - lib/active_merchant/billing/gateways/payflow_uk.rb | 1 - lib/active_merchant/billing/gateways/payscout.rb | 1 - lib/active_merchant/billing/gateways/quickpay.rb | 1 - .../billing/gateways/quickpay/quickpay_v4to7.rb | 1 - lib/active_merchant/billing/gateways/sallie_mae.rb | 1 - lib/active_merchant/billing/gateways/secure_pay.rb | 1 - lib/active_merchant/billing/gateways/secure_pay_tech.rb | 1 - lib/active_merchant/billing/gateways/smart_ps.rb | 1 - lib/active_merchant/billing/gateways/swipe_checkout.rb | 1 - lib/active_merchant/billing/gateways/transax.rb | 1 - lib/active_merchant/billing/gateways/transnational.rb | 1 - lib/activemerchant.rb | 2 +- lib/support/gateway_support.rb | 1 - test/remote/gateways/remote_inspire_test.rb | 2 -- test/remote/gateways/remote_so_easy_pay_test.rb | 1 - test/remote/gateways/remote_stripe_android_pay_test.rb | 2 +- test/remote/gateways/remote_stripe_apple_pay_test.rb | 1 - test/remote/gateways/remote_viaklix_test.rb | 2 +- test/unit/cvv_result_test.rb | 2 +- test/unit/expiry_date_test.rb | 2 +- test/unit/gateways/in_context_paypal_express_test.rb | 1 - test/unit/gateways/inspire_test.rb | 1 - test/unit/gateways/instapay_test.rb | 1 - test/unit/gateways/opp_test.rb | 1 - test/unit/gateways/paypal_digital_goods_test.rb | 1 - test/unit/gateways/psl_card_test.rb | 2 +- test/unit/gateways/quickpay_test.rb | 1 - test/unit/gateways/skip_jack_test.rb | 1 - test/unit/gateways/so_easy_pay_test.rb | 1 - test/unit/gateways/viaklix_test.rb | 2 +- 56 files changed, 9 insertions(+), 63 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9be5fbc942b..ba51669d47e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -252,13 +252,6 @@ Layout/Tab: - 'lib/active_merchant/billing/gateways/trust_commerce.rb' - 'test/remote/gateways/remote_orbital_test.rb' -# Offense count: 57 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: final_newline, final_blank_line -Layout/TrailingBlankLines: - Enabled: false - # Offense count: 357 # Cop supports --auto-correct. # Configuration parameters: AllowInHeredoc. diff --git a/lib/active_merchant/billing/compatibility.rb b/lib/active_merchant/billing/compatibility.rb index 87b7790440f..df999f60ed3 100644 --- a/lib/active_merchant/billing/compatibility.rb +++ b/lib/active_merchant/billing/compatibility.rb @@ -115,4 +115,3 @@ def full_messages Compatibility::Model.send(:include, Rails::Model) end end - diff --git a/lib/active_merchant/billing/gateways/beanstream_interac.rb b/lib/active_merchant/billing/gateways/beanstream_interac.rb index 836f686607d..37ca7595a31 100644 --- a/lib/active_merchant/billing/gateways/beanstream_interac.rb +++ b/lib/active_merchant/billing/gateways/beanstream_interac.rb @@ -55,4 +55,3 @@ def build_response(*args) end end end - diff --git a/lib/active_merchant/billing/gateways/card_save.rb b/lib/active_merchant/billing/gateways/card_save.rb index 48c7decf336..821ba3c3b6a 100644 --- a/lib/active_merchant/billing/gateways/card_save.rb +++ b/lib/active_merchant/billing/gateways/card_save.rb @@ -20,4 +20,3 @@ def initialize(options={}) end end end - diff --git a/lib/active_merchant/billing/gateways/citrus_pay.rb b/lib/active_merchant/billing/gateways/citrus_pay.rb index 3b12c5deaf6..00ab762d196 100644 --- a/lib/active_merchant/billing/gateways/citrus_pay.rb +++ b/lib/active_merchant/billing/gateways/citrus_pay.rb @@ -20,4 +20,3 @@ class CitrusPayGateway < Gateway end end end - diff --git a/lib/active_merchant/billing/gateways/exact.rb b/lib/active_merchant/billing/gateways/exact.rb index 915a1a82c5d..6858ef98aa6 100644 --- a/lib/active_merchant/billing/gateways/exact.rb +++ b/lib/active_merchant/billing/gateways/exact.rb @@ -222,4 +222,3 @@ def parse_elements(response, root) end end end - diff --git a/lib/active_merchant/billing/gateways/federated_canada.rb b/lib/active_merchant/billing/gateways/federated_canada.rb index 404e8bebd60..639fd3a3aff 100644 --- a/lib/active_merchant/billing/gateways/federated_canada.rb +++ b/lib/active_merchant/billing/gateways/federated_canada.rb @@ -157,4 +157,3 @@ def post_data(action, parameters = {}) end end end - diff --git a/lib/active_merchant/billing/gateways/finansbank.rb b/lib/active_merchant/billing/gateways/finansbank.rb index 144f798abfe..5f496570853 100644 --- a/lib/active_merchant/billing/gateways/finansbank.rb +++ b/lib/active_merchant/billing/gateways/finansbank.rb @@ -20,4 +20,3 @@ class FinansbankGateway < CC5Gateway end end end - diff --git a/lib/active_merchant/billing/gateways/first_giving.rb b/lib/active_merchant/billing/gateways/first_giving.rb index 65bd5256104..975409638d7 100644 --- a/lib/active_merchant/billing/gateways/first_giving.rb +++ b/lib/active_merchant/billing/gateways/first_giving.rb @@ -140,4 +140,3 @@ def headers end end end - diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb index fbd202ceee6..5a95e3383db 100644 --- a/lib/active_merchant/billing/gateways/garanti.rb +++ b/lib/active_merchant/billing/gateways/garanti.rb @@ -257,4 +257,3 @@ def strip_invalid_xml_chars(xml) end end end - diff --git a/lib/active_merchant/billing/gateways/hdfc.rb b/lib/active_merchant/billing/gateways/hdfc.rb index 01404cd8d00..f10438b0b47 100644 --- a/lib/active_merchant/billing/gateways/hdfc.rb +++ b/lib/active_merchant/billing/gateways/hdfc.rb @@ -204,4 +204,3 @@ def escape(string, max_length=250) end end end - diff --git a/lib/active_merchant/billing/gateways/inspire.rb b/lib/active_merchant/billing/gateways/inspire.rb index 324f1f8bb5f..f7ee068cdf0 100644 --- a/lib/active_merchant/billing/gateways/inspire.rb +++ b/lib/active_merchant/billing/gateways/inspire.rb @@ -216,4 +216,3 @@ def determine_funding_source(source) end end end - diff --git a/lib/active_merchant/billing/gateways/instapay.rb b/lib/active_merchant/billing/gateways/instapay.rb index d2ef3f9d13b..7d18c8da05b 100644 --- a/lib/active_merchant/billing/gateways/instapay.rb +++ b/lib/active_merchant/billing/gateways/instapay.rb @@ -160,4 +160,3 @@ def post_data(action, parameters = {}) end end end - diff --git a/lib/active_merchant/billing/gateways/itransact.rb b/lib/active_merchant/billing/gateways/itransact.rb index 0d96f7556e6..b0329417f44 100644 --- a/lib/active_merchant/billing/gateways/itransact.rb +++ b/lib/active_merchant/billing/gateways/itransact.rb @@ -445,4 +445,3 @@ def sign_payload(payload) end end end - diff --git a/lib/active_merchant/billing/gateways/merchant_one.rb b/lib/active_merchant/billing/gateways/merchant_one.rb index c65149bed62..a514a9e6107 100644 --- a/lib/active_merchant/billing/gateways/merchant_one.rb +++ b/lib/active_merchant/billing/gateways/merchant_one.rb @@ -111,4 +111,3 @@ def parse(data) end end end - diff --git a/lib/active_merchant/billing/gateways/modern_payments.rb b/lib/active_merchant/billing/gateways/modern_payments.rb index d94d12cb6d9..c5846f7a079 100644 --- a/lib/active_merchant/billing/gateways/modern_payments.rb +++ b/lib/active_merchant/billing/gateways/modern_payments.rb @@ -35,4 +35,3 @@ def cim end end end - diff --git a/lib/active_merchant/billing/gateways/modern_payments_cim.rb b/lib/active_merchant/billing/gateways/modern_payments_cim.rb index 7420ff6cd23..0d9ef36fc3e 100644 --- a/lib/active_merchant/billing/gateways/modern_payments_cim.rb +++ b/lib/active_merchant/billing/gateways/modern_payments_cim.rb @@ -215,4 +215,3 @@ def parse_element(response, node) end end end - diff --git a/lib/active_merchant/billing/gateways/money_movers.rb b/lib/active_merchant/billing/gateways/money_movers.rb index a41b57abeb5..870b47d2ac4 100644 --- a/lib/active_merchant/billing/gateways/money_movers.rb +++ b/lib/active_merchant/billing/gateways/money_movers.rb @@ -149,4 +149,3 @@ def post_data(action, parameters = {}) end end end - diff --git a/lib/active_merchant/billing/gateways/netaxept.rb b/lib/active_merchant/billing/gateways/netaxept.rb index b3f1652c662..f142ce5a968 100644 --- a/lib/active_merchant/billing/gateways/netaxept.rb +++ b/lib/active_merchant/billing/gateways/netaxept.rb @@ -178,4 +178,3 @@ def encode(hash) end end end - diff --git a/lib/active_merchant/billing/gateways/network_merchants.rb b/lib/active_merchant/billing/gateways/network_merchants.rb index b684e92c5a8..aadc09d425f 100644 --- a/lib/active_merchant/billing/gateways/network_merchants.rb +++ b/lib/active_merchant/billing/gateways/network_merchants.rb @@ -239,4 +239,3 @@ def parse(raw_response) end end end - diff --git a/lib/active_merchant/billing/gateways/pac_net_raven.rb b/lib/active_merchant/billing/gateways/pac_net_raven.rb index 1fd15b5c0ae..631e1441175 100644 --- a/lib/active_merchant/billing/gateways/pac_net_raven.rb +++ b/lib/active_merchant/billing/gateways/pac_net_raven.rb @@ -204,4 +204,3 @@ def signature(action, post, parameters = {}) end end end - diff --git a/lib/active_merchant/billing/gateways/pay_gate_xml.rb b/lib/active_merchant/billing/gateways/pay_gate_xml.rb index 55c9b7b67af..572ae9d7066 100644 --- a/lib/active_merchant/billing/gateways/pay_gate_xml.rb +++ b/lib/active_merchant/billing/gateways/pay_gate_xml.rb @@ -274,4 +274,4 @@ def message_from(response) end end end -end \ No newline at end of file +end diff --git a/lib/active_merchant/billing/gateways/pay_secure.rb b/lib/active_merchant/billing/gateways/pay_secure.rb index 72be0071d10..bbdfc2bacf9 100644 --- a/lib/active_merchant/billing/gateways/pay_secure.rb +++ b/lib/active_merchant/billing/gateways/pay_secure.rb @@ -109,4 +109,3 @@ def post_data(action, parameters = {}) end end end - diff --git a/lib/active_merchant/billing/gateways/payex.rb b/lib/active_merchant/billing/gateways/payex.rb index 82a40a46ab9..03aa3f24a9b 100644 --- a/lib/active_merchant/billing/gateways/payex.rb +++ b/lib/active_merchant/billing/gateways/payex.rb @@ -408,4 +408,3 @@ def message_from(response) end end end - diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_response.rb b/lib/active_merchant/billing/gateways/payflow/payflow_response.rb index 21f6b5cb868..e888ea2fec1 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_response.rb @@ -10,4 +10,4 @@ def payment_history end end end -end \ No newline at end of file +end diff --git a/lib/active_merchant/billing/gateways/payflow_express_uk.rb b/lib/active_merchant/billing/gateways/payflow_express_uk.rb index 79bf204de91..a314bad48c4 100644 --- a/lib/active_merchant/billing/gateways/payflow_express_uk.rb +++ b/lib/active_merchant/billing/gateways/payflow_express_uk.rb @@ -12,4 +12,3 @@ class PayflowExpressUkGateway < PayflowExpressGateway end end end - diff --git a/lib/active_merchant/billing/gateways/payflow_uk.rb b/lib/active_merchant/billing/gateways/payflow_uk.rb index 7d67610438f..e963c152ef0 100644 --- a/lib/active_merchant/billing/gateways/payflow_uk.rb +++ b/lib/active_merchant/billing/gateways/payflow_uk.rb @@ -18,4 +18,3 @@ def express end end end - diff --git a/lib/active_merchant/billing/gateways/payscout.rb b/lib/active_merchant/billing/gateways/payscout.rb index 7596dddccbc..88fb8624655 100644 --- a/lib/active_merchant/billing/gateways/payscout.rb +++ b/lib/active_merchant/billing/gateways/payscout.rb @@ -158,4 +158,3 @@ def post_data(action, parameters = {}) end end end - diff --git a/lib/active_merchant/billing/gateways/quickpay.rb b/lib/active_merchant/billing/gateways/quickpay.rb index 34d36f93196..5c1f6fb33bb 100644 --- a/lib/active_merchant/billing/gateways/quickpay.rb +++ b/lib/active_merchant/billing/gateways/quickpay.rb @@ -23,4 +23,3 @@ def self.new(options = {}) end end end - diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb index 95fae367036..a43fb085838 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb @@ -224,4 +224,3 @@ def format_order_number(number) end end end - diff --git a/lib/active_merchant/billing/gateways/sallie_mae.rb b/lib/active_merchant/billing/gateways/sallie_mae.rb index 510273a1fc4..7e15f08e232 100644 --- a/lib/active_merchant/billing/gateways/sallie_mae.rb +++ b/lib/active_merchant/billing/gateways/sallie_mae.rb @@ -140,4 +140,3 @@ def message_from(response) end end end - diff --git a/lib/active_merchant/billing/gateways/secure_pay.rb b/lib/active_merchant/billing/gateways/secure_pay.rb index 68d32c5b5c2..656e360940c 100644 --- a/lib/active_merchant/billing/gateways/secure_pay.rb +++ b/lib/active_merchant/billing/gateways/secure_pay.rb @@ -198,4 +198,3 @@ def split(response) end end end - diff --git a/lib/active_merchant/billing/gateways/secure_pay_tech.rb b/lib/active_merchant/billing/gateways/secure_pay_tech.rb index 5a6036afcd1..3cf645f8838 100644 --- a/lib/active_merchant/billing/gateways/secure_pay_tech.rb +++ b/lib/active_merchant/billing/gateways/secure_pay_tech.rb @@ -102,4 +102,3 @@ def post_data(action, post) end end end - diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb index 0b9841189e9..b6a89f13b39 100644 --- a/lib/active_merchant/billing/gateways/smart_ps.rb +++ b/lib/active_merchant/billing/gateways/smart_ps.rb @@ -278,4 +278,3 @@ def determine_funding_source(source) end end end - diff --git a/lib/active_merchant/billing/gateways/swipe_checkout.rb b/lib/active_merchant/billing/gateways/swipe_checkout.rb index ea0bbc3b925..dcd63d1fdec 100644 --- a/lib/active_merchant/billing/gateways/swipe_checkout.rb +++ b/lib/active_merchant/billing/gateways/swipe_checkout.rb @@ -150,4 +150,3 @@ def build_error_response(message, params={}) end end end - diff --git a/lib/active_merchant/billing/gateways/transax.rb b/lib/active_merchant/billing/gateways/transax.rb index c11c830bac9..7411ad573c4 100644 --- a/lib/active_merchant/billing/gateways/transax.rb +++ b/lib/active_merchant/billing/gateways/transax.rb @@ -20,4 +20,3 @@ class TransaxGateway < SmartPs end end end - diff --git a/lib/active_merchant/billing/gateways/transnational.rb b/lib/active_merchant/billing/gateways/transnational.rb index bce37f5eede..350a2e91857 100644 --- a/lib/active_merchant/billing/gateways/transnational.rb +++ b/lib/active_merchant/billing/gateways/transnational.rb @@ -7,4 +7,3 @@ class TransnationalGateway < NetworkMerchantsGateway end end end - diff --git a/lib/activemerchant.rb b/lib/activemerchant.rb index 0a3f08fee3f..118568f06b3 100644 --- a/lib/activemerchant.rb +++ b/lib/activemerchant.rb @@ -1 +1 @@ -require 'active_merchant' \ No newline at end of file +require 'active_merchant' diff --git a/lib/support/gateway_support.rb b/lib/support/gateway_support.rb index 1ae661a6375..84cf58df2fc 100644 --- a/lib/support/gateway_support.rb +++ b/lib/support/gateway_support.rb @@ -67,4 +67,3 @@ def to_s end end end - diff --git a/test/remote/gateways/remote_inspire_test.rb b/test/remote/gateways/remote_inspire_test.rb index d9594ceda57..221ea62b17a 100644 --- a/test/remote/gateways/remote_inspire_test.rb +++ b/test/remote/gateways/remote_inspire_test.rb @@ -159,5 +159,3 @@ def test_invalid_login assert_failure response end end - - diff --git a/test/remote/gateways/remote_so_easy_pay_test.rb b/test/remote/gateways/remote_so_easy_pay_test.rb index 791a5343505..e24d837703b 100644 --- a/test/remote/gateways/remote_so_easy_pay_test.rb +++ b/test/remote/gateways/remote_so_easy_pay_test.rb @@ -62,4 +62,3 @@ def test_invalid_login assert_equal 'Website verification failed, wrong websiteID or password', response.message end end - diff --git a/test/remote/gateways/remote_stripe_android_pay_test.rb b/test/remote/gateways/remote_stripe_android_pay_test.rb index 10631d08d2c..5abf0974a17 100644 --- a/test/remote/gateways/remote_stripe_android_pay_test.rb +++ b/test/remote/gateways/remote_stripe_android_pay_test.rb @@ -45,4 +45,4 @@ def test_successful_auth_with_android_pay_raw_cryptogram assert_equal 'wow@example.com', response.params['metadata']['email'] assert_match CHARGE_ID_REGEX, response.authorization end -end \ No newline at end of file +end diff --git a/test/remote/gateways/remote_stripe_apple_pay_test.rb b/test/remote/gateways/remote_stripe_apple_pay_test.rb index d7d966ddb45..c5231114490 100644 --- a/test/remote/gateways/remote_stripe_apple_pay_test.rb +++ b/test/remote/gateways/remote_stripe_apple_pay_test.rb @@ -163,4 +163,3 @@ def test_successful_auth_with_apple_pay_raw_cryptogram_without_eci end end - diff --git a/test/remote/gateways/remote_viaklix_test.rb b/test/remote/gateways/remote_viaklix_test.rb index 02b2bf06df8..952d3a62a43 100644 --- a/test/remote/gateways/remote_viaklix_test.rb +++ b/test/remote/gateways/remote_viaklix_test.rb @@ -40,4 +40,4 @@ def test_credit assert credit = @gateway.credit(@amount, @credit_card) assert_success credit end -end \ No newline at end of file +end diff --git a/test/unit/cvv_result_test.rb b/test/unit/cvv_result_test.rb index 12ed48d1e35..ac44bdf24b1 100644 --- a/test/unit/cvv_result_test.rb +++ b/test/unit/cvv_result_test.rb @@ -30,4 +30,4 @@ def test_to_hash assert_equal 'M', result['code'] assert_equal CVVResult.messages['M'], result['message'] end -end \ No newline at end of file +end diff --git a/test/unit/expiry_date_test.rb b/test/unit/expiry_date_test.rb index 0306b339447..25e2e22bc0b 100644 --- a/test/unit/expiry_date_test.rb +++ b/test/unit/expiry_date_test.rb @@ -29,4 +29,4 @@ def test_month_and_year_coerced_to_integer assert_equal 13, expiry.month assert_equal 2009, expiry.year end -end \ No newline at end of file +end diff --git a/test/unit/gateways/in_context_paypal_express_test.rb b/test/unit/gateways/in_context_paypal_express_test.rb index 4760bf50e5b..4e92dc3032a 100644 --- a/test/unit/gateways/in_context_paypal_express_test.rb +++ b/test/unit/gateways/in_context_paypal_express_test.rb @@ -40,4 +40,3 @@ def test_test_redirect_url_without_review assert_equal TEST_REDIRECT_URL_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', review: false) end end - diff --git a/test/unit/gateways/inspire_test.rb b/test/unit/gateways/inspire_test.rb index 1bb0ea565e8..6aac648f1da 100644 --- a/test/unit/gateways/inspire_test.rb +++ b/test/unit/gateways/inspire_test.rb @@ -140,4 +140,3 @@ def failed_refund_response 'response=3&responsetext=Invalid Transaction ID specified REFID:3150951931&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=refund&response_code=300' end end - diff --git a/test/unit/gateways/instapay_test.rb b/test/unit/gateways/instapay_test.rb index acd35d3027b..16880aab17f 100644 --- a/test/unit/gateways/instapay_test.rb +++ b/test/unit/gateways/instapay_test.rb @@ -99,4 +99,3 @@ def failed_capture_response "<html><body><plaintext>\r\nDeclined=DECLINED:1101450002:Post amount exceeds Auth amount:\r\nhistoryid=\r\norderid=\r\nDeclined=DECLINED:1101450002:Post amount exceeds Auth amount:\r\nrcode=1101450002\r\nReason=DECLINED:1101450002:Post amount exceeds Auth amount:\r\nresult=0\r\nStatus=Declined\r\ntransid=0\r\n" end end - diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb index 93d33190471..3c7ccf84ae3 100644 --- a/test/unit/gateways/opp_test.rb +++ b/test/unit/gateways/opp_test.rb @@ -213,4 +213,3 @@ def initialize(code, body) end end - diff --git a/test/unit/gateways/paypal_digital_goods_test.rb b/test/unit/gateways/paypal_digital_goods_test.rb index cef8d773b49..9e46f0036d6 100644 --- a/test/unit/gateways/paypal_digital_goods_test.rb +++ b/test/unit/gateways/paypal_digital_goods_test.rb @@ -120,4 +120,3 @@ def successful_setup_response end end - diff --git a/test/unit/gateways/psl_card_test.rb b/test/unit/gateways/psl_card_test.rb index 8e31f389338..9ef1a651b84 100644 --- a/test/unit/gateways/psl_card_test.rb +++ b/test/unit/gateways/psl_card_test.rb @@ -62,4 +62,4 @@ def successful_purchase_response def unsuccessful_purchase_response 'ResponseCode=05&Message=CARD DECLINED&QAAddress=The Parkway Larches Approach Hull North Humberside&QAPostcode=HU7 9OP&MerchantName=Merchant Name&QAName=' end -end \ No newline at end of file +end diff --git a/test/unit/gateways/quickpay_test.rb b/test/unit/gateways/quickpay_test.rb index 3ce28fd9070..98bb37cb941 100644 --- a/test/unit/gateways/quickpay_test.rb +++ b/test/unit/gateways/quickpay_test.rb @@ -19,4 +19,3 @@ def test_v10 end end - diff --git a/test/unit/gateways/skip_jack_test.rb b/test/unit/gateways/skip_jack_test.rb index d1faca21da2..45f70914506 100644 --- a/test/unit/gateways/skip_jack_test.rb +++ b/test/unit/gateways/skip_jack_test.rb @@ -276,4 +276,3 @@ def successful_paymentech_authorization_response CSV end end - diff --git a/test/unit/gateways/so_easy_pay_test.rb b/test/unit/gateways/so_easy_pay_test.rb index 1dead1bd716..94a7f913a80 100644 --- a/test/unit/gateways/so_easy_pay_test.rb +++ b/test/unit/gateways/so_easy_pay_test.rb @@ -222,4 +222,3 @@ def failed_credit_response end end - diff --git a/test/unit/gateways/viaklix_test.rb b/test/unit/gateways/viaklix_test.rb index ea24cf3f3e2..6b624676452 100644 --- a/test/unit/gateways/viaklix_test.rb +++ b/test/unit/gateways/viaklix_test.rb @@ -75,4 +75,4 @@ def invalid_login_response ssl_result_message=The viaKLIX ID and/or User ID supplied in the authorization request is invalid.\r RESPONSE end -end \ No newline at end of file +end From edcc2fe4daf33b571b960408fe6a99b44487201a Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@bitquabit.com> Date: Mon, 22 Oct 2018 16:44:30 -0400 Subject: [PATCH 586/677] RuboCop: fix Layout/Tab --- .rubocop_todo.yml | 11 ----------- .../billing/gateways/braintree_blue.rb | 4 ++-- .../billing/gateways/efsnet.rb | 18 +++++++++--------- .../billing/gateways/pagarme.rb | 2 +- .../billing/gateways/trust_commerce.rb | 10 +++++----- test/remote/gateways/remote_orbital_test.rb | 19 ++++++++++--------- 6 files changed, 27 insertions(+), 37 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ba51669d47e..a3681855ba4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -241,17 +241,6 @@ Layout/SpaceInsideStringInterpolation: - 'lib/active_merchant/billing/gateways/trust_commerce.rb' - 'test/unit/gateways/worldpay_test.rb' -# Offense count: 27 -# Cop supports --auto-correct. -# Configuration parameters: IndentationWidth. -Layout/Tab: - Exclude: - - 'lib/active_merchant/billing/gateways/braintree_blue.rb' - - 'lib/active_merchant/billing/gateways/efsnet.rb' - - 'lib/active_merchant/billing/gateways/pagarme.rb' - - 'lib/active_merchant/billing/gateways/trust_commerce.rb' - - 'test/remote/gateways/remote_orbital_test.rb' - # Offense count: 357 # Cop supports --auto-correct. # Configuration parameters: AllowInHeredoc. diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 6295c80164c..1c35f5d0534 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -231,7 +231,7 @@ def add_customer_with_credit_card(creditcard, options) :last_name => creditcard.last_name, :email => scrub_email(options[:email]), :phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] && - options[:billing_address][:phone]), + options[:billing_address][:phone]), :id => options[:customer], :device_data => options[:device_data], }.merge credit_card_params @@ -558,7 +558,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) :id => options[:store] == true ? '' : options[:store], :email => scrub_email(options[:email]), :phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] && - options[:billing_address][:phone]) + options[:billing_address][:phone]) }, :options => { :store_in_vault => options[:store] ? true : false, diff --git a/lib/active_merchant/billing/gateways/efsnet.rb b/lib/active_merchant/billing/gateways/efsnet.rb index a7e428b1eff..91e689d3fa7 100644 --- a/lib/active_merchant/billing/gateways/efsnet.rb +++ b/lib/active_merchant/billing/gateways/efsnet.rb @@ -200,15 +200,15 @@ def actions CREDIT_CARD_FIELDS = %w(AuthorizationNumber ClientIpAddress BillingAddress BillingCity BillingState BillingPostalCode BillingCountry BillingName CardVerificationValue ExpirationMonth ExpirationYear ReferenceNumber TransactionAmount AccountNumber ) ACTIONS = { - :credit_card_authorize => CREDIT_CARD_FIELDS, - :credit_card_charge => CREDIT_CARD_FIELDS, - :credit_card_voice_authorize => CREDIT_CARD_FIELDS, - :credit_card_capture => CREDIT_CARD_FIELDS, - :credit_card_credit => CREDIT_CARD_FIELDS + ['OriginalTransactionAmount'], - :credit_card_refund => %w(ReferenceNumber TransactionAmount OriginalTransactionAmount OriginalTransactionID ClientIpAddress), - :void_transaction => %w(ReferenceNumber TransactionID), - :credit_card_settle => %w(ReferenceNumber TransactionAmount OriginalTransactionAmount OriginalTransactionID ClientIpAddress), - :system_check => %w(SystemCheck), + :credit_card_authorize => CREDIT_CARD_FIELDS, + :credit_card_charge => CREDIT_CARD_FIELDS, + :credit_card_voice_authorize => CREDIT_CARD_FIELDS, + :credit_card_capture => CREDIT_CARD_FIELDS, + :credit_card_credit => CREDIT_CARD_FIELDS + ['OriginalTransactionAmount'], + :credit_card_refund => %w(ReferenceNumber TransactionAmount OriginalTransactionAmount OriginalTransactionID ClientIpAddress), + :void_transaction => %w(ReferenceNumber TransactionID), + :credit_card_settle => %w(ReferenceNumber TransactionAmount OriginalTransactionAmount OriginalTransactionID ClientIpAddress), + :system_check => %w(SystemCheck), } end end diff --git a/lib/active_merchant/billing/gateways/pagarme.rb b/lib/active_merchant/billing/gateways/pagarme.rb index 7dfabd6f56d..63d29f4f2c3 100644 --- a/lib/active_merchant/billing/gateways/pagarme.rb +++ b/lib/active_merchant/billing/gateways/pagarme.rb @@ -181,7 +181,7 @@ def response_error(raw_response) end def json_error(raw_response) - msg = 'Resposta inválida retornada pela API do Pagar.me. Por favor entre em contato com suporte@pagar.me se você continuar recebendo essa mensagem.' + msg = 'Resposta inválida retornada pela API do Pagar.me. Por favor entre em contato com suporte@pagar.me se você continuar recebendo essa mensagem.' msg += " (A resposta retornada pela API foi #{raw_response.inspect})" { 'errors' => [{ diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb index 4908df12cde..2b3dae1ec69 100644 --- a/lib/active_merchant/billing/gateways/trust_commerce.rb +++ b/lib/active_merchant/billing/gateways/trust_commerce.rb @@ -19,10 +19,10 @@ module Billing #:nodoc: # Next, create a credit card object using a TC approved test card. # # creditcard = ActiveMerchant::Billing::CreditCard.new( - # :number => '4111111111111111', - # :month => 8, - # :year => 2006, - # :first_name => 'Longbob', + # :number => '4111111111111111', + # :month => 8, + # :year => 2006, + # :first_name => 'Longbob', # :last_name => 'Longsen' # ) # @@ -353,7 +353,7 @@ def add_addresses(params, options) params[:shipto_address2] = shipping_address[:address2] unless shipping_address[:address2].blank? params[:shipto_city] = shipping_address[:city] unless shipping_address[:city].blank? params[:shipto_state] = shipping_address[:state] unless shipping_address[:state].blank? - params[:shipto_zip] = shipping_address[:zip] unless shipping_address[:zip].blank? + params[:shipto_zip] = shipping_address[:zip] unless shipping_address[:zip].blank? params[:shipto_country] = shipping_address[:country] unless shipping_address[:country].blank? end end diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb index 20b1b018431..55cdcce9bd0 100644 --- a/test/remote/gateways/remote_orbital_test.rb +++ b/test/remote/gateways/remote_orbital_test.rb @@ -40,15 +40,16 @@ def setup } @test_suite = [ - {:card => :visa, :AVSzip => 11111, :CVD => 111, :amount => 3000}, - {:card => :visa, :AVSzip => 33333, :CVD => nil, :amount => 3801}, - {:card => :mc, :AVSzip => 44444, :CVD => nil, :amount => 4100}, - {:card => :mc, :AVSzip => 88888, :CVD => 666, :amount => 1102}, - {:card => :amex, :AVSzip => 55555, :CVD => nil, :amount => 105500}, - {:card => :amex, :AVSzip => 66666, :CVD => 2222, :amount => 7500}, - {:card => :ds, :AVSzip => 77777, :CVD => nil, :amount => 1000}, - {:card => :ds, :AVSzip => 88888, :CVD => 444, :amount => 6303}, - {:card => :jcb, :AVSzip => 33333, :CVD => nil, :amount => 2900}] + {:card => :visa, :AVSzip => 11111, :CVD => 111, :amount => 3000}, + {:card => :visa, :AVSzip => 33333, :CVD => nil, :amount => 3801}, + {:card => :mc, :AVSzip => 44444, :CVD => nil, :amount => 4100}, + {:card => :mc, :AVSzip => 88888, :CVD => 666, :amount => 1102}, + {:card => :amex, :AVSzip => 55555, :CVD => nil, :amount => 105500}, + {:card => :amex, :AVSzip => 66666, :CVD => 2222, :amount => 7500}, + {:card => :ds, :AVSzip => 77777, :CVD => nil, :amount => 1000}, + {:card => :ds, :AVSzip => 88888, :CVD => 444, :amount => 6303}, + {:card => :jcb, :AVSzip => 33333, :CVD => nil, :amount => 2900} + ] end def test_successful_purchase From 4bfe35c27cb6e0e5333eeff3331f929fe292e149 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@bitquabit.com> Date: Mon, 22 Oct 2018 17:00:43 -0400 Subject: [PATCH 587/677] RuboCop: fix Layout/TrailingWhitespace --- .rubocop_todo.yml | 6 --- lib/active_merchant/billing/avs_result.rb | 24 ++++----- .../billing/gateways/card_save.rb | 8 +-- .../billing/gateways/creditcall.rb | 6 +-- .../billing/gateways/credorax.rb | 2 +- .../gateways/payflow/payflow_response.rb | 2 +- .../billing/gateways/quickbooks.rb | 2 +- .../gateways/quickpay/quickpay_common.rb | 14 +++--- .../gateways/quickpay/quickpay_v4to7.rb | 2 +- .../billing/gateways/transax.rb | 8 +-- .../billing/gateways/trexle.rb | 12 ++--- .../billing/gateways/usa_epay.rb | 2 +- .../remote_beanstream_interac_test.rb | 14 +++--- test/remote/gateways/remote_card_save_test.rb | 10 ++-- test/remote/gateways/remote_efsnet_test.rb | 14 +++--- test/remote/gateways/remote_instapay_test.rb | 10 ++-- test/remote/gateways/remote_itransact_test.rb | 9 ++-- .../gateways/remote_metrics_global_test.rb | 36 ++++++------- .../remote_modern_payments_cim_test.rb | 23 ++++----- .../remote/gateways/remote_pay_secure_test.rb | 8 +-- .../gateways/remote_paybox_direct_test.rb | 16 +++--- .../gateways/remote_payflow_express_test.rb | 6 +-- .../remote/gateways/remote_payflow_uk_test.rb | 34 ++++++------- test/remote/gateways/remote_psl_card_test.rb | 50 +++++++++---------- test/remote/gateways/remote_quantum_test.rb | 7 ++- .../remote/gateways/remote_sallie_mae_test.rb | 6 +-- .../gateways/remote_secure_pay_tech_test.rb | 6 +-- .../remote/gateways/remote_secure_pay_test.rb | 10 ++-- .../remote/gateways/remote_stripe_emv_test.rb | 2 +- .../gateways/remote_trans_first_test.rb | 2 +- ...te_trans_first_transaction_express_test.rb | 2 +- test/remote/gateways/remote_trexle_test.rb | 2 +- .../gateways/remote_trust_commerce_test.rb | 2 +- test/remote/gateways/remote_viaklix_test.rb | 20 ++++---- test/unit/cvv_result_test.rb | 8 +-- test/unit/expiry_date_test.rb | 8 +-- test/unit/gateways/beanstream_interac_test.rb | 14 +++--- test/unit/gateways/cecabank_test.rb | 2 +- test/unit/gateways/federated_canada_test.rb | 34 ++++++------- test/unit/gateways/global_collect_test.rb | 30 +++++------ test/unit/gateways/instapay_test.rb | 22 ++++---- test/unit/gateways/itransact_test.rb | 16 +++--- test/unit/gateways/mundipagg_test.rb | 2 +- test/unit/gateways/pay_secure_test.rb | 22 ++++---- test/unit/gateways/payflow_uk_test.rb | 8 +-- test/unit/gateways/psl_card_test.rb | 14 +++--- test/unit/gateways/quantum_test.rb | 18 +++---- test/unit/gateways/quickpay_test.rb | 12 ++--- test/unit/gateways/quickpay_v4to7_test.rb | 6 +-- test/unit/gateways/secure_pay_tech_test.rb | 12 ++--- test/unit/gateways/trexle_test.rb | 34 ++++++------- test/unit/gateways/viaklix_test.rb | 34 ++++++------- 52 files changed, 332 insertions(+), 341 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a3681855ba4..1841c4a0842 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -241,12 +241,6 @@ Layout/SpaceInsideStringInterpolation: - 'lib/active_merchant/billing/gateways/trust_commerce.rb' - 'test/unit/gateways/worldpay_test.rb' -# Offense count: 357 -# Cop supports --auto-correct. -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Enabled: false - # Offense count: 4 Lint/AmbiguousBlockAssociation: Exclude: diff --git a/lib/active_merchant/billing/avs_result.rb b/lib/active_merchant/billing/avs_result.rb index 527c3efa119..7324daef438 100644 --- a/lib/active_merchant/billing/avs_result.rb +++ b/lib/active_merchant/billing/avs_result.rb @@ -2,7 +2,7 @@ # encoding: utf-8 module ActiveMerchant - module Billing + module Billing # Implements the Address Verification System # https://www.wellsfargo.com/downloads/pdf/biz/merchant/visa_avs.pdf # http://en.wikipedia.org/wiki/Address_Verification_System @@ -38,7 +38,7 @@ class AVSResult 'Y' => 'Street address and 5-digit postal code match.', 'Z' => 'Street address does not match, but 5-digit postal code matches.' } - + # Map vendor's AVS result code to a postal match code POSTAL_MATCH_CODE = { 'Y' => %w( D H F H J L M P Q V W X Y Z ), @@ -49,7 +49,7 @@ class AVSResult codes.each { |code| map[code] = type } map end - + # Map vendor's AVS result code to a street match code STREET_MATCH_CODE = { 'Y' => %w( A B D H J M O Q T V X Y ), @@ -60,32 +60,32 @@ class AVSResult codes.each { |code| map[code] = type } map end - + attr_reader :code, :message, :street_match, :postal_match - + def self.messages MESSAGES end - + def initialize(attrs) attrs ||= {} - + @code = attrs[:code].upcase unless attrs[:code].blank? @message = self.class.messages[code] - + if attrs[:street_match].blank? @street_match = STREET_MATCH_CODE[code] - else + else @street_match = attrs[:street_match].upcase end - + if attrs[:postal_match].blank? @postal_match = POSTAL_MATCH_CODE[code] - else + else @postal_match = attrs[:postal_match].upcase end end - + def to_hash { 'code' => code, 'message' => message, diff --git a/lib/active_merchant/billing/gateways/card_save.rb b/lib/active_merchant/billing/gateways/card_save.rb index 821ba3c3b6a..7d5920be05b 100644 --- a/lib/active_merchant/billing/gateways/card_save.rb +++ b/lib/active_merchant/billing/gateways/card_save.rb @@ -2,21 +2,21 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class CardSaveGateway < IridiumGateway # CardSave lets you handle failovers on payments by providing 3 gateways in case one happens to be down - # URLS = ['https://gw1.cardsaveonlinepayments.com:4430/','https://gw2.cardsaveonlinepayments.com:4430/','https://gw3.cardsaveonlinepayments.com:4430/'] - + # URLS = ['https://gw1.cardsaveonlinepayments.com:4430/','https://gw2.cardsaveonlinepayments.com:4430/','https://gw3.cardsaveonlinepayments.com:4430/'] + self.money_format = :cents self.default_currency = 'GBP' self.supported_cardtypes = [ :visa, :maestro, :master, :american_express, :jcb ] self.supported_countries = [ 'GB' ] self.homepage_url = 'http://www.cardsave.net/' self.display_name = 'CardSave' - + def initialize(options={}) super @test_url = 'https://gw1.cardsaveonlinepayments.com:4430/' @live_url = 'https://gw1.cardsaveonlinepayments.com:4430/' end - + end end end diff --git a/lib/active_merchant/billing/gateways/creditcall.rb b/lib/active_merchant/billing/gateways/creditcall.rb index 4ce8a1f916d..554a12ac6be 100644 --- a/lib/active_merchant/billing/gateways/creditcall.rb +++ b/lib/active_merchant/billing/gateways/creditcall.rb @@ -14,14 +14,14 @@ class CreditcallGateway < Gateway self.homepage_url = 'https://www.creditcall.com' self.display_name = 'Creditcall' - + CVV_CODE = { 'matched' => 'M', 'notmatched' => 'N', 'notchecked' => 'P', 'partialmatch' => 'N' } - + AVS_CODE = { 'matched;matched' => 'D', 'matched;notchecked' =>'B', @@ -53,7 +53,7 @@ def purchase(money, payment_method, options={}) end merged_params = multi_response.responses.map(&:params).reduce({}, :merge) - + Response.new( multi_response.primary_response.success?, multi_response.primary_response.message, diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb index 96f45bc5c81..9a60d276fbe 100644 --- a/lib/active_merchant/billing/gateways/credorax.rb +++ b/lib/active_merchant/billing/gateways/credorax.rb @@ -185,7 +185,7 @@ def credit(amount, payment_method, options={}) add_email(post, options) add_echo(post, options) add_transaction_type(post, options) - + commit(:credit, post) end diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_response.rb b/lib/active_merchant/billing/gateways/payflow/payflow_response.rb index e888ea2fec1..83caaff5800 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_response.rb @@ -4,7 +4,7 @@ class PayflowResponse < Response def profile_id @params['profile_id'] end - + def payment_history @payment_history ||= @params['rp_payment_result'].collect(&:stringify_keys) rescue [] end diff --git a/lib/active_merchant/billing/gateways/quickbooks.rb b/lib/active_merchant/billing/gateways/quickbooks.rb index c81ab1deeda..f346cefc34b 100644 --- a/lib/active_merchant/billing/gateways/quickbooks.rb +++ b/lib/active_merchant/billing/gateways/quickbooks.rb @@ -253,7 +253,7 @@ def cvv_code_from(response) def success?(response) return FRAUD_WARNING_CODES.concat(['0']).include?(response['errors'].first['code']) if response['errors'] - + !['DECLINED', 'CANCELLED'].include?(response['status']) end diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb index 904c03d8c26..930958e0cbb 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb @@ -136,9 +136,9 @@ module QuickpayCommon :chstatus => %w(protocol msgtype merchant apikey) }, - + 10 => { - :authorize => %w(mobile_number acquirer autofee customer_id extras + :authorize => %w(mobile_number acquirer autofee customer_id extras zero_auth customer_ip), :capture => %w( extras ), :cancel => %w( extras ), @@ -148,7 +148,7 @@ module QuickpayCommon :recurring => %w(auto_capture autofee zero_auth) } } - + RESPONSE_CODES = { 200 => 'OK', 201 => 'Created', @@ -163,18 +163,18 @@ module QuickpayCommon 409 => 'Conflict', 500 => 'Internal Server Error' } - + def self.included(base) base.default_currency = 'DKK' base.money_format = :cents - - base.supported_cardtypes = [:dankort, :forbrugsforeningen, :visa, :master, + + base.supported_cardtypes = [:dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro] base.supported_countries = ['DE', 'DK', 'ES', 'FI', 'FR', 'FO', 'GB', 'IS', 'NO', 'SE'] base.homepage_url = 'http://quickpay.net/' base.display_name = 'QuickPay' end - + def expdate(credit_card) year = format(credit_card.year, :two_digits) month = format(credit_card.month, :two_digits) diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb index a43fb085838..810d5cdefaa 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb @@ -6,7 +6,7 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class QuickpayV4to7Gateway < Gateway include QuickpayCommon - self.live_url = self.test_url = 'https://secure.quickpay.dk/api' + self.live_url = self.test_url = 'https://secure.quickpay.dk/api' APPROVED = '000' # The login is the QuickpayId diff --git a/lib/active_merchant/billing/gateways/transax.rb b/lib/active_merchant/billing/gateways/transax.rb index 7411ad573c4..ac462b23763 100644 --- a/lib/active_merchant/billing/gateways/transax.rb +++ b/lib/active_merchant/billing/gateways/transax.rb @@ -4,16 +4,16 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class TransaxGateway < SmartPs self.live_url = self.test_url = 'https://secure.nelixtransax.net/api/transact.php' - + # The countries the gateway supports merchants from as 2 digit ISO country codes self.supported_countries = ['US'] - + # The card types supported by the payment gateway self.supported_cardtypes = [:visa, :master, :american_express, :discover] - + # The homepage URL of the gateway self.homepage_url = 'https://www.nelixtransax.com/' - + # The name of the gateway self.display_name = 'NELiX TransaX' diff --git a/lib/active_merchant/billing/gateways/trexle.rb b/lib/active_merchant/billing/gateways/trexle.rb index f7f98e21766..42451539b2c 100644 --- a/lib/active_merchant/billing/gateways/trexle.rb +++ b/lib/active_merchant/billing/gateways/trexle.rb @@ -154,21 +154,21 @@ def headers(params = {}) result['X-Safe-Card'] = params[:safe_card] if params[:safe_card] result end - + def commit(method, action, params, options) url = "#{test? ? test_url : live_url}/#{action}" raw_response = ssl_request(method, url, post_data(params), headers(options)) parsed_response = parse(raw_response) - success_response(parsed_response) + success_response(parsed_response) rescue ResponseError => e error_response(parse(e.response.body)) rescue JSON::ParserError unparsable_response(raw_response) end - + def success_response(body) return invalid_response unless body['response'] - + response = body['response'] Response.new( true, @@ -195,7 +195,7 @@ def unparsable_response(raw_response) message += " (The raw response returned by the API was #{raw_response.inspect})" return Response.new(false, message) end - + def invalid_response message = 'Invalid response.' return Response.new(false, message) @@ -207,7 +207,7 @@ def token(response) def parse(body) return {} if body.blank? - JSON.parse(body) + JSON.parse(body) end def post_data(parameters = {}) diff --git a/lib/active_merchant/billing/gateways/usa_epay.rb b/lib/active_merchant/billing/gateways/usa_epay.rb index b43e355f61c..0558311bc11 100644 --- a/lib/active_merchant/billing/gateways/usa_epay.rb +++ b/lib/active_merchant/billing/gateways/usa_epay.rb @@ -9,7 +9,7 @@ class UsaEpayGateway < Gateway self.abstract_class = true ## - # Creates an instance of UsaEpayTransactionGateway by default, but if + # Creates an instance of UsaEpayTransactionGateway by default, but if # :software id or :live_url are passed in the options hash it will # create an instance of UsaEpayAdvancedGateway. # diff --git a/test/remote/gateways/remote_beanstream_interac_test.rb b/test/remote/gateways/remote_beanstream_interac_test.rb index 497b0bb744f..4f4d1b9b79e 100644 --- a/test/remote/gateways/remote_beanstream_interac_test.rb +++ b/test/remote/gateways/remote_beanstream_interac_test.rb @@ -1,13 +1,13 @@ require 'test_helper' class RemoteBeanstreamInteracTest < Test::Unit::TestCase - + def setup @gateway = BeanstreamInteracGateway.new(fixtures(:beanstream_interac)) - + @amount = 100 - - @options = { + + @options = { :order_id => generate_unique_id, :billing_address => { :name => 'xiaobo zzz', @@ -27,19 +27,19 @@ def setup :custom => 'reference one' } end - + def test_successful_purchase assert response = @gateway.purchase(@amount, @options) assert_success response assert_equal 'R', response.params['responseType'] assert_false response.redirect.blank? end - + def test_failed_confirmation assert response = @gateway.confirm('') assert_failure response end - + def test_invalid_login gateway = BeanstreamInteracGateway.new( :merchant_id => '', diff --git a/test/remote/gateways/remote_card_save_test.rb b/test/remote/gateways/remote_card_save_test.rb index 23af62ab582..9fe97a8d251 100644 --- a/test/remote/gateways/remote_card_save_test.rb +++ b/test/remote/gateways/remote_card_save_test.rb @@ -1,23 +1,23 @@ require 'test_helper' -class RemoteCardSaveTest < Test::Unit::TestCase +class RemoteCardSaveTest < Test::Unit::TestCase def setup @gateway = CardSaveGateway.new(fixtures(:card_save)) - + @amount = 100 @credit_card = credit_card('4976000000003436', :verification_value => '452') @declined_card = credit_card('4221690000004963', :verification_value => '125') @addresses = {'4976000000003436' => { :name => 'John Watson', :address1 => '32 Edward Street', :city => 'Camborne,', :state => 'Cornwall', :country => 'GB', :zip => 'TR14 8PA' }, '4221690000004963' => { :name => 'Ian Lee', :address1 => '274 Lymington Avenue', :city => 'London', :state => 'London', :country => 'GB', :zip => 'N22 6JN' }} - - @options = { + + @options = { :order_id => '1', :billing_address => @addresses[@credit_card.number], :description => 'Store Purchase' } end - + def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response diff --git a/test/remote/gateways/remote_efsnet_test.rb b/test/remote/gateways/remote_efsnet_test.rb index 052ab40a589..4e6f22499b7 100644 --- a/test/remote/gateways/remote_efsnet_test.rb +++ b/test/remote/gateways/remote_efsnet_test.rb @@ -1,22 +1,22 @@ require 'test_helper' class RemoteEfsnetTest < Test::Unit::TestCase - + def setup Base.mode = :test @gateway = EfsnetGateway.new(fixtures(:efsnet)) - + @credit_card = credit_card('4000100011112224') - + @amount = 100 @declined_amount = 156 - @options = { :order_id => generate_unique_id, + @options = { :order_id => generate_unique_id, :billing_address => address } end - + def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response @@ -45,10 +45,10 @@ def test_unsuccessful_purchase def test_authorize_and_capture amount = @amount assert auth = @gateway.authorize(amount, @credit_card, @options) - assert_success auth + assert_success auth assert_equal 'Approved', auth.message assert auth.authorization - + assert capture = @gateway.capture(amount, auth.authorization, @options) assert_success capture end diff --git a/test/remote/gateways/remote_instapay_test.rb b/test/remote/gateways/remote_instapay_test.rb index 2919d97b98d..5a8286cf234 100644 --- a/test/remote/gateways/remote_instapay_test.rb +++ b/test/remote/gateways/remote_instapay_test.rb @@ -1,7 +1,7 @@ require 'test_helper' class RemoteInstapayTest < Test::Unit::TestCase - + def setup @gateway = InstapayGateway.new(fixtures(:instapay)) @@ -38,22 +38,22 @@ def test_failed_authorization assert response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response end - + def test_authorization_and_capture assert authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization - + assert capture = @gateway.capture(@amount, authorization.authorization) assert_success capture assert_equal InstapayGateway::SUCCESS_MESSAGE, capture.message end - + def test_invalid_login gateway = InstapayGateway.new( :login => 'X', :password => 'Y' ) - + assert response = gateway.purchase(@amount, @credit_card) assert_failure response assert_equal 'Invalid merchant', response.message diff --git a/test/remote/gateways/remote_itransact_test.rb b/test/remote/gateways/remote_itransact_test.rb index 6456398e292..d949b17232d 100644 --- a/test/remote/gateways/remote_itransact_test.rb +++ b/test/remote/gateways/remote_itransact_test.rb @@ -1,22 +1,21 @@ require 'test_helper' class RemoteItransactTest < Test::Unit::TestCase - def setup @gateway = ItransactGateway.new(fixtures(:itransact)) - + @amount = 1065 @credit_card = credit_card('4000100011112224') @declined_card = credit_card('4000300011112220') - - @options = { + + @options = { :order_id => '1', :billing_address => address, :description => 'Store Purchase' } end - + def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response diff --git a/test/remote/gateways/remote_metrics_global_test.rb b/test/remote/gateways/remote_metrics_global_test.rb index b1d19387559..3669fd41a11 100644 --- a/test/remote/gateways/remote_metrics_global_test.rb +++ b/test/remote/gateways/remote_metrics_global_test.rb @@ -3,7 +3,7 @@ class MetricsGlobalTest < Test::Unit::TestCase def setup Base.mode = :test - + @gateway = MetricsGlobalGateway.new(fixtures(:metrics_global)) @amount = 100 @credit_card = credit_card('4111111111111111', :verification_value => '999') @@ -13,7 +13,7 @@ def setup :description => 'Store purchase' } end - + def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response @@ -21,7 +21,7 @@ def test_successful_purchase assert_equal 'This transaction has been approved', response.message assert response.authorization end - + def test_declined_authorization @amount = 10 assert response = @gateway.purchase(@amount, @credit_card, @options) @@ -29,40 +29,40 @@ def test_declined_authorization assert response.test? assert_equal 'This transaction has been declined', response.message end - + def test_successful_authorization assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response assert_equal 'This transaction has been approved', response.message assert response.authorization end - + def test_authorization_and_capture assert authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization - + assert capture = @gateway.capture(@amount, authorization.authorization) assert_success capture assert_equal 'This transaction has been approved', capture.message end - + def test_authorization_and_void assert authorization = @gateway.authorize(@amount, @credit_card, @options) assert_success authorization - + assert void = @gateway.void(authorization.authorization) assert_success void assert_equal 'This transaction has been approved', void.message end - + def test_bad_login gateway = MetricsGlobalGateway.new( :login => 'X', :password => 'Y' ) - + assert response = gateway.purchase(@amount, @credit_card) - + assert_equal Response, response.class assert_equal ['avs_result_code', 'card_code', @@ -72,18 +72,18 @@ def test_bad_login 'transaction_id'], response.params.keys.sort assert_match(/Authentication Failed/, response.message) - + assert_equal false, response.success? end - + def test_using_test_request gateway = MetricsGlobalGateway.new( :login => 'X', :password => 'Y' ) - + assert response = gateway.purchase(@amount, @credit_card) - + assert_equal Response, response.class assert_equal ['avs_result_code', 'card_code', @@ -91,9 +91,9 @@ def test_using_test_request 'response_reason_code', 'response_reason_text', 'transaction_id'], response.params.keys.sort - + assert_match(/Authentication Failed/, response.message) - - assert_equal false, response.success? + + assert_equal false, response.success? end end diff --git a/test/remote/gateways/remote_modern_payments_cim_test.rb b/test/remote/gateways/remote_modern_payments_cim_test.rb index a6afc2b97fe..8c310d0fe17 100644 --- a/test/remote/gateways/remote_modern_payments_cim_test.rb +++ b/test/remote/gateways/remote_modern_payments_cim_test.rb @@ -1,47 +1,46 @@ require 'test_helper' class RemoteModernPaymentsCimTest < Test::Unit::TestCase - def setup @gateway = ModernPaymentsCimGateway.new(fixtures(:modern_payments)) - + @amount = 100 @credit_card = credit_card('4111111111111111') @declined_card = credit_card('4000000000000000') - - @options = { + + @options = { :billing_address => address, :customer => 'JIMSMITH2000' } end - + def test_successful_create_customer response = @gateway.create_customer(@options) assert_success response assert !response.params['create_customer_result'].blank? end - + def test_successful_modify_customer_credit_card customer = @gateway.create_customer(@options) assert_success customer - + customer_id = customer.params['create_customer_result'] - + credit_card = @gateway.modify_customer_credit_card(customer_id, @credit_card) assert_success credit_card assert !credit_card.params['modify_customer_credit_card_result'].blank? end - + def test_succsessful_authorize_credit_card_payment customer = @gateway.create_customer(@options) assert_success customer - + customer_id = customer.params['create_customer_result'] - + credit_card = @gateway.modify_customer_credit_card(customer_id, @credit_card) assert_success credit_card - + payment = @gateway.authorize_credit_card_payment(customer_id, @amount) assert_success payment end diff --git a/test/remote/gateways/remote_pay_secure_test.rb b/test/remote/gateways/remote_pay_secure_test.rb index 8dd8837adc1..ee153752bb9 100644 --- a/test/remote/gateways/remote_pay_secure_test.rb +++ b/test/remote/gateways/remote_pay_secure_test.rb @@ -4,15 +4,15 @@ class RemotePaySecureTest < Test::Unit::TestCase def setup @gateway = PaySecureGateway.new(fixtures(:pay_secure)) - + @credit_card = credit_card('4000100011112224') - @options = { + @options = { :billing_address => address, :order_id => generate_unique_id } @amount = 100 end - + def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response @@ -26,7 +26,7 @@ def test_unsuccessful_purchase assert_equal 'Declined, card expired', response.message assert_failure response end - + def test_invalid_login gateway = PaySecureGateway.new( :login => '', diff --git a/test/remote/gateways/remote_paybox_direct_test.rb b/test/remote/gateways/remote_paybox_direct_test.rb index 8ee4639b8fb..25c03d67804 100644 --- a/test/remote/gateways/remote_paybox_direct_test.rb +++ b/test/remote/gateways/remote_paybox_direct_test.rb @@ -6,18 +6,18 @@ class RemotePayboxDirectTest < Test::Unit::TestCase def setup @gateway = PayboxDirectGateway.new(fixtures(:paybox_direct)) - + @amount = 100 @credit_card = credit_card('1111222233334444') @declined_card = credit_card('1111222233334445') - - @options = { + + @options = { :order_id => '1', :billing_address => address, :description => 'Store Purchase' } end - + def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response @@ -39,7 +39,7 @@ def test_authorize_and_capture assert capture = @gateway.capture(amount, auth.authorization, :order_id => '1') assert_success capture end - + def test_purchase_and_void assert purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase @@ -56,7 +56,7 @@ def test_failed_capture assert_failure response assert_equal 'Invalid data', response.message end - + def test_purchase_and_partial_credit assert purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase @@ -66,7 +66,7 @@ def test_purchase_and_partial_credit assert_equal 'The transaction was approved', credit.message assert_success credit end - + def test_successful_refund assert purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase @@ -84,7 +84,7 @@ def test_partial_refund end def test_failed_refund - refund = @gateway.refund(@amount, '', order_id: '2') + refund = @gateway.refund(@amount, '', order_id: '2') assert_failure refund assert_equal 'Invalid data', refund.message end diff --git a/test/remote/gateways/remote_payflow_express_test.rb b/test/remote/gateways/remote_payflow_express_test.rb index 5c8978d6802..827907d02d9 100644 --- a/test/remote/gateways/remote_payflow_express_test.rb +++ b/test/remote/gateways/remote_payflow_express_test.rb @@ -3,7 +3,7 @@ class RemotePayflowExpressTest < Test::Unit::TestCase def setup Base.mode = :test - + @gateway = PayflowExpressGateway.new(fixtures(:payflow)) @options = { @@ -20,7 +20,7 @@ def setup :email => 'cody@example.com' } end - + # Only works with a Payflow 2.0 account or by requesting the addition # of Express checkout to an existing Payflow Pro account. This can be done # by contacting Payflow sales. The PayPal account used must be a business @@ -37,7 +37,7 @@ def test_set_express_authorization assert response.test? assert !response.params['token'].blank? end - + def test_set_express_purchase @options.update( :return_url => 'http://example.com', diff --git a/test/remote/gateways/remote_payflow_uk_test.rb b/test/remote/gateways/remote_payflow_uk_test.rb index 5242f8f813a..c2aebf853ec 100644 --- a/test/remote/gateways/remote_payflow_uk_test.rb +++ b/test/remote/gateways/remote_payflow_uk_test.rb @@ -6,7 +6,7 @@ def setup # The default partner is PayPalUk @gateway = PayflowUkGateway.new(fixtures(:payflow_uk)) - + @creditcard = CreditCard.new( :number => '5105105105105100', :month => 11, @@ -17,7 +17,7 @@ def setup :brand => 'master' ) - @options = { + @options = { :billing_address => { :name => 'Cody Fauser', :address1 => '1234 Shady Brook Lane', @@ -30,7 +30,7 @@ def setup :email => 'cody@example.com' } end - + def test_successful_purchase assert response = @gateway.purchase(100000, @creditcard, @options) assert_equal 'Approved', response.message @@ -38,14 +38,14 @@ def test_successful_purchase assert response.test? assert_not_nil response.authorization end - + def test_declined_purchase assert response = @gateway.purchase(210000, @creditcard, @options) assert_equal 'Failed merchant rule check', response.message assert_failure response assert response.test? end - + def test_successful_purchase_solo assert response = @gateway.purchase(100000, @solo, @options) assert_equal 'Approved', response.message @@ -53,16 +53,16 @@ def test_successful_purchase_solo assert response.test? assert_not_nil response.authorization end - + def test_no_card_issue_or_card_start_with_switch assert response = @gateway.purchase(100000, @switch, @options) assert_failure response - + assert_equal 'Field format error: CARDSTART or CARDISSUE must be present', response.message assert_failure response assert response.test? end - + def test_successful_purchase_switch_with_issue_number @switch.issue_number = '01' assert response = @gateway.purchase(100000, @switch, @options) @@ -71,7 +71,7 @@ def test_successful_purchase_switch_with_issue_number assert response.test? assert_not_nil response.authorization end - + def test_successful_purchase_switch_with_start_date @switch.start_month = 12 @switch.start_year = 1999 @@ -81,7 +81,7 @@ def test_successful_purchase_switch_with_start_date assert response.test? assert_not_nil response.authorization end - + def test_successful_purchase_switch_with_start_date_and_issue_number @switch.issue_number = '05' @switch.start_month = 12 @@ -92,7 +92,7 @@ def test_successful_purchase_switch_with_start_date_and_issue_number assert response.test? assert_not_nil response.authorization end - + def test_successful_authorization assert response = @gateway.authorize(100, @creditcard, @options) assert_equal 'Approved', response.message @@ -110,13 +110,13 @@ def test_authorize_and_capture assert capture = @gateway.capture(amount, auth.authorization) assert_success capture end - + def test_failed_capture assert response = @gateway.capture(100, '999') assert_failure response assert_equal 'Invalid tender', response.message end - + def test_authorize_and_void assert auth = @gateway.authorize(100, @creditcard, @options) assert_success auth @@ -125,7 +125,7 @@ def test_authorize_and_void assert void = @gateway.void(auth.authorization) assert_success void end - + def test_invalid_login gateway = PayflowGateway.new( :login => '', @@ -135,16 +135,16 @@ def test_invalid_login assert_equal 'Invalid vendor account', response.message assert_failure response end - + def test_duplicate_request_id gateway = PayflowUkGateway.new( :login => @login, :password => @password ) - + request_id = Digest::SHA1.hexdigest(rand.to_s).slice(0,32) gateway.expects(:generate_unique_id).times(2).returns(request_id) - + response1 = gateway.purchase(100, @creditcard, @options) assert_nil response1.params['duplicate'] response2 = gateway.purchase(100, @creditcard, @options) diff --git a/test/remote/gateways/remote_psl_card_test.rb b/test/remote/gateways/remote_psl_card_test.rb index a5ea5c9d6ed..6b1b9e6e215 100644 --- a/test/remote/gateways/remote_psl_card_test.rb +++ b/test/remote/gateways/remote_psl_card_test.rb @@ -1,29 +1,29 @@ require 'test_helper' class RemotePslCardTest < Test::Unit::TestCase - + def setup @gateway = PslCardGateway.new(fixtures(:psl_card)) - + @uk_maestro = CreditCard.new(fixtures(:psl_maestro)) @uk_maestro_address = fixtures(:psl_maestro_address) - + @solo = CreditCard.new(fixtures(:psl_solo)) @solo_address = fixtures(:psl_solo_address) - + @visa = CreditCard.new(fixtures(:psl_visa)) @visa_address = fixtures(:psl_visa_address) - + @visa_debit = CreditCard.new(fixtures(:psl_visa_debit)) @visa_address = fixtures(:psl_visa_debit_address) - + # The test results are determined by the amount of the transaction @accept_amount = 1000 @referred_amount = 6000 @declined_amount = 11000 @keep_card_amount = 15000 end - + def test_successful_visa_purchase response = @gateway.purchase(@accept_amount, @visa, :billing_address => @visa_address @@ -31,14 +31,14 @@ def test_successful_visa_purchase assert_success response assert response.test? end - + def test_successful_visa_debit_purchase response = @gateway.purchase(@accept_amount, @visa_debit, :billing_address => @visa_debit_address ) assert_success response end - + # Fix regression discovered in production def test_visa_debit_purchase_should_not_send_debit_info_if_present @visa_debit.start_month = '07' @@ -47,7 +47,7 @@ def test_visa_debit_purchase_should_not_send_debit_info_if_present ) assert_success response end - + def test_successful_visa_purchase_specifying_currency response = @gateway.purchase(@accept_amount, @visa, :billing_address => @visa_address, @@ -56,67 +56,67 @@ def test_successful_visa_purchase_specifying_currency assert_success response assert response.test? end - + def test_successful_solo_purchase - response = @gateway.purchase(@accept_amount, @solo, + response = @gateway.purchase(@accept_amount, @solo, :billing_address => @solo_address ) assert_success response assert response.test? end - + def test_referred_purchase - response = @gateway.purchase(@referred_amount, @uk_maestro, + response = @gateway.purchase(@referred_amount, @uk_maestro, :billing_address => @uk_maestro_address ) assert_failure response assert response.test? end - + def test_declined_purchase - response = @gateway.purchase(@declined_amount, @uk_maestro, + response = @gateway.purchase(@declined_amount, @uk_maestro, :billing_address => @uk_maestro_address ) assert_failure response assert response.test? end - + def test_declined_keep_card_purchase - response = @gateway.purchase(@keep_card_amount, @uk_maestro, + response = @gateway.purchase(@keep_card_amount, @uk_maestro, :billing_address => @uk_maestro_address ) assert_failure response assert response.test? end - + def test_successful_authorization - response = @gateway.authorize(@accept_amount, @visa, + response = @gateway.authorize(@accept_amount, @visa, :billing_address => @visa_address ) assert_success response assert response.test? end - + def test_no_login @gateway = PslCardGateway.new( :login => '' ) - response = @gateway.authorize(@accept_amount, @uk_maestro, + response = @gateway.authorize(@accept_amount, @uk_maestro, :billing_address => @uk_maestro_address ) assert_failure response assert response.test? end - + def test_successful_authorization_and_capture authorization = @gateway.authorize(@accept_amount, @visa, :billing_address => @visa_address ) assert_success authorization assert authorization.test? - + capture = @gateway.capture(@accept_amount, authorization.authorization) - + assert_success capture assert capture.test? end diff --git a/test/remote/gateways/remote_quantum_test.rb b/test/remote/gateways/remote_quantum_test.rb index dfa3b5682a5..370e802d66c 100644 --- a/test/remote/gateways/remote_quantum_test.rb +++ b/test/remote/gateways/remote_quantum_test.rb @@ -1,15 +1,14 @@ require 'test_helper' class RemoteQuantumTest < Test::Unit::TestCase - def setup @gateway = QuantumGateway.new(fixtures(:quantum)) - + @amount = 100 @credit_card = credit_card('4000100011112224') end - + def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card) assert_success response @@ -53,7 +52,7 @@ def test_void assert response = @gateway.void(response.authorization) assert_success response end - + def test_passing_billing_address options = {:billing_address => address} assert response = @gateway.purchase(@amount, @credit_card, options) diff --git a/test/remote/gateways/remote_sallie_mae_test.rb b/test/remote/gateways/remote_sallie_mae_test.rb index 09f14cb2337..f2b47acef22 100644 --- a/test/remote/gateways/remote_sallie_mae_test.rb +++ b/test/remote/gateways/remote_sallie_mae_test.rb @@ -3,12 +3,12 @@ class RemoteSallieMaeTest < Test::Unit::TestCase def setup @gateway = SallieMaeGateway.new(fixtures(:sallie_mae)) - + @amount = 100 @credit_card = credit_card('5454545454545454') @declined_card = credit_card('4000300011112220') - - @options = { + + @options = { :billing_address => address, :description => 'Store Purchase' } diff --git a/test/remote/gateways/remote_secure_pay_tech_test.rb b/test/remote/gateways/remote_secure_pay_tech_test.rb index 737d2d92280..3b76bf77eef 100644 --- a/test/remote/gateways/remote_secure_pay_tech_test.rb +++ b/test/remote/gateways/remote_secure_pay_tech_test.rb @@ -5,14 +5,14 @@ class RemoteSecurePayTechTest < Test::Unit::TestCase def setup @gateway = SecurePayTechGateway.new(fixtures(:secure_pay_tech)) - + @accepted_amount = 10000 @declined_amount = 10075 - + @credit_card = credit_card('4987654321098769', :month => '5', :year => '2013') @options = { :billing_address => address } end - + def test_successful_purchase assert response = @gateway.purchase(@accepted_amount, @credit_card, @options) assert_equal 'Transaction OK', response.message diff --git a/test/remote/gateways/remote_secure_pay_test.rb b/test/remote/gateways/remote_secure_pay_test.rb index c739e1cc9f4..63f83f5e40b 100644 --- a/test/remote/gateways/remote_secure_pay_test.rb +++ b/test/remote/gateways/remote_secure_pay_test.rb @@ -1,7 +1,7 @@ require 'test_helper' -class RemoteSecurePayTest < Test::Unit::TestCase - +class RemoteSecurePayTest < Test::Unit::TestCase + def setup @gateway = SecurePayGateway.new(fixtures(:secure_pay)) @@ -9,16 +9,16 @@ def setup :month => '7', :year => '2014' ) - + @options = { :order_id => generate_unique_id, :description => 'Store purchase', :billing_address => address } - + @amount = 100 end - + def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert response.success? diff --git a/test/remote/gateways/remote_stripe_emv_test.rb b/test/remote/gateways/remote_stripe_emv_test.rb index 929d05d2cc2..6d2742d7d35 100644 --- a/test/remote/gateways/remote_stripe_emv_test.rb +++ b/test/remote/gateways/remote_stripe_emv_test.rb @@ -22,7 +22,7 @@ def setup # This capture hex says that the payload is a transaction cryptogram (TC) but does not # provide the actual cryptogram. This will only work in test mode and would cause real # cards to be declined. - @capture_options = { icc_data: '9F270140' } + @capture_options = { icc_data: '9F270140' } end # for EMV contact transactions, it's advised to do a separate auth + capture diff --git a/test/remote/gateways/remote_trans_first_test.rb b/test/remote/gateways/remote_trans_first_test.rb index 3b19be25327..3423954560e 100644 --- a/test/remote/gateways/remote_trans_first_test.rb +++ b/test/remote/gateways/remote_trans_first_test.rb @@ -78,7 +78,7 @@ def test_successful_void assert_success void end - # Refunds can only be successfully run on settled transactions which take 24 hours + # Refunds can only be successfully run on settled transactions which take 24 hours # def test_successful_refund # assert purchase = @gateway.purchase(@amount, @credit_card, @options) # assert_success purchase diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb index f2045dcd4e1..894b07c440e 100644 --- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb +++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb @@ -45,7 +45,7 @@ def test_successful_purchase assert_equal 'Street address does not match, but 5-digit postal code matches.', response.avs_result['message'] assert_equal 'CVV matches', response.cvv_result['message'] end - + def test_successful_purchase_no_avs options = @options.dup options[:shipping_address] = nil diff --git a/test/remote/gateways/remote_trexle_test.rb b/test/remote/gateways/remote_trexle_test.rb index cd8f5360315..149a8530797 100644 --- a/test/remote/gateways/remote_trexle_test.rb +++ b/test/remote/gateways/remote_trexle_test.rb @@ -163,7 +163,7 @@ def test_transcript_scrubbing @gateway.purchase(@amount, @credit_card, @options) end clean_transcript = @gateway.scrub(transcript) - + assert_scrubbed(@credit_card.number, clean_transcript) assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript) end diff --git a/test/remote/gateways/remote_trust_commerce_test.rb b/test/remote/gateways/remote_trust_commerce_test.rb index 8fd3215f4f1..576fde7292a 100644 --- a/test/remote/gateways/remote_trust_commerce_test.rb +++ b/test/remote/gateways/remote_trust_commerce_test.rb @@ -156,7 +156,7 @@ def test_transcript_scrubbing @gateway.purchase(@amount, @credit_card, @options) end clean_transcript = @gateway.scrub(transcript) - + assert_scrubbed(@credit_card.number, clean_transcript) assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript) end diff --git a/test/remote/gateways/remote_viaklix_test.rb b/test/remote/gateways/remote_viaklix_test.rb index 952d3a62a43..c3dc47c1a43 100644 --- a/test/remote/gateways/remote_viaklix_test.rb +++ b/test/remote/gateways/remote_viaklix_test.rb @@ -3,40 +3,40 @@ class RemoteViaklixTest < Test::Unit::TestCase def setup @gateway = ViaklixGateway.new(fixtures(:viaklix)) - - @credit_card = credit_card + + @credit_card = credit_card @bad_credit_card = credit_card('invalid') - + @options = { :order_id => '#1000.1', - :email => 'paul@domain.com', + :email => 'paul@domain.com', :description => 'Test Transaction', :billing_address => address } @amount = 100 end - + def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) - + assert_success response assert response.test? assert_equal 'APPROVED', response.message assert response.authorization end - + def test_failed_purchase assert response = @gateway.purchase(@amount, @bad_credit_card, @options) - + assert_failure response assert response.test? assert_equal 'The Credit Card Number supplied in the authorization request appears invalid.', response.message end - + def test_credit assert purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase - + assert credit = @gateway.credit(@amount, @credit_card) assert_success credit end diff --git a/test/unit/cvv_result_test.rb b/test/unit/cvv_result_test.rb index ac44bdf24b1..282fc97c8a6 100644 --- a/test/unit/cvv_result_test.rb +++ b/test/unit/cvv_result_test.rb @@ -6,25 +6,25 @@ def test_nil_data assert_nil result.code assert_nil result.message end - + def test_blank_data result = CVVResult.new('') assert_nil result.code assert_nil result.message end - + def test_successful_match result = CVVResult.new('M') assert_equal 'M', result.code assert_equal CVVResult.messages['M'], result.message end - + def test_failed_match result = CVVResult.new('N') assert_equal 'N', result.code assert_equal CVVResult.messages['N'], result.message end - + def test_to_hash result = CVVResult.new('M').to_hash assert_equal 'M', result['code'] diff --git a/test/unit/expiry_date_test.rb b/test/unit/expiry_date_test.rb index 25e2e22bc0b..07a44b26c15 100644 --- a/test/unit/expiry_date_test.rb +++ b/test/unit/expiry_date_test.rb @@ -6,24 +6,24 @@ def test_should_be_expired date = CreditCard::ExpiryDate.new(last_month.month, last_month.year) assert date.expired? end - + def test_today_should_not_be_expired today = Time.now.utc date = CreditCard::ExpiryDate.new(today.month, today.year) assert_false date.expired? end - + def test_dates_in_the_future_should_not_be_expired next_month = 1.month.from_now date = CreditCard::ExpiryDate.new(next_month.month, next_month.year) assert_false date.expired? end - + def test_invalid_date expiry = CreditCard::ExpiryDate.new(13, 2009) assert_equal Time.at(0).utc, expiry.expiration end - + def test_month_and_year_coerced_to_integer expiry = CreditCard::ExpiryDate.new('13', '2009') assert_equal 13, expiry.month diff --git a/test/unit/gateways/beanstream_interac_test.rb b/test/unit/gateways/beanstream_interac_test.rb index c1158396746..a0a7bac3862 100644 --- a/test/unit/gateways/beanstream_interac_test.rb +++ b/test/unit/gateways/beanstream_interac_test.rb @@ -8,14 +8,14 @@ def setup ) @amount = 100 - - @options = { + + @options = { :order_id => '1', :billing_address => address, :description => 'Store Purchase' } end - + def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) response = @gateway.purchase(@amount, @options) @@ -25,7 +25,7 @@ def test_successful_purchase assert response.params['pageContents'] assert_equal response.params['pageContents'], response.redirect end - + def test_successful_confirmation @gateway.expects(:ssl_post).returns(successful_confirmation_response) @@ -36,15 +36,15 @@ def test_successful_confirmation end private - + def successful_purchase_response 'responseType=R&pageContents=%3CHTML%3E%3CHEAD%3E%3C%2FHEAD%3E%3CBODY%3E%3CFORM%20action%3D%22https%3A%2F%2Fpayments%2Ebeanstream%2Ecom%2FiOnlineEmulator%2Fgateway%2Easp%22%20method%3DPOST%20id%3DfrmIOnline%20name%3DfrmIOnline%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHNUM%22%20%20value%3D%2210010162199999%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FAMOUNT%22%20%20value%3D%221500%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FTERMID%22%20value%3D%2262199999%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FCURRENCY%22%20value%3D%22CAD%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FINVOICE%22%20value%3D%221be7db7a129b07ac5f7e%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHDATA%22%20value%3D%226CE36AF7%2D5013%2D4B94%2DB740153714A41962%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FFUNDEDURL%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%5Fauth%2Easp%3F%26funded%3D1%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FNOTFUNDEDURL%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%5Fauth%2Easp%3F%26funded%3D0%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22merchant%5Fname%22%20value%3D%22Cody%20Fauser%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%2Easp%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost2%22%20value%3D%22https%3A%2F%2Fwww%2Ecatnrose%2Ecom%2Fioxml%2Easp%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost3%22%20value%3D%22%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHLANG%22%20value%3D%22en%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FVERSION%22%20value%3D%221%22%3E%3C%2FFORM%3E%3CSCRIPT%20language%3D%22JavaScript%22%3Edocument%2EfrmIOnline%2Esubmit%28%29%3B%3C%2FSCRIPT%3E%3C%2FBODY%3E%3C%2FHTML%3E' end - + def successful_return_from_interac_online 'bank_choice=1&merchant_name=Billing+Boss+IO+SB&confirmValue=&headerText=&IDEBIT_MERCHDATA=C4B50A48-6E11-4C21-A31EF4A602BC0099&IDEBIT_INVOICE=18face21593b59c7bb7e&IDEBIT_AMOUNT=1500&IDEBIT_FUNDEDURL=http%3A%2F%2Febay.massapparel.com%3A8000%2Finterac%2Ffunded%3Ffunded%3D1&IDEBIT_NOTFUNDEDURL=http%3A%2F%2Febay.massapparel.com%3A8000%2Finterac%2Fnotfunded%3Ffunded%3D0&IDEBIT_ISSLANG=en&IDEBIT_TRACK2=3728024906540591214%3D12010123456789XYZ&IDEBIT_ISSCONF=CONF%23TEST&IDEBIT_ISSNAME=TestBank1&IDEBIT_VERSION=1&accountType=Chequing' end - + def successful_confirmation_response 'trnApproved=1&trnId=10000029&messageId=1&messageText=Approved&trnOrderNumber=f29d2406b49b239b6dfb5db1f642b2&authCode=TEST&errorType=N&errorFields=&responseType=T&trnAmount=5%2E00&trnDate=6%2F8%2F2008+3%3A17%3A12+PM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+for+this+transaction%2E&trnType=P&paymentMethod=IO&ioConfCode=CONF%23TEST&ioInstName=TestBank1&ref1=reference+one&ref2=&ref3=&ref4=&ref5=' end diff --git a/test/unit/gateways/cecabank_test.rb b/test/unit/gateways/cecabank_test.rb index 3ed551400fe..f58aa10e620 100644 --- a/test/unit/gateways/cecabank_test.rb +++ b/test/unit/gateways/cecabank_test.rb @@ -72,7 +72,7 @@ def test_unsuccessful_refund_request assert_failure response assert response.test? end - + def test_transcript_scrubbing assert_equal scrubbed_transcript, @gateway.scrub(transcript) end diff --git a/test/unit/gateways/federated_canada_test.rb b/test/unit/gateways/federated_canada_test.rb index 0e9497ae03c..cad64a37f16 100644 --- a/test/unit/gateways/federated_canada_test.rb +++ b/test/unit/gateways/federated_canada_test.rb @@ -11,13 +11,13 @@ def setup @credit_card.verification_value = '999' @amount = 100 - @options = { + @options = { :order_id => '1', :billing_address => address, :description => 'Store Purchase' } end - + def test_successful_authorization @gateway.expects(:ssl_post).returns(successful_authorization_response) options = {:billing_address => {:address1 => '888', :address2 => 'apt 13', :country => 'CA', :state => 'SK', :city => 'Big Beaver', :zip => '77777'}} @@ -26,18 +26,18 @@ def test_successful_authorization assert_success response assert_equal '1355694937', response.authorization assert_equal 'auth', response.params['type'] - end - + end + def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response assert_success response assert_equal '1346648416', response.authorization - assert_equal 'sale', response.params['type'] + assert_equal 'sale', response.params['type'] assert response.test? end - + def test_unsuccessful_request @gateway.expects(:ssl_post).returns(failed_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) @@ -51,7 +51,7 @@ def test_add_address assert_equal ['address1', 'address2', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort assert_equal 'SK', result[:state] assert_equal '123 Happy Town Road', result[:address1] - assert_equal 'apt 13', result[:address2] + assert_equal 'apt 13', result[:address2] assert_equal 'CA', result[:country] end @@ -61,15 +61,15 @@ def test_add_invoice assert_equal '#1001', result[:orderid] assert_equal 'This is a great order', result[:orderdescription] end - + def test_purchase_is_valid_csv params = {:amount => @amount} @gateway.send(:add_creditcard, params, @credit_card) assert data = @gateway.send(:post_data, 'auth', params) assert_equal post_data_fixture.size, data.size - end - + end + def test_purchase_meets_minimum_requirements params = {:amount => @amount} @gateway.send(:add_creditcard, params, @credit_card) @@ -78,7 +78,7 @@ def test_purchase_meets_minimum_requirements assert_not_nil(data.include?(key)) end end - + def test_expdate_formatting assert_equal '0909', @gateway.send(:expdate, credit_card('4111111111111111', :month => '9', :year => '2009')) assert_equal '0711', @gateway.send(:expdate, credit_card('4111111111111111', :month => '7', :year => '2011')) @@ -103,7 +103,7 @@ def test_cvv_result response = @gateway.purchase(@amount, @credit_card) assert_equal 'M', response.cvv_result['code'] end - + def test_amount assert_equal '1.00', @gateway.send(:amount, 100) assert_equal '10.00', @gateway.send(:amount, 1000) @@ -111,17 +111,17 @@ def test_amount @gateway.send(:amount, '10.00') end end - + private - + def post_data_fixture 'password=password&type=auth&ccnumber=4111111111111111&username=demo&ccexp=1111&amount=100&cvv=999' end - + def minimum_requirements %w{type username password amount ccnumber ccexp} end - + # Raw successful authorization response def successful_authorization_response 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1355694937&avsresponse=Y&cvvresponse=M&orderid=&type=auth&response_code=100' @@ -131,7 +131,7 @@ def successful_authorization_response def successful_purchase_response 'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1346648416&avsresponse=N&cvvresponse=N&orderid=&type=sale&response_code=100' end - + # Raw failed sale response def failed_purchase_response 'response=2&responsetext=DECLINE&authcode=&transactionid=1346648595&avsresponse=N&cvvresponse=N&orderid=&type=sale&response_code=200' diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb index 8ad5d5a1c02..4424d29d787 100644 --- a/test/unit/gateways/global_collect_test.rb +++ b/test/unit/gateways/global_collect_test.rb @@ -216,7 +216,7 @@ def test_invalid_raw_response response = stub_comms do @gateway.purchase(@accepted_amount, @credit_card, @options) end.respond_with(invalid_json_response) - + assert_failure response assert_match %r{^Invalid response received from the Ingenico ePayments}, response.message end @@ -230,7 +230,7 @@ def test_scrub_invalid_response response = stub_comms do @gateway.purchase(@accepted_amount, @credit_card, @options) end.respond_with(invalid_json_plus_card_data).message - + assert_equal @gateway.scrub(response), scrubbed_invalid_json_plus end @@ -393,22 +393,22 @@ def failed_verify_response end def invalid_json_response - '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> - <html><head> - <title>502 Proxy Error</title> - </head><body> - <h1>Proxy Error</h1> - <p>The proxy server received an invalid - response from an upstream server.<br /> - The proxy server could not handle the request <em><a href="/v1/9040/payments">POST&nbsp;/v1/9040/payments</a></em>.<p> - Reason: <strong>Error reading from remote server</strong></p></p> + '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> + <html><head> + <title>502 Proxy Error</title> + </head><body> + <h1>Proxy Error</h1> + <p>The proxy server received an invalid + response from an upstream server.<br /> + The proxy server could not handle the request <em><a href="/v1/9040/payments">POST&nbsp;/v1/9040/payments</a></em>.<p> + Reason: <strong>Error reading from remote server</strong></p></p> </body></html>' end def invalid_json_plus_card_data - %q(<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> - <html><head> - <title>502 Proxy Error</title> + %q(<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> + <html><head> + <title>502 Proxy Error</title> </head></html> opening connection to api-sandbox.globalcollect.com:443... opened @@ -429,6 +429,6 @@ def invalid_json_plus_card_data end def scrubbed_invalid_json_plus - "Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message. (The raw response returned by the API was \"<!DOCTYPE HTML PUBLIC \\\"-//IETF//DTD HTML 2.0//EN\\\"> \\n <html><head> \\n <title>502 Proxy Error</title> \\n </head></html>\\n opening connection to api-sandbox.globalcollect.com:443...\\n opened\\n starting SSL for api-sandbox.globalcollect.com:443...\\n SSL established\\n <- \\\"POST //v1/1428/payments HTTP/1.1\\\\r\\\\nContent-Type: application/json\\\\r\\\\nAuthorization: [FILTERED]\\\\r\\\\nDate: Tue, 15 Mar 2016 14:32:13 GMT\\\\r\\\\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\\\\r\\\\nAccept: */*\\\\r\\\\nUser-Agent: Ruby\\\\r\\\\nConnection: close\\\\r\\\\nHost: api-sandbox.globalcollect.com\\\\r\\\\nContent-Length: 560\\\\r\\\\n\\\\r\\\\n\\\"\\n <- \\\"{\\\\\\\"order\\\\\\\":{\\\\\\\"amountOfMoney\\\\\\\":{\\\\\\\"amount\\\\\\\":\\\\\\\"100\\\\\\\",\\\\\\\"currencyCode\\\\\\\":\\\\\\\"USD\\\\\\\"},\\\\\\\"customer\\\\\\\":{\\\\\\\"merchantCustomerId\\\\\\\":null,\\\\\\\"personalInformation\\\\\\\":{\\\\\\\"name\\\\\\\":{\\\\\\\"firstName\\\\\\\":null,\\\\\\\"surname\\\\\\\":null}},\\\\\\\"billingAddress\\\\\\\":{\\\\\\\"street\\\\\\\":\\\\\\\"456 My Street\\\\\\\",\\\\\\\"additionalInfo\\\\\\\":\\\\\\\"Apt 1\\\\\\\",\\\\\\\"zip\\\\\\\":\\\\\\\"K1C2N6\\\\\\\",\\\\\\\"city\\\\\\\":\\\\\\\"Ottawa\\\\\\\",\\\\\\\"state\\\\\\\":\\\\\\\"ON\\\\\\\",\\\\\\\"countryCode\\\\\\\":\\\\\\\"CA\\\\\\\"}},\\\\\\\"contactDetails\\\\\\\":{\\\\\\\"emailAddress\\\\\\\":null}},\\\\\\\"cardPaymentMethodSpecificInput\\\\\\\":{\\\\\\\"paymentProductId\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"skipAuthentication\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"skipFraudService\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"card\\\\\\\":{\\\\\\\"cvv\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"cardNumber\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"expiryDate\\\\\\\":\\\\\\\"0917\\\\\\\",\\\\\\\"cardholderName\\\\\\\":\\\\\\\"Longbob Longsen\\\\\\\"}}}\\\"\\n -> \\\"HTTP/1.1 201 Created\\\\r\\\\n\\\"\\n -> \\\"Date: Tue, 15 Mar 2016 18:32:14 GMT\\\\r\\\\n\\\"\\n -> \\\"Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1p\\\\r\\\\n\\\"\\n -> \\\"Location: https://api-sandbox.globalcollect.com:443/v1/1428/payments/000000142800000000300000100001\\\\r\\\\n\\\"\\n -> \\\"X-Powered-By: Servlet/3.0 JSP/2.2\\\\r\\\\n\\\"\\n -> \\\"Connection: close\\\\r\\\\n\\\"\\n -> \\\"Transfer-Encoding: chunked\\\\r\\\\n\\\"\\n -> \\\"Content-Type: application/json\\\\r\\\\n\\\"\\n -> \\\"\\\\r\\\\n\\\"\\n -> \\\"457\\\\r\\\\n\\\"\")" + "Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message. (The raw response returned by the API was \"<!DOCTYPE HTML PUBLIC \\\"-//IETF//DTD HTML 2.0//EN\\\">\\n <html><head>\\n <title>502 Proxy Error</title>\\n </head></html>\\n opening connection to api-sandbox.globalcollect.com:443...\\n opened\\n starting SSL for api-sandbox.globalcollect.com:443...\\n SSL established\\n <- \\\"POST //v1/1428/payments HTTP/1.1\\\\r\\\\nContent-Type: application/json\\\\r\\\\nAuthorization: [FILTERED]\\\\r\\\\nDate: Tue, 15 Mar 2016 14:32:13 GMT\\\\r\\\\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\\\\r\\\\nAccept: */*\\\\r\\\\nUser-Agent: Ruby\\\\r\\\\nConnection: close\\\\r\\\\nHost: api-sandbox.globalcollect.com\\\\r\\\\nContent-Length: 560\\\\r\\\\n\\\\r\\\\n\\\"\\n <- \\\"{\\\\\\\"order\\\\\\\":{\\\\\\\"amountOfMoney\\\\\\\":{\\\\\\\"amount\\\\\\\":\\\\\\\"100\\\\\\\",\\\\\\\"currencyCode\\\\\\\":\\\\\\\"USD\\\\\\\"},\\\\\\\"customer\\\\\\\":{\\\\\\\"merchantCustomerId\\\\\\\":null,\\\\\\\"personalInformation\\\\\\\":{\\\\\\\"name\\\\\\\":{\\\\\\\"firstName\\\\\\\":null,\\\\\\\"surname\\\\\\\":null}},\\\\\\\"billingAddress\\\\\\\":{\\\\\\\"street\\\\\\\":\\\\\\\"456 My Street\\\\\\\",\\\\\\\"additionalInfo\\\\\\\":\\\\\\\"Apt 1\\\\\\\",\\\\\\\"zip\\\\\\\":\\\\\\\"K1C2N6\\\\\\\",\\\\\\\"city\\\\\\\":\\\\\\\"Ottawa\\\\\\\",\\\\\\\"state\\\\\\\":\\\\\\\"ON\\\\\\\",\\\\\\\"countryCode\\\\\\\":\\\\\\\"CA\\\\\\\"}},\\\\\\\"contactDetails\\\\\\\":{\\\\\\\"emailAddress\\\\\\\":null}},\\\\\\\"cardPaymentMethodSpecificInput\\\\\\\":{\\\\\\\"paymentProductId\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"skipAuthentication\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"skipFraudService\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"card\\\\\\\":{\\\\\\\"cvv\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"cardNumber\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"expiryDate\\\\\\\":\\\\\\\"0917\\\\\\\",\\\\\\\"cardholderName\\\\\\\":\\\\\\\"Longbob Longsen\\\\\\\"}}}\\\"\\n -> \\\"HTTP/1.1 201 Created\\\\r\\\\n\\\"\\n -> \\\"Date: Tue, 15 Mar 2016 18:32:14 GMT\\\\r\\\\n\\\"\\n -> \\\"Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1p\\\\r\\\\n\\\"\\n -> \\\"Location: https://api-sandbox.globalcollect.com:443/v1/1428/payments/000000142800000000300000100001\\\\r\\\\n\\\"\\n -> \\\"X-Powered-By: Servlet/3.0 JSP/2.2\\\\r\\\\n\\\"\\n -> \\\"Connection: close\\\\r\\\\n\\\"\\n -> \\\"Transfer-Encoding: chunked\\\\r\\\\n\\\"\\n -> \\\"Content-Type: application/json\\\\r\\\\n\\\"\\n -> \\\"\\\\r\\\\n\\\"\\n -> \\\"457\\\\r\\\\n\\\"\")" end end diff --git a/test/unit/gateways/instapay_test.rb b/test/unit/gateways/instapay_test.rb index 16880aab17f..d70c9c52f72 100644 --- a/test/unit/gateways/instapay_test.rb +++ b/test/unit/gateways/instapay_test.rb @@ -42,31 +42,31 @@ def test_unsuccessful_auth assert_failure response assert_nil response.authorization end - + def test_avs_result @gateway.expects(:ssl_post).returns(successful_purchase_response) - + response = @gateway.purchase(@amount, @credit_card) assert_equal 'X', response.avs_result['code'] end - + def test_cvv_result @gateway.expects(:ssl_post).returns(successful_purchase_response) - + response = @gateway.purchase(@amount, @credit_card) assert_equal 'M', response.cvv_result['code'] end - + def test_successful_capture @gateway.expects(:ssl_post).returns(successful_capture_response) - + response = @gateway.capture(100, '123456') assert_equal InstapayGateway::SUCCESS_MESSAGE, response.message end - + def test_failed_capture @gateway.expects(:ssl_post).returns(failed_capture_response) - + response = @gateway.capture(100, '123456') assert_equal 'Post amount exceeds Auth amount', response.message end @@ -82,7 +82,7 @@ def successful_purchase_response def failed_purchase_response "<html><body><plaintext>\r\nDeclined=DECLINED:0720930009:CVV2 MISMATCH:N7\r\nhistoryid=118583848\r\norderid=92886713\r\nACCOUNTNUMBER=************2220\r\nDeclined=DECLINED:0720930009:CVV2 MISMATCH:N7\r\nhistoryid=118583848\r\norderid=92886713\r\nrcode=0720930009\r\nReason=DECLINED:0720930009:CVV2 MISMATCH:N7\r\nrecurid=0\r\nresult=0\r\nStatus=Declined\r\ntransid=80410586\r\n" end - + def successful_auth_response "<html><body><plaintext>\r\nAccepted=AUTH:TEST:::118585994:::\r\nhistoryid=118585994\r\norderid=92888143\r\nAccepted=AUTH:TEST:::118585994:::\r\nACCOUNTNUMBER=************5454\r\nauthcode=TEST\r\nAuthNo=AUTH:TEST:::118585994:::\r\nhistoryid=118585994\r\norderid=92888143\r\nrecurid=0\r\nrefcode=118585994-TEST\r\nresult=1\r\nStatus=Accepted\r\ntransid=0\r\n" end @@ -90,11 +90,11 @@ def successful_auth_response def failed_auth_response "<html><body><plaintext>\r\nDeclined=DECLINED:0720930009:CVV2 MISMATCH:N7\r\nhistoryid=118585991\r\norderid=92888142\r\nACCOUNTNUMBER=************2220\r\nDeclined=DECLINED:0720930009:CVV2 MISMATCH:N7\r\nhistoryid=118585991\r\norderid=92888142\r\nrcode=0720930009\r\nReason=DECLINED:0720930009:CVV2 MISMATCH:N7\r\nrecurid=0\r\nresult=0\r\nStatus=Declined\r\ntransid=80412271\r\n" end - + def successful_capture_response "<html><body><plaintext>\r\nAccepted=AVSAUTH:TEST:::121609962::::DUPLICATE\r\nhistoryid=121609962\r\norderid=95009583\r\nAccepted=AVSAUTH:TEST:::121609962::::DUPLICATE\r\nACCOUNTNUMBER=************5454\r\nauthcode=TEST\r\nAuthNo=AVSAUTH:TEST:::121609962::::DUPLICATE\r\nDUPLICATE=1\r\nhistoryid=121609962\r\norderid=95009583\r\nrecurid=0\r\nrefcode=121609962-TEST\r\nresult=1\r\nStatus=Accepted\r\ntransid=0\r\n" end - + def failed_capture_response "<html><body><plaintext>\r\nDeclined=DECLINED:1101450002:Post amount exceeds Auth amount:\r\nhistoryid=\r\norderid=\r\nDeclined=DECLINED:1101450002:Post amount exceeds Auth amount:\r\nrcode=1101450002\r\nReason=DECLINED:1101450002:Post amount exceeds Auth amount:\r\nresult=0\r\nStatus=Declined\r\ntransid=0\r\n" end diff --git a/test/unit/gateways/itransact_test.rb b/test/unit/gateways/itransact_test.rb index e1fe37ef8e3..5f43bfc702f 100644 --- a/test/unit/gateways/itransact_test.rb +++ b/test/unit/gateways/itransact_test.rb @@ -11,8 +11,8 @@ def setup @credit_card = credit_card @check = check @amount = 1014 # = $10.14 - - @options = { + + @options = { :email => 'name@domain.com', :order_id => '1', :billing_address => address, @@ -20,14 +20,14 @@ def setup :email_text => ['line1', 'line2', 'line3'] } end - + def test_successful_card_purchase @gateway.expects(:ssl_post).returns(successful_card_purchase_response) - + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response assert_success response - + assert_equal '9999999999', response.authorization assert response.test? end @@ -45,19 +45,19 @@ def test_successful_check_purchase def test_unsuccessful_card_request @gateway.expects(:ssl_post).returns(failed_purchase_response) - + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response assert response.test? end private - + def successful_card_purchase_response "<?xml version=\"1.0\" standalone=\"yes\"?> <GatewayInterface><TransactionResponse><TransactionResult><Status>ok</Status><ErrorCategory></ErrorCategory><ErrorMessage></ErrorMessage><WarningMessage></WarningMessage><AuthCode></AuthCode><AVSCategory></AVSCategory><AVSResponse></AVSResponse><CVV2Response></CVV2Response><TimeStamp>20081216141214</TimeStamp><TestMode>TRUE</TestMode><Total>1.0</Total><XID>9999999999</XID><CustomerData><BillingAddress><Address1>1234 My Street</Address1><City>Ottawa</City><FirstName>Longbob</FirstName><LastName>Longsen</LastName><State>ON</State><Zip>K1C2N6</Zip><Country>CA</Country><Phone>(555)555-5555</Phone></BillingAddress><ShippingAddress><Address1></Address1><City></City><FirstName></FirstName><LastName></LastName><State></State><Zip></Zip><Country></Country><Phone></Phone></ShippingAddress></CustomerData></TransactionResult></TransactionResponse></GatewayInterface>" end - + def failed_purchase_response '<?xml version="1.0" standalone="yes"?> <GatewayInterface><TransactionResponse><TransactionResult><Status>FAILED</Status><ErrorCategory>REQUEST_FORMAT</ErrorCategory><ErrorMessage>Form does not contain xml parameter</ErrorMessage><AuthCode></AuthCode><AVSCategory></AVSCategory><AVSResponse></AVSResponse><CVV2Response></CVV2Response><TimeStamp></TimeStamp><TestMode></TestMode><Total></Total><XID></XID><CustomerData><BillingAddress><Address1 /><City></City><FirstName></FirstName><LastName></LastName><State></State><Zip></Zip><Country></Country><Phone></Phone></BillingAddress><ShippingAddress><Address1></Address1><City></City><FirstName></FirstName><LastName></LastName><State></State><Zip></Zip><Country></Country><Phone></Phone></ShippingAddress></CustomerData></TransactionResult></TransactionResponse></GatewayInterface>' diff --git a/test/unit/gateways/mundipagg_test.rb b/test/unit/gateways/mundipagg_test.rb index f8fe08779cb..7caa206f0d0 100644 --- a/test/unit/gateways/mundipagg_test.rb +++ b/test/unit/gateways/mundipagg_test.rb @@ -712,7 +712,7 @@ def successful_void_response def failed_void_response '{"message": "Charge not found."}' end - + def successful_verify_response %( { diff --git a/test/unit/gateways/pay_secure_test.rb b/test/unit/gateways/pay_secure_test.rb index 32ba6132b64..a49bf1a60f0 100644 --- a/test/unit/gateways/pay_secure_test.rb +++ b/test/unit/gateways/pay_secure_test.rb @@ -1,7 +1,7 @@ require 'test_helper' class PaySecureTest < Test::Unit::TestCase - + def setup @gateway = PaySecureGateway.new( :login => 'login', @@ -9,14 +9,14 @@ def setup ) @credit_card = credit_card - @options = { + @options = { :order_id => '1000', :billing_address => address, :description => 'Test purchase' } @amount = 100 end - + def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) @@ -25,7 +25,7 @@ def test_successful_purchase assert_equal '2778;SimProxy 54041670', response.authorization assert response.test? end - + def test_failed_purchase @gateway.expects(:ssl_post).returns(failure_response) assert response = @gateway.purchase(@amount, @credit_card, @options) @@ -33,21 +33,21 @@ def test_failed_purchase assert_equal "Field value '8f796cb29a1be32af5ce12d4ca7425c2' does not match required format.", response.message assert_failure response end - + def test_avs_result_not_supported @gateway.expects(:ssl_post).returns(successful_purchase_response) - - response = @gateway.purchase(@amount, @credit_card, @options) + + response = @gateway.purchase(@amount, @credit_card, @options) assert_nil response.avs_result['code'] end - + def test_cvv_result_not_supported @gateway.expects(:ssl_post).returns(successful_purchase_response) - + response = @gateway.purchase(@amount, @credit_card, @options) assert_nil response.cvv_result['code'] end - + private def successful_purchase_response @@ -61,7 +61,7 @@ def successful_purchase_response TransID: SimProxy 54041670 RESPONSE end - + def failure_response <<-RESPONSE Status: Declined diff --git a/test/unit/gateways/payflow_uk_test.rb b/test/unit/gateways/payflow_uk_test.rb index e7adc1b7fd9..9d50c599edd 100644 --- a/test/unit/gateways/payflow_uk_test.rb +++ b/test/unit/gateways/payflow_uk_test.rb @@ -11,19 +11,19 @@ def setup def test_default_currency assert_equal 'GBP', PayflowUkGateway.default_currency end - + def test_express_instance assert_instance_of PayflowExpressUkGateway, @gateway.express end - + def test_default_partner assert_equal 'PayPalUk', PayflowUkGateway.partner end - + def test_supported_countries assert_equal ['GB'], PayflowUkGateway.supported_countries end - + def test_supported_card_types assert_equal [:visa, :master, :american_express, :discover], PayflowUkGateway.supported_cardtypes end diff --git a/test/unit/gateways/psl_card_test.rb b/test/unit/gateways/psl_card_test.rb index 9ef1a651b84..6a971d1815e 100644 --- a/test/unit/gateways/psl_card_test.rb +++ b/test/unit/gateways/psl_card_test.rb @@ -8,14 +8,14 @@ def setup :password => 'PASSWORD' ) - @credit_card = credit_card + @credit_card = credit_card @options = { :billing_address => address, :description => 'Store purchase' } @amount = 100 end - + def test_successful_authorization @gateway.expects(:ssl_post).returns(successful_purchase_response) assert response = @gateway.authorize(@amount, @credit_card, @options) @@ -34,15 +34,15 @@ def test_unsuccessful_request def test_supported_countries assert_equal ['GB'], PslCardGateway.supported_countries end - + def test_supported_card_types assert_equal [ :visa, :master, :american_express, :diners_club, :jcb, :maestro ], PslCardGateway.supported_cardtypes end - + def test_avs_result @gateway.expects(:ssl_post).returns(successful_purchase_response) - response = @gateway.purchase(@amount, @credit_card, @options) + response = @gateway.purchase(@amount, @credit_card, @options) assert_equal 'Y', response.avs_result['code'] end @@ -52,13 +52,13 @@ def test_cvv_result response = @gateway.purchase(@amount, @credit_card, @options) assert_equal 'M', response.cvv_result['code'] end - + private def successful_purchase_response 'ResponseCode=00&Message=AUTHCODE:01256&CrossReference=08012522454901256086&First4=4543&Last4=9982&ExpMonth=12&ExpYear=2010&AVSCV2Check=ALL MATCH&Amount=1000&QAAddress=76 Roseby Avenue Manchester&QAPostcode=M63X 7TH&MerchantName=Merchant Name&QAName=John Smith' end - + def unsuccessful_purchase_response 'ResponseCode=05&Message=CARD DECLINED&QAAddress=The Parkway Larches Approach Hull North Humberside&QAPostcode=HU7 9OP&MerchantName=Merchant Name&QAName=' end diff --git a/test/unit/gateways/quantum_test.rb b/test/unit/gateways/quantum_test.rb index a1d771cd8b0..10bb11ccaf4 100644 --- a/test/unit/gateways/quantum_test.rb +++ b/test/unit/gateways/quantum_test.rb @@ -9,19 +9,19 @@ def setup @credit_card = credit_card @amount = 100 - - @options = { + + @options = { :billing_address => address, :description => 'Store Purchase' } end - + def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) - + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - + # Replace with authorization number from the successful response assert_equal '2983691;2224', response.authorization assert response.test? @@ -29,14 +29,14 @@ def test_successful_purchase def test_unsuccessful_request @gateway.expects(:ssl_post).returns(failed_purchase_response) - + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response assert response.test? end - + private - + # Place raw successful response from gateway here def successful_purchase_response %(<QGWRequest> @@ -74,7 +74,7 @@ def successful_purchase_response </Result> </QGWRequest>) end - + # Place raw failed response from gateway here def failed_purchase_response %(<QGWRequest> diff --git a/test/unit/gateways/quickpay_test.rb b/test/unit/gateways/quickpay_test.rb index 98bb37cb941..f9f2e2d28cd 100644 --- a/test/unit/gateways/quickpay_test.rb +++ b/test/unit/gateways/quickpay_test.rb @@ -1,21 +1,21 @@ require 'test_helper' class QuickpayTest < Test::Unit::TestCase - + def test_error_without_login_option assert_raise ArgumentError do QuickpayGateway.new end end - + def test_v4to7 - gateway = QuickpayGateway.new(:login => 50000000, :password => 'secret') + gateway = QuickpayGateway.new(:login => 50000000, :password => 'secret') assert_instance_of QuickpayV4to7Gateway, gateway end - + def test_v10 - gateway = QuickpayGateway.new(:login => 100, :api_key => 'APIKEY') + gateway = QuickpayGateway.new(:login => 100, :api_key => 'APIKEY') assert_instance_of QuickpayV10Gateway, gateway end - + end diff --git a/test/unit/gateways/quickpay_v4to7_test.rb b/test/unit/gateways/quickpay_v4to7_test.rb index a01c4b5315c..74e395980ca 100644 --- a/test/unit/gateways/quickpay_v4to7_test.rb +++ b/test/unit/gateways/quickpay_v4to7_test.rb @@ -2,11 +2,11 @@ class QuickpayV4to7Test < Test::Unit::TestCase include CommStub - + def merchant_id - '80000000000' + '80000000000' end - + def setup @gateway = QuickpayGateway.new( :login => merchant_id, diff --git a/test/unit/gateways/secure_pay_tech_test.rb b/test/unit/gateways/secure_pay_tech_test.rb index 90847f8e9d6..87293a7f817 100644 --- a/test/unit/gateways/secure_pay_tech_test.rb +++ b/test/unit/gateways/secure_pay_tech_test.rb @@ -13,32 +13,32 @@ def setup :billing_address => address } end - + def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) - + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response assert_success response assert response.test? assert_equal '4--120119220646821', response.authorization end - + def test_unsuccessful_purchase @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response) - + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response assert_failure response assert response.test? end - + private def successful_purchase_response "1,4--120119220646821,000000014511,23284,014511,20080125\r\n" end - + def unsuccessful_purchase_response "4,4--120119180936527,000000014510,23283,014510,20080125\r\n" end diff --git a/test/unit/gateways/trexle_test.rb b/test/unit/gateways/trexle_test.rb index 288ca190d21..5ce9da270f2 100644 --- a/test/unit/gateways/trexle_test.rb +++ b/test/unit/gateways/trexle_test.rb @@ -42,7 +42,7 @@ def test_supported_countries GI GR HK HU ID IE IL IM IN IS IT JO KW LB LI LK LT LU LV MC MT MU MV MX MY NL NO NZ OM PH PL PT QA RO SA SE SG SI SK SM TR TT UM US VA VN ZA) - assert_equal expected_supported_countries, TrexleGateway.supported_countries + assert_equal expected_supported_countries, TrexleGateway.supported_countries end def test_supported_cardtypes @@ -302,8 +302,8 @@ def test_transcript_scrubbing private def successful_purchase_response - '{ - "response":{ + '{ + "response":{ "token":"charge_0cfad7ee5ffe75f58222bff214bfa5cc7ad7c367", "success":true, "captured":true @@ -312,17 +312,17 @@ def successful_purchase_response end def failed_purchase_response - '{ + '{ "error":"Payment failed", "detail":"An error occurred while processing your card. Try again in a little bit." }' end def successful_store_response - '{ - "response":{ + '{ + "response":{ "token":"token_2cb443cf26b6ecdadd8144d1fac8240710aa41f1", - "card":{ + "card":{ "token":"token_f974687e4e866d6cca534e1cd42236817d315b3a", "primary":true } @@ -331,17 +331,17 @@ def successful_store_response end def failed_store_response - '{ + '{ "error":"an error has occured", "detail":"invalid token" }' end def successful_customer_store_response - '{ - "response":{ + '{ + "response":{ "token":"token_940ade441a23d53e04017f53af6c3a1eae9978ae", - "card":{ + "card":{ "token":"token_9a3f559962cbf6828e2cc38a02023565b0294548", "scheme":"master", "display_number":"XXXX-XXXX-XXXX-4444", @@ -362,15 +362,15 @@ def successful_customer_store_response end def failed_customer_store_response - '{ + '{ "error":"an error has occured", "detail":"invalid token" }' end def successful_refund_response - '{ - "response":{ + '{ + "response":{ "token":"refund_7f696a86f9cb136520c51ea90c17f687b8df40b0", "success":true, "amount":100, @@ -381,15 +381,15 @@ def successful_refund_response end def failed_refund_response - '{ + '{ "error":"Refund failed", "detail":"invalid token" }' end def successful_capture_response - '{ - "response":{ + '{ + "response":{ "token":"charge_6e47a330dca67ec7f696e8b650db22fe69bb8499", "success":true, "captured":true diff --git a/test/unit/gateways/viaklix_test.rb b/test/unit/gateways/viaklix_test.rb index 6b624676452..ef288b6b652 100644 --- a/test/unit/gateways/viaklix_test.rb +++ b/test/unit/gateways/viaklix_test.rb @@ -7,8 +7,8 @@ def setup :login => 'LOGIN', :password => 'PIN' ) - - @credit_card = credit_card + + @credit_card = credit_card @options = { :order_id => '37', :email => 'paul@domain.com', @@ -17,10 +17,10 @@ def setup } @amount = 100 end - - def test_purchase_success + + def test_purchase_success @gateway.expects(:ssl_post).returns(successful_purchase_response) - + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response assert_success response @@ -29,46 +29,46 @@ def test_purchase_success def test_purchase_error @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response) - + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response assert_failure response end - + def test_invalid_login @gateway.expects(:ssl_post).returns(invalid_login_response) - + assert response = @gateway.purchase(@amount, @credit_card, @options) - + assert_equal '7000', response.params['result'] assert_equal 'The viaKLIX ID and/or User ID supplied in the authorization request is invalid.', response.params['result_message'] assert_failure response end - + def test_avs_result @gateway.expects(:ssl_post).returns(successful_purchase_response) - + response = @gateway.purchase(@amount, @credit_card) assert_equal 'Y', response.avs_result['code'] end - + def test_cvv_result @gateway.expects(:ssl_post).returns(successful_purchase_response) - + response = @gateway.purchase(@amount, @credit_card) assert_equal 'M', response.cvv_result['code'] end - + private - + def successful_purchase_response "ssl_result=0\r\nssl_company=;\r\nssl_city=Herndon\r\nssl_avs_zip=90201\r\nssl_address2=\r\nssl_ship_to_last_name=Jacobs\r\nssl_ship_to_city=Herndon\r\nssl_approval_code=05737D\r\nssl_avs_response=Y\r\nssl_salestax=\r\nssl_ship_to_phone=\r\ncustomer_code=jacobsr1@cox.net\r\nship_to_country=US\r\ncountry=US\r\nssl_txn_id=7E2419F7-2354-4766-BF5C-19C75A1F379A\r\nssl_transaction_type=SALE\r\nssl_invoice_number=#1158.1\r\nssl_amount=243.95\r\nssl_card_number=43*******6820\r\nssl_description=\r\nssl_phone=703-404-9270\r\nssl_ship_to_avs_address=\r\nssl_first_name=Cody\r\nssl_avs_address=12213 Jonathons Glen Way\r\nssl_result_message=APPROVED\r\nssl_exp_date=1109\r\nssl_last_name=Fauser\r\nssl_ship_to_first_name=Robert\r\nssl_ship_to_address2=\r\nssl_ship_to_state=VA\r\nssl_ship_to_avs_zip=\r\nssl_cvv2_response=M\r\nssl_state=VA\r\nssl_email=cody@example.com\r\nssl_ship_to_company=\r\n" end - + def unsuccessful_purchase_response "ssl_result=1\r\nssl_result_message=This transaction request has not been approved. You may elect to use another form of payment to complete this transaction or contact customer service for additional options." end - + def invalid_login_response <<-RESPONSE ssl_result=7000\r From 4796e86750781e7d870134a7f4292948bc115710 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 23 Oct 2018 11:31:32 -0400 Subject: [PATCH 588/677] Revert "Mercado Pago: do not infer card type" This reverts commit d9c5a1a011263c5677e7d0dc084d5fc2d16193ff. This reversion is almost certainly temporary, but we were seeing higher-than-expected inference errors when this went to production, so we're temporarily going to pull this until we know what's up. --- .../billing/gateways/mercado_pago.rb | 10 ++++- test/unit/gateways/mercado_pago_test.rb | 38 ++++++++++--------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index 51aafc8f457..3c841fccc53 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -10,6 +10,11 @@ class MercadoPagoGateway < Gateway self.display_name = 'Mercado Pago' self.money_format = :dollars + CARD_BRAND = { + 'american_express' => 'amex', + 'diners_club' => 'diners' + } + def initialize(options={}) requires!(options, :access_token) super @@ -18,6 +23,7 @@ def initialize(options={}) def purchase(money, payment, options={}) MultiResponse.run do |r| r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) } + options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand)) options.merge!(card_token: r.authorization.split('|').first) r.process { commit('purchase', 'payments', purchase_request(money, payment, options) ) } end @@ -26,6 +32,7 @@ def purchase(money, payment, options={}) def authorize(money, payment, options={}) MultiResponse.run do |r| r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) } + options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand)) options.merge!(card_token: r.authorization.split('|').first) r.process { commit('authorize', 'payments', authorize_request(money, payment, options) ) } end @@ -174,8 +181,7 @@ def add_invoice(post, money, options) def add_payment(post, options) post[:token] = options[:card_token] - post[:issuer_id] = options[:issuer_id] if options[:issuer_id] - post[:payment_method_id] = options[:payment_method_id] if options[:payment_method_id] + post[:payment_method_id] = options[:card_brand] end def parse(body) diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb index 1e53016dde3..7b29e5252c8 100644 --- a/test/unit/gateways/mercado_pago_test.rb +++ b/test/unit/gateways/mercado_pago_test.rb @@ -149,14 +149,14 @@ def test_scrub assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed end - def test_does_not_send_brand + def test_sends_american_express_as_amex credit_card = credit_card('378282246310005', brand: 'american_express') response = stub_comms do @gateway.purchase(@amount, credit_card, @options) end.check_request do |endpoint, data, headers| if endpoint =~ /payments/ - assert_not_match(%r("payment_method_id":"amex"), data) + assert_match(%r("payment_method_id":"amex"), data) end end.respond_with(successful_purchase_response) @@ -164,11 +164,11 @@ def test_does_not_send_brand assert_equal '4141491|1.0', response.authorization end - def test_sends_payment_method_id - credit_card = credit_card('30569309025904') + def test_sends_diners_club_as_diners + credit_card = credit_card('30569309025904', brand: 'diners_club') response = stub_comms do - @gateway.purchase(@amount, credit_card, @options.merge(payment_method_id: 'diners')) + @gateway.purchase(@amount, credit_card, @options) end.check_request do |endpoint, data, headers| if endpoint =~ /payments/ assert_match(%r("payment_method_id":"diners"), data) @@ -179,6 +179,21 @@ def test_sends_payment_method_id assert_equal '4141491|1.0', response.authorization end + def test_sends_mastercard_as_master + credit_card = credit_card('5555555555554444', brand: 'master') + + response = stub_comms do + @gateway.purchase(@amount, credit_card, @options) + end.check_request do |endpoint, data, headers| + if endpoint =~ /payments/ + assert_match(%r("payment_method_id":"master"), data) + end + end.respond_with(successful_purchase_response) + + assert_success response + assert_equal '4141491|1.0', response.authorization + end + def test_includes_deviceid_header @options[:device_id] = '1a2b3c' @gateway.expects(:ssl_post).with(anything, anything, headers = {'Content-Type' => 'application/json'}).returns(successful_purchase_response) @@ -202,19 +217,6 @@ def test_includes_additional_data assert_success response end - def test_includes_issuer_id - response = stub_comms do - @gateway.purchase(@amount, @credit_card, @options.merge(issuer_id: '1a2b3c4d')) - end.check_request do |endpoint, data, headers| - if endpoint =~ /payments/ - assert_match(%r("issuer_id":"1a2b3c4d"), data) - end - end.respond_with(successful_purchase_response) - - assert_success response - assert_equal '4141491|1.0', response.authorization - end - private def pre_scrubbed From 8e230ded182d3ff109d7617ecf9e21efc6811ef3 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 23 Oct 2018 13:35:13 -0400 Subject: [PATCH 589/677] Authorize.Net: Pass some level 3 fields This enables passing of some of the Level 3/III data and lineItem fields for transactions that support them. Also fixes some changelog formatting. Remote: 69 tests, 238 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 95 tests, 558 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 13 +++-- .../billing/gateways/authorize_net.rb | 12 ++++ .../gateways/remote_authorize_net_test.rb | 53 ++++++++++++++---- test/unit/gateways/authorize_net_test.rb | 55 +++++++++++++++++++ 4 files changed, 117 insertions(+), 16 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a80da434731..314de3945ad 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,19 +1,20 @@ = ActiveMerchant CHANGELOG == HEAD -* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] [#3002] -* Global Collect: handle internal server errors [molbrown] [#3005] +* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002 +* Global Collect: handle internal server errors [molbrown] #3005 * Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009 * RuboCop: AlignHash [nfarve] #3004 * Beanstream: Switch `recurringPayment` flag from boolean to integer [dtykocki] #3011 -* Payflow Express: Add phone to returned Response [filipebarcos] [#3003] +* Payflow Express: Add phone to returned Response [filipebarcos] #3003 +* Authorize.Net: Pass some level 3 fields [curiousepic] #3022 == Version 1.85.0 (September 28, 2018) -* Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001] +* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 == Version 1.84.0 (September 27, 2018) * PayU Latam: support partial captures [bpollack] #2974 -* Braintree: Reflect correct test mode in Braintree responses [elfassy] [#2980] +* Braintree: Reflect correct test mode in Braintree responses [elfassy] #2980 * FirstPay: Expose error code [curiousepic] #2979 * Barclaycard Smartpay: Pass device_fingerprint when specified [dtykocki] #2981 * Komoju: remove no-longer-relevant sandbox URL [miyazawadegica] #2987 @@ -39,7 +40,7 @@ * Gateway generator: fix a typo that would cause the script to crash [bpollack] #2962 * Clearhaus: use $0 for verify transactions [bpollack] #2964 * Global Collect: properly handle partial captures [bpollack] #2967 -* Braintree: Add support for GooglePay [dtykocki] [#2966] +* Braintree: Add support for GooglePay [dtykocki] #2966 * Adyen: allow overriding card brands [bpollack] #2968 * Adyen: allow custom routing [bpollack] #2969 * First Pay: Adds scrubbing [deedeelavinder] #2972 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index 0c4c4c0c8a0..75fa6c6fdd1 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -257,6 +257,7 @@ def add_auth_purchase(xml, transaction_type, amount, payment, options) add_market_type_device_type(xml, payment, options) add_settings(xml, payment, options) add_user_fields(xml, amount, options) + add_ship_from_address(xml, options) end end @@ -610,6 +611,16 @@ def add_shipping_address(xml, options, root_node='shipTo') end end + def add_ship_from_address(xml, options, root_node='shipFrom') + address = options[:ship_from_address] + return unless address + + xml.send(root_node) do + xml.zip(truncate(address[:zip], 20)) unless empty?(address[:zip]) + xml.country(truncate(address[:country], 60)) unless empty?(address[:country]) + end + end + def add_order_id(xml, options) xml.refId(truncate(options[:order_id], 20)) end @@ -619,6 +630,7 @@ def add_invoice(xml, transaction_type, options) xml.invoiceNumber(truncate(options[:order_id], 20)) xml.description(truncate(options[:description], 255)) xml.purchaseOrderNumber(options[:po_number]) if options[:po_number] && transaction_type.start_with?('profileTrans') + xml.summaryCommodityCode(truncate(options[:summary_commodity_code], 4)) if options[:summary_commodity_code] && !transaction_type.start_with?('profileTrans') end # Authorize.net API requires lineItems to be placed directly after order tag diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb index 034e0f92cc8..2b239ad18bb 100644 --- a/test/remote/gateways/remote_authorize_net_test.rb +++ b/test/remote/gateways/remote_authorize_net_test.rb @@ -36,6 +36,16 @@ def setup tax_exempt: 'false', po_number: '123' } + + @level_3_options = { + ship_from_address: { + zip: '27701', + country: 'US' + }, + summary_commodity_code: 'CODE' + } + + @level_2_and_3_options = @level_2_options.merge(@level_3_options) end def test_successful_purchase @@ -105,8 +115,31 @@ def test_successful_purchase_with_line_items assert response.authorization end - def test_successful_purchase_with_level_2_data - response = @gateway.purchase(@amount, @credit_card, @options.merge(@level_2_options)) + def test_successful_purchase_with_level_3_line_item_data + additional_options = { + email: 'anet@example.com', + line_items: [ + { + item_id: '1', + name: 'mug', + description: 'coffee', + quantity: '100', + unit_price: '10', + unit_of_measure: 'yards', + total_amount: '1000', + product_code: 'coupon' + } + ] + } + response = @gateway.purchase(@amount, @credit_card, @options.merge(additional_options)) + assert_success response + assert response.test? + assert_equal 'This transaction has been approved', response.message + assert response.authorization + end + + def test_successful_purchase_with_level_2_and_3_data + response = @gateway.purchase(@amount, @credit_card, @options.merge(@level_2_and_3_options)) assert_success response assert_equal 'This transaction has been approved', response.message end @@ -361,11 +394,11 @@ def test_successful_purchase_using_stored_card_new_payment_profile assert_equal 'This transaction has been approved.', response.message end - def test_successful_purchase_with_stored_card_and_level_2_data + def test_successful_purchase_with_stored_card_and_level_2_and_3_data store_response = @gateway.store(@credit_card, @options) assert_success store_response - response = @gateway.purchase(@amount, store_response.authorization, @options.merge(@level_2_options)) + response = @gateway.purchase(@amount, store_response.authorization, @options.merge(@level_2_and_3_options)) assert_success response assert_equal 'This transaction has been approved.', response.message end @@ -383,15 +416,15 @@ def test_successful_authorize_and_capture_using_stored_card assert_equal 'This transaction has been approved.', capture.message end - def test_successful_authorize_and_capture_using_stored_card_with_level_2_data + def test_successful_authorize_and_capture_using_stored_card_with_level_2_and_3_data store = @gateway.store(@credit_card, @options) assert_success store - auth = @gateway.authorize(@amount, store.authorization, @options.merge(@level_2_options)) + auth = @gateway.authorize(@amount, store.authorization, @options.merge(@level_2_and_3_options)) assert_success auth assert_equal 'This transaction has been approved.', auth.message - capture = @gateway.capture(@amount, auth.authorization, @options.merge(@level_2_options)) + capture = @gateway.capture(@amount, auth.authorization, @options.merge(@level_2_and_3_options)) assert_success capture assert_equal 'This transaction has been approved.', capture.message end @@ -467,14 +500,14 @@ def test_faux_successful_refund_using_stored_card assert_match %r{does not meet the criteria for issuing a credit}, refund.message, 'Only allowed to refund transactions that have settled. This is the best we can do for now testing wise.' end - def test_faux_successful_refund_using_stored_card_and_level_2_data + def test_faux_successful_refund_using_stored_card_and_level_2_and_3_data store = @gateway.store(@credit_card, @options) assert_success store - purchase = @gateway.purchase(@amount, store.authorization, @options.merge(@level_2_options)) + purchase = @gateway.purchase(@amount, store.authorization, @options.merge(@level_2_and_3_options)) assert_success purchase - refund = @gateway.refund(@amount, purchase.authorization, @options.merge(@level_2_options)) + refund = @gateway.refund(@amount, purchase.authorization, @options.merge(@level_2_and_3_options)) assert_failure refund assert_match %r{does not meet the criteria for issuing a credit}, refund.message, 'Only allowed to refund transactions that have settled. This is the best we can do for now testing wise.' end diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 358124ae04f..813c26dfaaf 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -29,6 +29,14 @@ def setup description: 'Store Purchase' } + @level_3_options = { + ship_from_address: { + zip: 'origin27701', + country: 'originUS' + }, + summary_commodity_code: 'CODE' + } + @additional_options = { line_items: [ { @@ -47,6 +55,21 @@ def setup } ] } + + @level_3_line_item_options = { + line_items: [ + { + item_id: '1', + name: 'mug', + description: 'coffee', + quantity: '100', + unit_price: '10', + unit_of_measure: 'yards', + total_amount: '1000', + product_code: 'coupon' + } + ] + } end def test_add_swipe_data_with_bad_data @@ -326,6 +349,20 @@ def test_passes_header_email_receipt end.respond_with(successful_purchase_response) end + def test_passes_level_3_options + stub_comms do + @gateway.purchase(@amount, credit_card, @options.merge(@level_3_options)) + end.check_request do |endpoint, data, headers| + assert_match(/<order>/, data) + assert_match(/<summaryCommodityCode>#{@level_3_options[:summary_commodity_code]}<\/summaryCommodityCode>/, data) + assert_match(/<\/order>/, data) + assert_match(/<shipFrom>/, data) + assert_match(/<zip>#{@level_3_options[:ship_from_address][:zip]}<\/zip>/, data) + assert_match(/<country>#{@level_3_options[:ship_from_address][:country]}<\/country>/, data) + assert_match(/<\/shipFrom>/, data) + end.respond_with(successful_purchase_response) + end + def test_passes_line_items stub_comms do @gateway.purchase(@amount, credit_card, @options.merge(@additional_options)) @@ -347,6 +384,24 @@ def test_passes_line_items end.respond_with(successful_purchase_response) end + def test_passes_level_3_line_items + stub_comms do + @gateway.purchase(@amount, credit_card, @options.merge(@level_3_line_item_options)) + end.check_request do |endpoint, data, headers| + assert_match(/<lineItems>/, data) + assert_match(/<lineItem>/, data) + assert_match(/<itemId>#{@level_3_line_item_options[:line_items][0][:item_id]}<\/itemId>/, data) + assert_match(/<name>#{@level_3_line_item_options[:line_items][0][:name]}<\/name>/, data) + assert_match(/<description>#{@level_3_line_item_options[:line_items][0][:description]}<\/description>/, data) + assert_match(/<quantity>#{@level_3_line_item_options[:line_items][0][:quantity]}<\/quantity>/, data) + assert_match(/<unitPrice>#{@level_3_line_item_options[:line_items][0][:unit_price]}<\/unitPrice>/, data) + assert_match(/<unitOfMeasure>#{@level_3_line_item_options[:line_items][0][:unit_of_measure]}<\/unitOfMeasure>/, data) + assert_match(/<totalAmount>#{@level_3_line_item_options[:line_items][0][:total_amount]}<\/totalAmount>/, data) + assert_match(/<productCode>#{@level_3_line_item_options[:line_items][0][:product_code]}<\/productCode>/, data) + assert_match(/<\/lineItems>/, data) + end.respond_with(successful_purchase_response) + end + def test_failed_purchase @gateway.expects(:ssl_post).returns(failed_purchase_response) From 8a1c77a0d7bf25ea3efadaf9a3564ec6bf18a7f5 Mon Sep 17 00:00:00 2001 From: Jonathan Girard Viau <am00620@ens.etsmtl.ca> Date: Fri, 26 Oct 2018 11:01:11 -0400 Subject: [PATCH 590/677] Add state to the netbanx payload (#3024) This field is needed for certain transaction that could get declined because of the gateway "Risk Management department" --- lib/active_merchant/billing/gateways/netbanx.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/active_merchant/billing/gateways/netbanx.rb b/lib/active_merchant/billing/gateways/netbanx.rb index 444723f66ff..8afb50bfb66 100644 --- a/lib/active_merchant/billing/gateways/netbanx.rb +++ b/lib/active_merchant/billing/gateways/netbanx.rb @@ -165,9 +165,10 @@ def map_address(address) return {} if address.nil? country = Country.find(address[:country]) if address[:country] mapped = { - :street => address[:address1], - :city => address[:city], - :zip => address[:zip], + :street => address[:address1], + :city => address[:city], + :zip => address[:zip], + :state => address[:state], } mapped.merge!({:country => country.code(:alpha2).value}) unless country.blank? From 9a1e62fab0fc3c24bf68a47bd48f48cc012bb873 Mon Sep 17 00:00:00 2001 From: "Jonathan G.V" <jonathan.girardviau@shopify.com> Date: Fri, 26 Oct 2018 11:41:22 -0400 Subject: [PATCH 591/677] Release v1.86.0 --- CHANGELOG | 4 ++++ lib/active_merchant/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 314de3945ad..b80a96427f4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,13 +1,17 @@ = ActiveMerchant CHANGELOG == HEAD +== Version 1.86.0 (October 26, 2018) * UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002 * Global Collect: handle internal server errors [molbrown] #3005 * Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009 * RuboCop: AlignHash [nfarve] #3004 * Beanstream: Switch `recurringPayment` flag from boolean to integer [dtykocki] #3011 +* Update Swipe HQ endpoint [bdewater] #3013 +* Braintree: Adds device_data [deedeelavinder] #3012 * Payflow Express: Add phone to returned Response [filipebarcos] #3003 * Authorize.Net: Pass some level 3 fields [curiousepic] #3022 +* Add state to the netbanx payload [Girardvjonathan] #3024 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 6f6f680ff1c..813ed5dbdd2 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = '1.85.0' + VERSION = '1.86.0' end From cc816a671f6433c260dc850d95f23befe15bcb80 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@bitquabit.com> Date: Tue, 23 Oct 2018 14:12:56 -0400 Subject: [PATCH 592/677] RuboCop: fix Lint/EmptyWhen --- .rubocop_todo.yml | 5 ----- lib/active_merchant/billing/gateways/usa_epay_advanced.rb | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1841c4a0842..cd0b907b06a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -266,11 +266,6 @@ Lint/DuplicateMethods: - 'test/remote/gateways/remote_netaxept_test.rb' - 'test/remote/gateways/remote_verifi_test.rb' -# Offense count: 1 -Lint/EmptyWhen: - Exclude: - - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' - # Offense count: 3 Lint/FormatParameterMismatch: Exclude: diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb index 2f756c0979e..bf38626368a 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb @@ -1386,7 +1386,8 @@ def build_transaction_request_object(soap, options, name='Params') build_tag soap, v[0], v[1], options[k] end case - when options[:payment_method] == nil + when options[:payment_method].nil? + nil when options[:payment_method].kind_of?(ActiveMerchant::Billing::CreditCard) build_credit_card_data soap, options when options[:payment_method].kind_of?(ActiveMerchant::Billing::Check) From 4abd2f0db48a6314ab16906525efb34f8b7e6bc5 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@bitquabit.com> Date: Tue, 23 Oct 2018 14:20:41 -0400 Subject: [PATCH 593/677] Remove unused variables --- .../billing/gateways/borgun.rb | 1 - .../billing/gateways/element.rb | 4 ++-- .../billing/gateways/realex.rb | 19 +++++++++---------- test/unit/gateways/paypal_test.rb | 6 +++--- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb index c6bf5612262..3705be21163 100644 --- a/lib/active_merchant/billing/gateways/borgun.rb +++ b/lib/active_merchant/billing/gateways/borgun.rb @@ -130,7 +130,6 @@ def commit(action, post) post[:Processor] = @options[:processor] post[:MerchantID] = @options[:merchant_id] - url = (test? ? test_url : live_url) request = build_request(action, post) raw = ssl_post(url(action), request, headers) pairs = parse(raw) diff --git a/lib/active_merchant/billing/gateways/element.rb b/lib/active_merchant/billing/gateways/element.rb index 248626e5802..419fdd6e843 100644 --- a/lib/active_merchant/billing/gateways/element.rb +++ b/lib/active_merchant/billing/gateways/element.rb @@ -334,9 +334,9 @@ def payment_account_type(payment) def url(action) if action == 'PaymentAccountCreate' - url = (test? ? SERVICE_TEST_URL : SERVICE_LIVE_URL) + test? ? SERVICE_TEST_URL : SERVICE_LIVE_URL else - url = (test? ? test_url : live_url) + test? ? test_url : live_url end end diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index cb97ac7bb87..c44ed00d11d 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -286,26 +286,25 @@ def expiry_date(credit_card) end def message_from(response) - message = nil case response[:result] when '00' - message = SUCCESS + SUCCESS when '101' - message = response[:message] + esponse[:message] when '102', '103' - message = DECLINED + DECLINED when /^2[0-9][0-9]/ - message = BANK_ERROR + BANK_ERROR when /^3[0-9][0-9]/ - message = REALEX_ERROR + REALEX_ERROR when /^5[0-9][0-9]/ - message = response[:message] + response[:message] when '600', '601', '603' - message = ERROR + ERROR when '666' - message = CLIENT_DEACTIVATED + CLIENT_DEACTIVATED else - message = DECLINED + DECLINED end end diff --git a/test/unit/gateways/paypal_test.rb b/test/unit/gateways/paypal_test.rb index 1b129b30330..a9ae07cbfc4 100644 --- a/test/unit/gateways/paypal_test.rb +++ b/test/unit/gateways/paypal_test.rb @@ -474,20 +474,20 @@ def test_bill_outstanding_amoung_response end def test_mass_pay_transfer_recipient_types - response = stub_comms do + stub_comms do @gateway.transfer 1000, 'fred@example.com' end.check_request do |endpoint, data, headers| assert_no_match %r{ReceiverType}, data end.respond_with(successful_purchase_response) - response = stub_comms do + stub_comms do @gateway.transfer 1000, 'fred@example.com', :receiver_type => 'EmailAddress' end.check_request do |endpoint, data, headers| assert_match %r{<ReceiverType>EmailAddress</ReceiverType>}, data assert_match %r{<ReceiverEmail>fred@example\.com</ReceiverEmail>}, data end.respond_with(successful_purchase_response) - response = stub_comms do + stub_comms do @gateway.transfer 1000, 'fred@example.com', :receiver_type => 'UserID' end.check_request do |endpoint, data, headers| assert_match %r{<ReceiverType>UserID</ReceiverType>}, data From c4781e20c14de87dbfa6731d1314f0c1531fb7ce Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@bitquabit.com> Date: Tue, 23 Oct 2018 14:24:06 -0400 Subject: [PATCH 594/677] Remove script markers from files that aren't scripts --- .rubocop_todo.yml | 8 -------- lib/active_merchant/billing/avs_result.rb | 1 - lib/active_merchant/billing/gateways/skip_jack.rb | 1 - test/test_helper.rb | 1 - 4 files changed, 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cd0b907b06a..88855c21a7b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -299,14 +299,6 @@ Lint/RescueException: Exclude: - 'lib/active_merchant/billing/gateways/quantum.rb' -# Offense count: 3 -# Cop supports --auto-correct. -Lint/ScriptPermission: - Exclude: - - 'lib/active_merchant/billing/avs_result.rb' - - 'lib/active_merchant/billing/gateways/skip_jack.rb' - - 'test/test_helper.rb' - # Offense count: 11 # Cop supports --auto-correct. Lint/StringConversionInInterpolation: diff --git a/lib/active_merchant/billing/avs_result.rb b/lib/active_merchant/billing/avs_result.rb index 7324daef438..b21017eaa2f 100644 --- a/lib/active_merchant/billing/avs_result.rb +++ b/lib/active_merchant/billing/avs_result.rb @@ -1,4 +1,3 @@ -#!ruby19 # encoding: utf-8 module ActiveMerchant diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb index 563a169ba8d..d3da3bea486 100644 --- a/lib/active_merchant/billing/gateways/skip_jack.rb +++ b/lib/active_merchant/billing/gateways/skip_jack.rb @@ -1,4 +1,3 @@ -#!ruby19 # encoding: utf-8 module ActiveMerchant #:nodoc: diff --git a/test/test_helper.rb b/test/test_helper.rb index dbfeb798930..7400150f5cc 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,4 +1,3 @@ -#!/usr/bin/env ruby $:.unshift File.expand_path('../../lib', __FILE__) require 'bundler/setup' From 03274b2688fc959f60eb99f02e2eb933a348af73 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@bitquabit.com> Date: Tue, 23 Oct 2018 14:30:54 -0400 Subject: [PATCH 595/677] Fix confusing/ineffective access modifier --- .rubocop_todo.yml | 5 ----- lib/active_merchant/network_connection_retries.rb | 14 ++++++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 88855c21a7b..f20729eaff9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -277,11 +277,6 @@ Lint/HandleExceptions: - 'lib/active_merchant/billing/gateways/mastercard.rb' - 'lib/active_merchant/billing/gateways/trust_commerce.rb' -# Offense count: 1 -Lint/IneffectiveAccessModifier: - Exclude: - - 'lib/active_merchant/network_connection_retries.rb' - # Offense count: 1 Lint/NestedMethodDefinition: Exclude: diff --git a/lib/active_merchant/network_connection_retries.rb b/lib/active_merchant/network_connection_retries.rb index 0bce98f7619..e23d7e5adf5 100644 --- a/lib/active_merchant/network_connection_retries.rb +++ b/lib/active_merchant/network_connection_retries.rb @@ -36,6 +36,12 @@ def retry_exceptions(options={}) end end + def self.log(logger, level, message, tag=nil) + tag ||= self.class.to_s + message = "[#{tag}] #{message}" + logger&.send(level, message) + end + private def retry_network_exceptions(options = {}) @@ -62,14 +68,6 @@ def retry_network_exceptions(options = {}) end end - def self.log(logger, level, message, tag=nil) - tag ||= self.class.to_s - message = "[#{tag}] #{message}" - logger&.send(level, message) - end - - private - def log_with_retry_details(logger, attempts, time, message, tag) NetworkConnectionRetries.log(logger, :info, 'connection_attempt=%d connection_request_time=%.4fs connection_msg="%s"' % [attempts, time, message], tag) end From 16a77e0907e27e8aa599a8cdd49bf27764e83881 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@bitquabit.com> Date: Thu, 25 Oct 2018 08:52:08 -0400 Subject: [PATCH 596/677] RuboCop: fix Lint/UselessAssignment Note that this fixes some ACTUAL BUGS IN THE CODE; it's not purely a formatting change. There were several instances of the wrong variable getting used, a test not actually doing anything, etc. --- .rubocop_todo.yml | 4 ---- .../billing/gateways/global_collect.rb | 1 - lib/active_merchant/billing/gateways/qbms.rb | 2 +- lib/active_merchant/billing/gateways/realex.rb | 2 +- lib/active_merchant/billing/gateways/redsys.rb | 2 +- lib/active_merchant/billing/gateways/skip_jack.rb | 2 +- .../billing/gateways/worldpay_online_payments.rb | 2 +- lib/active_merchant/network_connection_retries.rb | 2 +- lib/support/gateway_support.rb | 2 +- .../remote/gateways/remote_authorize_net_cim_test.rb | 10 +++++----- test/remote/gateways/remote_beanstream_test.rb | 2 +- test/remote/gateways/remote_braintree_orange_test.rb | 2 +- test/remote/gateways/remote_cenpos_test.rb | 4 ++-- test/remote/gateways/remote_cyber_source_test.rb | 2 +- test/remote/gateways/remote_elavon_test.rb | 2 +- test/remote/gateways/remote_iridium_test.rb | 4 ++-- .../gateways/remote_jetpay_v2_certification_test.rb | 6 +++--- test/remote/gateways/remote_litle_test.rb | 2 +- test/remote/gateways/remote_mundipagg_test.rb | 2 +- test/remote/gateways/remote_nab_transact_test.rb | 2 +- test/remote/gateways/remote_payment_express_test.rb | 1 - test/remote/gateways/remote_realex_test.rb | 4 ++-- test/remote/gateways/remote_sage_pay_test.rb | 2 +- test/remote/gateways/remote_sage_test.rb | 2 +- .../remote/gateways/remote_usa_epay_advanced_test.rb | 12 ------------ test/remote/gateways/remote_visanet_peru_test.rb | 2 +- test/remote/gateways/remote_world_net_test.rb | 3 +-- test/unit/gateways/mercado_pago_test.rb | 4 ++-- test/unit/gateways/pin_test.rb | 4 ++-- test/unit/gateways/skip_jack_test.rb | 2 +- test/unit/gateways/stripe_test.rb | 5 ++--- test/unit/gateways/trexle_test.rb | 4 ++-- 32 files changed, 41 insertions(+), 61 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f20729eaff9..0198fc2ee40 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -328,10 +328,6 @@ Lint/UselessAccessModifier: Exclude: - 'lib/active_merchant/network_connection_retries.rb' -# Offense count: 68 -Lint/UselessAssignment: - Enabled: false - # Offense count: 1409 Metrics/AbcSize: Max: 192 diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index a6f0135921e..659804cd3fd 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -170,7 +170,6 @@ def add_refund_customer_data(post, options) end def add_address(post, creditcard, options) - billing_address = options[:billing_address] || options[:address] shipping_address = options[:shipping_address] if billing_address = options[:billing_address] || options[:address] post['order']['customer']['billingAddress'] = { diff --git a/lib/active_merchant/billing/gateways/qbms.rb b/lib/active_merchant/billing/gateways/qbms.rb index 85c9adf939a..5d37f900bf4 100644 --- a/lib/active_merchant/billing/gateways/qbms.rb +++ b/lib/active_merchant/billing/gateways/qbms.rb @@ -101,7 +101,7 @@ def void(authorization, options = {}) # def credit(money, identification, options = {}) ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE - refund(money, identification, options = {}) + refund(money, identification, {}) end def refund(money, identification, options = {}) diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index c44ed00d11d..bfe4733cd72 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -290,7 +290,7 @@ def message_from(response) when '00' SUCCESS when '101' - esponse[:message] + response[:message] when '102', '103' DECLINED when /^2[0-9][0-9]/ diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb index 8fbe07af636..237ce51b2ce 100644 --- a/lib/active_merchant/billing/gateways/redsys.rb +++ b/lib/active_merchant/billing/gateways/redsys.rb @@ -523,7 +523,7 @@ def xml_signed_fields(data) xml_signed_fields += data[:ds_cardnumber] end - xml_signed_fields += data[:ds_transactiontype] + data[:ds_securepayment] + xml_signed_fields + data[:ds_transactiontype] + data[:ds_securepayment] end def get_key(order_id) diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb index d3da3bea486..7dbf0372d62 100644 --- a/lib/active_merchant/billing/gateways/skip_jack.rb +++ b/lib/active_merchant/billing/gateways/skip_jack.rb @@ -274,7 +274,7 @@ def commit(action, money, parameters) def url_for(action) result = test? ? self.test_url : self.live_url result += advanced? && action == :authorization ? ADVANCED_PATH : BASIC_PATH - result += "?#{ACTIONS[action]}" + result + "?#{ACTIONS[action]}" end def add_credentials(params, action) diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb index ede932554ba..513d2a667d5 100644 --- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb @@ -163,7 +163,7 @@ def commit(method, url, parameters=nil, options = {}, type = false) rescue ResponseError => e raw_response = e.response.body response = response_error(raw_response) - rescue JSON::ParserError => e + rescue JSON::ParserError response = json_error(raw_response) end diff --git a/lib/active_merchant/network_connection_retries.rb b/lib/active_merchant/network_connection_retries.rb index e23d7e5adf5..09e1b146f30 100644 --- a/lib/active_merchant/network_connection_retries.rb +++ b/lib/active_merchant/network_connection_retries.rb @@ -28,7 +28,7 @@ def retry_exceptions(options={}) rescue OpenSSL::X509::CertificateError => e NetworkConnectionRetries.log(options[:logger], :error, e.message, options[:tag]) raise ActiveMerchant::ClientCertificateError, 'The remote server did not accept the provided SSL certificate' - rescue Zlib::BufError => e + rescue Zlib::BufError raise ActiveMerchant::InvalidResponseError, 'The remote server replied with an invalid response' rescue *connection_errors.keys => e raise ActiveMerchant::ConnectionError.new(derived_error_message(connection_errors, e.class), e) diff --git a/lib/support/gateway_support.rb b/lib/support/gateway_support.rb index 84cf58df2fc..36b916773ec 100644 --- a/lib/support/gateway_support.rb +++ b/lib/support/gateway_support.rb @@ -14,7 +14,7 @@ def initialize filename = File.basename(f, '.rb') gateway_name = filename + '_gateway' begin - gateway_class = ('ActiveMerchant::Billing::' + gateway_name.camelize).constantize + ('ActiveMerchant::Billing::' + gateway_name.camelize).constantize rescue NameError puts 'Could not load gateway ' + gateway_name.camelize + ' from ' + f + '.' end diff --git a/test/remote/gateways/remote_authorize_net_cim_test.rb b/test/remote/gateways/remote_authorize_net_cim_test.rb index b0c5e09f7d4..08001073228 100644 --- a/test/remote/gateways/remote_authorize_net_cim_test.rb +++ b/test/remote/gateways/remote_authorize_net_cim_test.rb @@ -185,7 +185,7 @@ def test_successful_create_customer_payment_profile_request end def test_successful_create_customer_payment_profile_request_with_bank_account - payment_profile = @options[:profile].delete(:payment_profiles) + @options[:profile].delete(:payment_profiles) assert response = @gateway.create_customer_profile(@options) @customer_profile_id = response.authorization @@ -254,7 +254,7 @@ def test_successful_get_customer_profile_with_multiple_payment_profiles assert response = @gateway.create_customer_profile(@options) @customer_profile_id = response.authorization - assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id) + assert @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id) assert response = @gateway.create_customer_payment_profile( :customer_profile_id => @customer_profile_id, @@ -423,7 +423,7 @@ def test_successful_update_customer_payment_profile_request masked_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => response.params['payment_profile']['payment']['credit_card']['card_number']) # Update only the billing address with a masked card and expiration date - assert response = @gateway.update_customer_payment_profile( + assert @gateway.update_customer_payment_profile( :customer_profile_id => @customer_profile_id, :payment_profile => { :customer_payment_profile_id => customer_payment_profile_id, @@ -469,7 +469,7 @@ def test_successful_update_customer_payment_profile_request_with_credit_card_las last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => '4242') # Credit card with only last four digits # Update only the billing address with a card with the last 4 digits and expiration date - assert response = @gateway.update_customer_payment_profile( + assert @gateway.update_customer_payment_profile( :customer_profile_id => @customer_profile_id, :payment_profile => { :customer_payment_profile_id => customer_payment_profile_id, @@ -766,7 +766,7 @@ def test_should_create_customer_profile_transaction_auth_only_and_then_prior_aut end def get_and_validate_customer_payment_profile_request_with_bank_account_response - payment_profile = @options[:profile].delete(:payment_profiles) + @options[:profile].delete(:payment_profiles) assert response = @gateway.create_customer_profile(@options) @customer_profile_id = response.authorization diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb index 7041bd6ca9a..e4dd84e4680 100644 --- a/test/remote/gateways/remote_beanstream_test.rb +++ b/test/remote/gateways/remote_beanstream_test.rb @@ -267,7 +267,7 @@ def test_successful_check_purchase_and_refund assert_success purchase assert refund = @gateway.refund(@amount, purchase.authorization) - assert_success credit + assert_success refund end def test_successful_recurring diff --git a/test/remote/gateways/remote_braintree_orange_test.rb b/test/remote/gateways/remote_braintree_orange_test.rb index 4f2b3f171f3..4b4e659e4a3 100644 --- a/test/remote/gateways/remote_braintree_orange_test.rb +++ b/test/remote/gateways/remote_braintree_orange_test.rb @@ -27,7 +27,7 @@ def test_successful_purchase_with_echeck :account_holder_type => 'personal', :account_type => 'checking' ) - assert response = @gateway.purchase(@amount, @check, @options) + assert response = @gateway.purchase(@amount, check, @options) assert_equal 'This transaction has been approved', response.message assert_success response end diff --git a/test/remote/gateways/remote_cenpos_test.rb b/test/remote/gateways/remote_cenpos_test.rb index 479545edb08..a3474658bbc 100644 --- a/test/remote/gateways/remote_cenpos_test.rb +++ b/test/remote/gateways/remote_cenpos_test.rb @@ -104,7 +104,7 @@ def test_failed_capture assert_success response assert_equal 'Succeeded', response.message - capture = @gateway.capture(@amount, response.authorization) + @gateway.capture(@amount, response.authorization) capture = @gateway.capture(@amount, response.authorization) assert_failure capture assert_equal 'Duplicated force transaction.', capture.message @@ -132,7 +132,7 @@ def test_failed_void response = @gateway.authorize(@amount, @credit_card, @options) assert_success response - void = @gateway.void(response.authorization) + @gateway.void(response.authorization) void = @gateway.void(response.authorization) assert_failure void assert_equal 'Original Transaction not found', void.message diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb index d3af9274365..e35e01ba8ce 100644 --- a/test/remote/gateways/remote_cyber_source_test.rb +++ b/test/remote/gateways/remote_cyber_source_test.rb @@ -213,7 +213,7 @@ def test_successful_authorization_and_failed_capture end def test_failed_capture_bad_auth_info - assert auth = @gateway.authorize(@amount, @credit_card, @options) + assert @gateway.authorize(@amount, @credit_card, @options) assert capture = @gateway.capture(@amount, 'a;b;c', @options) assert_failure capture end diff --git a/test/remote/gateways/remote_elavon_test.rb b/test/remote/gateways/remote_elavon_test.rb index 63d07da8491..9c560e7ec77 100644 --- a/test/remote/gateways/remote_elavon_test.rb +++ b/test/remote/gateways/remote_elavon_test.rb @@ -120,7 +120,7 @@ def test_purchase_and_unsuccessful_void assert purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase - assert response = @gateway.void(purchase.authorization) + assert @gateway.void(purchase.authorization) assert response = @gateway.void(purchase.authorization) assert_failure response assert_equal 'The transaction ID is invalid for this transaction type', response.message diff --git a/test/remote/gateways/remote_iridium_test.rb b/test/remote/gateways/remote_iridium_test.rb index 92dee585764..dc033cabe3a 100644 --- a/test/remote/gateways/remote_iridium_test.rb +++ b/test/remote/gateways/remote_iridium_test.rb @@ -101,7 +101,7 @@ def test_successful_authorization_and_failed_capture end def test_failed_capture_bad_auth_info - assert auth = @gateway.authorize(@amount, @credit_card, @options) + assert @gateway.authorize(@amount, @credit_card, @options) assert capture = @gateway.capture(@amount, 'a;b;c', @options) assert_failure capture end @@ -118,7 +118,7 @@ def test_successful_purchase_by_reference def test_failed_purchase_by_reference assert response = @gateway.authorize(1, @credit_card, @options) assert_success response - assert(reference = response.authorization) + assert response.authorization assert response = @gateway.purchase(@amount, 'bogusref', {:order_id => generate_unique_id}) assert_failure response diff --git a/test/remote/gateways/remote_jetpay_v2_certification_test.rb b/test/remote/gateways/remote_jetpay_v2_certification_test.rb index 4916dd08435..be182a8be37 100644 --- a/test/remote/gateways/remote_jetpay_v2_certification_test.rb +++ b/test/remote/gateways/remote_jetpay_v2_certification_test.rb @@ -238,7 +238,7 @@ def test_certification_void03_void04_purchase_void_visa puts "\n#{@options[:order_id]}: #{@unique_id}" @options[:order_id] = 'VOID04' - transaction_id, approval, amount, token = response.authorization.split(';') + transaction_id, approval, _amount, token = response.authorization.split(';') amount = 500 authorization = [transaction_id, approval, amount, token].join(';') assert response = @gateway.void(authorization, @options) @@ -302,7 +302,7 @@ def test_certification_tok16_authorize_with_token_request_visa assert response = @gateway.authorize(amount, visa, @options) assert_success response assert_equal 'APPROVED', response.message - transaction_id, approval, amount, token = response.authorization.split(';') + _transaction_id, _approval, _amount, token = response.authorization.split(';') assert_equal token, response.params['token'] @unique_id = response.params['unique_id'] end @@ -314,7 +314,7 @@ def test_certification_tok17_purchase_with_token_request_amex assert response = @gateway.purchase(amount, amex, @options) assert_success response assert_equal 'APPROVED', response.message - transaction_id, approval, amount, token = response.authorization.split(';') + _transaction_id, _approval, _amount, token = response.authorization.split(';') assert_equal token, response.params['token'] @unique_id = response.params['unique_id'] end diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb index 73d71064585..8d510dcbea4 100644 --- a/test/remote/gateways/remote_litle_test.rb +++ b/test/remote/gateways/remote_litle_test.rb @@ -93,7 +93,7 @@ def test_successful_authorization_with_merchant_data campaign: 'super-awesome-campaign', merchant_grouping_id: 'brilliant-group' ) - assert response = @gateway.authorize(10010, @credit_card1, options) + assert @gateway.authorize(10010, @credit_card1, options) end def test_successful_authorization_with_echeck diff --git a/test/remote/gateways/remote_mundipagg_test.rb b/test/remote/gateways/remote_mundipagg_test.rb index 417cc547102..39846fea222 100644 --- a/test/remote/gateways/remote_mundipagg_test.rb +++ b/test/remote/gateways/remote_mundipagg_test.rb @@ -9,7 +9,7 @@ def setup @declined_card = credit_card('4000300011112220') @voucher = credit_card('60607044957644', brand: 'sodexo') @options = { - billing_address: address(options = { neighborhood: 'Sesame Street' }), + billing_address: address({neighborhood: 'Sesame Street'}), description: 'Store Purchase' } end diff --git a/test/remote/gateways/remote_nab_transact_test.rb b/test/remote/gateways/remote_nab_transact_test.rb index ce7ce019ec5..55289ec9ff0 100644 --- a/test/remote/gateways/remote_nab_transact_test.rb +++ b/test/remote/gateways/remote_nab_transact_test.rb @@ -246,7 +246,7 @@ def test_failure_trigger_purchase purchase_response = @gateway.purchase(trigger_amount, gateway_id) - assert gateway_id = purchase_response.params['crn'] + assert purchase_response.params['crn'] assert_failure purchase_response assert_equal 'Invalid Amount', purchase_response.message end diff --git a/test/remote/gateways/remote_payment_express_test.rb b/test/remote/gateways/remote_payment_express_test.rb index cca036a49cb..8519fc72c5e 100644 --- a/test/remote/gateways/remote_payment_express_test.rb +++ b/test/remote/gateways/remote_payment_express_test.rb @@ -97,7 +97,6 @@ def test_store_with_custom_token end def test_store_invalid_credit_card - original_number = @credit_card.number @credit_card.number = 2 assert response = @gateway.store(@credit_card) diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb index 73ec653e86f..fc1800f2c63 100644 --- a/test/remote/gateways/remote_realex_test.rb +++ b/test/remote/gateways/remote_realex_test.rb @@ -18,14 +18,14 @@ def setup @mastercard_referral_a = card_fixtures(:realex_mastercard_referral_a) @mastercard_coms_error = card_fixtures(:realex_mastercard_coms_error) - @apple_pay = credit_card = network_tokenization_credit_card('4242424242424242', + @apple_pay = network_tokenization_credit_card('4242424242424242', payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', verification_value: nil, eci: '05', source: :apple_pay ) - @declined_apple_pay = credit_card = network_tokenization_credit_card('4000120000001154', + @declined_apple_pay = network_tokenization_credit_card('4000120000001154', payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', verification_value: nil, eci: '05', diff --git a/test/remote/gateways/remote_sage_pay_test.rb b/test/remote/gateways/remote_sage_pay_test.rb index 3abd17c88d5..c7647d53969 100644 --- a/test/remote/gateways/remote_sage_pay_test.rb +++ b/test/remote/gateways/remote_sage_pay_test.rb @@ -350,7 +350,7 @@ def test_successful_store_and_repurchase_with_resupplied_verification_value assert response = @gateway.store(@visa) assert_success response assert !response.authorization.blank? - assert purchase = @gateway.purchase(@amount, response.authorization, @options.merge(customer: 1)) + assert @gateway.purchase(@amount, response.authorization, @options.merge(customer: 1)) assert purchase = @gateway.purchase(@amount, response.authorization, @options.merge(verification_value: '123', order_id: generate_unique_id)) assert_success purchase end diff --git a/test/remote/gateways/remote_sage_test.rb b/test/remote/gateways/remote_sage_test.rb index fbab6a0417a..5107a12e97d 100644 --- a/test/remote/gateways/remote_sage_test.rb +++ b/test/remote/gateways/remote_sage_test.rb @@ -165,7 +165,7 @@ def test_partial_refund def test_store_visa assert response = @gateway.store(@visa, @options) assert_success response - assert auth = response.authorization, + assert response.authorization, 'Store card authorization should not be nil' assert_not_nil response.message end diff --git a/test/remote/gateways/remote_usa_epay_advanced_test.rb b/test/remote/gateways/remote_usa_epay_advanced_test.rb index 01ec1523690..df133607dda 100644 --- a/test/remote/gateways/remote_usa_epay_advanced_test.rb +++ b/test/remote/gateways/remote_usa_epay_advanced_test.rb @@ -92,18 +92,6 @@ def setup :payment_method => @check, :amount => 2500 } - - payment_methods = [ - { - :name => 'My Visa', # optional - :sort => 2, # optional - :method => @credit_card - }, - { - :name => 'My Checking', - :method => @check - } - ] end # Standard Gateway ================================================== diff --git a/test/remote/gateways/remote_visanet_peru_test.rb b/test/remote/gateways/remote_visanet_peru_test.rb index ff1b0160c76..5f70eaeeb3d 100644 --- a/test/remote/gateways/remote_visanet_peru_test.rb +++ b/test/remote/gateways/remote_visanet_peru_test.rb @@ -107,7 +107,7 @@ def test_successful_refund_unsettled assert_success response new_auth = "_|#{response.authorization.split('|')[1]}" - refund = @gateway.refund(@amount, new_auth, @options.merge(force_full_refund_if_unsettled: true, ruc: '20341198217')) + @gateway.refund(@amount, new_auth, @options.merge(force_full_refund_if_unsettled: true, ruc: '20341198217')) # this test will fail currently because there is no E2E test working for visanet # assert_success refund # assert_equal "OK", refund.message diff --git a/test/remote/gateways/remote_world_net_test.rb b/test/remote/gateways/remote_world_net_test.rb index 14986a28487..67d198f1fbf 100644 --- a/test/remote/gateways/remote_world_net_test.rb +++ b/test/remote/gateways/remote_world_net_test.rb @@ -109,7 +109,7 @@ def test_successful_void auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert void = @gateway.void(auth.authorization) + assert @gateway.void(auth.authorization) # UNSUPPORTED # assert_success void # assert_equal 'REPLACE WITH SUCCESSFUL VOID MESSAGE', response.message @@ -156,7 +156,6 @@ def test_unsuccessful_unstore response = @gateway.store(@credit_card, @options) assert_success response assert_equal nil, response.message - card_reference = response.authorization assert response = @gateway.unstore('123456789', @options) assert_failure response diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb index 7b29e5252c8..72ad12215f5 100644 --- a/test/unit/gateways/mercado_pago_test.rb +++ b/test/unit/gateways/mercado_pago_test.rb @@ -196,8 +196,8 @@ def test_sends_mastercard_as_master def test_includes_deviceid_header @options[:device_id] = '1a2b3c' - @gateway.expects(:ssl_post).with(anything, anything, headers = {'Content-Type' => 'application/json'}).returns(successful_purchase_response) - @gateway.expects(:ssl_post).with(anything, anything, headers = {'Content-Type' => 'application/json', 'X-Device-Session-ID' => '1a2b3c'}).returns(successful_purchase_response) + @gateway.expects(:ssl_post).with(anything, anything, {'Content-Type' => 'application/json'}).returns(successful_purchase_response) + @gateway.expects(:ssl_post).with(anything, anything, {'Content-Type' => 'application/json', 'X-Device-Session-ID' => '1a2b3c'}).returns(successful_purchase_response) response = @gateway.purchase(@amount, @credit_card, @options) assert_success response diff --git a/test/unit/gateways/pin_test.rb b/test/unit/gateways/pin_test.rb index fc16c0d1f68..33a27b55a56 100644 --- a/test/unit/gateways/pin_test.rb +++ b/test/unit/gateways/pin_test.rb @@ -304,13 +304,13 @@ def test_headers } @gateway.expects(:ssl_request).with(:post, anything, anything, expected_headers).returns(successful_purchase_response) - assert response = @gateway.purchase(@amount, @credit_card, {}) + assert @gateway.purchase(@amount, @credit_card, {}) expected_headers['X-Partner-Key'] = 'MyPartnerKey' expected_headers['X-Safe-Card'] = '1' @gateway.expects(:ssl_request).with(:post, anything, anything, expected_headers).returns(successful_purchase_response) - assert response = @gateway.purchase(@amount, @credit_card, :partner_key => 'MyPartnerKey', :safe_card => '1') + assert @gateway.purchase(@amount, @credit_card, :partner_key => 'MyPartnerKey', :safe_card => '1') end def test_transcript_scrubbing diff --git a/test/unit/gateways/skip_jack_test.rb b/test/unit/gateways/skip_jack_test.rb index 45f70914506..6df67c6a94e 100644 --- a/test/unit/gateways/skip_jack_test.rb +++ b/test/unit/gateways/skip_jack_test.rb @@ -206,7 +206,7 @@ def test_serial_number_is_added_before_developer_serial_number_for_capture response = @gateway.authorize(@amount, @credit_card, @options) @gateway.expects(:ssl_post).with('https://developer.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest', "szTransactionId=#{response.authorization}&szSerialNumber=X&szForceSettlement=0&szDeveloperSerialNumber=Y&szDesiredStatus=SETTLE&szAmount=1.00").returns(successful_capture_response) - response = @gateway.capture(@amount, response.authorization) + @gateway.capture(@amount, response.authorization) end def test_successful_partial_capture diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index 0dd7f51097c..edbafbd49d4 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -725,7 +725,7 @@ def test_unsuccessful_verify end def test_successful_request_always_uses_live_mode_to_determine_test_request - @gateway.expects(:ssl_request).returns(successful_partially_refunded_response(:livemode => true)) + @gateway.expects(:ssl_request).returns(successful_partially_refunded_response) assert response = @gateway.refund(@refund_amount, 'ch_test_charge') assert_success response @@ -1989,8 +1989,7 @@ def successful_purchase_response(refunded=false) RESPONSE end - def successful_partially_refunded_response(options = {}) - options = {:livemode=>false}.merge!(options) + def successful_partially_refunded_response <<-RESPONSE { "id": "re_test_refund", diff --git a/test/unit/gateways/trexle_test.rb b/test/unit/gateways/trexle_test.rb index 5ce9da270f2..a1ee4295ccc 100644 --- a/test/unit/gateways/trexle_test.rb +++ b/test/unit/gateways/trexle_test.rb @@ -286,13 +286,13 @@ def test_headers } @gateway.expects(:ssl_request).with(:post, anything, anything, expected_headers).returns(successful_purchase_response) - assert response = @gateway.purchase(@amount, @credit_card, {}) + assert @gateway.purchase(@amount, @credit_card, {}) expected_headers['X-Partner-Key'] = 'MyPartnerKey' expected_headers['X-Safe-Card'] = '1' @gateway.expects(:ssl_request).with(:post, anything, anything, expected_headers).returns(successful_purchase_response) - assert response = @gateway.purchase(@amount, @credit_card, partner_key: 'MyPartnerKey', safe_card: '1') + assert @gateway.purchase(@amount, @credit_card, partner_key: 'MyPartnerKey', safe_card: '1') end def test_transcript_scrubbing From f9ed08a45105b6951108278ef1286b2fa1f841f6 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder <deedeelavinder@gmail.com> Date: Tue, 30 Oct 2018 17:05:33 -0400 Subject: [PATCH 597/677] Barclaycard Smartpay: Improves Error Handling The error handling was not exposing detailed error codes and messages in the response. This returns those codes and messages where appropriate. This also adds and updates several tests. Unit tests: 27 tests, 133 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote tests: 33 tests, 69 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 96.9697% passed This failure is for "Invalid credentials" for `test_successful_third_party_payout` and is unrelated. Closes #3026 --- CHANGELOG | 1 + .../billing/gateways/barclaycard_smartpay.rb | 10 +++--- .../remote_barclaycard_smartpay_test.rb | 20 +++++++++-- .../gateways/barclaycard_smartpay_test.rb | 34 ++++++++++++++++--- 4 files changed, 53 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b80a96427f4..b6a84d107d7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * Payflow Express: Add phone to returned Response [filipebarcos] #3003 * Authorize.Net: Pass some level 3 fields [curiousepic] #3022 * Add state to the netbanx payload [Girardvjonathan] #3024 +* Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb index 1ea7ee14dce..84a59f82081 100644 --- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb @@ -168,11 +168,11 @@ def commit(action, post, account = 'ws', password = @options[:password]) return Response.new(false, 'Invalid credentials', {}, :test => test?) when '403' return Response.new(false, 'Not allowed', {}, :test => test?) - when '422' - return Response.new(false, 'Unprocessable Entity', {}, :test => test?) - when '500' - if e.response.body.split(' ')[0] == 'validation' - return Response.new(false, e.response.body.split(' ', 3)[2], {}, :test => test?) + when '422', '500' + if e.response.body.split(/\W+/).any? { |word| %w(validation configuration security).include?(word) } + error_message = e.response.body[/#{Regexp.escape('message=')}(.*?)#{Regexp.escape('&')}/m, 1].tr('+', ' ') + error_code = e.response.body[/#{Regexp.escape('errorCode=')}(.*?)#{Regexp.escape('&')}/m, 1] + return Response.new(false, error_code + ': ' + error_message, {}, :test => test?) end end raise diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb index 105166a2250..1f0444d6a08 100644 --- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb +++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb @@ -6,6 +6,7 @@ def setup BarclaycardSmartpayGateway.ssl_strict = false @amount = 100 + @error_amount = 1_000_000_000_000_000_000_000 @credit_card = credit_card('4111111111111111', :month => 10, :year => 2020, :verification_value => 737) @declined_card = credit_card('4000300011112220', :month => 3, :year => 2030, :verification_value => 737) @three_ds_enrolled_card = credit_card('4212345678901237', brand: :visa) @@ -196,9 +197,16 @@ def test_partial_capture assert_success capture end - def test_failed_capture + def test_failed_capture_with_bad_auth + response = @gateway.capture(100, '0000000000000000', @options) + assert_failure response + assert_equal('167: Original pspReference required for this operation', response.message) + end + + def test_failed_capture_with_bad_amount response = @gateway.capture(nil, '', @options) assert_failure response + assert_equal('137: Invalid amount specified', response.message) end def test_successful_refund @@ -287,9 +295,9 @@ def test_successful_store end def test_failed_store - response = @gateway.store(credit_card('', :month => '', :year => '', :verification_value => ''), @options) + response = @gateway.store(credit_card('4111111111111111', :month => '', :year => '', :verification_value => ''), @options) assert_failure response - assert_equal 'Unprocessable Entity', response.message + assert_equal '129: Expiry Date Invalid', response.message end # AVS must be enabled on the gateway's end for the test account used @@ -330,4 +338,10 @@ def test_transcript_scrubbing assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript) assert_scrubbed(@gateway.options[:password], clean_transcript) end + + def test_proper_error_response_handling + response = @gateway.purchase(@error_amount, @credit_card, @options) + assert_equal('702: Internal error', response.message) + assert_not_equal(response.message, 'Unable to communicate with the payment system.') + end end diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb index e88dd36bdea..2bb8443b85d 100644 --- a/test/unit/gateways/barclaycard_smartpay_test.rb +++ b/test/unit/gateways/barclaycard_smartpay_test.rb @@ -207,10 +207,11 @@ def test_successful_capture end def test_failed_capture - @gateway.stubs(:ssl_post).raises(ActiveMerchant::ResponseError.new(stub(:code => '500', :body => failed_capture_response))) + @gateway.stubs(:ssl_post).raises(ActiveMerchant::ResponseError.new(stub(:code => '422', :body => failed_capture_response))) response = @gateway.capture(@amount, '0000000000000000', @options) assert_failure response + assert_equal('167: Original pspReference required for this operation', response.message) assert response.test? end @@ -238,10 +239,11 @@ def test_successful_refund end def test_failed_refund - @gateway.stubs(:ssl_post).raises(ActiveMerchant::ResponseError.new(stub(:code => '500', :body => failed_refund_response))) + @gateway.stubs(:ssl_post).raises(ActiveMerchant::ResponseError.new(stub(:code => '422', :body => failed_refund_response))) response = @gateway.refund(@amount, '0000000000000000', @options) assert_failure response + assert_equal('137: Invalid amount specified', response.message) assert response.test? end @@ -367,6 +369,22 @@ def test_transcript_scrubbing assert_equal scrubbed_transcript, @gateway.scrub(transcript) end + def test_proper_error_response_handling + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.respond_with(configuration_error_response) + + message = "#{response.params['errorCode']}: #{response.params['message']}" + assert_equal('905: Payment details are not supported', message) + + response2 = stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.respond_with(validation_error_response) + + message2 = "#{response2.params['errorCode']}: #{response2.params['message']}" + assert_equal('702: Internal error', message2) + end + private def successful_authorize_response @@ -386,7 +404,7 @@ def successful_capture_response end def failed_capture_response - 'validation 100 No amount specified' + 'errorType=validation&errorCode=167&message=Original+pspReference+required+for+this+operation&status=422' end def successful_refund_response @@ -394,7 +412,7 @@ def successful_refund_response end def failed_refund_response - 'validation 100 No amount specified' + 'errorType=validation&errorCode=137&message=Invalid+amount+specified&status=422' end def successful_credit_response @@ -429,6 +447,14 @@ def failed_avs_response 'additionalData.liabilityShift=false&additionalData.authCode=3115&additionalData.avsResult=2+Neither+postal+code+nor+address+match&additionalData.cardHolderName=Longbob+Longsen&additionalData.threeDOffered=false&additionalData.refusalReasonRaw=AUTHORISED&additionalData.issuerCountry=US&additionalData.cvcResult=1+Matches&additionalData.avsResultRaw=2&additionalData.threeDAuthenticated=false&additionalData.cvcResultRaw=1&additionalData.acquirerCode=SmartPayTestPmmAcquirer&additionalData.acquirerReference=7F50RDN2L06&fraudResult.accountScore=170&fraudResult.results.0.accountScore=20&fraudResult.results.0.checkId=2&fraudResult.results.0.name=CardChunkUsage&fraudResult.results.1.accountScore=25&fraudResult.results.1.checkId=4&fraudResult.results.1.name=HolderNameUsage&fraudResult.results.2.accountScore=25&fraudResult.results.2.checkId=8&fraudResult.results.2.name=ShopperEmailUsage&fraudResult.results.3.accountScore=0&fraudResult.results.3.checkId=1&fraudResult.results.3.name=PaymentDetailRefCheck&fraudResult.results.4.accountScore=0&fraudResult.results.4.checkId=13&fraudResult.results.4.name=IssuerRefCheck&fraudResult.results.5.accountScore=0&fraudResult.results.5.checkId=15&fraudResult.results.5.name=IssuingCountryReferral&fraudResult.results.6.accountScore=0&fraudResult.results.6.checkId=26&fraudResult.results.6.name=ShopperEmailRefCheck&fraudResult.results.7.accountScore=0&fraudResult.results.7.checkId=27&fraudResult.results.7.name=PmOwnerRefCheck&fraudResult.results.8.accountScore=0&fraudResult.results.8.checkId=10&fraudResult.results.8.name=HolderNameContainsNumber&fraudResult.results.9.accountScore=0&fraudResult.results.9.checkId=11&fraudResult.results.9.name=HolderNameIsOneWord&fraudResult.results.10.accountScore=0&fraudResult.results.10.checkId=21&fraudResult.results.10.name=EmailDomainValidation&fraudResult.results.11.accountScore=100&fraudResult.results.11.checkId=20&fraudResult.results.11.name=AVSAuthResultCheck&fraudResult.results.12.accountScore=0&fraudResult.results.12.checkId=25&fraudResult.results.12.name=CVCAuthResultCheck&pspReference=8814591938804745&refusalReason=FRAUD-CANCELLED&resultCode=Cancelled&authCode=3115' end + def validation_error_response + 'errorType=validation&errorCode=702&message=Internal+error&status=500' + end + + def configuration_error_response + 'errorType=configuration&errorCode=905&message=Payment+details+are+not+supported&pspReference=4315391674762857&status=500' + end + def transcript %( opening connection to pal-test.barclaycardsmartpay.com:443... From 21d7500581450c8c6f2774f712937695bcbd4a37 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 30 Oct 2018 14:29:47 -0400 Subject: [PATCH 598/677] Braintree: Fix passing phone-only billing address If a billing address option had only a phone number, the billing address element was still included in the request with all empty fields, which causes a failure. Now we remove the phone from the billing address hash before it's added. Closes #3025 Remote: 64 tests, 365 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 55 tests, 139 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/braintree_blue.rb | 5 +++-- .../gateways/remote_braintree_blue_test.rb | 14 ++++++++++++ test/unit/gateways/braintree_blue_test.rb | 22 +++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b6a84d107d7..439f91e9e81 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ * Authorize.Net: Pass some level 3 fields [curiousepic] #3022 * Add state to the netbanx payload [Girardvjonathan] #3024 * Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026 +* Braintree: Fix passing phone-only billing address [curiousepic] #3025 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 1c35f5d0534..d693e587fed 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -304,12 +304,13 @@ def merge_credit_card_options(parameters, options) parameters[:credit_card] ||= {} parameters[:credit_card].merge!(:options => valid_options) - parameters[:credit_card][:billing_address] = map_address(options[:billing_address]) if options[:billing_address] + address = options[:billing_address]&.except(:phone) + return parameters if address.nil? || address.empty? + parameters[:credit_card][:billing_address] = map_address(address) parameters end def map_address(address) - return {} if address.nil? mapped = { :street_address => address[:address1], :extended_address => address[:address2], diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index 46a6610cc6f..22885692808 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -168,6 +168,20 @@ def test_successful_store_with_billing_address assert_equal purchase_response.params['braintree_transaction']['billing_details'], response_billing_details end + def test_successful_store_with_phone_only_billing_address_option + billing_address = { + :phone => '123-456-7890' + } + credit_card = credit_card('5105105105105100') + assert response = @gateway.store(credit_card, :billing_address => billing_address) + assert_success response + assert_equal 'OK', response.message + + vault_id = response.params['customer_vault_id'] + purchase_response = @gateway.purchase(@amount, vault_id) + assert_success purchase_response + end + def test_successful_store_with_credit_card_token credit_card = credit_card('5105105105105100') credit_card_token = generate_unique_id diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index e6986cae2c5..68a6092da88 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -351,6 +351,28 @@ def test_store_with_billing_address_options @gateway.store(credit_card('41111111111111111111'), :billing_address => billing_address) end + def test_store_with_phone_only_billing_address_option + customer_attributes = { + :credit_cards => [stub_everything], + :email => 'email', + :first_name => 'John', + :last_name => 'Smith', + :phone => '123-456-7890' + } + billing_address = { + :phone => '123-456-7890' + } + customer = stub(customer_attributes) + customer.stubs(:id).returns('123') + result = Braintree::SuccessfulResult.new(:customer => customer) + Braintree::CustomerGateway.any_instance.expects(:create).with do |params| + assert_nil params[:credit_card][:billing_address] + params + end.returns(result) + + @gateway.store(credit_card('41111111111111111111'), :billing_address => billing_address) + end + def test_store_with_credit_card_token customer = stub( :email => 'email', From 2841acc17f8413a88e6985b976fc2f2561ee8aa9 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Thu, 1 Nov 2018 14:43:03 -0400 Subject: [PATCH 599/677] Litle: Capitalize check account type Check payment methods may have lowercase account_type properties, but the api expects it to be capitalized. Closes #3028 Remote (10 unrelated failures, mostly unexpected successes): 37 tests, 137 assertions, 10 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 72.973% passed Unit: 35 tests, 151 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/litle.rb | 2 +- test/remote/gateways/remote_litle_test.rb | 4 ++-- test/unit/gateways/litle_test.rb | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 439f91e9e81..1f9e4bbbe9d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * Add state to the netbanx payload [Girardvjonathan] #3024 * Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026 * Braintree: Fix passing phone-only billing address [curiousepic] #3025 +* Litle: Capitalize check account type [curiousepic] #3028 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index 61be3eedaa7..324b976629a 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -268,7 +268,7 @@ def add_payment_method(doc, payment_method, options) end elsif check?(payment_method) doc.echeck do - doc.accType(payment_method.account_type) + doc.accType(payment_method.account_type.capitalize) doc.accNum(payment_method.account_number) doc.routingNum(payment_method.routing_number) doc.checkNum(payment_method.number) diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb index 8d510dcbea4..6fd3107832f 100644 --- a/test/remote/gateways/remote_litle_test.rb +++ b/test/remote/gateways/remote_litle_test.rb @@ -67,13 +67,13 @@ def setup name: 'Tom Black', routing_number: '011075150', account_number: '4099999992', - account_type: 'Checking' + account_type: 'checking' ) @authorize_check = check( name: 'John Smith', routing_number: '011075150', account_number: '1099999999', - account_type: 'Checking' + account_type: 'checking' ) @store_check = check( routing_number: '011100012', diff --git a/test/unit/gateways/litle_test.rb b/test/unit/gateways/litle_test.rb index 652ea34eb84..00538933ec8 100644 --- a/test/unit/gateways/litle_test.rb +++ b/test/unit/gateways/litle_test.rb @@ -36,13 +36,13 @@ def setup name: 'Tom Black', routing_number: '011075150', account_number: '4099999992', - account_type: 'Checking' + account_type: 'checking' ) @authorize_check = check( name: 'John Smith', routing_number: '011075150', account_number: '1099999999', - account_type: 'Checking' + account_type: 'checking' ) end From 73c951d660f38986d25ed6c16bcd1a38f4f596eb Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 1 Nov 2018 10:58:54 -0400 Subject: [PATCH 600/677] RuboCop: fix Lint/AmbiguousBlockAssociation --- .rubocop_todo.yml | 7 ------- test/test_helper.rb | 2 +- test/unit/gateways/gateway_test.rb | 4 ++-- test/unit/gateways/worldpay_test.rb | 2 +- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0198fc2ee40..a25f069387e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -241,13 +241,6 @@ Layout/SpaceInsideStringInterpolation: - 'lib/active_merchant/billing/gateways/trust_commerce.rb' - 'test/unit/gateways/worldpay_test.rb' -# Offense count: 4 -Lint/AmbiguousBlockAssociation: - Exclude: - - 'test/test_helper.rb' - - 'test/unit/gateways/gateway_test.rb' - - 'test/unit/gateways/worldpay_test.rb' - # Offense count: 31 Lint/AmbiguousRegexpLiteral: Enabled: false diff --git a/test/test_helper.rb b/test/test_helper.rb index 7400150f5cc..90a557c2eb9 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -131,7 +131,7 @@ def clean_backtrace(&block) yield rescue AssertionClass => e path = File.expand_path(__FILE__) - raise AssertionClass, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ } + raise AssertionClass, e.message, (e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }) end end diff --git a/test/unit/gateways/gateway_test.rb b/test/unit/gateways/gateway_test.rb index f8f29c235be..56a957f6109 100644 --- a/test/unit/gateways/gateway_test.rb +++ b/test/unit/gateways/gateway_test.rb @@ -11,10 +11,10 @@ def teardown def test_should_detect_if_a_card_is_supported Gateway.supported_cardtypes = [:visa, :bogus] - assert [:visa, :bogus].all? { |supported_cardtype| Gateway.supports?(supported_cardtype) } + assert([:visa, :bogus].all? { |supported_cardtype| Gateway.supports?(supported_cardtype) }) Gateway.supported_cardtypes = [] - assert_false [:visa, :bogus].all? { |invalid_cardtype| Gateway.supports?(invalid_cardtype) } + assert_false([:visa, :bogus].all? { |invalid_cardtype| Gateway.supports?(invalid_cardtype) }) end def test_should_validate_supported_countries diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index 37fcef0e548..7fe93d7acc2 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -97,7 +97,7 @@ def test_purchase_does_not_run_inquiry end.respond_with(successful_capture_response) assert_success response - assert_equal %w(authorize capture), response.responses.collect{|e| e.params['action']} + assert_equal(%w(authorize capture), response.responses.collect{|e| e.params['action']}) end def test_successful_void From 349db7e5827eccecbc64ee7e4da3691b751cbc8e Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 1 Nov 2018 11:04:08 -0400 Subject: [PATCH 601/677] RuboCop: fix Lint/AmbiguousRegexpLiteral --- .rubocop_todo.yml | 4 ---- test/remote/gateways/remote_blue_snap_test.rb | 16 ++++++++-------- test/remote/gateways/remote_citrus_pay_test.rb | 4 ++-- test/remote/gateways/remote_ezic_test.rb | 6 +++--- test/remote/gateways/remote_fat_zebra_test.rb | 2 +- test/remote/gateways/remote_first_pay_test.rb | 2 +- .../gateways/remote_global_transport_test.rb | 4 ++-- .../remote/gateways/remote_iats_payments_test.rb | 2 +- test/remote/gateways/remote_migs_test.rb | 2 +- test/remote/gateways/remote_openpay_test.rb | 2 +- test/remote/gateways/remote_payu_latam_test.rb | 10 +++++----- test/remote/gateways/remote_quickpay_v10_test.rb | 2 +- .../remote/gateways/remote_redsys_sha256_test.rb | 2 +- test/remote/gateways/remote_redsys_test.rb | 2 +- test/remote/gateways/remote_stripe_test.rb | 6 +++--- ...emote_trans_first_transaction_express_test.rb | 2 +- test/remote/gateways/remote_visanet_peru_test.rb | 6 +++--- 17 files changed, 35 insertions(+), 39 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a25f069387e..deca557091e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -241,10 +241,6 @@ Layout/SpaceInsideStringInterpolation: - 'lib/active_merchant/billing/gateways/trust_commerce.rb' - 'test/unit/gateways/worldpay_test.rb' -# Offense count: 31 -Lint/AmbiguousRegexpLiteral: - Enabled: false - # Offense count: 148 # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb index 9934855f3de..8f3604241a5 100644 --- a/test/remote/gateways/remote_blue_snap_test.rb +++ b/test/remote/gateways/remote_blue_snap_test.rb @@ -47,7 +47,7 @@ def test_successful_purchase_with_currency def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_match /Authorization has failed for this transaction/, response.message + assert_match(/Authorization has failed for this transaction/, response.message) assert_equal '14002', response.error_code end @@ -77,7 +77,7 @@ def test_successful_authorize_and_capture def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_match /Authorization has failed for this transaction/, response.message + assert_match(/Authorization has failed for this transaction/, response.message) end def test_partial_capture_succeeds_even_though_amount_is_ignored_by_gateway @@ -91,7 +91,7 @@ def test_partial_capture_succeeds_even_though_amount_is_ignored_by_gateway def test_failed_capture response = @gateway.capture(@amount, '') assert_failure response - assert_match /due to missing transaction ID/, response.message + assert_match(/due to missing transaction ID/, response.message) end def test_successful_refund @@ -114,7 +114,7 @@ def test_partial_refund def test_failed_refund response = @gateway.refund(@amount, '') assert_failure response - assert_match /cannot be completed due to missing transaction ID/, response.message + assert_match(/cannot be completed due to missing transaction ID/, response.message) end def test_successful_void @@ -129,7 +129,7 @@ def test_successful_void def test_failed_void response = @gateway.void('') assert_failure response - assert_match /cannot be completed due to missing transaction ID/, response.message + assert_match(/cannot be completed due to missing transaction ID/, response.message) end def test_successful_verify @@ -141,7 +141,7 @@ def test_successful_verify def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_match /Authorization has failed for this transaction/, response.message + assert_match(/Authorization has failed for this transaction/, response.message) end def test_successful_store @@ -152,14 +152,14 @@ def test_successful_store assert response.authorization assert_equal 'I', response.avs_result['code'] assert_equal 'P', response.cvv_result['code'] - assert_match /services\/2\/vaulted-shoppers/, response.params['content-location-header'] + assert_match(/services\/2\/vaulted-shoppers/, response.params['content-location-header']) end def test_failed_store assert response = @gateway.store(@declined_card, @options) assert_failure response - assert_match /Transaction failed because of payment processing failure/, response.message + assert_match(/Transaction failed because of payment processing failure/, response.message) assert_equal '14002', response.error_code end diff --git a/test/remote/gateways/remote_citrus_pay_test.rb b/test/remote/gateways/remote_citrus_pay_test.rb index 1acf5ed9a4b..cf7d131b942 100644 --- a/test/remote/gateways/remote_citrus_pay_test.rb +++ b/test/remote/gateways/remote_citrus_pay_test.rb @@ -56,7 +56,7 @@ def test_adds_3dsecure_id_to_authorize def test_failed_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_match /FAILURE/, response.message + assert_match %r{FAILURE}, response.message end def test_successful_authorize_and_capture @@ -73,7 +73,7 @@ def test_successful_authorize_and_capture def test_failed_authorize assert response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_match /FAILURE/, response.message + assert_match(/FAILURE/, response.message) end def test_successful_refund diff --git a/test/remote/gateways/remote_ezic_test.rb b/test/remote/gateways/remote_ezic_test.rb index e2051de0ad3..7aacb3f3a74 100644 --- a/test/remote/gateways/remote_ezic_test.rb +++ b/test/remote/gateways/remote_ezic_test.rb @@ -48,7 +48,7 @@ def test_failed_capture assert capture = @gateway.capture(@amount+30, auth.authorization) assert_failure capture - assert_match /Settlement amount cannot exceed authorized amount/, capture.message + assert_match(/Settlement amount cannot exceed authorized amount/, capture.message) end def test_successful_refund @@ -76,7 +76,7 @@ def test_failed_refund assert refund = @gateway.refund(@amount + 49, purchase.authorization) assert_failure refund - assert_match /Amount of refunds exceed original sale/, refund.message + assert_match(/Amount of refunds exceed original sale/, refund.message) end def test_failed_void @@ -114,6 +114,6 @@ def test_invalid_login gateway = EzicGateway.new(account_id: '11231') response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_match /Invalid account number/, response.message + assert_match(/Invalid account number/, response.message) end end diff --git a/test/remote/gateways/remote_fat_zebra_test.rb b/test/remote/gateways/remote_fat_zebra_test.rb index 0f75fcdac91..dd4d594751e 100644 --- a/test/remote/gateways/remote_fat_zebra_test.rb +++ b/test/remote/gateways/remote_fat_zebra_test.rb @@ -30,7 +30,7 @@ def test_successful_multi_currency_purchase def test_unsuccessful_multi_currency_purchase assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:currency => 'XYZ')) assert_failure response - assert_match /Currency XYZ is not valid for this merchant/, response.message + assert_match(/Currency XYZ is not valid for this merchant/, response.message) end def test_successful_purchase_sans_cvv diff --git a/test/remote/gateways/remote_first_pay_test.rb b/test/remote/gateways/remote_first_pay_test.rb index f30fc4223b0..6e174f76976 100644 --- a/test/remote/gateways/remote_first_pay_test.rb +++ b/test/remote/gateways/remote_first_pay_test.rb @@ -108,7 +108,7 @@ def test_invalid_login ) response = gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert_match /Merchant: 1234 has encountered error #DTO-200-TC./, response.error_code + assert_match(/Merchant: 1234 has encountered error #DTO-200-TC./, response.error_code) end def test_recurring_payment diff --git a/test/remote/gateways/remote_global_transport_test.rb b/test/remote/gateways/remote_global_transport_test.rb index 1f5c45b4cb4..eac5264fe9c 100644 --- a/test/remote/gateways/remote_global_transport_test.rb +++ b/test/remote/gateways/remote_global_transport_test.rb @@ -63,7 +63,7 @@ def test_failed_capture assert capture = @gateway.capture(1000, auth.authorization) assert_failure capture - assert_match /must be less than or equal to the original amount/, capture.message + assert_match(/must be less than or equal to the original amount/, capture.message) end def test_successful_refund @@ -90,7 +90,7 @@ def test_failed_refund assert refund = @gateway.refund(1000, purchase.authorization) assert_failure refund - assert_match /Refund Exceeds Available Refund Amount/, refund.message + assert_match(/Refund Exceeds Available Refund Amount/, refund.message) end def test_successful_void diff --git a/test/remote/gateways/remote_iats_payments_test.rb b/test/remote/gateways/remote_iats_payments_test.rb index 4a1a256da8e..34d604b7b92 100644 --- a/test/remote/gateways/remote_iats_payments_test.rb +++ b/test/remote/gateways/remote_iats_payments_test.rb @@ -99,7 +99,7 @@ def test_failed_store credit_card = credit_card('4111') assert store = @gateway.store(credit_card, @options) assert_failure store - assert_match /Invalid credit card number/, store.message + assert_match(/Invalid credit card number/, store.message) end def test_invalid_login diff --git a/test/remote/gateways/remote_migs_test.rb b/test/remote/gateways/remote_migs_test.rb index 3e6f3ae43f6..077762dc30b 100644 --- a/test/remote/gateways/remote_migs_test.rb +++ b/test/remote/gateways/remote_migs_test.rb @@ -41,7 +41,7 @@ def test_server_purchase_url choice_url = @gateway.purchase_offsite_url(@amount, options) - assert_response_match /Pay securely .* by clicking on the card logo below/, choice_url + assert_response_match(/Pay securely .* by clicking on the card logo below/, choice_url) responses = { 'visa' => /You have chosen .*VISA.*/, diff --git a/test/remote/gateways/remote_openpay_test.rb b/test/remote/gateways/remote_openpay_test.rb index 54db72973a2..079b4d09279 100644 --- a/test/remote/gateways/remote_openpay_test.rb +++ b/test/remote/gateways/remote_openpay_test.rb @@ -165,7 +165,7 @@ def test_successful_verify def test_unsuccessful_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_match /The card was declined/, response.message + assert_match(/The card was declined/, response.message) end def test_invalid_login diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb index e1fa12362d6..8f6518fc4b1 100644 --- a/test/remote/gateways/remote_payu_latam_test.rb +++ b/test/remote/gateways/remote_payu_latam_test.rb @@ -290,13 +290,13 @@ def test_well_formed_refund_fails_as_expected def test_failed_refund response = @gateway.refund(@amount, '') assert_failure response - assert_match /property: parentTransactionId, message: must not be null/, response.message + assert_match(/property: parentTransactionId, message: must not be null/, response.message) end def test_failed_refund_with_specified_language response = @gateway.refund(@amount, '', language: 'es') assert_failure response - assert_match /property: parentTransactionId, message: No puede ser vacio/, response.message + assert_match(/property: parentTransactionId, message: No puede ser vacio/, response.message) end # If this test fails, support for void may have been added to the sandbox @@ -312,13 +312,13 @@ def test_unsupported_test_void_fails_as_expected def test_failed_void response = @gateway.void('') assert_failure response - assert_match /property: parentTransactionId, message: must not be null/, response.message + assert_match(/property: parentTransactionId, message: must not be null/, response.message) end def test_failed_void_with_specified_language response = @gateway.void('', language: 'es') assert_failure response - assert_match /property: parentTransactionId, message: No puede ser vacio/, response.message + assert_match(/property: parentTransactionId, message: No puede ser vacio/, response.message) end # If this test fails, support for captures may have been added to the sandbox @@ -334,7 +334,7 @@ def test_unsupported_test_capture_fails_as_expected def test_failed_capture response = @gateway.capture(@amount, '') assert_failure response - assert_match /must not be null/, response.message + assert_match(/must not be null/, response.message) end def test_verify_credentials diff --git a/test/remote/gateways/remote_quickpay_v10_test.rb b/test/remote/gateways/remote_quickpay_v10_test.rb index d10e107fa09..4a349cecafd 100644 --- a/test/remote/gateways/remote_quickpay_v10_test.rb +++ b/test/remote/gateways/remote_quickpay_v10_test.rb @@ -82,7 +82,7 @@ def test_unsuccessful_purchase_with_invalid_acquirers def test_unsuccessful_authorize_with_invalid_card assert response = @gateway.authorize(@amount, @invalid_card, @options) assert_failure response - assert_match /Rejected test operation/, response.message + assert_match(/Rejected test operation/, response.message) end def test_successful_authorize_and_capture diff --git a/test/remote/gateways/remote_redsys_sha256_test.rb b/test/remote/gateways/remote_redsys_sha256_test.rb index 8d3a2bbf8f1..43718a5f67a 100644 --- a/test/remote/gateways/remote_redsys_sha256_test.rb +++ b/test/remote/gateways/remote_redsys_sha256_test.rb @@ -64,7 +64,7 @@ def test_successful_authorise_and_capture capture = @gateway.capture(100, authorize.authorization) assert_success capture - assert_match /Refund.*approved/, capture.message + assert_match(/Refund.*approved/, capture.message) end def test_successful_authorise_using_vault_id diff --git a/test/remote/gateways/remote_redsys_test.rb b/test/remote/gateways/remote_redsys_test.rb index 0dcaf5a017e..cfaf52723b2 100644 --- a/test/remote/gateways/remote_redsys_test.rb +++ b/test/remote/gateways/remote_redsys_test.rb @@ -66,7 +66,7 @@ def test_successful_authorise_and_capture capture = @gateway.capture(100, authorize.authorization) assert_success capture - assert_match /Refund.*approved/, capture.message + assert_match(/Refund.*approved/, capture.message) end def test_successful_authorise_using_vault_id diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb index cbc94e8ab52..6be3a6dd4e6 100644 --- a/test/remote/gateways/remote_stripe_test.rb +++ b/test/remote/gateways/remote_stripe_test.rb @@ -127,7 +127,7 @@ def test_unsuccessful_purchase assert_failure response assert_match %r{Your card was declined}, response.message assert_match Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code - assert_match /ch_[a-zA-Z\d]+/, response.authorization + assert_match(/ch_[a-zA-Z\d]+/, response.authorization) end def test_unsuccessful_purchase_with_destination_and_amount @@ -493,8 +493,8 @@ def test_successful_store_of_bank_account response = @gateway.store(@check, @options) assert_success response customer_id, bank_account_id = response.authorization.split('|') - assert_match /^cus_/, customer_id - assert_match /^ba_/, bank_account_id + assert_match(/^cus_/, customer_id) + assert_match(/^ba_/, bank_account_id) end def test_unsuccessful_purchase_from_stored_but_unverified_bank_account diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb index 894b07c440e..32f0f08a199 100644 --- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb +++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb @@ -232,7 +232,7 @@ def test_failed_refund def test_successful_refund_with_echeck purchase = @gateway.purchase(@amount, @check, @options) assert_success purchase - assert_match /purchase_echeck/, purchase.authorization + assert_match(/purchase_echeck/, purchase.authorization) refund = @gateway.refund(@amount, purchase.authorization) assert_success refund diff --git a/test/remote/gateways/remote_visanet_peru_test.rb b/test/remote/gateways/remote_visanet_peru_test.rb index 5f70eaeeb3d..59425892e09 100644 --- a/test/remote/gateways/remote_visanet_peru_test.rb +++ b/test/remote/gateways/remote_visanet_peru_test.rb @@ -89,7 +89,7 @@ def test_failed_authorize def test_failed_capture response = @gateway.capture('900000044') assert_failure response - assert_match /NUMORDEN 900000044 no se encuentra registrado/, response.message + assert_match(/NUMORDEN 900000044 no se encuentra registrado/, response.message) assert_equal 400, response.error_code end @@ -116,7 +116,7 @@ def test_successful_refund_unsettled def test_failed_refund response = @gateway.refund(@amount, '900000044' ) assert_failure response - assert_match /NUMORDEN 900000044 no se encuentra registrado/, response.message + assert_match(/NUMORDEN 900000044 no se encuentra registrado/, response.message) assert_equal 400, response.error_code end @@ -132,7 +132,7 @@ def test_successful_void def test_failed_void response = @gateway.void('900000044') assert_failure response - assert_match /NUMORDEN no se encuentra registrado/, response.message + assert_match(/NUMORDEN no se encuentra registrado/, response.message) assert_equal 400, response.error_code end From 6534296404b069e0f000199ffba7309821bd1975 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 1 Nov 2018 11:07:12 -0400 Subject: [PATCH 602/677] RuboCop: fix Lint/NestedMethodDefinition --- .rubocop_todo.yml | 5 ----- test/unit/gateways/blue_pay_test.rb | 7 ++----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index deca557091e..9e10caafdfb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -266,11 +266,6 @@ Lint/HandleExceptions: - 'lib/active_merchant/billing/gateways/mastercard.rb' - 'lib/active_merchant/billing/gateways/trust_commerce.rb' -# Offense count: 1 -Lint/NestedMethodDefinition: - Exclude: - - 'test/unit/gateways/blue_pay_test.rb' - # Offense count: 4 Lint/ParenthesesAsGroupedExpression: Exclude: diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb index b7947bfc02f..5ae66d0fe58 100644 --- a/test/unit/gateways/blue_pay_test.rb +++ b/test/unit/gateways/blue_pay_test.rb @@ -175,12 +175,9 @@ def test_cvv_result end def test_message_from - def get_msg(query) - @gateway.send(:parse, query).message - end - assert_equal 'CVV does not match', get_msg('STATUS=2&CVV2=N&AVS=A&MESSAGE=FAILURE') + assert_equal 'CVV does not match', @gateway.send(:parse, 'STATUS=2&CVV2=N&AVS=A&MESSAGE=FAILURE').message assert_equal 'Street address matches, but 5-digit and 9-digit postal code do not match.', - get_msg('STATUS=2&CVV2=M&AVS=A&MESSAGE=FAILURE') + @gateway.send(:parse, 'STATUS=2&CVV2=M&AVS=A&MESSAGE=FAILURE').message end # Recurring Billing Unit Tests From f5aca23b646790cd35e503f1432e8f91587e8390 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 1 Nov 2018 11:10:10 -0400 Subject: [PATCH 603/677] RuboCop: fix Lint/ParenthesesAsGroupedExpression --- .rubocop_todo.yml | 7 ------- .../billing/gateways/trans_first_transaction_express.rb | 2 +- test/remote/gateways/remote_payment_express_test.rb | 4 ++-- test/remote/gateways/remote_worldpay_test.rb | 2 +- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9e10caafdfb..2bf8d3323a0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -266,13 +266,6 @@ Lint/HandleExceptions: - 'lib/active_merchant/billing/gateways/mastercard.rb' - 'lib/active_merchant/billing/gateways/trust_commerce.rb' -# Offense count: 4 -Lint/ParenthesesAsGroupedExpression: - Exclude: - - 'lib/active_merchant/billing/gateways/trans_first_transaction_express.rb' - - 'test/remote/gateways/remote_payment_express_test.rb' - - 'test/remote/gateways/remote_worldpay_test.rb' - # Offense count: 1 Lint/RescueException: Exclude: diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb index 546a3d4d0c1..544eea6379b 100644 --- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb @@ -539,7 +539,7 @@ def add_contact(doc, fullname, options) if (billing_address = options[:billing_address]) if billing_address[:phone] doc['v1'].phone do - doc['v1'].type (options[:phone_number_type] || '4') + doc['v1'].type(options[:phone_number_type] || '4') doc['v1'].nr billing_address[:phone].gsub(/\D/, '') end end diff --git a/test/remote/gateways/remote_payment_express_test.rb b/test/remote/gateways/remote_payment_express_test.rb index 8519fc72c5e..eeb9d3b0b33 100644 --- a/test/remote/gateways/remote_payment_express_test.rb +++ b/test/remote/gateways/remote_payment_express_test.rb @@ -107,7 +107,7 @@ def test_store_and_charge assert response = @gateway.store(@credit_card) assert_success response assert_equal 'The Transaction was approved', response.message - assert (token = response.authorization) + assert(token = response.authorization) assert purchase = @gateway.purchase( @amount, token) assert_equal 'The Transaction was approved', purchase.message @@ -119,7 +119,7 @@ def test_store_and_authorize_and_capture assert response = @gateway.store(@credit_card) assert_success response assert_equal 'The Transaction was approved', response.message - assert (token = response.authorization) + assert(token = response.authorization) assert auth = @gateway.authorize(@amount, token, @options) assert_success auth diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index f32933a1010..fd4f73be9dd 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -155,7 +155,7 @@ def test_ip_address def test_void assert_success(response = @gateway.authorize(@amount, @credit_card, @options)) sleep(40) - assert_success (void = @gateway.void(response.authorization)) + assert_success(void = @gateway.void(response.authorization)) assert_equal 'SUCCESS', void.message assert void.params['cancel_received_order_code'] end From f5913a51d23fcaead6047989620fbe10b7d9c76a Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 1 Nov 2018 11:11:23 -0400 Subject: [PATCH 604/677] RuboCop: fix Style/MethodDefParentheses --- .rubocop_todo.yml | 10 ---------- lib/active_merchant/billing/gateways/cyber_source.rb | 2 +- test/unit/gateways/quickpay_v10_test.rb | 2 +- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2bf8d3323a0..47f103efa2f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -938,16 +938,6 @@ Style/LineEndConcatenation: Style/MethodCallWithoutArgsParentheses: Enabled: false -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline -Style/MethodDefParentheses: - Exclude: - - 'lib/active_merchant/billing/gateways/cyber_source.rb' - - 'test/unit/gateways/ideal_rabobank_test.rb' - - 'test/unit/gateways/quickpay_v10_test.rb' - # Offense count: 626 Style/MultilineBlockChain: Enabled: false diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 60a0fd3caef..ec831d9377f 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -410,7 +410,7 @@ def add_business_rules_data(xml, payment_method, options) end end - def extract_option prioritized_options, option_name + def extract_option(prioritized_options, option_name) options_matching_key = prioritized_options.detect do |options| options.has_key? option_name end diff --git a/test/unit/gateways/quickpay_v10_test.rb b/test/unit/gateways/quickpay_v10_test.rb index 8a5404a3207..61bec826b5d 100644 --- a/test/unit/gateways/quickpay_v10_test.rb +++ b/test/unit/gateways/quickpay_v10_test.rb @@ -10,7 +10,7 @@ def setup @options = { :order_id => '1', :billing_address => address, :customer_ip => '1.1.1.1' } end - def parse body + def parse(body) JSON.parse(body) end From 08e19cf974dbc37863b566a36ca15442af398fac Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 1 Nov 2018 11:12:49 -0400 Subject: [PATCH 605/677] RuboCop: fix Lint/StringConversionInInterpolation --- .rubocop_todo.yml | 11 ----------- lib/active_merchant/billing/gateways/adyen.rb | 2 +- lib/active_merchant/billing/gateways/dibs.rb | 2 +- lib/active_merchant/billing/gateways/pay_junction.rb | 2 +- lib/active_merchant/billing/gateways/skip_jack.rb | 2 +- .../billing/gateways/usa_epay_advanced.rb | 4 ++-- test/remote/gateways/remote_authorize_net_cim_test.rb | 10 +++++----- 7 files changed, 11 insertions(+), 22 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 47f103efa2f..100ba02790f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -271,17 +271,6 @@ Lint/RescueException: Exclude: - 'lib/active_merchant/billing/gateways/quantum.rb' -# Offense count: 11 -# Cop supports --auto-correct. -Lint/StringConversionInInterpolation: - Exclude: - - 'lib/active_merchant/billing/gateways/adyen.rb' - - 'lib/active_merchant/billing/gateways/dibs.rb' - - 'lib/active_merchant/billing/gateways/pay_junction.rb' - - 'lib/active_merchant/billing/gateways/skip_jack.rb' - - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' - - 'test/remote/gateways/remote_authorize_net_cim_test.rb' - # Offense count: 1 Lint/UnderscorePrefixedVariableName: Exclude: diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index cef696b8d8f..a73e0b92860 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -233,7 +233,7 @@ def parse(body) def commit(action, parameters) begin - raw_response = ssl_post("#{url}/#{action.to_s}", post_data(action, parameters), request_headers) + raw_response = ssl_post("#{url}/#{action}", post_data(action, parameters), request_headers) response = parse(raw_response) rescue ResponseError => e raw_response = e.response.body diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb index 647d749bdae..d753f9fa143 100644 --- a/lib/active_merchant/billing/gateways/dibs.rb +++ b/lib/active_merchant/billing/gateways/dibs.rb @@ -159,7 +159,7 @@ def build_request(post) end def add_hmac(post) - data = post.sort.collect { |key, value| "#{key}=#{value.to_s}" }.join('&') + data = post.sort.collect { |key, value| "#{key}=#{value}" }.join('&') digest = OpenSSL::Digest.new('sha256') key = [@options[:secret_key]].pack('H*') post[:MAC] = OpenSSL::HMAC.hexdigest(digest, key, data) diff --git a/lib/active_merchant/billing/gateways/pay_junction.rb b/lib/active_merchant/billing/gateways/pay_junction.rb index 5255ef2106d..0113c737966 100644 --- a/lib/active_merchant/billing/gateways/pay_junction.rb +++ b/lib/active_merchant/billing/gateways/pay_junction.rb @@ -366,7 +366,7 @@ def post_data(action, params) params[:version] = API_VERSION params[:transaction_type] = action - params.reject{|k,v| v.blank?}.collect{ |k, v| "dc_#{k.to_s}=#{CGI.escape(v.to_s)}" }.join('&') + params.reject{|k,v| v.blank?}.collect{ |k, v| "dc_#{k}=#{CGI.escape(v.to_s)}" }.join('&') end def parse(body) diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb index 7dbf0372d62..5e5b8a91534 100644 --- a/lib/active_merchant/billing/gateways/skip_jack.rb +++ b/lib/active_merchant/billing/gateways/skip_jack.rb @@ -354,7 +354,7 @@ def post_data(action, money, params = {}) add_credentials(params, action) add_amount(params, action, money) sorted_params = params.to_a.sort{|a,b| a.to_s <=> b.to_s}.reverse - sorted_params.collect { |key, value| "#{key.to_s}=#{CGI.escape(value.to_s)}" }.join('&') + sorted_params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def add_transaction_id(post, transaction_id) diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb index bf38626368a..a34d269abb6 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb @@ -272,8 +272,8 @@ def initialize(options = {}) requires!(options, :login, :password) if options[:software_id] - self.live_url = "#{LIVE_URL_BASE}#{options[:software_id].to_s}" - self.test_url = "#{TEST_URL_BASE}#{options[:software_id].to_s}" + self.live_url = "#{LIVE_URL_BASE}#{options[:software_id]}" + self.test_url = "#{TEST_URL_BASE}#{options[:software_id]}" else self.live_url = options[:live_url].to_s self.test_url = options[:test_url].to_s if options[:test_url] diff --git a/test/remote/gateways/remote_authorize_net_cim_test.rb b/test/remote/gateways/remote_authorize_net_cim_test.rb index 08001073228..124b81c7753 100644 --- a/test/remote/gateways/remote_authorize_net_cim_test.rb +++ b/test/remote/gateways/remote_authorize_net_cim_test.rb @@ -615,7 +615,7 @@ def test_should_create_duplicate_customer_profile_transactions_with_duplicate_wi :type => :auth_capture, :order => { :invoice_number => key.to_s, - :description => "Test Order Description #{key.to_s}", + :description => "Test Order Description #{key}", :purchase_order_number => key.to_s }, :amount => @amount @@ -651,7 +651,7 @@ def test_should_not_create_duplicate_customer_profile_transactions_without_dupli :type => :auth_capture, :order => { :invoice_number => key.to_s, - :description => "Test Order Description #{key.to_s}", + :description => "Test Order Description #{key}", :purchase_order_number => key.to_s }, :amount => @amount @@ -821,7 +821,7 @@ def get_and_validate_auth_capture_response :type => :auth_capture, :order => { :invoice_number => key.to_s, - :description => "Test Order Description #{key.to_s}", + :description => "Test Order Description #{key}", :purchase_order_number => key.to_s }, :amount => @amount @@ -836,7 +836,7 @@ def get_and_validate_auth_capture_response assert_equal 'auth_capture', response.params['direct_response']['transaction_type'] assert_equal '100.00', response.params['direct_response']['amount'] assert_equal response.params['direct_response']['invoice_number'], key.to_s - assert_equal response.params['direct_response']['order_description'], "Test Order Description #{key.to_s}" + assert_equal response.params['direct_response']['order_description'], "Test Order Description #{key}" assert_equal response.params['direct_response']['purchase_order_number'], key.to_s return response end @@ -856,7 +856,7 @@ def get_and_validate_auth_only_response :type => :auth_only, :order => { :invoice_number => key.to_s, - :description => "Test Order Description #{key.to_s}", + :description => "Test Order Description #{key}", :purchase_order_number => key.to_s }, :amount => @amount From d548ddfacf98bcd07ee4636046ad90fabb4a6b5c Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 1 Nov 2018 11:16:31 -0400 Subject: [PATCH 606/677] RuboCop: fix Style/Lambda --- .rubocop_todo.yml | 8 -------- lib/active_merchant/billing/gateways/orbital.rb | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 100ba02790f..62b89cf66cf 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -903,14 +903,6 @@ Style/InverseMethods: - 'lib/active_merchant/billing/gateways/ogone.rb' - 'lib/active_merchant/billing/gateways/worldpay.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: line_count_dependent, lambda, literal -Style/Lambda: - Exclude: - - 'lib/active_merchant/billing/gateways/orbital.rb' - # Offense count: 15 # Cop supports --auto-correct. Style/LineEndConcatenation: diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index 53ac7b2ac25..89a5007f85b 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -531,7 +531,7 @@ def commit(order, message_type, trace_number=nil) headers = POST_HEADERS.merge('Content-length' => order.size.to_s) headers.merge!( 'Trace-number' => trace_number.to_s, 'Merchant-Id' => @options[:merchant_id] ) if @options[:retry_logic] && trace_number - request = lambda{|url| parse(ssl_post(url, order, headers))} + request = ->(url){ parse(ssl_post(url, order, headers))} # Failover URL will be attempted in the event of a connection error response = begin From a23919156f315f895341480c26512ab314cc8e71 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 1 Nov 2018 11:18:30 -0400 Subject: [PATCH 607/677] RuboCop: fix Style/LineEndConcatenation --- .rubocop_todo.yml | 10 ---------- lib/active_merchant/billing/gateways/commercegate.rb | 4 ++-- lib/active_merchant/billing/gateways/pay_hub.rb | 2 +- lib/active_merchant/billing/gateways/swipe_checkout.rb | 4 ++-- test/unit/gateways/barclays_epdq_extra_plus_test.rb | 10 +++++----- test/unit/gateways/ogone_test.rb | 10 +++++----- 6 files changed, 15 insertions(+), 25 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 62b89cf66cf..cae28dbf98e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -903,16 +903,6 @@ Style/InverseMethods: - 'lib/active_merchant/billing/gateways/ogone.rb' - 'lib/active_merchant/billing/gateways/worldpay.rb' -# Offense count: 15 -# Cop supports --auto-correct. -Style/LineEndConcatenation: - Exclude: - - 'lib/active_merchant/billing/gateways/commercegate.rb' - - 'lib/active_merchant/billing/gateways/pay_hub.rb' - - 'lib/active_merchant/billing/gateways/swipe_checkout.rb' - - 'test/unit/gateways/barclays_epdq_extra_plus_test.rb' - - 'test/unit/gateways/ogone_test.rb' - # Offense count: 31 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. diff --git a/lib/active_merchant/billing/gateways/commercegate.rb b/lib/active_merchant/billing/gateways/commercegate.rb index c831141b0c8..f3cd6500830 100644 --- a/lib/active_merchant/billing/gateways/commercegate.rb +++ b/lib/active_merchant/billing/gateways/commercegate.rb @@ -126,8 +126,8 @@ def message_from(response) if response['returnText'].present? response['returnText'] else - 'Invalid response received from the CommerceGate API. ' + - 'Please contact CommerceGate support if you continue to receive this message. ' + + 'Invalid response received from the CommerceGate API. ' \ + 'Please contact CommerceGate support if you continue to receive this message. ' \ "(The raw response returned by the API was #{response.inspect})" end end diff --git a/lib/active_merchant/billing/gateways/pay_hub.rb b/lib/active_merchant/billing/gateways/pay_hub.rb index d354f5c1db9..47c6ac35cc7 100644 --- a/lib/active_merchant/billing/gateways/pay_hub.rb +++ b/lib/active_merchant/billing/gateways/pay_hub.rb @@ -200,7 +200,7 @@ def response_error(raw_response) def json_error(raw_response) { - error_message: 'Invalid response received from the Payhub API. Please contact wecare@payhub.com if you continue to receive this message.' + + error_message: 'Invalid response received from the Payhub API. Please contact wecare@payhub.com if you continue to receive this message.' \ " (The raw response returned by the API was #{raw_response.inspect})" } end diff --git a/lib/active_merchant/billing/gateways/swipe_checkout.rb b/lib/active_merchant/billing/gateways/swipe_checkout.rb index dcd63d1fdec..aaf4002d355 100644 --- a/lib/active_merchant/billing/gateways/swipe_checkout.rb +++ b/lib/active_merchant/billing/gateways/swipe_checkout.rb @@ -117,8 +117,8 @@ def commit(action, money, parameters) rescue ResponseError => e build_error_response("ssl_post() with url #{url} raised ResponseError: #{e}") rescue JSON::ParserError => e - msg = 'Invalid response received from the Swipe Checkout API. ' + - 'Please contact support@optimizerhq.com if you continue to receive this message.' + + msg = 'Invalid response received from the Swipe Checkout API. ' \ + 'Please contact support@optimizerhq.com if you continue to receive this message.' \ " (Full error message: #{e})" build_error_response(msg) end diff --git a/test/unit/gateways/barclays_epdq_extra_plus_test.rb b/test/unit/gateways/barclays_epdq_extra_plus_test.rb index 2155d23a374..330bdf13d4d 100644 --- a/test/unit/gateways/barclays_epdq_extra_plus_test.rb +++ b/test/unit/gateways/barclays_epdq_extra_plus_test.rb @@ -414,15 +414,15 @@ def test_transcript_scrubbing private def string_to_digest - 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'+ - 'CN=Client NamemynicesigCURRENCY=EURmynicesigOPERATION=RESmynicesig'+ + 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'\ + 'CN=Client NamemynicesigCURRENCY=EURmynicesigOPERATION=RESmynicesig'\ 'ORDERID=1mynicesigPSPID=MrPSPIDmynicesig' end def d3d_string_to_digest - 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'+ - 'CN=Client NamemynicesigCURRENCY=EURmynicesigFLAG3D=Ymynicesig'+ - 'HTTP_ACCEPT=*/*mynicesigOPERATION=RESmynicesigORDERID=1mynicesig'+ + 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'\ + 'CN=Client NamemynicesigCURRENCY=EURmynicesigFLAG3D=Ymynicesig'\ + 'HTTP_ACCEPT=*/*mynicesigOPERATION=RESmynicesigORDERID=1mynicesig'\ 'PSPID=MrPSPIDmynicesigWIN3DS=MAINWmynicesig' end diff --git a/test/unit/gateways/ogone_test.rb b/test/unit/gateways/ogone_test.rb index 3118e4b7193..8454a030cfd 100644 --- a/test/unit/gateways/ogone_test.rb +++ b/test/unit/gateways/ogone_test.rb @@ -453,15 +453,15 @@ def test_transcript_scrubbing private def string_to_digest - 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'+ - 'CN=Client NamemynicesigCURRENCY=EURmynicesigOPERATION=RESmynicesig'+ + 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'\ + 'CN=Client NamemynicesigCURRENCY=EURmynicesigOPERATION=RESmynicesig'\ 'ORDERID=1mynicesigPSPID=MrPSPIDmynicesig' end def d3d_string_to_digest - 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'+ - 'CN=Client NamemynicesigCURRENCY=EURmynicesigFLAG3D=Ymynicesig'+ - 'HTTP_ACCEPT=*/*mynicesigOPERATION=RESmynicesigORDERID=1mynicesig'+ + 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'\ + 'CN=Client NamemynicesigCURRENCY=EURmynicesigFLAG3D=Ymynicesig'\ + 'HTTP_ACCEPT=*/*mynicesigOPERATION=RESmynicesigORDERID=1mynicesig'\ 'PSPID=MrPSPIDmynicesigWIN3DS=MAINWmynicesig' end From 3e4930f652435904448df6f28930a36d07fa3541 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 1 Nov 2018 11:20:03 -0400 Subject: [PATCH 608/677] RuboCop: fix Lint/UnderscorePrefixedVariableName --- .rubocop_todo.yml | 5 ----- lib/active_merchant/billing/gateways/ogone.rb | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cae28dbf98e..21f586c44be 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -271,11 +271,6 @@ Lint/RescueException: Exclude: - 'lib/active_merchant/billing/gateways/quantum.rb' -# Offense count: 1 -Lint/UnderscorePrefixedVariableName: - Exclude: - - 'lib/active_merchant/billing/gateways/ogone.rb' - # Offense count: 1453 # Cop supports --auto-correct. # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb index 0ac3b015f75..776fa67b0a4 100644 --- a/lib/active_merchant/billing/gateways/ogone.rb +++ b/lib/active_merchant/billing/gateways/ogone.rb @@ -301,8 +301,8 @@ def add_eci(post, eci) add_pair post, 'ECI', eci.to_s end - def add_alias(post, _alias, alias_operation = nil) - add_pair post, 'ALIAS', _alias + def add_alias(post, alias_name, alias_operation = nil) + add_pair post, 'ALIAS', alias_name add_pair post, 'ALIASOPERATION', alias_operation unless alias_operation.nil? end From 695bd9a7be3e5c8bac95feadaa43bdbb0ad2e108 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 1 Nov 2018 11:22:45 -0400 Subject: [PATCH 609/677] RuboCop: fix Layout/SpaceInsideStringInterpolation --- .rubocop_todo.yml | 10 ---------- lib/active_merchant/billing/gateways/garanti.rb | 2 +- lib/active_merchant/billing/gateways/trust_commerce.rb | 2 +- test/unit/gateways/worldpay_test.rb | 2 +- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 21f586c44be..ad95f8046e4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -231,16 +231,6 @@ Layout/SpaceInsideReferenceBrackets: - 'test/remote/gateways/remote_ideal_rabobank_test.rb' - 'test/remote/gateways/remote_wirecard_test.rb' -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceInsideStringInterpolation: - Exclude: - - 'lib/active_merchant/billing/gateways/garanti.rb' - - 'lib/active_merchant/billing/gateways/trust_commerce.rb' - - 'test/unit/gateways/worldpay_test.rb' - # Offense count: 148 # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb index 5a95e3383db..ef2dacc84c8 100644 --- a/lib/active_merchant/billing/gateways/garanti.rb +++ b/lib/active_merchant/billing/gateways/garanti.rb @@ -181,7 +181,7 @@ def add_addresses(xml, options) def add_address(xml, address) xml.tag! 'Name', normalize(address[:name]) address_text = address[:address1] - address_text << " #{ address[:address2]}" if address[:address2] + address_text << " #{address[:address2]}" if address[:address2] xml.tag! 'Text', normalize(address_text) xml.tag! 'City', normalize(address[:city]) xml.tag! 'District', normalize(address[:state]) diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb index 2b3dae1ec69..7fab693c69e 100644 --- a/lib/active_merchant/billing/gateways/trust_commerce.rb +++ b/lib/active_merchant/billing/gateways/trust_commerce.rb @@ -371,7 +371,7 @@ def clean_and_stringify_params(parameters) end def post_data(parameters) - parameters.collect { |key, value| "#{key}=#{ CGI.escape(value.to_s)}" }.join('&') + parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def commit(action, parameters) diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index 7fe93d7acc2..e40767eda0a 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -655,7 +655,7 @@ def successful_refund_inquiry_response(last_event='CAPTURED') <payment> <paymentMethod>VISA-SSL</paymentMethod> <amount value="100" currencyCode="GBP" exponent="2" debitCreditIndicator="credit"/> - <lastEvent>#{ last_event }</lastEvent> + <lastEvent>#{last_event}</lastEvent> <CVCResultCode description="UNKNOWN"/> <AVSResultCode description="NOT SUPPLIED BY SHOPPER"/> <balance accountType="IN_PROCESS_AUTHORISED"> From 12f15a70f6c12bf3397d7be6fa66dc1c1438d1fd Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 1 Nov 2018 11:38:57 -0400 Subject: [PATCH 610/677] RuboCop: fix Lint/DuplicateMethods --- .rubocop_todo.yml | 9 --- .../remote_litle_certification_test.rb | 56 ------------------- .../remote_mercury_certification_test.rb | 24 -------- .../gateways/remote_modern_payments_test.rb | 11 ---- test/remote/gateways/remote_netaxept_test.rb | 14 ----- test/remote/gateways/remote_verifi_test.rb | 9 --- 6 files changed, 123 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ad95f8046e4..70e66b6ae38 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -236,15 +236,6 @@ Layout/SpaceInsideReferenceBrackets: Lint/AssignmentInCondition: Enabled: false -# Offense count: 8 -Lint/DuplicateMethods: - Exclude: - - 'test/remote/gateways/remote_litle_certification_test.rb' - - 'test/remote/gateways/remote_mercury_certification_test.rb' - - 'test/remote/gateways/remote_modern_payments_test.rb' - - 'test/remote/gateways/remote_netaxept_test.rb' - - 'test/remote/gateways/remote_verifi_test.rb' - # Offense count: 3 Lint/FormatParameterMismatch: Exclude: diff --git a/test/remote/gateways/remote_litle_certification_test.rb b/test/remote/gateways/remote_litle_certification_test.rb index 90335ac3a7b..c36e352e476 100644 --- a/test/remote/gateways/remote_litle_certification_test.rb +++ b/test/remote/gateways/remote_litle_certification_test.rb @@ -1161,62 +1161,6 @@ def test_authorize_and_purchase_and_credit_with_token private - def auth_assertions(amount, card, options, assertions={}) - # 1: authorize - assert response = @gateway.authorize(amount, card, options) - assert_success response - assert_equal 'Approved', response.message - assert_equal assertions[:avs], response.avs_result['code'] if assertions[:avs] - assert_equal assertions[:cvv], response.cvv_result['code'] if assertions[:cvv] - assert_equal auth_code(options[:order_id]), response.params['authCode'] - puts "Test #{options[:order_id]} Authorize: #{txn_id(response)}" - - # 1A: capture - assert response = @gateway.capture(amount, response.authorization, {:id => transaction_id}) - assert_equal 'Approved', response.message - puts "Test #{options[:order_id]}A: #{txn_id(response)}" - - # 1B: credit - assert response = @gateway.credit(amount, response.authorization, {:id => transaction_id}) - assert_equal 'Approved', response.message - puts "Test #{options[:order_id]}B: #{txn_id(response)}" - - # 1C: void - assert response = @gateway.void(response.authorization, {:id => transaction_id}) - assert_equal 'Approved', response.message - puts "Test #{options[:order_id]}C: #{txn_id(response)}" - end - - def authorize_avs_assertions(credit_card, options, assertions={}) - assert response = @gateway.authorize(000, credit_card, options) - assert_equal assertions.key?(:success) ? assertions[:success] : true, response.success? - assert_equal assertions[:message] || 'Approved', response.message - assert_equal assertions[:avs], response.avs_result['code'], caller.inspect - assert_equal assertions[:cvv], response.cvv_result['code'], caller.inspect if assertions[:cvv] - puts "Test #{options[:order_id]} AVS Only: #{txn_id(response)}" - end - - def sale_assertions(amount, card, options, assertions={}) - # 1: sale - assert response = @gateway.purchase(amount, card, options) - assert_success response - assert_equal 'Approved', response.message - assert_equal assertions[:avs], response.avs_result['code'] if assertions[:avs] - assert_equal assertions[:cvv], response.cvv_result['code'] if assertions[:cvv] - assert_equal auth_code(options[:order_id]), response.params['authCode'] - puts "Test #{options[:order_id]} Sale: #{txn_id(response)}" - - # 1B: credit - assert response = @gateway.credit(amount, response.authorization, {:id => transaction_id}) - assert_equal 'Approved', response.message - puts "Test #{options[:order_id]}B Sale: #{txn_id(response)}" - - # 1C: void - assert response = @gateway.void(response.authorization, {:id => transaction_id}) - assert_equal 'Approved', response.message - puts "Test #{options[:order_id]}C Sale: #{txn_id(response)}" - end - def auth_assertions(amount, card, options, assertions={}) # 1: authorize assert response = @gateway.authorize(amount, card, options) diff --git a/test/remote/gateways/remote_mercury_certification_test.rb b/test/remote/gateways/remote_mercury_certification_test.rb index f019b3ad045..56cb9de3234 100644 --- a/test/remote/gateways/remote_mercury_certification_test.rb +++ b/test/remote/gateways/remote_mercury_certification_test.rb @@ -30,30 +30,6 @@ def test_sale_and_void assert_equal 'AP', void.params['text_response'] end - def test_preauth_capture_and_reversal - close_batch(tokenization_gateway) - - cc = credit_card( - '4005550000000480', - :brand => 'visa', - :month => '12', - :year => '15', - :verification_value => '123' - ) - - preauth = tokenization_gateway.authorize(106, cc, options('1')) - assert_success preauth - assert_equal 'AP', preauth.params['text_response'] - - capture = tokenization_gateway.capture(106, preauth.authorization, options) - assert_success capture - assert_equal 'AP', capture.params['text_response'] - - reversal = tokenization_gateway.void(capture.authorization, options.merge(:try_reversal => true)) - assert_success reversal - assert_equal 'REVERSED', reversal.params['text_response'] - end - def test_return close_batch(tokenization_gateway) diff --git a/test/remote/gateways/remote_modern_payments_test.rb b/test/remote/gateways/remote_modern_payments_test.rb index cb5d594afa7..e0fff6eeb95 100644 --- a/test/remote/gateways/remote_modern_payments_test.rb +++ b/test/remote/gateways/remote_modern_payments_test.rb @@ -32,16 +32,6 @@ def test_unsuccessful_purchase assert_equal ModernPaymentsCimGateway::FAILURE_MESSAGE, response.message end - def test_invalid_login - gateway = ModernPaymentsGateway.new( - :login => '5000', - :password => 'password' - ) - assert response = gateway.purchase(@amount, @credit_card, @options) - assert_failure response - assert_equal ModernPaymentsCimGateway::FAILURE_MESSAGE, response.message - end - def test_invalid_login gateway = ModernPaymentsGateway.new( :login => '', @@ -52,5 +42,4 @@ def test_invalid_login gateway.purchase(@amount, @credit_card, @options) end end - end diff --git a/test/remote/gateways/remote_netaxept_test.rb b/test/remote/gateways/remote_netaxept_test.rb index 5219b4144bc..6112d9798c9 100644 --- a/test/remote/gateways/remote_netaxept_test.rb +++ b/test/remote/gateways/remote_netaxept_test.rb @@ -74,20 +74,6 @@ def test_failed_void assert_equal 'Unable to annul, wrong state', response.message end - def test_successful_amex_purchase - credit_card = credit_card('378282246310005', :brand => 'american_express') - assert response = @gateway.purchase(@amount, credit_card, @options) - assert_success response - assert_equal 'OK', response.message - end - - def test_successful_master_purchase - credit_card = credit_card('5413000000000000', :brand => 'master') - assert response = @gateway.purchase(@amount, credit_card, @options) - assert_success response - assert_equal 'OK', response.message - end - def test_error_in_transaction_setup assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:currency => 'BOGG')) assert_failure response diff --git a/test/remote/gateways/remote_verifi_test.rb b/test/remote/gateways/remote_verifi_test.rb index d9579c15752..2514864a96f 100644 --- a/test/remote/gateways/remote_verifi_test.rb +++ b/test/remote/gateways/remote_verifi_test.rb @@ -58,15 +58,6 @@ def test_authorization_and_capture assert_equal 'Transaction was Approved', capture.message end - def test_authorization_and_void - assert authorization = @gateway.authorize(@amount, @credit_card, @options) - assert_success authorization - assert authorization - assert void = @gateway.void(authorization.authorization, @options) - assert_success void - assert_equal 'Transaction was Approved', void.message - end - # Credits are not enabled on test accounts, so this should always fail def test_credit assert response = @gateway.credit(@amount, @credit_card, @options) From db320231388bcc434684f7aebc2d1537db476b6b Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Fri, 2 Nov 2018 09:59:38 -0400 Subject: [PATCH 611/677] Braintree: Account for nil billing address fields The earlier fix for phone-only billing address options did not account for other elements being present but nil. Now we compact the address. Closes #3029 Remote: 64 tests, 365 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 56 tests, 141 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/braintree_blue.rb | 2 +- .../gateways/remote_braintree_blue_test.rb | 3 +- test/unit/gateways/braintree_blue_test.rb | 28 +++++++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1f9e4bbbe9d..d98fa432d0a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ * Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026 * Braintree: Fix passing phone-only billing address [curiousepic] #3025 * Litle: Capitalize check account type [curiousepic] #3028 +* Braintree: Account for nil billing address fields [curiousepic] #3029 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index d693e587fed..067fadc5299 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -305,7 +305,7 @@ def merge_credit_card_options(parameters, options) parameters[:credit_card] ||= {} parameters[:credit_card].merge!(:options => valid_options) address = options[:billing_address]&.except(:phone) - return parameters if address.nil? || address.empty? + return parameters if address.nil? || address.values.compact.empty? parameters[:credit_card][:billing_address] = map_address(address) parameters end diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index 22885692808..ff816acb973 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -170,7 +170,8 @@ def test_successful_store_with_billing_address def test_successful_store_with_phone_only_billing_address_option billing_address = { - :phone => '123-456-7890' + :phone => '123-456-7890', + :city => nil } credit_card = credit_card('5105105105105100') assert response = @gateway.store(credit_card, :billing_address => billing_address) diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index 68a6092da88..0a604b717f5 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -373,6 +373,34 @@ def test_store_with_phone_only_billing_address_option @gateway.store(credit_card('41111111111111111111'), :billing_address => billing_address) end + def test_store_with_phone_only_non_nil_billing_address_option + customer_attributes = { + :credit_cards => [stub_everything], + :email => 'email', + :first_name => 'John', + :last_name => 'Smith', + :phone => '123-456-7890' + } + billing_address = { + :phone => '123-456-7890', + :address1 => nil, + :address2 => nil, + :city => nil, + :state => nil, + :zip => nil, + :country_name => nil + } + customer = stub(customer_attributes) + customer.stubs(:id).returns('123') + result = Braintree::SuccessfulResult.new(:customer => customer) + Braintree::CustomerGateway.any_instance.expects(:create).with do |params| + assert_nil params[:credit_card][:billing_address] + params + end.returns(result) + + @gateway.store(credit_card('41111111111111111111'), :billing_address => billing_address) + end + def test_store_with_credit_card_token customer = stub( :email => 'email', From 2f4b8e0e1e8e248d6e32042e90792e4cd49a2390 Mon Sep 17 00:00:00 2001 From: Kheang Lim <kheang@spreedly.com> Date: Fri, 2 Nov 2018 11:48:10 -0400 Subject: [PATCH 612/677] Realex: Add verify Add verify method by making an Open to Buy (OTB) request: https://developer.realexpayments.com/#!/api/process-payment/otb Closes #3030 Remote (1 unrelated failure from `test_realex_purchase_then_refund`): 23 tests, 122 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 95.6522% passed Unit: 22 tests, 526 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/realex.rb | 21 ++++++++++++ test/remote/gateways/remote_realex_test.rb | 26 +++++++++++++++ test/unit/gateways/realex_test.rb | 32 ++++++++++++++++++- 4 files changed, 79 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index d98fa432d0a..d678c59ba95 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * Braintree: Fix passing phone-only billing address [curiousepic] #3025 * Litle: Capitalize check account type [curiousepic] #3028 * Braintree: Account for nil billing address fields [curiousepic] #3029 +* Realex: Add verify [kheang] #3030 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index bfe4733cd72..6d58ea3f6e9 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -80,6 +80,13 @@ def void(authorization, options = {}) commit(request) end + def verify(credit_card, options = {}) + requires!(options, :order_id) + + request = build_verify_request(credit_card, options) + commit(request) + end + def supports_scrubbing true end @@ -185,6 +192,20 @@ def build_void_request(authorization, options) xml.target! end + # Verify initiates an OTB (Open To Buy) request + def build_verify_request(credit_card, options) + timestamp = new_timestamp + xml = Builder::XmlMarkup.new :indent => 2 + xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'otb' do + add_merchant_details(xml, options) + xml.tag! 'orderid', sanitize_order_id(options[:order_id]) + add_card(xml, credit_card) + add_comments(xml, options) + add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), credit_card.number) + end + xml.target! + end + def add_address_and_customer_info(xml, options) billing_address = options[:billing_address] || options[:address] shipping_address = options[:shipping_address] diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb index fc1800f2c63..b8280a6d8bc 100644 --- a/test/remote/gateways/remote_realex_test.rb +++ b/test/remote/gateways/remote_realex_test.rb @@ -328,6 +328,32 @@ def test_realex_purchase_then_refund assert_equal 'Successful', rebate_response.message end + def test_realex_verify + response = @gateway.verify(@visa, + :order_id => generate_unique_id, + :description => 'Test Realex verify' + ) + + assert_not_nil response + assert_success response + assert response.test? + assert response.authorization.length > 0 + assert_equal 'Successful', response.message + end + + def test_realex_verify_declined + response = @gateway.verify(@visa_declined, + :order_id => generate_unique_id, + :description => 'Test Realex verify declined' + ) + + assert_not_nil response + assert_failure response + assert response.test? + assert_equal '101', response.params['result'] + assert_match %r{DECLINED}i, response.message + end + def test_maps_avs_and_cvv_response_codes [ @visa, @mastercard ].each do |card| response = @gateway.purchase(@amount, card, diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb index e30172fa1ed..8eb73a2ed5b 100644 --- a/test/unit/gateways/realex_test.rb +++ b/test/unit/gateways/realex_test.rb @@ -3,7 +3,8 @@ class RealexTest < Test::Unit::TestCase class ActiveMerchant::Billing::RealexGateway # For the purposes of testing, lets redefine some protected methods as public. - public :build_purchase_or_authorization_request, :build_refund_request, :build_void_request, :build_capture_request + public :build_purchase_or_authorization_request, :build_refund_request, :build_void_request, + :build_capture_request, :build_verify_request end def setup @@ -193,6 +194,35 @@ def test_void_xml assert_xml_equal valid_void_request_xml, @gateway.build_void_request('1;4321;1234', {}) end + def test_verify_xml + options = { + :order_id => '1' + } + @gateway.expects(:new_timestamp).returns('20181026114304') + + valid_verify_request_xml = <<-SRC +<request timestamp="20181026114304" type="otb"> + <merchantid>your_merchant_id</merchantid> + <account>your_account</account> + <orderid>1</orderid> + <card> + <number>4263971921001307</number> + <expdate>0808</expdate> + <chname>Longbob Longsen</chname> + <type>VISA</type> + <issueno></issueno> + <cvn> + <number></number> + <presind></presind> + </cvn> + </card> + <sha1hash>d53aebf1eaee4c3ff4c30f83f27b80ce99ba5644</sha1hash> +</request> +SRC + + assert_xml_equal valid_verify_request_xml, @gateway.build_verify_request(@credit_card, options) + end + def test_auth_xml options = { :order_id => '1' From d1c2025a9cfe6f6ff14093cfcb7b83adc2b257f2 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 2 Nov 2018 15:33:07 -0400 Subject: [PATCH 613/677] RuboCop: fix Style/RandomWithOffset --- .rubocop_todo.yml | 13 ------------- lib/active_merchant/billing/gateways/borgun.rb | 2 +- test/remote/gateways/remote_beanstream_test.rb | 2 +- .../remote/gateways/remote_braintree_orange_test.rb | 6 +++--- test/remote/gateways/remote_inspire_test.rb | 6 +++--- test/remote/gateways/remote_merchant_ware_test.rb | 2 +- .../remote_merchant_ware_version_four_test.rb | 2 +- test/remote/gateways/remote_pay_junction_test.rb | 2 +- test/unit/gateways/beanstream_test.rb | 2 +- 9 files changed, 12 insertions(+), 25 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 70e66b6ae38..9939f162946 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1073,19 +1073,6 @@ Style/Proc: Style/RaiseArgs: Enabled: false -# Offense count: 12 -# Cop supports --auto-correct. -Style/RandomWithOffset: - Exclude: - - 'lib/active_merchant/billing/gateways/borgun.rb' - - 'test/remote/gateways/remote_beanstream_test.rb' - - 'test/remote/gateways/remote_braintree_orange_test.rb' - - 'test/remote/gateways/remote_inspire_test.rb' - - 'test/remote/gateways/remote_merchant_ware_test.rb' - - 'test/remote/gateways/remote_merchant_ware_version_four_test.rb' - - 'test/remote/gateways/remote_pay_junction_test.rb' - - 'test/unit/gateways/beanstream_test.rb' - # Offense count: 87 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb index 3705be21163..966124156ce 100644 --- a/lib/active_merchant/billing/gateways/borgun.rb +++ b/lib/active_merchant/billing/gateways/borgun.rb @@ -213,7 +213,7 @@ def url(action) end def six_random_digits - (0...6).map { (48 + rand(10)).chr }.join + (0...6).map { rand(48..57).chr }.join end end end diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb index e4dd84e4680..876a02f65f0 100644 --- a/test/remote/gateways/remote_beanstream_test.rb +++ b/test/remote/gateways/remote_beanstream_test.rb @@ -316,7 +316,7 @@ def test_successful_add_to_vault_with_store_method end def test_add_to_vault_with_custom_vault_id_with_store_method - @options[:vault_id] = rand(100000)+10001 + @options[:vault_id] = rand(10001..110000) assert response = @gateway.store(@visa, @options.dup) assert_equal 'Operation Successful', response.message assert_success response diff --git a/test/remote/gateways/remote_braintree_orange_test.rb b/test/remote/gateways/remote_braintree_orange_test.rb index 4b4e659e4a3..0816eb1821b 100644 --- a/test/remote/gateways/remote_braintree_orange_test.rb +++ b/test/remote/gateways/remote_braintree_orange_test.rb @@ -4,7 +4,7 @@ class RemoteBraintreeOrangeTest < Test::Unit::TestCase def setup @gateway = BraintreeGateway.new(fixtures(:braintree_orange)) - @amount = rand(10000) + 1001 + @amount = rand(1001..11000) @credit_card = credit_card('4111111111111111') @check = check() @declined_amount = rand(99) @@ -67,7 +67,7 @@ def test_successful_add_to_vault_and_use end def test_add_to_vault_with_custom_vault_id - @options[:store] = rand(100000)+10001 + @options[:store] = rand(10001..110000) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_equal 'This transaction has been approved', response.message assert_success response @@ -75,7 +75,7 @@ def test_add_to_vault_with_custom_vault_id end def test_add_to_vault_with_custom_vault_id_with_store_method - @options[:billing_id] = rand(100000)+10001 + @options[:billing_id] = rand(10001..110000) assert response = @gateway.store(@credit_card, @options.dup) assert_equal 'Customer Added', response.message assert_success response diff --git a/test/remote/gateways/remote_inspire_test.rb b/test/remote/gateways/remote_inspire_test.rb index 221ea62b17a..4e137b4d3ff 100644 --- a/test/remote/gateways/remote_inspire_test.rb +++ b/test/remote/gateways/remote_inspire_test.rb @@ -4,7 +4,7 @@ class RemoteBraintreeTest < Test::Unit::TestCase def setup @gateway = InspireGateway.new(fixtures(:inspire)) - @amount = rand(10000) + 1001 + @amount = rand(1001..11000) @credit_card = credit_card('4111111111111111', :brand => 'visa') @declined_amount = rand(99) @options = { :order_id => generate_unique_id, @@ -57,7 +57,7 @@ def test_successful_add_to_vault_and_use end def test_add_to_vault_with_custom_vault_id - @options[:store] = rand(100000)+10001 + @options[:store] = rand(10001..110000) response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal 'This transaction has been approved', response.message @@ -65,7 +65,7 @@ def test_add_to_vault_with_custom_vault_id end def test_add_to_vault_with_custom_vault_id_with_store_method - @options[:billing_id] = rand(100000)+10001 + @options[:billing_id] = rand(10001..110000) response = @gateway.store(@credit_card, @options.dup) assert_success response assert_equal 'This transaction has been approved', response.message diff --git a/test/remote/gateways/remote_merchant_ware_test.rb b/test/remote/gateways/remote_merchant_ware_test.rb index 71c812e730a..b4b4dc2c899 100644 --- a/test/remote/gateways/remote_merchant_ware_test.rb +++ b/test/remote/gateways/remote_merchant_ware_test.rb @@ -4,7 +4,7 @@ class RemoteMerchantWareTest < Test::Unit::TestCase def setup @gateway = MerchantWareGateway.new(fixtures(:merchant_ware)) - @amount = rand(1000) + 200 + @amount = rand(200..1199) @credit_card = credit_card('5424180279791732', {:brand => 'master'}) diff --git a/test/remote/gateways/remote_merchant_ware_version_four_test.rb b/test/remote/gateways/remote_merchant_ware_version_four_test.rb index 98bb62a166d..9d02a5514d2 100644 --- a/test/remote/gateways/remote_merchant_ware_version_four_test.rb +++ b/test/remote/gateways/remote_merchant_ware_version_four_test.rb @@ -3,7 +3,7 @@ class RemoteMerchantWareVersionFourTest < Test::Unit::TestCase def setup @gateway = MerchantWareVersionFourGateway.new(fixtures(:merchant_ware_version_four)) - @amount = rand(1000) + 200 + @amount = rand(200..1199) @credit_card = credit_card('5424180279791732', {:brand => 'master'}) @declined_card = credit_card('1234567890123') diff --git a/test/remote/gateways/remote_pay_junction_test.rb b/test/remote/gateways/remote_pay_junction_test.rb index 7514b3c8a5a..bacaae52e44 100644 --- a/test/remote/gateways/remote_pay_junction_test.rb +++ b/test/remote/gateways/remote_pay_junction_test.rb @@ -138,6 +138,6 @@ def test_should_send_invoice private def success_price - 200 + rand(200) + rand(200..399) end end diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb index 985748dfd03..c07adf22c0e 100644 --- a/test/unit/gateways/beanstream_test.rb +++ b/test/unit/gateways/beanstream_test.rb @@ -139,7 +139,7 @@ def test_successful_purchase_with_check def test_successful_purchase_with_vault @gateway.expects(:ssl_post).returns(successful_purchase_response) - vault = rand(100000)+10001 + vault = rand(10001..110000) assert response = @gateway.purchase(@amount, vault, @options) assert_success response From e789801bcf3dbc9ca69dd4887f69459ff7f76131 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 2 Nov 2018 15:35:01 -0400 Subject: [PATCH 614/677] RuboCop: fix Style/TernaryParentheses --- .rubocop_todo.yml | 18 ------------------ .../gateways/beanstream/beanstream_core.rb | 6 +++--- .../billing/gateways/blue_snap.rb | 6 +++--- lib/active_merchant/billing/gateways/borgun.rb | 2 +- .../billing/gateways/card_stream.rb | 2 +- lib/active_merchant/billing/gateways/litle.rb | 2 +- lib/active_merchant/billing/gateways/ogone.rb | 2 +- .../billing/gateways/payeezy.rb | 2 +- .../billing/gateways/visanet_peru.rb | 2 +- 9 files changed, 12 insertions(+), 30 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9939f162946..00f7496edca 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1165,24 +1165,6 @@ Style/StringLiterals: Style/SymbolArray: Enabled: false -# Offense count: 15 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, AllowSafeAssignment. -# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex -Style/TernaryParentheses: - Exclude: - - 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb' - - 'lib/active_merchant/billing/gateways/blue_snap.rb' - - 'lib/active_merchant/billing/gateways/borgun.rb' - - 'lib/active_merchant/billing/gateways/braintree_blue.rb' - - 'lib/active_merchant/billing/gateways/card_stream.rb' - - 'lib/active_merchant/billing/gateways/litle.rb' - - 'lib/active_merchant/billing/gateways/moneris_us.rb' - - 'lib/active_merchant/billing/gateways/ogone.rb' - - 'lib/active_merchant/billing/gateways/orbital.rb' - - 'lib/active_merchant/billing/gateways/payeezy.rb' - - 'lib/active_merchant/billing/gateways/visanet_peru.rb' - # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline. diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index d1d7b2b75c4..0c309da8c52 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -193,11 +193,11 @@ def add_customer_ip(post, options) end def void_action(original_transaction_type) - (original_transaction_type == TRANSACTIONS[:refund]) ? :void_refund : :void_purchase + original_transaction_type == TRANSACTIONS[:refund] ? :void_refund : :void_purchase end def refund_action(type) - (type == TRANSACTIONS[:check_purchase]) ? :check_refund : :refund + type == TRANSACTIONS[:check_purchase] ? :check_refund : :refund end def secure_profile_action(type) @@ -412,7 +412,7 @@ def post(data, use_profile_api=nil) :test => test? || response[:authCode] == 'TEST', :authorization => authorization_from(response), :cvv_result => CVD_CODES[response[:cvdId]], - :avs_result => { :code => (AVS_CODES.include? response[:avsId]) ? AVS_CODES[response[:avsId]] : response[:avsId] } + :avs_result => { :code => AVS_CODES.include? response[:avsId] ? AVS_CODES[response[:avsId]] : response[:avsId] } ) end diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb index 441d0e4b763..240a90c5a49 100644 --- a/lib/active_merchant/billing/gateways/blue_snap.rb +++ b/lib/active_merchant/billing/gateways/blue_snap.rb @@ -262,7 +262,7 @@ def commit(action, verb = :post) def url(action = nil) base = test? ? test_url : live_url - resource = (action == :store) ? 'vaulted-shoppers' : 'transactions' + resource = action == :store ? 'vaulted-shoppers' : 'transactions' "#{base}/#{resource}" end @@ -288,7 +288,7 @@ def message_from(succeeded, parsed_response) end def authorization_from(action, parsed_response) - (action == :store) ? vaulted_shopper_id(parsed_response) : parsed_response['transaction-id'] + action == :store ? vaulted_shopper_id(parsed_response) : parsed_response['transaction-id'] end def vaulted_shopper_id(parsed_response) @@ -307,7 +307,7 @@ def root_attributes end def root_element(action) - (action == :store) ? 'vaulted-shopper' : 'card-transaction' + action == :store ? 'vaulted-shopper' : 'card-transaction' end def headers diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb index 966124156ce..ae144a95c59 100644 --- a/lib/active_merchant/billing/gateways/borgun.rb +++ b/lib/active_merchant/billing/gateways/borgun.rb @@ -181,7 +181,7 @@ def headers end def build_request(action, post) - mode = (action == 'void') ? 'cancel' : 'get' + mode = action == 'void' ? 'cancel' : 'get' xml = Builder::XmlMarkup.new :indent => 18 xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8') xml.tag!("#{mode}Authorization") do diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb index c049b2dff57..8fa7085e67c 100644 --- a/lib/active_merchant/billing/gateways/card_stream.rb +++ b/lib/active_merchant/billing/gateways/card_stream.rb @@ -278,7 +278,7 @@ def add_credit_card(post, credit_card) end def add_threeds_required(post, options) - add_pair(post, :threeDSRequired, (options[:threeds_required] || @threeds_required) ? 'Y' : 'N') + add_pair(post, :threeDSRequired, options[:threeds_required] || @threeds_required ? 'Y' : 'N') end def add_remote_address(post, options={}) diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index 324b976629a..2adaf564609 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -402,7 +402,7 @@ def success_from(kind, parsed) end def authorization_from(kind, parsed, money) - (kind == :registerToken) ? parsed[:litleToken] : "#{parsed[:litleTxnId]};#{kind};#{money}" + kind == :registerToken ? parsed[:litleToken] : "#{parsed[:litleTxnId]};#{kind};#{money}" end def split_authorization(authorization) diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb index 776fa67b0a4..3805eaf7df9 100644 --- a/lib/active_merchant/billing/gateways/ogone.rb +++ b/lib/active_merchant/billing/gateways/ogone.rb @@ -149,7 +149,7 @@ def initialize(options = {}) # Verify and reserve the specified amount on the account, without actually doing the transaction. def authorize(money, payment_source, options = {}) post = {} - action = (payment_source.brand == 'mastercard') ? 'PAU' : 'RES' + action = payment_source.brand == 'mastercard' ? 'PAU' : 'RES' add_invoice(post, options) add_payment_source(post, payment_source, options) add_address(post, payment_source, options) diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index fc14df47d07..6342bce30d8 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -135,7 +135,7 @@ def amount_from_authorization(authorization) def add_authorization_info(params, authorization, options = {}) transaction_id, transaction_tag, method, _ = authorization.split('|') - params[:method] = (method == 'token') ? 'credit_card' : method + params[:method] = method == 'token' ? 'credit_card' : method if options[:reversal_id] params[:reversal_id] = options[:reversal_id] diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb index c8ba88f8b16..47f0b5d99de 100644 --- a/lib/active_merchant/billing/gateways/visanet_peru.rb +++ b/lib/active_merchant/billing/gateways/visanet_peru.rb @@ -176,7 +176,7 @@ def url(action, params, options={}) end def method(action) - (%w(authorize refund).include? action) ? :post : :put + %w(authorize refund).include? action ? :post : :put end def authorization_from(params, response, options) From 13a07dc44c5a4086d759c49fd1a1108c6223b05b Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 2 Nov 2018 15:36:57 -0400 Subject: [PATCH 615/677] RuboCop: fix Style/StringLiterals This had actually already been fixed, then got re-introduced a month ago. --- .rubocop_todo.yml | 4 ---- test/unit/gateways/global_collect_test.rb | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 00f7496edca..179c4eeef19 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1154,10 +1154,6 @@ Style/SpecialGlobalVars: Style/StringLiteralsInInterpolation: Enabled: false -Style/StringLiterals: - Exclude: - - 'test/unit/gateways/global_collect_test.rb' - # Offense count: 307 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinSize. diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb index 4424d29d787..318f4ea8e38 100644 --- a/test/unit/gateways/global_collect_test.rb +++ b/test/unit/gateways/global_collect_test.rb @@ -429,6 +429,6 @@ def invalid_json_plus_card_data end def scrubbed_invalid_json_plus - "Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message. (The raw response returned by the API was \"<!DOCTYPE HTML PUBLIC \\\"-//IETF//DTD HTML 2.0//EN\\\">\\n <html><head>\\n <title>502 Proxy Error</title>\\n </head></html>\\n opening connection to api-sandbox.globalcollect.com:443...\\n opened\\n starting SSL for api-sandbox.globalcollect.com:443...\\n SSL established\\n <- \\\"POST //v1/1428/payments HTTP/1.1\\\\r\\\\nContent-Type: application/json\\\\r\\\\nAuthorization: [FILTERED]\\\\r\\\\nDate: Tue, 15 Mar 2016 14:32:13 GMT\\\\r\\\\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\\\\r\\\\nAccept: */*\\\\r\\\\nUser-Agent: Ruby\\\\r\\\\nConnection: close\\\\r\\\\nHost: api-sandbox.globalcollect.com\\\\r\\\\nContent-Length: 560\\\\r\\\\n\\\\r\\\\n\\\"\\n <- \\\"{\\\\\\\"order\\\\\\\":{\\\\\\\"amountOfMoney\\\\\\\":{\\\\\\\"amount\\\\\\\":\\\\\\\"100\\\\\\\",\\\\\\\"currencyCode\\\\\\\":\\\\\\\"USD\\\\\\\"},\\\\\\\"customer\\\\\\\":{\\\\\\\"merchantCustomerId\\\\\\\":null,\\\\\\\"personalInformation\\\\\\\":{\\\\\\\"name\\\\\\\":{\\\\\\\"firstName\\\\\\\":null,\\\\\\\"surname\\\\\\\":null}},\\\\\\\"billingAddress\\\\\\\":{\\\\\\\"street\\\\\\\":\\\\\\\"456 My Street\\\\\\\",\\\\\\\"additionalInfo\\\\\\\":\\\\\\\"Apt 1\\\\\\\",\\\\\\\"zip\\\\\\\":\\\\\\\"K1C2N6\\\\\\\",\\\\\\\"city\\\\\\\":\\\\\\\"Ottawa\\\\\\\",\\\\\\\"state\\\\\\\":\\\\\\\"ON\\\\\\\",\\\\\\\"countryCode\\\\\\\":\\\\\\\"CA\\\\\\\"}},\\\\\\\"contactDetails\\\\\\\":{\\\\\\\"emailAddress\\\\\\\":null}},\\\\\\\"cardPaymentMethodSpecificInput\\\\\\\":{\\\\\\\"paymentProductId\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"skipAuthentication\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"skipFraudService\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"card\\\\\\\":{\\\\\\\"cvv\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"cardNumber\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"expiryDate\\\\\\\":\\\\\\\"0917\\\\\\\",\\\\\\\"cardholderName\\\\\\\":\\\\\\\"Longbob Longsen\\\\\\\"}}}\\\"\\n -> \\\"HTTP/1.1 201 Created\\\\r\\\\n\\\"\\n -> \\\"Date: Tue, 15 Mar 2016 18:32:14 GMT\\\\r\\\\n\\\"\\n -> \\\"Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1p\\\\r\\\\n\\\"\\n -> \\\"Location: https://api-sandbox.globalcollect.com:443/v1/1428/payments/000000142800000000300000100001\\\\r\\\\n\\\"\\n -> \\\"X-Powered-By: Servlet/3.0 JSP/2.2\\\\r\\\\n\\\"\\n -> \\\"Connection: close\\\\r\\\\n\\\"\\n -> \\\"Transfer-Encoding: chunked\\\\r\\\\n\\\"\\n -> \\\"Content-Type: application/json\\\\r\\\\n\\\"\\n -> \\\"\\\\r\\\\n\\\"\\n -> \\\"457\\\\r\\\\n\\\"\")" + 'Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message. (The raw response returned by the API was "<!DOCTYPE HTML PUBLIC \\"-//IETF//DTD HTML 2.0//EN\\">\\n <html><head>\\n <title>502 Proxy Error</title>\\n </head></html>\\n opening connection to api-sandbox.globalcollect.com:443...\\n opened\\n starting SSL for api-sandbox.globalcollect.com:443...\\n SSL established\\n <- \\"POST //v1/1428/payments HTTP/1.1\\\\r\\\\nContent-Type: application/json\\\\r\\\\nAuthorization: [FILTERED]\\\\r\\\\nDate: Tue, 15 Mar 2016 14:32:13 GMT\\\\r\\\\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\\\\r\\\\nAccept: */*\\\\r\\\\nUser-Agent: Ruby\\\\r\\\\nConnection: close\\\\r\\\\nHost: api-sandbox.globalcollect.com\\\\r\\\\nContent-Length: 560\\\\r\\\\n\\\\r\\\\n\\"\\n <- \\"{\\\\\\"order\\\\\\":{\\\\\\"amountOfMoney\\\\\\":{\\\\\\"amount\\\\\\":\\\\\\"100\\\\\\",\\\\\\"currencyCode\\\\\\":\\\\\\"USD\\\\\\"},\\\\\\"customer\\\\\\":{\\\\\\"merchantCustomerId\\\\\\":null,\\\\\\"personalInformation\\\\\\":{\\\\\\"name\\\\\\":{\\\\\\"firstName\\\\\\":null,\\\\\\"surname\\\\\\":null}},\\\\\\"billingAddress\\\\\\":{\\\\\\"street\\\\\\":\\\\\\"456 My Street\\\\\\",\\\\\\"additionalInfo\\\\\\":\\\\\\"Apt 1\\\\\\",\\\\\\"zip\\\\\\":\\\\\\"K1C2N6\\\\\\",\\\\\\"city\\\\\\":\\\\\\"Ottawa\\\\\\",\\\\\\"state\\\\\\":\\\\\\"ON\\\\\\",\\\\\\"countryCode\\\\\\":\\\\\\"CA\\\\\\"}},\\\\\\"contactDetails\\\\\\":{\\\\\\"emailAddress\\\\\\":null}},\\\\\\"cardPaymentMethodSpecificInput\\\\\\":{\\\\\\"paymentProductId\\\\\\":\\\\\\"1\\\\\\",\\\\\\"skipAuthentication\\\\\\":\\\\\\"true\\\\\\",\\\\\\"skipFraudService\\\\\\":\\\\\\"true\\\\\\",\\\\\\"card\\\\\\":{\\\\\\"cvv\\\\\\":\\\\\\"[FILTERED]\\\\\\",\\\\\\"cardNumber\\\\\\":\\\\\\"[FILTERED]\\\\\\",\\\\\\"expiryDate\\\\\\":\\\\\\"0917\\\\\\",\\\\\\"cardholderName\\\\\\":\\\\\\"Longbob Longsen\\\\\\"}}}\\"\\n -> \\"HTTP/1.1 201 Created\\\\r\\\\n\\"\\n -> \\"Date: Tue, 15 Mar 2016 18:32:14 GMT\\\\r\\\\n\\"\\n -> \\"Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1p\\\\r\\\\n\\"\\n -> \\"Location: https://api-sandbox.globalcollect.com:443/v1/1428/payments/000000142800000000300000100001\\\\r\\\\n\\"\\n -> \\"X-Powered-By: Servlet/3.0 JSP/2.2\\\\r\\\\n\\"\\n -> \\"Connection: close\\\\r\\\\n\\"\\n -> \\"Transfer-Encoding: chunked\\\\r\\\\n\\"\\n -> \\"Content-Type: application/json\\\\r\\\\n\\"\\n -> \\"\\\\r\\\\n\\"\\n -> \\"457\\\\r\\\\n\\"")' end end From e382e5738972b8cb6d771f8b6879d44987b7b02b Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 2 Nov 2018 15:41:01 -0400 Subject: [PATCH 616/677] RuboCop: fix Layout/SpaceInsideReferenceBrackets --- .rubocop_todo.yml | 17 ---------------- .../gateways/beanstream/beanstream_core.rb | 2 +- .../billing/gateways/blue_pay.rb | 2 +- .../billing/gateways/braintree_blue.rb | 2 +- lib/active_merchant/billing/gateways/cams.rb | 20 +++++++++---------- .../billing/gateways/metrics_global.rb | 4 ++-- .../billing/gateways/sage_pay.rb | 6 +++--- .../billing/gateways/secure_pay.rb | 4 ++-- .../billing/gateways/transact_pro.rb | 2 +- test/remote/gateways/remote_wirecard_test.rb | 4 ++-- 10 files changed, 23 insertions(+), 40 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 179c4eeef19..b13c458f006 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -214,23 +214,6 @@ Layout/SpaceInsideParens: Layout/SpaceInsidePercentLiteralDelimiters: Enabled: false -# Offense count: 35 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBrackets: space, no_space -Layout/SpaceInsideReferenceBrackets: - Exclude: - - 'lib/active_merchant/billing/gateways/blue_pay.rb' - - 'lib/active_merchant/billing/gateways/cams.rb' - - 'lib/active_merchant/billing/gateways/ideal/ideal_base.rb' - - 'lib/active_merchant/billing/gateways/metrics_global.rb' - - 'lib/active_merchant/billing/gateways/sage_pay.rb' - - 'lib/active_merchant/billing/gateways/secure_pay.rb' - - 'lib/active_merchant/billing/gateways/transact_pro.rb' - - 'test/remote/gateways/remote_ideal_rabobank_test.rb' - - 'test/remote/gateways/remote_wirecard_test.rb' - # Offense count: 148 # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index 0c309da8c52..3b6c9d2cfc4 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -412,7 +412,7 @@ def post(data, use_profile_api=nil) :test => test? || response[:authCode] == 'TEST', :authorization => authorization_from(response), :cvv_result => CVD_CODES[response[:cvdId]], - :avs_result => { :code => AVS_CODES.include? response[:avsId] ? AVS_CODES[response[:avsId]] : response[:avsId] } + :avs_result => { :code => AVS_CODES.include?(response[:avsId]) ? AVS_CODES[response[:avsId]] : response[:avsId] } ) end diff --git a/lib/active_merchant/billing/gateways/blue_pay.rb b/lib/active_merchant/billing/gateways/blue_pay.rb index 063434a150f..c9cf54e23ff 100644 --- a/lib/active_merchant/billing/gateways/blue_pay.rb +++ b/lib/active_merchant/billing/gateways/blue_pay.rb @@ -374,7 +374,7 @@ def message_from(parsed) if CARD_CODE_ERRORS.include?(parsed[:card_code]) message = CVVResult.messages[parsed[:card_code]] elsif AVS_ERRORS.include?(parsed[:avs_result_code]) - message = AVSResult.messages[ parsed[:avs_result_code] ] + message = AVSResult.messages[parsed[:avs_result_code]] else message = message.chomp('.') end diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 067fadc5299..5f0c0f30542 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -53,7 +53,7 @@ def initialize(options = {}) super if wiredump_device.present? - logger = ((Logger === wiredump_device) ? wiredump_device : Logger.new(wiredump_device)) + logger = (Logger === wiredump_device ? wiredump_device : Logger.new(wiredump_device)) logger.level = Logger::DEBUG else logger = Braintree::Configuration.logger.clone diff --git a/lib/active_merchant/billing/gateways/cams.rb b/lib/active_merchant/billing/gateways/cams.rb index c053f77ecbc..fdb310358c6 100644 --- a/lib/active_merchant/billing/gateways/cams.rb +++ b/lib/active_merchant/billing/gateways/cams.rb @@ -140,18 +140,18 @@ def scrub(transcript) def add_address(post, creditcard, options={}) post[:firstname] = creditcard.first_name - post[:lastname ] = creditcard.last_name + post[:lastname] = creditcard.last_name return unless options[:billing_address] address = options[:billing_address] - post[:address1 ] = address[:address1] - post[:address2 ] = address[:address2] - post[:city ] = address[:city] - post[:state ] = address[:state] - post[:zip ] = address[:zip] - post[:country ] = address[:country] - post[:phone ] = address[:phone] + post[:address1] = address[:address1] + post[:address2] = address[:address2] + post[:city] = address[:city] + post[:state] = address[:state] + post[:zip] = address[:zip] + post[:country] = address[:country] + post[:phone] = address[:phone] end def add_reference(post, authorization) @@ -167,8 +167,8 @@ def add_invoice(post, money, options) def add_payment(post, payment) post[:ccnumber] = payment.number - post[:ccexp ] = "#{payment.month.to_s.rjust(2,"0")}#{payment.year.to_s[-2..-1]}" - post[:cvv ] = payment.verification_value + post[:ccexp] = "#{payment.month.to_s.rjust(2,"0")}#{payment.year.to_s[-2..-1]}" + post[:cvv] = payment.verification_value end def parse(body) diff --git a/lib/active_merchant/billing/gateways/metrics_global.rb b/lib/active_merchant/billing/gateways/metrics_global.rb index de046d9932b..314f403c83c 100644 --- a/lib/active_merchant/billing/gateways/metrics_global.rb +++ b/lib/active_merchant/billing/gateways/metrics_global.rb @@ -286,9 +286,9 @@ def add_address(post, options) def message_from(results) if results[:response_code] == DECLINED - return CVVResult.messages[ results[:card_code] ] if CARD_CODE_ERRORS.include?(results[:card_code]) + return CVVResult.messages[results[:card_code]] if CARD_CODE_ERRORS.include?(results[:card_code]) if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code]) - return AVSResult.messages[ results[:avs_result_code] ] + return AVSResult.messages[results[:avs_result_code]] end end diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index 81506b77007..591b3c6a43d 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -349,10 +349,10 @@ def commit(action, parameters) :test => test?, :authorization => authorization_from(response, parameters, action), :avs_result => { - :street_match => AVS_CODE[ response['AddressResult'] ], - :postal_match => AVS_CODE[ response['PostCodeResult'] ], + :street_match => AVS_CODE[response['AddressResult']], + :postal_match => AVS_CODE[response['PostCodeResult']], }, - :cvv_result => CVV_CODE[ response['CV2Result'] ] + :cvv_result => CVV_CODE[response['CV2Result']] ) end diff --git a/lib/active_merchant/billing/gateways/secure_pay.rb b/lib/active_merchant/billing/gateways/secure_pay.rb index 656e360940c..4cd0c8a63d3 100644 --- a/lib/active_merchant/billing/gateways/secure_pay.rb +++ b/lib/active_merchant/billing/gateways/secure_pay.rb @@ -183,9 +183,9 @@ def add_address(post, options) def message_from(results) if results[:response_code] == DECLINED - return CVVResult.messages[ results[:card_code] ] if CARD_CODE_ERRORS.include?(results[:card_code]) + return CVVResult.messages[results[:card_code]] if CARD_CODE_ERRORS.include?(results[:card_code]) if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code]) - return AVSResult.messages[ results[:avs_result_code] ] + return AVSResult.messages[results[:avs_result_code]] end end diff --git a/lib/active_merchant/billing/gateways/transact_pro.rb b/lib/active_merchant/billing/gateways/transact_pro.rb index 5855527bfc0..6029f837afb 100644 --- a/lib/active_merchant/billing/gateways/transact_pro.rb +++ b/lib/active_merchant/billing/gateways/transact_pro.rb @@ -174,7 +174,7 @@ def parse(body) { status: 'success', id: m[2] } : { status: 'failure', message: m[2] } else - Hash[ status: body ] + Hash[status: body] end end diff --git a/test/remote/gateways/remote_wirecard_test.rb b/test/remote/gateways/remote_wirecard_test.rb index b58b05ee05b..586e1567351 100644 --- a/test/remote/gateways/remote_wirecard_test.rb +++ b/test/remote/gateways/remote_wirecard_test.rb @@ -214,7 +214,7 @@ def test_wrong_creditcard_purchase assert response = @gateway.purchase(@amount, @declined_card, @options) assert response.test? assert_failure response - assert response.message[ /Credit card number not allowed in demo mode/ ], 'Got wrong response message' + assert response.message[/Credit card number not allowed in demo mode/], 'Got wrong response message' assert_equal '24997', response.params['ErrorCode'] end @@ -222,7 +222,7 @@ def test_wrong_creditcard_store assert response = @gateway.store(@declined_card, @options) assert response.test? assert_failure response - assert response.message[ /Credit card number not allowed in demo mode/ ], 'Got wrong response message' + assert response.message[/Credit card number not allowed in demo mode/], 'Got wrong response message' end def test_unauthorized_capture From 4a7f7ddaa0751e1dfec8822c2bbbcad990630fb7 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 2 Nov 2018 15:45:00 -0400 Subject: [PATCH 617/677] RuboCop: fix Performance/InefficientHashSearch --- .rubocop_todo.yml | 10 ---------- .../billing/gateways/usa_epay_advanced.rb | 2 +- test/unit/gateways/payscout_test.rb | 18 +++++++++--------- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b13c458f006..5d019a72cf0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -414,16 +414,6 @@ Performance/CompareWithBlock: Exclude: - 'lib/active_merchant/billing/gateways/skip_jack.rb' -# Offense count: 13 -# Cop supports --auto-correct. -Performance/InefficientHashSearch: - Exclude: - - 'lib/active_merchant/billing/credit_card.rb' - - 'lib/active_merchant/billing/gateways/inspire.rb' - - 'lib/active_merchant/billing/gateways/smart_ps.rb' - - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' - - 'test/unit/gateways/payscout_test.rb' - # Offense count: 8 # Cop supports --auto-correct. Performance/RangeInclude: diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb index a34d269abb6..803fce7532e 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb @@ -1503,7 +1503,7 @@ def build_shipping_address(soap, options) def build_field_value_array(soap, tag_name, type, custom_data, fields) soap.tag! tag_name, 'SOAP-ENC:arryType' => "xsd:#{type}[#{options.length}]", 'xsi:type' => "ns1:#{type}Array" do custom_data.each do |k, v| - build_field_value soap, fields[k][1], v, fields[k][0] if fields.keys.include? k + build_field_value soap, fields[k][1], v, fields[k][0] if fields.key?(k) end end end diff --git a/test/unit/gateways/payscout_test.rb b/test/unit/gateways/payscout_test.rb index fcf69767329..f5cb64b3a3f 100644 --- a/test/unit/gateways/payscout_test.rb +++ b/test/unit/gateways/payscout_test.rb @@ -259,15 +259,15 @@ def test_add_creditcard def test_parse data = @gateway.send(:parse, approved_authorization_response) - assert data.keys.include?('response') - assert data.keys.include?('responsetext') - assert data.keys.include?('authcode') - assert data.keys.include?('transactionid') - assert data.keys.include?('avsresponse') - assert data.keys.include?('cvvresponse') - assert data.keys.include?('orderid') - assert data.keys.include?('type') - assert data.keys.include?('response_code') + assert data.key?('response') + assert data.key?('responsetext') + assert data.key?('authcode') + assert data.key?('transactionid') + assert data.key?('avsresponse') + assert data.key?('cvvresponse') + assert data.key?('orderid') + assert data.key?('type') + assert data.key?('response_code') assert_equal '1', data['response'] assert_equal 'SUCCESS', data['responsetext'] From affa88530639dfe3d2e81bdfa1f2084671d6c679 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 2 Nov 2018 15:46:54 -0400 Subject: [PATCH 618/677] RuboCop: fix Performance/ReverseEach --- .rubocop_todo.yml | 6 ------ lib/active_merchant/billing/gateways/trust_commerce.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5d019a72cf0..436868e009a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -445,12 +445,6 @@ Performance/RedundantMatch: Performance/RedundantMerge: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -Performance/ReverseEach: - Exclude: - - 'lib/active_merchant/billing/gateways/trust_commerce.rb' - # Offense count: 12 # Cop supports --auto-correct. Performance/StringReplacement: diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb index 7fab693c69e..19bf5d122ad 100644 --- a/lib/active_merchant/billing/gateways/trust_commerce.rb +++ b/lib/active_merchant/billing/gateways/trust_commerce.rb @@ -362,7 +362,7 @@ def clean_and_stringify_params(parameters) # TCLink wants us to send a hash with string keys, and activemerchant pushes everything around with # symbol keys. Before sending our input to TCLink, we convert all our keys to strings and dump the symbol keys. # We also remove any pairs with nil values, as these confuse TCLink. - parameters.keys.reverse.each do |key| + parameters.keys.reverse_each do |key| if parameters[key] parameters[key.to_s] = parameters[key] end From 2960fcf47668012af8c200f7b3b09dd57b4bab13 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 2 Nov 2018 15:48:05 -0400 Subject: [PATCH 619/677] RuboCop: fix Performance/CompareWithBlock --- .rubocop_todo.yml | 6 ------ lib/active_merchant/billing/gateways/skip_jack.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 436868e009a..0fd6882efd2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -408,12 +408,6 @@ Performance/Casecmp: - 'lib/active_merchant/billing/gateways/redsys.rb' - 'lib/active_merchant/country.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Performance/CompareWithBlock: - Exclude: - - 'lib/active_merchant/billing/gateways/skip_jack.rb' - # Offense count: 8 # Cop supports --auto-correct. Performance/RangeInclude: diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb index 5e5b8a91534..adbbd32f0dc 100644 --- a/lib/active_merchant/billing/gateways/skip_jack.rb +++ b/lib/active_merchant/billing/gateways/skip_jack.rb @@ -353,7 +353,7 @@ def parse_status_response(body, response_keys) def post_data(action, money, params = {}) add_credentials(params, action) add_amount(params, action, money) - sorted_params = params.to_a.sort{|a,b| a.to_s <=> b.to_s}.reverse + sorted_params = params.to_a.sort_by(&:to_s).reverse sorted_params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end From e58d67036447ca5dc8ae5f2e3767fd929e06580a Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 2 Nov 2018 15:50:37 -0400 Subject: [PATCH 620/677] RuboCop: fix Performance/RedundantBlockCall --- .rubocop_todo.yml | 6 ------ test/unit/gateways/nab_transact_test.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0fd6882efd2..07c068687e3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -420,12 +420,6 @@ Performance/RangeInclude: - 'lib/active_merchant/billing/gateways/moneris.rb' - 'lib/active_merchant/billing/gateways/moneris_us.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Performance/RedundantBlockCall: - Exclude: - - 'test/unit/gateways/nab_transact_test.rb' - # Offense count: 4 # Cop supports --auto-correct. Performance/RedundantMatch: diff --git a/test/unit/gateways/nab_transact_test.rb b/test/unit/gateways/nab_transact_test.rb index 3e7dca2eedb..d6a0af00347 100644 --- a/test/unit/gateways/nab_transact_test.rb +++ b/test/unit/gateways/nab_transact_test.rb @@ -229,7 +229,7 @@ def valid_metadata(name, location) def assert_metadata(name, location, &block) stub_comms(@gateway, :ssl_request) do - block.call + yield end.check_request do |method, endpoint, data, headers| metadata_matcher = Regexp.escape(valid_metadata(name, location)) assert_match %r{#{metadata_matcher}}, data From 7cf9934d925eaa23dafbbcd3cd6fbaff012f578e Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 2 Nov 2018 15:52:27 -0400 Subject: [PATCH 621/677] RuboCop: fix Performance/RangeInclude --- .rubocop_todo.yml | 12 ------------ lib/active_merchant/billing/check.rb | 2 +- lib/active_merchant/billing/credit_card_methods.rb | 4 ++-- lib/active_merchant/billing/gateways/blue_pay.rb | 2 +- lib/active_merchant/billing/gateways/blue_snap.rb | 2 +- lib/active_merchant/billing/gateways/cashnet.rb | 2 +- lib/active_merchant/billing/gateways/moneris.rb | 2 +- lib/active_merchant/billing/gateways/moneris_us.rb | 2 +- 8 files changed, 8 insertions(+), 20 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 07c068687e3..f6413bda303 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -408,18 +408,6 @@ Performance/Casecmp: - 'lib/active_merchant/billing/gateways/redsys.rb' - 'lib/active_merchant/country.rb' -# Offense count: 8 -# Cop supports --auto-correct. -Performance/RangeInclude: - Exclude: - - 'lib/active_merchant/billing/check.rb' - - 'lib/active_merchant/billing/credit_card_methods.rb' - - 'lib/active_merchant/billing/gateways/blue_pay.rb' - - 'lib/active_merchant/billing/gateways/blue_snap.rb' - - 'lib/active_merchant/billing/gateways/cashnet.rb' - - 'lib/active_merchant/billing/gateways/moneris.rb' - - 'lib/active_merchant/billing/gateways/moneris_us.rb' - # Offense count: 4 # Cop supports --auto-correct. Performance/RedundantMatch: diff --git a/lib/active_merchant/billing/check.rb b/lib/active_merchant/billing/check.rb index 9d73819560a..0653848f3f5 100644 --- a/lib/active_merchant/billing/check.rb +++ b/lib/active_merchant/billing/check.rb @@ -59,7 +59,7 @@ def credit_card? # (3(d1 + d4 + d7) + 7(d2 + d5 + d8) + 1(d3 + d6 + d9))mod 10 = 0 # See http://en.wikipedia.org/wiki/Routing_transit_number#Internal_checksums def valid_routing_number? - digits = routing_number.to_s.split('').map(&:to_i).select{|d| (0..9).include?(d)} + digits = routing_number.to_s.split('').map(&:to_i).select{|d| (0..9).cover?(d)} case digits.size when 9 checksum = ((3 * (digits[0] + digits[3] + digits[6])) + diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb index 1d79d9a2e1c..67c80f5e5b1 100644 --- a/lib/active_merchant/billing/credit_card_methods.rb +++ b/lib/active_merchant/billing/credit_card_methods.rb @@ -10,7 +10,7 @@ module CreditCardMethods 'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ }, 'jcb' => ->(num) { num =~ /^35(28|29|[3-8]\d)\d{12}$/ }, 'dankort' => ->(num) { num =~ /^5019\d{12}$/ }, - 'maestro' => ->(num) { (12..19).include?(num&.size) && in_bin_range?(num.slice(0, 6), MAESTRO_RANGES) }, + 'maestro' => ->(num) { (12..19).cover?(num&.size) && in_bin_range?(num.slice(0, 6), MAESTRO_RANGES) }, 'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ }, 'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ }, 'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ }, @@ -86,7 +86,7 @@ def credit_card? end def valid_expiry_year?(year) - (Time.now.year..Time.now.year + 20).include?(year.to_i) + (Time.now.year..Time.now.year + 20).cover?(year.to_i) end def valid_start_year?(year) diff --git a/lib/active_merchant/billing/gateways/blue_pay.rb b/lib/active_merchant/billing/gateways/blue_pay.rb index c9cf54e23ff..988c2f1e946 100644 --- a/lib/active_merchant/billing/gateways/blue_pay.rb +++ b/lib/active_merchant/billing/gateways/blue_pay.rb @@ -510,7 +510,7 @@ def calc_rebill_tps(post) end def handle_response(response) - if ignore_http_status || (200...300).include?(response.code.to_i) + if ignore_http_status || (200...300).cover?(response.code.to_i) return response.body end raise ResponseError.new(response) diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb index 240a90c5a49..aaeaee85478 100644 --- a/lib/active_merchant/billing/gateways/blue_snap.rb +++ b/lib/active_merchant/billing/gateways/blue_snap.rb @@ -279,7 +279,7 @@ def avs_lookup_key(p) end def success_from(action, response) - (200...300).include?(response.code.to_i) + (200...300).cover?(response.code.to_i) end def message_from(succeeded, parsed_response) diff --git a/lib/active_merchant/billing/gateways/cashnet.rb b/lib/active_merchant/billing/gateways/cashnet.rb index 9632d273383..db28d9de497 100644 --- a/lib/active_merchant/billing/gateways/cashnet.rb +++ b/lib/active_merchant/billing/gateways/cashnet.rb @@ -140,7 +140,7 @@ def parse(body) end def handle_response(response) - if (200...300).include?(response.code.to_i) + if (200...300).cover?(response.code.to_i) return response.body elsif response.code.to_i == 302 return ssl_get(URI.parse(response['location'])) diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb index 2a632811ed5..bf8533c78fc 100644 --- a/lib/active_merchant/billing/gateways/moneris.rb +++ b/lib/active_merchant/billing/gateways/moneris.rb @@ -244,7 +244,7 @@ def authorization_from(response = {}) def successful?(response) response[:response_code] && response[:complete] && - (0..49).include?(response[:response_code].to_i) + (0..49).cover?(response[:response_code].to_i) end def parse(xml) diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb index dd625fe0a96..9fc3f5b55c4 100644 --- a/lib/active_merchant/billing/gateways/moneris_us.rb +++ b/lib/active_merchant/billing/gateways/moneris_us.rb @@ -239,7 +239,7 @@ def authorization_from(response = {}) def successful?(response) response[:response_code] && response[:complete] && - (0..49).include?(response[:response_code].to_i) + (0..49).cover?(response[:response_code].to_i) end def parse(xml) From 969a232142cdee58554db7805bd3b7f4a20cab88 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 2 Nov 2018 15:54:42 -0400 Subject: [PATCH 622/677] RuboCop: fix Performance/Casecmp --- .rubocop_todo.yml | 11 ----------- lib/active_merchant/billing/gateways/ebanx.rb | 2 +- lib/active_merchant/billing/gateways/eway_managed.rb | 2 +- lib/active_merchant/billing/gateways/itransact.rb | 2 +- lib/active_merchant/billing/gateways/paystation.rb | 2 +- lib/active_merchant/billing/gateways/redsys.rb | 2 +- lib/active_merchant/country.rb | 2 +- 7 files changed, 6 insertions(+), 17 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f6413bda303..94529205619 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -397,17 +397,6 @@ Naming/VariableNumber: - 'test/unit/gateways/orbital_test.rb' - 'test/unit/gateways/paypal/paypal_common_api_test.rb' -# Offense count: 6 -# Cop supports --auto-correct. -Performance/Casecmp: - Exclude: - - 'lib/active_merchant/billing/gateways/ebanx.rb' - - 'lib/active_merchant/billing/gateways/eway_managed.rb' - - 'lib/active_merchant/billing/gateways/itransact.rb' - - 'lib/active_merchant/billing/gateways/paystation.rb' - - 'lib/active_merchant/billing/gateways/redsys.rb' - - 'lib/active_merchant/country.rb' - # Offense count: 4 # Cop supports --auto-correct. Performance/RedundantMatch: diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb index d22affa971f..b7d1dc15171 100644 --- a/lib/active_merchant/billing/gateways/ebanx.rb +++ b/lib/active_merchant/billing/gateways/ebanx.rb @@ -147,7 +147,7 @@ def add_customer_data(post, payment, options) def add_customer_responsible_person(post, payment, options) post[:payment][:person_type] = options[:person_type] if options[:person_type] - if options[:person_type] && options[:person_type].downcase == 'business' + if options[:person_type]&.casecmp('business')&.zero? post[:payment][:responsible] = {} post[:payment][:responsible][:name] = options[:responsible_name] if options[:responsible_name] post[:payment][:responsible][:document] = options[:responsible_document] if options[:responsible_document] diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb index 85616ed0b74..780f5c55481 100644 --- a/lib/active_merchant/billing/gateways/eway_managed.rb +++ b/lib/active_merchant/billing/gateways/eway_managed.rb @@ -165,7 +165,7 @@ def parse(body) reply[:success]=true else if root = REXML::XPath.first(xml, '//UpdateCustomerResult') then - if root.text.downcase == 'true' then + if root.text.casecmp('true').zero? then reply[:message]='OK' reply[:success]=true else diff --git a/lib/active_merchant/billing/gateways/itransact.rb b/lib/active_merchant/billing/gateways/itransact.rb index b0329417f44..e76919e4b8f 100644 --- a/lib/active_merchant/billing/gateways/itransact.rb +++ b/lib/active_merchant/billing/gateways/itransact.rb @@ -424,7 +424,7 @@ def parse(raw_xml) def successful?(response) # Turns out the PaymentClearing gateway is not consistent... - response[:status].downcase =='ok' + response[:status].casecmp('ok').zero? end def test_mode?(response) diff --git a/lib/active_merchant/billing/gateways/paystation.rb b/lib/active_merchant/billing/gateways/paystation.rb index 44d64dce8ae..69a6f8c8b95 100644 --- a/lib/active_merchant/billing/gateways/paystation.rb +++ b/lib/active_merchant/billing/gateways/paystation.rb @@ -179,7 +179,7 @@ def commit(post) message = message_from(response) PaystationResponse.new(success?(response), message, response, - :test => (response[:tm] && response[:tm].downcase == 't'), + :test => (response[:tm]&.casecmp('t')&.zero?), :authorization => response[:paystation_transaction_id] ) end diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb index 237ce51b2ce..792b935d557 100644 --- a/lib/active_merchant/billing/gateways/redsys.rb +++ b/lib/active_merchant/billing/gateways/redsys.rb @@ -432,7 +432,7 @@ def parse(data) def validate_signature(data) if sha256_authentication? sig = Base64.strict_encode64(mac256(get_key(data[:ds_order].to_s), xml_signed_fields(data))) - sig.upcase == data[:ds_signature].to_s.upcase + sig.casecmp(data[:ds_signature].to_s).zero? else str = data[:ds_amount] + data[:ds_order].to_s + diff --git a/lib/active_merchant/country.rb b/lib/active_merchant/country.rb index 82c333fef74..996647a975a 100644 --- a/lib/active_merchant/country.rb +++ b/lib/active_merchant/country.rb @@ -326,7 +326,7 @@ def self.find(name) country_code = CountryCode.new(name) country = COUNTRIES.detect{|c| c[country_code.format] == upcase_name } else - country = COUNTRIES.detect{|c| c[:name].upcase == name.upcase } + country = COUNTRIES.detect{|c| c[:name].casecmp(name).zero? } end raise InvalidCountryCodeError, "No country could be found for the country #{name}" if country.nil? Country.new(country.dup) From 20ddb42be9c0cfc79cc6e08abd5f2084184390ca Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Fri, 2 Nov 2018 15:57:09 -0400 Subject: [PATCH 623/677] RuboCop: fix Performance/Casecmp --- .rubocop_todo.yml | 6 ------ .../billing/gateways/authorize_net_cim.rb | 2 +- lib/active_merchant/billing/gateways/beanstream.rb | 3 ++- .../billing/gateways/braintree_blue.rb | 6 +++--- lib/active_merchant/billing/gateways/digitzs.rb | 6 +++--- lib/active_merchant/billing/gateways/element.rb | 4 ++-- .../billing/gateways/global_collect.rb | 2 +- lib/active_merchant/billing/gateways/iridium.rb | 4 ++-- .../billing/gateways/mercado_pago.rb | 10 +++++----- .../billing/gateways/merchant_one.rb | 4 ++-- .../billing/gateways/merchant_warrior.rb | 2 +- lib/active_merchant/billing/gateways/migs.rb | 6 ++---- lib/active_merchant/billing/gateways/netbanx.rb | 2 +- lib/active_merchant/billing/gateways/ogone.rb | 2 +- lib/active_merchant/billing/gateways/orbital.rb | 10 ++++++---- .../billing/gateways/pay_gate_xml.rb | 9 ++++++--- .../billing/gateways/payflow/payflow_common_api.rb | 2 +- lib/active_merchant/billing/gateways/payway.rb | 2 +- lib/active_merchant/billing/gateways/stripe.rb | 8 ++++---- .../billing/gateways/usa_epay_advanced.rb | 4 ++-- lib/active_merchant/billing/gateways/worldpay.rb | 4 ++-- test/remote/gateways/remote_card_save_test.rb | 2 +- test/remote/gateways/remote_eway_rapid_test.rb | 2 +- test/remote/gateways/remote_linkpoint_test.rb | 11 +++++------ .../remote/gateways/remote_optimal_payment_test.rb | 2 +- test/remote/gateways/remote_orbital_test.rb | 4 ++-- test/remote/gateways/remote_pro_pay_test.rb | 2 +- .../gateways/remote_usa_epay_advanced_test.rb | 2 +- test/remote/gateways/remote_worldpay_test.rb | 4 ++-- test/unit/gateways/credorax_test.rb | 2 +- test/unit/gateways/mundipagg_test.rb | 2 +- test/unit/gateways/stripe_test.rb | 14 +++++++------- test/unit/gateways/usa_epay_advanced_test.rb | 2 +- 33 files changed, 72 insertions(+), 75 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 94529205619..689e4e01296 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -404,12 +404,6 @@ Performance/RedundantMatch: - 'lib/active_merchant/billing/gateways/opp.rb' - 'test/unit/gateways/payu_latam_test.rb' -# Offense count: 59 -# Cop supports --auto-correct. -# Configuration parameters: MaxKeyValuePairs. -Performance/RedundantMerge: - Enabled: false - # Offense count: 12 # Cop supports --auto-correct. Performance/StringReplacement: diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb index af7c4a769b1..f57e1397af3 100644 --- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb +++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb @@ -614,7 +614,7 @@ def build_update_customer_shipping_address_request(xml, options) def build_create_customer_profile_transaction_request(xml, options) options[:extra_options] ||= {} - options[:extra_options].merge!('x_delim_char' => @options[:delimiter]) if @options[:delimiter] + options[:extra_options]['x_delim_char'] = @options[:delimiter] if @options[:delimiter] add_transaction(xml, options[:transaction]) xml.tag!('extraOptions') do diff --git a/lib/active_merchant/billing/gateways/beanstream.rb b/lib/active_merchant/billing/gateways/beanstream.rb index 0c1b42ed7b4..6947992934d 100644 --- a/lib/active_merchant/billing/gateways/beanstream.rb +++ b/lib/active_merchant/billing/gateways/beanstream.rb @@ -186,7 +186,8 @@ def update(vault_id, payment_method, options = {}) else post[:singleUseToken] = payment_method end - options.merge!({:vault_id => vault_id, :operation => secure_profile_action(:modify)}) + options[:vault_id] = vault_id + options[:operation] = secure_profile_action(:modify) add_secure_profile_variables(post,options) commit(post, true) end diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 5f0c0f30542..fdd5111fa8a 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -143,7 +143,7 @@ def update(vault_id, creditcard, options = {}) braintree_credit_card = @braintree_gateway.customer.find(vault_id).credit_cards.detect(&:default?) return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil? - options.merge!(:update_existing_token => braintree_credit_card.token) + options[:update_existing_token] = braintree_credit_card.token credit_card_params = merge_credit_card_options({ :credit_card => { :cardholder_name => creditcard.name, @@ -303,7 +303,7 @@ def merge_credit_card_options(parameters, options) end parameters[:credit_card] ||= {} - parameters[:credit_card].merge!(:options => valid_options) + parameters[:credit_card][:options] = valid_options address = options[:billing_address]&.except(:phone) return parameters if address.nil? || address.values.compact.empty? parameters[:credit_card][:billing_address] = map_address(address) @@ -569,7 +569,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options) } if options[:skip_advanced_fraud_checking] - parameters[:options].merge!({ :skip_advanced_fraud_checking => options[:skip_advanced_fraud_checking] }) + parameters[:options][:skip_advanced_fraud_checking] = options[:skip_advanced_fraud_checking] end parameters[:custom_fields] = options[:custom_fields] diff --git a/lib/active_merchant/billing/gateways/digitzs.rb b/lib/active_merchant/billing/gateways/digitzs.rb index b8b7d96fcb5..1dff6179965 100644 --- a/lib/active_merchant/billing/gateways/digitzs.rb +++ b/lib/active_merchant/billing/gateways/digitzs.rb @@ -36,7 +36,7 @@ def refund(money, authorization, options={}) def store(payment, options = {}) MultiResponse.run do |r| r.process { commit('auth/token', app_token_request(options)) } - options.merge!({ app_token: app_token_from(r) }) + options[:app_token] = app_token_from(r) if options[:customer_id].present? customer_id = check_customer_exists(options) @@ -197,7 +197,7 @@ def add_credit_card_to_customer(payment, options = {}) def add_customer_with_credit_card(payment, options = {}) customer_response = commit('customers', create_customer_request(payment, options), options) - options.merge!({customer_id: customer_response.authorization}) + options[:customer_id] = customer_response.authorization commit('tokens', create_token_request(payment, options), options) end @@ -257,7 +257,7 @@ def headers(options) 'x-api-key' => @options[:api_key] } - headers.merge!({'Authorization' => "Bearer #{options[:app_token]}"}) if options[:app_token] + headers['Authorization'] = "Bearer #{options[:app_token]}" if options[:app_token] headers end diff --git a/lib/active_merchant/billing/gateways/element.rb b/lib/active_merchant/billing/gateways/element.rb index 419fdd6e843..a82803884ba 100644 --- a/lib/active_merchant/billing/gateways/element.rb +++ b/lib/active_merchant/billing/gateways/element.rb @@ -54,7 +54,7 @@ def authorize(money, payment, options={}) def capture(money, authorization, options={}) trans_id, _ = split_authorization(authorization) - options.merge!({trans_id: trans_id}) + options[:trans_id] = trans_id request = build_soap_request do |xml| xml.CreditCardAuthorizationCompletion(xmlns: 'https://transaction.elementexpress.com') do @@ -69,7 +69,7 @@ def capture(money, authorization, options={}) def refund(money, authorization, options={}) trans_id, _ = split_authorization(authorization) - options.merge!({trans_id: trans_id}) + options[:trans_id] = trans_id request = build_soap_request do |xml| xml.CreditCardReturn(xmlns: 'https://transaction.elementexpress.com') do diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index 659804cd3fd..a96cbb12d42 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -200,7 +200,7 @@ def add_address(post, creditcard, options) def add_fraud_fields(post, options) fraud_fields = {} fraud_fields.merge!(options[:fraud_fields]) if options[:fraud_fields] - fraud_fields.merge!({customerIpAddress: options[:ip]}) if options[:ip] + fraud_fields[:customerIpAddress] = options[:ip] if options[:ip] post['fraudFields'] = fraud_fields unless fraud_fields.empty? end diff --git a/lib/active_merchant/billing/gateways/iridium.rb b/lib/active_merchant/billing/gateways/iridium.rb index 3723f287e43..65024f293aa 100644 --- a/lib/active_merchant/billing/gateways/iridium.rb +++ b/lib/active_merchant/billing/gateways/iridium.rb @@ -278,7 +278,7 @@ def scrub(transcript) private def build_purchase_request(type, money, creditcard, options) - options.merge!(:action => 'CardDetailsTransaction') + options[:action] = 'CardDetailsTransaction' build_request(options) do |xml| add_purchase_data(xml, type, money, options) add_creditcard(xml, creditcard) @@ -287,7 +287,7 @@ def build_purchase_request(type, money, creditcard, options) end def build_reference_request(type, money, authorization, options) - options.merge!(:action => 'CrossReferenceTransaction') + options[:action] = 'CrossReferenceTransaction' order_id, cross_reference, _ = authorization.split(';') build_request(options) do |xml| if money diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index 3c841fccc53..900f2ceb361 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -23,8 +23,8 @@ def initialize(options={}) def purchase(money, payment, options={}) MultiResponse.run do |r| r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) } - options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand)) - options.merge!(card_token: r.authorization.split('|').first) + options[:card_brand] = (CARD_BRAND[payment.brand] || payment.brand) + options[:card_token] = r.authorization.split('|').first r.process { commit('purchase', 'payments', purchase_request(money, payment, options) ) } end end @@ -32,8 +32,8 @@ def purchase(money, payment, options={}) def authorize(money, payment, options={}) MultiResponse.run do |r| r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) } - options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand)) - options.merge!(card_token: r.authorization.split('|').first) + options[:card_brand] = (CARD_BRAND[payment.brand] || payment.brand) + options[:card_token] = r.authorization.split('|').first r.process { commit('authorize', 'payments', authorize_request(money, payment, options) ) } end end @@ -108,7 +108,7 @@ def purchase_request(money, payment, options = {}) def authorize_request(money, payment, options = {}) post = purchase_request(money, payment, options) - post.merge!(capture: false) + post[:capture] = false post end diff --git a/lib/active_merchant/billing/gateways/merchant_one.rb b/lib/active_merchant/billing/gateways/merchant_one.rb index a514a9e6107..2352178da07 100644 --- a/lib/active_merchant/billing/gateways/merchant_one.rb +++ b/lib/active_merchant/billing/gateways/merchant_one.rb @@ -46,7 +46,7 @@ def purchase(money, creditcard, options = {}) def capture(money, authorization, options = {}) post = {} - post.merge!(:transactionid => authorization) + post[:transactionid] = authorization add_amount(post, money, options) commit('capture', money, post) end @@ -87,7 +87,7 @@ def commit(action, money, parameters={}) end def post_data(action, parameters = {}) - parameters.merge!({:type => action}) + parameters[:type] = action ret = '' for key in parameters.keys ret += "#{key}=#{CGI.escape(parameters[key].to_s)}" diff --git a/lib/active_merchant/billing/gateways/merchant_warrior.rb b/lib/active_merchant/billing/gateways/merchant_warrior.rb index 701b44ab049..66da5f62317 100644 --- a/lib/active_merchant/billing/gateways/merchant_warrior.rb +++ b/lib/active_merchant/billing/gateways/merchant_warrior.rb @@ -46,7 +46,7 @@ def capture(money, identification, options = {}) post = {} add_amount(post, money, options) add_transaction(post, identification) - post.merge!('captureAmount' => amount(money)) + post['captureAmount'] = amount(money) commit('processCapture', post) end diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb index 27c13eee3b6..a7bc303d06c 100644 --- a/lib/active_merchant/billing/gateways/migs.rb +++ b/lib/active_merchant/billing/gateways/migs.rb @@ -169,10 +169,8 @@ def purchase_offsite_url(money, options = {}) add_invoice(post, options) add_creditcard_type(post, options[:card_type]) if options[:card_type] - post.merge!( - :Locale => options[:locale] || 'en', - :ReturnURL => options[:return_url] - ) + post[:Locale] = options[:locale] || 'en' + post[:ReturnURL] = options[:return_url] add_standard_parameters('pay', post, options[:unique_id]) diff --git a/lib/active_merchant/billing/gateways/netbanx.rb b/lib/active_merchant/billing/gateways/netbanx.rb index 8afb50bfb66..78f80153ec4 100644 --- a/lib/active_merchant/billing/gateways/netbanx.rb +++ b/lib/active_merchant/billing/gateways/netbanx.rb @@ -170,7 +170,7 @@ def map_address(address) :zip => address[:zip], :state => address[:state], } - mapped.merge!({:country => country.code(:alpha2).value}) unless country.blank? + mapped[:country] = country.code(:alpha2).value unless country.blank? mapped end diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb index 3805eaf7df9..b0a8be19343 100644 --- a/lib/active_merchant/billing/gateways/ogone.rb +++ b/lib/active_merchant/billing/gateways/ogone.rb @@ -213,7 +213,7 @@ def verify(credit_card, options={}) # Store a credit card by creating an Ogone Alias def store(payment_source, options = {}) - options.merge!(:alias_operation => 'BYPSP') unless(options.has_key?(:billing_id) || options.has_key?(:store)) + options[:alias_operation] = 'BYPSP' unless(options.has_key?(:billing_id) || options.has_key?(:store)) response = authorize(@options[:store_amount] || 1, payment_source, options) void(response.authorization) if response.success? response diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index 89a5007f85b..c5f9000e4e3 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -273,13 +273,13 @@ def void(authorization, options = {}, deprecated = {}) # 'MS' - Manual Suspend def add_customer_profile(creditcard, options = {}) - options.merge!(:customer_profile_action => CREATE) + options[:customer_profile_action] = CREATE order = build_customer_request_xml(creditcard, options) commit(order, :add_customer_profile) end def update_customer_profile(creditcard, options = {}) - options.merge!(:customer_profile_action => UPDATE) + options[:customer_profile_action] = UPDATE order = build_customer_request_xml(creditcard, options) commit(order, :update_customer_profile) end @@ -529,8 +529,10 @@ def recurring_parse_element(response, node) def commit(order, message_type, trace_number=nil) headers = POST_HEADERS.merge('Content-length' => order.size.to_s) - headers.merge!( 'Trace-number' => trace_number.to_s, - 'Merchant-Id' => @options[:merchant_id] ) if @options[:retry_logic] && trace_number + if @options[:retry_logic] && trace_number + headers['Trace-number'] = trace_number.to_s + headers['Merchant-Id'] = @options[:merchant_id] + end request = ->(url){ parse(ssl_post(url, order, headers))} # Failover URL will be attempted in the event of a connection error diff --git a/lib/active_merchant/billing/gateways/pay_gate_xml.rb b/lib/active_merchant/billing/gateways/pay_gate_xml.rb index 572ae9d7066..7c17b1dfa3f 100644 --- a/lib/active_merchant/billing/gateways/pay_gate_xml.rb +++ b/lib/active_merchant/billing/gateways/pay_gate_xml.rb @@ -170,21 +170,24 @@ def purchase(money, creditcard, options = {}) def authorize(money, creditcard, options = {}) action = 'authtx' - options.merge!(:money => money, :creditcard => creditcard) + options[:money] = money + options[:creditcard] = creditcard commit(action, build_request(action, options)) end def capture(money, authorization, options = {}) action = 'settletx' - options.merge!(:money => money, :authorization => authorization) + options[:money] = money + options[:authorization] = authorization commit(action, build_request(action, options), authorization) end def refund(money, authorization, options={}) action = 'refundtx' - options.merge!(:money => money, :authorization => authorization) + options[:money] = money + options[:authorization] = authorization commit(action, build_request(action, options)) end diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb index 319c56bb64b..b524126ef1e 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb @@ -202,7 +202,7 @@ def build_headers(content_length) 'X-VPS-Request-ID' => SecureRandom.hex(16) } - headers.merge!('PAYPAL-NVP' => 'Y') if self.use_paypal_nvp + headers['PAYPAL-NVP'] = 'Y' if self.use_paypal_nvp headers end diff --git a/lib/active_merchant/billing/gateways/payway.rb b/lib/active_merchant/billing/gateways/payway.rb index b7b40b6c8b0..e8f9d8c163a 100644 --- a/lib/active_merchant/billing/gateways/payway.rb +++ b/lib/active_merchant/billing/gateways/payway.rb @@ -177,7 +177,7 @@ def add_auth(post) # Creates the request and returns the summarized result def commit(action, post) add_auth(post) - post.merge!('order.type' => TRANSACTIONS[action]) + post['order.type'] = TRANSACTIONS[action] request = post.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') response = ssl_post(self.live_url, request) diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 81c2fd982cc..905a370e3c9 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -177,7 +177,7 @@ def refund_application_fee(money, identification, options = {}) post = {} add_amount(post, money, options) - options.merge!(:key => @fee_refund_api_key) if @fee_refund_api_key + options[:key] = @fee_refund_api_key if @fee_refund_api_key options.delete(:stripe_account) refund_fee = commit(:post, "application_fees/#{CGI.escape(identification)}/refunds", post, options) @@ -491,7 +491,7 @@ def add_emv_metadata(post, creditcard) end def fetch_application_fee(identification, options = {}) - options.merge!(:key => @fee_refund_api_key) + options[:key] = @fee_refund_api_key fetch_charge = commit(:get, "charges/#{CGI.escape(identification)}", nil, options) application_fee_response!(fetch_charge, "Application fee id could not be retrieved: #{fetch_charge.message}") @@ -549,8 +549,8 @@ def headers(options = {}) 'X-Stripe-Client-User-Agent' => stripe_client_user_agent(options), 'X-Stripe-Client-User-Metadata' => {:ip => options[:ip]}.to_json } - headers.merge!('Idempotency-Key' => idempotency_key) if idempotency_key - headers.merge!('Stripe-Account' => options[:stripe_account]) if options[:stripe_account] + headers['Idempotency-Key'] = idempotency_key if idempotency_key + headers['Stripe-Account'] = options[:stripe_account] if options[:stripe_account] headers end diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb index 803fce7532e..90a0adb9f64 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb @@ -1538,7 +1538,7 @@ def commit(action, request) def build_response(action, soap) response_params, success, message, authorization, avs, cvv = parse(action, soap) - response_params.merge!('soap_response' => soap) if @options[:soap_response] + response_params['soap_response'] = soap if @options[:soap_response] Response.new( success, @@ -1553,7 +1553,7 @@ def build_response(action, soap) def avs_from(avs) avs_params = { :code => avs } - avs_params.merge!(:message => AVS_CUSTOM_MESSAGES[avs]) if AVS_CUSTOM_MESSAGES.key?(avs) + avs_params[:message] = AVS_CUSTOM_MESSAGES[avs] if AVS_CUSTOM_MESSAGES.key?(avs) avs_params end diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index 7d817e61a9b..bb06b90c88f 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -212,7 +212,7 @@ def add_amount(xml, money, options) } if options[:debit_credit_indicator] - amount_hash.merge!('debitCreditIndicator' => options[:debit_credit_indicator]) + amount_hash['debitCreditIndicator'] = options[:debit_credit_indicator] end xml.tag! 'amount', amount_hash @@ -339,7 +339,7 @@ def headers(options) 'Authorization' => encoded_credentials } if options[:cookie] - headers.merge!('Set-Cookie' => options[:cookie]) if options[:cookie] + headers['Set-Cookie'] = options[:cookie] if options[:cookie] end headers end diff --git a/test/remote/gateways/remote_card_save_test.rb b/test/remote/gateways/remote_card_save_test.rb index 9fe97a8d251..06ee56d1053 100644 --- a/test/remote/gateways/remote_card_save_test.rb +++ b/test/remote/gateways/remote_card_save_test.rb @@ -25,7 +25,7 @@ def test_successful_purchase end def test_unsuccessful_purchase - @options.merge!(:billing_address => @addresses[@declined_card.number]) + @options[:billing_address] = @addresses[@declined_card.number] assert response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response assert_equal 'Card declined', response.message diff --git a/test/remote/gateways/remote_eway_rapid_test.rb b/test/remote/gateways/remote_eway_rapid_test.rb index edf59a27625..f0c33ba61e8 100644 --- a/test/remote/gateways/remote_eway_rapid_test.rb +++ b/test/remote/gateways/remote_eway_rapid_test.rb @@ -153,7 +153,7 @@ def test_successful_store end def test_failed_store - @options[:billing_address].merge!(country: nil) + @options[:billing_address][:country] = nil response = @gateway.store(@credit_card, @options) assert_failure response assert_equal 'V6044', response.params['Errors'] diff --git a/test/remote/gateways/remote_linkpoint_test.rb b/test/remote/gateways/remote_linkpoint_test.rb index 722b17d6ef7..1a51911712d 100644 --- a/test/remote/gateways/remote_linkpoint_test.rb +++ b/test/remote/gateways/remote_linkpoint_test.rb @@ -90,12 +90,11 @@ def test_successfull_purchase_and_credit end def test_successfull_purchase_with_item_entity - @options.merge!({:line_items => - [ - {:id => '123456', :description => 'Logo T-Shirt', :price => '12.00', :quantity => '1', - :options => [{:name => 'Color', :value => 'Red'}, {:name => 'Size', :value => 'XL'}]}, - {:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'} - ]}) + @options[:line_items] = [ + {:id => '123456', :description => 'Logo T-Shirt', :price => '12.00', :quantity => '1', + :options => [{:name => 'Color', :value => 'Red'}, {:name => 'Size', :value => 'XL'}]}, + {:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'} + ] assert purchase = @gateway.purchase(1500, @credit_card, @options) assert_success purchase end diff --git a/test/remote/gateways/remote_optimal_payment_test.rb b/test/remote/gateways/remote_optimal_payment_test.rb index f42849579d9..58a93dcce78 100644 --- a/test/remote/gateways/remote_optimal_payment_test.rb +++ b/test/remote/gateways/remote_optimal_payment_test.rb @@ -24,7 +24,7 @@ def test_successful_purchase end def test_unsuccessful_purchase_with_shipping_address - @options.merge!(:shipping_address => address) + @options[:shipping_address] = address assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal 'no_error', response.message diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb index 55cdcce9bd0..ccceb0fc5ed 100644 --- a/test/remote/gateways/remote_orbital_test.rb +++ b/test/remote/gateways/remote_orbital_test.rb @@ -198,7 +198,7 @@ def test_auth_only_transactions for suite in @test_suite do amount = suite[:amount] card = credit_card(@cards[suite[:card]], :verification_value => suite[:CVD]) - @options[:address].merge!(:zip => suite[:AVSzip]) + @options[:address][:zip] = suite[:AVSzip] assert response = @gateway.authorize(amount, card, @options) assert_kind_of Response, response @@ -216,7 +216,7 @@ def test_auth_capture_transactions for suite in @test_suite do amount = suite[:amount] card = credit_card(@cards[suite[:card]], :verification_value => suite[:CVD]) - options = @options; options[:address].merge!(:zip => suite[:AVSzip]) + options = @options; options[:address][:zip] = suite[:AVSzip] assert response = @gateway.purchase(amount, card, options) assert_kind_of Response, response diff --git a/test/remote/gateways/remote_pro_pay_test.rb b/test/remote/gateways/remote_pro_pay_test.rb index 5a99435ed6b..c447f996862 100644 --- a/test/remote/gateways/remote_pro_pay_test.rb +++ b/test/remote/gateways/remote_pro_pay_test.rb @@ -34,7 +34,7 @@ def test_successful_purchase_with_more_options end def test_successful_recurring_purchase_without_cvv - @options.merge!({recurring_payment: 'Y'}) + @options[:recurring_payment] = 'Y' response = @gateway.purchase(@amount, @credit_card_without_cvv, @options) assert_success response assert_equal 'Success', response.message diff --git a/test/remote/gateways/remote_usa_epay_advanced_test.rb b/test/remote/gateways/remote_usa_epay_advanced_test.rb index df133607dda..021f73d910a 100644 --- a/test/remote/gateways/remote_usa_epay_advanced_test.rb +++ b/test/remote/gateways/remote_usa_epay_advanced_test.rb @@ -312,7 +312,7 @@ def test_run_check_credit # TODO get offline auth_code? def test_post_auth - @options.merge!(:authorization_code => 123456) + @options[:authorization_code] = 123456 response = @gateway.post_auth(@options) assert response.params['post_auth_return'] end diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index fd4f73be9dd..c6f116a15c4 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -21,11 +21,11 @@ def test_successful_purchase end def test_successful_purchase_with_hcg_additional_data - @options.merge!(hcg_additional_data: { + @options[:hcg_additional_data] = { key1: 'value1', key2: 'value2', key3: 'value3' - }) + } assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response diff --git a/test/unit/gateways/credorax_test.rb b/test/unit/gateways/credorax_test.rb index 8c588c3f108..18eb1d1381d 100644 --- a/test/unit/gateways/credorax_test.rb +++ b/test/unit/gateways/credorax_test.rb @@ -215,7 +215,7 @@ def test_adds_a9_field end def test_supports_billing_descriptor - @options.merge!({ billing_descriptor: 'abcdefghijkl'}) + @options[:billing_descriptor] = 'abcdefghijkl' stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| diff --git a/test/unit/gateways/mundipagg_test.rb b/test/unit/gateways/mundipagg_test.rb index 7caa206f0d0..208ddba3a5d 100644 --- a/test/unit/gateways/mundipagg_test.rb +++ b/test/unit/gateways/mundipagg_test.rb @@ -25,7 +25,7 @@ def test_successful_purchase end def test_successful_purchase_with_holder_document - @options.merge!(holder_document: 'a1b2c3d4') + @options[:holder_document] = 'a1b2c3d4' response = stub_comms do @gateway.purchase(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index edbafbd49d4..0f66d7985ad 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -1197,7 +1197,7 @@ def test_passing_expand_parameters post.include?('expand[0]=balance_transaction') end.returns(successful_authorization_response) - @options.merge!(:expand => :balance_transaction) + @options[:expand] = :balance_transaction @gateway.authorize(@amount, @credit_card, @options) end @@ -1207,7 +1207,7 @@ def test_passing_expand_parameters_as_array post.include?('expand[0]=balance_transaction&expand[1]=customer') end.returns(successful_authorization_response) - @options.merge!(:expand => [:balance_transaction, :customer]) + @options[:expand] = [:balance_transaction, :customer] @gateway.authorize(@amount, @credit_card, @options) end @@ -1225,7 +1225,7 @@ def test_passing_recurring_eci_sets_recurring_flag post.include?('recurring=true') end.returns(successful_authorization_response) - @options.merge!(eci: 'recurring') + @options[:eci] = 'recurring' @gateway.authorize(@amount, @credit_card, @options) end @@ -1235,7 +1235,7 @@ def test_passing_unknown_eci_does_not_set_recurring_flag !post.include?('recurring') end.returns(successful_authorization_response) - @options.merge!(eci: 'installment') + @options[:eci] = 'installment' @gateway.authorize(@amount, @credit_card, @options) end @@ -1245,7 +1245,7 @@ def test_passing_recurring_true_option_sets_recurring_flag post.include?('recurring=true') end.returns(successful_authorization_response) - @options.merge!(recurring: true) + @options[:recurring] = true @gateway.authorize(@amount, @credit_card, @options) end @@ -1255,7 +1255,7 @@ def test_passing_recurring_false_option_does_not_set_recurring_flag !post.include?('recurring') end.returns(successful_authorization_response) - @options.merge!(recurring: false) + @options[:recurring] = false @gateway.authorize(@amount, @credit_card, @options) end @@ -1400,7 +1400,7 @@ def test_passing_stripe_account_header headers.include?('Stripe-Account') end.returns(successful_authorization_response) - @options.merge!(stripe_account: fixtures(:stripe_destination)[:stripe_user_id]) + @options[:stripe_account] = fixtures(:stripe_destination)[:stripe_user_id] @gateway.purchase(@amount, @credit_card, @options) end diff --git a/test/unit/gateways/usa_epay_advanced_test.rb b/test/unit/gateways/usa_epay_advanced_test.rb index 5f37ec88899..7c22b87d841 100644 --- a/test/unit/gateways/usa_epay_advanced_test.rb +++ b/test/unit/gateways/usa_epay_advanced_test.rb @@ -290,7 +290,7 @@ def test_successful_get_customer_payment_methods end def test_successful_update_customer_payment_method - @options.merge!(@payment_options).merge!(:method_id => 1) + @options.merge!(@payment_options)[:method_id] = 1 @gateway.expects(:ssl_post).returns(successful_update_customer_payment_method_response) assert response = @gateway.update_customer_payment_method(@options) From b7c2aca7ba599bf406797cf403bad8bbdbffe9b0 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Mon, 5 Nov 2018 09:31:06 -0500 Subject: [PATCH 624/677] Braintree: Actually account for nil address fields Phone is not the only field a billing address option may contain that the gateway doesn't want in the element, so we now instead map fields first, and then don't add the hash if there are no non-nil fields. Closes #3032 Remote: 64 tests, 365 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 56 tests, 141 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/braintree_blue.rb | 9 +++++---- test/remote/gateways/remote_braintree_blue_test.rb | 11 +++++++++-- test/unit/gateways/braintree_blue_test.rb | 4 +++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d678c59ba95..d225259b878 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ * Litle: Capitalize check account type [curiousepic] #3028 * Braintree: Account for nil billing address fields [curiousepic] #3029 * Realex: Add verify [kheang] #3030 +* Braintree: Actually account for nil address fields [curiousepic] #3032 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index fdd5111fa8a..715f57e0f9b 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -303,10 +303,11 @@ def merge_credit_card_options(parameters, options) end parameters[:credit_card] ||= {} - parameters[:credit_card][:options] = valid_options - address = options[:billing_address]&.except(:phone) - return parameters if address.nil? || address.values.compact.empty? - parameters[:credit_card][:billing_address] = map_address(address) + parameters[:credit_card].merge!(:options => valid_options) + if options[:billing_address] + address = map_address(options[:billing_address]) + parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| v.nil? } + end parameters end diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index ff816acb973..7ae338e81ca 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -168,10 +168,17 @@ def test_successful_store_with_billing_address assert_equal purchase_response.params['braintree_transaction']['billing_details'], response_billing_details end - def test_successful_store_with_phone_only_billing_address_option + def test_successful_store_with_nil_billing_address_options billing_address = { + :name => 'John Smith', :phone => '123-456-7890', - :city => nil + :company => nil, + :address1 => nil, + :address2 => nil, + :city => nil, + :state => nil, + :zip => nil, + :country_name => nil } credit_card = credit_card('5105105105105100') assert response = @gateway.store(credit_card, :billing_address => billing_address) diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index 0a604b717f5..21f7e152be5 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -373,7 +373,7 @@ def test_store_with_phone_only_billing_address_option @gateway.store(credit_card('41111111111111111111'), :billing_address => billing_address) end - def test_store_with_phone_only_non_nil_billing_address_option + def test_store_with_nil_billing_address_options customer_attributes = { :credit_cards => [stub_everything], :email => 'email', @@ -382,7 +382,9 @@ def test_store_with_phone_only_non_nil_billing_address_option :phone => '123-456-7890' } billing_address = { + :name => 'John Smith', :phone => '123-456-7890', + :company => nil, :address1 => nil, :address2 => nil, :city => nil, From 6ea353a450fd48c1df7c539e698327bd5ac40e0d Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Mon, 22 Oct 2018 11:10:06 -0400 Subject: [PATCH 625/677] Rubocop: Layout/CaseIndention and Layout/ElseAlignment Fixes some issues with indention and alignment with cases and elses. --- .rubocop.yml | 3 + .rubocop_todo.yml | 25 ------- .../billing/credit_card_formatting.rb | 6 +- lib/active_merchant/billing/gateway.rb | 18 ++--- .../billing/gateways/authorize_net.rb | 12 ++-- .../billing/gateways/authorize_net_cim.rb | 16 ++--- .../billing/gateways/balanced.rb | 16 ++--- .../billing/gateways/braintree_blue.rb | 2 +- .../billing/gateways/card_stream.rb | 14 ++-- .../billing/gateways/clearhaus.rb | 12 ++-- .../billing/gateways/eway_managed.rb | 8 +-- .../billing/gateways/firstdata_e4.rb | 12 ++-- .../billing/gateways/moneris.rb | 20 +++--- .../billing/gateways/moneris_us.rb | 10 +-- .../billing/gateways/netbanx.rb | 70 +++++++++---------- lib/active_merchant/billing/gateways/omise.rb | 10 +-- .../billing/gateways/pac_net_raven.rb | 10 +-- .../billing/gateways/payflow.rb | 18 ++--- .../billing/gateways/payment_express.rb | 14 ++-- .../billing/gateways/paymill.rb | 4 +- .../billing/gateways/sage_pay.rb | 6 +- .../billing/gateways/trust_commerce.rb | 6 +- lib/active_merchant/billing/response.rb | 12 ++-- 23 files changed, 151 insertions(+), 173 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d101dfec1a3..f1deca38196 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -29,3 +29,6 @@ Layout/AlignParameters: Layout/DotPosition: EnforcedStyle: trailing + +Layout/CaseIndentation: + EnforcedStyle: end diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 689e4e01296..3c88f5cb74d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -14,36 +14,11 @@ Gemspec/OrderedDependencies: Exclude: - 'activemerchant.gemspec' -# Offense count: 113 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. -# SupportedStyles: case, end -Layout/CaseIndentation: - Enabled: false - # Offense count: 426 # Cop supports --auto-correct. Layout/ClosingHeredocIndentation: Enabled: false -# Offense count: 24 -# Cop supports --auto-correct. -Layout/ElseAlignment: - Exclude: - - 'lib/active_merchant/billing/gateway.rb' - - 'lib/active_merchant/billing/gateways/authorize_net.rb' - - 'lib/active_merchant/billing/gateways/balanced.rb' - - 'lib/active_merchant/billing/gateways/braintree_blue.rb' - - 'lib/active_merchant/billing/gateways/card_stream.rb' - - 'lib/active_merchant/billing/gateways/clearhaus.rb' - - 'lib/active_merchant/billing/gateways/firstdata_e4.rb' - - 'lib/active_merchant/billing/gateways/moneris.rb' - - 'lib/active_merchant/billing/gateways/moneris_us.rb' - - 'lib/active_merchant/billing/gateways/pac_net_raven.rb' - - 'lib/active_merchant/billing/gateways/payflow.rb' - - 'lib/active_merchant/billing/gateways/trust_commerce.rb' - - 'lib/active_merchant/billing/response.rb' - # Offense count: 165 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/active_merchant/billing/credit_card_formatting.rb b/lib/active_merchant/billing/credit_card_formatting.rb index 74837bebac0..2a55bae60ad 100644 --- a/lib/active_merchant/billing/credit_card_formatting.rb +++ b/lib/active_merchant/billing/credit_card_formatting.rb @@ -13,9 +13,9 @@ def format(number, option) return '' if number.blank? case option - when :two_digits then sprintf('%.2i', number.to_i)[-2..-1] - when :four_digits then sprintf('%.4i', number.to_i)[-4..-1] - else number + when :two_digits then sprintf('%.2i', number.to_i)[-2..-1] + when :four_digits then sprintf('%.4i', number.to_i)[-4..-1] + else number end end end diff --git a/lib/active_merchant/billing/gateway.rb b/lib/active_merchant/billing/gateway.rb index 9db7133d6b2..29fcc6bbaf8 100644 --- a/lib/active_merchant/billing/gateway.rb +++ b/lib/active_merchant/billing/gateway.rb @@ -204,11 +204,11 @@ def supports_network_tokenization? def normalize(field) case field - when 'true' then true - when 'false' then false - when '' then nil - when 'null' then nil - else field + when 'true' then true + when 'false' then false + when '' then nil + when 'null' then nil + else field end end @@ -241,10 +241,10 @@ def name def amount(money) return nil if money.nil? cents = if money.respond_to?(:cents) - ActiveMerchant.deprecated 'Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents' - money.cents - else - money + ActiveMerchant.deprecated 'Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents' + money.cents + else + money end if money.is_a?(String) diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index 75fa6c6fdd1..31640f0ca11 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -133,9 +133,9 @@ def capture(amount, authorization, options={}) def refund(amount, authorization, options={}) response = if auth_was_for_cim?(authorization) - cim_refund(amount, authorization, options) - else - normal_refund(amount, authorization, options) + cim_refund(amount, authorization, options) + else + normal_refund(amount, authorization, options) end return response if response.success? @@ -594,9 +594,9 @@ def add_shipping_address(xml, options, root_node='shipTo') xml.send(root_node) do first_name, last_name = if address[:name] - split_names(address[:name]) - else - [address[:first_name], address[:last_name]] + split_names(address[:name]) + else + [address[:first_name], address[:last_name]] end full_address = "#{address[:address1]} #{address[:address2]}".strip diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb index f57e1397af3..5f9d67c1a01 100644 --- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb +++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb @@ -379,18 +379,18 @@ def create_customer_profile_transaction(options) requires!(options, :transaction) requires!(options[:transaction], :type) case options[:transaction][:type] - when :void + when :void requires!(options[:transaction], :trans_id) - when :refund + when :refund requires!(options[:transaction], :trans_id) && ( (options[:transaction][:customer_profile_id] && options[:transaction][:customer_payment_profile_id]) || options[:transaction][:credit_card_number_masked] || (options[:transaction][:bank_routing_number_masked] && options[:transaction][:bank_account_number_masked]) ) - when :prior_auth_capture + when :prior_auth_capture requires!(options[:transaction], :amount, :trans_id) - else + else requires!(options[:transaction], :amount, :customer_profile_id, :customer_payment_profile_id) end request = build_request(:create_customer_profile_transaction, options) @@ -665,12 +665,12 @@ def add_transaction(xml, transaction) xml.tag!(CIM_TRANSACTION_TYPES[transaction[:type]]) do # The amount to be billed to the customer case transaction[:type] - when :void + when :void tag_unless_blank(xml,'customerProfileId', transaction[:customer_profile_id]) tag_unless_blank(xml,'customerPaymentProfileId', transaction[:customer_payment_profile_id]) tag_unless_blank(xml,'customerShippingAddressId', transaction[:customer_shipping_address_id]) xml.tag!('transId', transaction[:trans_id]) - when :refund + when :refund xml.tag!('amount', transaction[:amount]) tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id]) tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id]) @@ -683,11 +683,11 @@ def add_transaction(xml, transaction) add_tax(xml, transaction[:tax]) if transaction[:tax] add_duty(xml, transaction[:duty]) if transaction[:duty] add_shipping(xml, transaction[:shipping]) if transaction[:shipping] - when :prior_auth_capture + when :prior_auth_capture xml.tag!('amount', transaction[:amount]) add_order(xml, transaction[:order]) if transaction[:order].present? xml.tag!('transId', transaction[:trans_id]) - else + else xml.tag!('amount', transaction[:amount]) xml.tag!('customerProfileId', transaction[:customer_profile_id]) xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id]) diff --git a/lib/active_merchant/billing/gateways/balanced.rb b/lib/active_merchant/billing/gateways/balanced.rb index dcc931d7e45..671cc596bf3 100644 --- a/lib/active_merchant/billing/gateways/balanced.rb +++ b/lib/active_merchant/billing/gateways/balanced.rb @@ -45,10 +45,10 @@ def purchase(money, payment_method, options = {}) MultiResponse.run do |r| identifier = if(payment_method.respond_to?(:number)) - r.process{store(payment_method, options)} - r.authorization - else - payment_method + r.process{store(payment_method, options)} + r.authorization + else + payment_method end r.process{commit('debits', "cards/#{card_identifier_from(identifier)}/debits", post)} end @@ -62,10 +62,10 @@ def authorize(money, payment_method, options = {}) MultiResponse.run do |r| identifier = if(payment_method.respond_to?(:number)) - r.process{store(payment_method, options)} - r.authorization - else - payment_method + r.process{store(payment_method, options)} + r.authorization + else + payment_method end r.process{commit('card_holds', "cards/#{card_identifier_from(identifier)}/card_holds", post)} end diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 715f57e0f9b..0669b444b8b 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -303,7 +303,7 @@ def merge_credit_card_options(parameters, options) end parameters[:credit_card] ||= {} - parameters[:credit_card].merge!(:options => valid_options) + parameters[:credit_card][:options] = valid_options if options[:billing_address] address = map_address(options[:billing_address]) parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| v.nil? } diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb index 8fa7085e67c..190f2fe797b 100644 --- a/lib/active_merchant/billing/gateways/card_stream.rb +++ b/lib/active_merchant/billing/gateways/card_stream.rb @@ -334,13 +334,13 @@ def avs_from(response) street_match = AVS_STREET_MATCH[response[:avscv2ResponseCode].to_s[2, 1]] code = if postal_match == 'Y' && street_match == 'Y' - 'M' - elsif postal_match == 'Y' - 'P' - elsif street_match == 'Y' - 'A' - else - 'I' + 'M' + elsif postal_match == 'Y' + 'P' + elsif street_match == 'Y' + 'A' + else + 'I' end AVSResult.new({ diff --git a/lib/active_merchant/billing/gateways/clearhaus.rb b/lib/active_merchant/billing/gateways/clearhaus.rb index 4fd7745f395..2d2d73aa4f2 100644 --- a/lib/active_merchant/billing/gateways/clearhaus.rb +++ b/lib/active_merchant/billing/gateways/clearhaus.rb @@ -54,12 +54,12 @@ def authorize(amount, payment, options={}) add_invoice(post, amount, options) action = if payment.respond_to?(:number) - add_payment(post, payment) - '/authorizations' - elsif payment.kind_of?(String) - "/cards/#{payment}/authorizations" - else - raise ArgumentError.new("Unknown payment type #{payment.inspect}") + add_payment(post, payment) + '/authorizations' + elsif payment.kind_of?(String) + "/cards/#{payment}/authorizations" + else + raise ArgumentError.new("Unknown payment type #{payment.inspect}") end post[:recurring] = options[:recurring] if options[:recurring] diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb index 780f5c55481..2182bfac70b 100644 --- a/lib/active_merchant/billing/gateways/eway_managed.rb +++ b/lib/active_merchant/billing/gateways/eway_managed.rb @@ -231,13 +231,13 @@ def commit(action, post) def soap_request(arguments, action) # eWay demands all fields be sent, but contain an empty string if blank post = case action - when 'QueryCustomer' + when 'QueryCustomer' arguments - when 'ProcessPayment' + when 'ProcessPayment' default_payment_fields.merge(arguments) - when 'CreateCustomer' + when 'CreateCustomer' default_customer_fields.merge(arguments) - when 'UpdateCustomer' + when 'UpdateCustomer' default_customer_fields.merge(arguments) end diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index fa5781da07c..da6b77b306e 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -246,12 +246,12 @@ def add_credit_card(xml, credit_card, options) def add_credit_card_eci(xml, credit_card, options) eci = if credit_card.is_a?(NetworkTokenizationCreditCard) && credit_card.source == :apple_pay && card_brand(credit_card) == 'discover' - # Discover requires any Apple Pay transaction, regardless of in-app - # or web, and regardless of the ECI contained in the PKPaymentToken, - # to have an ECI value explicitly of 04. - '04' - else - (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI + # Discover requires any Apple Pay transaction, regardless of in-app + # or web, and regardless of the ECI contained in the PKPaymentToken, + # to have an ECI value explicitly of 04. + '04' + else + (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI end xml.tag! 'Ecommerce_Flag', eci.to_s =~ /^[0-9]+$/ ? eci.to_s.rjust(2, '0') : eci diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb index bf8533c78fc..97c3d6cbc63 100644 --- a/lib/active_merchant/billing/gateways/moneris.rb +++ b/lib/active_merchant/billing/gateways/moneris.rb @@ -51,11 +51,11 @@ def authorize(money, creditcard_or_datakey, options = {}) post[:address] = options[:billing_address] || options[:address] post[:crypt_type] = options[:crypt_type] || @options[:crypt_type] action = if post[:cavv] - 'cavv_preauth' - elsif post[:data_key].blank? - 'preauth' - else - 'res_preauth_cc' + 'cavv_preauth' + elsif post[:data_key].blank? + 'preauth' + else + 'res_preauth_cc' end commit(action, post) end @@ -73,11 +73,11 @@ def purchase(money, creditcard_or_datakey, options = {}) post[:address] = options[:billing_address] || options[:address] post[:crypt_type] = options[:crypt_type] || @options[:crypt_type] action = if post[:cavv] - 'cavv_purchase' - elsif post[:data_key].blank? - 'purchase' - else - 'res_purchase_cc' + 'cavv_purchase' + elsif post[:data_key].blank? + 'purchase' + else + 'res_purchase_cc' end commit(action, post) end diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb index 9fc3f5b55c4..5cb3c515183 100644 --- a/lib/active_merchant/billing/gateways/moneris_us.rb +++ b/lib/active_merchant/billing/gateways/moneris_us.rb @@ -74,11 +74,11 @@ def purchase(money, creditcard_or_datakey, options = {}) add_address(post, creditcard_or_datakey, options) post[:crypt_type] = options[:crypt_type] || @options[:crypt_type] action = if creditcard_or_datakey.is_a?(String) - 'us_res_purchase_cc' - elsif card_brand(creditcard_or_datakey) == 'check' - 'us_ach_debit' - elsif post[:data_key].blank? - 'us_purchase' + 'us_res_purchase_cc' + elsif card_brand(creditcard_or_datakey) == 'check' + 'us_ach_debit' + elsif post[:data_key].blank? + 'us_purchase' end commit(action, post) end diff --git a/lib/active_merchant/billing/gateways/netbanx.rb b/lib/active_merchant/billing/gateways/netbanx.rb index 78f80153ec4..901efd4ddfb 100644 --- a/lib/active_merchant/billing/gateways/netbanx.rb +++ b/lib/active_merchant/billing/gateways/netbanx.rb @@ -247,41 +247,41 @@ def headers def error_code_from(response) unless success_from(response) case response['errorCode'] - when '3002' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid card number or brand or combination of card number and brand with your request. - when '3004' then STANDARD_ERROR_CODE[:incorrect_zip] # The zip/postal code must be provided for an AVS check request. - when '3005' then STANDARD_ERROR_CODE[:incorrect_cvc] # You submitted an incorrect CVC value with your request. - when '3006' then STANDARD_ERROR_CODE[:expired_card] # You submitted an expired credit card number with your request. - when '3009' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank. - when '3011' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the card used is a restricted card. Contact the cardholder's credit card company for further investigation. - when '3012' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the credit card expiry date submitted is invalid. - when '3013' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to problems with the credit card account. - when '3014' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined - the issuing bank has returned an unknown response. Contact the card holder's credit card company for further investigation. - when '3015' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you process the transaction manually by calling the cardholder's credit card company. - when '3016' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – it may be a lost or stolen card. - when '3017' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid credit card number with your request. - when '3022' then STANDARD_ERROR_CODE[:card_declined] # The card has been declined due to insufficient funds. - when '3023' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to its proprietary card activity regulations. - when '3024' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the issuing bank does not permit the transaction for this card. - when '3032' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank or external gateway because the card is probably in one of their negative databases. - when '3035' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to exceeded PIN attempts. - when '3036' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid issuer. - when '3037' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because it is invalid. - when '3038' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to customer cancellation. - when '3039' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid authentication value. - when '3040' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the request type is not permitted on the card. - when '3041' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a timeout. - when '3042' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a cryptographic error. - when '3045' then STANDARD_ERROR_CODE[:invalid_expiry_date] # You submitted an invalid date format for this request. - when '3046' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount was set to zero. - when '3047' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount exceeds the floor limit. - when '3048' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount is less than the floor limit. - when '3049' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card has expired. - when '3050' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – fraudulent activity is suspected. - when '3051' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – contact the acquirer for more information. - when '3052' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card is restricted. - when '3053' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – please call the acquirer. - when '3054' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined due to suspected fraud. - else STANDARD_ERROR_CODE[:processing_error] + when '3002' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid card number or brand or combination of card number and brand with your request. + when '3004' then STANDARD_ERROR_CODE[:incorrect_zip] # The zip/postal code must be provided for an AVS check request. + when '3005' then STANDARD_ERROR_CODE[:incorrect_cvc] # You submitted an incorrect CVC value with your request. + when '3006' then STANDARD_ERROR_CODE[:expired_card] # You submitted an expired credit card number with your request. + when '3009' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank. + when '3011' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the card used is a restricted card. Contact the cardholder's credit card company for further investigation. + when '3012' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the credit card expiry date submitted is invalid. + when '3013' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to problems with the credit card account. + when '3014' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined - the issuing bank has returned an unknown response. Contact the card holder's credit card company for further investigation. + when '3015' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you process the transaction manually by calling the cardholder's credit card company. + when '3016' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – it may be a lost or stolen card. + when '3017' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid credit card number with your request. + when '3022' then STANDARD_ERROR_CODE[:card_declined] # The card has been declined due to insufficient funds. + when '3023' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to its proprietary card activity regulations. + when '3024' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the issuing bank does not permit the transaction for this card. + when '3032' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank or external gateway because the card is probably in one of their negative databases. + when '3035' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to exceeded PIN attempts. + when '3036' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid issuer. + when '3037' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because it is invalid. + when '3038' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to customer cancellation. + when '3039' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid authentication value. + when '3040' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the request type is not permitted on the card. + when '3041' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a timeout. + when '3042' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a cryptographic error. + when '3045' then STANDARD_ERROR_CODE[:invalid_expiry_date] # You submitted an invalid date format for this request. + when '3046' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount was set to zero. + when '3047' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount exceeds the floor limit. + when '3048' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount is less than the floor limit. + when '3049' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card has expired. + when '3050' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – fraudulent activity is suspected. + when '3051' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – contact the acquirer for more information. + when '3052' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card is restricted. + when '3053' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – please call the acquirer. + when '3054' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined due to suspected fraud. + else STANDARD_ERROR_CODE[:processing_error] end end end diff --git a/lib/active_merchant/billing/gateways/omise.rb b/lib/active_merchant/billing/gateways/omise.rb index 30ff0845778..3dbb8e30c37 100644 --- a/lib/active_merchant/billing/gateways/omise.rb +++ b/lib/active_merchant/billing/gateways/omise.rb @@ -246,15 +246,15 @@ def error_code_from(response) def message_to_standard_error_code_from(response) message = response['message'] if response['code'] == 'invalid_card' case message - when /brand not supported/ + when /brand not supported/ STANDARD_ERROR_CODE[:invalid_number] - when /number is invalid/ + when /number is invalid/ STANDARD_ERROR_CODE[:incorrect_number] - when /expiration date cannot be in the past/ + when /expiration date cannot be in the past/ STANDARD_ERROR_CODE[:expired_card] - when /expiration \w+ is invalid/ + when /expiration \w+ is invalid/ STANDARD_ERROR_CODE[:invalid_expiry_date] - else + else STANDARD_ERROR_CODE[:processing_error] end end diff --git a/lib/active_merchant/billing/gateways/pac_net_raven.rb b/lib/active_merchant/billing/gateways/pac_net_raven.rb index 631e1441175..fbc5557fd07 100644 --- a/lib/active_merchant/billing/gateways/pac_net_raven.rb +++ b/lib/active_merchant/billing/gateways/pac_net_raven.rb @@ -193,11 +193,11 @@ def request_id def signature(action, post, parameters = {}) string = if %w(cc_settle cc_debit cc_preauth cc_refund).include?(action) - post['UserName'] + post['Timestamp'] + post['RequestID'] + post['PymtType'] + parameters['Amount'].to_s + parameters['Currency'] - elsif action == 'void' - post['UserName'] + post['Timestamp'] + post['RequestID'] + parameters['TrackingNumber'] - else - post['UserName'] + post['UserName'] + post['Timestamp'] + post['RequestID'] + post['PymtType'] + parameters['Amount'].to_s + parameters['Currency'] + elsif action == 'void' + post['UserName'] + post['Timestamp'] + post['RequestID'] + parameters['TrackingNumber'] + else + post['UserName'] end OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new(@options[:secret]), @options[:secret], string) end diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb index db7ac1cbe11..418e2e05b68 100644 --- a/lib/active_merchant/billing/gateways/payflow.rb +++ b/lib/active_merchant/billing/gateways/payflow.rb @@ -318,20 +318,20 @@ def build_recurring_request(action, money, options) def get_pay_period(options) requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily, :semimonthly, :quadweekly, :quarterly, :semiyearly]) case options[:periodicity] - when :weekly then 'Weekly' - when :biweekly then 'Bi-weekly' - when :semimonthly then 'Semi-monthly' - when :quadweekly then 'Every four weeks' - when :monthly then 'Monthly' - when :quarterly then 'Quarterly' - when :semiyearly then 'Semi-yearly' - when :yearly then 'Yearly' + when :weekly then 'Weekly' + when :biweekly then 'Bi-weekly' + when :semimonthly then 'Semi-monthly' + when :quadweekly then 'Every four weeks' + when :monthly then 'Monthly' + when :quarterly then 'Quarterly' + when :semiyearly then 'Semi-yearly' + when :yearly then 'Yearly' end end def format_rp_date(time) case time - when Time, Date then time.strftime('%m%d%Y') + when Time, Date then time.strftime('%m%d%Y') else time.to_s end diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb index 347f423fac7..b668aa14109 100644 --- a/lib/active_merchant/billing/gateways/payment_express.rb +++ b/lib/active_merchant/billing/gateways/payment_express.rb @@ -340,13 +340,13 @@ def format_date(month, year) def normalized_client_type(client_type_from_options) case client_type_from_options.to_s.downcase - when 'web' then 'Web' - when 'ivr' then 'IVR' - when 'moto' then 'MOTO' - when 'unattended' then 'Unattended' - when 'internet' then 'Internet' - when 'recurring' then 'Recurring' - else nil + when 'web' then 'Web' + when 'ivr' then 'IVR' + when 'moto' then 'MOTO' + when 'unattended' then 'Unattended' + when 'internet' then 'Internet' + when 'recurring' then 'Recurring' + else nil end end end diff --git a/lib/active_merchant/billing/gateways/paymill.rb b/lib/active_merchant/billing/gateways/paymill.rb index ff2f8268484..858cc4bd5d9 100644 --- a/lib/active_merchant/billing/gateways/paymill.rb +++ b/lib/active_merchant/billing/gateways/paymill.rb @@ -128,9 +128,9 @@ def authorization_from(parsed_response) def action_with_token(action, money, payment_method, options) options[:money] = money case payment_method - when String + when String self.send("#{action}_with_token", money, payment_method, options) - else + else MultiResponse.run do |r| r.process { save_card(payment_method, options) } r.process { self.send("#{action}_with_token", money, r.authorization, options) } diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index 591b3c6a43d..ae3f747d018 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -380,9 +380,9 @@ def url_for(action) def build_url(action) endpoint = case action - when :purchase, :authorization then 'vspdirect-register' - when :store then 'directtoken' - else TRANSACTIONS[action].downcase + when :purchase, :authorization then 'vspdirect-register' + when :store then 'directtoken' + else TRANSACTIONS[action].downcase end "#{test? ? self.test_url : self.live_url}/#{endpoint}.vsp" end diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb index 19bf5d122ad..eaf6cf4900b 100644 --- a/lib/active_merchant/billing/gateways/trust_commerce.rb +++ b/lib/active_merchant/billing/gateways/trust_commerce.rb @@ -383,9 +383,9 @@ def commit(action, parameters) clean_and_stringify_params(parameters) data = if tclink? - TCLink.send(parameters) - else - parse( ssl_post(self.live_url, post_data(parameters)) ) + TCLink.send(parameters) + else + parse( ssl_post(self.live_url, post_data(parameters)) ) end # to be considered successful, transaction status must be either "approved" or "accepted" diff --git a/lib/active_merchant/billing/response.rb b/lib/active_merchant/billing/response.rb index a59174ceb7c..8470e8385e1 100644 --- a/lib/active_merchant/billing/response.rb +++ b/lib/active_merchant/billing/response.rb @@ -27,15 +27,15 @@ def initialize(success, message, params = {}, options = {}) @emv_authorization = options[:emv_authorization] @avs_result = if options[:avs_result].kind_of?(AVSResult) - options[:avs_result].to_hash - else - AVSResult.new(options[:avs_result]).to_hash + options[:avs_result].to_hash + else + AVSResult.new(options[:avs_result]).to_hash end @cvv_result = if options[:cvv_result].kind_of?(CVVResult) - options[:cvv_result].to_hash - else - CVVResult.new(options[:cvv_result]).to_hash + options[:cvv_result].to_hash + else + CVVResult.new(options[:cvv_result]).to_hash end end end From e6cc43a3fb6145bf4c5d6d46a4eefd1282015ba6 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder <deedeelavinder@gmail.com> Date: Mon, 5 Nov 2018 20:38:36 -0500 Subject: [PATCH 626/677] Corrects Method method --- lib/active_merchant/billing/gateways/visanet_peru.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb index 47f0b5d99de..c8ba88f8b16 100644 --- a/lib/active_merchant/billing/gateways/visanet_peru.rb +++ b/lib/active_merchant/billing/gateways/visanet_peru.rb @@ -176,7 +176,7 @@ def url(action, params, options={}) end def method(action) - %w(authorize refund).include? action ? :post : :put + (%w(authorize refund).include? action) ? :post : :put end def authorization_from(params, response, options) From c1c78afe84f800b124c7011942aac2e6fba51dfc Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 6 Nov 2018 09:34:00 -0500 Subject: [PATCH 627/677] Visanet Peru: fix RuboCop error Additionally, the unit tests previously didn't actually test the right thing (the requests were returned in the wrong order)--but, due to how they were written, they could still pass. Problematic ones have been fixed, and would now fail with the patch that #3034 had to paritally revert. Unit: 13 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- .../billing/gateways/visanet_peru.rb | 2 +- test/unit/gateways/visanet_peru_test.rb | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb index c8ba88f8b16..c15d4fdde1c 100644 --- a/lib/active_merchant/billing/gateways/visanet_peru.rb +++ b/lib/active_merchant/billing/gateways/visanet_peru.rb @@ -176,7 +176,7 @@ def url(action, params, options={}) end def method(action) - (%w(authorize refund).include? action) ? :post : :put + %w(authorize refund).include?(action) ? :post : :put end def authorization_from(params, response, options) diff --git a/test/unit/gateways/visanet_peru_test.rb b/test/unit/gateways/visanet_peru_test.rb index 55d77cb4427..bbf3af32b47 100644 --- a/test/unit/gateways/visanet_peru_test.rb +++ b/test/unit/gateways/visanet_peru_test.rb @@ -16,20 +16,20 @@ def setup end def test_successful_purchase - @gateway.expects(:ssl_request).returns(successful_authorize_response) - @gateway.expects(:ssl_request).returns(successful_capture_response) + @gateway.expects(:ssl_request).with(:post, any_parameters).returns(successful_authorize_response) + @gateway.expects(:ssl_request).with(:put, any_parameters).returns(successful_capture_response) response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal 'OK', response.message assert_match %r([0-9]{9}|$), response.authorization - assert_equal @options[:order_id], response.params['externalTransactionId'] + assert_equal 'de9dc65c094fb4f1defddc562731af81', response.params['externalTransactionId'] assert response.test? end def test_failed_purchase - @gateway.expects(:ssl_request).returns(failed_authorize_response_bad_card) + @gateway.expects(:ssl_request).with(:post, any_parameters).returns(failed_authorize_response_bad_card) response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response @@ -64,14 +64,14 @@ def test_failed_authorize end def test_successful_capture - @gateway.expects(:ssl_request).returns(successful_authorize_response) - @gateway.expects(:ssl_request).returns(successful_capture_response) + @gateway.expects(:ssl_request).with(:post, any_parameters).returns(successful_authorize_response) + @gateway.expects(:ssl_request).with(:put, any_parameters).returns(successful_capture_response) response = @gateway.authorize(@amount, @credit_card, @options) capture = @gateway.capture(response.authorization, @options) assert_success capture assert_equal 'OK', capture.message assert_match %r(^[0-9]{9}|$), capture.authorization - assert_equal @options[:order_id], capture.params['externalTransactionId'] + assert_equal 'de9dc65c094fb4f1defddc562731af81', capture.params['externalTransactionId'] assert capture.test? end @@ -90,14 +90,14 @@ def test_successful_refund response = @gateway.purchase(@amount, @credit_card, @options) assert_success response - @gateway.expects(:ssl_request).returns(successful_refund_response) + @gateway.expects(:ssl_request).with(:put, any_parameters).returns(successful_refund_response) refund = @gateway.refund(@amount, response.authorization) assert_success refund assert_equal 'OK', refund.message end def test_failed_refund - @gateway.expects(:ssl_request).returns(failed_refund_response) + @gateway.expects(:ssl_request).with(:put, any_parameters).returns(failed_refund_response) response = @gateway.refund(@amount, '122333444') assert_failure response assert_match(/No se realizo la anulacion del deposito/, response.message) From 57eb7ddb92091cd75290328700e15566d0e53c87 Mon Sep 17 00:00:00 2001 From: molbrown <molly@spreedly.com> Date: Fri, 2 Nov 2018 14:29:42 -0400 Subject: [PATCH 628/677] Paymentez: Adds support for user.phone field Adds user.phone field for Paymentez and updates remote test. Unit tests: 19 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote tests: 17 tests, 33 assertions, 6 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 64.7059% passed These failures due to `The method authorize is not supported by carrier`. Country credentials used for testing do not support `authorize`. Unrelated. Closes #3033 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/paymentez.rb | 1 + test/remote/gateways/remote_paymentez_test.rb | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index d225259b878..67b40fb097b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * Braintree: Account for nil billing address fields [curiousepic] #3029 * Realex: Add verify [kheang] #3030 * Braintree: Actually account for nil address fields [curiousepic] #3032 +* Paymentez: Adds support for user.phone field [molbrown] #3033 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index af73e15b31c..55a7a786c0c 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -134,6 +134,7 @@ def add_customer_data(post, options) post[:user][:email] = options[:email] post[:user][:ip_address] = options[:ip] if options[:ip] post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number] + post[:user][:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address]) end def add_invoice(post, money, options) diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb index b6c2fca7173..5a43ce26613 100644 --- a/test/remote/gateways/remote_paymentez_test.rb +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -26,7 +26,8 @@ def test_successful_purchase_with_more_options options = { order_id: '1', ip: '127.0.0.1', - tax_percentage: 0.07 + tax_percentage: 0.07, + phone: '333 333 3333' } response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) From 3d94477b8c7e2d6d192b3cc442526574fed81216 Mon Sep 17 00:00:00 2001 From: molbrown <molly@spreedly.com> Date: Wed, 7 Nov 2018 14:15:12 -0500 Subject: [PATCH 629/677] Paymentez: Does not send nil for empty parameter phone Unit tests: 19 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote tests: 18 tests, 34 assertions, 7 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 61.1111% passed These failures due to The method authorize is not supported by carrier. Country credentials used for testing do not support authorize. Unrelated. Closes #3036 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/paymentez.rb | 3 ++- test/remote/gateways/remote_paymentez_test.rb | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 67b40fb097b..c175a8f17a9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * Realex: Add verify [kheang] #3030 * Braintree: Actually account for nil address fields [curiousepic] #3032 * Paymentez: Adds support for user.phone field [molbrown] #3033 +* Paymentez: Does not send nil for empty parameter phone [molbrown] #3036 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index 55a7a786c0c..603fca01baa 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -134,7 +134,8 @@ def add_customer_data(post, options) post[:user][:email] = options[:email] post[:user][:ip_address] = options[:ip] if options[:ip] post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number] - post[:user][:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address]) + post[:user][:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address] && + options[:billing_address][:phone]) end def add_invoice(post, money, options) diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb index 5a43ce26613..6cb11be8a46 100644 --- a/test/remote/gateways/remote_paymentez_test.rb +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -34,6 +34,18 @@ def test_successful_purchase_with_more_options assert_success response end + def test_successful_purchase_without_phone_option + options = { + order_id: '1', + ip: '127.0.0.1', + tax_percentage: 0.07 + } + + response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) + assert_success response + refute_includes(response.params, 'phone') + end + def test_successful_purchase_with_token store_response = @gateway.store(@credit_card, @options) assert_success store_response From d70550265c31af11d6a35cff7a5a072f43e74f5d Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 7 Nov 2018 16:50:31 -0500 Subject: [PATCH 630/677] Revert "Paymentez: Does not send nil for empty parameter phone" This reverts commit 3d94477b8c7e2d6d192b3cc442526574fed81216. --- CHANGELOG | 1 - lib/active_merchant/billing/gateways/paymentez.rb | 3 +-- test/remote/gateways/remote_paymentez_test.rb | 12 ------------ 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c175a8f17a9..67b40fb097b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,7 +19,6 @@ * Realex: Add verify [kheang] #3030 * Braintree: Actually account for nil address fields [curiousepic] #3032 * Paymentez: Adds support for user.phone field [molbrown] #3033 -* Paymentez: Does not send nil for empty parameter phone [molbrown] #3036 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index 603fca01baa..55a7a786c0c 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -134,8 +134,7 @@ def add_customer_data(post, options) post[:user][:email] = options[:email] post[:user][:ip_address] = options[:ip] if options[:ip] post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number] - post[:user][:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address] && - options[:billing_address][:phone]) + post[:user][:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address]) end def add_invoice(post, money, options) diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb index 6cb11be8a46..5a43ce26613 100644 --- a/test/remote/gateways/remote_paymentez_test.rb +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -34,18 +34,6 @@ def test_successful_purchase_with_more_options assert_success response end - def test_successful_purchase_without_phone_option - options = { - order_id: '1', - ip: '127.0.0.1', - tax_percentage: 0.07 - } - - response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) - assert_success response - refute_includes(response.params, 'phone') - end - def test_successful_purchase_with_token store_response = @gateway.store(@credit_card, @options) assert_success store_response From a2941fb36c49defdd35c08411384646ba2239f41 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Wed, 7 Nov 2018 16:50:47 -0500 Subject: [PATCH 631/677] Revert "Paymentez: Adds support for user.phone field" This reverts commit 57eb7ddb92091cd75290328700e15566d0e53c87. --- CHANGELOG | 1 - lib/active_merchant/billing/gateways/paymentez.rb | 1 - test/remote/gateways/remote_paymentez_test.rb | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 67b40fb097b..d225259b878 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,7 +18,6 @@ * Braintree: Account for nil billing address fields [curiousepic] #3029 * Realex: Add verify [kheang] #3030 * Braintree: Actually account for nil address fields [curiousepic] #3032 -* Paymentez: Adds support for user.phone field [molbrown] #3033 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index 55a7a786c0c..af73e15b31c 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -134,7 +134,6 @@ def add_customer_data(post, options) post[:user][:email] = options[:email] post[:user][:ip_address] = options[:ip] if options[:ip] post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number] - post[:user][:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address]) end def add_invoice(post, money, options) diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb index 5a43ce26613..b6c2fca7173 100644 --- a/test/remote/gateways/remote_paymentez_test.rb +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -26,8 +26,7 @@ def test_successful_purchase_with_more_options options = { order_id: '1', ip: '127.0.0.1', - tax_percentage: 0.07, - phone: '333 333 3333' + tax_percentage: 0.07 } response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) From 89eb45ad69509c125f4d51b443382195dd6ef6e9 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 1 Nov 2018 11:57:50 -0400 Subject: [PATCH 632/677] Mercado Pago: do not infer card type This is a re-application of d9c5a1a0. Allow the card type to be passed in explicitly instead via the :payment_method_id option. Additionally, allow sending the :issuer_id. Unit: 19 tests, 93 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 17 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- .../billing/gateways/mercado_pago.rb | 10 +---- test/unit/gateways/mercado_pago_test.rb | 38 +++++++++---------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index 900f2ceb361..ef76ab493ad 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -10,11 +10,6 @@ class MercadoPagoGateway < Gateway self.display_name = 'Mercado Pago' self.money_format = :dollars - CARD_BRAND = { - 'american_express' => 'amex', - 'diners_club' => 'diners' - } - def initialize(options={}) requires!(options, :access_token) super @@ -23,7 +18,6 @@ def initialize(options={}) def purchase(money, payment, options={}) MultiResponse.run do |r| r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) } - options[:card_brand] = (CARD_BRAND[payment.brand] || payment.brand) options[:card_token] = r.authorization.split('|').first r.process { commit('purchase', 'payments', purchase_request(money, payment, options) ) } end @@ -32,7 +26,6 @@ def purchase(money, payment, options={}) def authorize(money, payment, options={}) MultiResponse.run do |r| r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) } - options[:card_brand] = (CARD_BRAND[payment.brand] || payment.brand) options[:card_token] = r.authorization.split('|').first r.process { commit('authorize', 'payments', authorize_request(money, payment, options) ) } end @@ -181,7 +174,8 @@ def add_invoice(post, money, options) def add_payment(post, options) post[:token] = options[:card_token] - post[:payment_method_id] = options[:card_brand] + post[:issuer_id] = options[:issuer_id] if options[:issuer_id] + post[:payment_method_id] = options[:payment_method_id] if options[:payment_method_id] end def parse(body) diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb index 72ad12215f5..9139432254c 100644 --- a/test/unit/gateways/mercado_pago_test.rb +++ b/test/unit/gateways/mercado_pago_test.rb @@ -149,14 +149,14 @@ def test_scrub assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed end - def test_sends_american_express_as_amex + def test_does_not_send_brand credit_card = credit_card('378282246310005', brand: 'american_express') response = stub_comms do @gateway.purchase(@amount, credit_card, @options) end.check_request do |endpoint, data, headers| if endpoint =~ /payments/ - assert_match(%r("payment_method_id":"amex"), data) + assert_not_match(%r("payment_method_id":"amex"), data) end end.respond_with(successful_purchase_response) @@ -164,11 +164,11 @@ def test_sends_american_express_as_amex assert_equal '4141491|1.0', response.authorization end - def test_sends_diners_club_as_diners - credit_card = credit_card('30569309025904', brand: 'diners_club') + def test_sends_payment_method_id + credit_card = credit_card('30569309025904') response = stub_comms do - @gateway.purchase(@amount, credit_card, @options) + @gateway.purchase(@amount, credit_card, @options.merge(payment_method_id: 'diners')) end.check_request do |endpoint, data, headers| if endpoint =~ /payments/ assert_match(%r("payment_method_id":"diners"), data) @@ -179,21 +179,6 @@ def test_sends_diners_club_as_diners assert_equal '4141491|1.0', response.authorization end - def test_sends_mastercard_as_master - credit_card = credit_card('5555555555554444', brand: 'master') - - response = stub_comms do - @gateway.purchase(@amount, credit_card, @options) - end.check_request do |endpoint, data, headers| - if endpoint =~ /payments/ - assert_match(%r("payment_method_id":"master"), data) - end - end.respond_with(successful_purchase_response) - - assert_success response - assert_equal '4141491|1.0', response.authorization - end - def test_includes_deviceid_header @options[:device_id] = '1a2b3c' @gateway.expects(:ssl_post).with(anything, anything, {'Content-Type' => 'application/json'}).returns(successful_purchase_response) @@ -217,6 +202,19 @@ def test_includes_additional_data assert_success response end + def test_includes_issuer_id + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(issuer_id: '1a2b3c4d')) + end.check_request do |endpoint, data, headers| + if endpoint =~ /payments/ + assert_match(%r("issuer_id":"1a2b3c4d"), data) + end + end.respond_with(successful_purchase_response) + + assert_success response + assert_equal '4141491|1.0', response.authorization + end + private def pre_scrubbed From 9ca795fbfbc1afd08aad71b8baaa192f6141e80f Mon Sep 17 00:00:00 2001 From: molbrown <molly@spreedly.com> Date: Wed, 7 Nov 2018 16:05:10 -0500 Subject: [PATCH 633/677] Paymentez: Does not send phone parameter unless it is defined Unit tests: 19 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote tests: 18 tests, 34 assertions, 6 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 66.6667% passed These failures due to `The method authorize is not supported by carrier`. Country credentials used for testing do not support authorize. Unrelated. Closes Paymentez: #3037 --- CHANGELOG | 1 + .../billing/gateways/paymentez.rb | 3 +++ test/remote/gateways/remote_paymentez_test.rb | 21 ++++++++++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d225259b878..5597fcaa206 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * Braintree: Account for nil billing address fields [curiousepic] #3029 * Realex: Add verify [kheang] #3030 * Braintree: Actually account for nil address fields [curiousepic] #3032 +* Paymentez: Does not send phone parameter unless it is defined [molbrown] #3037 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index af73e15b31c..de8aef722bf 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -134,6 +134,9 @@ def add_customer_data(post, options) post[:user][:email] = options[:email] post[:user][:ip_address] = options[:ip] if options[:ip] post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number] + if phone = options[:phone] || options[:billing_address][:phone] + post[:user][:phone] = phone + end end def add_invoice(post, money, options) diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb index b6c2fca7173..2498722a50c 100644 --- a/test/remote/gateways/remote_paymentez_test.rb +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -5,8 +5,8 @@ def setup @gateway = PaymentezGateway.new(fixtures(:paymentez)) @amount = 100 - @credit_card = credit_card('4111111111111111', verification_value: '555') - @declined_card = credit_card('4242424242424242', verification_value: '555') + @credit_card = credit_card('4111111111111111', verification_value: '666') + @declined_card = credit_card('4242424242424242', verification_value: '666') @options = { billing_address: address, description: 'Store Purchase', @@ -26,7 +26,22 @@ def test_successful_purchase_with_more_options options = { order_id: '1', ip: '127.0.0.1', - tax_percentage: 0.07 + tax_percentage: 0.07, + phone: '333 333 3333' + } + + response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) + assert_success response + end + + def test_successful_purchase_without_phone_option + options = { + order_id: '1', + ip: '127.0.0.1', + tax_percentage: 0.07, + billing_address: { + phone: nil + } } response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) From 1cab3d01310d91d9e4fd8309b877218b9912cc22 Mon Sep 17 00:00:00 2001 From: molbrown <molly@spreedly.com> Date: Thu, 8 Nov 2018 15:30:11 -0500 Subject: [PATCH 634/677] Revert "Paymentez: Does not send phone parameter unless it is defined" This reverts commit 9ca795fbfbc1afd08aad71b8baaa192f6141e80f. --- CHANGELOG | 1 - .../billing/gateways/paymentez.rb | 3 --- test/remote/gateways/remote_paymentez_test.rb | 21 +++---------------- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5597fcaa206..d225259b878 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,7 +18,6 @@ * Braintree: Account for nil billing address fields [curiousepic] #3029 * Realex: Add verify [kheang] #3030 * Braintree: Actually account for nil address fields [curiousepic] #3032 -* Paymentez: Does not send phone parameter unless it is defined [molbrown] #3037 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index de8aef722bf..af73e15b31c 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -134,9 +134,6 @@ def add_customer_data(post, options) post[:user][:email] = options[:email] post[:user][:ip_address] = options[:ip] if options[:ip] post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number] - if phone = options[:phone] || options[:billing_address][:phone] - post[:user][:phone] = phone - end end def add_invoice(post, money, options) diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb index 2498722a50c..b6c2fca7173 100644 --- a/test/remote/gateways/remote_paymentez_test.rb +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -5,8 +5,8 @@ def setup @gateway = PaymentezGateway.new(fixtures(:paymentez)) @amount = 100 - @credit_card = credit_card('4111111111111111', verification_value: '666') - @declined_card = credit_card('4242424242424242', verification_value: '666') + @credit_card = credit_card('4111111111111111', verification_value: '555') + @declined_card = credit_card('4242424242424242', verification_value: '555') @options = { billing_address: address, description: 'Store Purchase', @@ -26,22 +26,7 @@ def test_successful_purchase_with_more_options options = { order_id: '1', ip: '127.0.0.1', - tax_percentage: 0.07, - phone: '333 333 3333' - } - - response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) - assert_success response - end - - def test_successful_purchase_without_phone_option - options = { - order_id: '1', - ip: '127.0.0.1', - tax_percentage: 0.07, - billing_address: { - phone: nil - } + tax_percentage: 0.07 } response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) From df4be76590d81efefaf1da994ce92b20ec731d37 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 8 Nov 2018 15:33:28 -0500 Subject: [PATCH 635/677] Credorax: add submerchant_id support Unit: 20 tests, 92 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/credorax.rb | 10 ++++++++++ test/unit/gateways/credorax_test.rb | 9 +++++++++ 3 files changed, 20 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index d225259b878..0f3b7d98826 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ * Braintree: Account for nil billing address fields [curiousepic] #3029 * Realex: Add verify [kheang] #3030 * Braintree: Actually account for nil address fields [curiousepic] #3032 +* Credorax: allow sending submerchant ID (h3 parameter) [bpollack] #3040 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb index 9a60d276fbe..4689e66d7fe 100644 --- a/lib/active_merchant/billing/gateways/credorax.rb +++ b/lib/active_merchant/billing/gateways/credorax.rb @@ -129,6 +129,7 @@ def purchase(amount, payment_method, options={}) add_email(post, options) add_3d_secure(post, options) add_echo(post, options) + add_submerchant_id(post, options) add_transaction_type(post, options) commit(:purchase, post) @@ -142,6 +143,7 @@ def authorize(amount, payment_method, options={}) add_email(post, options) add_3d_secure(post, options) add_echo(post, options) + add_submerchant_id(post, options) add_transaction_type(post, options) commit(:authorize, post) @@ -153,6 +155,7 @@ def capture(amount, authorization, options={}) add_reference(post, authorization) add_customer_data(post, options) add_echo(post, options) + add_submerchant_id(post, options) commit(:capture, post) end @@ -162,6 +165,7 @@ def void(authorization, options={}) add_customer_data(post, options) reference_action = add_reference(post, authorization) add_echo(post, options) + add_submerchant_id(post, options) post[:a1] = generate_unique_id commit(:void, post, reference_action) @@ -173,6 +177,7 @@ def refund(amount, authorization, options={}) add_reference(post, authorization) add_customer_data(post, options) add_echo(post, options) + add_submerchant_id(post, options) commit(:refund, post) end @@ -184,6 +189,7 @@ def credit(amount, payment_method, options={}) add_customer_data(post, options) add_email(post, options) add_echo(post, options) + add_submerchant_id(post, options) add_transaction_type(post, options) commit(:credit, post) @@ -268,6 +274,10 @@ def add_echo(post, options) post[:d2] = options[:echo] unless options[:echo].blank? end + def add_submerchant_id(post, options) + post[:h3] = options[:submerchant_id] if options[:submerchant_id] + end + def add_transaction_type(post, options) post[:a9] = options[:transaction_type] if options[:transaction_type] end diff --git a/test/unit/gateways/credorax_test.rb b/test/unit/gateways/credorax_test.rb index 18eb1d1381d..c93b3987470 100644 --- a/test/unit/gateways/credorax_test.rb +++ b/test/unit/gateways/credorax_test.rb @@ -214,6 +214,15 @@ def test_adds_a9_field end.respond_with(successful_purchase_response) end + def test_adds_submerchant_id + @options[:submerchant_id] = '12345' + stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match(/h3=12345/, data) + end.respond_with(successful_purchase_response) + end + def test_supports_billing_descriptor @options[:billing_descriptor] = 'abcdefghijkl' stub_comms do From 3989f79ea94b0d5d3cc2a75a717756aee1945977 Mon Sep 17 00:00:00 2001 From: dtykocki <doug@spreedly.com> Date: Mon, 8 Oct 2018 12:46:59 -0400 Subject: [PATCH 636/677] Worldpay: Pass stored credential option fields In preparation for Visa card-on-file requirements. WorldPay's documentation on this subject can be found at: http://support.worldpay.com/support/kb/gg/corporate-gateway-guide/content/industryschemeextras/storedcredentials.htm Closes #3041 Remote: 27 tests, 109 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 39 tests, 222 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/worldpay.rb | 11 ++ test/remote/gateways/remote_worldpay_test.rb | 105 +++++++++++++----- test/unit/gateways/worldpay_test.rb | 15 +++ 4 files changed, 103 insertions(+), 29 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0f3b7d98826..8a56e45b2ae 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * Realex: Add verify [kheang] #3030 * Braintree: Actually account for nil address fields [curiousepic] #3032 * Credorax: allow sending submerchant ID (h3 parameter) [bpollack] #3040 +* Worldpay: Pass stored credential option fields [curiousepic] #3041 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index bb06b90c88f..b758032d61f 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -248,10 +248,21 @@ def add_payment_method(xml, amount, payment_method, options) xml.tag! 'session', 'shopperIPAddress' => options[:ip] if options[:ip] xml.tag! 'session', 'id' => options[:session_id] if options[:session_id] end + add_stored_credential_options(xml, options) if options[:stored_credential_usage] end end end + def add_stored_credential_options(xml, options={}) + if options[:stored_credential_initiated_reason] + xml.tag! 'storedCredentials', 'usage' => options[:stored_credential_usage], 'merchantInitiatedReason' => options[:stored_credential_initiated_reason] do + xml.tag! 'schemeTransactionIdentifier', options[:stored_credential_transaction_id] if options[:stored_credential_transaction_id] + end + else + xml.tag! 'storedCredentials', 'usage' => options[:stored_credential_usage] + end + end + def add_email(xml, options) return unless options[:execute_threed] || options[:email] xml.tag! 'shopper' do diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index c6f116a15c4..ff3c3b19ab9 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -11,7 +11,10 @@ def setup @declined_card = credit_card('4111111111111111', :first_name => nil, :last_name => 'REFUSED') @threeDS_card = credit_card('4111111111111111', :first_name => nil, :last_name => '3D') - @options = {order_id: generate_unique_id, email: 'wow@example.com'} + @options = { + order_id: generate_unique_id, + email: 'wow@example.com' + } end def test_successful_purchase @@ -44,8 +47,8 @@ def test_authorize_and_capture assert_success auth assert_equal 'SUCCESS', auth.message assert auth.authorization - sleep(40) - assert capture = @gateway.capture(@amount, auth.authorization) + + assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true) assert_success capture end @@ -53,15 +56,14 @@ def test_authorize_and_capture_by_reference assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth assert_equal 'SUCCESS', auth.message - sleep(40) - assert capture = @gateway.capture(@amount, auth.authorization) - assert_success capture + assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true) + assert_success capture assert reference = auth.authorization @options[:order_id] = generate_unique_id + assert auth = @gateway.authorize(@amount, reference, @options) - sleep(40) - assert capture = @gateway.capture(@amount, auth.authorization) + assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true) assert_success capture end @@ -69,15 +71,15 @@ def test_authorize_and_purchase_by_reference assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth assert_equal 'SUCCESS', auth.message - sleep(40) - assert capture = @gateway.capture(@amount, auth.authorization) - assert_success capture + assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true) + assert_success capture assert reference = auth.authorization + @options[:order_id] = generate_unique_id assert auth = @gateway.authorize(@amount, reference, @options) + @options[:order_id] = generate_unique_id - sleep(40) assert capture = @gateway.purchase(@amount, auth.authorization, @options) assert_success capture end @@ -87,8 +89,8 @@ def test_authorize_and_purchase_with_instalments assert_success auth assert_equal 'SUCCESS', auth.message assert auth.authorization - sleep(40) - assert capture = @gateway.capture(@amount, auth.authorization) + + assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true) assert_success capture end @@ -113,6 +115,52 @@ def test_successful_authorize_with_3ds refute first_message.params['session_id'].blank? end + def test_successful_auth_and_capture_with_stored_cred_options + assert auth = @gateway.authorize(@amount, @credit_card, @options.merge(stored_credential_usage: 'FIRST')) + assert_success auth + assert auth.authorization + assert auth.params['scheme_response'] + assert auth.params['transaction_identifier'] + + assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true) + assert_success capture + + options = @options.merge( + order_id: generate_unique_id, + stored_credential_usage: 'USED', + stored_credential_initiated_reason: 'UNSCHEDULED', + stored_credential_transaction_id: auth.params['transaction_identifier'] + ) + assert next_auth = @gateway.authorize(@amount, @credit_card, options) + assert next_auth.authorization + assert next_auth.params['scheme_response'] + assert next_auth.params['transaction_identifier'] + + assert capture = @gateway.capture(@amount, next_auth.authorization, authorization_validated: true) + assert_success capture + end + + # Fails currently because the sandbox doesn't actually validate the stored_credential options + # def test_failed_authorize_with_bad_stored_cred_options + # assert auth = @gateway.authorize(@amount, @credit_card, @options.merge(stored_credential_usage: 'FIRST')) + # assert_success auth + # assert auth.authorization + # assert auth.params['scheme_response'] + # assert auth.params['transaction_identifier'] + # + # assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true) + # assert_success capture + # + # options = @options.merge( + # order_id: generate_unique_id, + # stored_credential_usage: 'MEH', + # stored_credential_initiated_reason: 'BLAH', + # stored_credential_transaction_id: 'nah' + # ) + # assert next_auth = @gateway.authorize(@amount, @credit_card, options) + # assert_failure next_auth + # end + def test_failed_authorize_with_3ds session_id = generate_unique_id options = @options.merge( @@ -153,9 +201,8 @@ def test_ip_address end def test_void - assert_success(response = @gateway.authorize(@amount, @credit_card, @options)) - sleep(40) - assert_success(void = @gateway.void(response.authorization)) + assert_success response = @gateway.authorize(@amount, @credit_card, @options) + assert_success void = @gateway.void(response.authorization, authorization_validated: true) assert_equal 'SUCCESS', void.message assert void.params['cancel_received_order_code'] end @@ -243,22 +290,22 @@ def test_transcript_scrubbing # Worldpay has a delay between asking for a transaction to be captured and actually marking it as captured # These 2 tests work if you get authorizations from a purchase, wait some time and then perform the refund/void operation. - # def get_authorization - # assert_success(response = @gateway.purchase(@amount, @credit_card, @options)) - # assert response.authorization - # puts "auth: " + response.authorization - # end - - # def test_refund - # refund = @gateway.refund(@amount, 'replace_with_authorization') - # assert_success refund - # assert_equal "SUCCESS", refund.message - # end + def test_get_authorization + response = @gateway.purchase(@amount, @credit_card, @options) + assert response.authorization + puts 'auth: ' + response.authorization + end + def test_refund + refund = @gateway.refund(@amount, '39270fd70be13aab55f84e28be45cad3') + assert_success refund + assert_equal 'SUCCESS', refund.message + end + # # def test_void_fails_unless_status_is_authorised # response = @gateway.void('replace_with_authorization') # existing transaction in CAPTURED state # assert_failure response - # assert_equal "A transaction status of 'AUTHORISED' is required.", response.message + # assert_equal 'A transaction status of 'AUTHORISED' is required.', response.message # end end diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index e40767eda0a..a5e6cb611d2 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -53,6 +53,21 @@ def test_authorize_passes_ip_and_session_id assert_success response end + def test_authorize_passes_stored_credential_options + options = @options.merge( + stored_credential_usage: 'USED', + stored_credential_initiated_reason: 'UNSCHEDULED', + stored_credential_transaction_id: '000000000000020005060720116005060' + ) + response = stub_comms do + @gateway.authorize(@amount, @credit_card, options) + end.check_request do |endpoint, data, headers| + assert_match(/<storedCredentials usage\=\"USED\" merchantInitiatedReason\=\"UNSCHEDULED\"\>/, data) + assert_match(/<schemeTransactionIdentifier\>000000000000020005060720116005060\<\/schemeTransactionIdentifier\>/, data) + end.respond_with(successful_authorize_response) + assert_success response + end + def test_failed_authorize response = stub_comms do @gateway.authorize(@amount, @credit_card, @options) From f87ecc4b61eea6021dbc3b9751c2bbedb25afa17 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Fri, 9 Nov 2018 16:40:29 -0500 Subject: [PATCH 637/677] Worldpay: Re-comment remote test --- test/remote/gateways/remote_worldpay_test.rb | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index ff3c3b19ab9..64f7db2583b 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -289,18 +289,18 @@ def test_transcript_scrubbing # Worldpay has a delay between asking for a transaction to be captured and actually marking it as captured # These 2 tests work if you get authorizations from a purchase, wait some time and then perform the refund/void operation. - - def test_get_authorization - response = @gateway.purchase(@amount, @credit_card, @options) - assert response.authorization - puts 'auth: ' + response.authorization - end - - def test_refund - refund = @gateway.refund(@amount, '39270fd70be13aab55f84e28be45cad3') - assert_success refund - assert_equal 'SUCCESS', refund.message - end + # + # def test_get_authorization + # response = @gateway.purchase(@amount, @credit_card, @options) + # assert response.authorization + # puts 'auth: ' + response.authorization + # end + # + # def test_refund + # refund = @gateway.refund(@amount, '39270fd70be13aab55f84e28be45cad3') + # assert_success refund + # assert_equal 'SUCCESS', refund.message + # end # # def test_void_fails_unless_status_is_authorised # response = @gateway.void('replace_with_authorization') # existing transaction in CAPTURED state From 96b499e14c8fa2f31f9d1db65d019b3d01d887f5 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 12 Nov 2018 08:25:02 -0500 Subject: [PATCH 638/677] RuboCop: fix regression introduced in f87ecc4b61ee --- test/remote/gateways/remote_worldpay_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index 64f7db2583b..f21d674f2a6 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -289,7 +289,7 @@ def test_transcript_scrubbing # Worldpay has a delay between asking for a transaction to be captured and actually marking it as captured # These 2 tests work if you get authorizations from a purchase, wait some time and then perform the refund/void operation. - # + # # def test_get_authorization # response = @gateway.purchase(@amount, @credit_card, @options) # assert response.authorization From 7f16b1b3cb675ef8face489bd686c2e6de5a083b Mon Sep 17 00:00:00 2001 From: Lawrence Matacena <lmatacena@stopforschools.com> Date: Thu, 11 Oct 2018 04:55:58 -0400 Subject: [PATCH 639/677] Allow for CC number to be nil These are some slight tweaks to 2bc749340f89, largely about restoring the old, consistent behavior for CreditCardMethods#first_digits and CreditCardMethods#last_digits. Closes #3010 --- CHANGELOG | 2 ++ lib/active_merchant/billing/credit_card_methods.rb | 6 ++++-- test/unit/credit_card_methods_test.rb | 4 ++++ test/unit/credit_card_test.rb | 10 ++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8a56e45b2ae..8faf2ed2db4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ = ActiveMerchant CHANGELOG == HEAD +* Make behavior of nil CC numbers more consistent [guaguasi] #3010 + == Version 1.86.0 (October 26, 2018) * UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002 * Global Collect: handle internal server errors [molbrown] #3005 diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb index 67c80f5e5b1..05f07e46667 100644 --- a/lib/active_merchant/billing/credit_card_methods.rb +++ b/lib/active_merchant/billing/credit_card_methods.rb @@ -160,7 +160,7 @@ def brand?(number) end def electron?(number) - return false unless [16, 19].include?(number.length) + return false unless [16, 19].include?(number&.length) # don't recalculate for each range bank_identification_number = first_digits(number).to_i @@ -176,7 +176,7 @@ def type?(number) end def first_digits(number) - number.slice(0,6) + number&.slice(0, 6) || '' end def last_digits(number) @@ -201,10 +201,12 @@ def matching_type?(number, brand) private def valid_card_number_length?(number) #:nodoc: + return false if number.nil? number.length >= 12 end def valid_card_number_characters?(number) #:nodoc: + return false if number.nil? !number.match(/\D/) end diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb index 831359b9636..da6211e1a7f 100644 --- a/test/unit/credit_card_methods_test.rb +++ b/test/unit/credit_card_methods_test.rb @@ -167,6 +167,7 @@ def test_matching_discover_card def test_matching_invalid_card assert_nil CreditCard.brand?('XXXXXXXXXXXX0000') assert_false CreditCard.valid_number?('XXXXXXXXXXXX0000') + assert_false CreditCard.valid_number?(nil) end def test_16_digit_maestro_uk @@ -213,6 +214,9 @@ def test_electron_cards end end + # nil check + assert_false electron_test.call(nil) + # Visa range assert_false electron_test.call('4245180000000000') assert_false electron_test.call('4918810000000000') diff --git a/test/unit/credit_card_test.rb b/test/unit/credit_card_test.rb index 5c2f1eb6b50..40702473604 100644 --- a/test/unit/credit_card_test.rb +++ b/test/unit/credit_card_test.rb @@ -246,6 +246,16 @@ def test_bogus_last_digits assert_equal '1', ccn.last_digits end + def test_should_return_empty_string_for_first_digits_of_nil_card_number + ccn = CreditCard.new + assert_equal '', ccn.first_digits + end + + def test_should_return_empty_string_for_last_digits_of_nil_card_number + ccn = CreditCard.new + assert_equal '', ccn.last_digits + end + def test_should_return_first_four_digits_of_card_number ccn = CreditCard.new(:number => '4779139500118580') assert_equal '477913', ccn.first_digits From 83f89368f1f7c80dbf2e87b4d4a6aecfe307dbf3 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder <deedeelavinder@gmail.com> Date: Sat, 10 Nov 2018 23:24:24 -0500 Subject: [PATCH 640/677] Moneris: Adds Credential On File Logic This allows Credential On File information to be passed in the options hash. `cof_enabled` must be set to `true`. Values for the three CoF fields: `issuer_id`, `payment_indicator`, and `payment_information` must also be included. Unit Tests: 37 tests, 188 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote Tests: 29 tests, 114 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/moneris.rb | 115 ++++++++------ test/remote/gateways/remote_moneris_test.rb | 80 +++++++--- test/unit/gateways/moneris_test.rb | 149 +++++++++++++++++- 4 files changed, 279 insertions(+), 66 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8faf2ed2db4..04d7ba4ca8f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * Make behavior of nil CC numbers more consistent [guaguasi] #3010 +* Moneris: Adds Credential on File logic [deedeelavinder] #3042 == Version 1.86.0 (October 26, 2018) * UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002 diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb index 97c3d6cbc63..a92f567ec7a 100644 --- a/lib/active_merchant/billing/gateways/moneris.rb +++ b/lib/active_merchant/billing/gateways/moneris.rb @@ -33,7 +33,8 @@ def initialize(options = {}) requires!(options, :login, :password) @cvv_enabled = options[:cvv_enabled] @avs_enabled = options[:avs_enabled] - options = { :crypt_type => 7 }.merge(options) + @cof_enabled = options[:cof_enabled] + options[:crypt_type] = 7 unless options.has_key?(:crypt_type) super end @@ -46,17 +47,18 @@ def authorize(money, creditcard_or_datakey, options = {}) requires!(options, :order_id) post = {} add_payment_source(post, creditcard_or_datakey, options) - post[:amount] = amount(money) - post[:order_id] = options[:order_id] - post[:address] = options[:billing_address] || options[:address] + post[:amount] = amount(money) + post[:order_id] = options[:order_id] + post[:address] = options[:billing_address] || options[:address] post[:crypt_type] = options[:crypt_type] || @options[:crypt_type] + add_cof(post, options) if @cof_enabled action = if post[:cavv] 'cavv_preauth' elsif post[:data_key].blank? 'preauth' else 'res_preauth_cc' - end + end commit(action, post) end @@ -68,17 +70,18 @@ def purchase(money, creditcard_or_datakey, options = {}) requires!(options, :order_id) post = {} add_payment_source(post, creditcard_or_datakey, options) - post[:amount] = amount(money) - post[:order_id] = options[:order_id] - post[:address] = options[:billing_address] || options[:address] + post[:amount] = amount(money) + post[:order_id] = options[:order_id] + post[:address] = options[:billing_address] || options[:address] post[:crypt_type] = options[:crypt_type] || @options[:crypt_type] + add_cof(post, options) if @cof_enabled action = if post[:cavv] 'cavv_purchase' elsif post[:data_key].blank? 'purchase' else 'res_purchase_cc' - end + end commit(action, post) end @@ -182,16 +185,16 @@ def expdate(creditcard) def add_payment_source(post, payment_method, options) if payment_method.is_a?(String) - post[:data_key] = payment_method - post[:cust_id] = options[:customer] + post[:data_key] = payment_method + post[:cust_id] = options[:customer] else if payment_method.respond_to?(:track_data) && payment_method.track_data.present? - post[:pos_code] = '00' - post[:track2] = payment_method.track_data + post[:pos_code] = '00' + post[:track2] = payment_method.track_data else - post[:pan] = payment_method.number - post[:expdate] = expdate(payment_method) - post[:cvd_value] = payment_method.verification_value if payment_method.verification_value? + post[:pan] = payment_method.number + post[:expdate] = expdate(payment_method) + post[:cvd_value] = payment_method.verification_value if payment_method.verification_value? post[:cavv] = payment_method.payment_cryptogram if payment_method.is_a?(NetworkTokenizationCreditCard) post[:wallet_indicator] = wallet_indicator(payment_method.source.to_s) if payment_method.is_a?(NetworkTokenizationCreditCard) post[:crypt_type] = (payment_method.eci || 7) if payment_method.is_a?(NetworkTokenizationCreditCard) @@ -200,6 +203,12 @@ def add_payment_source(post, payment_method, options) end end + def add_cof(post, options) + post[:issuer_id] = options[:issuer_id] if options[:issuer_id] + post[:payment_indicator] = options[:payment_indicator] if options[:payment_indicator] + post[:payment_information] = options[:payment_information] if options[:payment_information] + end + # Common params used amongst the +credit+, +void+ and +capture+ methods def crediting_params(authorization, options = {}) { @@ -225,12 +234,14 @@ def commit(action, parameters = {}) raw = ssl_post(url, data) response = parse(raw) - Response.new(successful?(response), message_from(response[:message]), response, - :test => test?, - :avs_result => { :code => response[:avs_result_code] }, - :cvv_result => response[:cvd_result_code] && response[:cvd_result_code][-1,1], - :authorization => authorization_from(response) - ) + Response.new( + successful?(response), + message_from(response[:message]), + response, + :test => test?, + :avs_result => {:code => response[:avs_result_code]}, + :cvv_result => response[:cvd_result_code] && response[:cvd_result_code][-1, 1], + :authorization => authorization_from(response)) end # Generates a Moneris authorization string of the form 'trans_id;receipt_id'. @@ -262,9 +273,9 @@ def hashify_xml!(xml, response) end def post_data(action, parameters = {}) - xml = REXML::Document.new - root = xml.add_element('request') - root.add_element('store_id').text = options[:login] + xml = REXML::Document.new + root = xml.add_element('request') + root.add_element('store_id').text = options[:login] root.add_element('api_token').text = options[:password] root.add_element(transaction_element(action, parameters)) @@ -281,6 +292,8 @@ def transaction_element(action, parameters) transaction.add_element(avs_element(parameters[:address])) if @avs_enabled && parameters[:address] when :cvd_info transaction.add_element(cvd_element(parameters[:cvd_value])) if @cvv_enabled + when :cof_info + transaction.add_element(credential_on_file(parameters)) if @cof_enabled else transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank? end @@ -294,8 +307,8 @@ def avs_element(address) tokens = full_address.split(/\s+/) element = REXML::Element.new('avs_info') - element.add_element('avs_street_number').text = tokens.select{|x| x =~ /\d/}.join(' ') - element.add_element('avs_street_name').text = tokens.reject{|x| x =~ /\d/}.join(' ') + element.add_element('avs_street_number').text = tokens.select {|x| x =~ /\d/}.join(' ') + element.add_element('avs_street_name').text = tokens.reject {|x| x =~ /\d/}.join(' ') element.add_element('avs_zipcode').text = address[:zip] element end @@ -311,6 +324,18 @@ def cvd_element(cvd_value) element end + def credential_on_file(parameters) + issuer_id = parameters[:issuer_id] || '' + payment_indicator = parameters[:payment_indicator] if parameters[:payment_indicator] + payment_information = parameters[:payment_information] if parameters[:payment_information] + + cof_info = REXML::Element.new('cof_info') + cof_info.add_element('issuer_id').text = issuer_id + cof_info.add_element('payment_indicator').text = payment_indicator + cof_info.add_element('payment_information').text = payment_information + cof_info + end + def wallet_indicator(token_source) return 'APP' if token_source == 'apple_pay' return 'ANP' if token_source == 'android_pay' @@ -324,24 +349,24 @@ def message_from(message) def actions { - 'purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code], - 'preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code], - 'command' => [:order_id], - 'refund' => [:order_id, :amount, :txn_number, :crypt_type], - 'indrefund' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], - 'completion' => [:order_id, :comp_amount, :txn_number, :crypt_type], - 'purchasecorrection' => [:order_id, :txn_number, :crypt_type], - 'cavv_preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator], - 'cavv_purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator], - 'transact' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], - 'Batchcloseall' => [], - 'opentotals' => [:ecr_number], - 'batchclose' => [:ecr_number], - 'res_add_cc' => [:pan, :expdate, :crypt_type], - 'res_delete' => [:data_key], - 'res_update_cc' => [:data_key, :pan, :expdate, :crypt_type], - 'res_purchase_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type], - 'res_preauth_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type] + 'purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code, :cof_info], + 'preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code, :cof_info], + 'command' => [:order_id], + 'refund' => [:order_id, :amount, :txn_number, :crypt_type], + 'indrefund' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], + 'completion' => [:order_id, :comp_amount, :txn_number, :crypt_type], + 'purchasecorrection' => [:order_id, :txn_number, :crypt_type], + 'cavv_preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator], + 'cavv_purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator], + 'transact' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], + 'Batchcloseall' => [], + 'opentotals' => [:ecr_number], + 'batchclose' => [:ecr_number], + 'res_add_cc' => [:pan, :expdate, :crypt_type, :cof_info], + 'res_delete' => [:data_key], + 'res_update_cc' => [:data_key, :pan, :expdate, :crypt_type], + 'res_purchase_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type, :cof_info], + 'res_preauth_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type, :cof_info] } end end diff --git a/test/remote/gateways/remote_moneris_test.rb b/test/remote/gateways/remote_moneris_test.rb index 060ad177255..27da8f7271c 100644 --- a/test/remote/gateways/remote_moneris_test.rb +++ b/test/remote/gateways/remote_moneris_test.rb @@ -8,9 +8,9 @@ def setup @amount = 100 @credit_card = credit_card('4242424242424242') @options = { - :order_id => generate_unique_id, - :customer => generate_unique_id, - :billing_address => address + :order_id => generate_unique_id, + :customer => generate_unique_id, + :billing_address => address } end @@ -21,8 +21,48 @@ def test_successful_purchase assert_false response.authorization.blank? end + def test_successful_first_purchase_with_credential_on_file + gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true)) + assert response = gateway.purchase(@amount, @credit_card, @options.merge(issuer_id: '', payment_indicator: 'C', payment_information: '0')) + assert_success response + assert_equal 'Approved', response.message + assert_false response.authorization.blank? + assert_not_empty response.params['issuer_id'] + end + + def test_successful_subsequent_purchase_with_credential_on_file + gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true)) + assert response = gateway.authorize( + @amount, + @credit_card, + @options.merge( + issuer_id: '', + payment_indicator: 'C', + payment_information: '0' + ) + ) + assert_success response + assert_equal 'Approved', response.message + assert_false response.authorization.blank? + + assert response2 = gateway.purchase( + @amount, + @credit_card, + @options.merge( + order_id: response.authorization, + issuer_id: response.params['issuer_id'], + payment_indicator: 'U', + payment_information: '2' + ) + ) + assert_success response2 + assert_equal 'Approved', response2.message + assert_false response2.authorization.blank? + end + def test_successful_purchase_with_network_tokenization - @credit_card = network_tokenization_credit_card('4242424242424242', + @credit_card = network_tokenization_credit_card( + '4242424242424242', payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', verification_value: nil ) @@ -33,7 +73,8 @@ def test_successful_purchase_with_network_tokenization end def test_successful_purchase_with_network_tokenization_apple_pay_source - @credit_card = network_tokenization_credit_card('4242424242424242', + @credit_card = network_tokenization_credit_card( + '4242424242424242', payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', verification_value: nil, source: :apple_pay @@ -86,7 +127,8 @@ def test_successful_authorization_and_void end def test_successful_authorization_with_network_tokenization - @credit_card = network_tokenization_credit_card('4242424242424242', + @credit_card = network_tokenization_credit_card( + '4242424242424242', payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=', verification_value: nil ) @@ -202,23 +244,23 @@ def test_avs_result_valid_when_enabled assert response = gateway.purchase(1010, @credit_card, @options) assert_success response assert_equal(response.avs_result, { - 'code' => 'A', - 'message' => 'Street address matches, but 5-digit and 9-digit postal code do not match.', - 'street_match' => 'Y', - 'postal_match' => 'N' + 'code' => 'A', + 'message' => 'Street address matches, but 5-digit and 9-digit postal code do not match.', + 'street_match' => 'Y', + 'postal_match' => 'N' }) end def test_avs_result_nil_when_address_absent gateway = MonerisGateway.new(fixtures(:moneris).merge(avs_enabled: true)) - assert response = gateway.purchase(1010, @credit_card, @options.tap { |x| x.delete(:billing_address) }) + assert response = gateway.purchase(1010, @credit_card, @options.tap {|x| x.delete(:billing_address)}) assert_success response assert_equal(response.avs_result, { - 'code' => nil, - 'message' => nil, - 'street_match' => nil, - 'postal_match' => nil + 'code' => nil, + 'message' => nil, + 'street_match' => nil, + 'postal_match' => nil }) end @@ -226,10 +268,10 @@ def test_avs_result_nil_when_efraud_disabled assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal(response.avs_result, { - 'code' => nil, - 'message' => nil, - 'street_match' => nil, - 'postal_match' => nil + 'code' => nil, + 'message' => nil, + 'street_match' => nil, + 'postal_match' => nil }) end diff --git a/test/unit/gateways/moneris_test.rb b/test/unit/gateways/moneris_test.rb index 084bc5c84ca..a4144b398d5 100644 --- a/test/unit/gateways/moneris_test.rb +++ b/test/unit/gateways/moneris_test.rb @@ -7,7 +7,7 @@ def setup Base.mode = :test @gateway = MonerisGateway.new( - :login => 'store1', + :login => 'store3', :password => 'yesguy' ) @@ -18,7 +18,7 @@ def setup def test_default_options assert_equal 7, @gateway.options[:crypt_type] - assert_equal 'store1', @gateway.options[:login] + assert_equal 'store3', @gateway.options[:login] assert_equal 'yesguy', @gateway.options[:password] end @@ -30,6 +30,65 @@ def test_successful_purchase assert_equal '58-0_3;1026.1', response.authorization end + def test_successful_first_purchase_with_credential_on_file + gateway = MonerisGateway.new( + :login => 'store3', + :password => 'yesguy', + :cof_enabled => true + ) + gateway.expects(:ssl_post).returns(successful_first_cof_purchase_response) + assert response = gateway.purchase( + @amount, + @credit_card, + @options.merge( + issuer_id: '', + payment_indicator: 'C', + payment_information: '0' + ) + ) + assert_success response + assert_equal 'Approved', response.message + assert_false response.authorization.blank? + assert_not_empty response.params['issuer_id'] + end + + def test_successful_subsequent_purchase_with_credential_on_file + gateway = MonerisGateway.new( + :login => 'store3', + :password => 'yesguy', + :cof_enabled => true + ) + gateway.expects(:ssl_post).returns(successful_first_cof_authorize_response) + assert response = gateway.authorize( + @amount, + @credit_card, + @options.merge( + issuer_id: '', + payment_indicator: 'C', + payment_information: '0' + ) + ) + assert_success response + assert_equal 'Approved', response.message + assert_false response.authorization.blank? + + gateway.expects(:ssl_post).returns(successful_subsequent_cof_purchase_response) + + assert response2 = gateway.purchase( + @amount, + @credit_card, + @options.merge( + order_id: response.authorization, + issuer_id: response.params['issuer_id'], + payment_indicator: 'U', + payment_information: '2' + ) + ) + assert_success response2 + assert_equal 'Approved', response2.message + assert_false response2.authorization.blank? + end + def test_successful_purchase_with_network_tokenization @gateway.expects(:ssl_post).returns(successful_purchase_network_tokenization) @credit_card = network_tokenization_credit_card('4242424242424242', @@ -360,6 +419,92 @@ def successful_purchase_response RESPONSE end + def successful_first_cof_purchase_response + <<-RESPONSE +<?xml version=\"1.0\" standalone=\"yes\"?> +<?xml version=“1.0” standalone=“yes”?> +<response> + <receipt> + <ReceiptId>a33ba7edd448b91ef8d2f85fea614b8d</ReceiptId> + <ReferenceNum>660114080015099160</ReferenceNum> + <ResponseCode>027</ResponseCode> + <ISO>01</ISO> + <AuthCode>822665</AuthCode> + <TransTime>07:43:28</TransTime> + <TransDate>2018-11-11</TransDate> + <TransType>00</TransType> + <Complete>true</Complete> + <Message>APPROVED * =</Message> + <TransAmount>1.00</TransAmount> + <CardType>V</CardType> + <TransID>799655-0_11</TransID> + <TimedOut>false</TimedOut> + <BankTotals>null</BankTotals> + <Ticket>null</Ticket> + <IssuerId>355689484440192</IssuerId> + <IsVisaDebit>false</IsVisaDebit> + </receipt> +</response> + RESPONSE + end + + def successful_first_cof_authorize_response + <<-RESPONSE +<?xml version=\"1.0\" standalone=\"yes\"?> +<response> + <receipt> + <ReceiptId>8dbc28468af2007779bbede7ec1bab6c</ReceiptId> + <ReferenceNum>660109300018229130</ReferenceNum> + <ResponseCode>027</ResponseCode> + <ISO>01</ISO> + <AuthCode>718280</AuthCode> + <TransTime>07:50:53</TransTime> + <TransDate>2018-11-11</TransDate> + <TransType>01</TransType> + <Complete>true</Complete> + <Message>APPROVED * =</Message> + <TransAmount>1.00</TransAmount> + <CardType>V</CardType> + <TransID>830724-0_11</TransID> + <TimedOut>false</TimedOut> + <BankTotals>null</BankTotals> + <Ticket>null</Ticket> + <MessageId>1A8315282537312</MessageId> + <IssuerId>550923784451193</IssuerId> + <IsVisaDebit>false</IsVisaDebit> + </receipt> +</response> + RESPONSE + end + + def successful_subsequent_cof_purchase_response + <<-RESPONSE +<?xml version="1.0" standalone="yes"?> +<response> + <receipt> + <ReceiptId>830724-0_11;8dbc28468af2007779bbede7ec1bab6c</ReceiptId> + <ReferenceNum>660109490014038930</ReferenceNum> + <ResponseCode>027</ResponseCode> + <ISO>01</ISO> + <AuthCode>111234</AuthCode> + <TransTime>07:50:54</TransTime> + <TransDate>2018-11-11</TransDate> + <TransType>00</TransType> + <Complete>true</Complete> + <Message>APPROVED * =</Message> + <TransAmount>1.00</TransAmount> + <CardType>V</CardType> + <TransID>455422-0_11</TransID> + <TimedOut>false</TimedOut> + <BankTotals>null</BankTotals> + <Ticket>null</Ticket> + <IssuerId>762097792112819</IssuerId> + <IsVisaDebit>false</IsVisaDebit> + </receipt> +</response> + RESPONSE + end + def successful_purchase_network_tokenization <<-RESPONSE <?xml version="1.0"?> From 2059d31765d9f237b05d21b51a45d41e00696eeb Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Mon, 12 Nov 2018 14:06:16 -0500 Subject: [PATCH 641/677] Adyen: Return AVS and CVC Result Returns the result of avs and cvc in the response if it is provided. Loaded suite test/unit/gateways/adyen_test ........................ 24 tests, 115 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ---------------------------------------------------------------------------------------- Loaded suite test/remote/gateways/remote_adyen_test .................................... 36 tests, 90 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/adyen.rb | 45 ++++++++++++++++++- test/remote/gateways/remote_adyen_test.rb | 12 ++--- test/unit/gateways/adyen_test.rb | 7 +++ 4 files changed, 57 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 04d7ba4ca8f..10dd14af650 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * Make behavior of nil CC numbers more consistent [guaguasi] #3010 * Moneris: Adds Credential on File logic [deedeelavinder] #3042 +* Adyen: Return AVS and CVC Result [nfarve] #3044 == Version 1.86.0 (October 26, 2018) * UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002 diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index a73e0b92860..7aef6d0fbc1 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -103,6 +103,38 @@ def scrub(transcript) private + AVS_MAPPING = { + '0' => 'R', # Unknown + '1' => 'A', # Address matches, postal code doesn't + '2' => 'N', # Neither postal code nor address match + '3' => 'R', # AVS unavailable + '4' => 'E', # AVS not supported for this card type + '5' => 'U', # No AVS data provided + '6' => 'Z', # Postal code matches, address doesn't match + '7' => 'D', # Both postal code and address match + '8' => 'U', # Address not checked, postal code unknown + '9' => 'B', # Address matches, postal code unknown + '10' => 'N', # Address doesn't match, postal code unknown + '11' => 'U', # Postal code not checked, address unknown + '12' => 'B', # Address matches, postal code not checked + '13' => 'U', # Address doesn't match, postal code not checked + '14' => 'P', # Postal code matches, address unknown + '15' => 'P', # Postal code matches, address not checked + '16' => 'N', # Postal code doesn't match, address unknown + '17' => 'U', # Postal code doesn't match, address not checked + '18' => 'I' # Neither postal code nor address were checked + } + + CVC_MAPPING = { + '0' => 'P', # Unknown + '1' => 'M', # Matches + '2' => 'N', # Does not match + '3' => 'P', # Not checked + '4' => 'S', # No CVC/CVV provided, but was required + '5' => 'U', # Issuer not certifed by CVC/CVV + '6' => 'P' # No CVC/CVV provided + } + NETWORK_TOKENIZATION_CARD_SOURCE = { 'apple_pay' => 'applepay', 'android_pay' => 'androidpay', @@ -239,7 +271,6 @@ def commit(action, parameters) raw_response = e.response.body response = parse(raw_response) end - success = success_from(action, response) Response.new( success, @@ -247,10 +278,20 @@ def commit(action, parameters) response, authorization: authorization_from(action, parameters, response), test: test?, - error_code: success ? nil : error_code_from(response) + error_code: success ? nil : error_code_from(response), + avs_result: AVSResult.new(:code => avs_code_from(response)), + cvv_result: CVVResult.new(cvv_result_from(response)) ) end + def avs_code_from(response) + AVS_MAPPING[response['additionalData']['avsResult'][0..1].strip] if response.dig('additionalData', 'avsResult') + end + + def cvv_result_from(response) + CVC_MAPPING[response['additionalData']['cvcResult'][0]] if response.dig('additionalData', 'cvcResult') + end + def url if test? test_url diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb index 0ba48c81be2..d9f2bfead67 100644 --- a/test/remote/gateways/remote_adyen_test.rb +++ b/test/remote/gateways/remote_adyen_test.rb @@ -7,8 +7,8 @@ def setup @amount = 100 @credit_card = credit_card('4111111111111111', - :month => 8, - :year => 2018, + :month => 10, + :year => 2020, :first_name => 'John', :last_name => 'Smith', :verification_value => '737', @@ -63,7 +63,7 @@ def test_successful_authorize def test_failed_authorize response = @gateway.authorize(@amount, @declined_card, @options) assert_failure response - assert_equal 'CVC Declined', response.message + assert_equal 'Refused', response.message end def test_successful_purchase @@ -108,7 +108,7 @@ def test_successful_purchase_with_google_pay def test_failed_purchase response = @gateway.purchase(@amount, @declined_card, @options) assert_failure response - assert_equal 'CVC Declined', response.message + assert_equal 'Refused', response.message end def test_successful_authorize_and_capture @@ -184,7 +184,7 @@ def test_failed_store assert response = @gateway.store(@declined_card, @options) assert_failure response - assert_equal 'CVC Declined', response.message + assert_equal 'Refused', response.message end def test_successful_purchase_using_stored_card @@ -214,7 +214,7 @@ def test_successful_verify def test_failed_verify response = @gateway.verify(@declined_card, @options) assert_failure response - assert_match 'CVC Declined', response.message + assert_match 'Refused', response.message end def test_invalid_login diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb index 053b160516a..abfdee32e92 100644 --- a/test/unit/gateways/adyen_test.rb +++ b/test/unit/gateways/adyen_test.rb @@ -64,6 +64,8 @@ def test_successful_authorize assert_success response assert_equal '#7914775043909934#', response.authorization + assert_equal 'R', response.avs_result['code'] + assert_equal 'M', response.cvv_result['code'] assert response.test? end @@ -418,6 +420,11 @@ def failed_purchase_response def successful_authorize_response <<-RESPONSE { + "additionalData": { + "cvcResult": "1 Matches", + "avsResult": "0 Unknown", + "cvcResultRaw": "M" + }, "pspReference":"7914775043909934", "resultCode":"Authorised", "authCode":"50055" From f2e0acff44609b60f0cda49537aa583410bcc561 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder <deedeelavinder@gmail.com> Date: Tue, 13 Nov 2018 11:14:43 -0500 Subject: [PATCH 642/677] Moneris: fix remote test creds Remote: 29 tests, 114 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- test/fixtures.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixtures.yml b/test/fixtures.yml index d5dc2626ca6..f1de6db6807 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -520,7 +520,7 @@ monei: # Working credentials, no need to replace moneris: - login: store1 + login: store3 password: yesguy moneris_us: From 03055385c5875334dce29a43969ec60b09ae1a5a Mon Sep 17 00:00:00 2001 From: molbrown <molly@spreedly.com> Date: Mon, 12 Nov 2018 10:36:05 -0500 Subject: [PATCH 643/677] Paymentez: Supports phone field, does not send if empty Unit: 19 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 19 tests, 35 assertions, 6 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 68.4211% passed These failures due to `The method authorize is not supported by carrier`. Country credentials used for testing do not support authorize. Unrelated. Closes #3043 --- CHANGELOG | 1 + .../billing/gateways/paymentez.rb | 3 ++ test/remote/gateways/remote_paymentez_test.rb | 30 +++++++++++++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 10dd14af650..80d1de5d7db 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,7 @@ * Braintree: Actually account for nil address fields [curiousepic] #3032 * Credorax: allow sending submerchant ID (h3 parameter) [bpollack] #3040 * Worldpay: Pass stored credential option fields [curiousepic] #3041 +* Paymentez: Supports phone field, does not send if empty [molbrown] #3043 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb index af73e15b31c..cbdaa48d867 100644 --- a/lib/active_merchant/billing/gateways/paymentez.rb +++ b/lib/active_merchant/billing/gateways/paymentez.rb @@ -134,6 +134,9 @@ def add_customer_data(post, options) post[:user][:email] = options[:email] post[:user][:ip_address] = options[:ip] if options[:ip] post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number] + if phone = options[:phone] || options.dig(:billing_address, :phone) + post[:user][:phone] = phone + end end def add_invoice(post, money, options) diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb index b6c2fca7173..a09a19f1581 100644 --- a/test/remote/gateways/remote_paymentez_test.rb +++ b/test/remote/gateways/remote_paymentez_test.rb @@ -5,8 +5,8 @@ def setup @gateway = PaymentezGateway.new(fixtures(:paymentez)) @amount = 100 - @credit_card = credit_card('4111111111111111', verification_value: '555') - @declined_card = credit_card('4242424242424242', verification_value: '555') + @credit_card = credit_card('4111111111111111', verification_value: '666') + @declined_card = credit_card('4242424242424242', verification_value: '666') @options = { billing_address: address, description: 'Store Purchase', @@ -23,6 +23,32 @@ def test_successful_purchase end def test_successful_purchase_with_more_options + options = { + order_id: '1', + ip: '127.0.0.1', + tax_percentage: 0.07, + phone: '333 333 3333' + } + + response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) + assert_success response + end + + def test_successful_purchase_without_phone_billing_address_option + options = { + order_id: '1', + ip: '127.0.0.1', + tax_percentage: 0.07, + billing_address: { + phone: nil + } + } + + response = @gateway.purchase(@amount, @credit_card, @options.merge(options)) + assert_success response + end + + def test_successful_purchase_without_phone_option options = { order_id: '1', ip: '127.0.0.1', From 5dad76ca2fd20d1498b8e7c1c2ccd74380dac391 Mon Sep 17 00:00:00 2001 From: David Perry <dperry@spreedly.com> Date: Tue, 13 Nov 2018 16:16:16 -0500 Subject: [PATCH 644/677] Braintree: Account for nil address with existing customer The prior fix only worked for naive first-time stores. Now it's also used when adding a card to an existing customer profile. Closes #3407 Remote: 66 tests, 378 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Unit: 57 tests, 150 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/braintree_blue.rb | 5 +- .../gateways/remote_braintree_blue_test.rb | 50 +++++++++++++++++++ test/unit/gateways/braintree_blue_test.rb | 36 +++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 80d1de5d7db..c1a9e5d5161 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * Make behavior of nil CC numbers more consistent [guaguasi] #3010 * Moneris: Adds Credential on File logic [deedeelavinder] #3042 * Adyen: Return AVS and CVC Result [nfarve] #3044 +* Braintree: Account for nil address with existing customer [curiousepic] #3047 == Version 1.86.0 (October 26, 2018) * UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002 diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 0669b444b8b..f660e41f64a 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -259,7 +259,10 @@ def add_credit_card_to_customer(credit_card, options) expiration_year: credit_card.year.to_s, device_data: options[:device_data], } - parameters[:billing_address] = map_address(options[:billing_address]) if options[:billing_address] + if options[:billing_address] + address = map_address(options[:billing_address]) + parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| v.nil? } + end result = @braintree_gateway.credit_card.create(parameters) ActiveMerchant::Billing::Response.new( diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index 7ae338e81ca..db3c1fbd6db 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -38,6 +38,27 @@ def test_successful_authorize assert_equal 'authorized', response.params['braintree_transaction']['status'] end + def test_successful_authorize_with_nil_billing_address_options + credit_card = credit_card('5105105105105100') + options = { + :billing_address => { + :name => 'John Smith', + :phone => '123-456-7890', + :company => nil, + :address1 => nil, + :address2 => nil, + :city => nil, + :state => nil, + :zip => nil, + :country_name => nil + } + } + assert response = @gateway.authorize(@amount, credit_card, options) + assert_success response + assert_equal '1000 Approved', response.message + assert_equal 'authorized', response.params['braintree_transaction']['status'] + end + def test_masked_card_number assert response = @gateway.authorize(@amount, @credit_card, @options) assert_equal('510510******5100', response.params['braintree_transaction']['credit_card_details']['masked_number']) @@ -224,6 +245,35 @@ def test_successful_store_with_existing_customer_id assert_not_nil response.params['credit_card_token'] end + def test_successful_store_with_existing_customer_id_and_nil_billing_address_options + credit_card = credit_card('5105105105105100') + customer_id = generate_unique_id + options = { + :customer => customer_id, + :billing_address => { + :name => 'John Smith', + :phone => '123-456-7890', + :company => nil, + :address1 => nil, + :address2 => nil, + :city => nil, + :state => nil, + :zip => nil, + :country_name => nil + } + } + assert response = @gateway.store(credit_card, options) + assert_success response + assert_equal 1, @braintree_backend.customer.find(customer_id).credit_cards.size + + assert response = @gateway.store(credit_card, options) + assert_success response + assert_equal 2, @braintree_backend.customer.find(customer_id).credit_cards.size + assert_equal customer_id, response.params['customer_vault_id'] + assert_equal customer_id, response.authorization + assert_not_nil response.params['credit_card_token'] + end + def test_successful_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index 21f7e152be5..b13264ae47f 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -473,6 +473,42 @@ def test_store_with_existing_customer_id assert_equal 'cctoken', response.params['credit_card_token'] end + def test_store_with_existing_customer_id_and_nil_billing_address_options + credit_card = stub( + customer_id: 'customerid', + token: 'cctoken' + ) + options = { + :customer => 'customerid', + :billing_address => { + :name => 'John Smith', + :phone => '123-456-7890', + :company => nil, + :address1 => nil, + :address2 => nil, + :city => nil, + :state => nil, + :zip => nil, + :country_name => nil + } + } + + result = Braintree::SuccessfulResult.new(credit_card: credit_card) + Braintree::CustomerGateway.any_instance.expects(:find).with('customerid') + Braintree::CreditCardGateway.any_instance.expects(:create).with do |params| + assert_equal 'customerid', params[:customer_id] + assert_equal '41111111111111111111', params[:number] + assert_equal 'Longbob Longsen', params[:cardholder_name] + params + end.returns(result) + + response = @gateway.store(credit_card('41111111111111111111'), options) + assert_success response + assert_nil response.params['braintree_customer'] + assert_equal 'customerid', response.params['customer_vault_id'] + assert_equal 'cctoken', response.params['credit_card_token'] + end + def test_update_with_cvv stored_credit_card = mock(:token => 'token', :default? => true) customer = mock(:credit_cards => [stored_credit_card], :id => '123') From a75538dc1dd5986481a73e34efcd3a8e73c37961 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 8 Nov 2018 14:55:25 -0500 Subject: [PATCH 645/677] RuboCop: fix Layout/SpaceAfterComma --- .rubocop_todo.yml | 5 ----- lib/active_merchant/billing/credit_card.rb | 2 +- lib/active_merchant/billing/gateways/adyen.rb | 4 ++-- .../billing/gateways/authorize_net.rb | 2 +- .../billing/gateways/authorize_net_cim.rb | 8 ++++---- .../billing/gateways/bank_frick.rb | 2 +- .../billing/gateways/beanstream.rb | 2 +- .../gateways/beanstream/beanstream_core.rb | 2 +- .../billing/gateways/blue_pay.rb | 6 +++--- lib/active_merchant/billing/gateways/bogus.rb | 2 +- .../billing/gateways/borgun.rb | 4 ++-- .../billing/gateways/bridge_pay.rb | 2 +- lib/active_merchant/billing/gateways/cams.rb | 6 +++--- .../billing/gateways/cardknox.rb | 2 +- .../billing/gateways/cashnet.rb | 2 +- lib/active_merchant/billing/gateways/cc5.rb | 2 +- .../billing/gateways/commercegate.rb | 2 +- .../billing/gateways/credorax.rb | 2 +- .../billing/gateways/ct_payment.rb | 8 ++++---- .../billing/gateways/cyber_source.rb | 6 +++--- .../billing/gateways/data_cash.rb | 2 +- lib/active_merchant/billing/gateways/dibs.rb | 2 +- .../billing/gateways/efsnet.rb | 8 ++++---- .../billing/gateways/elavon.rb | 2 +- lib/active_merchant/billing/gateways/epay.rb | 2 +- lib/active_merchant/billing/gateways/eway.rb | 2 +- lib/active_merchant/billing/gateways/exact.rb | 2 +- .../billing/gateways/first_giving.rb | 2 +- .../billing/gateways/firstdata_e4.rb | 2 +- .../billing/gateways/flo2cash.rb | 2 +- .../billing/gateways/garanti.rb | 6 +++--- .../billing/gateways/global_collect.rb | 2 +- lib/active_merchant/billing/gateways/hdfc.rb | 2 +- lib/active_merchant/billing/gateways/hps.rb | 4 ++-- .../billing/gateways/inspire.rb | 14 ++++++------- .../billing/gateways/iridium.rb | 12 +++++------ .../billing/gateways/itransact.rb | 4 ++-- lib/active_merchant/billing/gateways/iveri.rb | 4 ++-- .../billing/gateways/jetpay.rb | 2 +- .../billing/gateways/jetpay_v2.rb | 2 +- .../billing/gateways/linkpoint.rb | 4 ++-- .../billing/gateways/merchant_e_solutions.rb | 6 +++--- .../billing/gateways/merchant_one.rb | 4 ++-- .../billing/gateways/merchant_warrior.rb | 2 +- .../billing/gateways/mercury.rb | 4 ++-- .../billing/gateways/moneris_us.rb | 2 +- .../billing/gateways/mundipagg.rb | 2 +- .../billing/gateways/net_registry.rb | 2 +- .../billing/gateways/netaxept.rb | 2 +- .../billing/gateways/netbilling.rb | 4 ++-- lib/active_merchant/billing/gateways/nmi.rb | 2 +- lib/active_merchant/billing/gateways/ogone.rb | 4 ++-- lib/active_merchant/billing/gateways/omise.rb | 2 +- .../billing/gateways/orbital.rb | 2 +- .../billing/gateways/pay_junction.rb | 2 +- .../billing/gateways/pay_junction_v2.rb | 2 +- .../billing/gateways/pay_secure.rb | 4 ++-- .../billing/gateways/paybox_direct.rb | 16 +++++++-------- .../billing/gateways/payflow.rb | 2 +- .../billing/gateways/payflow_express.rb | 2 +- .../billing/gateways/payment_express.rb | 6 +++--- .../billing/gateways/payway.rb | 2 +- .../billing/gateways/plugnpay.rb | 2 +- .../billing/gateways/pro_pay.rb | 4 ++-- .../billing/gateways/psigate.rb | 2 +- .../billing/gateways/quantum.rb | 8 ++++---- .../billing/gateways/quickbooks.rb | 2 +- .../billing/gateways/qvalent.rb | 2 +- .../billing/gateways/realex.rb | 2 +- .../billing/gateways/safe_charge.rb | 4 ++-- lib/active_merchant/billing/gateways/sage.rb | 12 +++++------ .../billing/gateways/skip_jack.rb | 2 +- .../billing/gateways/smart_ps.rb | 14 ++++++------- .../billing/gateways/so_easy_pay.rb | 2 +- .../trans_first_transaction_express.rb | 2 +- .../billing/gateways/transact_pro.rb | 4 ++-- .../billing/gateways/transax.rb | 2 +- .../billing/gateways/trust_commerce.rb | 2 +- .../billing/gateways/usa_epay_advanced.rb | 20 +++++++++---------- .../billing/gateways/viaklix.rb | 4 ++-- .../billing/gateways/visanet_peru.rb | 2 +- .../billing/gateways/wirecard.rb | 2 +- .../billing/gateways/worldpay.rb | 4 ++-- lib/active_merchant/country.rb | 2 +- lib/support/ssl_verify.rb | 2 +- .../remote/gateways/remote_beanstream_test.rb | 2 +- .../remote_ct_payment_certification_test.rb | 8 ++++---- .../remote/gateways/remote_ct_payment_test.rb | 12 +++++------ .../remote_litle_certification_test.rb | 8 ++++---- .../remote_merchant_ware_version_four_test.rb | 4 ++-- test/remote/gateways/remote_orbital_test.rb | 4 ++-- .../remote/gateways/remote_payflow_uk_test.rb | 2 +- .../remote_usa_epay_transaction_test.rb | 2 +- test/test_helper.rb | 2 +- test/unit/gateways/braintree_blue_test.rb | 6 +++--- test/unit/gateways/braintree_orange_test.rb | 2 +- test/unit/gateways/card_connect_test.rb | 2 +- test/unit/gateways/epay_test.rb | 2 +- test/unit/gateways/eway_rapid_test.rb | 2 +- test/unit/gateways/hps_test.rb | 12 +++++------ test/unit/gateways/nab_transact_test.rb | 12 +++++------ test/unit/gateways/opp_test.rb | 14 ++++++------- test/unit/gateways/optimal_payment_test.rb | 4 ++-- .../gateways/paypal/paypal_common_api_test.rb | 4 ++-- test/unit/gateways/qvalent_test.rb | 2 +- test/unit/gateways/redsys_test.rb | 2 +- test/unit/gateways/secure_pay_au_test.rb | 12 +++++------ test/unit/gateways/securion_pay_test.rb | 4 ++-- test/unit/gateways/stripe_test.rb | 10 +++++----- 109 files changed, 229 insertions(+), 234 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3c88f5cb74d..ade1c7ede93 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -116,11 +116,6 @@ Layout/MultilineOperationIndentation: - 'test/unit/gateways/ogone_test.rb' - 'test/unit/gateways/skip_jack_test.rb' -# Offense count: 315 -# Cop supports --auto-correct. -Layout/SpaceAfterComma: - Enabled: false - # Offense count: 638 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb index 19dcbec394a..d48f1d2b769 100644 --- a/lib/active_merchant/billing/credit_card.rb +++ b/lib/active_merchant/billing/credit_card.rb @@ -388,7 +388,7 @@ def expiration #:nodoc: private def month_days - mdays = [nil,31,28,31,30,31,30,31,31,30,31,30,31] + mdays = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] mdays[2] = 29 if Date.leap?(year) mdays[month] end diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index 7aef6d0fbc1..de0f15f32ee 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -7,7 +7,7 @@ class AdyenGateway < Gateway self.test_url = 'https://pal-test.adyen.com/pal/servlet/Payment/v18' self.live_url = 'https://pal-live.adyen.com/pal/servlet/Payment/v18' - self.supported_countries = ['AT','AU','BE','BG','BR','CH','CY','CZ','DE','DK','EE','ES','FI','FR','GB','GI','GR','HK','HU','IE','IS','IT','LI','LT','LU','LV','MC','MT','MX','NL','NO','PL','PT','RO','SE','SG','SK','SI','US'] + self.supported_countries = ['AT', 'AU', 'BE', 'BG', 'BR', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GI', 'GR', 'HK', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SG', 'SK', 'SI', 'US'] self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb, :dankort, :maestro, :discover] @@ -216,7 +216,7 @@ def add_card(post, credit_card) cvc: credit_card.verification_value } - card.delete_if{|k,v| v.blank? } + card.delete_if{|k, v| v.blank? } card[:holderName] ||= 'Not Provided' if credit_card.is_a?(NetworkTokenizationCreditCard) requires!(card, :expiryMonth, :expiryYear, :holderName, :number) post[:card] = card diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index 31640f0ca11..db5d98b69aa 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -394,7 +394,7 @@ def add_payment_source(xml, source, options, action = nil) end def camel_case_lower(key) - String(key).split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join + String(key).split('_').inject([]){ |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }.join end def add_settings(xml, source, options) diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb index 5f9d67c1a01..3a5cce3d5e5 100644 --- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb +++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb @@ -666,9 +666,9 @@ def add_transaction(xml, transaction) # The amount to be billed to the customer case transaction[:type] when :void - tag_unless_blank(xml,'customerProfileId', transaction[:customer_profile_id]) - tag_unless_blank(xml,'customerPaymentProfileId', transaction[:customer_payment_profile_id]) - tag_unless_blank(xml,'customerShippingAddressId', transaction[:customer_shipping_address_id]) + tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id]) + tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id]) + tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id]) xml.tag!('transId', transaction[:trans_id]) when :refund xml.tag!('amount', transaction[:amount]) @@ -698,7 +698,7 @@ def add_transaction(xml, transaction) if [:auth_capture, :auth_only, :capture_only].include?(transaction[:type]) xml.tag!('recurringBilling', transaction[:recurring_billing]) if transaction.has_key?(:recurring_billing) end - unless [:void,:refund,:prior_auth_capture].include?(transaction[:type]) + unless [:void, :refund, :prior_auth_capture].include?(transaction[:type]) tag_unless_blank(xml, 'cardCode', transaction[:card_code]) end end diff --git a/lib/active_merchant/billing/gateways/bank_frick.rb b/lib/active_merchant/billing/gateways/bank_frick.rb index fdfdfcff642..8a35089978c 100644 --- a/lib/active_merchant/billing/gateways/bank_frick.rb +++ b/lib/active_merchant/billing/gateways/bank_frick.rb @@ -9,7 +9,7 @@ class BankFrickGateway < Gateway self.test_url = 'https://test.ctpe.io/payment/ctpe' self.live_url = 'https://ctpe.io/payment/ctpe' - self.supported_countries = ['LI','US'] + self.supported_countries = ['LI', 'US'] self.default_currency = 'EUR' self.supported_cardtypes = [:visa, :master, :american_express, :discover] diff --git a/lib/active_merchant/billing/gateways/beanstream.rb b/lib/active_merchant/billing/gateways/beanstream.rb index 6947992934d..aedcac80462 100644 --- a/lib/active_merchant/billing/gateways/beanstream.rb +++ b/lib/active_merchant/billing/gateways/beanstream.rb @@ -188,7 +188,7 @@ def update(vault_id, payment_method, options = {}) end options[:vault_id] = vault_id options[:operation] = secure_profile_action(:modify) - add_secure_profile_variables(post,options) + add_secure_profile_variables(post, options) commit(post, true) end diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index 3b6c9d2cfc4..e3ff636c26f 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -398,7 +398,7 @@ def recurring_parse(data) end def commit(params, use_profile_api = false) - post(post_data(params,use_profile_api),use_profile_api) + post(post_data(params, use_profile_api), use_profile_api) end def recurring_commit(params) diff --git a/lib/active_merchant/billing/gateways/blue_pay.rb b/lib/active_merchant/billing/gateways/blue_pay.rb index 988c2f1e946..b3f789b7de3 100644 --- a/lib/active_merchant/billing/gateways/blue_pay.rb +++ b/lib/active_merchant/billing/gateways/blue_pay.rb @@ -330,7 +330,7 @@ def commit(action, money, fields) def parse_recurring(response_fields, opts={}) # expected status? parsed = {} - response_fields.each do |k,v| + response_fields.each do |k, v| mapped_key = REBILL_FIELD_MAP.include?(k) ? REBILL_FIELD_MAP[k] : k parsed[mapped_key] = v end @@ -345,14 +345,14 @@ def parse_recurring(response_fields, opts={}) # expected status? def parse(body) # The bp20api has max one value per form field. - response_fields = Hash[CGI::parse(body).map{|k,v| [k.upcase,v.first]}] + response_fields = Hash[CGI::parse(body).map{|k, v| [k.upcase, v.first]}] if response_fields.include? 'REBILL_ID' return parse_recurring(response_fields) end parsed = {} - response_fields.each do |k,v| + response_fields.each do |k, v| mapped_key = FIELD_MAP.include?(k) ? FIELD_MAP[k] : k parsed[mapped_key] = v end diff --git a/lib/active_merchant/billing/gateways/bogus.rb b/lib/active_merchant/billing/gateways/bogus.rb index b5d51182368..e72bae4760c 100644 --- a/lib/active_merchant/billing/gateways/bogus.rb +++ b/lib/active_merchant/billing/gateways/bogus.rb @@ -106,7 +106,7 @@ def unstore(reference, options = {}) when /1$/ Response.new(true, SUCCESS_MESSAGE, {}, :test => true) when /2$/ - Response.new(false, FAILURE_MESSAGE, {:error => FAILURE_MESSAGE },:test => true, :error_code => STANDARD_ERROR_CODE[:processing_error]) + Response.new(false, FAILURE_MESSAGE, {:error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error]) else raise Error, UNSTORE_ERROR_MESSAGE end diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb index ae144a95c59..26b7fff9ef5 100644 --- a/lib/active_merchant/billing/gateways/borgun.rb +++ b/lib/active_merchant/billing/gateways/borgun.rb @@ -76,7 +76,7 @@ def scrub(transcript) private - CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")} + CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")} CURRENCY_CODES['ISK'] = '352' CURRENCY_CODES['EUR'] = '978' CURRENCY_CODES['USD'] = '840' @@ -190,7 +190,7 @@ def build_request(action, post) end end inner = CGI.escapeHTML(xml.target!) - envelope(mode).sub(/{{ :body }}/,inner) + envelope(mode).sub(/{{ :body }}/, inner) end def envelope(mode) diff --git a/lib/active_merchant/billing/gateways/bridge_pay.rb b/lib/active_merchant/billing/gateways/bridge_pay.rb index 3e12f5b11d6..51d6cf3bc4d 100644 --- a/lib/active_merchant/billing/gateways/bridge_pay.rb +++ b/lib/active_merchant/billing/gateways/bridge_pay.rb @@ -237,7 +237,7 @@ def post_data(post) { :UserName => @options[:user_name], :Password => @options[:password] - }.merge(post).collect{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') + }.merge(post).collect{|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/cams.rb b/lib/active_merchant/billing/gateways/cams.rb index fdb310358c6..872c7818b2b 100644 --- a/lib/active_merchant/billing/gateways/cams.rb +++ b/lib/active_merchant/billing/gateways/cams.rb @@ -167,7 +167,7 @@ def add_invoice(post, money, options) def add_payment(post, payment) post[:ccnumber] = payment.number - post[:ccexp] = "#{payment.month.to_s.rjust(2,"0")}#{payment.year.to_s[-2..-1]}" + post[:ccexp] = "#{payment.month.to_s.rjust(2, "0")}#{payment.year.to_s[-2..-1]}" post[:cvv] = payment.verification_value end @@ -175,7 +175,7 @@ def parse(body) kvs = body.split('&') kvs.inject({}) { |h, kv| - k,v = kv.split('=') + k, v = kv.split('=') h[k] = v h } @@ -219,7 +219,7 @@ def post_data(parameters = {}) parameters[:password] = @options[:password] parameters[:username] = @options[:username] - parameters.collect{|k,v| "#{k}=#{v}" }.join('&') + parameters.collect{|k, v| "#{k}=#{v}" }.join('&') end def error_code_from(response) diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb index aa61d77dc77..a611004f75b 100644 --- a/lib/active_merchant/billing/gateways/cardknox.rb +++ b/lib/active_merchant/billing/gateways/cardknox.rb @@ -3,7 +3,7 @@ module Billing #:nodoc: class CardknoxGateway < Gateway self.live_url = 'https://x1.cardknox.com/gateway' - self.supported_countries = ['US','CA','GB'] + self.supported_countries = ['US', 'CA', 'GB'] self.default_currency = 'USD' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb] diff --git a/lib/active_merchant/billing/gateways/cashnet.rb b/lib/active_merchant/billing/gateways/cashnet.rb index db28d9de497..880ffb4986c 100644 --- a/lib/active_merchant/billing/gateways/cashnet.rb +++ b/lib/active_merchant/billing/gateways/cashnet.rb @@ -136,7 +136,7 @@ def parse(body) match = body.match(/<cngateway>(.*)<\/cngateway>/) return nil unless match - Hash[CGI::parse(match[1]).map{|k,v| [k.to_sym,v.first]}] + Hash[CGI::parse(match[1]).map{|k, v| [k.to_sym, v.first]}] end def handle_response(response) diff --git a/lib/active_merchant/billing/gateways/cc5.rb b/lib/active_merchant/billing/gateways/cc5.rb index e9c5dac6e00..695eb7a8703 100644 --- a/lib/active_merchant/billing/gateways/cc5.rb +++ b/lib/active_merchant/billing/gateways/cc5.rb @@ -188,7 +188,7 @@ def normalize(text) return unless text if ActiveSupport::Inflector.method(:transliterate).arity == -2 - ActiveSupport::Inflector.transliterate(text,'') + ActiveSupport::Inflector.transliterate(text, '') else text.gsub(/[^\x00-\x7F]+/, '') end diff --git a/lib/active_merchant/billing/gateways/commercegate.rb b/lib/active_merchant/billing/gateways/commercegate.rb index f3cd6500830..c1d6d5bc1f4 100644 --- a/lib/active_merchant/billing/gateways/commercegate.rb +++ b/lib/active_merchant/billing/gateways/commercegate.rb @@ -111,7 +111,7 @@ def parse(body) results = {} body.split(/\&/).each do |pair| - key,val = pair.split(%r{=}) + key, val = pair.split(%r{=}) results[key] = CGI.unescape(val) end diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb index 4689e66d7fe..4c2f173fb0f 100644 --- a/lib/active_merchant/billing/gateways/credorax.rb +++ b/lib/active_merchant/billing/gateways/credorax.rb @@ -337,7 +337,7 @@ def url end def parse(body) - Hash[CGI::parse(body).map{|k,v| [k.upcase,v.first]}] + Hash[CGI::parse(body).map{|k, v| [k.upcase, v.first]}] end def success_from(response) diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb index dd0c1ae2599..2e3d444cc1b 100644 --- a/lib/active_merchant/billing/gateways/ct_payment.rb +++ b/lib/active_merchant/billing/gateways/ct_payment.rb @@ -118,7 +118,7 @@ def verify(credit_card, options={}) post = {} add_terminal_number(post, options) add_operator_id(post, options) - add_invoice(post,0, options) + add_invoice(post, 0, options) add_payment(post, credit_card) add_address(post, credit_card, options) add_customer_data(post, options) @@ -159,7 +159,7 @@ def add_terminal_number(post, options) end def add_money(post, money) - post[:Amount] = money.to_s.rjust(11,'0') + post[:Amount] = money.to_s.rjust(11, '0') end def add_operator_id(post, options) @@ -179,7 +179,7 @@ def add_address(post, creditcard, options) def add_invoice(post, money, options) post[:CurrencyCode] = options[:currency] || (currency(money) if money) - post[:InvoiceNumber] = options[:order_id].rjust(12,'0') + post[:InvoiceNumber] = options[:order_id].rjust(12, '0') post[:InputType] = 'I' post[:LanguageCode] = 'E' end @@ -189,7 +189,7 @@ def add_payment(post, payment) post[:Token] = split_authorization(payment)[3].strip else post[:CardType] = CARD_BRAND[payment.brand] || ' ' - post[:CardNumber] = payment.number.rjust(40,' ') + post[:CardNumber] = payment.number.rjust(40, ' ') post[:ExpirationDate] = expdate(payment) post[:Cvv2Cvc2Number] = payment.verification_value end diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index ec831d9377f..d31c5e46de1 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -209,7 +209,7 @@ def calculate_tax(creditcard, options) # Determines if a card can be used for Pinless Debit Card transactions def validate_pinless_debit_card(creditcard, options = {}) requires!(options, :order_id) - commit(build_validate_pinless_debit_request(creditcard,options), :validate_pinless_debit_card, nil, options) + commit(build_validate_pinless_debit_request(creditcard, options), :validate_pinless_debit_card, nil, options) end def supports_scrubbing? @@ -392,7 +392,7 @@ def build_retrieve_subscription_request(reference, options) xml.target! end - def build_validate_pinless_debit_request(creditcard,options) + def build_validate_pinless_debit_request(creditcard, options) xml = Builder::XmlMarkup.new :indent => 2 add_creditcard(xml, creditcard) add_validate_pinless_debit_service(xml) @@ -432,7 +432,7 @@ def add_line_item_data(xml, options) def add_merchant_data(xml, options) xml.tag! 'merchantID', @options[:login] xml.tag! 'merchantReferenceCode', options[:order_id] || generate_unique_id - xml.tag! 'clientLibrary','Ruby Active Merchant' + xml.tag! 'clientLibrary', 'Ruby Active Merchant' xml.tag! 'clientLibraryVersion', VERSION xml.tag! 'clientEnvironment', RUBY_PLATFORM end diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb index f943a330d01..7a24dd3e5f3 100644 --- a/lib/active_merchant/billing/gateways/data_cash.rb +++ b/lib/active_merchant/billing/gateways/data_cash.rb @@ -269,7 +269,7 @@ def commit(request) end def format_date(month, year) - "#{format(month,:two_digits)}/#{format(year, :two_digits)}" + "#{format(month, :two_digits)}/#{format(year, :two_digits)}" end def parse(body) diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb index d753f9fa143..7e4d7ae7cec 100644 --- a/lib/active_merchant/billing/gateways/dibs.rb +++ b/lib/active_merchant/billing/gateways/dibs.rb @@ -87,7 +87,7 @@ def scrub(transcript) private - CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")} + CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")} CURRENCY_CODES['USD'] = '840' CURRENCY_CODES['DKK'] = '208' CURRENCY_CODES['NOK'] = '578' diff --git a/lib/active_merchant/billing/gateways/efsnet.rb b/lib/active_merchant/billing/gateways/efsnet.rb index 91e689d3fa7..ad16cfbf349 100644 --- a/lib/active_merchant/billing/gateways/efsnet.rb +++ b/lib/active_merchant/billing/gateways/efsnet.rb @@ -99,16 +99,16 @@ def build_credit_card_request(money, creditcard, options = {}) :client_ip_address => options[:ip] } - add_creditcard(post,creditcard) - add_address(post,options) + add_creditcard(post, creditcard) + add_address(post, options) post end def format_reference_number(number) - number.to_s.slice(0,12) + number.to_s.slice(0, 12) end - def add_address(post,options) + def add_address(post, options) if address = options[:billing_address] || options[:address] if address[:address2] post[:billing_address] = address[:address1].to_s << ' ' << address[:address2].to_s diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb index 1800d17b373..34bb44f5bc0 100644 --- a/lib/active_merchant/billing/gateways/elavon.rb +++ b/lib/active_merchant/billing/gateways/elavon.rb @@ -149,7 +149,7 @@ def scrub(transcript) private - def add_invoice(form,options) + def add_invoice(form, options) form[:invoice_number] = truncate((options[:order_id] || options[:invoice]), 10) form[:description] = truncate(options[:description], 255) end diff --git a/lib/active_merchant/billing/gateways/epay.rb b/lib/active_merchant/billing/gateways/epay.rb index 7f351623253..f26a9112a5d 100644 --- a/lib/active_merchant/billing/gateways/epay.rb +++ b/lib/active_merchant/billing/gateways/epay.rb @@ -208,7 +208,7 @@ def do_authorize(params) end result = {} - query.each_pair do |k,v| + query.each_pair do |k, v| result[k] = v.is_a?(Array) && v.size == 1 ? v[0] : v # make values like ['v'] into 'v' end result diff --git a/lib/active_merchant/billing/gateways/eway.rb b/lib/active_merchant/billing/gateways/eway.rb index a45db4bf881..5625420870e 100644 --- a/lib/active_merchant/billing/gateways/eway.rb +++ b/lib/active_merchant/billing/gateways/eway.rb @@ -145,7 +145,7 @@ def post_data(parameters = {}) def message_from(message) return '' if message.blank? - MESSAGES[message[0,2]] || message + MESSAGES[message[0, 2]] || message end def purchase_url(cvn) diff --git a/lib/active_merchant/billing/gateways/exact.rb b/lib/active_merchant/billing/gateways/exact.rb index 6858ef98aa6..a388bcc341f 100644 --- a/lib/active_merchant/billing/gateways/exact.rb +++ b/lib/active_merchant/billing/gateways/exact.rb @@ -211,7 +211,7 @@ def parse(xml) parse_elements(response, root) end - response.delete_if{ |k,v| SENSITIVE_FIELDS.include?(k) } + response.delete_if{ |k, v| SENSITIVE_FIELDS.include?(k) } end def parse_elements(response, root) diff --git a/lib/active_merchant/billing/gateways/first_giving.rb b/lib/active_merchant/billing/gateways/first_giving.rb index 975409638d7..3af7a394116 100644 --- a/lib/active_merchant/billing/gateways/first_giving.rb +++ b/lib/active_merchant/billing/gateways/first_giving.rb @@ -116,7 +116,7 @@ def post_data(post) end def encode(hash) - hash.collect{|(k,v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&') + hash.collect{|(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&') end def creditcard_brand(brand) diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index da6b77b306e..655703826f4 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -438,7 +438,7 @@ def parse(xml) parse_elements(response, root) end - response.delete_if{ |k,v| SENSITIVE_FIELDS.include?(k) } + response.delete_if{ |k, v| SENSITIVE_FIELDS.include?(k) } end def parse_elements(response, root) diff --git a/lib/active_merchant/billing/gateways/flo2cash.rb b/lib/active_merchant/billing/gateways/flo2cash.rb index 83bdb83f50f..e3ced39eae0 100644 --- a/lib/active_merchant/billing/gateways/flo2cash.rb +++ b/lib/active_merchant/billing/gateways/flo2cash.rb @@ -71,7 +71,7 @@ def scrub(transcript) private - CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")} + CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")} CURRENCY_CODES['NZD'] = '554' def add_invoice(post, money, options) diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb index ef2dacc84c8..64cf7224a95 100644 --- a/lib/active_merchant/billing/gateways/garanti.rb +++ b/lib/active_merchant/billing/gateways/garanti.rb @@ -5,7 +5,7 @@ class GarantiGateway < Gateway self.test_url = 'https://sanalposprovtest.garanti.com.tr/VPServlet' # The countries the gateway supports merchants from as 2 digit ISO country codes - self.supported_countries = ['US','TR'] + self.supported_countries = ['US', 'TR'] # The card types supported by the payment gateway self.supported_cardtypes = [:visa, :master, :american_express, :discover] @@ -195,7 +195,7 @@ def normalize(text) return unless text if ActiveSupport::Inflector.method(:transliterate).arity == -2 - ActiveSupport::Inflector.transliterate(text,'') + ActiveSupport::Inflector.transliterate(text, '') else text.gsub(/[^\x00-\x7F]+/, '') end @@ -214,7 +214,7 @@ def currency_code(currency) CURRENCY_CODES[currency] || CURRENCY_CODES[default_currency] end - def commit(money,request) + def commit(money, request) url = test? ? self.test_url : self.live_url raw_response = ssl_post(url, 'data=' + request) response = parse(raw_response) diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index a96cbb12d42..d0f3702191c 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -329,7 +329,7 @@ def error_code_from(succeeded, response) end def nestable_hash - Hash.new {|h,k| h[k] = Hash.new(&h.default_proc) } + Hash.new {|h, k| h[k] = Hash.new(&h.default_proc) } end def capture_requested?(response) diff --git a/lib/active_merchant/billing/gateways/hdfc.rb b/lib/active_merchant/billing/gateways/hdfc.rb index f10438b0b47..a6e228d5721 100644 --- a/lib/active_merchant/billing/gateways/hdfc.rb +++ b/lib/active_merchant/billing/gateways/hdfc.rb @@ -57,7 +57,7 @@ def refund(amount, authorization, options={}) private - CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")} + CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")} CURRENCY_CODES['AED'] = '784' CURRENCY_CODES['AUD'] = '036' CURRENCY_CODES['CAD'] = '124' diff --git a/lib/active_merchant/billing/gateways/hps.rb b/lib/active_merchant/billing/gateways/hps.rb index 5572924d1c7..22677874ff1 100644 --- a/lib/active_merchant/billing/gateways/hps.rb +++ b/lib/active_merchant/billing/gateways/hps.rb @@ -42,7 +42,7 @@ def purchase(money, card_or_token, options={}) commit('CreditSale') do |xml| add_amount(xml, money) add_allow_dup(xml) - add_customer_data(xml, card_or_token,options) + add_customer_data(xml, card_or_token, options) add_details(xml, options) add_descriptor_name(xml, options) add_payment(xml, card_or_token, options) @@ -54,7 +54,7 @@ def refund(money, transaction_id, options={}) add_amount(xml, money) add_allow_dup(xml) add_reference(xml, transaction_id) - add_customer_data(xml, transaction_id,options) + add_customer_data(xml, transaction_id, options) add_details(xml, options) end end diff --git a/lib/active_merchant/billing/gateways/inspire.rb b/lib/active_merchant/billing/gateways/inspire.rb index f7ee068cdf0..78a193fc5ce 100644 --- a/lib/active_merchant/billing/gateways/inspire.rb +++ b/lib/active_merchant/billing/gateways/inspire.rb @@ -33,7 +33,7 @@ def initialize(options = {}) def authorize(money, creditcard, options = {}) post = {} add_invoice(post, options) - add_payment_source(post, creditcard,options) + add_payment_source(post, creditcard, options) add_address(post, creditcard, options) add_customer_data(post, options) @@ -136,11 +136,11 @@ def add_payment_source(params, source, options={}) end end - def add_customer_vault_id(params,vault_id) + def add_customer_vault_id(params, vault_id) params[:customer_vault_id] = vault_id end - def add_creditcard(post, creditcard,options) + def add_creditcard(post, creditcard, options) if options[:store] post[:customer_vault] = 'add_customer' post[:customer_vault_id] = options[:store] unless options[:store] == true @@ -164,7 +164,7 @@ def add_check(post, check) def parse(body) results = {} body.split(/&/).each do |pair| - key,val = pair.split(%r{=}) + key, val = pair.split(%r{=}) results[key] = val end @@ -174,7 +174,7 @@ def parse(body) def commit(action, money, parameters) parameters[:amount] = amount(money) if money - response = parse( ssl_post(self.live_url, post_data(action,parameters)) ) + response = parse( ssl_post(self.live_url, post_data(action, parameters)) ) Response.new(response['response'] == '1', message_from(response), response, :authorization => response['transactionid'], @@ -186,7 +186,7 @@ def commit(action, money, parameters) def message_from(response) case response['responsetext'] - when 'SUCCESS','Approved' + when 'SUCCESS', 'Approved' 'This transaction has been approved' when 'DECLINE' 'This transaction has been declined' @@ -201,7 +201,7 @@ def post_data(action, parameters = {}) post[:password] = @options[:password] post[:type] = action if action - request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') + request = post.merge(parameters).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') request end diff --git a/lib/active_merchant/billing/gateways/iridium.rb b/lib/active_merchant/billing/gateways/iridium.rb index 65024f293aa..6b0ca00b4b7 100644 --- a/lib/active_merchant/billing/gateways/iridium.rb +++ b/lib/active_merchant/billing/gateways/iridium.rb @@ -419,29 +419,29 @@ def parse_element(reply, node) case node.name when 'CrossReferenceTransactionResult' reply[:transaction_result] = {} - node.attributes.each do |a,b| + node.attributes.each do |a, b| reply[:transaction_result][a.underscore.to_sym] = b end node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements? when 'CardDetailsTransactionResult' reply[:transaction_result] = {} - node.attributes.each do |a,b| + node.attributes.each do |a, b| reply[:transaction_result][a.underscore.to_sym] = b end node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements? when 'TransactionOutputData' reply[:transaction_output_data] = {} - node.attributes.each{|a,b| reply[:transaction_output_data][a.underscore.to_sym] = b } + node.attributes.each{|a, b| reply[:transaction_output_data][a.underscore.to_sym] = b } node.elements.each{|e| parse_element(reply[:transaction_output_data], e) } if node.has_elements? when 'CustomVariables' reply[:custom_variables] = {} - node.attributes.each{|a,b| reply[:custom_variables][a.underscore.to_sym] = b } + node.attributes.each{|a, b| reply[:custom_variables][a.underscore.to_sym] = b } node.elements.each{|e| parse_element(reply[:custom_variables], e) } if node.has_elements? when 'GatewayEntryPoints' reply[:gateway_entry_points] = {} - node.attributes.each{|a,b| reply[:gateway_entry_points][a.underscore.to_sym] = b } + node.attributes.each{|a, b| reply[:gateway_entry_points][a.underscore.to_sym] = b } node.elements.each{|e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements? else k = node.name.underscore.to_sym @@ -451,7 +451,7 @@ def parse_element(reply, node) else if node.has_attributes? reply[k] = {} - node.attributes.each{|a,b| reply[k][a.underscore.to_sym] = b } + node.attributes.each{|a, b| reply[k][a.underscore.to_sym] = b } else reply[k] = node.text end diff --git a/lib/active_merchant/billing/gateways/itransact.rb b/lib/active_merchant/billing/gateways/itransact.rb index e76919e4b8f..e7861de3d95 100644 --- a/lib/active_merchant/billing/gateways/itransact.rb +++ b/lib/active_merchant/billing/gateways/itransact.rb @@ -336,7 +336,7 @@ def add_creditcard(xml, creditcard) xml.AccountInfo { xml.CardAccount { xml.AccountNumber(creditcard.number.to_s) - xml.ExpirationMonth(creditcard.month.to_s.rjust(2,'0')) + xml.ExpirationMonth(creditcard.month.to_s.rjust(2, '0')) xml.ExpirationYear(creditcard.year.to_s) xml.CVVNumber(creditcard.verification_value.to_s) unless creditcard.verification_value.blank? } @@ -372,7 +372,7 @@ def add_transaction_control(xml, options) def add_vendor_data(xml, options) return if options[:vendor_data].blank? xml.VendorData { - options[:vendor_data].each do |k,v| + options[:vendor_data].each do |k, v| xml.Element { xml.Name(k) xml.Key(v) diff --git a/lib/active_merchant/billing/gateways/iveri.rb b/lib/active_merchant/billing/gateways/iveri.rb index 808966879c2..6d0f1f092df 100644 --- a/lib/active_merchant/billing/gateways/iveri.rb +++ b/lib/active_merchant/billing/gateways/iveri.rb @@ -241,8 +241,8 @@ def error_code_from(response, succeeded) def underscore(camel_cased_word) camel_cased_word.to_s.gsub(/::/, '/'). - gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). - gsub(/([a-z\d])([A-Z])/,'\1_\2'). + gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). + gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr('-', '_'). downcase end diff --git a/lib/active_merchant/billing/gateways/jetpay.rb b/lib/active_merchant/billing/gateways/jetpay.rb index f6c631c4421..cbe81b5368f 100644 --- a/lib/active_merchant/billing/gateways/jetpay.rb +++ b/lib/active_merchant/billing/gateways/jetpay.rb @@ -344,7 +344,7 @@ def add_credit_card(xml, credit_card) xml.tag! 'CardExpYear', format_exp(credit_card.year) if credit_card.first_name || credit_card.last_name - xml.tag! 'CardName', [credit_card.first_name,credit_card.last_name].compact.join(' ') + xml.tag! 'CardName', [credit_card.first_name, credit_card.last_name].compact.join(' ') end unless credit_card.verification_value.nil? || (credit_card.verification_value.length == 0) diff --git a/lib/active_merchant/billing/gateways/jetpay_v2.rb b/lib/active_merchant/billing/gateways/jetpay_v2.rb index ff136384912..ae99f7f75e3 100644 --- a/lib/active_merchant/billing/gateways/jetpay_v2.rb +++ b/lib/active_merchant/billing/gateways/jetpay_v2.rb @@ -369,7 +369,7 @@ def add_credit_card(xml, credit_card) xml.tag! 'CardExpYear', format_exp(credit_card.year) if credit_card.first_name || credit_card.last_name - xml.tag! 'CardName', [credit_card.first_name,credit_card.last_name].compact.join(' ') + xml.tag! 'CardName', [credit_card.first_name, credit_card.last_name].compact.join(' ') end unless credit_card.verification_value.nil? || (credit_card.verification_value.length == 0) diff --git a/lib/active_merchant/billing/gateways/linkpoint.rb b/lib/active_merchant/billing/gateways/linkpoint.rb index 37f0b3ab0b5..61e5fe0e430 100644 --- a/lib/active_merchant/billing/gateways/linkpoint.rb +++ b/lib/active_merchant/billing/gateways/linkpoint.rb @@ -266,8 +266,8 @@ def commit(money, creditcard, options = {}) Response.new(successful?(response), response[:message], response, :test => test?, :authorization => response[:ordernum], - :avs_result => { :code => response[:avs].to_s[2,1] }, - :cvv_result => response[:avs].to_s[3,1] + :avs_result => { :code => response[:avs].to_s[2, 1] }, + :cvv_result => response[:avs].to_s[3, 1] ) end diff --git a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb index f1306ce3db9..1f465a07ca4 100644 --- a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +++ b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb @@ -148,7 +148,7 @@ def add_3dsecure_params(post, options) def parse(body) results = {} body.split(/&/).each do |pair| - key,val = pair.split(/=/) + key, val = pair.split(/=/) results[key] = val end results @@ -159,7 +159,7 @@ def commit(action, money, parameters) parameters[:transaction_amount] = amount(money) if money unless action == 'V' response = begin - parse( ssl_post(url, post_data(action,parameters)) ) + parse( ssl_post(url, post_data(action, parameters)) ) rescue ActiveMerchant::ResponseError => e { 'error_code' => '404', 'auth_response_text' => e.to_s } end @@ -186,7 +186,7 @@ def post_data(action, parameters = {}) post[:profile_key] = @options[:password] post[:transaction_type] = action if action - request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') + request = post.merge(parameters).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') request end end diff --git a/lib/active_merchant/billing/gateways/merchant_one.rb b/lib/active_merchant/billing/gateways/merchant_one.rb index 2352178da07..e20dfe354bf 100644 --- a/lib/active_merchant/billing/gateways/merchant_one.rb +++ b/lib/active_merchant/billing/gateways/merchant_one.rb @@ -83,7 +83,7 @@ def add_creditcard(post, creditcard) def commit(action, money, parameters={}) parameters['username'] = @options[:username] parameters['password'] = @options[:password] - parse(ssl_post(BASE_URL,post_data(action, parameters))) + parse(ssl_post(BASE_URL, post_data(action, parameters))) end def post_data(action, parameters = {}) @@ -99,7 +99,7 @@ def post_data(action, parameters = {}) end def parse(data) - responses = CGI.parse(data).inject({}){|h,(k, v)| h[k] = v.first; h} + responses = CGI.parse(data).inject({}){|h, (k, v)| h[k] = v.first; h} Response.new( (responses['response'].to_i == 1), responses['responsetext'], diff --git a/lib/active_merchant/billing/gateways/merchant_warrior.rb b/lib/active_merchant/billing/gateways/merchant_warrior.rb index 66da5f62317..6a8e5538bb5 100644 --- a/lib/active_merchant/billing/gateways/merchant_warrior.rb +++ b/lib/active_merchant/billing/gateways/merchant_warrior.rb @@ -203,7 +203,7 @@ def success?(response) end def post_data(post) - post.collect{|k,v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') + post.collect{|k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/mercury.rb b/lib/active_merchant/billing/gateways/mercury.rb index 9580630d773..6fea6dd9197 100644 --- a/lib/active_merchant/billing/gateways/mercury.rb +++ b/lib/active_merchant/billing/gateways/mercury.rb @@ -18,7 +18,7 @@ class MercuryGateway < Gateway self.homepage_url = 'http://www.mercurypay.com' self.display_name = 'Mercury' - self.supported_countries = ['US','CA'] + self.supported_countries = ['US', 'CA'] self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb] self.default_currency = 'USD' @@ -349,7 +349,7 @@ def escape_xml(xml) end def unescape_xml(escaped_xml) - escaped_xml.gsub(/\&gt;/,'>').gsub(/\&lt;/,'<') + escaped_xml.gsub(/\&gt;/, '>').gsub(/\&lt;/, '<') end end end diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb index 5cb3c515183..9355406aed3 100644 --- a/lib/active_merchant/billing/gateways/moneris_us.rb +++ b/lib/active_merchant/billing/gateways/moneris_us.rb @@ -223,7 +223,7 @@ def commit(action, parameters = {}) Response.new(successful?(response), message_from(response[:message]), response, :test => test?, :avs_result => { :code => response[:avs_result_code] }, - :cvv_result => response[:cvd_result_code] && response[:cvd_result_code][-1,1], + :cvv_result => response[:cvd_result_code] && response[:cvd_result_code][-1, 1], :authorization => authorization_from(response) ) end diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb index fa9c882c6d2..cb23e8e6235 100644 --- a/lib/active_merchant/billing/gateways/mundipagg.rb +++ b/lib/active_merchant/billing/gateways/mundipagg.rb @@ -177,7 +177,7 @@ def add_credit_card(post, payment, options) post[:payment][:credit_card][:card][:exp_year] = payment.year post[:payment][:credit_card][:card][:cvv] = payment.verification_value post[:payment][:credit_card][:card][:holder_document] = options[:holder_document] if options[:holder_document] - add_billing_address(post,'credit_card', options) + add_billing_address(post, 'credit_card', options) end end diff --git a/lib/active_merchant/billing/gateways/net_registry.rb b/lib/active_merchant/billing/gateways/net_registry.rb index 62a2e8c9ba9..88cec2f11cf 100644 --- a/lib/active_merchant/billing/gateways/net_registry.rb +++ b/lib/active_merchant/billing/gateways/net_registry.rb @@ -152,7 +152,7 @@ def commit(action, params) def post_data(action, params) params['COMMAND'] = TRANSACTIONS[action] params['LOGIN'] = "#{@options[:login]}/#{@options[:password]}" - escape_uri(params.map{|k,v| "#{k}=#{v}"}.join('&')) + escape_uri(params.map{|k, v| "#{k}=#{v}"}.join('&')) end # The upstream is picky and so we can't use CGI.escape like we want to diff --git a/lib/active_merchant/billing/gateways/netaxept.rb b/lib/active_merchant/billing/gateways/netaxept.rb index f142ce5a968..18eb61964ca 100644 --- a/lib/active_merchant/billing/gateways/netaxept.rb +++ b/lib/active_merchant/billing/gateways/netaxept.rb @@ -173,7 +173,7 @@ def build_url(base, parameters=nil) end def encode(hash) - hash.collect{|(k,v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&') + hash.collect{|(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/netbilling.rb b/lib/active_merchant/billing/gateways/netbilling.rb index 32635e806dd..7b13aaf27cf 100644 --- a/lib/active_merchant/billing/gateways/netbilling.rb +++ b/lib/active_merchant/billing/gateways/netbilling.rb @@ -186,7 +186,7 @@ def add_credit_card(post, credit_card) def parse(body) results = {} body.split(/&/).each do |pair| - key,val = pair.split(/\=/) + key, val = pair.split(/\=/) results[key.to_sym] = CGI.unescape(val) end results @@ -224,7 +224,7 @@ def post_data(action, parameters = {}) parameters[:pay_type] = 'C' parameters[:tran_type] = TRANSACTIONS[action] - parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') + parameters.reject{|k, v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end end diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb index 0b6910ba82a..aa6e956f6c1 100644 --- a/lib/active_merchant/billing/gateways/nmi.rb +++ b/lib/active_merchant/billing/gateways/nmi.rb @@ -254,7 +254,7 @@ def url end def parse(body) - Hash[CGI::parse(body).map { |k,v| [k.intern, v.first] }] + Hash[CGI::parse(body).map { |k, v| [k.intern, v.first] }] end def success_from(response) diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb index b0a8be19343..99f998e895f 100644 --- a/lib/active_merchant/billing/gateways/ogone.rb +++ b/lib/active_merchant/billing/gateways/ogone.rb @@ -429,9 +429,9 @@ def calculate_signature(signed_parameters, algorithm, secret) raise "Unknown signature algorithm #{algorithm}" end - filtered_params = signed_parameters.select{|k,v| !v.blank?} + filtered_params = signed_parameters.select{|k, v| !v.blank?} sha_encryptor.hexdigest( - filtered_params.sort_by{|k,v| k.upcase}.map{|k, v| "#{k.upcase}=#{v}#{secret}"}.join('') + filtered_params.sort_by{|k, v| k.upcase}.map{|k, v| "#{k.upcase}=#{v}#{secret}"}.join('') ).upcase end diff --git a/lib/active_merchant/billing/gateways/omise.rb b/lib/active_merchant/billing/gateways/omise.rb index 3dbb8e30c37..fbb1af839ab 100644 --- a/lib/active_merchant/billing/gateways/omise.rb +++ b/lib/active_merchant/billing/gateways/omise.rb @@ -164,7 +164,7 @@ def scrub(transcript) transcript. gsub(/(Authorization: Basic )\w+/i, '\1[FILTERED]'). gsub(/(\\"number\\":)\\"\d+\\"/, '\1[FILTERED]'). - gsub(/(\\"security_code\\":)\\"\d+\\"/,'\1[FILTERED]') + gsub(/(\\"security_code\\":)\\"\d+\\"/, '\1[FILTERED]') end private diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index c5f9000e4e3..fe3f1a3b1d8 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -516,7 +516,7 @@ def parse(body) end end - response.delete_if { |k,_| SENSITIVE_FIELDS.include?(k) } + response.delete_if { |k, _| SENSITIVE_FIELDS.include?(k) } end def recurring_parse_element(response, node) diff --git a/lib/active_merchant/billing/gateways/pay_junction.rb b/lib/active_merchant/billing/gateways/pay_junction.rb index 0113c737966..84ccb33b34b 100644 --- a/lib/active_merchant/billing/gateways/pay_junction.rb +++ b/lib/active_merchant/billing/gateways/pay_junction.rb @@ -366,7 +366,7 @@ def post_data(action, params) params[:version] = API_VERSION params[:transaction_type] = action - params.reject{|k,v| v.blank?}.collect{ |k, v| "dc_#{k}=#{CGI.escape(v.to_s)}" }.join('&') + params.reject{|k, v| v.blank?}.collect{ |k, v| "dc_#{k}=#{CGI.escape(v.to_s)}" }.join('&') end def parse(body) diff --git a/lib/active_merchant/billing/gateways/pay_junction_v2.rb b/lib/active_merchant/billing/gateways/pay_junction_v2.rb index 669188c9d48..2f9a5148dc7 100644 --- a/lib/active_merchant/billing/gateways/pay_junction_v2.rb +++ b/lib/active_merchant/billing/gateways/pay_junction_v2.rb @@ -173,7 +173,7 @@ def success_from(response) def message_from(response) return response['response']['message'] if response['response'] - response['errors']&.inject(''){ |message,error| error['message'] + '|' + message } + response['errors']&.inject(''){ |message, error| error['message'] + '|' + message } end def authorization_from(response) diff --git a/lib/active_merchant/billing/gateways/pay_secure.rb b/lib/active_merchant/billing/gateways/pay_secure.rb index bbdfc2bacf9..f5f539a3185 100644 --- a/lib/active_merchant/billing/gateways/pay_secure.rb +++ b/lib/active_merchant/billing/gateways/pay_secure.rb @@ -52,7 +52,7 @@ def add_amount(post, money) end def add_invoice(post, options) - post[:merchant_transid] = options[:order_id].to_s.slice(0,21) + post[:merchant_transid] = options[:order_id].to_s.slice(0, 21) post[:memnum] = options[:invoice] post[:custnum] = options[:customer] post[:clientdata] = options[:description] @@ -104,7 +104,7 @@ def post_data(action, parameters = {}) parameters[:merchant_id] = @options[:login] parameters[:password] = @options[:password] - parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&') + parameters.reject{|k, v| v.blank?}.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/paybox_direct.rb b/lib/active_merchant/billing/gateways/paybox_direct.rb index c66933c5baa..ecb3d938a9f 100644 --- a/lib/active_merchant/billing/gateways/paybox_direct.rb +++ b/lib/active_merchant/billing/gateways/paybox_direct.rb @@ -86,8 +86,8 @@ def capture(money, authorization, options = {}) post = {} add_invoice(post, options) add_amount(post, money, options) - post[:numappel] = authorization[0,10] - post[:numtrans] = authorization[10,10] + post[:numappel] = authorization[0, 10] + post[:numtrans] = authorization[10, 10] commit('capture', money, post) end @@ -130,8 +130,8 @@ def add_creditcard(post, creditcard) end def add_reference(post, identification) - post[:numappel] = identification[0,10] - post[:numtrans] = identification[10,10] + post[:numappel] = identification[0, 10] + post[:numtrans] = identification[10, 10] end def add_amount(post, money, options) @@ -142,14 +142,14 @@ def add_amount(post, money, options) def parse(body) results = {} body.split(/&/).each do |pair| - key,val = pair.split(/\=/) + key, val = pair.split(/\=/) results[key.downcase.to_sym] = CGI.unescape(val) if val end results end def commit(action, money = nil, parameters = nil) - request_data = post_data(action,parameters) + request_data = post_data(action, parameters) response = parse(ssl_post(test? ? self.test_url : self.live_url, request_data)) response = parse(ssl_post(self.live_url_backup, request_data)) if service_unavailable?(response) && !test? Response.new(success?(response), message_from(response), response.merge( @@ -157,7 +157,7 @@ def commit(action, money = nil, parameters = nil) :test => test?, :authorization => response[:numappel].to_s + response[:numtrans].to_s, :fraud_review => false, - :sent_params => parameters.delete_if{|key,value| ['porteur','dateval','cvv'].include?(key.to_s)} + :sent_params => parameters.delete_if{|key, value| ['porteur', 'dateval', 'cvv'].include?(key.to_s)} ) end @@ -179,7 +179,7 @@ def post_data(action, parameters = {}) :type => TRANSACTIONS[action.to_sym], :dateq => Time.now.strftime('%d%m%Y%H%M%S'), :numquestion => unique_id(parameters[:order_id]), - :site => @options[:login].to_s[0,7], + :site => @options[:login].to_s[0, 7], :rang => @options[:rang] || @options[:login].to_s[7..-1], :cle => @options[:password], :pays => '', diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb index 418e2e05b68..e8f08d29834 100644 --- a/lib/active_merchant/billing/gateways/payflow.rb +++ b/lib/active_merchant/billing/gateways/payflow.rb @@ -143,7 +143,7 @@ def build_reference_sale_or_authorization_request(action, money, reference, opti billing_address = options[:billing_address] || options[:address] add_address(xml, 'BillTo', billing_address, options) if billing_address - add_address(xml, 'ShipTo', options[:shipping_address],options) if options[:shipping_address] + add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address] xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money) end diff --git a/lib/active_merchant/billing/gateways/payflow_express.rb b/lib/active_merchant/billing/gateways/payflow_express.rb index c2970b6e052..9676d2b1cf2 100644 --- a/lib/active_merchant/billing/gateways/payflow_express.rb +++ b/lib/active_merchant/billing/gateways/payflow_express.rb @@ -198,7 +198,7 @@ def add_paypal_details(xml, options) xml.tag! 'Token', options[:token] unless options[:token].blank? xml.tag! 'NoShipping', options[:no_shipping] ? '1' : '0' xml.tag! 'AddressOverride', options[:address_override] ? '1' : '0' - xml.tag! 'ButtonSource', application_id.to_s.slice(0,32) unless application_id.blank? + xml.tag! 'ButtonSource', application_id.to_s.slice(0, 32) unless application_id.blank? # Customization of the payment page xml.tag! 'PageStyle', options[:page_style] unless options[:page_style].blank? diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb index b668aa14109..d3e28786d8e 100644 --- a/lib/active_merchant/billing/gateways/payment_express.rb +++ b/lib/active_merchant/billing/gateways/payment_express.rb @@ -274,9 +274,9 @@ def add_optional_elements(xml, options) xml.add_element('ClientType').text = client_type end - xml.add_element('TxnData1').text = options[:txn_data1].to_s.slice(0,255) unless options[:txn_data1].blank? - xml.add_element('TxnData2').text = options[:txn_data2].to_s.slice(0,255) unless options[:txn_data2].blank? - xml.add_element('TxnData3').text = options[:txn_data3].to_s.slice(0,255) unless options[:txn_data3].blank? + xml.add_element('TxnData1').text = options[:txn_data1].to_s.slice(0, 255) unless options[:txn_data1].blank? + xml.add_element('TxnData2').text = options[:txn_data2].to_s.slice(0, 255) unless options[:txn_data2].blank? + xml.add_element('TxnData3').text = options[:txn_data3].to_s.slice(0, 255) unless options[:txn_data3].blank? end def new_transaction diff --git a/lib/active_merchant/billing/gateways/payway.rb b/lib/active_merchant/billing/gateways/payway.rb index e8f9d8c163a..b80e5f937a1 100644 --- a/lib/active_merchant/billing/gateways/payway.rb +++ b/lib/active_merchant/billing/gateways/payway.rb @@ -150,7 +150,7 @@ def add_payment_method(post, payment_method) post['card.cardHolderName'] = "#{payment_method.first_name} #{payment_method.last_name}" post['card.PAN'] = payment_method.number post['card.CVN'] = payment_method.verification_value - post['card.expiryYear'] = payment_method.year.to_s[-2,2] + post['card.expiryYear'] = payment_method.year.to_s[-2, 2] post['card.expiryMonth'] = sprintf('%02d', payment_method.month) else post['customer.customerReferenceNumber'] = payment_method diff --git a/lib/active_merchant/billing/gateways/plugnpay.rb b/lib/active_merchant/billing/gateways/plugnpay.rb index 634c1294189..750f133a35b 100644 --- a/lib/active_merchant/billing/gateways/plugnpay.rb +++ b/lib/active_merchant/billing/gateways/plugnpay.rb @@ -189,7 +189,7 @@ def commit(action, post) def parse(body) body = CGI.unescape(body) results = {} - body.split('&').collect { |e| e.split('=') }.each do |key,value| + body.split('&').collect { |e| e.split('=') }.each do |key, value| results[key.downcase.to_sym] = normalize(value.to_s.strip) end diff --git a/lib/active_merchant/billing/gateways/pro_pay.rb b/lib/active_merchant/billing/gateways/pro_pay.rb index ef3eb1050a9..d70b1539bb0 100644 --- a/lib/active_merchant/billing/gateways/pro_pay.rb +++ b/lib/active_merchant/billing/gateways/pro_pay.rb @@ -317,8 +317,8 @@ def build_xml_request def underscore(camel_cased_word) camel_cased_word.to_s.gsub(/::/, '/'). - gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). - gsub(/([a-z\d])([A-Z])/,'\1_\2'). + gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). + gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr('-', '_'). downcase end diff --git a/lib/active_merchant/billing/gateways/psigate.rb b/lib/active_merchant/billing/gateways/psigate.rb index f8dfbc67a5c..b987dd1e74b 100644 --- a/lib/active_merchant/billing/gateways/psigate.rb +++ b/lib/active_merchant/billing/gateways/psigate.rb @@ -168,7 +168,7 @@ def parameters(money, creditcard, options = {}) if creditcard exp_month = sprintf('%.2i', creditcard.month) unless creditcard.month.blank? - exp_year = creditcard.year.to_s[2,2] unless creditcard.year.blank? + exp_year = creditcard.year.to_s[2, 2] unless creditcard.year.blank? card_id_code = (creditcard.verification_value.blank? ? nil : '1') params.update( diff --git a/lib/active_merchant/billing/gateways/quantum.rb b/lib/active_merchant/billing/gateways/quantum.rb index 280bdcd87c8..e3b1d12decd 100644 --- a/lib/active_merchant/billing/gateways/quantum.rb +++ b/lib/active_merchant/billing/gateways/quantum.rb @@ -81,7 +81,7 @@ def setup_address_hash(options) def build_auth_request(money, creditcard, options) xml = Builder::XmlMarkup.new - add_common_credit_card_info(xml,'AUTH_ONLY') + add_common_credit_card_info(xml, 'AUTH_ONLY') add_purchase_data(xml, money) add_creditcard(xml, creditcard) add_address(xml, creditcard, options[:billing_address], options) @@ -94,7 +94,7 @@ def build_auth_request(money, creditcard, options) def build_capture_request(money, authorization, options) xml = Builder::XmlMarkup.new - add_common_credit_card_info(xml,'PREVIOUS_SALE') + add_common_credit_card_info(xml, 'PREVIOUS_SALE') transaction_id, _ = authorization_parts_from(authorization) add_transaction_id(xml, transaction_id) xml.target! @@ -115,7 +115,7 @@ def build_purchase_request(money, creditcard, options) def build_void_request(authorization, options) xml = Builder::XmlMarkup.new - add_common_credit_card_info(xml,'VOID') + add_common_credit_card_info(xml, 'VOID') transaction_id, _ = authorization_parts_from(authorization) add_transaction_id(xml, transaction_id) xml.target! @@ -123,7 +123,7 @@ def build_void_request(authorization, options) def build_credit_request(money, authorization, options) xml = Builder::XmlMarkup.new - add_common_credit_card_info(xml,'RETURN') + add_common_credit_card_info(xml, 'RETURN') add_purchase_data(xml, money) transaction_id, cc = authorization_parts_from(authorization) add_transaction_id(xml, transaction_id) diff --git a/lib/active_merchant/billing/gateways/quickbooks.rb b/lib/active_merchant/billing/gateways/quickbooks.rb index f346cefc34b..48442334eb2 100644 --- a/lib/active_merchant/billing/gateways/quickbooks.rb +++ b/lib/active_merchant/billing/gateways/quickbooks.rb @@ -48,7 +48,7 @@ class QuickbooksGateway < Gateway 'PMT-6000' => STANDARD_ERROR_CODE[:processing_error], # A temporary Issue prevented this request from being processed. } - FRAUD_WARNING_CODES = ['PMT-1000','PMT-1001','PMT-1002','PMT-1003'] + FRAUD_WARNING_CODES = ['PMT-1000', 'PMT-1001', 'PMT-1002', 'PMT-1003'] def initialize(options = {}) requires!(options, :consumer_key, :consumer_secret, :access_token, :token_secret, :realm) diff --git a/lib/active_merchant/billing/gateways/qvalent.rb b/lib/active_merchant/billing/gateways/qvalent.rb index 6d59464a09c..0dd7c279255 100644 --- a/lib/active_merchant/billing/gateways/qvalent.rb +++ b/lib/active_merchant/billing/gateways/qvalent.rb @@ -103,7 +103,7 @@ def scrub(transcript) private - CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")} + CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")} CURRENCY_CODES['AUD'] = 'AUD' CURRENCY_CODES['INR'] = 'INR' diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index 6d58ea3f6e9..1892e652378 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -279,7 +279,7 @@ def add_network_tokenization_card(xml, payment) end xml.tag! 'supplementarydata' do xml.tag! 'item', 'type' => 'mobile' do - xml.tag! 'field01', payment.source.to_s.gsub('_','-') + xml.tag! 'field01', payment.source.to_s.gsub('_', '-') end end end diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb index 7a3c64f7a27..8d3cccd3cc6 100644 --- a/lib/active_merchant/billing/gateways/safe_charge.rb +++ b/lib/active_merchant/billing/gateways/safe_charge.rb @@ -252,8 +252,8 @@ def error_code_from(response) def underscore(camel_cased_word) camel_cased_word.to_s.gsub(/::/, '/'). - gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). - gsub(/([a-z\d])([A-Z])/,'\1_\2'). + gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). + gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr('-', '_'). downcase end diff --git a/lib/active_merchant/billing/gateways/sage.rb b/lib/active_merchant/billing/gateways/sage.rb index 2c44e92eeed..52bb573c93e 100644 --- a/lib/active_merchant/billing/gateways/sage.rb +++ b/lib/active_merchant/billing/gateways/sage.rb @@ -179,9 +179,9 @@ def parse(data, source) def parse_check(data) response = {} - response[:success] = data[1,1] - response[:code] = data[2,6].strip - response[:message] = data[8,32].strip + response[:success] = data[1, 1] + response[:code] = data[2, 6].strip + response[:message] = data[8, 32].strip response[:risk] = data[40, 2] response[:reference] = data[42, 10] @@ -194,9 +194,9 @@ def parse_check(data) def parse_credit_card(data) response = {} - response[:success] = data[1,1] - response[:code] = data[2,6] - response[:message] = data[8,32].strip + response[:success] = data[1, 1] + response[:code] = data[2, 6] + response[:message] = data[8, 32].strip response[:front_end] = data[40, 2] response[:cvv_result] = data[42, 1] response[:avs_result] = data[43, 1].strip diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb index adbbd32f0dc..56dd6a2309e 100644 --- a/lib/active_merchant/billing/gateways/skip_jack.rb +++ b/lib/active_merchant/billing/gateways/skip_jack.rb @@ -368,7 +368,7 @@ def add_invoice(post, options) post[:OrderDescription] = options[:description] if order_items = options[:items] - post[:OrderString] = order_items.collect { |item| "#{item[:sku]}~#{item[:description].tr('~','-')}~#{item[:declared_value]}~#{item[:quantity]}~#{item[:taxable]}~~~~~~~~#{item[:tax_rate]}~||"}.join + post[:OrderString] = order_items.collect { |item| "#{item[:sku]}~#{item[:description].tr('~', '-')}~#{item[:declared_value]}~#{item[:quantity]}~#{item[:taxable]}~~~~~~~~#{item[:tax_rate]}~||"}.join else post[:OrderString] = '1~None~0.00~0~N~||' end diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb index b6a89f13b39..8f84413abdc 100644 --- a/lib/active_merchant/billing/gateways/smart_ps.rb +++ b/lib/active_merchant/billing/gateways/smart_ps.rb @@ -23,7 +23,7 @@ def initialize(options = {}) def authorize(money, creditcard, options = {}) post = {} add_invoice(post, options) - add_payment_source(post, creditcard,options) + add_payment_source(post, creditcard, options) add_address(post, options[:billing_address] || options[:address]) add_address(post, options[:shipping_address], 'shipping') add_customer_data(post, options) @@ -65,7 +65,7 @@ def credit(money, payment_source, options = {}) add_payment_source(post, payment_source, options) add_address(post, options[:billing_address] || options[:address]) add_customer_data(post, options) - add_sku(post,options) + add_sku(post, options) add_currency(post, money, options) add_processor(post, options) commit('credit', money, post) @@ -138,7 +138,7 @@ def add_customer_data(post, options) end end - def add_address(post, address,prefix='') + def add_address(post, address, prefix='') prefix +='_' unless prefix.blank? unless address.blank? or address.values.blank? post[prefix+'address1'] = address[:address1].to_s @@ -206,7 +206,7 @@ def add_check(post, check, options) post[:account_type] = check.account_type # The customer's type of ACH account end - def add_sku(post,options) + def add_sku(post, options) post['product_sku_#'] = options[:sku] || options['product_sku_#'] end @@ -221,7 +221,7 @@ def add_eci(post, options) def parse(body) results = {} body.split(/&/).each do |pair| - key,val = pair.split(/=/) + key, val = pair.split(/=/) results[key] = val end @@ -230,7 +230,7 @@ def parse(body) def commit(action, money, parameters) parameters[:amount] = localized_amount(money, parameters[:currency] || default_currency) if money - response = parse( ssl_post(self.live_url, post_data(action,parameters)) ) + response = parse( ssl_post(self.live_url, post_data(action, parameters)) ) Response.new(response['response'] == '1', message_from(response), response, :authorization => (response['transactionid'] || response['customer_vault_id']), :test => test?, @@ -263,7 +263,7 @@ def post_data(action, parameters = {}) post[:password] = @options[:password] post[:type] = action if action - request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') + request = post.merge(parameters).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') request end diff --git a/lib/active_merchant/billing/gateways/so_easy_pay.rb b/lib/active_merchant/billing/gateways/so_easy_pay.rb index 7b5198b7be7..f0fa4523322 100644 --- a/lib/active_merchant/billing/gateways/so_easy_pay.rb +++ b/lib/active_merchant/billing/gateways/so_easy_pay.rb @@ -114,7 +114,7 @@ def fill_credentials(soap, options) def fill_cardholder(soap, card, options) ch_info = options[:billing_address] || options[:address] - soap.tag!('customerIP',options[:ip].to_s) + soap.tag!('customerIP', options[:ip].to_s) name = card.name || ch_info[:name] soap.tag!('cardHolderName', name.to_s) address = ch_info[:address1] || '' diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb index 544eea6379b..c58ffb0d041 100644 --- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb @@ -321,7 +321,7 @@ def scrub(transcript) private - CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")} + CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")} CURRENCY_CODES['USD'] = '840' def headers diff --git a/lib/active_merchant/billing/gateways/transact_pro.rb b/lib/active_merchant/billing/gateways/transact_pro.rb index 6029f837afb..783e5e18b29 100644 --- a/lib/active_merchant/billing/gateways/transact_pro.rb +++ b/lib/active_merchant/billing/gateways/transact_pro.rb @@ -165,7 +165,7 @@ def add_credentials(post, key=:guid) def parse(body) if body =~ /^ID:/ - body.split('~').reduce(Hash.new) { |h,v| + body.split('~').reduce(Hash.new) { |h, v| m = v.match('(.*?):(.*)') h.merge!(m[1].underscore.to_sym => m[2]) } @@ -180,7 +180,7 @@ def parse(body) def commit(action, parameters, amount=nil) url = (test? ? test_url : live_url) - response = parse(ssl_post(url, post_data(action,parameters))) + response = parse(ssl_post(url, post_data(action, parameters))) Response.new( success_from(response), diff --git a/lib/active_merchant/billing/gateways/transax.rb b/lib/active_merchant/billing/gateways/transax.rb index ac462b23763..336a7fb31c3 100644 --- a/lib/active_merchant/billing/gateways/transax.rb +++ b/lib/active_merchant/billing/gateways/transax.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__),'smart_ps.rb') +require File.join(File.dirname(__FILE__), 'smart_ps.rb') module ActiveMerchant #:nodoc: module Billing #:nodoc: diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb index eaf6cf4900b..416824a5d38 100644 --- a/lib/active_merchant/billing/gateways/trust_commerce.rb +++ b/lib/active_merchant/billing/gateways/trust_commerce.rb @@ -403,7 +403,7 @@ def parse(body) results = {} body.split(/\n/).each do |pair| - key,val = pair.split(/=/) + key, val = pair.split(/=/) results[key] = val end diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb index 90a0adb9f64..23077a0fd87 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb @@ -1297,7 +1297,7 @@ def build_get_account_details(soap, options) def build_customer_data(soap, options) soap.CustomerData 'xsi:type' => 'ns1:CustomerObject' do - CUSTOMER_OPTIONS.each do |k,v| + CUSTOMER_OPTIONS.each do |k, v| build_tag soap, v[0], v[1], options[k] end build_billing_address soap, options @@ -1370,7 +1370,7 @@ def build_customer_payment_methods(soap, options) def build_customer_transaction(soap, options) soap.Parameters 'xsi:type' => 'ns1:CustomerTransactionRequest' do build_transaction_detail soap, options - CUSTOMER_TRANSACTION_REQUEST_OPTIONS.each do |k,v| + CUSTOMER_TRANSACTION_REQUEST_OPTIONS.each do |k, v| build_tag soap, v[0], v[1], options[k] end build_custom_fields soap, options @@ -1382,7 +1382,7 @@ def build_customer_transaction(soap, options) def build_transaction_request_object(soap, options, name='Params') soap.tag! name, 'xsi:type' => 'ns1:TransactionRequestObject' do - TRANSACTION_REQUEST_OBJECT_OPTIONS.each do |k,v| + TRANSACTION_REQUEST_OBJECT_OPTIONS.each do |k, v| build_tag soap, v[0], v[1], options[k] end case @@ -1406,10 +1406,10 @@ def build_transaction_request_object(soap, options, name='Params') def build_transaction_detail(soap, options) soap.Details 'xsi:type' => 'ns1:TransactionDetail' do - TRANSACTION_DETAIL_OPTIONS.each do |k,v| + TRANSACTION_DETAIL_OPTIONS.each do |k, v| build_tag soap, v[0], v[1], options[k] end - TRANSACTION_DETAIL_MONEY_OPTIONS.each do |k,v| + TRANSACTION_DETAIL_MONEY_OPTIONS.each do |k, v| build_tag soap, v[0], v[1], amount(options[k]) end end @@ -1425,7 +1425,7 @@ def build_credit_card_data(soap, options) end build_tag soap, :string, 'CardCode', options[:payment_method].verification_value build_tag soap, :boolean, 'CardPresent', options[:card_present] || false - CREDIT_CARD_DATA_OPTIONS.each do |k,v| + CREDIT_CARD_DATA_OPTIONS.each do |k, v| build_tag soap, v[0], v[1], options[k] end end @@ -1445,7 +1445,7 @@ def build_check_data(soap, options) build_tag soap, :string, 'Account', options[:payment_method].account_number build_tag soap, :string, 'Routing', options[:payment_method].routing_number build_tag soap, :string, 'AccountType', options[:payment_method].account_type.capitalize - CHECK_DATA_OPTIONS.each do |k,v| + CHECK_DATA_OPTIONS.each do |k, v| build_tag soap, v[0], v[1], options[k] end end @@ -1457,7 +1457,7 @@ def build_recurring_billing(soap, options) build_tag soap, :double, 'Amount', amount(options[:recurring][:amount]) build_tag soap, :string, 'Next', options[:recurring][:next].strftime('%Y-%m-%d') if options[:recurring][:next] build_tag soap, :string, 'Expire', options[:recurring][:expire].strftime('%Y-%m-%d') if options[:recurring][:expire] - RECURRING_BILLING_OPTIONS.each do |k,v| + RECURRING_BILLING_OPTIONS.each do |k, v| build_tag soap, v[0], v[1], options[:recurring][k] end end @@ -1480,7 +1480,7 @@ def build_billing_address(soap, options) options[:billing_address][:first_name], options[:billing_address][:last_name] = split_names(options[:billing_address][:name]) end soap.BillingAddress 'xsi:type' => 'ns1:Address' do - ADDRESS_OPTIONS.each do |k,v| + ADDRESS_OPTIONS.each do |k, v| build_tag soap, v[0], v[1], options[:billing_address][k] end end @@ -1493,7 +1493,7 @@ def build_shipping_address(soap, options) options[:shipping_address][:first_name], options[:shipping_address][:last_name] = split_names(options[:shipping_address][:name]) end soap.ShippingAddress 'xsi:type' => 'ns1:Address' do - ADDRESS_OPTIONS.each do |k,v| + ADDRESS_OPTIONS.each do |k, v| build_tag soap, v[0], v[1], options[:shipping_address][k] end end diff --git a/lib/active_merchant/billing/gateways/viaklix.rb b/lib/active_merchant/billing/gateways/viaklix.rb index 4e82980e7f1..af2b009d410 100644 --- a/lib/active_merchant/billing/gateways/viaklix.rb +++ b/lib/active_merchant/billing/gateways/viaklix.rb @@ -73,12 +73,12 @@ def add_customer_data(form, options) form[:customer_code] = options[:customer].to_s.slice(0, 10) unless options[:customer].blank? end - def add_invoice(form,options) + def add_invoice(form, options) form[:invoice_number] = (options[:order_id] || options[:invoice]).to_s.slice(0, 10) form[:description] = options[:description].to_s.slice(0, 255) end - def add_address(form,options) + def add_address(form, options) billing_address = options[:billing_address] || options[:address] if billing_address diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb index c15d4fdde1c..96eecc7d3a8 100644 --- a/lib/active_merchant/billing/gateways/visanet_peru.rb +++ b/lib/active_merchant/billing/gateways/visanet_peru.rb @@ -82,7 +82,7 @@ def scrub(transcript) private - CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")} + CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")} CURRENCY_CODES['USD'] = 840 CURRENCY_CODES['PEN'] = 604 diff --git a/lib/active_merchant/billing/gateways/wirecard.rb b/lib/active_merchant/billing/gateways/wirecard.rb index d04ddc569e5..9f412cf48ae 100644 --- a/lib/active_merchant/billing/gateways/wirecard.rb +++ b/lib/active_merchant/billing/gateways/wirecard.rb @@ -140,7 +140,7 @@ def scrub(transcript) private def clean_description(description) - description.to_s.slice(0,32).encode('US-ASCII', invalid: :replace, undef: :replace, replace: '?') + description.to_s.slice(0, 32).encode('US-ASCII', invalid: :replace, undef: :replace, replace: '?') end def prepare_options_hash(options) diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index b758032d61f..57cf72a9100 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -175,7 +175,7 @@ def build_authorization_request(money, payment_method, options) end def order_tag_attributes(options) - { 'orderCode' => options[:order_id], 'installationId' => options[:inst_id] || @options[:inst_id] }.reject{|_,v| !v} + { 'orderCode' => options[:order_id], 'installationId' => options[:inst_id] || @options[:inst_id] }.reject{|_, v| !v} end def build_capture_request(money, authorization, options) @@ -423,7 +423,7 @@ def required_status_message(raw, success_criteria) end def authorization_from(raw) - pair = raw.detect{|k,v| k.to_s =~ /_order_code$/} + pair = raw.detect{|k, v| k.to_s =~ /_order_code$/} (pair ? pair.last : nil) end diff --git a/lib/active_merchant/country.rb b/lib/active_merchant/country.rb index 996647a975a..34710a2572e 100644 --- a/lib/active_merchant/country.rb +++ b/lib/active_merchant/country.rb @@ -39,7 +39,7 @@ class Country def initialize(options = {}) @name = options.delete(:name) - @codes = options.collect{|k,v| CountryCode.new(v)} + @codes = options.collect{|k, v| CountryCode.new(v)} end def code(format) diff --git a/lib/support/ssl_verify.rb b/lib/support/ssl_verify.rb index 28189db7837..5570e7fde47 100644 --- a/lib/support/ssl_verify.rb +++ b/lib/support/ssl_verify.rb @@ -23,7 +23,7 @@ def test_gateways end uri = URI.parse(g.live_url) - result,message = ssl_verify_peer?(uri) + result, message = ssl_verify_peer?(uri) case result when :success print '.' diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb index 876a02f65f0..eed3b72531f 100644 --- a/test/remote/gateways/remote_beanstream_test.rb +++ b/test/remote/gateways/remote_beanstream_test.rb @@ -309,7 +309,7 @@ def test_invalid_login end def test_successful_add_to_vault_with_store_method - assert response = @gateway.store(@visa,@options) + assert response = @gateway.store(@visa, @options) assert_equal 'Operation Successful', response.message assert_success response assert_not_nil response.params['customer_vault_id'] diff --git a/test/remote/gateways/remote_ct_payment_certification_test.rb b/test/remote/gateways/remote_ct_payment_certification_test.rb index b2a9784e416..7a4ef3988f4 100644 --- a/test/remote/gateways/remote_ct_payment_certification_test.rb +++ b/test/remote/gateways/remote_ct_payment_certification_test.rb @@ -10,7 +10,7 @@ def setup billing_address: address, description: 'Store Purchase', merchant_terminal_number: ' ', - order_id: generate_unique_id[0,11] + order_id: generate_unique_id[0, 11] } end @@ -59,7 +59,7 @@ def test7 response = @gateway.authorize(@amount, @credit_card, @options) print_result(7, response) - capture_response = @gateway.capture(@amount, response.authorization, @options.merge(order_id: generate_unique_id[0,11])) + capture_response = @gateway.capture(@amount, response.authorization, @options.merge(order_id: generate_unique_id[0, 11])) print_result(10, capture_response) end @@ -69,14 +69,14 @@ def test8 response = @gateway.authorize(@amount, @credit_card, @options) print_result(8, response) - capture_response = @gateway.capture(@amount, response.authorization, @options.merge(order_id: generate_unique_id[0,11])) + capture_response = @gateway.capture(@amount, response.authorization, @options.merge(order_id: generate_unique_id[0, 11])) print_result(11, capture_response) end def test9 @credit_card = credit_card('341400000000000', month: '07', year: 2025, verification_value: '1234') @credit_card.brand = 'american_express' - response = @gateway.authorize(@amount, @credit_card, @options.merge(order_id: generate_unique_id[0,11])) + response = @gateway.authorize(@amount, @credit_card, @options.merge(order_id: generate_unique_id[0, 11])) print_result(9, response) capture_response = @gateway.capture(@amount, response.authorization, @options) diff --git a/test/remote/gateways/remote_ct_payment_test.rb b/test/remote/gateways/remote_ct_payment_test.rb index 43a198bd09a..4fd0ba8738a 100644 --- a/test/remote/gateways/remote_ct_payment_test.rb +++ b/test/remote/gateways/remote_ct_payment_test.rb @@ -10,7 +10,7 @@ def setup @options = { billing_address: address, description: 'Store Purchase', - order_id: generate_unique_id[0,11], + order_id: generate_unique_id[0, 11], email: 'bigbird@sesamestreet.com' } @@ -32,7 +32,7 @@ def test_successful_authorize_and_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert capture = @gateway.capture(@amount, auth.authorization, @options.merge(order_id: generate_unique_id[0,11])) + assert capture = @gateway.capture(@amount, auth.authorization, @options.merge(order_id: generate_unique_id[0, 11])) assert_success capture assert_equal 'APPROVED', capture.message end @@ -47,7 +47,7 @@ def test_partial_capture auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth - assert capture = @gateway.capture(@amount-1, auth.authorization, @options.merge(order_id: generate_unique_id[0,11])) + assert capture = @gateway.capture(@amount-1, auth.authorization, @options.merge(order_id: generate_unique_id[0, 11])) assert_success capture end @@ -61,7 +61,7 @@ def test_successful_refund purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase - assert refund = @gateway.refund(@amount, purchase.authorization, @options.merge(order_id: generate_unique_id[0,11])) + assert refund = @gateway.refund(@amount, purchase.authorization, @options.merge(order_id: generate_unique_id[0, 11])) assert_success refund assert_equal 'APPROVED', refund.message end @@ -70,12 +70,12 @@ def test_partial_refund purchase = @gateway.purchase(@amount, @credit_card, @options) assert_success purchase - assert refund = @gateway.refund(@amount-1, purchase.authorization, @options.merge(order_id: generate_unique_id[0,11])) + assert refund = @gateway.refund(@amount-1, purchase.authorization, @options.merge(order_id: generate_unique_id[0, 11])) assert_success refund end def test_failed_refund - response = @gateway.refund(@amount, '0123456789asd;0123456789asdf;12345678', @options.merge(order_id: generate_unique_id[0,11])) + response = @gateway.refund(@amount, '0123456789asd;0123456789asdf;12345678', @options.merge(order_id: generate_unique_id[0, 11])) assert_failure response assert_equal 'The original transaction number does not match any actual transaction', response.message end diff --git a/test/remote/gateways/remote_litle_certification_test.rb b/test/remote/gateways/remote_litle_certification_test.rb index c36e352e476..3a9558c701f 100644 --- a/test/remote/gateways/remote_litle_certification_test.rb +++ b/test/remote/gateways/remote_litle_certification_test.rb @@ -854,7 +854,7 @@ def test50 assert_success store_response assert_equal '445711', store_response.params['bin'] assert_equal 'VI', store_response.params['type'] - assert_equal '0123', store_response.params['litleToken'][-4,4] + assert_equal '0123', store_response.params['litleToken'][-4, 4] assert_equal '801', store_response.params['response'] assert_equal 'Account number was successfully registered', store_response.message puts "Test #{options[:order_id]}: #{txn_id(response)}" @@ -889,7 +889,7 @@ def test52 assert_equal '445711', store_response.params['bin'] assert_equal 'VI', store_response.params['type'] assert_equal '802', store_response.params['response'] - assert_equal '0123', store_response.params['litleToken'][-4,4] + assert_equal '0123', store_response.params['litleToken'][-4, 4] puts "Test #{options[:order_id]}: #{txn_id(store_response)}" end @@ -944,7 +944,7 @@ def test55 assert response = @gateway.authorize(15000, credit_card, options) assert_success response assert_equal 'Approved', response.message - assert_equal '0196', response.params['tokenResponse_litleToken'][-4,4] + assert_equal '0196', response.params['tokenResponse_litleToken'][-4, 4] assert %w(801 802).include? response.params['tokenResponse_tokenResponseCode'] assert_equal 'MC', response.params['tokenResponse_type'] assert_equal '543510', response.params['tokenResponse_bin'] @@ -984,7 +984,7 @@ def test57_58 assert_success response assert_equal 'Approved', response.message - assert_equal '0196', response.params['tokenResponse_litleToken'][-4,4] + assert_equal '0196', response.params['tokenResponse_litleToken'][-4, 4] assert %w(801 802).include? response.params['tokenResponse_tokenResponseCode'] assert_equal 'MC', response.params['tokenResponse_type'] assert_equal '543510', response.params['tokenResponse_bin'] diff --git a/test/remote/gateways/remote_merchant_ware_version_four_test.rb b/test/remote/gateways/remote_merchant_ware_version_four_test.rb index 9d02a5514d2..155bdc2e460 100644 --- a/test/remote/gateways/remote_merchant_ware_version_four_test.rb +++ b/test/remote/gateways/remote_merchant_ware_version_four_test.rb @@ -8,12 +8,12 @@ def setup @declined_card = credit_card('1234567890123') @options = { - :order_id => generate_unique_id[0,8], + :order_id => generate_unique_id[0, 8], :billing_address => address } @reference_purchase_options = { - :order_id => generate_unique_id[0,8] + :order_id => generate_unique_id[0, 8] } end diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb index ccceb0fc5ed..62fe766500c 100644 --- a/test/remote/gateways/remote_orbital_test.rb +++ b/test/remote/gateways/remote_orbital_test.rb @@ -231,7 +231,7 @@ def test_auth_capture_transactions # ==== Section C def test_mark_for_capture_transactions - [[:visa, 3000],[:mc, 4100],[:amex, 105500],[:ds, 1000],[:jcb, 2900]].each do |suite| + [[:visa, 3000], [:mc, 4100], [:amex, 105500], [:ds, 1000], [:jcb, 2900]].each do |suite| amount = suite[1] card = credit_card(@cards[suite[0]]) assert auth_response = @gateway.authorize(amount, card, @options) @@ -247,7 +247,7 @@ def test_mark_for_capture_transactions # ==== Section D def test_refund_transactions - [[:visa, 1200],[:mc, 1100],[:amex, 105500],[:ds, 1000],[:jcb, 2900]].each do |suite| + [[:visa, 1200], [:mc, 1100], [:amex, 105500], [:ds, 1000], [:jcb, 2900]].each do |suite| amount = suite[1] card = credit_card(@cards[suite[0]]) assert purchase_response = @gateway.purchase(amount, card, @options) diff --git a/test/remote/gateways/remote_payflow_uk_test.rb b/test/remote/gateways/remote_payflow_uk_test.rb index c2aebf853ec..5a5df22e94a 100644 --- a/test/remote/gateways/remote_payflow_uk_test.rb +++ b/test/remote/gateways/remote_payflow_uk_test.rb @@ -142,7 +142,7 @@ def test_duplicate_request_id :password => @password ) - request_id = Digest::SHA1.hexdigest(rand.to_s).slice(0,32) + request_id = Digest::SHA1.hexdigest(rand.to_s).slice(0, 32) gateway.expects(:generate_unique_id).times(2).returns(request_id) response1 = gateway.purchase(100, @creditcard, @options) diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb index b4760f3f387..e3afb520134 100644 --- a/test/remote/gateways/remote_usa_epay_transaction_test.rb +++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb @@ -63,7 +63,7 @@ def test_successful_purchase_with_extra_test_mode end def test_successful_purchase_with_email_receipt - assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:email => 'hank@hill.com',:cust_receipt => 'Yes')) + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:email => 'hank@hill.com', :cust_receipt => 'Yes')) assert_equal 'Success', response.message assert_success response end diff --git a/test/test_helper.rb b/test/test_helper.rb index 90a557c2eb9..99f482ce780 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -273,7 +273,7 @@ def symbolize_keys(hash) return unless hash.is_a?(Hash) hash.symbolize_keys! - hash.each{|k,v| symbolize_keys(v)} + hash.each{|k, v| symbolize_keys(v)} end end end diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index b13264ae47f..7c89a988d05 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -726,12 +726,12 @@ def test_that_setting_a_wiredump_device_on_the_gateway_sets_the_braintree_logger end def test_solution_id_is_added_to_create_transaction_parameters - assert_nil @gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'),{})[:channel] + assert_nil @gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'), {})[:channel] ActiveMerchant::Billing::BraintreeBlueGateway.application_id = 'ABC123' - assert_equal @gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'),{})[:channel], 'ABC123' + assert_equal @gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'), {})[:channel], 'ABC123' gateway = BraintreeBlueGateway.new(:merchant_id => 'test', :public_key => 'test', :private_key => 'test', channel: 'overidden-channel') - assert_equal gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'),{})[:channel], 'overidden-channel' + assert_equal gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'), {})[:channel], 'overidden-channel' ensure ActiveMerchant::Billing::BraintreeBlueGateway.application_id = nil end diff --git a/test/unit/gateways/braintree_orange_test.rb b/test/unit/gateways/braintree_orange_test.rb index 80eebb19dfc..399580184fb 100644 --- a/test/unit/gateways/braintree_orange_test.rb +++ b/test/unit/gateways/braintree_orange_test.rb @@ -96,7 +96,7 @@ def test_add_address def test_add_shipping_address result = {} - @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'},'shipping' ) + @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'}, 'shipping' ) assert_equal ['shipping_address1', 'shipping_city', 'shipping_company', 'shipping_country', 'shipping_phone', 'shipping_state', 'shipping_zip'], result.stringify_keys.keys.sort assert_equal 'CO', result['shipping_state'] assert_equal '164 Waverley Street', result['shipping_address1'] diff --git a/test/unit/gateways/card_connect_test.rb b/test/unit/gateways/card_connect_test.rb index d0e424e7be2..e4a49a1541b 100644 --- a/test/unit/gateways/card_connect_test.rb +++ b/test/unit/gateways/card_connect_test.rb @@ -79,7 +79,7 @@ def test_failed_authorize def test_successful_capture @gateway.expects(:ssl_request).returns(successful_capture_response) - response = @gateway.capture(@amount,'363168161558', @options) + response = @gateway.capture(@amount, '363168161558', @options) assert_success response assert_equal '363168161558', response.authorization diff --git a/test/unit/gateways/epay_test.rb b/test/unit/gateways/epay_test.rb index 6c4554f5969..59becd05499 100644 --- a/test/unit/gateways/epay_test.rb +++ b/test/unit/gateways/epay_test.rb @@ -39,7 +39,7 @@ def test_invalid_characters_in_response end def test_failed_response_on_purchase - @gateway.expects(:raw_ssl_request).returns(Net::HTTPBadRequest.new(1.0, 400,'Bad Request')) + @gateway.expects(:raw_ssl_request).returns(Net::HTTPBadRequest.new(1.0, 400, 'Bad Request')) assert response = @gateway.authorize(100, @credit_card) assert_equal 400, response.params['response_code'] diff --git a/test/unit/gateways/eway_rapid_test.rb b/test/unit/gateways/eway_rapid_test.rb index 41aed4196d0..15788011e99 100644 --- a/test/unit/gateways/eway_rapid_test.rb +++ b/test/unit/gateways/eway_rapid_test.rb @@ -189,7 +189,7 @@ def test_partner_id_truncates_to_50_characters stub_comms do @gateway.purchase(200, @credit_card, partner_id: partner_string) end.check_request do |endpoint, data, headers| - assert_match(%r{"PartnerID":"#{partner_string.slice(0,50)}"}, data) + assert_match(%r{"PartnerID":"#{partner_string.slice(0, 50)}"}, data) end.respond_with(successful_purchase_response) end diff --git a/test/unit/gateways/hps_test.rb b/test/unit/gateways/hps_test.rb index f6371b26394..107ec989b05 100644 --- a/test/unit/gateways/hps_test.rb +++ b/test/unit/gateways/hps_test.rb @@ -90,7 +90,7 @@ def test_failed_capture def test_successful_refund @gateway.expects(:ssl_post).returns(successful_refund_response) - refund = @gateway.refund(@amount,'transaction_id') + refund = @gateway.refund(@amount, 'transaction_id') assert_instance_of Response, refund assert_success refund assert_equal '0', refund.params['GatewayRspCode'] @@ -99,7 +99,7 @@ def test_successful_refund def test_failed_refund @gateway.expects(:ssl_post).returns(failed_refund_response) - refund = @gateway.refund(@amount,'169054') + refund = @gateway.refund(@amount, '169054') assert_instance_of Response, refund assert_failure refund end @@ -124,7 +124,7 @@ def test_successful_purchase_with_swipe_no_encryption @gateway.expects(:ssl_post).returns(successful_swipe_purchase_response) @credit_card.track_data = '%B547888879888877776?;5473500000000014=25121019999888877776?' - response = @gateway.purchase(@amount,@credit_card,@options) + response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal 'Success', response.message end @@ -133,7 +133,7 @@ def test_failed_purchase_with_swipe_bad_track_data @gateway.expects(:ssl_post).returns(failed_swipe_purchase_response) @credit_card.track_data = '%B547888879888877776?;?' - response = @gateway.purchase(@amount,@credit_card,@options) + response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response assert_equal 'Transaction was rejected because the track data could not be read.', response.message @@ -144,7 +144,7 @@ def test_successful_purchase_with_swipe_encryption_type_01 @options[:encryption_type] = '01' @credit_card.track_data = '&lt;E1052711%B5473501000000014^MC TEST CARD^251200000000000000000000000000000000?|GVEY/MKaKXuqqjKRRueIdCHPPoj1gMccgNOtHC41ymz7bIvyJJVdD3LW8BbwvwoenI+|+++++++C4cI2zjMp|11;5473501000000014=25120000000000000000?|8XqYkQGMdGeiIsgM0pzdCbEGUDP|+++++++C4cI2zjMp|00|||/wECAQECAoFGAgEH2wYcShV78RZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0PX50qfj4dt0lu9oFBESQQNkpoxEVpCW3ZKmoIV3T93zphPS3XKP4+DiVlM8VIOOmAuRrpzxNi0TN/DWXWSjUC8m/PI2dACGdl/hVJ/imfqIs68wYDnp8j0ZfgvM26MlnDbTVRrSx68Nzj2QAgpBCHcaBb/FZm9T7pfMr2Mlh2YcAt6gGG1i2bJgiEJn8IiSDX5M2ybzqRT86PCbKle/XCTwFFe1X|&gt;' - response = @gateway.purchase(@amount,@credit_card,@options) + response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal 'Success', response.message @@ -157,7 +157,7 @@ def test_successful_purchase_with_swipe_encryption_type_02 @options[:encrypted_track_number] = 2 @options[:ktb] = '/wECAQECAoFGAgEH3QgVTDT6jRZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0Nkt08KRSPigRYcr1HVgjRFEvtUBy+VcCKlOGA3871r3SOkqDvH2+30insdLHmhTLCc4sC2IhlobvWnutAfylKk2GLspH/pfEnVKPvBv0hBnF4413+QIRlAuGX6+qZjna2aMl0kIsjEY4N6qoVq2j5/e5I+41+a2pbm61blv2PEMAmyuCcAbN3/At/1kRZNwN6LSUg9VmJO83kOglWBe1CbdFtncq' @credit_card.track_data = '7SV2BK6ESQPrq01iig27E74SxMg' - response = @gateway.purchase(@amount,@credit_card,@options) + response = @gateway.purchase(@amount, @credit_card, @options) assert_success response assert_equal 'Success', response.message diff --git a/test/unit/gateways/nab_transact_test.rb b/test/unit/gateways/nab_transact_test.rb index d6a0af00347..d02ebadce3a 100644 --- a/test/unit/gateways/nab_transact_test.rb +++ b/test/unit/gateways/nab_transact_test.rb @@ -222,7 +222,7 @@ def check_transaction_type(type) end def valid_metadata(name, location) - return <<-XML.gsub(/^\s{4}/,'').gsub(/\n/, '') + return <<-XML.gsub(/^\s{4}/, '').gsub(/\n/, '') <metadata><meta name="ca_name" value="#{name}"/><meta name="ca_location" value="#{location}"/></metadata> XML end @@ -241,7 +241,7 @@ def failed_login_response end def successful_purchase_response - <<-XML.gsub(/^\s{4}/,'') + <<-XML.gsub(/^\s{4}/, '') <?xml version="1.0" encoding="UTF-8"?> <NABTransactMessage> <MessageInfo> @@ -284,7 +284,7 @@ def successful_purchase_response end def failed_purchase_response - <<-XML.gsub(/^\s{4}/,'') + <<-XML.gsub(/^\s{4}/, '') <?xml version="1.0" encoding="UTF-8"?> <NABTransactMessage> <MessageInfo> @@ -327,7 +327,7 @@ def failed_purchase_response end def successful_authorize_response - <<-XML.gsub(/^\s{4}/,'') + <<-XML.gsub(/^\s{4}/, '') <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?> <NABTransactMessage> <MessageInfo> @@ -372,7 +372,7 @@ def successful_authorize_response end def successful_refund_response - <<-XML.gsub(/^\s{4}/,'') + <<-XML.gsub(/^\s{4}/, '') <?xml version="1.0" encoding="UTF-8"?> <NABTransactMessage> <MessageInfo> @@ -415,7 +415,7 @@ def successful_refund_response end def failed_refund_response - <<-XML.gsub(/^\s{4}/,'') + <<-XML.gsub(/^\s{4}/, '') <?xml version="1.0" encoding="UTF-8"?> <NABTransactMessage> <MessageInfo> diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb index 3c7ccf84ae3..7302649b7da 100644 --- a/test/unit/gateways/opp_test.rb +++ b/test/unit/gateways/opp_test.rb @@ -188,18 +188,18 @@ def post_scrubbed def successful_response(type, id) OppMockResponse.new(200, - JSON.generate({'id' => id,'paymentType' => type,'paymentBrand' => 'VISA','amount' => '1.00','currency' => 'EUR',"des - criptor" => '5410.9959.0306 OPP_Channel ','result' => {'code' => '000.100.110','description' => "Request successfully processed in 'Merchant in Integrator Test Mode'"},'card' => {"bin - " => '420000','last4Digits' => '0000','holder' => 'Longbob Longsen','expiryMonth' => '05','expiryYear' => '2018'},'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage',"time - stamp" => '2015-06-20 19:31:01+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_4453edbc001f405da557c05cb3c3add9'}) + JSON.generate({'id' => id, 'paymentType' => type, 'paymentBrand' => 'VISA', 'amount' => '1.00', 'currency' => 'EUR', "des + criptor" => '5410.9959.0306 OPP_Channel ', 'result' => {'code' => '000.100.110', 'description' => "Request successfully processed in 'Merchant in Integrator Test Mode'"}, 'card' => {"bin + " => '420000', 'last4Digits' => '0000', 'holder' => 'Longbob Longsen', 'expiryMonth' => '05', 'expiryYear' => '2018'}, 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage', "time + stamp" => '2015-06-20 19:31:01+0000', 'ndc' => '8a8294174b7ecb28014b9699220015ca_4453edbc001f405da557c05cb3c3add9'}) ) end def failed_response(type, id, code='100.100.101') OppMockResponse.new(400, - JSON.generate({'id' => id,'paymentType' => type,'paymentBrand' => 'VISA','result' => {'code' => code,"des - cription" => 'invalid creditcard, bank account number or bank name'},'card' => {'bin' => '444444','last4Digits' => '4444','holder' => 'Longbob Longsen','expiryMonth' => '05','expiryYear' => '2018'}, - 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage','timestamp' => '2015-06-20 20:40:26+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d'}) + JSON.generate({'id' => id, 'paymentType' => type, 'paymentBrand' => 'VISA', 'result' => {'code' => code, "des + cription" => 'invalid creditcard, bank account number or bank name'}, 'card' => {'bin' => '444444', 'last4Digits' => '4444', 'holder' => 'Longbob Longsen', 'expiryMonth' => '05', 'expiryYear' => '2018'}, + 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage', 'timestamp' => '2015-06-20 20:40:26+0000', 'ndc' => '8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d'}) ) end diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb index b88d15665f7..45d34d08ab2 100644 --- a/test/unit/gateways/optimal_payment_test.rb +++ b/test/unit/gateways/optimal_payment_test.rb @@ -101,7 +101,7 @@ def test_purchase_from_any_other_country_includes_region_field def test_purchase_with_shipping_address @options[:shipping_address] = {:country => 'CA'} @gateway.expects(:ssl_post).with do |url, data| - xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=','') + xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=', '') doc = Nokogiri::XML.parse(CGI.unescape(xml)) doc.xpath('//xmlns:shippingDetails/xmlns:country').first.text == 'CA' && doc.to_s.include?('<shippingDetails>') end.returns(successful_purchase_response) @@ -112,7 +112,7 @@ def test_purchase_with_shipping_address def test_purchase_without_shipping_address @options[:shipping_address] = nil @gateway.expects(:ssl_post).with do |url, data| - xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=','') + xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=', '') doc = Nokogiri::XML.parse(CGI.unescape(xml)) doc.to_s.include?('<shippingDetails>') == false end.returns(successful_purchase_response) diff --git a/test/unit/gateways/paypal/paypal_common_api_test.rb b/test/unit/gateways/paypal/paypal_common_api_test.rb index 5193e20846b..588406406e0 100644 --- a/test/unit/gateways/paypal/paypal_common_api_test.rb +++ b/test/unit/gateways/paypal/paypal_common_api_test.rb @@ -118,13 +118,13 @@ def test_balance_cleans_up_currencies_values_like_0 end def test_build_do_authorize_request - request = REXML::Document.new(@gateway.send(:build_do_authorize,123, 100, :currency => 'USD')) + request = REXML::Document.new(@gateway.send(:build_do_authorize, 123, 100, :currency => 'USD')) assert_equal '123', REXML::XPath.first(request, '//DoAuthorizationReq/DoAuthorizationRequest/TransactionID').text assert_equal '1.00', REXML::XPath.first(request, '//DoAuthorizationReq/DoAuthorizationRequest/Amount').text end def test_build_manage_pending_transaction_status_request - request = REXML::Document.new(@gateway.send(:build_manage_pending_transaction_status,123, 'Accept')) + request = REXML::Document.new(@gateway.send(:build_manage_pending_transaction_status, 123, 'Accept')) assert_equal '123', REXML::XPath.first(request, '//ManagePendingTransactionStatusReq/ManagePendingTransactionStatusRequest/TransactionID').text assert_equal 'Accept', REXML::XPath.first(request, '//ManagePendingTransactionStatusReq/ManagePendingTransactionStatusRequest/Action').text end diff --git a/test/unit/gateways/qvalent_test.rb b/test/unit/gateways/qvalent_test.rb index 12a53e48d1d..f7fa337755a 100644 --- a/test/unit/gateways/qvalent_test.rb +++ b/test/unit/gateways/qvalent_test.rb @@ -55,7 +55,7 @@ def test_failed_authorize end.respond_with(failed_authorize_response) assert_failure response - assert_equal 'Expired card',response.message + assert_equal 'Expired card', response.message assert response.test? end diff --git a/test/unit/gateways/redsys_test.rb b/test/unit/gateways/redsys_test.rb index 4a5e9ce3816..741b5ae9eed 100644 --- a/test/unit/gateways/redsys_test.rb +++ b/test/unit/gateways/redsys_test.rb @@ -256,7 +256,7 @@ def test_whitespace_string_cvv_transcript_scrubbing # one with card and another without. def purchase_request - "entrada=%3CDATOSENTRADA%3E%0A++%3CDS_Version%3E0.1%3C%2FDS_Version%3E%0A++%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%0A++%3CDS_MERCHANT_AMOUNT%3E123%3C%2FDS_MERCHANT_AMOUNT%3E%0A++%3CDS_MERCHANT_ORDER%3E1001%3C%2FDS_MERCHANT_ORDER%3E%0A++%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%0A++%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%0A++%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%0A++%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%0A++%3CDS_MERCHANT_MERCHANTSIGNATURE%3Eb98b606a6a588d8c45c239f244160efbbe30b4a8%3C%2FDS_MERCHANT_MERCHANTSIGNATURE%3E%0A++%3CDS_MERCHANT_TITULAR%3ELongbob+Longsen%3C%2FDS_MERCHANT_TITULAR%3E%0A++%3CDS_MERCHANT_PAN%3E4242424242424242%3C%2FDS_MERCHANT_PAN%3E%0A++%3CDS_MERCHANT_EXPIRYDATE%3E#{(Time.now.year + 1).to_s.slice(2,2)}09%3C%2FDS_MERCHANT_EXPIRYDATE%3E%0A++%3CDS_MERCHANT_CVV2%3E123%3C%2FDS_MERCHANT_CVV2%3E%0A%3C%2FDATOSENTRADA%3E%0A" + "entrada=%3CDATOSENTRADA%3E%0A++%3CDS_Version%3E0.1%3C%2FDS_Version%3E%0A++%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%0A++%3CDS_MERCHANT_AMOUNT%3E123%3C%2FDS_MERCHANT_AMOUNT%3E%0A++%3CDS_MERCHANT_ORDER%3E1001%3C%2FDS_MERCHANT_ORDER%3E%0A++%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%0A++%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%0A++%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%0A++%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%0A++%3CDS_MERCHANT_MERCHANTSIGNATURE%3Eb98b606a6a588d8c45c239f244160efbbe30b4a8%3C%2FDS_MERCHANT_MERCHANTSIGNATURE%3E%0A++%3CDS_MERCHANT_TITULAR%3ELongbob+Longsen%3C%2FDS_MERCHANT_TITULAR%3E%0A++%3CDS_MERCHANT_PAN%3E4242424242424242%3C%2FDS_MERCHANT_PAN%3E%0A++%3CDS_MERCHANT_EXPIRYDATE%3E#{(Time.now.year + 1).to_s.slice(2, 2)}09%3C%2FDS_MERCHANT_EXPIRYDATE%3E%0A++%3CDS_MERCHANT_CVV2%3E123%3C%2FDS_MERCHANT_CVV2%3E%0A%3C%2FDATOSENTRADA%3E%0A" end def purchase_request_with_credit_card_token diff --git a/test/unit/gateways/secure_pay_au_test.rb b/test/unit/gateways/secure_pay_au_test.rb index e99997f6d4e..5d995aab6f8 100644 --- a/test/unit/gateways/secure_pay_au_test.rb +++ b/test/unit/gateways/secure_pay_au_test.rb @@ -201,7 +201,7 @@ def test_supports_scrubbing? private def successful_store_response - <<-XML.gsub(/^\s{4}/,'') + <<-XML.gsub(/^\s{4}/, '') <?xml version="1.0" encoding="UTF-8"?> <SecurePayMessage> <MessageInfo> @@ -240,7 +240,7 @@ def successful_store_response end def successful_unstore_response - <<-XML.gsub(/^\s{4}/,'') + <<-XML.gsub(/^\s{4}/, '') <?xml version="1.0" encoding="UTF-8"?> <SecurePayMessage> <MessageInfo> @@ -272,7 +272,7 @@ def successful_unstore_response end def successful_triggered_payment_response - <<-XML.gsub(/^\s{4}/,'') + <<-XML.gsub(/^\s{4}/, '') <?xml version="1.0" encoding="UTF-8"?> <SecurePayMessage> <MessageInfo> @@ -318,7 +318,7 @@ def failed_login_response end def successful_purchase_response - <<-XML.gsub(/^\s{4}/,'') + <<-XML.gsub(/^\s{4}/, '') <?xml version="1.0" encoding="UTF-8"?> <SecurePayMessage> <MessageInfo> @@ -365,7 +365,7 @@ def successful_purchase_response end def failed_purchase_response - <<-XML.gsub(/^\s{4}/,'') + <<-XML.gsub(/^\s{4}/, '') <?xml version="1.0" encoding="UTF-8"?> <SecurePayMessage> <MessageInfo> @@ -412,7 +412,7 @@ def failed_purchase_response end def successful_live_purchase_response - <<-XML.gsub(/^\s{4}/,'') + <<-XML.gsub(/^\s{4}/, '') <?xml version="1.0" encoding="UTF-8"?> <SecurePayMessage> <MessageInfo> diff --git a/test/unit/gateways/securion_pay_test.rb b/test/unit/gateways/securion_pay_test.rb index 2880ca98a15..198c2c920f8 100644 --- a/test/unit/gateways/securion_pay_test.rb +++ b/test/unit/gateways/securion_pay_test.rb @@ -87,7 +87,7 @@ def test_invalid_raw_response def test_client_data_submitted_with_purchase stub_comms(@gateway, :ssl_request) do updated_options = @options.merge({ description: 'test charge', ip: '127.127.127.127', user_agent: 'browser XXX', referrer: 'http://www.foobar.com', email: 'foo@bar.com' }) - @gateway.purchase(@amount,@credit_card,updated_options) + @gateway.purchase(@amount, @credit_card, updated_options) end.check_request do |method, endpoint, data, headers| assert_match(/description=test\+charge/, data) assert_match(/ip=127\.127\.127\.127/, data) @@ -100,7 +100,7 @@ def test_client_data_submitted_with_purchase def test_client_data_submitted_with_purchase_without_email_or_order stub_comms(@gateway, :ssl_request) do updated_options = @options.merge({ description: 'test charge', ip: '127.127.127.127', user_agent: 'browser XXX', referrer: 'http://www.foobar.com' }) - @gateway.purchase(@amount,@credit_card,updated_options) + @gateway.purchase(@amount, @credit_card, updated_options) end.check_request do |method, endpoint, data, headers| assert_match(/description=test\+charge/, data) assert_match(/ip=127\.127\.127\.127/, data) diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index 0f66d7985ad..b19b6e1fc74 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -938,8 +938,8 @@ def test_destination_amount_is_submitted_for_purchase def test_client_data_submitted_with_purchase stub_comms(@gateway, :ssl_request) do - updated_options = @options.merge({:description => 'a test customer',:ip => '127.127.127.127', :user_agent => 'some browser', :order_id => '42', :email => 'foo@wonderfullyfakedomain.com', :receipt_email => 'receipt-receiver@wonderfullyfakedomain.com', :referrer =>'http://www.shopify.com'}) - @gateway.purchase(@amount,@credit_card,updated_options) + updated_options = @options.merge({:description => 'a test customer', :ip => '127.127.127.127', :user_agent => 'some browser', :order_id => '42', :email => 'foo@wonderfullyfakedomain.com', :receipt_email => 'receipt-receiver@wonderfullyfakedomain.com', :referrer =>'http://www.shopify.com'}) + @gateway.purchase(@amount, @credit_card, updated_options) end.check_request do |method, endpoint, data, headers| assert_match(/description=a\+test\+customer/, data) assert_match(/ip=127\.127\.127\.127/, data) @@ -955,8 +955,8 @@ def test_client_data_submitted_with_purchase def test_client_data_submitted_with_purchase_without_email_or_order stub_comms(@gateway, :ssl_request) do - updated_options = @options.merge({:description => 'a test customer',:ip => '127.127.127.127', :user_agent => 'some browser', :referrer =>'http://www.shopify.com'}) - @gateway.purchase(@amount,@credit_card,updated_options) + updated_options = @options.merge({:description => 'a test customer', :ip => '127.127.127.127', :user_agent => 'some browser', :referrer =>'http://www.shopify.com'}) + @gateway.purchase(@amount, @credit_card, updated_options) end.check_request do |method, endpoint, data, headers| assert_match(/description=a\+test\+customer/, data) assert_match(/ip=127\.127\.127\.127/, data) @@ -970,7 +970,7 @@ def test_client_data_submitted_with_purchase_without_email_or_order def test_client_data_submitted_with_metadata_in_options stub_comms(@gateway, :ssl_request) do updated_options = @options.merge({:metadata => {:this_is_a_random_key_name => 'with a random value', :i_made_up_this_key_too => 'canyoutell'}, :order_id => '42', :email => 'foo@wonderfullyfakedomain.com'}) - @gateway.purchase(@amount,@credit_card,updated_options) + @gateway.purchase(@amount, @credit_card, updated_options) end.check_request do |method, endpoint, data, headers| assert_match(/metadata\[this_is_a_random_key_name\]=with\+a\+random\+value/, data) assert_match(/metadata\[i_made_up_this_key_too\]=canyoutell/, data) From 8fdbbf6840cbf19bf360fc4fe552debc2182451c Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 8 Nov 2018 15:00:31 -0500 Subject: [PATCH 646/677] RuboCop: fix Style/ParenthesesAroundCondition --- .rubocop_todo.yml | 6 ------ lib/active_merchant/billing/gateways/borgun.rb | 2 +- lib/active_merchant/billing/gateways/braintree_blue.rb | 6 +++--- lib/active_merchant/billing/gateways/card_stream.rb | 2 +- lib/active_merchant/billing/gateways/cenpos.rb | 2 +- lib/active_merchant/billing/gateways/checkout.rb | 2 +- lib/active_merchant/billing/gateways/ct_payment.rb | 2 +- lib/active_merchant/billing/gateways/cyber_source.rb | 2 +- lib/active_merchant/billing/gateways/eway.rb | 2 +- lib/active_merchant/billing/gateways/hdfc.rb | 2 +- lib/active_merchant/billing/gateways/hps.rb | 2 +- lib/active_merchant/billing/gateways/payex.rb | 2 +- lib/active_merchant/billing/gateways/paymill.rb | 2 +- lib/active_merchant/billing/gateways/payu_latam.rb | 2 +- lib/active_merchant/billing/gateways/quantum.rb | 2 +- lib/active_merchant/billing/gateways/realex.rb | 2 +- lib/active_merchant/billing/gateways/stripe.rb | 2 +- lib/active_merchant/billing/gateways/telr.rb | 2 +- lib/active_merchant/billing/gateways/visanet_peru.rb | 4 ++-- lib/active_merchant/billing/gateways/wirecard.rb | 2 +- .../billing/gateways/worldpay_online_payments.rb | 2 +- 21 files changed, 23 insertions(+), 29 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ade1c7ede93..cedf33c61f6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -927,12 +927,6 @@ Style/OrAssignment: Style/ParallelAssignment: Enabled: false -# Offense count: 29 -# Cop supports --auto-correct. -# Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. -Style/ParenthesesAroundCondition: - Enabled: false - # Offense count: 877 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb index 26b7fff9ef5..df56f97646d 100644 --- a/lib/active_merchant/billing/gateways/borgun.rb +++ b/lib/active_merchant/billing/gateways/borgun.rb @@ -112,7 +112,7 @@ def parse(xml) body.children.each do |node| if node.text? next - elsif (node.elements.size == 0) + elsif node.elements.size == 0 response[node.name.downcase.to_sym] = node.text else node.elements.each do |childnode| diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index f660e41f64a..8e8f9f6830a 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -279,10 +279,10 @@ def add_credit_card_to_customer(credit_card, options) def scrub_email(email) return nil unless email.present? - return nil if ( + return nil if email !~ /^.+@[^\.]+(\.[^\.]+)+[a-z]$/i || email =~ /\.(con|met)$/i - ) + email end @@ -323,7 +323,7 @@ def map_address(address) :region => address[:state], :postal_code => scrub_zip(address[:zip]), } - if (address[:country] || address[:country_code_alpha2]) + if address[:country] || address[:country_code_alpha2] mapped[:country_code_alpha2] = (address[:country] || address[:country_code_alpha2]) elsif address[:country_name] mapped[:country_name] = address[:country_name] diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb index 190f2fe797b..f5ac54fdb83 100644 --- a/lib/active_merchant/billing/gateways/card_stream.rb +++ b/lib/active_merchant/billing/gateways/card_stream.rb @@ -141,7 +141,7 @@ class CardStreamGateway < Gateway def initialize(options = {}) requires!(options, :login, :shared_secret) @threeds_required = false - if (options[:threeDSRequired]) + if options[:threeDSRequired] ActiveMerchant.deprecated(THREEDSECURE_REQUIRED_DEPRECATION_MESSAGE) @threeds_required = options[:threeDSRequired] end diff --git a/lib/active_merchant/billing/gateways/cenpos.rb b/lib/active_merchant/billing/gateways/cenpos.rb index 2a36063982f..5412821c21e 100644 --- a/lib/active_merchant/billing/gateways/cenpos.rb +++ b/lib/active_merchant/billing/gateways/cenpos.rb @@ -219,7 +219,7 @@ def parse(xml) doc.remove_namespaces! body = doc.xpath('//ProcessCreditCardResult') body.children.each do |node| - if (node.elements.size == 0) + if node.elements.size == 0 response[node.name.underscore.to_sym] = node.text else node.elements.each do |childnode| diff --git a/lib/active_merchant/billing/gateways/checkout.rb b/lib/active_merchant/billing/gateways/checkout.rb index cd6692a37d8..bd6149b246d 100644 --- a/lib/active_merchant/billing/gateways/checkout.rb +++ b/lib/active_merchant/billing/gateways/checkout.rb @@ -187,7 +187,7 @@ def parse_xml(xml) Nokogiri::XML(CGI.unescapeHTML(xml)).xpath('//response').children.each do |node| if node.text? next - elsif (node.elements.size == 0) + elsif node.elements.size == 0 response[node.name.downcase.to_sym] = node.text else node.elements.each do |childnode| diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb index 2e3d444cc1b..2fde2028088 100644 --- a/lib/active_merchant/billing/gateways/ct_payment.rb +++ b/lib/active_merchant/billing/gateways/ct_payment.rb @@ -254,7 +254,7 @@ def post_data(action, parameters = {}) parameters[:CompanyNumber] = @options[:company_number] parameters[:MerchantNumber] = @options[:merchant_number] parameters = parameters.collect do |key, value| - "#{key}=#{value}" unless (value.nil? || value.empty?) + "#{key}=#{value}" unless value.nil? || value.empty? end.join('&') payload = Base64.strict_encode64(parameters) "auth-api-key=#{@options[:api_key]}&payload=#{payload}".strip diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index d31c5e46de1..9cb8d2f1a2b 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -469,7 +469,7 @@ def add_creditcard(xml, creditcard) xml.tag! 'accountNumber', creditcard.number xml.tag! 'expirationMonth', format(creditcard.month, :two_digits) xml.tag! 'expirationYear', format(creditcard.year, :four_digits) - xml.tag!('cvNumber', creditcard.verification_value) unless (@options[:ignore_cvv] || creditcard.verification_value.blank? ) + xml.tag!('cvNumber', creditcard.verification_value) unless @options[:ignore_cvv] || creditcard.verification_value.blank? xml.tag! 'cardType', @@credit_card_codes[card_brand(creditcard).to_sym] end end diff --git a/lib/active_merchant/billing/gateways/eway.rb b/lib/active_merchant/billing/gateways/eway.rb index 5625420870e..04874aac7ba 100644 --- a/lib/active_merchant/billing/gateways/eway.rb +++ b/lib/active_merchant/billing/gateways/eway.rb @@ -66,7 +66,7 @@ def scrub(transcript) private def requires_address!(options) - raise ArgumentError.new('Missing eWay required parameters: address or billing_address') unless (options.has_key?(:address) or options.has_key?(:billing_address)) + raise ArgumentError.new('Missing eWay required parameters: address or billing_address') unless options.has_key?(:address) or options.has_key?(:billing_address) end def add_creditcard(post, creditcard) diff --git a/lib/active_merchant/billing/gateways/hdfc.rb b/lib/active_merchant/billing/gateways/hdfc.rb index a6e228d5721..3037ccac471 100644 --- a/lib/active_merchant/billing/gateways/hdfc.rb +++ b/lib/active_merchant/billing/gateways/hdfc.rb @@ -113,7 +113,7 @@ def parse(xml) doc.children.each do |node| if node.text? next - elsif (node.elements.size == 0) + elsif node.elements.size == 0 response[node.name.downcase.to_sym] = node.text else node.elements.each do |childnode| diff --git a/lib/active_merchant/billing/gateways/hps.rb b/lib/active_merchant/billing/gateways/hps.rb index 22677874ff1..dbc7997370b 100644 --- a/lib/active_merchant/billing/gateways/hps.rb +++ b/lib/active_merchant/billing/gateways/hps.rb @@ -204,7 +204,7 @@ def parse(raw) doc.remove_namespaces! if(header = doc.xpath('//Header').first) header.elements.each do |node| - if (node.elements.size == 0) + if node.elements.size == 0 response[node.name] = node.text else node.elements.each do |childnode| diff --git a/lib/active_merchant/billing/gateways/payex.rb b/lib/active_merchant/billing/gateways/payex.rb index 03aa3f24a9b..b82b8c4d21b 100644 --- a/lib/active_merchant/billing/gateways/payex.rb +++ b/lib/active_merchant/billing/gateways/payex.rb @@ -364,7 +364,7 @@ def parse(xml) doc = Nokogiri::XML(body) doc.root&.xpath('*')&.each do |node| - if (node.elements.size == 0) + if node.elements.size == 0 response[node.name.downcase.to_sym] = node.text else node.elements.each do |childnode| diff --git a/lib/active_merchant/billing/gateways/paymill.rb b/lib/active_merchant/billing/gateways/paymill.rb index 858cc4bd5d9..46179c8ecf5 100644 --- a/lib/active_merchant/billing/gateways/paymill.rb +++ b/lib/active_merchant/billing/gateways/paymill.rb @@ -314,7 +314,7 @@ def transaction_id(authorization) def response_message(parsed_response) return parsed_response['error'] if parsed_response['error'] - return 'Transaction approved.' if (parsed_response['data'] == []) + return 'Transaction approved.' if parsed_response['data'] == [] code = parsed_response['data']['response_code'].to_i RESPONSE_CODES[code] || code.to_s diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index bb5d16e085b..9c73136aca2 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -167,7 +167,7 @@ def add_payer(post, payment_method, options) address = options[:billing_address] payer = {} payer[:fullName] = payment_method.name.strip - payer[:contactPhone] = address[:phone] if (address && address[:phone]) + payer[:contactPhone] = address[:phone] if address && address[:phone] payer[:dniNumber] = options[:dni_number] if options[:dni_number] payer[:dniType] = options[:dni_type] if options[:dni_type] payer[:emailAddress] = options[:email] if options[:email] diff --git a/lib/active_merchant/billing/gateways/quantum.rb b/lib/active_merchant/billing/gateways/quantum.rb index e3b1d12decd..d15ec35c939 100644 --- a/lib/active_merchant/billing/gateways/quantum.rb +++ b/lib/active_merchant/billing/gateways/quantum.rb @@ -182,7 +182,7 @@ def add_creditcard(xml, creditcard) xml.tag! 'CreditCardNumber', creditcard.number xml.tag! 'ExpireMonth', format(creditcard.month, :two_digits) xml.tag! 'ExpireYear', format(creditcard.year, :four_digits) - xml.tag!('CVV2', creditcard.verification_value) unless (@options[:ignore_cvv] || creditcard.verification_value.blank? ) + xml.tag!('CVV2', creditcard.verification_value) unless @options[:ignore_cvv] || creditcard.verification_value.blank? end # Where we actually build the full SOAP request using builder diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index 1892e652378..3e0e1a21276 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -118,7 +118,7 @@ def parse(xml) doc = Nokogiri::XML(xml) doc.xpath('//response/*').each do |node| - if (node.elements.size == 0) + if node.elements.size == 0 response[node.name.downcase.to_sym] = normalize(node.text) else node.elements.each do |childnode| diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 905a370e3c9..1650c1baf43 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -474,7 +474,7 @@ def add_customer(post, payment, options) def add_flags(post, options) post[:uncaptured] = true if options[:uncaptured] - post[:recurring] = true if (options[:eci] == 'recurring' || options[:recurring]) + post[:recurring] = true if options[:eci] == 'recurring' || options[:recurring] end def add_metadata(post, options = {}) diff --git a/lib/active_merchant/billing/gateways/telr.rb b/lib/active_merchant/billing/gateways/telr.rb index f3938d89c9a..c39b0a17e34 100644 --- a/lib/active_merchant/billing/gateways/telr.rb +++ b/lib/active_merchant/billing/gateways/telr.rb @@ -215,7 +215,7 @@ def parse(xml) doc = Nokogiri::XML(xml) doc.root&.xpath('*')&.each do |node| - if (node.elements.size == 0) + if node.elements.size == 0 response[node.name.downcase.to_sym] = node.text else node.elements.each do |childnode| diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb index 96eecc7d3a8..6e5818bee63 100644 --- a/lib/active_merchant/billing/gateways/visanet_peru.rb +++ b/lib/active_merchant/billing/gateways/visanet_peru.rb @@ -166,9 +166,9 @@ def headers end def url(action, params, options={}) - if (action == 'authorize') + if action == 'authorize' "#{base_url}/#{@options[:merchant_id]}" - elsif (action == 'refund') + elsif action == 'refund' "#{base_url}/#{@options[:merchant_id]}/#{action}/#{options[:transaction_id]}" else "#{base_url}/#{@options[:merchant_id]}/#{action}/#{params[:purchaseNumber]}" diff --git a/lib/active_merchant/billing/gateways/wirecard.rb b/lib/active_merchant/billing/gateways/wirecard.rb index 9f412cf48ae..71134e66e2a 100644 --- a/lib/active_merchant/billing/gateways/wirecard.rb +++ b/lib/active_merchant/billing/gateways/wirecard.rb @@ -343,7 +343,7 @@ def parse_response(response, root) end status.elements.to_a.each do |node| - if (node.elements.size == 0) + if node.elements.size == 0 response[node.name.to_sym] = (node.text || '').strip else node.elements.each do |childnode| diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb index 513d2a667d5..d3a03ffbeec 100644 --- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb @@ -139,7 +139,7 @@ def commit(method, url, parameters=nil, options = {}, type = false) raw_response = ssl_request(method, self.live_url + url, json, headers(options)) - if (raw_response != '') + if raw_response != '' response = parse(raw_response) if type == 'token' success = response.key?('token') From e2fb86b1091bcee917a8597808c8305e52aa21e3 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 8 Nov 2018 15:04:17 -0500 Subject: [PATCH 647/677] RuboCop: fix Style/DefWithParentheses --- .rubocop_todo.yml | 7 ------- lib/active_merchant/billing/gateways/latitude19.rb | 2 +- lib/active_merchant/billing/gateways/pagarme.rb | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cedf33c61f6..399f452aaeb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -569,13 +569,6 @@ Style/DateTime: - 'test/unit/gateways/orbital_test.rb' - 'test/unit/gateways/paypal/paypal_common_api_test.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Style/DefWithParentheses: - Exclude: - - 'lib/active_merchant/billing/gateways/latitude19.rb' - - 'lib/active_merchant/billing/gateways/pagarme.rb' - # Offense count: 210 Style/Documentation: Enabled: false diff --git a/lib/active_merchant/billing/gateways/latitude19.rb b/lib/active_merchant/billing/gateways/latitude19.rb index 89d3d8f50df..d30b5e14a22 100644 --- a/lib/active_merchant/billing/gateways/latitude19.rb +++ b/lib/active_merchant/billing/gateways/latitude19.rb @@ -153,7 +153,7 @@ def add_request_id(post) post[:id] = SecureRandom.hex(16) end - def add_timestamp() + def add_timestamp Time.now.getutc.strftime('%Y%m%d%H%M%S') end diff --git a/lib/active_merchant/billing/gateways/pagarme.rb b/lib/active_merchant/billing/gateways/pagarme.rb index 63d29f4f2c3..26545c7c2d3 100644 --- a/lib/active_merchant/billing/gateways/pagarme.rb +++ b/lib/active_merchant/billing/gateways/pagarme.rb @@ -230,7 +230,7 @@ def authorization_from(response) end end - def test?() + def test? @api_key.start_with?('ak_test') end From 01a6f98fe3319a00e8c2c962b8580b9f8adc8e02 Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Fri, 16 Nov 2018 10:25:10 -0500 Subject: [PATCH 648/677] Optimal Payment: Add verify capabilities Adds verify to optimal payment. Loaded suite test/remote/gateways/remote_optimal_payment_test Started ................ 16 tests, 73 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/optimal_payment_test ................... 19 tests, 75 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/optimal_payment.rb | 5 +++++ test/remote/gateways/remote_optimal_payment_test.rb | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index c1a9e5d5161..8837cadee46 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ * Moneris: Adds Credential on File logic [deedeelavinder] #3042 * Adyen: Return AVS and CVC Result [nfarve] #3044 * Braintree: Account for nil address with existing customer [curiousepic] #3047 +* Optimal Payment: Add verify capabilities #3052 == Version 1.86.0 (October 26, 2018) * UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002 diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb index 7dd2427ac33..30f7bf57e02 100644 --- a/lib/active_merchant/billing/gateways/optimal_payment.rb +++ b/lib/active_merchant/billing/gateways/optimal_payment.rb @@ -60,6 +60,11 @@ def capture(money, authorization, options = {}) commit('ccSettlement', money, options) end + def verify(credit_card, options = {}) + parse_card_or_auth(credit_card, options) + commit('ccVerification', 0, options) + end + def supports_scrubbing? true end diff --git a/test/remote/gateways/remote_optimal_payment_test.rb b/test/remote/gateways/remote_optimal_payment_test.rb index 58a93dcce78..6061a306300 100644 --- a/test/remote/gateways/remote_optimal_payment_test.rb +++ b/test/remote/gateways/remote_optimal_payment_test.rb @@ -51,6 +51,12 @@ def test_purchase_with_no_cvv assert_equal 'no_error', response.message end + def test_successful_verify + response = @gateway.verify(@credit_card, @options) + assert_success response + assert_equal 'no_error', response.message + end + def test_authorize_and_capture assert auth = @gateway.authorize(@amount, @credit_card, @options) assert_success auth From acf1b4c2be042fd2fc8657028c6ecf5e8c401ba6 Mon Sep 17 00:00:00 2001 From: DeeDee Lavinder <deedeelavinder@gmail.com> Date: Thu, 15 Nov 2018 12:48:44 -0500 Subject: [PATCH 649/677] Moneris: Allows cof_enabled gateway to process non-cof transactions Adds a bypass for transactions without credential-on-file details when @cof_enabled is true. Unit Tests: 37 tests, 188 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote Tests: 31 tests, 119 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 93.5484% passed (The two failing tests are not related and appear to be timing-based.) --- lib/active_merchant/billing/gateways/moneris.rb | 12 ++++++++---- test/remote/gateways/remote_moneris_test.rb | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb index a92f567ec7a..839bac02869 100644 --- a/lib/active_merchant/billing/gateways/moneris.rb +++ b/lib/active_merchant/billing/gateways/moneris.rb @@ -293,7 +293,7 @@ def transaction_element(action, parameters) when :cvd_info transaction.add_element(cvd_element(parameters[:cvd_value])) if @cvv_enabled when :cof_info - transaction.add_element(credential_on_file(parameters)) if @cof_enabled + transaction.add_element(credential_on_file(parameters)) if @cof_enabled && cof_details_present?(parameters) else transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank? end @@ -324,10 +324,14 @@ def cvd_element(cvd_value) element end + def cof_details_present?(parameters) + parameters[:issuer_id] && parameters[:payment_indicator] && parameters[:payment_information] + end + def credential_on_file(parameters) - issuer_id = parameters[:issuer_id] || '' - payment_indicator = parameters[:payment_indicator] if parameters[:payment_indicator] - payment_information = parameters[:payment_information] if parameters[:payment_information] + issuer_id = parameters[:issuer_id] + payment_indicator = parameters[:payment_indicator] + payment_information = parameters[:payment_information] cof_info = REXML::Element.new('cof_info') cof_info.add_element('issuer_id').text = issuer_id diff --git a/test/remote/gateways/remote_moneris_test.rb b/test/remote/gateways/remote_moneris_test.rb index 27da8f7271c..f096b7a9d51 100644 --- a/test/remote/gateways/remote_moneris_test.rb +++ b/test/remote/gateways/remote_moneris_test.rb @@ -30,6 +30,23 @@ def test_successful_first_purchase_with_credential_on_file assert_not_empty response.params['issuer_id'] end + def test_successful_purchase_with_cof_enabled_and_no_cof_options + gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true)) + assert response = gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert_equal 'Approved', response.message + assert_false response.authorization.blank? + end + + def test_successful_non_cof_purchase_with_cof_enabled_and_only_issuer_id_sent + gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true)) + assert response = gateway.purchase(@amount, @credit_card, @options.merge(issuer_id: '')) + assert_success response + assert_equal 'Approved', response.message + assert_false response.authorization.blank? + assert_nil response.params['issuer_id'] + end + def test_successful_subsequent_purchase_with_credential_on_file gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true)) assert response = gateway.authorize( From ec8288dffd2c431c768541b601df9874e7065d22 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 20 Nov 2018 13:53:54 -0500 Subject: [PATCH 650/677] Update India support for various gateways --- CHANGELOG | 3 +++ lib/active_merchant/billing/gateways/cenpos.rb | 2 +- lib/active_merchant/billing/gateways/cyber_source.rb | 2 +- lib/active_merchant/billing/gateways/migs.rb | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8837cadee46..667d5008138 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,9 @@ * Adyen: Return AVS and CVC Result [nfarve] #3044 * Braintree: Account for nil address with existing customer [curiousepic] #3047 * Optimal Payment: Add verify capabilities #3052 +* Cenpos: update supported countries [bpollack] #3055 +* CyberSource: update supported countries [bpollack] #3055 +* MiGS: update supported countries [bpollack] #3055 == Version 1.86.0 (October 26, 2018) * UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002 diff --git a/lib/active_merchant/billing/gateways/cenpos.rb b/lib/active_merchant/billing/gateways/cenpos.rb index 5412821c21e..9ba37a7c00b 100644 --- a/lib/active_merchant/billing/gateways/cenpos.rb +++ b/lib/active_merchant/billing/gateways/cenpos.rb @@ -8,7 +8,7 @@ class CenposGateway < Gateway self.live_url = 'https://ww3.cenpos.net/6/transact.asmx' - self.supported_countries = %w(AD AI AG AR AU AT BS BB BE BZ BM BR BN BG CA HR CY CZ DK DM EE FI FR DE GR GD GY HK HU IS IN IL IT JP LV LI LT LU MY MT MX MC MS NL PA PL PT KN LC MF VC SM SG SK SI ZA ES SR SE CH TR GB US UY) + self.supported_countries = %w(AD AI AG AR AU AT BS BB BE BZ BM BR BN BG CA HR CY CZ DK DM EE FI FR DE GR GD GY HK HU IS IL IT JP LV LI LT LU MY MT MX MC MS NL PA PL PT KN LC MF VC SM SG SK SI ZA ES SR SE CH TR GB US UY) self.default_currency = 'USD' self.money_format = :dollars self.supported_cardtypes = [:visa, :master, :american_express, :discover] diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 9cb8d2f1a2b..daafe4ad92d 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -27,7 +27,7 @@ class CyberSourceGateway < Gateway XSD_VERSION = '1.121' self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro] - self.supported_countries = %w(US BR CA CN DK FI FR DE JP MX NO SE GB SG LB) + self.supported_countries = %w(US BR CA CN DK FI FR DE IN JP MX NO SE GB SG LB) self.default_currency = 'USD' self.currencies_without_fractions = %w(JPY) diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb index a7bc303d06c..bb0c3ef7ae1 100644 --- a/lib/active_merchant/billing/gateways/migs.rb +++ b/lib/active_merchant/billing/gateways/migs.rb @@ -17,7 +17,7 @@ class MigsGateway < Gateway # MiGS is supported throughout Asia Pacific, Middle East and Africa # MiGS is used in Australia (AU) by ANZ (eGate), CBA (CommWeb) and more # Source of Country List: http://www.scribd.com/doc/17811923 - self.supported_countries = %w(AU AE BD BN EG HK ID IN JO KW LB LK MU MV MY NZ OM PH QA SA SG TT VN) + self.supported_countries = %w(AU AE BD BN EG HK ID JO KW LB LK MU MV MY NZ OM PH QA SA SG TT VN) # The card types supported by the payment gateway self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb] From 8af148a9db3802a0c7832b46030543e3658a7bd2 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 8 Nov 2018 15:06:12 -0500 Subject: [PATCH 651/677] RuboCop: fix Layout/SpaceInsideParens --- .rubocop_todo.yml | 7 ------- lib/active_merchant/billing/gateways/bogus.rb | 4 ++-- lib/active_merchant/billing/gateways/braintree_blue.rb | 2 +- lib/active_merchant/billing/gateways/cardknox.rb | 2 +- lib/active_merchant/billing/gateways/cyber_source.rb | 2 +- lib/active_merchant/billing/gateways/elavon.rb | 2 +- lib/active_merchant/billing/gateways/inspire.rb | 2 +- lib/active_merchant/billing/gateways/itransact.rb | 2 +- lib/active_merchant/billing/gateways/linkpoint.rb | 2 +- lib/active_merchant/billing/gateways/mercado_pago.rb | 4 ++-- .../billing/gateways/merchant_e_solutions.rb | 2 +- lib/active_merchant/billing/gateways/net_registry.rb | 2 +- lib/active_merchant/billing/gateways/pay_hub.rb | 2 +- lib/active_merchant/billing/gateways/pay_junction.rb | 2 +- lib/active_merchant/billing/gateways/pay_secure.rb | 2 +- lib/active_merchant/billing/gateways/payflow.rb | 6 +++--- .../billing/gateways/payflow/payflow_common_api.rb | 2 +- lib/active_merchant/billing/gateways/paymill.rb | 2 +- lib/active_merchant/billing/gateways/plugnpay.rb | 2 +- lib/active_merchant/billing/gateways/psl_card.rb | 4 ++-- lib/active_merchant/billing/gateways/quantum.rb | 2 +- lib/active_merchant/billing/gateways/sage_pay.rb | 2 +- .../billing/gateways/secure_pay_tech.rb | 2 +- lib/active_merchant/billing/gateways/skip_jack.rb | 2 +- lib/active_merchant/billing/gateways/smart_ps.rb | 2 +- lib/active_merchant/billing/gateways/trust_commerce.rb | 4 ++-- .../billing/gateways/usa_epay_transaction.rb | 2 +- lib/active_merchant/billing/gateways/verifi.rb | 2 +- lib/active_merchant/billing/gateways/viaklix.rb | 2 +- lib/active_merchant/billing/gateways/worldpay.rb | 2 +- test/remote/gateways/remote_card_stream_test.rb | 4 ++-- test/remote/gateways/remote_cyber_source_test.rb | 2 +- test/remote/gateways/remote_exact_test.rb | 6 +++--- test/remote/gateways/remote_firstdata_e4_test.rb | 6 +++--- test/remote/gateways/remote_firstdata_e4_v27_test.rb | 6 +++--- test/remote/gateways/remote_flo2cash_simple_test.rb | 2 +- test/remote/gateways/remote_pay_junction_test.rb | 4 ++-- test/remote/gateways/remote_payeezy_test.rb | 4 ++-- test/remote/gateways/remote_payment_express_test.rb | 2 +- test/remote/gateways/remote_stripe_connect_test.rb | 2 +- test/remote/gateways/remote_visanet_peru_test.rb | 2 +- test/unit/gateways/blue_pay_test.rb | 6 +++--- test/unit/gateways/braintree_blue_test.rb | 2 +- test/unit/gateways/braintree_orange_test.rb | 8 ++++---- test/unit/gateways/cashnet_test.rb | 2 +- test/unit/gateways/clearhaus_test.rb | 2 +- test/unit/gateways/evo_ca_test.rb | 4 ++-- test/unit/gateways/exact_test.rb | 10 +++++----- test/unit/gateways/federated_canada_test.rb | 2 +- test/unit/gateways/inspire_test.rb | 4 ++-- test/unit/gateways/metrics_global_test.rb | 4 ++-- test/unit/gateways/money_movers_test.rb | 2 +- test/unit/gateways/pac_net_raven_test.rb | 2 +- test/unit/gateways/payflow_test.rb | 4 ++-- test/unit/gateways/paypal_digital_goods_test.rb | 6 +++--- test/unit/gateways/plugnpay_test.rb | 4 ++-- 56 files changed, 86 insertions(+), 93 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 399f452aaeb..a93108be0b4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -172,13 +172,6 @@ Layout/SpaceInsideBlockBraces: Layout/SpaceInsideHashLiteralBraces: Enabled: false -# Offense count: 116 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceInsideParens: - Enabled: false - # Offense count: 115 # Cop supports --auto-correct. Layout/SpaceInsidePercentLiteralDelimiters: diff --git a/lib/active_merchant/billing/gateways/bogus.rb b/lib/active_merchant/billing/gateways/bogus.rb index e72bae4760c..8cafd0eeba5 100644 --- a/lib/active_merchant/billing/gateways/bogus.rb +++ b/lib/active_merchant/billing/gateways/bogus.rb @@ -47,7 +47,7 @@ def credit(money, paysource, options = {}) money = amount(money) case normalize(paysource) when /1$/ - Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true ) + Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true) when /2$/ Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error]) else @@ -130,7 +130,7 @@ def authorize_swipe(money, paysource, options = {}) money = amount(money) case normalize(paysource) when /1$/, AUTHORIZATION - Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION ) + Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION) when /2$/ Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error]) else diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 8e8f9f6830a..d39a4b72b56 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -69,7 +69,7 @@ def initialize(options = {}) :logger => options[:logger] || logger ) - @braintree_gateway = Braintree::Gateway.new( @configuration ) + @braintree_gateway = Braintree::Gateway.new(@configuration) end def authorize(money, credit_card_or_vault_id, options = {}) diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb index a611004f75b..634eb8a72ac 100644 --- a/lib/active_merchant/billing/gateways/cardknox.rb +++ b/lib/active_merchant/billing/gateways/cardknox.rb @@ -255,7 +255,7 @@ def add_cardknox_token(post, authorization) def parse(body) fields = {} for line in body.split('&') - key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten + key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten fields[key] = CGI.unescape(value.to_s) end diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index daafe4ad92d..2d3e2ceff0f 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -113,7 +113,7 @@ def initialize(options = {}) def authorize(money, creditcard_or_reference, options = {}) setup_address_hash(options) - commit(build_auth_request(money, creditcard_or_reference, options), :authorize, money, options ) + commit(build_auth_request(money, creditcard_or_reference, options), :authorize, money, options) end def capture(money, authorization, options = {}) diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb index 34bb44f5bc0..bdcf11490e4 100644 --- a/lib/active_merchant/billing/gateways/elavon.rb +++ b/lib/active_merchant/billing/gateways/elavon.rb @@ -256,7 +256,7 @@ def commit(action, money, parameters, options) parameters[:amount] = amount(money) parameters[:transaction_type] = self.actions[action] - response = parse( ssl_post(test? ? self.test_url : self.live_url, post_data(parameters, options)) ) + response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(parameters, options))) Response.new(response['result'] == '0', message_from(response), response, :test => @options[:test] || test?, diff --git a/lib/active_merchant/billing/gateways/inspire.rb b/lib/active_merchant/billing/gateways/inspire.rb index 78a193fc5ce..0e57ffe09f2 100644 --- a/lib/active_merchant/billing/gateways/inspire.rb +++ b/lib/active_merchant/billing/gateways/inspire.rb @@ -174,7 +174,7 @@ def parse(body) def commit(action, money, parameters) parameters[:amount] = amount(money) if money - response = parse( ssl_post(self.live_url, post_data(action, parameters)) ) + response = parse(ssl_post(self.live_url, post_data(action, parameters))) Response.new(response['response'] == '1', message_from(response), response, :authorization => response['transactionid'], diff --git a/lib/active_merchant/billing/gateways/itransact.rb b/lib/active_merchant/billing/gateways/itransact.rb index e7861de3d95..8bac0734e0a 100644 --- a/lib/active_merchant/billing/gateways/itransact.rb +++ b/lib/active_merchant/billing/gateways/itransact.rb @@ -302,7 +302,7 @@ def add_invoice(xml, money, options) xml.AuthCode options[:force] if options[:force] if options[:order_items].blank? xml.Total(amount(money)) unless(money.nil? || money < 0.01) - xml.Description(options[:description]) unless( options[:description].blank?) + xml.Description(options[:description]) unless(options[:description].blank?) else xml.OrderItems { options[:order_items].each do |item| diff --git a/lib/active_merchant/billing/gateways/linkpoint.rb b/lib/active_merchant/billing/gateways/linkpoint.rb index 61e5fe0e430..4dd09c89800 100644 --- a/lib/active_merchant/billing/gateways/linkpoint.rb +++ b/lib/active_merchant/billing/gateways/linkpoint.rb @@ -169,7 +169,7 @@ def initialize(options = {}) def recurring(money, creditcard, options={}) ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE - requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily], :installments, :order_id ) + requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily], :installments, :order_id) options.update( :ordertype => 'SALE', diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb index ef76ab493ad..95a9f372930 100644 --- a/lib/active_merchant/billing/gateways/mercado_pago.rb +++ b/lib/active_merchant/billing/gateways/mercado_pago.rb @@ -19,7 +19,7 @@ def purchase(money, payment, options={}) MultiResponse.run do |r| r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) } options[:card_token] = r.authorization.split('|').first - r.process { commit('purchase', 'payments', purchase_request(money, payment, options) ) } + r.process { commit('purchase', 'payments', purchase_request(money, payment, options)) } end end @@ -27,7 +27,7 @@ def authorize(money, payment, options={}) MultiResponse.run do |r| r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) } options[:card_token] = r.authorization.split('|').first - r.process { commit('authorize', 'payments', authorize_request(money, payment, options) ) } + r.process { commit('authorize', 'payments', authorize_request(money, payment, options)) } end end diff --git a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb index 1f465a07ca4..fd7368d68db 100644 --- a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +++ b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb @@ -159,7 +159,7 @@ def commit(action, money, parameters) parameters[:transaction_amount] = amount(money) if money unless action == 'V' response = begin - parse( ssl_post(url, post_data(action, parameters)) ) + parse(ssl_post(url, post_data(action, parameters))) rescue ActiveMerchant::ResponseError => e { 'error_code' => '404', 'auth_response_text' => e.to_s } end diff --git a/lib/active_merchant/billing/gateways/net_registry.rb b/lib/active_merchant/billing/gateways/net_registry.rb index 88cec2f11cf..0440ee8be2f 100644 --- a/lib/active_merchant/billing/gateways/net_registry.rb +++ b/lib/active_merchant/billing/gateways/net_registry.rb @@ -142,7 +142,7 @@ def expiry(credit_card) # omitted if nil. def commit(action, params) # get gateway response - response = parse( ssl_post(self.live_url, post_data(action, params)) ) + response = parse(ssl_post(self.live_url, post_data(action, params))) Response.new(response['status'] == 'approved', message_from(response), response, :authorization => authorization_from(response, action) diff --git a/lib/active_merchant/billing/gateways/pay_hub.rb b/lib/active_merchant/billing/gateways/pay_hub.rb index 47c6ac35cc7..fdcc6c5d600 100644 --- a/lib/active_merchant/billing/gateways/pay_hub.rb +++ b/lib/active_merchant/billing/gateways/pay_hub.rb @@ -171,7 +171,7 @@ def commit(post) success = false begin - raw_response = ssl_post(live_url, post.to_json, {'Content-Type' => 'application/json'} ) + raw_response = ssl_post(live_url, post.to_json, {'Content-Type' => 'application/json'}) response = parse(raw_response) success = (response['RESPONSE_CODE'] == '00') rescue ResponseError => e diff --git a/lib/active_merchant/billing/gateways/pay_junction.rb b/lib/active_merchant/billing/gateways/pay_junction.rb index 84ccb33b34b..19dd8317037 100644 --- a/lib/active_merchant/billing/gateways/pay_junction.rb +++ b/lib/active_merchant/billing/gateways/pay_junction.rb @@ -334,7 +334,7 @@ def add_optional_fields(params, options) def commit(action, parameters) url = test? ? self.test_url : self.live_url - response = parse( ssl_post(url, post_data(action, parameters)) ) + response = parse(ssl_post(url, post_data(action, parameters))) Response.new(successful?(response), message_from(response), response, :test => test?, diff --git a/lib/active_merchant/billing/gateways/pay_secure.rb b/lib/active_merchant/billing/gateways/pay_secure.rb index f5f539a3185..117b33939d9 100644 --- a/lib/active_merchant/billing/gateways/pay_secure.rb +++ b/lib/active_merchant/billing/gateways/pay_secure.rb @@ -66,7 +66,7 @@ def add_credit_card(post, credit_card) end def commit(action, money, parameters) - response = parse( ssl_post(self.live_url, post_data(action, parameters)) ) + response = parse(ssl_post(self.live_url, post_data(action, parameters))) Response.new(successful?(response), message_from(response), response, :test => test_response?(response), diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb index e8f08d29834..3123693a84d 100644 --- a/lib/active_merchant/billing/gateways/payflow.rb +++ b/lib/active_merchant/billing/gateways/payflow.rb @@ -92,7 +92,7 @@ def cancel_recurring(profile_id) def recurring_inquiry(profile_id, options = {}) ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE - request = build_recurring_request(:inquiry, nil, options.update( :profile_id => profile_id )) + request = build_recurring_request(:inquiry, nil, options.update(:profile_id => profile_id)) commit(request, options.merge(:request_type => :recurring)) end @@ -289,7 +289,7 @@ def build_recurring_request(action, money, options) end if action == :add - xml.tag! 'Start', format_rp_date(options[:starting_at] || Date.today + 1 ) + xml.tag! 'Start', format_rp_date(options[:starting_at] || Date.today + 1) else xml.tag! 'Start', format_rp_date(options[:starting_at]) unless options[:starting_at].nil? end @@ -308,7 +308,7 @@ def build_recurring_request(action, money, options) xml.tag! 'ProfileID', options[:profile_id] end if action == :inquiry - xml.tag! 'PaymentHistory', ( options[:history] ? 'Y' : 'N' ) + xml.tag! 'PaymentHistory', (options[:history] ? 'Y' : 'N') end end end diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb index b524126ef1e..32213491eb5 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb @@ -178,7 +178,7 @@ def parse_element(response, node) # down as we do everywhere else. RPPaymentResult elements are not contained # in an RPPaymentResults element so we'll come here multiple times response[node_name] ||= [] - response[node_name] << ( payment_result_response = {} ) + response[node_name] << (payment_result_response = {}) node.xpath('.//*').each{ |e| parse_element(payment_result_response, e) } when node.xpath('.//*').to_a.any? node.xpath('.//*').each{|e| parse_element(response, e) } diff --git a/lib/active_merchant/billing/gateways/paymill.rb b/lib/active_merchant/billing/gateways/paymill.rb index 46179c8ecf5..01b4cd9ebfb 100644 --- a/lib/active_merchant/billing/gateways/paymill.rb +++ b/lib/active_merchant/billing/gateways/paymill.rb @@ -82,7 +82,7 @@ def add_credit_card(post, credit_card, options) post['account.verification'] = credit_card.verification_value post['account.email'] = (options[:email] || nil) post['presentation.amount3D'] = (options[:money] || nil) - post['presentation.currency3D'] = (options[:currency] || currency( options[:money])) + post['presentation.currency3D'] = (options[:currency] || currency(options[:money])) end def headers diff --git a/lib/active_merchant/billing/gateways/plugnpay.rb b/lib/active_merchant/billing/gateways/plugnpay.rb index 750f133a35b..36becf69ff8 100644 --- a/lib/active_merchant/billing/gateways/plugnpay.rb +++ b/lib/active_merchant/billing/gateways/plugnpay.rb @@ -174,7 +174,7 @@ def refund(money, reference, options = {}) private def commit(action, post) - response = parse( ssl_post(self.live_url, post_data(action, post)) ) + response = parse(ssl_post(self.live_url, post_data(action, post))) success = SUCCESS_CODES.include?(response[:finalstatus]) message = success ? 'Success' : message_from(response) diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb index 827a5cc11a4..d0495a42037 100644 --- a/lib/active_merchant/billing/gateways/psl_card.rb +++ b/lib/active_merchant/billing/gateways/psl_card.rb @@ -242,7 +242,7 @@ def currency_code(currency) def parse(body) fields = {} for line in body.split('&') - key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten + key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten fields[key] = CGI.unescape(value) end fields.symbolize_keys @@ -257,7 +257,7 @@ def parse(body) # - ActiveMerchant::Billing::Response object # def commit(request) - response = parse( ssl_post(self.live_url, post_data(request)) ) + response = parse(ssl_post(self.live_url, post_data(request))) Response.new(response[:ResponseCode] == APPROVED, response[:Message], response, :test => test?, diff --git a/lib/active_merchant/billing/gateways/quantum.rb b/lib/active_merchant/billing/gateways/quantum.rb index d15ec35c939..38a53eeb08c 100644 --- a/lib/active_merchant/billing/gateways/quantum.rb +++ b/lib/active_merchant/billing/gateways/quantum.rb @@ -44,7 +44,7 @@ def initialize(options = {}) # def authorize(money, creditcard, options = {}) setup_address_hash(options) - commit(build_auth_request(money, creditcard, options), options ) + commit(build_auth_request(money, creditcard, options), options) end # Capture an authorization that has previously been requested diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index ae3f747d018..449d7306580 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -343,7 +343,7 @@ def format_date(month, year) end def commit(action, parameters) - response = parse( ssl_post(url_for(action), post_data(action, parameters)) ) + response = parse(ssl_post(url_for(action), post_data(action, parameters))) Response.new(response['Status'] == APPROVED, message_from(response), response, :test => test?, diff --git a/lib/active_merchant/billing/gateways/secure_pay_tech.rb b/lib/active_merchant/billing/gateways/secure_pay_tech.rb index 3cf645f8838..b6980d4cf99 100644 --- a/lib/active_merchant/billing/gateways/secure_pay_tech.rb +++ b/lib/active_merchant/billing/gateways/secure_pay_tech.rb @@ -82,7 +82,7 @@ def parse(body) end def commit(action, post) - response = parse( ssl_post(self.live_url, post_data(action, post) ) ) + response = parse(ssl_post(self.live_url, post_data(action, post))) Response.new(response[:result_code] == 1, message_from(response), response, :test => test?, diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb index 56dd6a2309e..3528b04f22c 100644 --- a/lib/active_merchant/billing/gateways/skip_jack.rb +++ b/lib/active_merchant/billing/gateways/skip_jack.rb @@ -260,7 +260,7 @@ def add_status_action(post, action) end def commit(action, money, parameters) - response = parse( ssl_post( url_for(action), post_data(action, money, parameters) ), action ) + response = parse(ssl_post(url_for(action), post_data(action, money, parameters)), action) # Pass along the original transaction id in the case an update transaction Response.new(response[:success], message_from(response, action), response, diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb index 8f84413abdc..fe196f6dc0b 100644 --- a/lib/active_merchant/billing/gateways/smart_ps.rb +++ b/lib/active_merchant/billing/gateways/smart_ps.rb @@ -230,7 +230,7 @@ def parse(body) def commit(action, money, parameters) parameters[:amount] = localized_amount(money, parameters[:currency] || default_currency) if money - response = parse( ssl_post(self.live_url, post_data(action, parameters)) ) + response = parse(ssl_post(self.live_url, post_data(action, parameters))) Response.new(response['response'] == '1', message_from(response), response, :authorization => (response['transactionid'] || response['customer_vault_id']), :test => test?, diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb index 416824a5d38..c10819e6eed 100644 --- a/lib/active_merchant/billing/gateways/trust_commerce.rb +++ b/lib/active_merchant/billing/gateways/trust_commerce.rb @@ -237,7 +237,7 @@ def void(authorization, options = {}) def recurring(money, creditcard, options = {}) ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE - requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily] ) + requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily]) cycle = case options[:periodicity] when :monthly @@ -385,7 +385,7 @@ def commit(action, parameters) data = if tclink? TCLink.send(parameters) else - parse( ssl_post(self.live_url, post_data(parameters)) ) + parse(ssl_post(self.live_url, post_data(parameters))) end # to be considered successful, transaction status must be either "approved" or "accepted" diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb index bb9b41d7fcb..4eb7827b27c 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb @@ -234,7 +234,7 @@ def add_split_payments(post, options) def parse(body) fields = {} for line in body.split('&') - key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten + key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten fields[key] = CGI.unescape(value.to_s) end diff --git a/lib/active_merchant/billing/gateways/verifi.rb b/lib/active_merchant/billing/gateways/verifi.rb index b8c2142e621..e435505d8be 100644 --- a/lib/active_merchant/billing/gateways/verifi.rb +++ b/lib/active_merchant/billing/gateways/verifi.rb @@ -192,7 +192,7 @@ def add_security_key_data(post, options, money) def commit(trx_type, money, post) post[:amount] = amount(money) - response = parse( ssl_post(self.live_url, post_data(trx_type, post)) ) + response = parse(ssl_post(self.live_url, post_data(trx_type, post))) Response.new(response[:response].to_i == SUCCESS, message_from(response), response, :test => test?, diff --git a/lib/active_merchant/billing/gateways/viaklix.rb b/lib/active_merchant/billing/gateways/viaklix.rb index af2b009d410..269c5b3a8be 100644 --- a/lib/active_merchant/billing/gateways/viaklix.rb +++ b/lib/active_merchant/billing/gateways/viaklix.rb @@ -138,7 +138,7 @@ def commit(action, money, parameters) parameters[:amount] = amount(money) parameters[:transaction_type] = self.actions[action] - response = parse( ssl_post(test? ? self.test_url : self.live_url, post_data(parameters)) ) + response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(parameters))) Response.new(response['result'] == APPROVED, message_from(response), response, :test => @options[:test] || test?, diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index 57cf72a9100..30b795da727 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -67,7 +67,7 @@ def refund(money, authorization, options = {}) return response if response.success? return response unless options[:force_full_refund_if_unsettled] - void(authorization, options ) if response.params['last_event'] == 'AUTHORISED' + void(authorization, options) if response.params['last_event'] == 'AUTHORISED' end # Credits only function on a Merchant ID/login/profile flagged for Payouts diff --git a/test/remote/gateways/remote_card_stream_test.rb b/test/remote/gateways/remote_card_stream_test.rb index c35543a9b9b..fd6d3e8e3ef 100644 --- a/test/remote/gateways/remote_card_stream_test.rb +++ b/test/remote/gateways/remote_card_stream_test.rb @@ -424,8 +424,8 @@ def test_transcript_scrubbing end clean_transcript = @gateway.scrub(transcript) - assert_scrubbed( @visacreditcard.number, clean_transcript) - assert_scrubbed( @visacreditcard.verification_value.to_s, clean_transcript) + assert_scrubbed(@visacreditcard.number, clean_transcript) + assert_scrubbed(@visacreditcard.verification_value.to_s, clean_transcript) assert_scrubbed(@gateway.options[:shared_secret], clean_transcript) end end diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb index e35e01ba8ce..eca6db9a23e 100644 --- a/test/remote/gateways/remote_cyber_source_test.rb +++ b/test/remote/gateways/remote_cyber_source_test.rb @@ -219,7 +219,7 @@ def test_failed_capture_bad_auth_info end def test_invalid_login - gateway = CyberSourceGateway.new( :login => 'asdf', :password => 'qwer' ) + gateway = CyberSourceGateway.new(:login => 'asdf', :password => 'qwer') assert response = gateway.purchase(@amount, @credit_card, @options) assert_failure response assert_equal "wsse:FailedCheck: \nSecurity Data : UsernameToken authentication failed.\n", response.message diff --git a/test/remote/gateways/remote_exact_test.rb b/test/remote/gateways/remote_exact_test.rb index 879c7b3aa42..8843e170d74 100644 --- a/test/remote/gateways/remote_exact_test.rb +++ b/test/remote/gateways/remote_exact_test.rb @@ -21,7 +21,7 @@ def test_successful_purchase def test_unsuccessful_purchase # ask for error 13 response (Amount Error) via dollar amount 5,000 + error @amount = 501300 - assert response = @gateway.purchase(@amount, @credit_card, @options ) + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_match %r{Transaction Normal}, response.message assert_failure response end @@ -49,8 +49,8 @@ def test_failed_capture end def test_invalid_login - gateway = ExactGateway.new( :login => 'NotARealUser', - :password => 'NotARealPassword' ) + gateway = ExactGateway.new(:login => 'NotARealUser', + :password => 'NotARealPassword') assert response = gateway.purchase(@amount, @credit_card, @options) assert_match %r{^Invalid Login}, response.message assert_failure response diff --git a/test/remote/gateways/remote_firstdata_e4_test.rb b/test/remote/gateways/remote_firstdata_e4_test.rb index 3a541b57290..f7d88e60197 100755 --- a/test/remote/gateways/remote_firstdata_e4_test.rb +++ b/test/remote/gateways/remote_firstdata_e4_test.rb @@ -89,7 +89,7 @@ def test_successful_purchase_with_card_authentication def test_unsuccessful_purchase # ask for error 13 response (Amount Error) via dollar amount 5,000 + error @amount = 501300 - assert response = @gateway.purchase(@amount, @credit_card, @options ) + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_match(/Transaction Normal/, response.message) assert_failure response end @@ -104,7 +104,7 @@ def test_bad_creditcard_number def test_trans_error # ask for error 42 (unable to send trans) as the cents bit... @amount = 500042 - assert response = @gateway.purchase(@amount, @credit_card, @options ) + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_match(/Unable to Send Transaction/, response.message) # 42 is 'unable to send trans' assert_failure response assert_equal response.error_code, 'processing_error' @@ -179,7 +179,7 @@ def test_failed_verify def test_invalid_login gateway = FirstdataE4Gateway.new(:login => 'NotARealUser', - :password => 'NotARealPassword' ) + :password => 'NotARealPassword') assert response = gateway.purchase(@amount, @credit_card, @options) assert_match %r{Unauthorized Request}, response.message assert_failure response diff --git a/test/remote/gateways/remote_firstdata_e4_v27_test.rb b/test/remote/gateways/remote_firstdata_e4_v27_test.rb index 0832c159edc..4233159fc39 100644 --- a/test/remote/gateways/remote_firstdata_e4_v27_test.rb +++ b/test/remote/gateways/remote_firstdata_e4_v27_test.rb @@ -81,7 +81,7 @@ def test_successful_purchase_with_card_authentication def test_unsuccessful_purchase # ask for error 13 response (Amount Error) via dollar amount 5,000 + error @amount = 501300 - assert response = @gateway.purchase(@amount, @credit_card, @options ) + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_match(/Transaction Normal/, response.message) assert_failure response end @@ -96,7 +96,7 @@ def test_bad_creditcard_number def test_trans_error # ask for error 42 (unable to send trans) as the cents bit... @amount = 500042 - assert response = @gateway.purchase(@amount, @credit_card, @options ) + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_match(/Unable to Send Transaction/, response.message) # 42 is 'unable to send trans' assert_failure response assert_equal response.error_code, 'processing_error' @@ -162,7 +162,7 @@ def test_invalid_login gateway = FirstdataE4V27Gateway.new(:login => 'NotARealUser', :password => 'NotARealPassword', :key_id => 'NotARealKey', - :hmac_key => 'NotARealHMAC' ) + :hmac_key => 'NotARealHMAC') assert response = gateway.purchase(@amount, @credit_card, @options) assert_match %r{Unauthorized Request}, response.message assert_failure response diff --git a/test/remote/gateways/remote_flo2cash_simple_test.rb b/test/remote/gateways/remote_flo2cash_simple_test.rb index 15aafebb4bb..f952d7c0be1 100644 --- a/test/remote/gateways/remote_flo2cash_simple_test.rb +++ b/test/remote/gateways/remote_flo2cash_simple_test.rb @@ -7,7 +7,7 @@ def setup @gateway = Flo2cashSimpleGateway.new(fixtures(:flo2cash_simple)) @amount = 100 - @credit_card = credit_card('5123456789012346', brand: :master, month: 5, year: 2017, verification_value: 111 ) + @credit_card = credit_card('5123456789012346', brand: :master, month: 5, year: 2017, verification_value: 111) @declined_card = credit_card('4000300011112220') @options = { diff --git a/test/remote/gateways/remote_pay_junction_test.rb b/test/remote/gateways/remote_pay_junction_test.rb index bacaae52e44..1db822d8bb1 100644 --- a/test/remote/gateways/remote_pay_junction_test.rb +++ b/test/remote/gateways/remote_pay_junction_test.rb @@ -55,7 +55,7 @@ def test_successful_purchase_with_cvv end def test_successful_authorize - assert response = @gateway.authorize( AMOUNT, @credit_card, @options) + assert response = @gateway.authorize(AMOUNT, @credit_card, @options) assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message assert_equal 'hold', response.params['posture'], 'Should be a held charge' @@ -102,7 +102,7 @@ def test_successful_instant_purchase # transaction can be executed if you have the transaction ID of a # previous successful transaction. - purchase = @gateway.purchase( AMOUNT, @credit_card, @options) + purchase = @gateway.purchase(AMOUNT, @credit_card, @options) assert_success purchase assert response = @gateway.purchase(AMOUNT, purchase.authorization, :order_id => generate_unique_id) diff --git a/test/remote/gateways/remote_payeezy_test.rb b/test/remote/gateways/remote_payeezy_test.rb index 2580c070dbe..24871731678 100644 --- a/test/remote/gateways/remote_payeezy_test.rb +++ b/test/remote/gateways/remote_payeezy_test.rb @@ -70,7 +70,7 @@ def test_successful_purchase_with_soft_descriptors def test_failed_purchase @amount = 501300 - assert response = @gateway.purchase(@amount, @credit_card, @options ) + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_match(/Transaction not approved/, response.message) assert_failure response end @@ -262,7 +262,7 @@ def test_response_contains_cvv_and_avs_results def test_trans_error # ask for error 42 (unable to send trans) as the cents bit... @amount = 500042 - assert response = @gateway.purchase(@amount, @credit_card, @options ) + assert response = @gateway.purchase(@amount, @credit_card, @options) assert_match(/Server Error/, response.message) # 42 is 'unable to send trans' assert_failure response assert_equal '500', response.error_code diff --git a/test/remote/gateways/remote_payment_express_test.rb b/test/remote/gateways/remote_payment_express_test.rb index eeb9d3b0b33..355f1830817 100644 --- a/test/remote/gateways/remote_payment_express_test.rb +++ b/test/remote/gateways/remote_payment_express_test.rb @@ -109,7 +109,7 @@ def test_store_and_charge assert_equal 'The Transaction was approved', response.message assert(token = response.authorization) - assert purchase = @gateway.purchase( @amount, token) + assert purchase = @gateway.purchase(@amount, token) assert_equal 'The Transaction was approved', purchase.message assert_success purchase assert_not_nil purchase.authorization diff --git a/test/remote/gateways/remote_stripe_connect_test.rb b/test/remote/gateways/remote_stripe_connect_test.rb index a8cd4664f36..8309d62f98d 100644 --- a/test/remote/gateways/remote_stripe_connect_test.rb +++ b/test/remote/gateways/remote_stripe_connect_test.rb @@ -18,7 +18,7 @@ def setup end def test_application_fee_for_stripe_connect - assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:application_fee => 12 )) + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:application_fee => 12)) assert_success response end diff --git a/test/remote/gateways/remote_visanet_peru_test.rb b/test/remote/gateways/remote_visanet_peru_test.rb index 59425892e09..d596f4b451e 100644 --- a/test/remote/gateways/remote_visanet_peru_test.rb +++ b/test/remote/gateways/remote_visanet_peru_test.rb @@ -114,7 +114,7 @@ def test_successful_refund_unsettled end def test_failed_refund - response = @gateway.refund(@amount, '900000044' ) + response = @gateway.refund(@amount, '900000044') assert_failure response assert_match(/NUMORDEN 900000044 no se encuentra registrado/, response.message) assert_equal 400, response.error_code diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb index 5ae66d0fe58..b4b040f5c43 100644 --- a/test/unit/gateways/blue_pay_test.rb +++ b/test/unit/gateways/blue_pay_test.rb @@ -51,7 +51,7 @@ def test_failed_authorization def test_add_address_outsite_north_america result = {} - @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Test St.', :address2 => '5F', :city => 'Testville', :company => 'Test Company', :country => 'DE', :state => ''} ) + @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Test St.', :address2 => '5F', :city => 'Testville', :company => 'Test Company', :country => 'DE', :state => ''}) assert_equal ['ADDR1', 'ADDR2', 'CITY', 'COMPANY_NAME', 'COUNTRY', 'PHONE', 'STATE', 'ZIP'], result.stringify_keys.keys.sort assert_equal 'n/a', result[:STATE] assert_equal '123 Test St.', result[:ADDR1] @@ -61,7 +61,7 @@ def test_add_address_outsite_north_america def test_add_address result = {} - @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Test St.', :address2 => '5F', :city => 'Testville', :company => 'Test Company', :country => 'US', :state => 'AK'} ) + @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Test St.', :address2 => '5F', :city => 'Testville', :company => 'Test Company', :country => 'US', :state => 'AK'}) assert_equal ['ADDR1', 'ADDR2', 'CITY', 'COMPANY_NAME', 'COUNTRY', 'PHONE', 'STATE', 'ZIP'], result.stringify_keys.keys.sort assert_equal 'AK', result[:STATE] @@ -73,7 +73,7 @@ def test_name_comes_from_payment_method result = {} @gateway.send(:add_creditcard, result, @credit_card) - @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Test St.', :address2 => '5F', :city => 'Testville', :company => 'Test Company', :country => 'US', :state => 'AK'} ) + @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Test St.', :address2 => '5F', :city => 'Testville', :company => 'Test Company', :country => 'US', :state => 'AK'}) assert_equal @credit_card.first_name, result[:NAME1] assert_equal @credit_card.last_name, result[:NAME2] diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index 7c89a988d05..1a0b83e24cc 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -11,7 +11,7 @@ def setup :test => true ) - @internal_gateway = @gateway.instance_variable_get( :@braintree_gateway ) + @internal_gateway = @gateway.instance_variable_get(:@braintree_gateway) end def teardown diff --git a/test/unit/gateways/braintree_orange_test.rb b/test/unit/gateways/braintree_orange_test.rb index 399580184fb..ee4149137bb 100644 --- a/test/unit/gateways/braintree_orange_test.rb +++ b/test/unit/gateways/braintree_orange_test.rb @@ -47,7 +47,7 @@ def test_successful_store def test_add_processor result = {} - @gateway.send(:add_processor, result, {:processor => 'ccprocessorb'} ) + @gateway.send(:add_processor, result, {:processor => 'ccprocessorb'}) assert_equal ['processor_id'], result.stringify_keys.keys.sort assert_equal 'ccprocessorb', result[:processor_id] end @@ -86,7 +86,7 @@ def test_unsuccessful_verify def test_add_address result = {} - @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} ) + @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'}) assert_equal ['address1', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort assert_equal 'CO', result['state'] assert_equal '164 Waverley Street', result['address1'] @@ -96,7 +96,7 @@ def test_add_address def test_add_shipping_address result = {} - @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'}, 'shipping' ) + @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'}, 'shipping') assert_equal ['shipping_address1', 'shipping_city', 'shipping_company', 'shipping_country', 'shipping_phone', 'shipping_state', 'shipping_zip'], result.stringify_keys.keys.sort assert_equal 'CO', result['shipping_state'] assert_equal '164 Waverley Street', result['shipping_address1'] @@ -114,7 +114,7 @@ def test_adding_store_adds_vault_id_flag def test_blank_store_doesnt_add_vault_flag result = {} - @gateway.send(:add_creditcard, result, @credit_card, {} ) + @gateway.send(:add_creditcard, result, @credit_card, {}) assert_equal ['ccexp', 'ccnumber', 'cvv', 'firstname', 'lastname'], result.stringify_keys.keys.sort assert_nil result[:customer_vault] end diff --git a/test/unit/gateways/cashnet_test.rb b/test/unit/gateways/cashnet_test.rb index af7ab9fa0bd..844702eac9a 100644 --- a/test/unit/gateways/cashnet_test.rb +++ b/test/unit/gateways/cashnet_test.rb @@ -76,7 +76,7 @@ def test_add_creditcard def test_add_address result = {} - @gateway.send(:add_address, result, billing_address: {address1: '123 Test St.', address2: '5F', city: 'Testville', zip: '12345', state: 'AK'} ) + @gateway.send(:add_address, result, billing_address: {address1: '123 Test St.', address2: '5F', city: 'Testville', zip: '12345', state: 'AK'}) assert_equal ['addr_g', 'city_g', 'state_g', 'zip_g'], result.stringify_keys.keys.sort assert_equal '123 Test St.,5F', result[:addr_g] diff --git a/test/unit/gateways/clearhaus_test.rb b/test/unit/gateways/clearhaus_test.rb index 0794d356bdc..d0b383e962f 100644 --- a/test/unit/gateways/clearhaus_test.rb +++ b/test/unit/gateways/clearhaus_test.rb @@ -153,7 +153,7 @@ def test_successful_void def test_failed_void @gateway.expects(:ssl_post).returns(failed_void_response) - response = @gateway.void( @credit_card, @options) + response = @gateway.void(@credit_card, @options) assert_failure response assert_equal 40000, response.error_code diff --git a/test/unit/gateways/evo_ca_test.rb b/test/unit/gateways/evo_ca_test.rb index e699e1462a1..f2fe062e658 100644 --- a/test/unit/gateways/evo_ca_test.rb +++ b/test/unit/gateways/evo_ca_test.rb @@ -99,7 +99,7 @@ def test_successful_refund def test_add_address result = {} - @gateway.send(:add_address, result, :address => {:address1 => '123 Main Street', :country => 'CA', :state => 'BC'} ) + @gateway.send(:add_address, result, :address => {:address1 => '123 Main Street', :country => 'CA', :state => 'BC'}) assert_equal %w{address1 address2 city company country firstname lastname phone state zip}, result.stringify_keys.keys.sort assert_equal 'BC', result[:state] assert_equal '123 Main Street', result[:address1] @@ -109,7 +109,7 @@ def test_add_address def test_add_shipping_address result = {} - @gateway.send(:add_address, result, :shipping_address => {:address1 => '123 Main Street', :country => 'CA', :state => 'BC'} ) + @gateway.send(:add_address, result, :shipping_address => {:address1 => '123 Main Street', :country => 'CA', :state => 'BC'}) assert_equal %w{shipping_address1 shipping_address2 shipping_city shipping_company shipping_country shipping_firstname shipping_lastname shipping_state shipping_zip}, result.stringify_keys.keys.sort assert_equal 'BC', result[:shipping_state] assert_equal '123 Main Street', result[:shipping_address1] diff --git a/test/unit/gateways/exact_test.rb b/test/unit/gateways/exact_test.rb index b48a4170d74..33345b22541 100644 --- a/test/unit/gateways/exact_test.rb +++ b/test/unit/gateways/exact_test.rb @@ -2,8 +2,8 @@ class ExactTest < Test::Unit::TestCase def setup - @gateway = ExactGateway.new( :login => 'A00427-01', - :password => 'testus' ) + @gateway = ExactGateway.new(:login => 'A00427-01', + :password => 'testus') @credit_card = credit_card @amount = 100 @@ -49,9 +49,9 @@ def test_failed_purchase end def test_expdate - assert_equal( '%02d%s' % [ @credit_card.month, - @credit_card.year.to_s[-2..-1] ], - @gateway.send(:expdate, @credit_card) ) + assert_equal('%02d%s' % [ @credit_card.month, + @credit_card.year.to_s[-2..-1] ], + @gateway.send(:expdate, @credit_card)) end def test_soap_fault diff --git a/test/unit/gateways/federated_canada_test.rb b/test/unit/gateways/federated_canada_test.rb index cad64a37f16..d3ca5956ae8 100644 --- a/test/unit/gateways/federated_canada_test.rb +++ b/test/unit/gateways/federated_canada_test.rb @@ -47,7 +47,7 @@ def test_unsuccessful_request def test_add_address result = {} - @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Happy Town Road', :address2 => 'apt 13', :country => 'CA', :state => 'SK', :phone => '1234567890'} ) + @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Happy Town Road', :address2 => 'apt 13', :country => 'CA', :state => 'SK', :phone => '1234567890'}) assert_equal ['address1', 'address2', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort assert_equal 'SK', result[:state] assert_equal '123 Happy Town Road', result[:address1] diff --git a/test/unit/gateways/inspire_test.rb b/test/unit/gateways/inspire_test.rb index 6aac648f1da..b92b13ef34c 100644 --- a/test/unit/gateways/inspire_test.rb +++ b/test/unit/gateways/inspire_test.rb @@ -60,7 +60,7 @@ def test_failed_refund def test_add_address result = {} - @gateway.send(:add_address, result, nil, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} ) + @gateway.send(:add_address, result, nil, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'}) assert_equal ['address1', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort assert_equal 'CO', result[:state] assert_equal '164 Waverley Street', result[:address1] @@ -86,7 +86,7 @@ def test_adding_store_adds_vault_id_flag def test_blank_store_doesnt_add_vault_flag result = {} - @gateway.send(:add_creditcard, result, @credit_card, {} ) + @gateway.send(:add_creditcard, result, @credit_card, {}) assert_equal ['ccexp', 'ccnumber', 'cvv', 'firstname', 'lastname'], result.stringify_keys.keys.sort assert_nil result[:customer_vault] end diff --git a/test/unit/gateways/metrics_global_test.rb b/test/unit/gateways/metrics_global_test.rb index 5082a40facc..5cf3c841bff 100644 --- a/test/unit/gateways/metrics_global_test.rb +++ b/test/unit/gateways/metrics_global_test.rb @@ -44,7 +44,7 @@ def test_failed_authorization def test_add_address_outsite_north_america result = {} - @gateway.send(:add_address, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'DE', :state => ''} ) + @gateway.send(:add_address, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'DE', :state => ''}) assert_equal ['address', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort assert_equal 'n/a', result[:state] @@ -55,7 +55,7 @@ def test_add_address_outsite_north_america def test_add_address result = {} - @gateway.send(:add_address, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} ) + @gateway.send(:add_address, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'}) assert_equal ['address', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort assert_equal 'CO', result[:state] diff --git a/test/unit/gateways/money_movers_test.rb b/test/unit/gateways/money_movers_test.rb index de2c1820701..c5c3b275baf 100644 --- a/test/unit/gateways/money_movers_test.rb +++ b/test/unit/gateways/money_movers_test.rb @@ -44,7 +44,7 @@ def test_unsuccessful_request def test_add_address result = {} - @gateway.send(:add_address, result, :billing_address => {:address1 => '1 Main St.', :address2 => 'apt 13', :country => 'US', :state => 'MI', :phone => '1234567890'} ) + @gateway.send(:add_address, result, :billing_address => {:address1 => '1 Main St.', :address2 => 'apt 13', :country => 'US', :state => 'MI', :phone => '1234567890'}) assert_equal ['address1', 'address2', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort assert_equal 'MI', result[:state] assert_equal '1 Main St.', result[:address1] diff --git a/test/unit/gateways/pac_net_raven_test.rb b/test/unit/gateways/pac_net_raven_test.rb index 29d99cb9e84..f2e66cce048 100644 --- a/test/unit/gateways/pac_net_raven_test.rb +++ b/test/unit/gateways/pac_net_raven_test.rb @@ -179,7 +179,7 @@ def test_argument_error_secret def test_add_address result = {} - @gateway.send(:add_address, result, :billing_address => {:address1 => 'Address 1', :address2 => 'Address 2', :zip => 'ZIP'} ) + @gateway.send(:add_address, result, :billing_address => {:address1 => 'Address 1', :address2 => 'Address 2', :zip => 'ZIP'}) assert_equal ['BillingPostalCode', 'BillingStreetAddressLineFour', 'BillingStreetAddressLineOne'], result.stringify_keys.keys.sort assert_equal 'ZIP', result['BillingPostalCode'] assert_equal 'Address 2', result['BillingStreetAddressLineFour'] diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb index ef6e449fbce..2ddee59bb92 100644 --- a/test/unit/gateways/payflow_test.rb +++ b/test/unit/gateways/payflow_test.rb @@ -14,7 +14,7 @@ def setup @amount = 100 @credit_card = credit_card('4242424242424242') @options = { :billing_address => address.merge(:first_name => 'Longbob', :last_name => 'Longsen') } - @check = check( :name => 'Jim Smith' ) + @check = check(:name => 'Jim Smith') end def test_successful_authorization @@ -360,7 +360,7 @@ def test_recurring_profile_payment_history_inquiry end def test_recurring_profile_payment_history_inquiry_contains_the_proper_xml - request = @gateway.send( :build_recurring_request, :inquiry, nil, :profile_id => 'RT0000000009', :history => true) + request = @gateway.send(:build_recurring_request, :inquiry, nil, :profile_id => 'RT0000000009', :history => true) assert_match %r(<PaymentHistory>Y</PaymentHistory), request end diff --git a/test/unit/gateways/paypal_digital_goods_test.rb b/test/unit/gateways/paypal_digital_goods_test.rb index 9e46f0036d6..ab7cf6c03eb 100644 --- a/test/unit/gateways/paypal_digital_goods_test.rb +++ b/test/unit/gateways/paypal_digital_goods_test.rb @@ -56,7 +56,7 @@ def test_setup_request_invalid_requests :description => 'Test Title', :return_url => 'http://return.url', :cancel_return_url => 'http://cancel.url', - :items => [ Hash.new ] ) + :items => [ Hash.new ]) end assert_raise ArgumentError do @@ -70,7 +70,7 @@ def test_setup_request_invalid_requests :quantity => '1', :amount => 100, :description => 'Description', - :category => 'Physical' } ] ) + :category => 'Physical' } ]) end end @@ -87,7 +87,7 @@ def test_build_setup_request_valid :quantity => '1', :amount => 100, :description => 'Description', - :category => 'Digital' } ] ) + :category => 'Digital' } ]) end private diff --git a/test/unit/gateways/plugnpay_test.rb b/test/unit/gateways/plugnpay_test.rb index c815b9fe251..4760eada3f6 100644 --- a/test/unit/gateways/plugnpay_test.rb +++ b/test/unit/gateways/plugnpay_test.rb @@ -70,7 +70,7 @@ def test_refund def test_add_address_outsite_north_america result = PlugnpayGateway::PlugnpayPostData.new - @gateway.send(:add_addresses, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'DE', :state => 'Dortmund'} ) + @gateway.send(:add_addresses, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'DE', :state => 'Dortmund'}) assert_equal result[:state], 'ZZ' assert_equal result[:province], 'Dortmund' @@ -85,7 +85,7 @@ def test_add_address_outsite_north_america def test_add_address result = PlugnpayGateway::PlugnpayPostData.new - @gateway.send(:add_addresses, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} ) + @gateway.send(:add_addresses, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'}) assert_equal result[:card_state], 'CO' assert_equal result[:card_address1], '164 Waverley Street' From cbbd15e7a990002629acde0ba30ef9cdcb14c279 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 20 Nov 2018 08:41:09 -0500 Subject: [PATCH 652/677] Clearhaus: update submission data format Unit: 22 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 23 tests, 70 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/clearhaus.rb | 12 ++++++------ test/unit/gateways/clearhaus_test.rb | 10 +++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 667d5008138..6888977fb1e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Clearhaus: update submission data format [bpollack] #3053 * Make behavior of nil CC numbers more consistent [guaguasi] #3010 * Moneris: Adds Credential on File logic [deedeelavinder] #3042 * Adyen: Return AVS and CVC Result [nfarve] #3044 diff --git a/lib/active_merchant/billing/gateways/clearhaus.rb b/lib/active_merchant/billing/gateways/clearhaus.rb index 2d2d73aa4f2..b53d792a4f4 100644 --- a/lib/active_merchant/billing/gateways/clearhaus.rb +++ b/lib/active_merchant/billing/gateways/clearhaus.rb @@ -63,7 +63,7 @@ def authorize(amount, payment, options={}) end post[:recurring] = options[:recurring] if options[:recurring] - post[:threed_secure] = {pares: options[:pares]} if options[:pares] + post[:card][:pares] = options[:pares] if options[:pares] commit(action, post) end @@ -108,7 +108,7 @@ def scrub(transcript) transcript. gsub(%r((Authorization: Basic )[\w=]+), '\1[FILTERED]'). gsub(%r((&?card(?:\[|%5B)csc(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]'). - gsub(%r((&?card(?:\[|%5B)number(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]') + gsub(%r((&?card(?:\[|%5B)pan(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]') end private @@ -126,12 +126,12 @@ def add_amount(post, amount, options) def add_payment(post, payment) card = {} - card[:number] = payment.number + card[:pan] = payment.number card[:expire_month] = '%02d'% payment.month card[:expire_year] = payment.year if payment.verification_value? - card[:csc] = payment.verification_value + card[:csc] = payment.verification_value end post[:card] = card if card.any? @@ -139,8 +139,8 @@ def add_payment(post, payment) def headers(api_key) { - 'Authorization' => 'Basic ' + Base64.strict_encode64("#{api_key}:"), - 'User-Agent' => "Clearhaus ActiveMerchantBindings/#{ActiveMerchant::VERSION}" + 'Authorization' => 'Basic ' + Base64.strict_encode64("#{api_key}:"), + 'User-Agent' => "Clearhaus ActiveMerchantBindings/#{ActiveMerchant::VERSION}" } end diff --git a/test/unit/gateways/clearhaus_test.rb b/test/unit/gateways/clearhaus_test.rb index d0b383e962f..b877de05e4f 100644 --- a/test/unit/gateways/clearhaus_test.rb +++ b/test/unit/gateways/clearhaus_test.rb @@ -56,7 +56,7 @@ def test_successful_authorize_with_threed assert_success response assert response.test? end.check_request do |endpoint, data, headers| - expr = { threed_secure: { pares: '123' } }.to_query + expr = { card: { pares: '123' } }.to_query assert_match expr, data end.respond_with(successful_authorize_response) end @@ -225,7 +225,7 @@ def test_signing_request end.check_request do |method, endpoint, data, headers| assert headers['Signature'] assert_match %r{7e51b92e-ca7e-48e3-8a96-7d66cf1f2da2 RS256-hex}, headers['Signature'] - assert_match %r{02f56ed1f6c60cdefd$}, headers['Signature'] + assert_match %r{25f8283c3cc43911d7$}, headers['Signature'] end.respond_with(successful_authorize_response) end @@ -244,7 +244,7 @@ def test_cleans_whitespace_from_private_key end.check_request do |method, endpoint, data, headers| assert headers['Signature'] assert_match %r{7e51b92e-ca7e-48e3-8a96-7d66cf1f2da2 RS256-hex}, headers['Signature'] - assert_match %r{02f56ed1f6c60cdefd$}, headers['Signature'] + assert_match %r{25f8283c3cc43911d7$}, headers['Signature'] end.respond_with(successful_authorize_response) end @@ -275,7 +275,7 @@ def pre_scrubbed starting SSL for gateway.test.clearhaus.com:443... SSL established <- "POST /authorizations HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nAuthorization: Basic NTI2Y2Y1NjQtMTE5Yy00YmI2LTljZjgtMDAxNWVhYzdlNGY2Og==\r\nUser-Agent: Clearhaus ActiveMerchantBindings/1.54.0\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nConnection: close\r\nHost: gateway.test.clearhaus.com\r\nContent-Length: 128\r\n\r\n" -<- "amount=100&card%5Bcsc%5D=123&card%5Bexpire_month%5D=09&card%5Bexpire_year%5D=2016&card%5Bnumber%5D=4111111111111111&currency=EUR" +<- "amount=100&card%5Bcsc%5D=123&card%5Bexpire_month%5D=09&card%5Bexpire_year%5D=2016&card%5Bpan%5D=4111111111111111&currency=EUR" -> "HTTP/1.1 201 Created\r\n" -> "Content-Type: application/vnd.clearhaus-gateway.hal+json; version=0.9.0; charset=utf-8\r\n" -> "Date: Wed, 28 Oct 2015 18:56:11 GMT\r\n" @@ -318,7 +318,7 @@ def post_scrubbed starting SSL for gateway.test.clearhaus.com:443... SSL established <- "POST /authorizations HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nAuthorization: Basic [FILTERED]\r\nUser-Agent: Clearhaus ActiveMerchantBindings/1.54.0\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nConnection: close\r\nHost: gateway.test.clearhaus.com\r\nContent-Length: 128\r\n\r\n" -<- "amount=100&card%5Bcsc%5D=[FILTERED]&card%5Bexpire_month%5D=09&card%5Bexpire_year%5D=2016&card%5Bnumber%5D=[FILTERED]&currency=EUR" +<- "amount=100&card%5Bcsc%5D=[FILTERED]&card%5Bexpire_month%5D=09&card%5Bexpire_year%5D=2016&card%5Bpan%5D=[FILTERED]&currency=EUR" -> "HTTP/1.1 201 Created\r\n" -> "Content-Type: application/vnd.clearhaus-gateway.hal+json; version=0.9.0; charset=utf-8\r\n" -> "Date: Wed, 28 Oct 2015 18:56:11 GMT\r\n" From 60efe5c5bd27cafa22edb6cdef2273ca7a8da72f Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 8 Nov 2018 15:08:40 -0500 Subject: [PATCH 653/677] RuboCop: fix block spacing This is actually two fixes, Layout/SpaceInsideBlockBraces and Layout/SpaceBeforeBlockBraces, because the diff actually looks worse if you do either of them alone (and the same lines largely get touched on the follow-up diff anyway). --- .rubocop_todo.yml | 16 -------- lib/active_merchant/billing/check.rb | 2 +- lib/active_merchant/billing/compatibility.rb | 6 +-- lib/active_merchant/billing/gateways/adyen.rb | 6 +-- .../billing/gateways/allied_wallet.rb | 2 +- .../billing/gateways/authorize_net.rb | 4 +- .../billing/gateways/authorize_net_arb.rb | 2 +- .../billing/gateways/authorize_net_cim.rb | 4 +- .../billing/gateways/axcessms.rb | 4 +- .../billing/gateways/balanced.rb | 10 ++--- .../gateways/beanstream/beanstream_core.rb | 2 +- .../billing/gateways/blue_pay.rb | 2 +- .../billing/gateways/blue_snap.rb | 2 +- .../billing/gateways/borgun.rb | 2 +- .../billing/gateways/braintree_blue.rb | 2 +- .../billing/gateways/bridge_pay.rb | 2 +- lib/active_merchant/billing/gateways/cams.rb | 2 +- .../billing/gateways/cardknox.rb | 4 +- .../billing/gateways/cardprocess.rb | 2 +- .../billing/gateways/cashnet.rb | 2 +- lib/active_merchant/billing/gateways/cc5.rb | 2 +- .../billing/gateways/creditcall.rb | 4 +- .../billing/gateways/credorax.rb | 6 +-- .../billing/gateways/ct_payment.rb | 2 +- lib/active_merchant/billing/gateways/culqi.rb | 2 +- .../billing/gateways/cyber_source.rb | 2 +- .../billing/gateways/data_cash.rb | 2 +- lib/active_merchant/billing/gateways/dibs.rb | 2 +- .../billing/gateways/digitzs.rb | 4 +- .../billing/gateways/elavon.rb | 2 +- .../billing/gateways/eway_rapid.rb | 2 +- lib/active_merchant/billing/gateways/exact.rb | 2 +- .../billing/gateways/federated_canada.rb | 2 +- .../billing/gateways/first_giving.rb | 2 +- .../billing/gateways/firstdata_e4.rb | 2 +- .../billing/gateways/flo2cash.rb | 4 +- .../billing/gateways/garanti.rb | 2 +- .../billing/gateways/global_collect.rb | 2 +- lib/active_merchant/billing/gateways/hdfc.rb | 2 +- .../billing/gateways/inspire.rb | 2 +- .../billing/gateways/iridium.rb | 20 +++++----- lib/active_merchant/billing/gateways/iveri.rb | 2 +- .../billing/gateways/jetpay.rb | 2 +- .../billing/gateways/jetpay_v2.rb | 2 +- .../billing/gateways/maxipago.rb | 2 +- .../billing/gateways/merchant_e_solutions.rb | 2 +- .../billing/gateways/merchant_one.rb | 2 +- .../billing/gateways/merchant_partners.rb | 2 +- .../billing/gateways/merchant_warrior.rb | 4 +- .../billing/gateways/micropayment.rb | 2 +- lib/active_merchant/billing/gateways/migs.rb | 2 +- .../billing/gateways/modern_payments_cim.rb | 4 +- .../billing/gateways/moneris.rb | 4 +- .../billing/gateways/moneris_us.rb | 4 +- .../billing/gateways/money_movers.rb | 2 +- .../billing/gateways/nab_transact.rb | 2 +- .../billing/gateways/net_registry.rb | 2 +- .../billing/gateways/netaxept.rb | 12 +++--- .../billing/gateways/netbilling.rb | 2 +- .../billing/gateways/netpay.rb | 2 +- lib/active_merchant/billing/gateways/nmi.rb | 2 +- lib/active_merchant/billing/gateways/ogone.rb | 6 +-- lib/active_merchant/billing/gateways/opp.rb | 2 +- .../billing/gateways/orbital.rb | 4 +- .../billing/gateways/pac_net_raven.rb | 2 +- .../billing/gateways/pay_conex.rb | 2 +- .../billing/gateways/pay_gate_xml.rb | 4 +- .../billing/gateways/pay_junction.rb | 2 +- .../billing/gateways/pay_junction_v2.rb | 4 +- .../billing/gateways/pay_secure.rb | 2 +- .../billing/gateways/paybox_direct.rb | 2 +- lib/active_merchant/billing/gateways/payex.rb | 14 +++---- .../gateways/payflow/payflow_common_api.rb | 4 +- .../billing/gateways/payscout.rb | 2 +- .../billing/gateways/payu_in.rb | 6 +-- .../billing/gateways/psl_card.rb | 2 +- .../billing/gateways/quantum.rb | 2 +- .../billing/gateways/quickbooks.rb | 10 ++--- .../billing/gateways/quickpay/quickpay_v10.rb | 2 +- .../billing/gateways/qvalent.rb | 4 +- .../billing/gateways/realex.rb | 2 +- .../billing/gateways/secure_net.rb | 2 +- .../billing/gateways/secure_pay_au.rb | 2 +- .../billing/gateways/skip_jack.rb | 2 +- .../billing/gateways/smart_ps.rb | 2 +- .../trans_first_transaction_express.rb | 2 +- .../billing/gateways/transact_pro.rb | 4 +- .../billing/gateways/usa_epay_transaction.rb | 2 +- lib/active_merchant/billing/gateways/vanco.rb | 4 +- .../billing/gateways/viaklix.rb | 2 +- .../billing/gateways/visanet_peru.rb | 2 +- .../billing/gateways/worldpay.rb | 20 +++++----- lib/active_merchant/billing/response.rb | 2 +- lib/active_merchant/country.rb | 8 ++-- lib/support/gateway_support.rb | 4 +- .../gateways/remote_braintree_blue_test.rb | 2 +- test/remote/gateways/remote_moneris_test.rb | 2 +- test/remote/gateways/remote_paypal_test.rb | 2 +- .../gateways/remote_securion_pay_test.rb | 6 +-- test/test_helper.rb | 2 +- test/unit/country_code_test.rb | 2 +- test/unit/credit_card_test.rb | 2 +- test/unit/gateways/balanced_test.rb | 2 +- test/unit/gateways/cyber_source_test.rb | 2 +- test/unit/gateways/data_cash_test.rb | 4 +- test/unit/gateways/exact_test.rb | 2 +- test/unit/gateways/firstdata_e4_test.rb | 4 +- test/unit/gateways/firstdata_e4_v27_test.rb | 2 +- test/unit/gateways/migs_test.rb | 6 +-- test/unit/gateways/optimal_payment_test.rb | 4 +- test/unit/gateways/pac_net_raven_test.rb | 6 +-- test/unit/gateways/realex_test.rb | 2 +- test/unit/gateways/securion_pay_test.rb | 4 +- test/unit/gateways/stripe_test.rb | 10 ++--- test/unit/gateways/webpay_test.rb | 2 +- test/unit/gateways/worldpay_test.rb | 2 +- test/unit/multi_response_test.rb | 38 +++++++++---------- 117 files changed, 217 insertions(+), 233 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a93108be0b4..10ed49082bc 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -134,14 +134,6 @@ Layout/SpaceAroundKeyword: Layout/SpaceAroundOperators: Enabled: false -# Offense count: 182 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceBeforeBlockBraces: - Enabled: false - # Offense count: 118 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. @@ -156,14 +148,6 @@ Layout/SpaceInsideArrayPercentLiteral: Exclude: - 'lib/active_merchant/billing/gateways/migs/migs_codes.rb' -# Offense count: 345 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: - Enabled: false - # Offense count: 1186 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. diff --git a/lib/active_merchant/billing/check.rb b/lib/active_merchant/billing/check.rb index 0653848f3f5..6dcba4b0267 100644 --- a/lib/active_merchant/billing/check.rb +++ b/lib/active_merchant/billing/check.rb @@ -59,7 +59,7 @@ def credit_card? # (3(d1 + d4 + d7) + 7(d2 + d5 + d8) + 1(d3 + d6 + d9))mod 10 = 0 # See http://en.wikipedia.org/wiki/Routing_transit_number#Internal_checksums def valid_routing_number? - digits = routing_number.to_s.split('').map(&:to_i).select{|d| (0..9).cover?(d)} + digits = routing_number.to_s.split('').map(&:to_i).select { |d| (0..9).cover?(d) } case digits.size when 9 checksum = ((3 * (digits[0] + digits[3] + digits[6])) + diff --git a/lib/active_merchant/billing/compatibility.rb b/lib/active_merchant/billing/compatibility.rb index df999f60ed3..11103dcee68 100644 --- a/lib/active_merchant/billing/compatibility.rb +++ b/lib/active_merchant/billing/compatibility.rb @@ -61,7 +61,7 @@ def internal_errors class Errors < Hash def initialize - super(){|h, k| h[k] = []} + super() { |h, k| h[k] = [] } end alias count size @@ -75,7 +75,7 @@ def []=(key, value) end def empty? - all?{|k, v| v&.empty?} + all? { |k, v| v&.empty? } end def on(field) @@ -91,7 +91,7 @@ def add_to_base(error) end def each_full - full_messages.each{|msg| yield msg} + full_messages.each { |msg| yield msg } end def full_messages diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb index de0f15f32ee..2e7b5ba1eb9 100644 --- a/lib/active_merchant/billing/gateways/adyen.rb +++ b/lib/active_merchant/billing/gateways/adyen.rb @@ -34,8 +34,8 @@ def initialize(options={}) def purchase(money, payment, options={}) MultiResponse.run do |r| - r.process{authorize(money, payment, options)} - r.process{capture(money, r.authorization, options)} + r.process { authorize(money, payment, options) } + r.process { capture(money, r.authorization, options) } end end @@ -216,7 +216,7 @@ def add_card(post, credit_card) cvc: credit_card.verification_value } - card.delete_if{|k, v| v.blank? } + card.delete_if { |k, v| v.blank? } card[:holderName] ||= 'Not Provided' if credit_card.is_a?(NetworkTokenizationCreditCard) requires!(card, :expiryMonth, :expiryYear, :holderName, :number) post[:card] = card diff --git a/lib/active_merchant/billing/gateways/allied_wallet.rb b/lib/active_merchant/billing/gateways/allied_wallet.rb index 55181e90d30..8cdbd6f4eaa 100644 --- a/lib/active_merchant/billing/gateways/allied_wallet.rb +++ b/lib/active_merchant/billing/gateways/allied_wallet.rb @@ -182,7 +182,7 @@ def parse(body) def parse_element(response, node) if node.has_elements? - node.elements.each{|element| parse_element(response, element) } + node.elements.each { |element| parse_element(response, element) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index db5d98b69aa..738bc90a586 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -199,7 +199,7 @@ def unstore(authorization) end def verify_credentials - response = commit(:verify_credentials) { } + response = commit(:verify_credentials) {} response.success? end @@ -394,7 +394,7 @@ def add_payment_source(xml, source, options, action = nil) end def camel_case_lower(key) - String(key).split('_').inject([]){ |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }.join + String(key).split('_').inject([]) { |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }.join end def add_settings(xml, source, options) diff --git a/lib/active_merchant/billing/gateways/authorize_net_arb.rb b/lib/active_merchant/billing/gateways/authorize_net_arb.rb index 8781f60ea66..406cc55e50e 100644 --- a/lib/active_merchant/billing/gateways/authorize_net_arb.rb +++ b/lib/active_merchant/billing/gateways/authorize_net_arb.rb @@ -407,7 +407,7 @@ def recurring_parse(action, xml) def recurring_parse_element(response, node) if node.has_elements? - node.elements.each{|e| recurring_parse_element(response, e) } + node.elements.each { |e| recurring_parse_element(response, e) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb index 3a5cce3d5e5..0ca1ec4d7a0 100644 --- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb +++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb @@ -878,7 +878,7 @@ def tag_unless_blank(xml, tag_name, data) end def format_extra_options(options) - options&.map{ |k, v| "#{k}=#{v}" }&.join('&') + options&.map { |k, v| "#{k}=#{v}" }&.join('&') end def parse_direct_response(params) @@ -952,7 +952,7 @@ def parse(action, xml) def parse_element(node) if node.has_elements? response = {} - node.elements.each{ |e| + node.elements.each { |e| key = e.name.underscore value = parse_element(e) if response.has_key?(key) diff --git a/lib/active_merchant/billing/gateways/axcessms.rb b/lib/active_merchant/billing/gateways/axcessms.rb index 59c8edaa4ea..7f9207ff6a2 100644 --- a/lib/active_merchant/billing/gateways/axcessms.rb +++ b/lib/active_merchant/billing/gateways/axcessms.rb @@ -94,11 +94,11 @@ def parse(body) def parse_element(response, node) if node.has_attributes? - node.attributes.each{|name, value| response["#{node.name}_#{name}".underscore.to_sym] = value } + node.attributes.each { |name, value| response["#{node.name}_#{name}".underscore.to_sym] = value } end if node.has_elements? - node.elements.each{|element| parse_element(response, element) } + node.elements.each { |element| parse_element(response, element) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/balanced.rb b/lib/active_merchant/billing/gateways/balanced.rb index 671cc596bf3..f9b7accff02 100644 --- a/lib/active_merchant/billing/gateways/balanced.rb +++ b/lib/active_merchant/billing/gateways/balanced.rb @@ -45,12 +45,12 @@ def purchase(money, payment_method, options = {}) MultiResponse.run do |r| identifier = if(payment_method.respond_to?(:number)) - r.process{store(payment_method, options)} + r.process { store(payment_method, options) } r.authorization else payment_method end - r.process{commit('debits', "cards/#{card_identifier_from(identifier)}/debits", post)} + r.process { commit('debits', "cards/#{card_identifier_from(identifier)}/debits", post) } end end @@ -62,12 +62,12 @@ def authorize(money, payment_method, options = {}) MultiResponse.run do |r| identifier = if(payment_method.respond_to?(:number)) - r.process{store(payment_method, options)} + r.process { store(payment_method, options) } r.authorization else payment_method end - r.process{commit('card_holds', "cards/#{card_identifier_from(identifier)}/card_holds", post)} + r.process { commit('card_holds', "cards/#{card_identifier_from(identifier)}/card_holds", post) } end end @@ -118,7 +118,7 @@ def reference_identifier_from(identifier) when %r{\|} uri = identifier. split('|'). - detect{|part| part.size > 0} + detect { |part| part.size > 0 } uri.split('/')[2] when %r{\/} identifier.split('/')[5] diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb index e3ff636c26f..5d0640262fe 100644 --- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb @@ -463,7 +463,7 @@ def post_data(params, use_profile_api) params[:vbvEnabled] = '0' params[:scEnabled] = '0' - params.reject{|k, v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') + params.reject { |k, v| v.blank? }.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/blue_pay.rb b/lib/active_merchant/billing/gateways/blue_pay.rb index b3f789b7de3..b80ffcc2575 100644 --- a/lib/active_merchant/billing/gateways/blue_pay.rb +++ b/lib/active_merchant/billing/gateways/blue_pay.rb @@ -345,7 +345,7 @@ def parse_recurring(response_fields, opts={}) # expected status? def parse(body) # The bp20api has max one value per form field. - response_fields = Hash[CGI::parse(body).map{|k, v| [k.upcase, v.first]}] + response_fields = Hash[CGI::parse(body).map { |k, v| [k.upcase, v.first] }] if response_fields.include? 'REBILL_ID' return parse_recurring(response_fields) diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb index aaeaee85478..8c55f6910b7 100644 --- a/lib/active_merchant/billing/gateways/blue_snap.rb +++ b/lib/active_merchant/billing/gateways/blue_snap.rb @@ -230,7 +230,7 @@ def parse(response) def parse_element(parsed, node) if !node.elements.empty? - node.elements.each {|e| parse_element(parsed, e) } + node.elements.each { |e| parse_element(parsed, e) } else parsed[node.name.downcase] = node.text end diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb index df56f97646d..b949144fcfb 100644 --- a/lib/active_merchant/billing/gateways/borgun.rb +++ b/lib/active_merchant/billing/gateways/borgun.rb @@ -76,7 +76,7 @@ def scrub(transcript) private - CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")} + CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") } CURRENCY_CODES['ISK'] = '352' CURRENCY_CODES['EUR'] = '978' CURRENCY_CODES['USD'] = '840' diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index d39a4b72b56..6a263624017 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -123,7 +123,7 @@ def store(creditcard, options = {}) if options[:customer].present? MultiResponse.new.tap do |r| customer_exists_response = nil - r.process{customer_exists_response = check_customer_exists(options[:customer])} + r.process { customer_exists_response = check_customer_exists(options[:customer]) } r.process do if customer_exists_response.params['exists'] add_credit_card_to_customer(creditcard, options) diff --git a/lib/active_merchant/billing/gateways/bridge_pay.rb b/lib/active_merchant/billing/gateways/bridge_pay.rb index 51d6cf3bc4d..d8cf6218265 100644 --- a/lib/active_merchant/billing/gateways/bridge_pay.rb +++ b/lib/active_merchant/billing/gateways/bridge_pay.rb @@ -237,7 +237,7 @@ def post_data(post) { :UserName => @options[:user_name], :Password => @options[:password] - }.merge(post).collect{|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') + }.merge(post).collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/cams.rb b/lib/active_merchant/billing/gateways/cams.rb index 872c7818b2b..4fd30dd0489 100644 --- a/lib/active_merchant/billing/gateways/cams.rb +++ b/lib/active_merchant/billing/gateways/cams.rb @@ -219,7 +219,7 @@ def post_data(parameters = {}) parameters[:password] = @options[:password] parameters[:username] = @options[:username] - parameters.collect{|k, v| "#{k}=#{v}" }.join('&') + parameters.collect { |k, v| "#{k}=#{v}" }.join('&') end def error_code_from(response) diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb index 634eb8a72ac..10b3976dc7d 100644 --- a/lib/active_merchant/billing/gateways/cardknox.rb +++ b/lib/active_merchant/billing/gateways/cardknox.rb @@ -276,7 +276,7 @@ def parse(body) amount: fields['xAuthAmount'], masked_card_num: fields['xMaskedCardNumber'], masked_account_number: fields['MaskedAccountNumber'] - }.delete_if{|k, v| v.nil?} + }.delete_if { |k, v| v.nil? } end def commit(action, source_type, parameters) @@ -320,7 +320,7 @@ def post_data(command, parameters = {}) initial_parameters[:Hash] = "s/#{seed}/#{hash}/n" unless @options[:pin].blank? parameters = initial_parameters.merge(parameters) - parameters.reject{|k, v| v.blank?}.collect{ |key, value| "x#{key}=#{CGI.escape(value.to_s)}" }.join('&') + parameters.reject { |k, v| v.blank? }.collect { |key, value| "x#{key}=#{CGI.escape(value.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/cardprocess.rb b/lib/active_merchant/billing/gateways/cardprocess.rb index 42824ccf952..c91121c0641 100644 --- a/lib/active_merchant/billing/gateways/cardprocess.rb +++ b/lib/active_merchant/billing/gateways/cardprocess.rb @@ -189,7 +189,7 @@ def post_data(action, parameters = {}) post[:authentication][:password] = @options[:password] post[:authentication][:entityId] = @options[:entity_id] post[:paymentType] = action - dot_flatten_hash(post).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') + dot_flatten_hash(post).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def error_code_from(response) diff --git a/lib/active_merchant/billing/gateways/cashnet.rb b/lib/active_merchant/billing/gateways/cashnet.rb index 880ffb4986c..48a7d1308c5 100644 --- a/lib/active_merchant/billing/gateways/cashnet.rb +++ b/lib/active_merchant/billing/gateways/cashnet.rb @@ -136,7 +136,7 @@ def parse(body) match = body.match(/<cngateway>(.*)<\/cngateway>/) return nil unless match - Hash[CGI::parse(match[1]).map{|k, v| [k.to_sym, v.first]}] + Hash[CGI::parse(match[1]).map { |k, v| [k.to_sym, v.first] }] end def handle_response(response) diff --git a/lib/active_merchant/billing/gateways/cc5.rb b/lib/active_merchant/billing/gateways/cc5.rb index 695eb7a8703..3d25ec7d3f1 100644 --- a/lib/active_merchant/billing/gateways/cc5.rb +++ b/lib/active_merchant/billing/gateways/cc5.rb @@ -174,7 +174,7 @@ def parse(body) def parse_element(response, node) if node.has_elements? - node.elements.each{|element| parse_element(response, element) } + node.elements.each { |element| parse_element(response, element) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/creditcall.rb b/lib/active_merchant/billing/gateways/creditcall.rb index 554a12ac6be..45f84569f5d 100644 --- a/lib/active_merchant/billing/gateways/creditcall.rb +++ b/lib/active_merchant/billing/gateways/creditcall.rb @@ -147,7 +147,7 @@ def build_xml_request def add_transaction_details(xml, amount, authorization, type, options={}) xml.TransactionDetails do xml.MessageType type - xml.Amount(unit: 'Minor'){ xml.text(amount) } if amount + xml.Amount(unit: 'Minor') { xml.text(amount) } if amount xml.CardEaseReference authorization if authorization xml.VoidReason '01' if type == 'Void' end @@ -157,7 +157,7 @@ def add_terminal_details(xml, options={}) xml.TerminalDetails do xml.TerminalID @options[:terminal_id] xml.TransactionKey @options[:transaction_key] - xml.Software(version: 'SoftwareVersion'){ xml.text('SoftwareName') } + xml.Software(version: 'SoftwareVersion') { xml.text('SoftwareName') } end end diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb index 4c2f173fb0f..ccc42a508ed 100644 --- a/lib/active_merchant/billing/gateways/credorax.rb +++ b/lib/active_merchant/billing/gateways/credorax.rb @@ -317,11 +317,11 @@ def sign_request(params) end def post_data(action, params, reference_action) - params.keys.each { |key| params[key] = params[key].to_s} + params.keys.each { |key| params[key] = params[key].to_s } params[:M] = @options[:merchant_id] params[:O] = request_action(action, reference_action) params[:K] = sign_request(params) - params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') + params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') end def request_action(action, reference_action) @@ -337,7 +337,7 @@ def url end def parse(body) - Hash[CGI::parse(body).map{|k, v| [k.upcase, v.first]}] + Hash[CGI::parse(body).map { |k, v| [k.upcase, v.first] }] end def success_from(response) diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb index 2fde2028088..315f16375d8 100644 --- a/lib/active_merchant/billing/gateways/ct_payment.rb +++ b/lib/active_merchant/billing/gateways/ct_payment.rb @@ -224,7 +224,7 @@ def commit(action, parameters) commit_raw(action, parameters) else MultiResponse.run(true) do |r| - r.process { commit_raw(action, parameters)} + r.process { commit_raw(action, parameters) } r.process { split_auth = split_authorization(r.authorization) auth = (action.include?('recur')? split_auth[4] : split_auth[0]) diff --git a/lib/active_merchant/billing/gateways/culqi.rb b/lib/active_merchant/billing/gateways/culqi.rb index 7b0e078207a..80b4d030198 100644 --- a/lib/active_merchant/billing/gateways/culqi.rb +++ b/lib/active_merchant/billing/gateways/culqi.rb @@ -235,7 +235,7 @@ def headers end def post_data(action, params) - params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') + params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') end def url diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 2d3e2ceff0f..83f4734a5f0 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -755,7 +755,7 @@ def parse(xml) def parse_element(reply, node) if node.has_elements? - node.elements.each{|e| parse_element(reply, e) } + node.elements.each { |e| parse_element(reply, e) } else if node.parent.name =~ /item/ parent = node.parent.name diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb index 7a24dd3e5f3..def3288babf 100644 --- a/lib/active_merchant/billing/gateways/data_cash.rb +++ b/lib/active_merchant/billing/gateways/data_cash.rb @@ -286,7 +286,7 @@ def parse(body) def parse_element(response, node) if node.has_elements? - node.elements.each{|e| parse_element(response, e) } + node.elements.each { |e| parse_element(response, e) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb index 7e4d7ae7cec..e3936bc383f 100644 --- a/lib/active_merchant/billing/gateways/dibs.rb +++ b/lib/active_merchant/billing/gateways/dibs.rb @@ -87,7 +87,7 @@ def scrub(transcript) private - CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")} + CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") } CURRENCY_CODES['USD'] = '840' CURRENCY_CODES['DKK'] = '208' CURRENCY_CODES['NOK'] = '578' diff --git a/lib/active_merchant/billing/gateways/digitzs.rb b/lib/active_merchant/billing/gateways/digitzs.rb index 1dff6179965..bbc82d4a2b8 100644 --- a/lib/active_merchant/billing/gateways/digitzs.rb +++ b/lib/active_merchant/billing/gateways/digitzs.rb @@ -228,7 +228,7 @@ def success_from(response) def message_from(response) return response['message'] if response['message'] return 'Success' if success_from(response) - response['errors'].map {|error_hash| error_hash['detail'] }.join(', ') + response['errors'].map { |error_hash| error_hash['detail'] }.join(', ') end def authorization_from(response) @@ -263,7 +263,7 @@ def headers(options) def error_code_from(response) unless success_from(response) - response['errors'].nil? ? response['message'] : response['errors'].map {|error_hash| error_hash['code'] }.join(', ') + response['errors'].nil? ? response['message'] : response['errors'].map { |error_hash| error_hash['code'] }.join(', ') end end diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb index bdcf11490e4..ab234228e87 100644 --- a/lib/active_merchant/billing/gateways/elavon.rb +++ b/lib/active_merchant/billing/gateways/elavon.rb @@ -299,7 +299,7 @@ def preamble def parse(msg) resp = {} - msg.split(self.delimiter).collect{|li| + msg.split(self.delimiter).collect { |li| key, value = li.split('=') resp[key.to_s.strip.gsub(/^ssl_/, '')] = value.to_s.strip } diff --git a/lib/active_merchant/billing/gateways/eway_rapid.rb b/lib/active_merchant/billing/gateways/eway_rapid.rb index c8fb53e0aa0..29d06a837b4 100644 --- a/lib/active_merchant/billing/gateways/eway_rapid.rb +++ b/lib/active_merchant/billing/gateways/eway_rapid.rb @@ -299,7 +299,7 @@ def success?(response) end def parse_errors(message) - errors = message.split(',').collect{|code| MESSAGES[code.strip]}.flatten.join(',') + errors = message.split(',').collect { |code| MESSAGES[code.strip] }.flatten.join(',') errors.presence || message end diff --git a/lib/active_merchant/billing/gateways/exact.rb b/lib/active_merchant/billing/gateways/exact.rb index a388bcc341f..06f31316e66 100644 --- a/lib/active_merchant/billing/gateways/exact.rb +++ b/lib/active_merchant/billing/gateways/exact.rb @@ -211,7 +211,7 @@ def parse(xml) parse_elements(response, root) end - response.delete_if{ |k, v| SENSITIVE_FIELDS.include?(k) } + response.delete_if { |k, v| SENSITIVE_FIELDS.include?(k) } end def parse_elements(response, root) diff --git a/lib/active_merchant/billing/gateways/federated_canada.rb b/lib/active_merchant/billing/gateways/federated_canada.rb index 639fd3a3aff..b6666a9fa44 100644 --- a/lib/active_merchant/billing/gateways/federated_canada.rb +++ b/lib/active_merchant/billing/gateways/federated_canada.rb @@ -152,7 +152,7 @@ def post_data(action, parameters = {}) parameters[:type] = action parameters[:username] = @options[:login] parameters[:password] = @options[:password] - parameters.map{|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') + parameters.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/first_giving.rb b/lib/active_merchant/billing/gateways/first_giving.rb index 3af7a394116..09dea7f8e5a 100644 --- a/lib/active_merchant/billing/gateways/first_giving.rb +++ b/lib/active_merchant/billing/gateways/first_giving.rb @@ -116,7 +116,7 @@ def post_data(post) end def encode(hash) - hash.collect{|(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&') + hash.collect { |(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&') end def creditcard_brand(brand) diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb index 655703826f4..12290ad51c6 100755 --- a/lib/active_merchant/billing/gateways/firstdata_e4.rb +++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb @@ -438,7 +438,7 @@ def parse(xml) parse_elements(response, root) end - response.delete_if{ |k, v| SENSITIVE_FIELDS.include?(k) } + response.delete_if { |k, v| SENSITIVE_FIELDS.include?(k) } end def parse_elements(response, root) diff --git a/lib/active_merchant/billing/gateways/flo2cash.rb b/lib/active_merchant/billing/gateways/flo2cash.rb index e3ced39eae0..1f5c9d8076b 100644 --- a/lib/active_merchant/billing/gateways/flo2cash.rb +++ b/lib/active_merchant/billing/gateways/flo2cash.rb @@ -71,7 +71,7 @@ def scrub(transcript) private - CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")} + CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") } CURRENCY_CODES['NZD'] = '554' def add_invoice(post, money, options) @@ -172,7 +172,7 @@ def parse(body, action) def parse_element(response, node) if node.has_elements? - node.elements.each{|element| parse_element(response, element) } + node.elements.each { |element| parse_element(response, element) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb index 64cf7224a95..3c7f19efc5d 100644 --- a/lib/active_merchant/billing/gateways/garanti.rb +++ b/lib/active_merchant/billing/gateways/garanti.rb @@ -240,7 +240,7 @@ def parse(body) def parse_element(response, node) if node.has_elements? - node.elements.each{|element| parse_element(response, element) } + node.elements.each { |element| parse_element(response, element) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb index d0f3702191c..370780d14f1 100644 --- a/lib/active_merchant/billing/gateways/global_collect.rb +++ b/lib/active_merchant/billing/gateways/global_collect.rb @@ -329,7 +329,7 @@ def error_code_from(succeeded, response) end def nestable_hash - Hash.new {|h, k| h[k] = Hash.new(&h.default_proc) } + Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) } end def capture_requested?(response) diff --git a/lib/active_merchant/billing/gateways/hdfc.rb b/lib/active_merchant/billing/gateways/hdfc.rb index 3037ccac471..142d7c83b82 100644 --- a/lib/active_merchant/billing/gateways/hdfc.rb +++ b/lib/active_merchant/billing/gateways/hdfc.rb @@ -57,7 +57,7 @@ def refund(amount, authorization, options={}) private - CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")} + CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") } CURRENCY_CODES['AED'] = '784' CURRENCY_CODES['AUD'] = '036' CURRENCY_CODES['CAD'] = '124' diff --git a/lib/active_merchant/billing/gateways/inspire.rb b/lib/active_merchant/billing/gateways/inspire.rb index 0e57ffe09f2..e7771e9ec81 100644 --- a/lib/active_merchant/billing/gateways/inspire.rb +++ b/lib/active_merchant/billing/gateways/inspire.rb @@ -201,7 +201,7 @@ def post_data(action, parameters = {}) post[:password] = @options[:password] post[:type] = action if action - request = post.merge(parameters).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') + request = post.merge(parameters).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') request end diff --git a/lib/active_merchant/billing/gateways/iridium.rb b/lib/active_merchant/billing/gateways/iridium.rb index 6b0ca00b4b7..6b6eda3805b 100644 --- a/lib/active_merchant/billing/gateways/iridium.rb +++ b/lib/active_merchant/billing/gateways/iridium.rb @@ -422,36 +422,36 @@ def parse_element(reply, node) node.attributes.each do |a, b| reply[:transaction_result][a.underscore.to_sym] = b end - node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements? + node.elements.each { |e| parse_element(reply[:transaction_result], e) } if node.has_elements? when 'CardDetailsTransactionResult' reply[:transaction_result] = {} node.attributes.each do |a, b| reply[:transaction_result][a.underscore.to_sym] = b end - node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements? + node.elements.each { |e| parse_element(reply[:transaction_result], e) } if node.has_elements? when 'TransactionOutputData' reply[:transaction_output_data] = {} - node.attributes.each{|a, b| reply[:transaction_output_data][a.underscore.to_sym] = b } - node.elements.each{|e| parse_element(reply[:transaction_output_data], e) } if node.has_elements? + node.attributes.each { |a, b| reply[:transaction_output_data][a.underscore.to_sym] = b } + node.elements.each { |e| parse_element(reply[:transaction_output_data], e) } if node.has_elements? when 'CustomVariables' reply[:custom_variables] = {} - node.attributes.each{|a, b| reply[:custom_variables][a.underscore.to_sym] = b } - node.elements.each{|e| parse_element(reply[:custom_variables], e) } if node.has_elements? + node.attributes.each { |a, b| reply[:custom_variables][a.underscore.to_sym] = b } + node.elements.each { |e| parse_element(reply[:custom_variables], e) } if node.has_elements? when 'GatewayEntryPoints' reply[:gateway_entry_points] = {} - node.attributes.each{|a, b| reply[:gateway_entry_points][a.underscore.to_sym] = b } - node.elements.each{|e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements? + node.attributes.each { |a, b| reply[:gateway_entry_points][a.underscore.to_sym] = b } + node.elements.each { |e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements? else k = node.name.underscore.to_sym if node.has_elements? reply[k] = {} - node.elements.each{|e| parse_element(reply[k], e) } + node.elements.each { |e| parse_element(reply[k], e) } else if node.has_attributes? reply[k] = {} - node.attributes.each{|a, b| reply[k][a.underscore.to_sym] = b } + node.attributes.each { |a, b| reply[k][a.underscore.to_sym] = b } else reply[k] = node.text end diff --git a/lib/active_merchant/billing/gateways/iveri.rb b/lib/active_merchant/billing/gateways/iveri.rb index 6d0f1f092df..4a8d96e4752 100644 --- a/lib/active_merchant/billing/gateways/iveri.rb +++ b/lib/active_merchant/billing/gateways/iveri.rb @@ -206,7 +206,7 @@ def parse_element(parsed, node) end if !node.elements.empty? - node.elements.each {|e| parse_element(parsed, e) } + node.elements.each { |e| parse_element(parsed, e) } else parsed[underscore(node.name)] = node.text end diff --git a/lib/active_merchant/billing/gateways/jetpay.rb b/lib/active_merchant/billing/gateways/jetpay.rb index cbe81b5368f..aaa955dd24a 100644 --- a/lib/active_merchant/billing/gateways/jetpay.rb +++ b/lib/active_merchant/billing/gateways/jetpay.rb @@ -315,7 +315,7 @@ def parse(body) def parse_element(response, node) if node.has_elements? - node.elements.each{|element| parse_element(response, element) } + node.elements.each { |element| parse_element(response, element) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/jetpay_v2.rb b/lib/active_merchant/billing/gateways/jetpay_v2.rb index ae99f7f75e3..515bba8fc84 100644 --- a/lib/active_merchant/billing/gateways/jetpay_v2.rb +++ b/lib/active_merchant/billing/gateways/jetpay_v2.rb @@ -324,7 +324,7 @@ def parse(body) def parse_element(response, node) if node.has_elements? - node.elements.each{|element| parse_element(response, element) } + node.elements.each { |element| parse_element(response, element) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/maxipago.rb b/lib/active_merchant/billing/gateways/maxipago.rb index d029d261b93..b4ca346327b 100644 --- a/lib/active_merchant/billing/gateways/maxipago.rb +++ b/lib/active_merchant/billing/gateways/maxipago.rb @@ -142,7 +142,7 @@ def parse(body) def parse_element(response, node) if node.has_elements? - node.elements.each{|element| parse_element(response, element) } + node.elements.each { |element| parse_element(response, element) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb index fd7368d68db..bad8070e2d1 100644 --- a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +++ b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb @@ -186,7 +186,7 @@ def post_data(action, parameters = {}) post[:profile_key] = @options[:password] post[:transaction_type] = action if action - request = post.merge(parameters).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') + request = post.merge(parameters).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') request end end diff --git a/lib/active_merchant/billing/gateways/merchant_one.rb b/lib/active_merchant/billing/gateways/merchant_one.rb index e20dfe354bf..f2b081c2074 100644 --- a/lib/active_merchant/billing/gateways/merchant_one.rb +++ b/lib/active_merchant/billing/gateways/merchant_one.rb @@ -99,7 +99,7 @@ def post_data(action, parameters = {}) end def parse(data) - responses = CGI.parse(data).inject({}){|h, (k, v)| h[k] = v.first; h} + responses = CGI.parse(data).inject({}) { |h, (k, v)| h[k] = v.first; h } Response.new( (responses['response'].to_i == 1), responses['responsetext'], diff --git a/lib/active_merchant/billing/gateways/merchant_partners.rb b/lib/active_merchant/billing/gateways/merchant_partners.rb index 3af4a301cdf..e4630211a5d 100644 --- a/lib/active_merchant/billing/gateways/merchant_partners.rb +++ b/lib/active_merchant/billing/gateways/merchant_partners.rb @@ -212,7 +212,7 @@ def parse_element(response, node) if node.elements.size == 0 response[node.name.downcase.underscore.to_sym] = node.text else - node.elements.each{|element| parse_element(response, element) } + node.elements.each { |element| parse_element(response, element) } end end diff --git a/lib/active_merchant/billing/gateways/merchant_warrior.rb b/lib/active_merchant/billing/gateways/merchant_warrior.rb index 6a8e5538bb5..8e92e21811e 100644 --- a/lib/active_merchant/billing/gateways/merchant_warrior.rb +++ b/lib/active_merchant/billing/gateways/merchant_warrior.rb @@ -158,7 +158,7 @@ def parse(body) def parse_element(response, node) if node.has_elements? - node.elements.each{|element| parse_element(response, element)} + node.elements.each { |element| parse_element(response, element) } else response[node.name.underscore.to_sym] = node.text end @@ -203,7 +203,7 @@ def success?(response) end def post_data(post) - post.collect{|k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') + post.collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/micropayment.rb b/lib/active_merchant/billing/gateways/micropayment.rb index 17a3750fb95..fc416311865 100644 --- a/lib/active_merchant/billing/gateways/micropayment.rb +++ b/lib/active_merchant/billing/gateways/micropayment.rb @@ -140,7 +140,7 @@ def headers end def post_data(action, params) - params.map {|k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&') + params.map { |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&') end def url(action) diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb index bb0c3ef7ae1..f689a41fc4f 100644 --- a/lib/active_merchant/billing/gateways/migs.rb +++ b/lib/active_merchant/billing/gateways/migs.rb @@ -249,7 +249,7 @@ def add_creditcard(post, creditcard) def add_creditcard_type(post, card_type) post[:Gateway] = 'ssl' - post[:card] = CARD_TYPES.detect{|ct| ct.am_code == card_type}.migs_long_code + post[:card] = CARD_TYPES.detect { |ct| ct.am_code == card_type }.migs_long_code end def parse(body) diff --git a/lib/active_merchant/billing/gateways/modern_payments_cim.rb b/lib/active_merchant/billing/gateways/modern_payments_cim.rb index 0d9ef36fc3e..b1626434d38 100644 --- a/lib/active_merchant/billing/gateways/modern_payments_cim.rb +++ b/lib/active_merchant/billing/gateways/modern_payments_cim.rb @@ -122,7 +122,7 @@ def build_request(action, params) xml.tag! action, { 'xmlns' => xmlns(action) } do xml.tag! 'clientId', @options[:login] xml.tag! 'clientCode', @options[:password] - params.each {|key, value| xml.tag! key, value } + params.each { |key, value| xml.tag! key, value } end end end @@ -207,7 +207,7 @@ def parse(action, xml) def parse_element(response, node) if node.has_elements? - node.elements.each{|e| parse_element(response, e) } + node.elements.each { |e| parse_element(response, e) } else response[node.name.underscore.to_sym] = node.text.to_s.strip end diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb index 839bac02869..9410a306b0a 100644 --- a/lib/active_merchant/billing/gateways/moneris.rb +++ b/lib/active_merchant/billing/gateways/moneris.rb @@ -307,8 +307,8 @@ def avs_element(address) tokens = full_address.split(/\s+/) element = REXML::Element.new('avs_info') - element.add_element('avs_street_number').text = tokens.select {|x| x =~ /\d/}.join(' ') - element.add_element('avs_street_name').text = tokens.reject {|x| x =~ /\d/}.join(' ') + element.add_element('avs_street_number').text = tokens.select { |x| x =~ /\d/ }.join(' ') + element.add_element('avs_street_name').text = tokens.reject { |x| x =~ /\d/ }.join(' ') element.add_element('avs_zipcode').text = address[:zip] element end diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb index 9355406aed3..28c06ea91d0 100644 --- a/lib/active_merchant/billing/gateways/moneris_us.rb +++ b/lib/active_merchant/billing/gateways/moneris_us.rb @@ -291,8 +291,8 @@ def avs_element(address) tokens = full_address.split(/\s+/) element = REXML::Element.new('avs_info') - element.add_element('avs_street_number').text = tokens.select{|x| x =~ /\d/}.join(' ') - element.add_element('avs_street_name').text = tokens.reject{|x| x =~ /\d/}.join(' ') + element.add_element('avs_street_number').text = tokens.select { |x| x =~ /\d/ }.join(' ') + element.add_element('avs_street_name').text = tokens.reject { |x| x =~ /\d/ }.join(' ') element.add_element('avs_zipcode').text = address[:zip] element end diff --git a/lib/active_merchant/billing/gateways/money_movers.rb b/lib/active_merchant/billing/gateways/money_movers.rb index 870b47d2ac4..8a7a1e9e9a4 100644 --- a/lib/active_merchant/billing/gateways/money_movers.rb +++ b/lib/active_merchant/billing/gateways/money_movers.rb @@ -144,7 +144,7 @@ def post_data(action, parameters = {}) parameters[:type] = action parameters[:username] = @options[:login] parameters[:password] = @options[:password] - parameters.map{|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') + parameters.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/nab_transact.rb b/lib/active_merchant/billing/gateways/nab_transact.rb index d09cf7ffc9d..f7df53da09b 100644 --- a/lib/active_merchant/billing/gateways/nab_transact.rb +++ b/lib/active_merchant/billing/gateways/nab_transact.rb @@ -280,7 +280,7 @@ def parse(body) def parse_element(response, node) if node.has_elements? - node.elements.each{|element| parse_element(response, element) } + node.elements.each { |element| parse_element(response, element) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/net_registry.rb b/lib/active_merchant/billing/gateways/net_registry.rb index 0440ee8be2f..8f199a88ca8 100644 --- a/lib/active_merchant/billing/gateways/net_registry.rb +++ b/lib/active_merchant/billing/gateways/net_registry.rb @@ -152,7 +152,7 @@ def commit(action, params) def post_data(action, params) params['COMMAND'] = TRANSACTIONS[action] params['LOGIN'] = "#{@options[:login]}/#{@options[:password]}" - escape_uri(params.map{|k, v| "#{k}=#{v}"}.join('&')) + escape_uri(params.map { |k, v| "#{k}=#{v}" }.join('&')) end # The upstream is picky and so we can't use CGI.escape like we want to diff --git a/lib/active_merchant/billing/gateways/netaxept.rb b/lib/active_merchant/billing/gateways/netaxept.rb index 18eb61964ca..6681259e657 100644 --- a/lib/active_merchant/billing/gateways/netaxept.rb +++ b/lib/active_merchant/billing/gateways/netaxept.rb @@ -31,8 +31,8 @@ def purchase(money, creditcard, options = {}) requires!(options, :order_id) MultiResponse.run do |r| - r.process{authorize(money, creditcard, options)} - r.process{capture(money, r.authorization, options)} + r.process { authorize(money, creditcard, options) } + r.process { capture(money, r.authorization, options) } end end @@ -40,9 +40,9 @@ def authorize(money, creditcard, options = {}) requires!(options, :order_id) MultiResponse.run do |r| - r.process{setup_transaction(money, options)} - r.process{add_and_auth_credit_card(r.authorization, creditcard, options)} - r.process{query_transaction(r.authorization, options)} + r.process { setup_transaction(money, options) } + r.process { add_and_auth_credit_card(r.authorization, creditcard, options) } + r.process { query_transaction(r.authorization, options) } end end @@ -173,7 +173,7 @@ def build_url(base, parameters=nil) end def encode(hash) - hash.collect{|(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&') + hash.collect { |(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/netbilling.rb b/lib/active_merchant/billing/gateways/netbilling.rb index 7b13aaf27cf..1cc79fe11fb 100644 --- a/lib/active_merchant/billing/gateways/netbilling.rb +++ b/lib/active_merchant/billing/gateways/netbilling.rb @@ -224,7 +224,7 @@ def post_data(action, parameters = {}) parameters[:pay_type] = 'C' parameters[:tran_type] = TRANSACTIONS[action] - parameters.reject{|k, v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') + parameters.reject { |k, v| v.blank? }.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') end end diff --git a/lib/active_merchant/billing/gateways/netpay.rb b/lib/active_merchant/billing/gateways/netpay.rb index 7b660cefe98..48e2a0a14d5 100644 --- a/lib/active_merchant/billing/gateways/netpay.rb +++ b/lib/active_merchant/billing/gateways/netpay.rb @@ -190,7 +190,7 @@ def commit(action, parameters, options) add_login_data(parameters) add_action(parameters, action, options) - post = parameters.collect{|key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') + post = parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') parse(ssl_post(url, post), parameters) end diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb index aa6e956f6c1..8591a802945 100644 --- a/lib/active_merchant/billing/gateways/nmi.rb +++ b/lib/active_merchant/billing/gateways/nmi.rb @@ -246,7 +246,7 @@ def headers end def post_data(action, params) - params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') + params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') end def url diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb index 99f998e895f..5d6041c887f 100644 --- a/lib/active_merchant/billing/gateways/ogone.rb +++ b/lib/active_merchant/billing/gateways/ogone.rb @@ -429,9 +429,9 @@ def calculate_signature(signed_parameters, algorithm, secret) raise "Unknown signature algorithm #{algorithm}" end - filtered_params = signed_parameters.select{|k, v| !v.blank?} + filtered_params = signed_parameters.select { |k, v| !v.blank? } sha_encryptor.hexdigest( - filtered_params.sort_by{|k, v| k.upcase}.map{|k, v| "#{k.upcase}=#{v}#{secret}"}.join('') + filtered_params.sort_by { |k, v| k.upcase }.map { |k, v| "#{k.upcase}=#{v}#{secret}" }.join('') ).upcase end @@ -446,7 +446,7 @@ def legacy_calculate_signature(parameters, secret) PSPID Operation ALIAS - ).map{|key| parameters[key]} + + ).map { |key| parameters[key] } + [secret] ).join('') ).upcase diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb index 19d3a11477f..03f6e92286e 100644 --- a/lib/active_merchant/billing/gateways/opp.rb +++ b/lib/active_merchant/billing/gateways/opp.rb @@ -272,7 +272,7 @@ def add_3d_secure(post, options) def add_options(post, options) post[:createRegistration] = options[:create_registration] if options[:create_registration] && !options[:registrationId] post[:testMode] = options[:test_mode] if test? && options[:test_mode] - options.each {|key, value| post[key] = value if key.to_s.match('customParameters\[[a-zA-Z0-9\._]{3,64}\]') } + options.each { |key, value| post[key] = value if key.to_s.match('customParameters\[[a-zA-Z0-9\._]{3,64}\]') } post['customParameters[SHOPPER_pluginId]'] = 'activemerchant' post['customParameters[custom_disable3DSecure]'] = options[:disable_3d_secure] if options[:disable_3d_secure] end diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index fe3f1a3b1d8..f85b73cd35a 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -521,7 +521,7 @@ def parse(body) def recurring_parse_element(response, node) if node.has_elements? - node.elements.each{|e| recurring_parse_element(response, e) } + node.elements.each { |e| recurring_parse_element(response, e) } else response[node.name.underscore.to_sym] = node.text end @@ -533,7 +533,7 @@ def commit(order, message_type, trace_number=nil) headers['Trace-number'] = trace_number.to_s headers['Merchant-Id'] = @options[:merchant_id] end - request = ->(url){ parse(ssl_post(url, order, headers))} + request = ->(url) { parse(ssl_post(url, order, headers)) } # Failover URL will be attempted in the event of a connection error response = begin diff --git a/lib/active_merchant/billing/gateways/pac_net_raven.rb b/lib/active_merchant/billing/gateways/pac_net_raven.rb index fbc5557fd07..952684b1943 100644 --- a/lib/active_merchant/billing/gateways/pac_net_raven.rb +++ b/lib/active_merchant/billing/gateways/pac_net_raven.rb @@ -107,7 +107,7 @@ def add_address(post, options) end def parse(body) - Hash[body.split('&').map{|x| x.split('=').map{|y| CGI.unescape(y)}}] + Hash[body.split('&').map { |x| x.split('=').map { |y| CGI.unescape(y) } }] end def commit(action, money, parameters) diff --git a/lib/active_merchant/billing/gateways/pay_conex.rb b/lib/active_merchant/billing/gateways/pay_conex.rb index 0095bcfc29b..d0ae08146e8 100644 --- a/lib/active_merchant/billing/gateways/pay_conex.rb +++ b/lib/active_merchant/billing/gateways/pay_conex.rb @@ -231,7 +231,7 @@ def message_from(response) def post_data(action, params) params[:transaction_type] = action - params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') + params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') end def unparsable_response(raw_response) diff --git a/lib/active_merchant/billing/gateways/pay_gate_xml.rb b/lib/active_merchant/billing/gateways/pay_gate_xml.rb index 7c17b1dfa3f..35261aaf564 100644 --- a/lib/active_merchant/billing/gateways/pay_gate_xml.rb +++ b/lib/active_merchant/billing/gateways/pay_gate_xml.rb @@ -162,8 +162,8 @@ def initialize(options = {}) def purchase(money, creditcard, options = {}) MultiResponse.run do |r| - r.process{authorize(money, creditcard, options)} - r.process{capture(money, r.authorization, options)} + r.process { authorize(money, creditcard, options) } + r.process { capture(money, r.authorization, options) } end end diff --git a/lib/active_merchant/billing/gateways/pay_junction.rb b/lib/active_merchant/billing/gateways/pay_junction.rb index 19dd8317037..68a24d6f8fc 100644 --- a/lib/active_merchant/billing/gateways/pay_junction.rb +++ b/lib/active_merchant/billing/gateways/pay_junction.rb @@ -366,7 +366,7 @@ def post_data(action, params) params[:version] = API_VERSION params[:transaction_type] = action - params.reject{|k, v| v.blank?}.collect{ |k, v| "dc_#{k}=#{CGI.escape(v.to_s)}" }.join('&') + params.reject { |k, v| v.blank? }.collect { |k, v| "dc_#{k}=#{CGI.escape(v.to_s)}" }.join('&') end def parse(body) diff --git a/lib/active_merchant/billing/gateways/pay_junction_v2.rb b/lib/active_merchant/billing/gateways/pay_junction_v2.rb index 2f9a5148dc7..aed266facd6 100644 --- a/lib/active_merchant/billing/gateways/pay_junction_v2.rb +++ b/lib/active_merchant/billing/gateways/pay_junction_v2.rb @@ -146,7 +146,7 @@ def headers end def post_data(params) - params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') + params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&') end def url(params={}) @@ -173,7 +173,7 @@ def success_from(response) def message_from(response) return response['response']['message'] if response['response'] - response['errors']&.inject(''){ |message, error| error['message'] + '|' + message } + response['errors']&.inject('') { |message, error| error['message'] + '|' + message } end def authorization_from(response) diff --git a/lib/active_merchant/billing/gateways/pay_secure.rb b/lib/active_merchant/billing/gateways/pay_secure.rb index 117b33939d9..76c13578379 100644 --- a/lib/active_merchant/billing/gateways/pay_secure.rb +++ b/lib/active_merchant/billing/gateways/pay_secure.rb @@ -104,7 +104,7 @@ def post_data(action, parameters = {}) parameters[:merchant_id] = @options[:login] parameters[:password] = @options[:password] - parameters.reject{|k, v| v.blank?}.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&') + parameters.reject { |k, v| v.blank? }.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&') end end end diff --git a/lib/active_merchant/billing/gateways/paybox_direct.rb b/lib/active_merchant/billing/gateways/paybox_direct.rb index ecb3d938a9f..e99d787f210 100644 --- a/lib/active_merchant/billing/gateways/paybox_direct.rb +++ b/lib/active_merchant/billing/gateways/paybox_direct.rb @@ -157,7 +157,7 @@ def commit(action, money = nil, parameters = nil) :test => test?, :authorization => response[:numappel].to_s + response[:numtrans].to_s, :fraud_review => false, - :sent_params => parameters.delete_if{|key, value| ['porteur', 'dateval', 'cvv'].include?(key.to_s)} + :sent_params => parameters.delete_if { |key, value| ['porteur', 'dateval', 'cvv'].include?(key.to_s) } ) end diff --git a/lib/active_merchant/billing/gateways/payex.rb b/lib/active_merchant/billing/gateways/payex.rb index b82b8c4d21b..c43e36bb13f 100644 --- a/lib/active_merchant/billing/gateways/payex.rb +++ b/lib/active_merchant/billing/gateways/payex.rb @@ -63,8 +63,8 @@ def authorize(amount, payment_method, options = {}) if payment_method.respond_to?(:number) # credit card authorization MultiResponse.new.tap do |r| - r.process {send_initialize(amount, true, options)} - r.process {send_purchasecc(payment_method, r.params['orderref'])} + r.process { send_initialize(amount, true, options) } + r.process { send_purchasecc(payment_method, r.params['orderref']) } end else # stored authorization @@ -91,8 +91,8 @@ def purchase(amount, payment_method, options = {}) if payment_method.respond_to?(:number) # credit card purchase MultiResponse.new.tap do |r| - r.process {send_initialize(amount, false, options)} - r.process {send_purchasecc(payment_method, r.params['orderref'])} + r.process { send_initialize(amount, false, options) } + r.process { send_purchasecc(payment_method, r.params['orderref']) } end else # stored purchase @@ -154,10 +154,10 @@ def store(creditcard, options = {}) requires!(options, :order_id) amount = amount(1) # 1 cent for authorization MultiResponse.run(:first) do |r| - r.process {send_create_agreement(options)} - r.process {send_initialize(amount, true, options.merge({agreement_ref: r.authorization}))} + r.process { send_create_agreement(options) } + r.process { send_initialize(amount, true, options.merge({agreement_ref: r.authorization})) } order_ref = r.params['orderref'] - r.process {send_purchasecc(creditcard, order_ref)} + r.process { send_purchasecc(creditcard, order_ref) } end end diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb index 32213491eb5..4ad1bd00739 100644 --- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb @@ -179,9 +179,9 @@ def parse_element(response, node) # in an RPPaymentResults element so we'll come here multiple times response[node_name] ||= [] response[node_name] << (payment_result_response = {}) - node.xpath('.//*').each{ |e| parse_element(payment_result_response, e) } + node.xpath('.//*').each { |e| parse_element(payment_result_response, e) } when node.xpath('.//*').to_a.any? - node.xpath('.//*').each{|e| parse_element(response, e) } + node.xpath('.//*').each { |e| parse_element(response, e) } when node_name.to_s =~ /amt$/ # *Amt elements don't put the value in the #text - instead they use a Currency attribute response[node_name] = node.attributes['Currency'].to_s diff --git a/lib/active_merchant/billing/gateways/payscout.rb b/lib/active_merchant/billing/gateways/payscout.rb index 88fb8624655..d2ad18b5a16 100644 --- a/lib/active_merchant/billing/gateways/payscout.rb +++ b/lib/active_merchant/billing/gateways/payscout.rb @@ -102,7 +102,7 @@ def add_creditcard(post, creditcard) end def parse(body) - Hash[body.split('&').map{|x| x.split('=')}] + Hash[body.split('&').map { |x| x.split('=') }] end def commit(action, money, parameters) diff --git a/lib/active_merchant/billing/gateways/payu_in.rb b/lib/active_merchant/billing/gateways/payu_in.rb index f75cbbd7df7..eabc32c1cd6 100644 --- a/lib/active_merchant/billing/gateways/payu_in.rb +++ b/lib/active_merchant/billing/gateways/payu_in.rb @@ -32,11 +32,11 @@ def purchase(money, payment, options={}) add_auth(post) MultiResponse.run do |r| - r.process{commit(url('purchase'), post)} + r.process { commit(url('purchase'), post) } if(r.params['enrolled'].to_s == '0') - r.process{commit(r.params['post_uri'], r.params['form_post_vars'])} + r.process { commit(r.params['post_uri'], r.params['form_post_vars']) } else - r.process{handle_3dsecure(r)} + r.process { handle_3dsecure(r) } end end end diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb index d0495a42037..77da4a123db 100644 --- a/lib/active_merchant/billing/gateways/psl_card.rb +++ b/lib/active_merchant/billing/gateways/psl_card.rb @@ -183,7 +183,7 @@ def add_address(post, options) address = options[:billing_address] || options[:address] return if address.nil? - post[:QAAddress] = [:address1, :address2, :city, :state].collect{|a| address[a]}.reject(&:blank?).join(' ') + post[:QAAddress] = [:address1, :address2, :city, :state].collect { |a| address[a] }.reject(&:blank?).join(' ') post[:QAPostcode] = address[:zip] end diff --git a/lib/active_merchant/billing/gateways/quantum.rb b/lib/active_merchant/billing/gateways/quantum.rb index 38a53eeb08c..4fd43ad07ca 100644 --- a/lib/active_merchant/billing/gateways/quantum.rb +++ b/lib/active_merchant/billing/gateways/quantum.rb @@ -251,7 +251,7 @@ def parse(xml) def parse_element(reply, node) if node.has_elements? - node.elements.each{|e| parse_element(reply, e) } + node.elements.each { |e| parse_element(reply, e) } else if node.parent.name =~ /item/ parent = node.parent.name + (node.parent.attributes['id'] ? '_' + node.parent.attributes['id'] : '') diff --git a/lib/active_merchant/billing/gateways/quickbooks.rb b/lib/active_merchant/billing/gateways/quickbooks.rb index 48442334eb2..1f73575bdab 100644 --- a/lib/active_merchant/billing/gateways/quickbooks.rb +++ b/lib/active_merchant/billing/gateways/quickbooks.rb @@ -224,17 +224,17 @@ def headers(method, uri) } # prepare components for signature - oauth_signature_base_string = [method.to_s.upcase, request_uri.to_s, oauth_parameters.to_param].map{|v| CGI.escape(v) }.join('&') - oauth_signing_key = [@options[:consumer_secret], @options[:token_secret]].map{|v| CGI.escape(v)}.join('&') + oauth_signature_base_string = [method.to_s.upcase, request_uri.to_s, oauth_parameters.to_param].map { |v| CGI.escape(v) }.join('&') + oauth_signing_key = [@options[:consumer_secret], @options[:token_secret]].map { |v| CGI.escape(v) }.join('&') hmac_signature = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), oauth_signing_key, oauth_signature_base_string) # append signature to required OAuth parameters oauth_parameters[:oauth_signature] = CGI.escape(Base64.encode64(hmac_signature).chomp.gsub(/\n/, '')) # prepare Authorization header string - oauth_parameters = Hash[oauth_parameters.sort_by {|k, _| k}] + oauth_parameters = Hash[oauth_parameters.sort_by { |k, _| k }] oauth_headers = ["OAuth realm=\"#{@options[:realm]}\""] - oauth_headers += oauth_parameters.map {|k, v| "#{k}=\"#{v}\""} + oauth_headers += oauth_parameters.map { |k, v| "#{k}=\"#{v}\"" } { 'Content-type' => 'application/json', @@ -258,7 +258,7 @@ def success?(response) end def message_from(response) - response['errors'].present? ? response['errors'].map {|error_hash| error_hash['message'] }.join(' ') : response['status'] + response['errors'].present? ? response['errors'].map { |error_hash| error_hash['message'] }.join(' ') : response['status'] end def errors_from(response) diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb index f26ed7eda57..10ad00b3ae3 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb @@ -78,7 +78,7 @@ def verify(credit_card, options={}) def store(credit_card, options = {}) MultiResponse.run do |r| r.process { create_store(options) } - r.process { authorize_store(r.authorization, credit_card, options)} + r.process { authorize_store(r.authorization, credit_card, options) } end end diff --git a/lib/active_merchant/billing/gateways/qvalent.rb b/lib/active_merchant/billing/gateways/qvalent.rb index 0dd7c279255..46c43aae0cd 100644 --- a/lib/active_merchant/billing/gateways/qvalent.rb +++ b/lib/active_merchant/billing/gateways/qvalent.rb @@ -103,7 +103,7 @@ def scrub(transcript) private - CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")} + CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") } CURRENCY_CODES['AUD'] = 'AUD' CURRENCY_CODES['INR'] = 'INR' @@ -197,7 +197,7 @@ def parse(body) def parse_element(response, node) if node.has_elements? - node.elements.each{|element| parse_element(response, element) } + node.elements.each { |element| parse_element(response, element) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb index 3e0e1a21276..ca0b91517b3 100644 --- a/lib/active_merchant/billing/gateways/realex.rb +++ b/lib/active_merchant/billing/gateways/realex.rb @@ -286,7 +286,7 @@ def add_network_tokenization_card(xml, payment) def format_address_code(address) code = [address[:zip].to_s, address[:address1].to_s + address[:address2].to_s] - code.collect{|e| e.gsub(/\D/, '')}.reject(&:empty?).join('|') + code.collect { |e| e.gsub(/\D/, '') }.reject(&:empty?).join('|') end def new_timestamp diff --git a/lib/active_merchant/billing/gateways/secure_net.rb b/lib/active_merchant/billing/gateways/secure_net.rb index 66ccc07dc00..f3abdf29935 100644 --- a/lib/active_merchant/billing/gateways/secure_net.rb +++ b/lib/active_merchant/billing/gateways/secure_net.rb @@ -247,7 +247,7 @@ def parse(xml) def recurring_parse_element(response, node) if node.has_elements? - node.elements.each{|e| recurring_parse_element(response, e) } + node.elements.each { |e| recurring_parse_element(response, e) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/secure_pay_au.rb b/lib/active_merchant/billing/gateways/secure_pay_au.rb index 3a6aa76775f..37a2845bbd5 100644 --- a/lib/active_merchant/billing/gateways/secure_pay_au.rb +++ b/lib/active_merchant/billing/gateways/secure_pay_au.rb @@ -276,7 +276,7 @@ def parse(body) def parse_element(response, node) if node.has_elements? - node.elements.each{|element| parse_element(response, element) } + node.elements.each { |element| parse_element(response, element) } else response[node.name.underscore.to_sym] = node.text end diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb index 3528b04f22c..158742d58f7 100644 --- a/lib/active_merchant/billing/gateways/skip_jack.rb +++ b/lib/active_merchant/billing/gateways/skip_jack.rb @@ -368,7 +368,7 @@ def add_invoice(post, options) post[:OrderDescription] = options[:description] if order_items = options[:items] - post[:OrderString] = order_items.collect { |item| "#{item[:sku]}~#{item[:description].tr('~', '-')}~#{item[:declared_value]}~#{item[:quantity]}~#{item[:taxable]}~~~~~~~~#{item[:tax_rate]}~||"}.join + post[:OrderString] = order_items.collect { |item| "#{item[:sku]}~#{item[:description].tr('~', '-')}~#{item[:declared_value]}~#{item[:quantity]}~#{item[:taxable]}~~~~~~~~#{item[:tax_rate]}~||" }.join else post[:OrderString] = '1~None~0.00~0~N~||' end diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb index fe196f6dc0b..0e1b7c0a699 100644 --- a/lib/active_merchant/billing/gateways/smart_ps.rb +++ b/lib/active_merchant/billing/gateways/smart_ps.rb @@ -263,7 +263,7 @@ def post_data(action, parameters = {}) post[:password] = @options[:password] post[:type] = action if action - request = post.merge(parameters).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') + request = post.merge(parameters).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&') request end diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb index c58ffb0d041..e9ac1ac2a9f 100644 --- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb @@ -321,7 +321,7 @@ def scrub(transcript) private - CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")} + CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") } CURRENCY_CODES['USD'] = '840' def headers diff --git a/lib/active_merchant/billing/gateways/transact_pro.rb b/lib/active_merchant/billing/gateways/transact_pro.rb index 783e5e18b29..5aaa36d756d 100644 --- a/lib/active_merchant/billing/gateways/transact_pro.rb +++ b/lib/active_merchant/billing/gateways/transact_pro.rb @@ -32,7 +32,7 @@ def purchase(amount, payment, options={}) post[:rs] = @options[:terminal] MultiResponse.run do |r| - r.process{commit('init', post)} + r.process { commit('init', post) } r.process do post = PostData.new post[:init_transaction_id] = r.authorization @@ -54,7 +54,7 @@ def authorize(amount, payment, options={}) post[:rs] = @options[:terminal] MultiResponse.run do |r| - r.process{commit('init_dms', post)} + r.process { commit('init_dms', post) } r.process do post = PostData.new post[:init_transaction_id] = r.authorization diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb index 4eb7827b27c..55d6b439956 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb @@ -253,7 +253,7 @@ def parse(body) :error_code => fields['UMerrorcode'], :acs_url => fields['UMacsurl'], :payload => fields['UMpayload'] - }.delete_if{|k, v| v.nil?} + }.delete_if { |k, v| v.nil? } end def commit(action, parameters) diff --git a/lib/active_merchant/billing/gateways/vanco.rb b/lib/active_merchant/billing/gateways/vanco.rb index 38e2f2aef87..546eedbca4e 100644 --- a/lib/active_merchant/billing/gateways/vanco.rb +++ b/lib/active_merchant/billing/gateways/vanco.rb @@ -82,8 +82,8 @@ def add_errors_to_response(response, errors_xml) response[:error_message] = error['ErrorDescription'] response[:error_codes] = error['ErrorCode'] elsif error.kind_of?(Array) - error_str = error.map { |e| e['ErrorDescription']}.join('. ') - error_codes = error.map { |e| e['ErrorCode']}.join(', ') + error_str = error.map { |e| e['ErrorDescription'] }.join('. ') + error_codes = error.map { |e| e['ErrorCode'] }.join(', ') response[:error_message] = "#{error_str}." response[:error_codes] = error_codes end diff --git a/lib/active_merchant/billing/gateways/viaklix.rb b/lib/active_merchant/billing/gateways/viaklix.rb index 269c5b3a8be..b68a8ec3ac9 100644 --- a/lib/active_merchant/billing/gateways/viaklix.rb +++ b/lib/active_merchant/billing/gateways/viaklix.rb @@ -165,7 +165,7 @@ def post_data(parameters) # Parse the response message def parse(msg) resp = {} - msg.split(self.delimiter).collect{|li| + msg.split(self.delimiter).collect { |li| key, value = li.split('=') resp[key.strip.gsub(/^ssl_/, '')] = value.to_s.strip } diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb index 6e5818bee63..70999dc58ee 100644 --- a/lib/active_merchant/billing/gateways/visanet_peru.rb +++ b/lib/active_merchant/billing/gateways/visanet_peru.rb @@ -82,7 +82,7 @@ def scrub(transcript) private - CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")} + CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") } CURRENCY_CODES['USD'] = 840 CURRENCY_CODES['PEN'] = 604 diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index 30b795da727..e5b30d2d6f8 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -30,8 +30,8 @@ def initialize(options = {}) def purchase(money, payment_method, options = {}) MultiResponse.run do |r| - r.process{authorize(money, payment_method, options)} - r.process{capture(money, r.authorization, options.merge(:authorization_validated => true))} + r.process { authorize(money, payment_method, options) } + r.process { capture(money, r.authorization, options.merge(:authorization_validated => true)) } end end @@ -42,19 +42,19 @@ def authorize(money, payment_method, options = {}) def capture(money, authorization, options = {}) MultiResponse.run do |r| - r.process{inquire_request(authorization, options, 'AUTHORISED')} unless options[:authorization_validated] + r.process { inquire_request(authorization, options, 'AUTHORISED') } unless options[:authorization_validated] if r.params authorization_currency = r.params['amount_currency_code'] options = options.merge(:currency => authorization_currency) if authorization_currency.present? end - r.process{capture_request(money, authorization, options)} + r.process { capture_request(money, authorization, options) } end end def void(authorization, options = {}) MultiResponse.run do |r| - r.process{inquire_request(authorization, options, 'AUTHORISED')} unless options[:authorization_validated] - r.process{cancel_request(authorization, options)} + r.process { inquire_request(authorization, options, 'AUTHORISED') } unless options[:authorization_validated] + r.process { cancel_request(authorization, options) } end end @@ -175,7 +175,7 @@ def build_authorization_request(money, payment_method, options) end def order_tag_attributes(options) - { 'orderCode' => options[:order_id], 'installationId' => options[:inst_id] || @options[:inst_id] }.reject{|_, v| !v} + { 'orderCode' => options[:order_id], 'installationId' => options[:inst_id] || @options[:inst_id] }.reject { |_, v| !v } end def build_capture_request(money, authorization, options) @@ -337,7 +337,7 @@ def parse_element(raw, node) end if node.has_elements? raw[node.name.underscore.to_sym] = true unless node.name.blank? - node.elements.each{|e| parse_element(raw, e) } + node.elements.each { |e| parse_element(raw, e) } else raw[node.name.underscore.to_sym] = node.text unless node.text.nil? end @@ -418,12 +418,12 @@ def error_code_from(success, raw) def required_status_message(raw, success_criteria) if(!success_criteria.include?(raw[:last_event])) - "A transaction status of #{success_criteria.collect{|c| "'#{c}'"}.join(" or ")} is required." + "A transaction status of #{success_criteria.collect { |c| "'#{c}'" }.join(" or ")} is required." end end def authorization_from(raw) - pair = raw.detect{|k, v| k.to_s =~ /_order_code$/} + pair = raw.detect { |k, v| k.to_s =~ /_order_code$/ } (pair ? pair.last : nil) end diff --git a/lib/active_merchant/billing/response.rb b/lib/active_merchant/billing/response.rb index 8470e8385e1..491bb0cab5b 100644 --- a/lib/active_merchant/billing/response.rb +++ b/lib/active_merchant/billing/response.rb @@ -70,7 +70,7 @@ def process(ignore_result=false) def <<(response) if response.is_a?(MultiResponse) - response.responses.each{|r| @responses << r} + response.responses.each { |r| @responses << r } else @responses << response end diff --git a/lib/active_merchant/country.rb b/lib/active_merchant/country.rb index 34710a2572e..bdc25799900 100644 --- a/lib/active_merchant/country.rb +++ b/lib/active_merchant/country.rb @@ -39,11 +39,11 @@ class Country def initialize(options = {}) @name = options.delete(:name) - @codes = options.collect{|k, v| CountryCode.new(v)} + @codes = options.collect { |k, v| CountryCode.new(v) } end def code(format) - @codes.detect{|c| c.format == format} + @codes.detect { |c| c.format == format } end def ==(other) @@ -324,9 +324,9 @@ def self.find(name) when 2, 3 upcase_name = name.upcase country_code = CountryCode.new(name) - country = COUNTRIES.detect{|c| c[country_code.format] == upcase_name } + country = COUNTRIES.detect { |c| c[country_code.format] == upcase_name } else - country = COUNTRIES.detect{|c| c[:name].casecmp(name).zero? } + country = COUNTRIES.detect { |c| c[:name].casecmp(name).zero? } end raise InvalidCountryCodeError, "No country could be found for the country #{name}" if country.nil? Country.new(country.dup) diff --git a/lib/support/gateway_support.rb b/lib/support/gateway_support.rb index 36b916773ec..b3bb28e54cf 100644 --- a/lib/support/gateway_support.rb +++ b/lib/support/gateway_support.rb @@ -24,14 +24,14 @@ def initialize end def each_gateway - @gateways.each{|g| yield g } + @gateways.each { |g| yield g } end def features width = 15 print 'Name'.center(width + 20) - ACTIONS.each{|f| print f.to_s.capitalize.center(width) } + ACTIONS.each { |f| print f.to_s.capitalize.center(width) } puts each_gateway do |g| diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index db3c1fbd6db..b756c862f63 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -3,7 +3,7 @@ class RemoteBraintreeBlueTest < Test::Unit::TestCase def setup @gateway = BraintreeGateway.new(fixtures(:braintree_blue)) - @braintree_backend = @gateway.instance_eval{@braintree_gateway} + @braintree_backend = @gateway.instance_eval { @braintree_gateway } @amount = 100 @declined_amount = 2000_00 diff --git a/test/remote/gateways/remote_moneris_test.rb b/test/remote/gateways/remote_moneris_test.rb index f096b7a9d51..1e4308bc62d 100644 --- a/test/remote/gateways/remote_moneris_test.rb +++ b/test/remote/gateways/remote_moneris_test.rb @@ -271,7 +271,7 @@ def test_avs_result_valid_when_enabled def test_avs_result_nil_when_address_absent gateway = MonerisGateway.new(fixtures(:moneris).merge(avs_enabled: true)) - assert response = gateway.purchase(1010, @credit_card, @options.tap {|x| x.delete(:billing_address)}) + assert response = gateway.purchase(1010, @credit_card, @options.tap { |x| x.delete(:billing_address) }) assert_success response assert_equal(response.avs_result, { 'code' => nil, diff --git a/test/remote/gateways/remote_paypal_test.rb b/test/remote/gateways/remote_paypal_test.rb index 3cb88a8ed96..7465a369da7 100644 --- a/test/remote/gateways/remote_paypal_test.rb +++ b/test/remote/gateways/remote_paypal_test.rb @@ -216,7 +216,7 @@ def test_failed_multiple_transfer assert_success response # You can only include up to 250 recipients - recipients = (1..251).collect {|i| [100, "person#{i}@example.com"]} + recipients = (1..251).collect { |i| [100, "person#{i}@example.com"] } response = @gateway.transfer(*recipients) assert_failure response end diff --git a/test/remote/gateways/remote_securion_pay_test.rb b/test/remote/gateways/remote_securion_pay_test.rb index d6b66c7ad0b..59b600899f1 100644 --- a/test/remote/gateways/remote_securion_pay_test.rb +++ b/test/remote/gateways/remote_securion_pay_test.rb @@ -106,7 +106,7 @@ def test_successful_full_refund assert refund.params['refunded'] assert_equal 0, refund.params['amount'] assert_equal 1, refund.params['refunds'].size - assert_equal @amount, refund.params['refunds'].map{|r| r['amount']}.sum + assert_equal @amount, refund.params['refunds'].map { |r| r['amount'] }.sum assert refund.authorization end @@ -124,7 +124,7 @@ def test_successful_partially_refund assert second_refund.params['refunded'] assert_equal @amount - 2 * @refund_amount, second_refund.params['amount'] assert_equal 2, second_refund.params['refunds'].size - assert_equal 2 * @refund_amount, second_refund.params['refunds'].map{|r| r['amount']}.sum + assert_equal 2 * @refund_amount, second_refund.params['refunds'].map { |r| r['amount'] }.sum assert second_refund.authorization end @@ -154,7 +154,7 @@ def test_successful_void assert void.params['refunded'] assert_equal 0, void.params['amount'] assert_equal 1, void.params['refunds'].size - assert_equal @amount, void.params['refunds'].map{|r| r['amount']}.sum + assert_equal @amount, void.params['refunds'].map { |r| r['amount'] }.sum assert void.authorization end diff --git a/test/test_helper.rb b/test/test_helper.rb index 99f482ce780..9666234fea9 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -273,7 +273,7 @@ def symbolize_keys(hash) return unless hash.is_a?(Hash) hash.symbolize_keys! - hash.each{|k, v| symbolize_keys(v)} + hash.each { |k, v| symbolize_keys(v) } end end end diff --git a/test/unit/country_code_test.rb b/test/unit/country_code_test.rb index b455d05f3d7..12ee3ae4ab4 100644 --- a/test/unit/country_code_test.rb +++ b/test/unit/country_code_test.rb @@ -26,6 +26,6 @@ def test_numeric_code end def test_invalid_code_format - assert_raises(ActiveMerchant::CountryCodeFormatError){ ActiveMerchant::CountryCode.new('Canada') } + assert_raises(ActiveMerchant::CountryCodeFormatError) { ActiveMerchant::CountryCode.new('Canada') } end end diff --git a/test/unit/credit_card_test.rb b/test/unit/credit_card_test.rb index 40702473604..fed8dea282f 100644 --- a/test/unit/credit_card_test.rb +++ b/test/unit/credit_card_test.rb @@ -188,7 +188,7 @@ def test_should_correctly_identify_card_brand assert_equal 'visa', CreditCard.brand?('4242424242424242') assert_equal 'american_express', CreditCard.brand?('341111111111111') assert_equal 'master', CreditCard.brand?('5105105105105100') - (222100..272099).each {|bin| assert_equal 'master', CreditCard.brand?(bin.to_s + '1111111111'), "Failed with BIN #{bin}"} + (222100..272099).each { |bin| assert_equal 'master', CreditCard.brand?(bin.to_s + '1111111111'), "Failed with BIN #{bin}" } assert_nil CreditCard.brand?('') end diff --git a/test/unit/gateways/balanced_test.rb b/test/unit/gateways/balanced_test.rb index f405a513edf..68e98b4f0d4 100644 --- a/test/unit/gateways/balanced_test.rb +++ b/test/unit/gateways/balanced_test.rb @@ -277,7 +277,7 @@ def test_passing_address @gateway.purchase(@amount, @credit_card, address: a) end.check_request do |method, endpoint, data, headers| next if endpoint =~ /debits/ - clean = proc{|s| Regexp.escape(CGI.escape(s))} + clean = proc { |s| Regexp.escape(CGI.escape(s)) } assert_match(%r{address\[line1\]=#{clean[a[:address1]]}}, data) assert_match(%r{address\[line2\]=#{clean[a[:address2]]}}, data) assert_match(%r{address\[city\]=#{clean[a[:city]]}}, data) diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index 82dbff6dd06..77602767222 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -231,7 +231,7 @@ def test_successful_check_purchase_request end def test_requires_error_on_tax_calculation_without_line_items - assert_raise(ArgumentError){ @gateway.calculate_tax(@credit_card, @options.delete_if{|key, val| key == :line_items})} + assert_raise(ArgumentError) { @gateway.calculate_tax(@credit_card, @options.delete_if { |key, val| key == :line_items }) } end def test_default_currency diff --git a/test/unit/gateways/data_cash_test.rb b/test/unit/gateways/data_cash_test.rb index a4f24b4a457..2fb5ac40d10 100644 --- a/test/unit/gateways/data_cash_test.rb +++ b/test/unit/gateways/data_cash_test.rb @@ -87,11 +87,11 @@ def test_supported_card_types end def test_purchase_with_missing_order_id_option - assert_raise(ArgumentError){ @gateway.purchase(100, @credit_card, {}) } + assert_raise(ArgumentError) { @gateway.purchase(100, @credit_card, {}) } end def test_authorize_with_missing_order_id_option - assert_raise(ArgumentError){ @gateway.authorize(100, @credit_card, {}) } + assert_raise(ArgumentError) { @gateway.authorize(100, @credit_card, {}) } end def test_purchase_does_not_raise_exception_with_missing_billing_address diff --git a/test/unit/gateways/exact_test.rb b/test/unit/gateways/exact_test.rb index 33345b22541..664f3d27ebf 100644 --- a/test/unit/gateways/exact_test.rb +++ b/test/unit/gateways/exact_test.rb @@ -22,7 +22,7 @@ def test_successful_purchase assert response.test? assert_equal 'Transaction Normal - VER UNAVAILABLE', response.message - ExactGateway::SENSITIVE_FIELDS.each{ |f| assert !response.params.has_key?(f.to_s) } + ExactGateway::SENSITIVE_FIELDS.each { |f| assert !response.params.has_key?(f.to_s) } end def test_successful_refund diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb index 7758d68a0e1..e4aa2511096 100755 --- a/test/unit/gateways/firstdata_e4_test.rb +++ b/test/unit/gateways/firstdata_e4_test.rb @@ -38,7 +38,7 @@ def test_successful_purchase assert response.test? assert_equal 'Transaction Normal - Approved', response.message - FirstdataE4Gateway::SENSITIVE_FIELDS.each{|f| assert !response.params.has_key?(f.to_s)} + FirstdataE4Gateway::SENSITIVE_FIELDS.each { |f| assert !response.params.has_key?(f.to_s) } end def test_successful_purchase_with_specified_currency @@ -51,7 +51,7 @@ def test_successful_purchase_with_specified_currency assert_equal 'Transaction Normal - Approved', response.message assert_equal 'GBP', response.params['currency'] - FirstdataE4Gateway::SENSITIVE_FIELDS.each{|f| assert !response.params.has_key?(f.to_s)} + FirstdataE4Gateway::SENSITIVE_FIELDS.each { |f| assert !response.params.has_key?(f.to_s) } end def test_successful_purchase_with_token diff --git a/test/unit/gateways/firstdata_e4_v27_test.rb b/test/unit/gateways/firstdata_e4_v27_test.rb index fbee6ed84cf..77c51017ffe 100644 --- a/test/unit/gateways/firstdata_e4_v27_test.rb +++ b/test/unit/gateways/firstdata_e4_v27_test.rb @@ -40,7 +40,7 @@ def test_successful_purchase assert response.test? assert_equal 'Transaction Normal - Approved', response.message - FirstdataE4V27Gateway::SENSITIVE_FIELDS.each{|f| assert !response.params.has_key?(f.to_s)} + FirstdataE4V27Gateway::SENSITIVE_FIELDS.each { |f| assert !response.params.has_key?(f.to_s) } end def test_successful_purchase_with_token diff --git a/test/unit/gateways/migs_test.rb b/test/unit/gateways/migs_test.rb index 807a7def5b0..f6ba3282202 100644 --- a/test/unit/gateways/migs_test.rb +++ b/test/unit/gateways/migs_test.rb @@ -63,10 +63,10 @@ def test_purchase_offsite_response assert_success response tampered_response1 = response_params.gsub('20DE', '20DF') - assert_raise(SecurityError){@gateway.purchase_offsite_response(tampered_response1)} + assert_raise(SecurityError) { @gateway.purchase_offsite_response(tampered_response1) } tampered_response2 = response_params.gsub('Locale=en', 'Locale=es') - assert_raise(SecurityError){@gateway.purchase_offsite_response(tampered_response2)} + assert_raise(SecurityError) { @gateway.purchase_offsite_response(tampered_response2) } end def test_scrub @@ -93,7 +93,7 @@ def failed_purchase_response end def build_response(options) - options.collect { |key, value| "vpc_#{key}=#{CGI.escape(value.to_s)}"}.join('&') + options.collect { |key, value| "vpc_#{key}=#{CGI.escape(value.to_s)}" }.join('&') end def pre_scrubbed diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb index 45d34d08ab2..f8d194e94ad 100644 --- a/test/unit/gateways/optimal_payment_test.rb +++ b/test/unit/gateways/optimal_payment_test.rb @@ -101,7 +101,7 @@ def test_purchase_from_any_other_country_includes_region_field def test_purchase_with_shipping_address @options[:shipping_address] = {:country => 'CA'} @gateway.expects(:ssl_post).with do |url, data| - xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=', '') + xml = data.split('&').detect { |string| string =~ /txnRequest=/ }.gsub('txnRequest=', '') doc = Nokogiri::XML.parse(CGI.unescape(xml)) doc.xpath('//xmlns:shippingDetails/xmlns:country').first.text == 'CA' && doc.to_s.include?('<shippingDetails>') end.returns(successful_purchase_response) @@ -112,7 +112,7 @@ def test_purchase_with_shipping_address def test_purchase_without_shipping_address @options[:shipping_address] = nil @gateway.expects(:ssl_post).with do |url, data| - xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=', '') + xml = data.split('&').detect { |string| string =~ /txnRequest=/ }.gsub('txnRequest=', '') doc = Nokogiri::XML.parse(CGI.unescape(xml)) doc.to_s.include?('<shippingDetails>') == false end.returns(successful_purchase_response) diff --git a/test/unit/gateways/pac_net_raven_test.rb b/test/unit/gateways/pac_net_raven_test.rb index f2e66cce048..79530834e28 100644 --- a/test/unit/gateways/pac_net_raven_test.rb +++ b/test/unit/gateways/pac_net_raven_test.rb @@ -157,21 +157,21 @@ def test_failed_void end def test_argument_error_prn - exception = assert_raises(ArgumentError){ + exception = assert_raises(ArgumentError) { PacNetRavenGateway.new(:user => 'user', :secret => 'secret') } assert_equal 'Missing required parameter: prn', exception.message end def test_argument_error_user - exception = assert_raises(ArgumentError){ + exception = assert_raises(ArgumentError) { PacNetRavenGateway.new(:secret => 'secret', :prn => 123456) } assert_equal 'Missing required parameter: user', exception.message end def test_argument_error_secret - exception = assert_raises(ArgumentError){ + exception = assert_raises(ArgumentError) { PacNetRavenGateway.new(:user => 'user', :prn => 123456) } assert_equal 'Missing required parameter: secret', exception.message diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb index 8eb73a2ed5b..b0b5e92859b 100644 --- a/test/unit/gateways/realex_test.rb +++ b/test/unit/gateways/realex_test.rb @@ -540,6 +540,6 @@ def assert_xml_equal_recursive(a, b) assert_equal a1.name, b1.name assert_equal a1.value, b1.value end - a.children.zip(b.children).all?{|a1, b1| assert_xml_equal_recursive(a1, b1)} + a.children.zip(b.children).all? { |a1, b1| assert_xml_equal_recursive(a1, b1) } end end diff --git a/test/unit/gateways/securion_pay_test.rb b/test/unit/gateways/securion_pay_test.rb index 198c2c920f8..06fbe0ff622 100644 --- a/test/unit/gateways/securion_pay_test.rb +++ b/test/unit/gateways/securion_pay_test.rb @@ -202,7 +202,7 @@ def test_successful_full_refund assert response.params['refunded'] assert_equal 0, response.params['amount'] assert_equal 1, response.params['refunds'].size - assert_equal @amount, response.params['refunds'].map{|r| r['amount']}.sum + assert_equal @amount, response.params['refunds'].map { |r| r['amount'] }.sum assert_equal 'char_DQca5ZjbewP2Oe0lIsNe4EXP', response.authorization assert response.test? end @@ -215,7 +215,7 @@ def test_successful_partially_refund assert_success response assert response.params['refunded'] assert_equal @amount - @refund_amount, response.params['amount'] - assert_equal @refund_amount, response.params['refunds'].map{|r| r['amount']}.sum + assert_equal @refund_amount, response.params['refunds'].map { |r| r['amount'] }.sum assert_equal 'char_oVnJ1j6fZqOvnopBBvlnpEuX', response.authorization assert response.test? end diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index b19b6e1fc74..34b53e17927 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -1071,7 +1071,7 @@ def test_gateway_without_credentials end def test_metadata_header - @gateway.expects(:ssl_request).once.with {|method, url, post, headers| + @gateway.expects(:ssl_request).once.with { |method, url, post, headers| headers && headers['X-Stripe-Client-User-Metadata'] == {:ip => '1.1.1.1'}.to_json }.returns(successful_purchase_response) @@ -1079,7 +1079,7 @@ def test_metadata_header end def test_optional_version_header - @gateway.expects(:ssl_request).once.with {|method, url, post, headers| + @gateway.expects(:ssl_request).once.with { |method, url, post, headers| headers && headers['Stripe-Version'] == '2013-10-29' }.returns(successful_purchase_response) @@ -1087,7 +1087,7 @@ def test_optional_version_header end def test_optional_idempotency_key_header - @gateway.expects(:ssl_request).once.with {|method, url, post, headers| + @gateway.expects(:ssl_request).once.with { |method, url, post, headers| headers && headers['Idempotency-Key'] == 'test123' }.returns(successful_purchase_response) @@ -1096,7 +1096,7 @@ def test_optional_idempotency_key_header end def test_optional_idempotency_on_void - @gateway.expects(:ssl_request).once.with {|method, url, post, headers| + @gateway.expects(:ssl_request).once.with { |method, url, post, headers| headers && headers['Idempotency-Key'] == 'test123' }.returns(successful_purchase_response(true)) @@ -1119,7 +1119,7 @@ def test_optional_idempotency_on_verify def test_initialize_gateway_with_version @gateway = StripeGateway.new(:login => 'login', :version => '2013-12-03') - @gateway.expects(:ssl_request).once.with {|method, url, post, headers| + @gateway.expects(:ssl_request).once.with { |method, url, post, headers| headers && headers['Stripe-Version'] == '2013-12-03' }.returns(successful_purchase_response) diff --git a/test/unit/gateways/webpay_test.rb b/test/unit/gateways/webpay_test.rb index d0163560e37..25123a5623b 100644 --- a/test/unit/gateways/webpay_test.rb +++ b/test/unit/gateways/webpay_test.rb @@ -158,7 +158,7 @@ def test_gateway_without_credentials end def test_metadata_header - @gateway.expects(:ssl_request).once.with {|method, url, post, headers| + @gateway.expects(:ssl_request).once.with { |method, url, post, headers| headers && headers['X-Webpay-Client-User-Metadata'] == {:ip => '1.1.1.1'}.to_json }.returns(successful_purchase_response) diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index a5e6cb611d2..cc4eee1f918 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -112,7 +112,7 @@ def test_purchase_does_not_run_inquiry end.respond_with(successful_capture_response) assert_success response - assert_equal(%w(authorize capture), response.responses.collect{|e| e.params['action']}) + assert_equal(%w(authorize capture), response.responses.collect { |e| e.params['action'] }) end def test_successful_void diff --git a/test/unit/multi_response_test.rb b/test/unit/multi_response_test.rb index 82e8735e962..a60062d0003 100644 --- a/test/unit/multi_response_test.rb +++ b/test/unit/multi_response_test.rb @@ -12,8 +12,8 @@ def test_processes_sub_requests r1 = Response.new(true, '1', {}) r2 = Response.new(true, '2', {}) m = MultiResponse.run do |r| - r.process{r1} - r.process{r2} + r.process { r1 } + r.process { r2 } end assert_equal [r1, r2], m.responses end @@ -22,8 +22,8 @@ def test_run_convenience_method r1 = Response.new(true, '1', {}) r2 = Response.new(true, '2', {}) m = MultiResponse.run do |r| - r.process{r1} - r.process{r2} + r.process { r1 } + r.process { r2 } end assert_equal [r1, r2], m.responses end @@ -42,7 +42,7 @@ def test_proxies_last_request :error_code => :card_declined, :fraud_review => true ) - m.process{r1} + m.process { r1 } assert_equal({'one' => 1}, m.params) assert_equal '1', m.message assert m.test @@ -63,7 +63,7 @@ def test_proxies_last_request :cvv_result => 'CVV2', :fraud_review => false ) - m.process{r2} + m.process { r2 } assert_equal({'two' => 2}, m.params) assert_equal '2', m.message assert !m.test @@ -87,7 +87,7 @@ def test_proxies_first_request_if_marked :cvv_result => 'CVV1', :fraud_review => true ) - m.process{r1} + m.process { r1 } assert_equal({'one' => 1}, m.params) assert_equal '1', m.message assert m.test @@ -107,7 +107,7 @@ def test_proxies_first_request_if_marked :cvv_result => 'CVV2', :fraud_review => false ) - m.process{r2} + m.process { r2 } assert_equal({'one' => 1}, m.params) assert_equal '1', m.message assert m.test @@ -124,9 +124,9 @@ def test_primary_response_always_returns_the_last_response_on_failure r1 = Response.new(true, '1', {}, {}) r2 = Response.new(false, '2', {}, {}) r3 = Response.new(false, '3', {}, {}) - m.process{r1} - m.process{r2} - m.process{r3} + m.process { r1 } + m.process { r2 } + m.process { r3 } assert_equal r2, m.primary_response assert_equal '2', m.message end @@ -135,8 +135,8 @@ def test_stops_processing_upon_failure r1 = Response.new(false, '1', {}) r2 = Response.new(true, '2', {}) m = MultiResponse.run do |r| - r.process{r1} - r.process{r2} + r.process { r1 } + r.process { r2 } end assert !m.success? assert_equal [r1], m.responses @@ -147,12 +147,12 @@ def test_merges_sub_multi_responses r2 = Response.new(true, '2', {}) r3 = Response.new(true, '3', {}) m1 = MultiResponse.run do |r| - r.process{r1} - r.process{r2} + r.process { r1 } + r.process { r2 } end m = MultiResponse.run do |r| - r.process{m1} - r.process{r3} + r.process { m1 } + r.process { r3 } end assert_equal [r1, r2, r3], m.responses end @@ -161,12 +161,12 @@ def test_handles_ignores_optional_request_result m = MultiResponse.new r1 = Response.new(true, '1') - m.process{r1} + m.process { r1 } assert_equal '1', m.message assert_equal [r1], m.responses r2 = Response.new(false, '2') - m.process(:ignore_result){r2} + m.process(:ignore_result) { r2 } assert_equal '1', m.message assert_equal [r1, r2], m.responses From 34f48ad6d1db4d655259e185c1d2363958ba00ff Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Wed, 21 Nov 2018 10:51:22 -0500 Subject: [PATCH 654/677] Forte: Allow void on capture Forte uses different transaction id's for captures. When trying to void a capture this results in a error. This saves the original auth transaction id and authorization id in the capture authorization so the original auth will be voided or refunded. Loaded suite test/unit/gateways/forte_test 20 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Loaded suite test/remote/gateways/remote_forte_test 21 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/forte.rb | 18 +++++++++++------- test/remote/gateways/remote_forte_test.rb | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6888977fb1e..deb927532a8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ * Cenpos: update supported countries [bpollack] #3055 * CyberSource: update supported countries [bpollack] #3055 * MiGS: update supported countries [bpollack] #3055 +* Forte: Allow void on capture #3059 == Version 1.86.0 (October 26, 2018) * UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002 diff --git a/lib/active_merchant/billing/gateways/forte.rb b/lib/active_merchant/billing/gateways/forte.rb index 12b2e6e3308..bdc06c7a3f5 100644 --- a/lib/active_merchant/billing/gateways/forte.rb +++ b/lib/active_merchant/billing/gateways/forte.rb @@ -191,7 +191,7 @@ def commit(type, parameters) success_from(response), message_from(response), response, - authorization: authorization_from(response), + authorization: authorization_from(response, parameters), avs_result: AVSResult.new(code: response['response']['avs_result']), cvv_result: CVVResult.new(response['response']['cvv_code']), test: test? @@ -219,8 +219,12 @@ def message_from(response) response['response']['response_desc'] end - def authorization_from(response) - [response.try(:[], 'transaction_id'), response.try(:[], 'response').try(:[], 'authorization_code')].join('#') + def authorization_from(response, parameters) + if parameters[:action] == 'capture' + [response['transaction_id'], response.dig('response', 'authorization_code'), parameters[:transaction_id], parameters[:authorization_code]].join('#') + else + [response['transaction_id'], response.dig('response', 'authorization_code')].join('#') + end end def endpoint @@ -253,13 +257,13 @@ def split_authorization(authorization) end def authorization_code_from(authorization) - _, authorization_code = split_authorization(authorization) - authorization_code + _, authorization_code, _, original_auth_authorization_code = split_authorization(authorization) + original_auth_authorization_code.present? ? original_auth_authorization_code : authorization_code end def transaction_id_from(authorization) - transaction_id, _ = split_authorization(authorization) - transaction_id + transaction_id, _, original_auth_transaction_id, _= split_authorization(authorization) + original_auth_transaction_id.present? ? original_auth_transaction_id : transaction_id end end end diff --git a/test/remote/gateways/remote_forte_test.rb b/test/remote/gateways/remote_forte_test.rb index 4be212bd5c7..8a2df5bccc8 100644 --- a/test/remote/gateways/remote_forte_test.rb +++ b/test/remote/gateways/remote_forte_test.rb @@ -82,6 +82,22 @@ def test_successful_authorize_and_capture assert_equal 'APPROVED', capture.message end + def test_successful_authorize_capture_void + auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + + wait_for_authorization_to_clear + + assert capture = @gateway.capture(@amount, auth.authorization, @options) + assert_success capture + assert_match auth.authorization.split('#')[0], capture.authorization + assert_match auth.authorization.split('#')[1], capture.authorization + assert_equal 'APPROVED', capture.message + + void = @gateway.void(capture.authorization) + assert_success void + end + def test_failed_authorize @amount = 1985 response = @gateway.authorize(@amount, @declined_card, @options) From ad6ffd468cb0e80405c668c430aeb2a647da73d2 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@bitquabit.com> Date: Thu, 22 Nov 2018 09:30:44 -0500 Subject: [PATCH 655/677] Upgrade RuboCop --- .rubocop_todo.yml | 238 +++++++++++++++++++++++++++------------------- Gemfile | 2 +- 2 files changed, 141 insertions(+), 99 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 10ed49082bc..25af39afb54 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-06-26 11:27:33 -0400 using RuboCop version 0.57.2. +# on 2018-11-20 16:45:49 -0500 using RuboCop version 0.60.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -14,121 +14,149 @@ Gemspec/OrderedDependencies: Exclude: - 'activemerchant.gemspec' -# Offense count: 426 +# Offense count: 1828 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/AlignHash: + Enabled: false + +# Offense count: 57 # Cop supports --auto-correct. Layout/ClosingHeredocIndentation: Enabled: false -# Offense count: 165 +# Offense count: 167 +# Cop supports --auto-correct. +Layout/EmptyLineAfterGuardClause: + Enabled: false + +# Offense count: 173 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only Layout/EmptyLinesAroundClassBody: Enabled: false -# Offense count: 40 +# Offense count: 39 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. # SupportedStylesAlignWith: keyword, variable, start_of_line Layout/EndAlignment: Enabled: false -# Offense count: 191 +# Offense count: 174 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. Layout/ExtraSpacing: Enabled: false -# Offense count: 122 +# Offense count: 105 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses Layout/FirstParameterIndentation: Enabled: false -# Offense count: 253 +# Offense count: 255 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_braces Layout/IndentHash: Enabled: false -# Offense count: 387 +# Offense count: 392 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent Layout/IndentHeredoc: Enabled: false -# Offense count: 97 +# Offense count: 92 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: normal, rails Layout/IndentationConsistency: Enabled: false -# Offense count: 197 +# Offense count: 193 # Cop supports --auto-correct. # Configuration parameters: Width, IgnoredPatterns. Layout/IndentationWidth: Enabled: false -# Offense count: 6 +# Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: symmetrical, new_line, same_line Layout/MultilineArrayBraceLayout: Exclude: - 'lib/active_merchant/billing/gateways/optimal_payment.rb' - - 'test/remote/gateways/remote_linkpoint_test.rb' - - 'test/remote/gateways/remote_orbital_test.rb' - - 'test/remote/gateways/remote_payflow_express_test.rb' -# Offense count: 42 +# Offense count: 36 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: symmetrical, new_line, same_line Layout/MultilineHashBraceLayout: Enabled: false -# Offense count: 234 +# Offense count: 232 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: symmetrical, new_line, same_line Layout/MultilineMethodCallBraceLayout: Enabled: false -# Offense count: 35 +# Offense count: 24 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented Layout/MultilineOperationIndentation: Exclude: - 'lib/active_merchant/billing/credit_card_methods.rb' - - 'lib/active_merchant/billing/gateways/commercegate.rb' - 'lib/active_merchant/billing/gateways/iridium.rb' - 'lib/active_merchant/billing/gateways/moneris.rb' - 'lib/active_merchant/billing/gateways/moneris_us.rb' - 'lib/active_merchant/billing/gateways/orbital.rb' - 'lib/active_merchant/billing/gateways/redsys.rb' - - 'test/unit/gateways/barclays_epdq_extra_plus_test.rb' - 'test/unit/gateways/braintree_blue_test.rb' - - 'test/unit/gateways/ogone_test.rb' - 'test/unit/gateways/skip_jack_test.rb' -# Offense count: 638 +# Offense count: 15 +# Cop supports --auto-correct. +Layout/RescueEnsureAlignment: + Exclude: + - 'lib/active_merchant/billing/gateways/balanced.rb' + - 'lib/active_merchant/billing/gateways/clearhaus.rb' + - 'lib/active_merchant/billing/gateways/culqi.rb' + - 'lib/active_merchant/billing/gateways/eway_managed.rb' + - 'lib/active_merchant/billing/gateways/fat_zebra.rb' + - 'lib/active_merchant/billing/gateways/hps.rb' + - 'lib/active_merchant/billing/gateways/iveri.rb' + - 'lib/active_merchant/billing/gateways/kushki.rb' + - 'lib/active_merchant/billing/gateways/merchant_e_solutions.rb' + - 'lib/active_merchant/billing/gateways/netbanx.rb' + - 'lib/active_merchant/billing/gateways/opp.rb' + - 'lib/active_merchant/billing/gateways/orbital.rb' + - 'lib/active_merchant/billing/gateways/pay_junction_v2.rb' + - 'lib/active_merchant/billing/gateways/quickbooks.rb' + - 'lib/active_merchant/billing/gateways/trans_first_transaction_express.rb' + +# Offense count: 649 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: space, no_space Layout/SpaceAroundEqualsInParameterDefault: Enabled: false -# Offense count: 105 +# Offense count: 104 # Cop supports --auto-correct. Layout/SpaceAroundKeyword: Enabled: false -# Offense count: 802 +# Offense count: 782 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment. Layout/SpaceAroundOperators: @@ -161,7 +189,7 @@ Layout/SpaceInsideHashLiteralBraces: Layout/SpaceInsidePercentLiteralDelimiters: Enabled: false -# Offense count: 148 +# Offense count: 150 # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: Enabled: false @@ -182,34 +210,29 @@ Lint/RescueException: Exclude: - 'lib/active_merchant/billing/gateways/quantum.rb' -# Offense count: 1453 +# Offense count: 1502 # Cop supports --auto-correct. # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: Enabled: false -# Offense count: 283 +# Offense count: 284 # Cop supports --auto-correct. # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. Lint/UnusedMethodArgument: Enabled: false -# Offense count: 1 -# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. -Lint/UselessAccessModifier: - Exclude: - - 'lib/active_merchant/network_connection_retries.rb' - -# Offense count: 1409 +# Offense count: 1418 Metrics/AbcSize: Max: 192 # Offense count: 26 # Configuration parameters: CountComments, ExcludedMethods. +# ExcludedMethods: refine Metrics/BlockLength: Max: 54 -# Offense count: 12 +# Offense count: 9 # Configuration parameters: CountBlocks. Metrics/BlockNesting: Max: 6 @@ -218,8 +241,8 @@ Metrics/BlockNesting: Metrics/CyclomaticComplexity: Max: 36 -# Offense count: 1741 -# Configuration parameters: CountComments. +# Offense count: 1793 +# Configuration parameters: CountComments, ExcludedMethods. Metrics/MethodLength: Max: 163 @@ -228,11 +251,9 @@ Metrics/MethodLength: Metrics/ParameterLists: Max: 6 -# Offense count: 126 +# Offense count: 129 Metrics/PerceivedComplexity: - Max: 32 - Exclude: - - 'lib/active_merchant/billing/gateways/braintree_blue.rb' + Max: 33 # Offense count: 6 Naming/AccessorMethodName: @@ -246,7 +267,7 @@ Naming/ConstantName: Exclude: - 'test/test_helper.rb' -# Offense count: 45 +# Offense count: 46 # Configuration parameters: EnforcedStyle. # SupportedStyles: lowercase, uppercase Naming/HeredocDelimiterCase: @@ -264,6 +285,8 @@ Naming/HeredocDelimiterNaming: Enabled: false # Offense count: 1 +# Configuration parameters: EnforcedStyleForLeadingUnderscores. +# SupportedStylesForLeadingUnderscores: disallowed, required, optional Naming/MemoizedInstanceVariableName: Exclude: - 'lib/active_merchant/billing/compatibility.rb' @@ -299,7 +322,7 @@ Naming/PredicateName: # Offense count: 14 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -# AllowedNames: io, id, to, by, on, in, at +# AllowedNames: io, id, to, by, on, in, at, ip, db Naming/UncommunicativeMethodParamName: Exclude: - 'lib/active_merchant/billing/gateways/blue_snap.rb' @@ -312,13 +335,12 @@ Naming/UncommunicativeMethodParamName: - 'test/unit/gateways/paypal/paypal_common_api_test.rb' - 'test/unit/gateways/realex_test.rb' -# Offense count: 51 +# Offense count: 49 # Configuration parameters: EnforcedStyle. # SupportedStyles: snake_case, camelCase Naming/VariableName: Exclude: - 'lib/active_merchant/billing/gateways/cyber_source.rb' - - 'lib/active_merchant/billing/gateways/ideal/ideal_base.rb' - 'lib/active_merchant/billing/gateways/iridium.rb' - 'lib/active_merchant/billing/gateways/latitude19.rb' - 'lib/active_merchant/billing/gateways/optimal_payment.rb' @@ -351,14 +373,13 @@ Performance/RedundantMatch: - 'lib/active_merchant/billing/gateways/opp.rb' - 'test/unit/gateways/payu_latam_test.rb' -# Offense count: 12 +# Offense count: 11 # Cop supports --auto-correct. Performance/StringReplacement: Exclude: - 'lib/active_merchant/billing/compatibility.rb' - 'lib/active_merchant/billing/gateways/card_connect.rb' - 'lib/active_merchant/billing/gateways/firstdata_e4.rb' - - 'lib/active_merchant/billing/gateways/ideal/ideal_base.rb' - 'lib/active_merchant/billing/gateways/merchant_ware.rb' - 'lib/active_merchant/billing/gateways/merchant_ware_version_four.rb' - 'lib/active_merchant/billing/gateways/orbital.rb' @@ -429,13 +450,12 @@ Style/Attr: Exclude: - 'test/unit/gateways/forte_test.rb' -# Offense count: 3 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: percent_q, bare_percent Style/BarePercentLiterals: Exclude: - - 'test/unit/gateways/clearhaus_test.rb' - 'test/unit/gateways/eway_rapid_test.rb' - 'test/unit/gateways/orbital_test.rb' @@ -447,7 +467,7 @@ Style/BlockComments: - 'test/remote/gateways/remote_netpay_test.rb' - 'test/remote/gateways/remote_payu_in_test.rb' -# Offense count: 75 +# Offense count: 77 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods. # SupportedStyles: line_count_based, semantic, braces_for_chaining @@ -457,7 +477,7 @@ Style/BlockComments: Style/BlockDelimiters: Enabled: false -# Offense count: 443 +# Offense count: 440 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: braces, no_braces, context_dependent @@ -479,7 +499,7 @@ Style/ClassAndModuleChildren: - 'test/unit/gateways/optimal_payment_test.rb' - 'test/unit/gateways/realex_test.rb' -# Offense count: 35 +# Offense count: 30 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: is_a?, kind_of? @@ -510,13 +530,12 @@ Style/ColonMethodCall: - 'lib/active_merchant/billing/gateways/nmi.rb' - 'test/unit/gateways/quickpay_v4to7_test.rb' -# Offense count: 6 +# Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: Keywords. # Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW Style/CommentAnnotation: Exclude: - - 'lib/active_merchant/billing/gateways/authorize_net_cim.rb' - 'test/remote/gateways/remote_usa_epay_advanced_test.rb' - 'test/unit/gateways/authorize_net_cim_test.rb' - 'test/unit/gateways/usa_epay_advanced_test.rb' @@ -530,7 +549,7 @@ Style/CommentedKeyword: - 'test/remote/gateways/remote_cardknox_test.rb' - 'test/unit/gateways/cardknox_test.rb' -# Offense count: 23 +# Offense count: 22 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. # SupportedStyles: assign_to_condition, assign_inside_condition @@ -538,6 +557,7 @@ Style/ConditionalAssignment: Enabled: false # Offense count: 7 +# Configuration parameters: AllowCoercion. Style/DateTime: Exclude: - 'test/remote/gateways/remote_first_pay_test.rb' @@ -546,7 +566,7 @@ Style/DateTime: - 'test/unit/gateways/orbital_test.rb' - 'test/unit/gateways/paypal/paypal_common_api_test.rb' -# Offense count: 210 +# Offense count: 211 Style/Documentation: Enabled: false @@ -621,7 +641,7 @@ Style/EmptyMethod: - 'test/unit/gateways/world_net_test.rb' - 'test/unit/gateways/worldpay_online_payments_test.rb' -# Offense count: 24 +# Offense count: 23 # Cop supports --auto-correct. Style/Encoding: Enabled: false @@ -642,6 +662,7 @@ Style/ExpandPathArguments: - 'test/test_helper.rb' # Offense count: 11 +# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: each, for Style/For: @@ -653,7 +674,7 @@ Style/For: - 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb' - 'test/remote/gateways/remote_orbital_test.rb' -# Offense count: 96 +# Offense count: 97 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: format, sprintf, percent @@ -676,7 +697,7 @@ Style/FormatStringToken: - 'test/unit/gateways/firstdata_e4_test.rb' - 'test/unit/gateways/safe_charge_test.rb' -# Offense count: 677 +# Offense count: 679 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: when_needed, always, never @@ -693,12 +714,12 @@ Style/GlobalVars: - 'test/unit/gateways/finansbank_test.rb' - 'test/unit/gateways/garanti_test.rb' -# Offense count: 192 +# Offense count: 196 # Configuration parameters: MinBodyLength. Style/GuardClause: Enabled: false -# Offense count: 7424 +# Offense count: 7482 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys @@ -712,7 +733,7 @@ Style/IdenticalConditionalBranches: - 'lib/active_merchant/billing/gateways/litle.rb' - 'lib/active_merchant/billing/gateways/payu_latam.rb' -# Offense count: 15 +# Offense count: 14 Style/IfInsideElse: Exclude: - 'lib/active_merchant/billing/credit_card.rb' @@ -731,11 +752,10 @@ Style/IfInsideElse: Style/IfUnlessModifier: Enabled: false -# Offense count: 3 +# Offense count: 1 Style/IfUnlessModifierOfIfUnless: Exclude: - 'lib/active_merchant/billing/gateways/merchant_e_solutions.rb' - - 'lib/active_merchant/posts_data.rb' # Offense count: 2 # Cop supports --auto-correct. @@ -745,27 +765,39 @@ Style/InverseMethods: - 'lib/active_merchant/billing/gateways/ogone.rb' - 'lib/active_merchant/billing/gateways/worldpay.rb' -# Offense count: 31 +# Offense count: 32 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. Style/MethodCallWithoutArgsParentheses: Enabled: false -# Offense count: 626 +# Offense count: 656 Style/MultilineBlockChain: Enabled: false -# Offense count: 20 +# Offense count: 15 # Cop supports --auto-correct. Style/MultilineIfModifier: - Enabled: false + Exclude: + - 'lib/active_merchant/billing/compatibility.rb' + - 'lib/active_merchant/billing/gateways/authorize_net_cim.rb' + - 'lib/active_merchant/billing/gateways/bank_frick.rb' + - 'lib/active_merchant/billing/gateways/cenpos.rb' + - 'lib/active_merchant/billing/gateways/efsnet.rb' + - 'lib/active_merchant/billing/gateways/eway.rb' + - 'lib/active_merchant/billing/gateways/flo2cash.rb' + - 'lib/active_merchant/billing/gateways/itransact.rb' + - 'lib/active_merchant/billing/gateways/monei.rb' + - 'lib/active_merchant/billing/gateways/optimal_payment.rb' + - 'lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb' + - 'lib/active_merchant/billing/gateways/psigate.rb' + - 'lib/active_merchant/billing/gateways/realex.rb' -# Offense count: 7 +# Offense count: 6 # Cop supports --auto-correct. Style/MultilineIfThen: Exclude: - 'lib/active_merchant/billing/gateways/eway_managed.rb' - - 'lib/active_merchant/connection.rb' # Offense count: 4 Style/MultilineTernaryOperator: @@ -780,12 +812,12 @@ Style/MultipleComparison: Exclude: - 'lib/active_merchant/billing/gateways/worldpay_online_payments.rb' -# Offense count: 516 +# Offense count: 530 # Cop supports --auto-correct. Style/MutableConstant: Enabled: false -# Offense count: 21 +# Offense count: 17 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: both, prefix, postfix @@ -793,7 +825,6 @@ Style/NegatedIf: Exclude: - 'lib/active_merchant/billing/credit_card.rb' - 'lib/active_merchant/billing/gateways/adyen.rb' - - 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb' - 'lib/active_merchant/billing/gateways/itransact.rb' - 'lib/active_merchant/billing/gateways/iveri.rb' - 'lib/active_merchant/billing/gateways/ogone.rb' @@ -803,12 +834,11 @@ Style/NegatedIf: - 'lib/support/ssl_verify.rb' - 'test/remote/gateways/remote_paypal_test.rb' -# Offense count: 3 +# Offense count: 1 # Cop supports --auto-correct. Style/NestedModifier: Exclude: - 'lib/active_merchant/billing/gateways/merchant_e_solutions.rb' - - 'lib/active_merchant/posts_data.rb' # Offense count: 2 # Cop supports --auto-correct. @@ -827,14 +857,15 @@ Style/Next: - 'lib/active_merchant/billing/gateways/authorize_net.rb' - 'lib/support/outbound_hosts.rb' -# Offense count: 6 +# Offense count: 5 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: predicate, comparison Style/NilComparison: Exclude: - 'lib/active_merchant/billing/gateways/card_stream.rb' - 'lib/active_merchant/billing/gateways/litle.rb' - 'lib/active_merchant/billing/gateways/telr.rb' - - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' - 'test/unit/gateways/braintree_blue_test.rb' - 'test/unit/gateways/stripe_test.rb' @@ -853,7 +884,7 @@ Style/Not: - 'test/test_helper.rb' - 'test/unit/gateways/braintree_blue_test.rb' -# Offense count: 20 +# Offense count: 19 # Cop supports --auto-correct. # Configuration parameters: EnforcedOctalStyle. # SupportedOctalStyles: zero_with_o, zero_only @@ -873,15 +904,15 @@ Style/NumericLiteralPrefix: - 'test/unit/gateways/opp_test.rb' - 'test/unit/gateways/pay_junction_v2_test.rb' -# Offense count: 446 +# Offense count: 466 # Cop supports --auto-correct. # Configuration parameters: Strict. Style/NumericLiterals: MinDigits: 17 -# Offense count: 40 +# Offense count: 41 # Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle. +# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. # SupportedStyles: predicate, comparison Style/NumericPredicate: Enabled: false @@ -897,7 +928,7 @@ Style/OrAssignment: Style/ParallelAssignment: Enabled: false -# Offense count: 877 +# Offense count: 879 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: @@ -912,7 +943,7 @@ Style/PerlBackrefs: - 'lib/support/outbound_hosts.rb' - 'test/unit/gateways/payu_in_test.rb' -# Offense count: 94 +# Offense count: 96 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: short, verbose @@ -926,25 +957,25 @@ Style/Proc: - 'test/unit/credit_card_methods_test.rb' - 'test/unit/gateways/nab_transact_test.rb' -# Offense count: 33 +# Offense count: 31 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: compact, exploded Style/RaiseArgs: Enabled: false -# Offense count: 87 +# Offense count: 86 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: Enabled: false -# Offense count: 173 +# Offense count: 179 # Cop supports --auto-correct. Style/RedundantSelf: Enabled: false -# Offense count: 1178 +# Offense count: 1209 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed @@ -1007,14 +1038,28 @@ Style/SingleLineMethods: Style/SpecialGlobalVars: EnforcedStyle: use_perl_names -# Offense count: 31 +# Offense count: 27 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: single_quotes, double_quotes Style/StringLiteralsInInterpolation: - Enabled: false + Exclude: + - 'lib/active_merchant/billing/gateways/banwire.rb' + - 'lib/active_merchant/billing/gateways/cams.rb' + - 'lib/active_merchant/billing/gateways/checkout_v2.rb' + - 'lib/active_merchant/billing/gateways/credorax.rb' + - 'lib/active_merchant/billing/gateways/digitzs.rb' + - 'lib/active_merchant/billing/gateways/ebanx.rb' + - 'lib/active_merchant/billing/gateways/merchant_one.rb' + - 'lib/active_merchant/billing/gateways/micropayment.rb' + - 'lib/active_merchant/billing/gateways/pagarme.rb' + - 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb' + - 'lib/active_merchant/billing/gateways/stripe.rb' + - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb' + - 'lib/active_merchant/billing/gateways/worldpay.rb' + - 'test/unit/gateways/eway_managed_test.rb' -# Offense count: 307 +# Offense count: 309 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinSize. # SupportedStyles: percent, brackets @@ -1028,39 +1073,36 @@ Style/SymbolArray: Style/TrailingCommaInArrayLiteral: Exclude: - 'lib/active_merchant/billing/credit_card_methods.rb' - - 'test/remote/gateways/remote_payflow_express_test.rb' - 'test/unit/gateways/netaxept_test.rb' - 'test/unit/gateways/usa_epay_transaction_test.rb' -# Offense count: 155 +# Offense count: 160 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma Style/TrailingCommaInHashLiteral: Enabled: false -# Offense count: 36 +# Offense count: 38 # Cop supports --auto-correct. # Configuration parameters: AllowNamedUnderscoreVariables. Style/TrailingUnderscoreVariable: Enabled: false -# Offense count: 117 +# Offense count: 119 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinSize, WordRegex. # SupportedStyles: percent, brackets Style/WordArray: Enabled: false -# Offense count: 33 +# Offense count: 34 # Cop supports --auto-correct. Style/ZeroLengthPredicate: Enabled: false -# Offense count: 9190 +# Offense count: 9321 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: - Max: 2484 - Exclude: - - 'test/unit/gateways/global_collect_test.rb' + Max: 2602 diff --git a/Gemfile b/Gemfile index 8fe123d5eb8..8ce730332ad 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' gemspec gem 'jruby-openssl', :platforms => :jruby -gem 'rubocop', '~> 0.58.1', require: false +gem 'rubocop', '~> 0.60.0', require: false group :test, :remote_test do # gateway-specific dependencies, keeping these gems out of the gemspec From 90e4c10180d03a6f88159cf33bc6a05cfcbb0c43 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Mon, 26 Nov 2018 14:54:01 -0500 Subject: [PATCH 656/677] Braintree Blue: actually, really, truly fix nil address fields Previously, on Battlestar Galactica, we only filtered out the address if the fields were nil. But some of our library consumers like to pass in empty strings, which we treated as actual data, whereas Braintree Blue weirdly insists "" is not a valid address. Treat empty strings the same as nil values. Unit: 57 tests, 150 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 66 tests, 378 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/braintree_blue.rb | 5 +++-- test/remote/gateways/remote_braintree_blue_test.rb | 2 +- test/unit/gateways/braintree_blue_test.rb | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb index 6a263624017..a3ffb37a325 100644 --- a/lib/active_merchant/billing/gateways/braintree_blue.rb +++ b/lib/active_merchant/billing/gateways/braintree_blue.rb @@ -39,6 +39,7 @@ module Billing #:nodoc: # class BraintreeBlueGateway < Gateway include BraintreeCommon + include Empty self.display_name = 'Braintree (Blue Platform)' @@ -261,7 +262,7 @@ def add_credit_card_to_customer(credit_card, options) } if options[:billing_address] address = map_address(options[:billing_address]) - parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| v.nil? } + parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| empty?(v) } end result = @braintree_gateway.credit_card.create(parameters) @@ -309,7 +310,7 @@ def merge_credit_card_options(parameters, options) parameters[:credit_card][:options] = valid_options if options[:billing_address] address = map_address(options[:billing_address]) - parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| v.nil? } + parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| empty?(v) } end parameters end diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb index b756c862f63..c6cd935e7db 100644 --- a/test/remote/gateways/remote_braintree_blue_test.rb +++ b/test/remote/gateways/remote_braintree_blue_test.rb @@ -46,7 +46,7 @@ def test_successful_authorize_with_nil_billing_address_options :phone => '123-456-7890', :company => nil, :address1 => nil, - :address2 => nil, + :address2 => '', :city => nil, :state => nil, :zip => nil, diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb index 1a0b83e24cc..0135224cd32 100644 --- a/test/unit/gateways/braintree_blue_test.rb +++ b/test/unit/gateways/braintree_blue_test.rb @@ -386,7 +386,7 @@ def test_store_with_nil_billing_address_options :phone => '123-456-7890', :company => nil, :address1 => nil, - :address2 => nil, + :address2 => '', :city => nil, :state => nil, :zip => nil, From 1253d4108a7040cfdb147d5ce6c74ea71445352d Mon Sep 17 00:00:00 2001 From: Filipe Costa <filipebarcos@gmail.com> Date: Thu, 29 Nov 2018 10:58:24 -0500 Subject: [PATCH 657/677] Release 1.87.0 --- CHANGELOG | 22 ++++++++++++---------- lib/active_merchant/version.rb | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index deb927532a8..5198e278bed 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,15 +1,26 @@ = ActiveMerchant CHANGELOG == HEAD -* Clearhaus: update submission data format [bpollack] #3053 +* Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026 +* Braintree: Fix passing phone-only billing address [curiousepic] #3025 +* Litle: Capitalize check account type [curiousepic] #3028 +* Braintree: Account for nil billing address fields [curiousepic] #3029 +* Realex: Add verify [kheang] #3030 +* Braintree: Actually account for nil address fields [curiousepic] #3032 +* Mercado Pago: do not infer card type [bpollack] #3038 +* Credorax: allow sending submerchant ID (h3 parameter) [bpollack] #3040 +* Worldpay: Pass stored credential option fields [curiousepic] #3041 * Make behavior of nil CC numbers more consistent [guaguasi] #3010 * Moneris: Adds Credential on File logic [deedeelavinder] #3042 * Adyen: Return AVS and CVC Result [nfarve] #3044 +* Paymentez: Supports phone field, does not send if empty [molbrown] #3043 * Braintree: Account for nil address with existing customer [curiousepic] #3047 * Optimal Payment: Add verify capabilities #3052 +* Moneris: Allows cof_enabled gateway to process non-cof transactions [deedeelavinder] #3051 * Cenpos: update supported countries [bpollack] #3055 * CyberSource: update supported countries [bpollack] #3055 * MiGS: update supported countries [bpollack] #3055 +* Clearhaus: update submission data format [bpollack] #3053 * Forte: Allow void on capture #3059 == Version 1.86.0 (October 26, 2018) @@ -23,15 +34,6 @@ * Payflow Express: Add phone to returned Response [filipebarcos] #3003 * Authorize.Net: Pass some level 3 fields [curiousepic] #3022 * Add state to the netbanx payload [Girardvjonathan] #3024 -* Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026 -* Braintree: Fix passing phone-only billing address [curiousepic] #3025 -* Litle: Capitalize check account type [curiousepic] #3028 -* Braintree: Account for nil billing address fields [curiousepic] #3029 -* Realex: Add verify [kheang] #3030 -* Braintree: Actually account for nil address fields [curiousepic] #3032 -* Credorax: allow sending submerchant ID (h3 parameter) [bpollack] #3040 -* Worldpay: Pass stored credential option fields [curiousepic] #3041 -* Paymentez: Supports phone field, does not send if empty [molbrown] #3043 == Version 1.85.0 (September 28, 2018) * Authorize.Net: Support custom delimiter for cim [curiousepic] #3001 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 813ed5dbdd2..54f720d8bf0 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = '1.86.0' + VERSION = '1.87.0' end From 3408663549bc8a4fd13dbdea9632746cddf813fa Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 27 Nov 2018 11:05:30 -0500 Subject: [PATCH 658/677] RuboCop: fix Layout/IndentationConsistency --- .rubocop_todo.yml | 7 - .../billing/gateways/cardknox.rb | 16 +- .../billing/gateways/cyber_source.rb | 26 +- lib/active_merchant/billing/gateways/epay.rb | 18 +- .../billing/gateways/eway_managed.rb | 26 +- lib/active_merchant/billing/gateways/litle.rb | 2 +- .../billing/gateways/netbilling.rb | 16 +- .../billing/gateways/paystation.rb | 152 ++--- .../billing/gateways/quickpay/quickpay_v10.rb | 300 ++++----- test/remote/gateways/remote_banwire_test.rb | 16 +- test/remote/gateways/remote_cardknox_test.rb | 2 +- .../gateways/remote_merchant_one_test.rb | 54 +- .../remote_usa_epay_transaction_test.rb | 12 +- test/unit/gateways/eway_managed_test.rb | 11 +- test/unit/gateways/netbanx_test.rb | 6 +- test/unit/gateways/orbital_test.rb | 12 +- test/unit/gateways/paypal_express_test.rb | 48 +- test/unit/gateways/paystation_test.rb | 614 +++++++++--------- test/unit/gateways/payway_test.rb | 54 +- test/unit/gateways/worldpay_test.rb | 6 +- 20 files changed, 695 insertions(+), 703 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 25af39afb54..08a3231d05a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -74,13 +74,6 @@ Layout/IndentHash: Layout/IndentHeredoc: Enabled: false -# Offense count: 92 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: normal, rails -Layout/IndentationConsistency: - Enabled: false - # Offense count: 193 # Cop supports --auto-correct. # Configuration parameters: Width, IgnoredPatterns. diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb index 10b3976dc7d..e4dd63bba30 100644 --- a/lib/active_merchant/billing/gateways/cardknox.rb +++ b/lib/active_merchant/billing/gateways/cardknox.rb @@ -282,14 +282,14 @@ def parse(body) def commit(action, source_type, parameters) response = parse(ssl_post(live_url, post_data(COMMANDS[source_type][action], parameters))) - Response.new( - (response[:status] == 'Approved'), - message_from(response), - response, - authorization: authorization_from(response, source_type), - avs_result: { code: response[:avs_result_code] }, - cvv_result: response[:cvv_result_code] - ) + Response.new( + (response[:status] == 'Approved'), + message_from(response), + response, + authorization: authorization_from(response, source_type), + avs_result: { code: response[:avs_result_code] }, + cvv_result: response[:cvv_result_code] + ) end def message_from(response) diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index 83f4734a5f0..9bc89b747ce 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -683,23 +683,23 @@ def lookup_country_code(country_field) # Where we actually build the full SOAP request using builder def build_request(body, options) xml = Builder::XmlMarkup.new :indent => 2 - xml.instruct! - xml.tag! 's:Envelope', {'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/'} do - xml.tag! 's:Header' do - xml.tag! 'wsse:Security', {'s:mustUnderstand' => '1', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'} do - xml.tag! 'wsse:UsernameToken' do - xml.tag! 'wsse:Username', @options[:login] - xml.tag! 'wsse:Password', @options[:password], 'Type' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText' - end + xml.instruct! + xml.tag! 's:Envelope', {'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/'} do + xml.tag! 's:Header' do + xml.tag! 'wsse:Security', {'s:mustUnderstand' => '1', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'} do + xml.tag! 'wsse:UsernameToken' do + xml.tag! 'wsse:Username', @options[:login] + xml.tag! 'wsse:Password', @options[:password], 'Type' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText' end end - xml.tag! 's:Body', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do - xml.tag! 'requestMessage', {'xmlns' => "urn:schemas-cybersource-com:transaction-data-#{XSD_VERSION}"} do - add_merchant_data(xml, options) - xml << body - end + end + xml.tag! 's:Body', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do + xml.tag! 'requestMessage', {'xmlns' => "urn:schemas-cybersource-com:transaction-data-#{XSD_VERSION}"} do + add_merchant_data(xml, options) + xml << body end end + end xml.target! end diff --git a/lib/active_merchant/billing/gateways/epay.rb b/lib/active_merchant/billing/gateways/epay.rb index f26a9112a5d..4f33ae1afe8 100644 --- a/lib/active_merchant/billing/gateways/epay.rb +++ b/lib/active_merchant/billing/gateways/epay.rb @@ -252,17 +252,17 @@ def make_headers(data, soap_call) def xml_builder(params, soap_call) xml = Builder::XmlMarkup.new(:indent => 2) xml.instruct! - xml.tag! 'soap:Envelope', { 'xmlns:xsi' => 'http://schemas.xmlsoap.org/soap/envelope/', - 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', - 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' } do - xml.tag! 'soap:Body' do - xml.tag! soap_call, { 'xmlns' => "#{self.live_url}remote/payment" } do - xml.tag! 'merchantnumber', @options[:login] - xml.tag! 'transactionid', params[:transaction] - xml.tag! 'amount', params[:amount].to_s if soap_call != 'delete' - end + xml.tag! 'soap:Envelope', { 'xmlns:xsi' => 'http://schemas.xmlsoap.org/soap/envelope/', + 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', + 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' } do + xml.tag! 'soap:Body' do + xml.tag! soap_call, { 'xmlns' => "#{self.live_url}remote/payment" } do + xml.tag! 'merchantnumber', @options[:login] + xml.tag! 'transactionid', params[:transaction] + xml.tag! 'amount', params[:amount].to_s if soap_call != 'delete' end end + end xml.target! end diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb index 2182bfac70b..9c6101d45e4 100644 --- a/lib/active_merchant/billing/gateways/eway_managed.rb +++ b/lib/active_merchant/billing/gateways/eway_managed.rb @@ -242,23 +242,23 @@ def soap_request(arguments, action) end xml = Builder::XmlMarkup.new :indent => 2 - xml.instruct! - xml.tag! 'soap12:Envelope', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap12' => 'http://www.w3.org/2003/05/soap-envelope'} do - xml.tag! 'soap12:Header' do - xml.tag! 'eWAYHeader', {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do - xml.tag! 'eWAYCustomerID', @options[:login] - xml.tag! 'Username', @options[:username] - xml.tag! 'Password', @options[:password] - end + xml.instruct! + xml.tag! 'soap12:Envelope', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap12' => 'http://www.w3.org/2003/05/soap-envelope'} do + xml.tag! 'soap12:Header' do + xml.tag! 'eWAYHeader', {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do + xml.tag! 'eWAYCustomerID', @options[:login] + xml.tag! 'Username', @options[:username] + xml.tag! 'Password', @options[:password] end - xml.tag! 'soap12:Body' do |x| - x.tag! action, {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do |y| - post.each do |key, value| - y.tag! key, value - end + end + xml.tag! 'soap12:Body' do |x| + x.tag! action, {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do |y| + post.each do |key, value| + y.tag! key, value end end end + end xml.target! end diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index 2adaf564609..82b35cc7af6 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -33,7 +33,7 @@ def purchase(money, payment_method, options={}) end end end - check?(payment_method) ? commit(:echeckSales, request, money) : commit(:sale, request, money) + check?(payment_method) ? commit(:echeckSales, request, money) : commit(:sale, request, money) end def authorize(money, payment_method, options={}) diff --git a/lib/active_merchant/billing/gateways/netbilling.rb b/lib/active_merchant/billing/gateways/netbilling.rb index 1cc79fe11fb..296d9e198ad 100644 --- a/lib/active_merchant/billing/gateways/netbilling.rb +++ b/lib/active_merchant/billing/gateways/netbilling.rb @@ -143,14 +143,14 @@ def add_address(post, credit_card, options) post[:bill_state] = billing_address[:state] end - if shipping_address = options[:shipping_address] - post[:ship_name1], post[:ship_name2] = split_names(shipping_address[:name]) - post[:ship_street] = shipping_address[:address1] - post[:ship_zip] = shipping_address[:zip] - post[:ship_city] = shipping_address[:city] - post[:ship_country] = shipping_address[:country] - post[:ship_state] = shipping_address[:state] - end + if shipping_address = options[:shipping_address] + post[:ship_name1], post[:ship_name2] = split_names(shipping_address[:name]) + post[:ship_street] = shipping_address[:address1] + post[:ship_zip] = shipping_address[:zip] + post[:ship_city] = shipping_address[:city] + post[:ship_country] = shipping_address[:country] + post[:ship_state] = shipping_address[:state] + end end def add_invoice(post, options) diff --git a/lib/active_merchant/billing/gateways/paystation.rb b/lib/active_merchant/billing/gateways/paystation.rb index 69a6f8c8b95..0c2afac4358 100644 --- a/lib/active_merchant/billing/gateways/paystation.rb +++ b/lib/active_merchant/billing/gateways/paystation.rb @@ -100,101 +100,101 @@ def scrub(transcript) private - def new_request - { - :pi => @options[:paystation_id], # paystation account id - :gi => @options[:gateway_id], # paystation gateway id - '2p' => 't', # two-party transaction type - :nr => 't', # -- redirect?? - :df => 'yymm' # date format: optional sometimes, required others - } - end - - def add_customer_data(post, options) - post[:mc] = options[:customer] - end + def new_request + { + :pi => @options[:paystation_id], # paystation account id + :gi => @options[:gateway_id], # paystation gateway id + '2p' => 't', # two-party transaction type + :nr => 't', # -- redirect?? + :df => 'yymm' # date format: optional sometimes, required others + } + end - def add_invoice(post, options) - post[:ms] = generate_unique_id - post[:mo] = options[:description] - post[:mr] = options[:order_id] - end + def add_customer_data(post, options) + post[:mc] = options[:customer] + end - def add_credit_card(post, credit_card) - post[:cn] = credit_card.number - post[:ct] = credit_card.brand - post[:ex] = format_date(credit_card.month, credit_card.year) - post[:cc] = credit_card.verification_value if credit_card.verification_value? - end + def add_invoice(post, options) + post[:ms] = generate_unique_id + post[:mo] = options[:description] + post[:mr] = options[:order_id] + end - def add_token(post, token) - post[:fp] = 't' # turn on "future payments" - what paystation calls Token Billing - post[:ft] = token - end + def add_credit_card(post, credit_card) + post[:cn] = credit_card.number + post[:ct] = credit_card.brand + post[:ex] = format_date(credit_card.month, credit_card.year) + post[:cc] = credit_card.verification_value if credit_card.verification_value? + end - def store_credit_card(post, options) - post[:fp] = 't' # turn on "future payments" - what paystation calls Token Billing - post[:fs] = 't' # tells paystation to store right now, not bill - post[:ft] = options[:token] if options[:token] # specify a token to use that, or let Paystation generate one - end + def add_token(post, token) + post[:fp] = 't' # turn on "future payments" - what paystation calls Token Billing + post[:ft] = token + end - def add_authorize_flag(post, options) - post[:pa] = 't' # tells Paystation that this is a pre-auth authorisation payment (account must be in pre-auth mode) - end + def store_credit_card(post, options) + post[:fp] = 't' # turn on "future payments" - what paystation calls Token Billing + post[:fs] = 't' # tells paystation to store right now, not bill + post[:ft] = options[:token] if options[:token] # specify a token to use that, or let Paystation generate one + end - def add_refund_specific_fields(post, authorization) - post[:rc] = 't' - post[:rt] = authorization - end + def add_authorize_flag(post, options) + post[:pa] = 't' # tells Paystation that this is a pre-auth authorisation payment (account must be in pre-auth mode) + end - def add_authorization_token(post, auth_token, verification_value = nil) - post[:cp] = 't' # Capture Payment flag – tells Paystation this transaction should be treated as a capture payment - post[:cx] = auth_token - post[:cc] = verification_value - end + def add_refund_specific_fields(post, authorization) + post[:rc] = 't' + post[:rt] = authorization + end - def add_amount(post, money, options) - post[:am] = amount(money) - post[:cu] = options[:currency] || currency(money) - end + def add_authorization_token(post, auth_token, verification_value = nil) + post[:cp] = 't' # Capture Payment flag – tells Paystation this transaction should be treated as a capture payment + post[:cx] = auth_token + post[:cc] = verification_value + end - def parse(xml_response) - response = {} + def add_amount(post, money, options) + post[:am] = amount(money) + post[:cu] = options[:currency] || currency(money) + end - xml = REXML::Document.new(xml_response) + def parse(xml_response) + response = {} - xml.elements.each("#{xml.root.name}/*") do |element| - response[element.name.underscore.to_sym] = element.text - end + xml = REXML::Document.new(xml_response) - response + xml.elements.each("#{xml.root.name}/*") do |element| + response[element.name.underscore.to_sym] = element.text end - def commit(post) - post[:tm] = 'T' if test? - pstn_prefix_params = post.collect { |key, value| "pstn_#{key}=#{CGI.escape(value.to_s)}" }.join('&') + response + end - data = ssl_post(self.live_url, "#{pstn_prefix_params}&paystation=_empty") - response = parse(data) - message = message_from(response) + def commit(post) + post[:tm] = 'T' if test? + pstn_prefix_params = post.collect { |key, value| "pstn_#{key}=#{CGI.escape(value.to_s)}" }.join('&') - PaystationResponse.new(success?(response), message, response, - :test => (response[:tm]&.casecmp('t')&.zero?), - :authorization => response[:paystation_transaction_id] - ) - end + data = ssl_post(self.live_url, "#{pstn_prefix_params}&paystation=_empty") + response = parse(data) + message = message_from(response) - def success?(response) - (response[:ec] == SUCCESSFUL_RESPONSE_CODE) || (response[:ec] == SUCCESSFUL_FUTURE_PAYMENT) - end + PaystationResponse.new(success?(response), message, response, + :test => (response[:tm]&.casecmp('t')&.zero?), + :authorization => response[:paystation_transaction_id] + ) + end - def message_from(response) - response[:em] - end + def success?(response) + (response[:ec] == SUCCESSFUL_RESPONSE_CODE) || (response[:ec] == SUCCESSFUL_FUTURE_PAYMENT) + end - def format_date(month, year) - "#{format(year, :two_digits)}#{format(month, :two_digits)}" - end + def message_from(response) + response[:em] + end + + def format_date(month, year) + "#{format(year, :two_digits)}#{format(month, :two_digits)}" + end end diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb index 10ad00b3ae3..971c703d528 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb @@ -99,197 +99,197 @@ def scrub(transcript) private - def authorization_params(money, credit_card_or_reference, options = {}) - post = {} - - add_amount(post, money, options) - add_credit_card_or_reference(post, credit_card_or_reference) - add_additional_params(:authorize, post, options) + def authorization_params(money, credit_card_or_reference, options = {}) + post = {} - post - end + add_amount(post, money, options) + add_credit_card_or_reference(post, credit_card_or_reference) + add_additional_params(:authorize, post, options) - def capture_params(money, credit_card, options = {}) - post = {} + post + end - add_amount(post, money, options) - add_additional_params(:capture, post, options) + def capture_params(money, credit_card, options = {}) + post = {} - post - end + add_amount(post, money, options) + add_additional_params(:capture, post, options) - def create_store(options = {}) - post = {} - commit('/cards', post) - end + post + end - def authorize_store(identification, credit_card, options = {}) - post = {} + def create_store(options = {}) + post = {} + commit('/cards', post) + end - add_credit_card_or_reference(post, credit_card, options) - commit(synchronized_path("/cards/#{identification}/authorize"), post) - end + def authorize_store(identification, credit_card, options = {}) + post = {} - def create_token(identification, options) - post = {} - commit(synchronized_path("/cards/#{identification}/tokens"), post) - end + add_credit_card_or_reference(post, credit_card, options) + commit(synchronized_path("/cards/#{identification}/authorize"), post) + end - def create_payment(money, options = {}) - post = {} - add_currency(post, money, options) - add_invoice(post, options) - commit('/payments', post) - end + def create_token(identification, options) + post = {} + commit(synchronized_path("/cards/#{identification}/tokens"), post) + end - def commit(action, params = {}) - success = false - begin - response = parse(ssl_post(self.live_url + action, params.to_json, headers)) - success = successful?(response) - rescue ResponseError => e - response = response_error(e.response.body) - rescue JSON::ParserError - response = json_error(response) - end + def create_payment(money, options = {}) + post = {} + add_currency(post, money, options) + add_invoice(post, options) + commit('/payments', post) + end - Response.new(success, message_from(success, response), response, - :test => test?, - :authorization => authorization_from(response) - ) + def commit(action, params = {}) + success = false + begin + response = parse(ssl_post(self.live_url + action, params.to_json, headers)) + success = successful?(response) + rescue ResponseError => e + response = response_error(e.response.body) + rescue JSON::ParserError + response = json_error(response) end - def authorization_from(response) - if response['token'] - response['token'].to_s - else - response['id'].to_s - end - end + Response.new(success, message_from(success, response), response, + :test => test?, + :authorization => authorization_from(response) + ) + end - def add_currency(post, money, options) - post[:currency] = options[:currency] || currency(money) + def authorization_from(response) + if response['token'] + response['token'].to_s + else + response['id'].to_s end + end - def add_amount(post, money, options) - post[:amount] = options[:amount] || amount(money) - end + def add_currency(post, money, options) + post[:currency] = options[:currency] || currency(money) + end - def add_autocapture(post, value) - post[:auto_capture] = value - end + def add_amount(post, money, options) + post[:amount] = options[:amount] || amount(money) + end - def add_order_id(post, options) - requires!(options, :order_id) - post[:order_id] = format_order_id(options[:order_id]) - end + def add_autocapture(post, value) + post[:auto_capture] = value + end - def add_invoice(post, options) - add_order_id(post, options) + def add_order_id(post, options) + requires!(options, :order_id) + post[:order_id] = format_order_id(options[:order_id]) + end - if options[:billing_address] - post[:invoice_address] = map_address(options[:billing_address]) - end + def add_invoice(post, options) + add_order_id(post, options) - if options[:shipping_address] - post[:shipping_address] = map_address(options[:shipping_address]) - end + if options[:billing_address] + post[:invoice_address] = map_address(options[:billing_address]) + end - [:metadata, :branding_id, :variables].each do |field| - post[field] = options[field] if options[field] - end + if options[:shipping_address] + post[:shipping_address] = map_address(options[:shipping_address]) end - def add_additional_params(action, post, options = {}) - MD5_CHECK_FIELDS[API_VERSION][action].each do |key| - key = key.to_sym - post[key] = options[key] if options[key] - end + [:metadata, :branding_id, :variables].each do |field| + post[field] = options[field] if options[field] end + end - def add_credit_card_or_reference(post, credit_card_or_reference, options = {}) - post[:card] ||= {} - if credit_card_or_reference.is_a?(String) - post[:card][:token] = credit_card_or_reference - else - post[:card][:number] = credit_card_or_reference.number - post[:card][:cvd] = credit_card_or_reference.verification_value - post[:card][:expiration] = expdate(credit_card_or_reference) - post[:card][:issued_to] = credit_card_or_reference.name - end + def add_additional_params(action, post, options = {}) + MD5_CHECK_FIELDS[API_VERSION][action].each do |key| + key = key.to_sym + post[key] = options[key] if options[key] end + end - def parse(body) - JSON.parse(body) + def add_credit_card_or_reference(post, credit_card_or_reference, options = {}) + post[:card] ||= {} + if credit_card_or_reference.is_a?(String) + post[:card][:token] = credit_card_or_reference + else + post[:card][:number] = credit_card_or_reference.number + post[:card][:cvd] = credit_card_or_reference.verification_value + post[:card][:expiration] = expdate(credit_card_or_reference) + post[:card][:issued_to] = credit_card_or_reference.name end + end - def successful?(response) - has_error = response['errors'] - invalid_code = invalid_operation_code?(response) + def parse(body) + JSON.parse(body) + end - !(has_error || invalid_code) - end + def successful?(response) + has_error = response['errors'] + invalid_code = invalid_operation_code?(response) - def message_from(success, response) - success ? 'OK' : (response['message'] || invalid_operation_message(response) || 'Unknown error - please contact QuickPay') - end + !(has_error || invalid_code) + end - def invalid_operation_code?(response) - if response['operations'] - operation = response['operations'].last - operation && operation['qp_status_code'] != '20000' - end - end + def message_from(success, response) + success ? 'OK' : (response['message'] || invalid_operation_message(response) || 'Unknown error - please contact QuickPay') + end - def invalid_operation_message(response) - response['operations'] && response['operations'].last['qp_status_msg'] + def invalid_operation_code?(response) + if response['operations'] + operation = response['operations'].last + operation && operation['qp_status_code'] != '20000' end + end - def map_address(address) - return {} if address.nil? - requires!(address, :name, :address1, :city, :zip, :country) - country = Country.find(address[:country]) - mapped = { - :name => address[:name], - :street => address[:address1], - :city => address[:city], - :region => address[:address2], - :zip_code => address[:zip], - :country_code => country.code(:alpha3).value - } - mapped - end + def invalid_operation_message(response) + response['operations'] && response['operations'].last['qp_status_msg'] + end - def format_order_id(order_id) - truncate(order_id.to_s.gsub(/#/, ''), 20) - end + def map_address(address) + return {} if address.nil? + requires!(address, :name, :address1, :city, :zip, :country) + country = Country.find(address[:country]) + mapped = { + :name => address[:name], + :street => address[:address1], + :city => address[:city], + :region => address[:address2], + :zip_code => address[:zip], + :country_code => country.code(:alpha3).value + } + mapped + end - def headers - auth = Base64.strict_encode64(":#{@options[:api_key]}") - { - 'Authorization' => 'Basic ' + auth, - 'User-Agent' => "Quickpay-v#{API_VERSION} ActiveMerchantBindings/#{ActiveMerchant::VERSION}", - 'Accept' => 'application/json', - 'Accept-Version' => "v#{API_VERSION}", - 'Content-Type' => 'application/json' - } - end + def format_order_id(order_id) + truncate(order_id.to_s.gsub(/#/, ''), 20) + end - def response_error(raw_response) - parse(raw_response) - rescue JSON::ParserError - json_error(raw_response) - end + def headers + auth = Base64.strict_encode64(":#{@options[:api_key]}") + { + 'Authorization' => 'Basic ' + auth, + 'User-Agent' => "Quickpay-v#{API_VERSION} ActiveMerchantBindings/#{ActiveMerchant::VERSION}", + 'Accept' => 'application/json', + 'Accept-Version' => "v#{API_VERSION}", + 'Content-Type' => 'application/json' + } + end - def json_error(raw_response) - msg = 'Invalid response received from the Quickpay API.' - msg += " (The raw response returned by the API was #{raw_response.inspect})" - { 'message' => msg } - end + def response_error(raw_response) + parse(raw_response) + rescue JSON::ParserError + json_error(raw_response) + end - def synchronized_path(path) - "#{path}?synchronized" - end + def json_error(raw_response) + msg = 'Invalid response received from the Quickpay API.' + msg += " (The raw response returned by the API was #{raw_response.inspect})" + { 'message' => msg } + end + + def synchronized_path(path) + "#{path}?synchronized" + end end end end diff --git a/test/remote/gateways/remote_banwire_test.rb b/test/remote/gateways/remote_banwire_test.rb index cb8331a5661..0af462e9a7b 100644 --- a/test/remote/gateways/remote_banwire_test.rb +++ b/test/remote/gateways/remote_banwire_test.rb @@ -53,14 +53,14 @@ def test_invalid_login assert_equal 'ID de cuenta invalido', response.message end -def test_transcript_scrubbing - transcript = capture_transcript(@gateway) do - @gateway.purchase(@amount, @credit_card, @options) - end - clean_transcript = @gateway.scrub(transcript) + def test_transcript_scrubbing + transcript = capture_transcript(@gateway) do + @gateway.purchase(@amount, @credit_card, @options) + end + clean_transcript = @gateway.scrub(transcript) - assert_scrubbed(@credit_card.number, clean_transcript) - assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript) -end + assert_scrubbed(@credit_card.number, clean_transcript) + assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript) + end end diff --git a/test/remote/gateways/remote_cardknox_test.rb b/test/remote/gateways/remote_cardknox_test.rb index 457c0928f27..211e1e9afcb 100644 --- a/test/remote/gateways/remote_cardknox_test.rb +++ b/test/remote/gateways/remote_cardknox_test.rb @@ -37,7 +37,7 @@ def setup } } - @options = {} + @options = {} end def test_successful_credit_card_purchase diff --git a/test/remote/gateways/remote_merchant_one_test.rb b/test/remote/gateways/remote_merchant_one_test.rb index 936cb70235e..2e8969dadc9 100644 --- a/test/remote/gateways/remote_merchant_one_test.rb +++ b/test/remote/gateways/remote_merchant_one_test.rb @@ -31,34 +31,34 @@ def test_successful_purchase assert_equal 'SUCCESS', response.message end - def test_unsuccessful_purchase - assert response = @gateway.purchase(@amount, @declined_card, @options) - assert_failure response - assert response.message.include? 'Invalid Credit Card Number' - end + def test_unsuccessful_purchase + assert response = @gateway.purchase(@amount, @declined_card, @options) + assert_failure response + assert response.message.include? 'Invalid Credit Card Number' + end - def test_authorize_and_capture - amount = @amount - assert auth = @gateway.authorize(amount, @credit_card, @options) - assert_success auth - assert_equal 'SUCCESS', auth.message - assert auth.authorization, auth.to_yaml - assert capture = @gateway.capture(amount, auth.authorization) - assert_success capture - end + def test_authorize_and_capture + amount = @amount + assert auth = @gateway.authorize(amount, @credit_card, @options) + assert_success auth + assert_equal 'SUCCESS', auth.message + assert auth.authorization, auth.to_yaml + assert capture = @gateway.capture(amount, auth.authorization) + assert_success capture + end - def test_failed_capture - assert response = @gateway.capture(@amount, '') - assert_failure response - end + def test_failed_capture + assert response = @gateway.capture(@amount, '') + assert_failure response + end - def test_invalid_login - gateway = MerchantOneGateway.new( - :username => 'nnn', - :password => 'nnn' - ) - assert response = gateway.purchase(@amount, @credit_card, @options) - assert_failure response - assert_equal 'Authentication Failed', response.message - end + def test_invalid_login + gateway = MerchantOneGateway.new( + :username => 'nnn', + :password => 'nnn' + ) + assert response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_equal 'Authentication Failed', response.message + end end diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb index e3afb520134..a99c5c793e4 100644 --- a/test/remote/gateways/remote_usa_epay_transaction_test.rb +++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb @@ -43,12 +43,12 @@ def test_successful_authorization_with_manual_entry assert_success response end - def test_successful_purchase_with_manual_entry - @credit_card.manual_entry = true - assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal 'Success', response.message - assert_success response - end + def test_successful_purchase_with_manual_entry + @credit_card.manual_entry = true + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_equal 'Success', response.message + assert_success response + end def test_successful_purchase_with_extra_details assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:order_id => generate_unique_id, :description => 'socool')) diff --git a/test/unit/gateways/eway_managed_test.rb b/test/unit/gateways/eway_managed_test.rb index c322e223579..02666e0bc71 100644 --- a/test/unit/gateways/eway_managed_test.rb +++ b/test/unit/gateways/eway_managed_test.rb @@ -372,9 +372,9 @@ def expected_store_request XML end - # Documented here: https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?op=CreateCustomer - def expected_purchase_request - <<-XML + # Documented here: https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?op=CreateCustomer + def expected_purchase_request + <<-XML <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Header> @@ -393,8 +393,8 @@ def expected_purchase_request </ProcessPayment> </soap12:Body> </soap12:Envelope> - XML - end + XML + end # Documented here: https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?op=QueryCustomer def expected_retrieve_request @@ -416,5 +416,4 @@ def expected_retrieve_request </soap12:Envelope> XML end - end diff --git a/test/unit/gateways/netbanx_test.rb b/test/unit/gateways/netbanx_test.rb index ba464b8eac2..cb9af17b688 100644 --- a/test/unit/gateways/netbanx_test.rb +++ b/test/unit/gateways/netbanx_test.rb @@ -146,9 +146,9 @@ def test_successful_unstore assert_success response assert response.test? - response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015') - assert_success response - assert response.test? + response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015') + assert_success response + assert response.test? end def test_scrub diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index b79fdac439e..f030672e46c 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -219,12 +219,12 @@ def test_truncates_phone def test_truncates_zip long_zip = '1234567890123' - response = stub_comms do - @gateway.purchase(50, credit_card, :order_id => 1, :billing_address => address(:zip => long_zip)) - end.check_request do |endpoint, data, headers| - assert_match(/1234567890</, data) - end.respond_with(successful_purchase_response) - assert_success response + response = stub_comms do + @gateway.purchase(50, credit_card, :order_id => 1, :billing_address => address(:zip => long_zip)) + end.check_request do |endpoint, data, headers| + assert_match(/1234567890</, data) + end.respond_with(successful_purchase_response) + assert_success response end def test_address_format diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb index 0c4f89d6641..1eef9513781 100644 --- a/test/unit/gateways/paypal_express_test.rb +++ b/test/unit/gateways/paypal_express_test.rb @@ -1056,8 +1056,8 @@ def response_with_error RESPONSE end - def response_with_errors - <<-RESPONSE + def response_with_errors + <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:market="urn:ebay:apis:Market" xmlns:auction="urn:ebay:apis:Auction" xmlns:sizeship="urn:ebay:api:PayPalAPI/sizeship.xsd" xmlns:ship="urn:ebay:apis:ship" xmlns:skype="urn:ebay:apis:skype" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI"> <SOAP-ENV:Header> @@ -1093,10 +1093,10 @@ def response_with_errors </SOAP-ENV:Body> </SOAP-ENV:Envelope> RESPONSE - end + end - def response_with_duplicate_errors - <<-RESPONSE + def response_with_duplicate_errors + <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:market="urn:ebay:apis:Market" xmlns:auction="urn:ebay:apis:Auction" xmlns:sizeship="urn:ebay:api:PayPalAPI/sizeship.xsd" xmlns:ship="urn:ebay:apis:ship" xmlns:skype="urn:ebay:apis:skype" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI"> <SOAP-ENV:Header> @@ -1132,10 +1132,10 @@ def response_with_duplicate_errors </SOAP-ENV:Body> </SOAP-ENV:Envelope> RESPONSE - end + end - def successful_cancel_billing_agreement_response - <<-RESPONSE + def successful_cancel_billing_agreement_response + <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" @@ -1159,10 +1159,10 @@ def successful_cancel_billing_agreement_response xsi:type="xs:string"></ExternalAddressID><AddressStatus xsi:type="ebl:AddressStatusCodeType">None</AddressStatus></Address></PayerInfo></BAUpdateResponseDetails></BAUpdateResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> RESPONSE - end + end - def failed_cancel_billing_agreement_response - <<-RESPONSE + def failed_cancel_billing_agreement_response + <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" @@ -1185,10 +1185,10 @@ def failed_cancel_billing_agreement_response xsi:type="xs:string"></AddressID><AddressOwner xsi:type="ebl:AddressOwnerCodeType">PayPal</AddressOwner><ExternalAddressID xsi:type="xs:string"></ExternalAddressID><AddressStatus xsi:type="ebl:AddressStatusCodeType">None</AddressStatus></Address></PayerInfo></BAUpdateResponseDetails></BAUpdateResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> RESPONSE - end + end - def successful_billing_agreement_details_response - <<-RESPONSE + def successful_billing_agreement_details_response + <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" @@ -1218,10 +1218,10 @@ def successful_billing_agreement_details_response <ExternalAddressID xsi:type="xs:string"></ExternalAddressID><AddressStatus xsi:type="ebl:AddressStatusCodeType">None</AddressStatus> </Address></PayerInfo></BAUpdateResponseDetails></BAUpdateResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> RESPONSE - end + end - def failure_billing_agreement_details_response - <<-RESPONSE + def failure_billing_agreement_details_response + <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" @@ -1250,10 +1250,10 @@ def failure_billing_agreement_details_response <ExternalAddressID xsi:type="xs:string"></ExternalAddressID><AddressStatus xsi:type="ebl:AddressStatusCodeType">None</AddressStatus></Address> </PayerInfo></BAUpdateResponseDetails></BAUpdateResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> RESPONSE - end + end - def pre_scrubbed - <<-TRANSCRIPT + def pre_scrubbed + <<-TRANSCRIPT <?xml version=\"1.0\" encoding=\"UTF-8\"?><env:Envelope xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><env:Header><RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\" xmlns:n1=\"urn:ebay:apis:eBLBaseComponents\" env:mustUnderstand=\"0\"><n1:Credentials><n1:Username>activemerchant-cert-test_api1.example.com</n1:Username><n1:Password>ERDD3JRFU5H5DQXS</n1:Password><n1:Subject/></n1:Credentials></RequesterCredentials></env:Header><env:Body><SetExpressCheckoutReq xmlns=\"urn:ebay:api:PayPalAPI\"> <SetExpressCheckoutRequest xmlns:n2=\"urn:ebay:apis:eBLBaseComponents\"> <n2:Version>124</n2:Version> @@ -1276,10 +1276,10 @@ def pre_scrubbed </env:Body></env:Envelope> <?xml version=\"1.0\" encoding=\"UTF-8\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:cc=\"urn:ebay:apis:CoreComponentTypes\" xmlns:wsu=\"http://schemas.xmlsoap.org/ws/2002/07/utility\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xmlns:ed=\"urn:ebay:apis:EnhancedDataTypes\" xmlns:ebl=\"urn:ebay:apis:eBLBaseComponents\" xmlns:ns=\"urn:ebay:api:PayPalAPI\"><SOAP-ENV:Header><Security xmlns=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xsi:type=\"wsse:SecurityType\"></Security><RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\" xsi:type=\"ebl:CustomSecurityHeaderType\"><Credentials xmlns=\"urn:ebay:apis:eBLBaseComponents\" xsi:type=\"ebl:UserIdPasswordType\"><Username xsi:type=\"xs:string\"></Username><Password xsi:type=\"xs:string\"></Password><Signature xsi:type=\"xs:string\"></Signature><Subject xsi:type=\"xs:string\"></Subject></Credentials></RequesterCredentials></SOAP-ENV:Header><SOAP-ENV:Body id=\"_0\"><SetExpressCheckoutResponse xmlns=\"urn:ebay:api:PayPalAPI\"><Timestamp xmlns=\"urn:ebay:apis:eBLBaseComponents\">2018-05-24T20:23:54Z</Timestamp><Ack xmlns=\"urn:ebay:apis:eBLBaseComponents\">Success</Ack><CorrelationID xmlns=\"urn:ebay:apis:eBLBaseComponents\">b6dd2a043921b</CorrelationID><Version xmlns=\"urn:ebay:apis:eBLBaseComponents\">124</Version><Build xmlns=\"urn:ebay:apis:eBLBaseComponents\">46549960</Build><Token xsi:type=\"ebl:ExpressCheckoutTokenType\">EC-7KR85820NC734104L</Token></SetExpressCheckoutResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> TRANSCRIPT - end + end - def post_scrubbed - <<-TRANSCRIPT + def post_scrubbed + <<-TRANSCRIPT <?xml version=\"1.0\" encoding=\"UTF-8\"?><env:Envelope xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><env:Header><RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\" xmlns:n1=\"urn:ebay:apis:eBLBaseComponents\" env:mustUnderstand=\"0\"><n1:Credentials><n1:Username>[FILTERED]</n1:Username><n1:Password>[FILTERED]</n1:Password><n1:Subject/></n1:Credentials></RequesterCredentials></env:Header><env:Body><SetExpressCheckoutReq xmlns=\"urn:ebay:api:PayPalAPI\"> <SetExpressCheckoutRequest xmlns:n2=\"urn:ebay:apis:eBLBaseComponents\"> <n2:Version>124</n2:Version> @@ -1302,5 +1302,5 @@ def post_scrubbed </env:Body></env:Envelope> <?xml version=\"1.0\" encoding=\"UTF-8\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:cc=\"urn:ebay:apis:CoreComponentTypes\" xmlns:wsu=\"http://schemas.xmlsoap.org/ws/2002/07/utility\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xmlns:ed=\"urn:ebay:apis:EnhancedDataTypes\" xmlns:ebl=\"urn:ebay:apis:eBLBaseComponents\" xmlns:ns=\"urn:ebay:api:PayPalAPI\"><SOAP-ENV:Header><Security xmlns=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xsi:type=\"wsse:SecurityType\"></Security><RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\" xsi:type=\"ebl:CustomSecurityHeaderType\"><Credentials xmlns=\"urn:ebay:apis:eBLBaseComponents\" xsi:type=\"ebl:UserIdPasswordType\"><Username xsi:type=\"xs:string\"></Username><Password xsi:type=\"xs:string\"></Password><Signature xsi:type=\"xs:string\"></Signature><Subject xsi:type=\"xs:string\"></Subject></Credentials></RequesterCredentials></SOAP-ENV:Header><SOAP-ENV:Body id=\"_0\"><SetExpressCheckoutResponse xmlns=\"urn:ebay:api:PayPalAPI\"><Timestamp xmlns=\"urn:ebay:apis:eBLBaseComponents\">2018-05-24T20:23:54Z</Timestamp><Ack xmlns=\"urn:ebay:apis:eBLBaseComponents\">Success</Ack><CorrelationID xmlns=\"urn:ebay:apis:eBLBaseComponents\">b6dd2a043921b</CorrelationID><Version xmlns=\"urn:ebay:apis:eBLBaseComponents\">124</Version><Build xmlns=\"urn:ebay:apis:eBLBaseComponents\">46549960</Build><Token xsi:type=\"ebl:ExpressCheckoutTokenType\">EC-7KR85820NC734104L</Token></SetExpressCheckoutResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> TRANSCRIPT - end + end end diff --git a/test/unit/gateways/paystation_test.rb b/test/unit/gateways/paystation_test.rb index 1ed768b1186..c32716c1383 100644 --- a/test/unit/gateways/paystation_test.rb +++ b/test/unit/gateways/paystation_test.rb @@ -118,312 +118,312 @@ def test_scrub private - def successful_purchase_response - %(<?xml version="1.0" standalone="yes"?> - <response> - <ec>0</ec> - <em>Transaction successful</em> - <ti>0006713018-01</ti> - <ct>mastercard</ct> - <merchant_ref>Store Purchase</merchant_ref> - <tm>T</tm> - <MerchantSession>1</MerchantSession> - <UsedAcquirerMerchantID>123456</UsedAcquirerMerchantID> - <TransactionID>0008813023-01</TransactionID> - <PurchaseAmount>10000</PurchaseAmount> - <Locale/> - <ReturnReceiptNumber>8813023</ReturnReceiptNumber> - <ShoppingTransactionNumber/> - <AcqResponseCode>00</AcqResponseCode> - <QSIResponseCode>0</QSIResponseCode> - <CSCResultCode/> - <AVSResultCode/> - <TransactionTime>2011-06-22 00:05:52</TransactionTime> - <PaystationErrorCode>0</PaystationErrorCode> - <PaystationErrorMessage>Transaction successful</PaystationErrorMessage> - <MerchantReference>Store Purchase</MerchantReference> - <TransactionMode>T</TransactionMode> - <BatchNumber>0622</BatchNumber> - <AuthorizeID/> - <Cardtype>MC</Cardtype> - <Username>12345</Username> - <RequestIP>192.168.0.1</RequestIP> - <RequestUserAgent/> - <RequestHttpReferrer/> - <PaymentRequestTime>2011-06-22 00:05:52</PaymentRequestTime> - <DigitalOrderTime/> - <DigitalReceiptTime>2011-06-22 00:05:52</DigitalReceiptTime> - <PaystationTransactionID>0008813023-01</PaystationTransactionID> - <IssuerName>unknown</IssuerName> - <IssuerCountry>unknown</IssuerCountry> - </response>) - end - - def failed_purchase_response - %(<?xml version="1.0" standalone="yes"?> - <response> - <ec>5</ec> - <em>Insufficient Funds</em> - <ti>0006713018-01</ti> - <ct>mastercard</ct> - <merchant_ref>Store Purchase</merchant_ref> - <tm>T</tm> - <MerchantSession>1</MerchantSession> - <UsedAcquirerMerchantID>123456</UsedAcquirerMerchantID> - <TransactionID>0008813018-01</TransactionID> - <PurchaseAmount>10051</PurchaseAmount> - <Locale/> - <ReturnReceiptNumber>8813018</ReturnReceiptNumber> - <ShoppingTransactionNumber/> - <AcqResponseCode>51</AcqResponseCode> - <QSIResponseCode>5</QSIResponseCode> - <CSCResultCode/> - <AVSResultCode/> - <TransactionTime>2011-06-22 00:05:46</TransactionTime> - <PaystationErrorCode>5</PaystationErrorCode> - <PaystationErrorMessage>Insufficient Funds</PaystationErrorMessage> - <MerchantReference>Store Purchase</MerchantReference> - <TransactionMode>T</TransactionMode> - <BatchNumber>0622</BatchNumber> - <AuthorizeID/> - <Cardtype>MC</Cardtype> - <Username>123456</Username> - <RequestIP>192.168.0.1</RequestIP> - <RequestUserAgent/> - <RequestHttpReferrer/> - <PaymentRequestTime>2011-06-22 00:05:46</PaymentRequestTime> - <DigitalOrderTime/> - <DigitalReceiptTime>2011-06-22 00:05:46</DigitalReceiptTime> - <PaystationTransactionID>0008813018-01</PaystationTransactionID> - <IssuerName>unknown</IssuerName> - <IssuerCountry>unknown</IssuerCountry> - </response>) - end - - def successful_store_response - %(<?xml version="1.0" standalone="yes"?> - <PaystationFuturePaymentResponse> - <ec>34</ec> - <em>Future Payment Saved Ok</em> - <ti/> - <ct/> - <merchant_ref>Store Purchase</merchant_ref> - <tm>T</tm> - <MerchantSession>3e48fa9a6b0fe36177adf7269db7a3c4</MerchantSession> - <UsedAcquirerMerchantID/> - <TransactionID/> - <PurchaseAmount>0</PurchaseAmount> - <Locale/> - <ReturnReceiptNumber/> - <ShoppingTransactionNumber/> - <AcqResponseCode/> - <QSIResponseCode/> - <CSCResultCode/> - <AVSResultCode/> - <TransactionTime>2011-07-10 13:58:55</TransactionTime> - <PaystationErrorCode>34</PaystationErrorCode> - <PaystationErrorMessage>Future Payment Saved Ok</PaystationErrorMessage> - <MerchantReference>Store Purchase</MerchantReference> - <TransactionMode>T</TransactionMode> - <BatchNumber/> - <AuthorizeID/> - <Cardtype/> - <Username>123456</Username> - <RequestIP>192.168.0.1</RequestIP> - <RequestUserAgent/> - <RequestHttpReferrer/> - <PaymentRequestTime>2011-07-10 13:58:55</PaymentRequestTime> - <DigitalOrderTime/> - <DigitalReceiptTime>2011-07-10 13:58:55</DigitalReceiptTime> - <PaystationTransactionID>0009062177-01</PaystationTransactionID> - <FuturePaymentToken>justatest1310263135</FuturePaymentToken> - <IssuerName>unknown</IssuerName> - <IssuerCountry>unknown</IssuerCountry> - </PaystationFuturePaymentResponse>) - end - - def successful_stored_purchase_response - %(<?xml version="1.0" standalone="yes"?> - <PaystationFuturePaymentResponse> - <ec>0</ec> - <em>Transaction successful</em> - <ti>0006713018-01</ti> - <ct>visa</ct> - <merchant_ref>Store Purchase</merchant_ref> - <tm>T</tm> - <MerchantSession>0fc70a577f19ae63f651f53c7044640a</MerchantSession> - <UsedAcquirerMerchantID>123456</UsedAcquirerMerchantID> - <TransactionID>0009062149-01</TransactionID> - <PurchaseAmount>10000</PurchaseAmount> - <Locale/> - <ReturnReceiptNumber>9062149</ReturnReceiptNumber> - <ShoppingTransactionNumber/> - <AcqResponseCode>00</AcqResponseCode> - <QSIResponseCode>0</QSIResponseCode> - <CSCResultCode/> - <AVSResultCode/> - <TransactionTime>2011-07-10 13:55:00</TransactionTime> - <PaystationErrorCode>0</PaystationErrorCode> - <PaystationErrorMessage>Transaction successful</PaystationErrorMessage> - <MerchantReference>Store Purchase</MerchantReference> - <TransactionMode>T</TransactionMode> - <BatchNumber>0710</BatchNumber> - <AuthorizeID/> - <Cardtype>VC</Cardtype> - <Username>123456</Username> - <RequestIP>192.168.0.1</RequestIP> - <RequestUserAgent/> - <RequestHttpReferrer/> - <PaymentRequestTime>2011-07-10 13:55:00</PaymentRequestTime> - <DigitalOrderTime/> - <DigitalReceiptTime>2011-07-10 13:55:00</DigitalReceiptTime> - <PaystationTransactionID>0009062149-01</PaystationTransactionID> - <FuturePaymentToken>u09fxli14afpnd6022x0z82317beqe9e2w048l9it8286k6lpvz9x27hdal9bl95</FuturePaymentToken> - <IssuerName>unknown</IssuerName> - <IssuerCountry>unknown</IssuerCountry> - </PaystationFuturePaymentResponse>) - end - - def successful_authorization_response - %(<?xml version="1.0" standalone="yes"?> - <response> - <ec>0</ec> - <em>Transaction successful</em> - <ti>0009062250-01</ti> - <ct>visa</ct> - <merchant_ref>Store Purchase</merchant_ref> - <tm>T</tm> - <MerchantSession>b2168af96076522466af4e3d61e5ba0c</MerchantSession> - <UsedAcquirerMerchantID>123456</UsedAcquirerMerchantID> - <TransactionID>0009062250-01</TransactionID> - <PurchaseAmount>10000</PurchaseAmount> - <Locale/> - <ReturnReceiptNumber>9062250</ReturnReceiptNumber> - <ShoppingTransactionNumber/> - <AcqResponseCode>00</AcqResponseCode> - <QSIResponseCode>0</QSIResponseCode> - <CSCResultCode/> - <AVSResultCode/> - <TransactionTime>2011-07-10 14:11:00</TransactionTime> - <PaystationErrorCode>0</PaystationErrorCode> - <PaystationErrorMessage>Transaction successful</PaystationErrorMessage> - <MerchantReference>Store Purchase</MerchantReference> - <TransactionMode>T</TransactionMode> - <BatchNumber>0710</BatchNumber> - <AuthorizeID/> - <Cardtype>VC</Cardtype> - <Username>123456</Username> - <RequestIP>192.168.0.1</RequestIP> - <RequestUserAgent/> - <RequestHttpReferrer/> - <PaymentRequestTime>2011-07-10 14:11:00</PaymentRequestTime> - <DigitalOrderTime/> - <DigitalReceiptTime>2011-07-10 14:11:00</DigitalReceiptTime> - <PaystationTransactionID>0009062250-01</PaystationTransactionID> - <IssuerName>unknown</IssuerName> - <IssuerCountry>unknown</IssuerCountry> - </response>) - end - - def successful_capture_response - %(<?xml version="1.0" standalone="yes"?> - <PaystationCaptureResponse> - <ec>0</ec> - <em>Transaction successful</em> - <ti>0009062289-01</ti> - <ct/> - <merchant_ref>Store Purchase</merchant_ref> - <tm>T</tm> - <MerchantSession>485fdedc81dc83848dd799cd10a869db</MerchantSession> - <UsedAcquirerMerchantID>123456</UsedAcquirerMerchantID> - <TransactionID>0009062289-01</TransactionID> - <CaptureAmount>10000</CaptureAmount> - <Locale/> - <ReturnReceiptNumber>9062289</ReturnReceiptNumber> - <ShoppingTransactionNumber/> - <AcqResponseCode>00</AcqResponseCode> - <QSIResponseCode>0</QSIResponseCode> - <CSCResultCode/> - <AVSResultCode/> - <TransactionTime>2011-07-10 14:17:36</TransactionTime> - <PaystationErrorCode>0</PaystationErrorCode> - <PaystationErrorMessage>Transaction successful</PaystationErrorMessage> - <MerchantReference>Store Purchase</MerchantReference> - <TransactionMode>T</TransactionMode> - <BatchNumber>0710</BatchNumber> - <AuthorizeID/> - <Cardtype/> - <Username>123456</Username> - <RequestIP>192.168.0.1</RequestIP> - <RequestUserAgent/> - <RequestHttpReferrer/> - <PaymentRequestTime>2011-07-10 14:17:36</PaymentRequestTime> - <DigitalOrderTime>2011-07-10 14:17:36</DigitalOrderTime> - <DigitalReceiptTime>2011-07-10 14:17:36</DigitalReceiptTime> - <PaystationTransactionID/> - <RefundedAmount/> - <CapturedAmount>10000</CapturedAmount> - <AuthorisedAmount/> - </PaystationCaptureResponse>) - end - - def successful_refund_response - %(<?xml version="1.0" standalone="yes"?> - <PaystationRefundResponse> - <ec>0</ec> - <em>Transaction successful</em> - <ti>0008813023-01</ti> - <ct>mastercard</ct> - <merchant_ref>Store Purchase</merchant_ref> - <tm>T</tm> - <MerchantSession>70ceae1b3f069e41ca7f4350a1180cb1</MerchantSession> - <UsedAcquirerMerchantID>924518</UsedAcquirerMerchantID> - <TransactionID>0008813023-01</TransactionID> - <RefundAmount>10000</RefundAmount> - <SurchargeAmount/> - <Locale>en</Locale> - <ReturnReceiptNumber>58160420</ReturnReceiptNumber> - <ShoppingTransactionNumber/> - <AcqResponseCode>00</AcqResponseCode> - <QSIResponseCode>0</QSIResponseCode> - <CSCResultCode/> - <AVSResultCode/> - <TransactionTime>2015-06-25 03:23:24</TransactionTime> - <PaystationErrorCode>0</PaystationErrorCode> - <PaystationErrorMessage>Transaction successful</PaystationErrorMessage> - <PaystationExtendedErrorMessage/> - <MerchantReference>Store Purchase</MerchantReference> - <CardNo>512345XXXXXXX346</CardNo> - <CardExpiry>1305</CardExpiry> - <TransactionProcess>refund</TransactionProcess> - <TransactionMode>T</TransactionMode> - <BatchNumber>0625</BatchNumber> - <AuthorizeID/> - <Cardtype>MC</Cardtype> - <Username>609035</Username> - <RequestIP>173.95.131.239</RequestIP> - <RequestUserAgent>Ruby</RequestUserAgent> - <RequestHttpReferrer/> - <PaymentRequestTime>2015-06-25 03:23:24</PaymentRequestTime> - <DigitalOrderTime>2015-06-25 03:23:24</DigitalOrderTime> - <DigitalReceiptTime/> - <PaystationTransactionID/> - <RefundedAmount>10000</RefundedAmount> - <CapturedAmount/> - </PaystationRefundResponse>) - end - - def failed_refund_response - %(<?xml version="1.0" standalone="yes"?> - <FONT FACE="Arial" SIZE="2"><strong>Error 11:</strong> Not enough input parameters.</FONT>) - end - - def pre_scrubbed - 'pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=5123456789012346&pstn_ct=visa&pstn_ex=1305&pstn_cc=123&pstn_tm=T&paystation=_empty' - end - - def post_scrubbed - 'pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=[FILTERED]&pstn_ct=visa&pstn_ex=1305&pstn_cc=[FILTERED]&pstn_tm=T&paystation=_empty' - end + def successful_purchase_response + %(<?xml version="1.0" standalone="yes"?> + <response> + <ec>0</ec> + <em>Transaction successful</em> + <ti>0006713018-01</ti> + <ct>mastercard</ct> + <merchant_ref>Store Purchase</merchant_ref> + <tm>T</tm> + <MerchantSession>1</MerchantSession> + <UsedAcquirerMerchantID>123456</UsedAcquirerMerchantID> + <TransactionID>0008813023-01</TransactionID> + <PurchaseAmount>10000</PurchaseAmount> + <Locale/> + <ReturnReceiptNumber>8813023</ReturnReceiptNumber> + <ShoppingTransactionNumber/> + <AcqResponseCode>00</AcqResponseCode> + <QSIResponseCode>0</QSIResponseCode> + <CSCResultCode/> + <AVSResultCode/> + <TransactionTime>2011-06-22 00:05:52</TransactionTime> + <PaystationErrorCode>0</PaystationErrorCode> + <PaystationErrorMessage>Transaction successful</PaystationErrorMessage> + <MerchantReference>Store Purchase</MerchantReference> + <TransactionMode>T</TransactionMode> + <BatchNumber>0622</BatchNumber> + <AuthorizeID/> + <Cardtype>MC</Cardtype> + <Username>12345</Username> + <RequestIP>192.168.0.1</RequestIP> + <RequestUserAgent/> + <RequestHttpReferrer/> + <PaymentRequestTime>2011-06-22 00:05:52</PaymentRequestTime> + <DigitalOrderTime/> + <DigitalReceiptTime>2011-06-22 00:05:52</DigitalReceiptTime> + <PaystationTransactionID>0008813023-01</PaystationTransactionID> + <IssuerName>unknown</IssuerName> + <IssuerCountry>unknown</IssuerCountry> + </response>) + end + + def failed_purchase_response + %(<?xml version="1.0" standalone="yes"?> + <response> + <ec>5</ec> + <em>Insufficient Funds</em> + <ti>0006713018-01</ti> + <ct>mastercard</ct> + <merchant_ref>Store Purchase</merchant_ref> + <tm>T</tm> + <MerchantSession>1</MerchantSession> + <UsedAcquirerMerchantID>123456</UsedAcquirerMerchantID> + <TransactionID>0008813018-01</TransactionID> + <PurchaseAmount>10051</PurchaseAmount> + <Locale/> + <ReturnReceiptNumber>8813018</ReturnReceiptNumber> + <ShoppingTransactionNumber/> + <AcqResponseCode>51</AcqResponseCode> + <QSIResponseCode>5</QSIResponseCode> + <CSCResultCode/> + <AVSResultCode/> + <TransactionTime>2011-06-22 00:05:46</TransactionTime> + <PaystationErrorCode>5</PaystationErrorCode> + <PaystationErrorMessage>Insufficient Funds</PaystationErrorMessage> + <MerchantReference>Store Purchase</MerchantReference> + <TransactionMode>T</TransactionMode> + <BatchNumber>0622</BatchNumber> + <AuthorizeID/> + <Cardtype>MC</Cardtype> + <Username>123456</Username> + <RequestIP>192.168.0.1</RequestIP> + <RequestUserAgent/> + <RequestHttpReferrer/> + <PaymentRequestTime>2011-06-22 00:05:46</PaymentRequestTime> + <DigitalOrderTime/> + <DigitalReceiptTime>2011-06-22 00:05:46</DigitalReceiptTime> + <PaystationTransactionID>0008813018-01</PaystationTransactionID> + <IssuerName>unknown</IssuerName> + <IssuerCountry>unknown</IssuerCountry> + </response>) + end + + def successful_store_response + %(<?xml version="1.0" standalone="yes"?> + <PaystationFuturePaymentResponse> + <ec>34</ec> + <em>Future Payment Saved Ok</em> + <ti/> + <ct/> + <merchant_ref>Store Purchase</merchant_ref> + <tm>T</tm> + <MerchantSession>3e48fa9a6b0fe36177adf7269db7a3c4</MerchantSession> + <UsedAcquirerMerchantID/> + <TransactionID/> + <PurchaseAmount>0</PurchaseAmount> + <Locale/> + <ReturnReceiptNumber/> + <ShoppingTransactionNumber/> + <AcqResponseCode/> + <QSIResponseCode/> + <CSCResultCode/> + <AVSResultCode/> + <TransactionTime>2011-07-10 13:58:55</TransactionTime> + <PaystationErrorCode>34</PaystationErrorCode> + <PaystationErrorMessage>Future Payment Saved Ok</PaystationErrorMessage> + <MerchantReference>Store Purchase</MerchantReference> + <TransactionMode>T</TransactionMode> + <BatchNumber/> + <AuthorizeID/> + <Cardtype/> + <Username>123456</Username> + <RequestIP>192.168.0.1</RequestIP> + <RequestUserAgent/> + <RequestHttpReferrer/> + <PaymentRequestTime>2011-07-10 13:58:55</PaymentRequestTime> + <DigitalOrderTime/> + <DigitalReceiptTime>2011-07-10 13:58:55</DigitalReceiptTime> + <PaystationTransactionID>0009062177-01</PaystationTransactionID> + <FuturePaymentToken>justatest1310263135</FuturePaymentToken> + <IssuerName>unknown</IssuerName> + <IssuerCountry>unknown</IssuerCountry> + </PaystationFuturePaymentResponse>) + end + + def successful_stored_purchase_response + %(<?xml version="1.0" standalone="yes"?> + <PaystationFuturePaymentResponse> + <ec>0</ec> + <em>Transaction successful</em> + <ti>0006713018-01</ti> + <ct>visa</ct> + <merchant_ref>Store Purchase</merchant_ref> + <tm>T</tm> + <MerchantSession>0fc70a577f19ae63f651f53c7044640a</MerchantSession> + <UsedAcquirerMerchantID>123456</UsedAcquirerMerchantID> + <TransactionID>0009062149-01</TransactionID> + <PurchaseAmount>10000</PurchaseAmount> + <Locale/> + <ReturnReceiptNumber>9062149</ReturnReceiptNumber> + <ShoppingTransactionNumber/> + <AcqResponseCode>00</AcqResponseCode> + <QSIResponseCode>0</QSIResponseCode> + <CSCResultCode/> + <AVSResultCode/> + <TransactionTime>2011-07-10 13:55:00</TransactionTime> + <PaystationErrorCode>0</PaystationErrorCode> + <PaystationErrorMessage>Transaction successful</PaystationErrorMessage> + <MerchantReference>Store Purchase</MerchantReference> + <TransactionMode>T</TransactionMode> + <BatchNumber>0710</BatchNumber> + <AuthorizeID/> + <Cardtype>VC</Cardtype> + <Username>123456</Username> + <RequestIP>192.168.0.1</RequestIP> + <RequestUserAgent/> + <RequestHttpReferrer/> + <PaymentRequestTime>2011-07-10 13:55:00</PaymentRequestTime> + <DigitalOrderTime/> + <DigitalReceiptTime>2011-07-10 13:55:00</DigitalReceiptTime> + <PaystationTransactionID>0009062149-01</PaystationTransactionID> + <FuturePaymentToken>u09fxli14afpnd6022x0z82317beqe9e2w048l9it8286k6lpvz9x27hdal9bl95</FuturePaymentToken> + <IssuerName>unknown</IssuerName> + <IssuerCountry>unknown</IssuerCountry> + </PaystationFuturePaymentResponse>) + end + + def successful_authorization_response + %(<?xml version="1.0" standalone="yes"?> + <response> + <ec>0</ec> + <em>Transaction successful</em> + <ti>0009062250-01</ti> + <ct>visa</ct> + <merchant_ref>Store Purchase</merchant_ref> + <tm>T</tm> + <MerchantSession>b2168af96076522466af4e3d61e5ba0c</MerchantSession> + <UsedAcquirerMerchantID>123456</UsedAcquirerMerchantID> + <TransactionID>0009062250-01</TransactionID> + <PurchaseAmount>10000</PurchaseAmount> + <Locale/> + <ReturnReceiptNumber>9062250</ReturnReceiptNumber> + <ShoppingTransactionNumber/> + <AcqResponseCode>00</AcqResponseCode> + <QSIResponseCode>0</QSIResponseCode> + <CSCResultCode/> + <AVSResultCode/> + <TransactionTime>2011-07-10 14:11:00</TransactionTime> + <PaystationErrorCode>0</PaystationErrorCode> + <PaystationErrorMessage>Transaction successful</PaystationErrorMessage> + <MerchantReference>Store Purchase</MerchantReference> + <TransactionMode>T</TransactionMode> + <BatchNumber>0710</BatchNumber> + <AuthorizeID/> + <Cardtype>VC</Cardtype> + <Username>123456</Username> + <RequestIP>192.168.0.1</RequestIP> + <RequestUserAgent/> + <RequestHttpReferrer/> + <PaymentRequestTime>2011-07-10 14:11:00</PaymentRequestTime> + <DigitalOrderTime/> + <DigitalReceiptTime>2011-07-10 14:11:00</DigitalReceiptTime> + <PaystationTransactionID>0009062250-01</PaystationTransactionID> + <IssuerName>unknown</IssuerName> + <IssuerCountry>unknown</IssuerCountry> + </response>) + end + + def successful_capture_response + %(<?xml version="1.0" standalone="yes"?> + <PaystationCaptureResponse> + <ec>0</ec> + <em>Transaction successful</em> + <ti>0009062289-01</ti> + <ct/> + <merchant_ref>Store Purchase</merchant_ref> + <tm>T</tm> + <MerchantSession>485fdedc81dc83848dd799cd10a869db</MerchantSession> + <UsedAcquirerMerchantID>123456</UsedAcquirerMerchantID> + <TransactionID>0009062289-01</TransactionID> + <CaptureAmount>10000</CaptureAmount> + <Locale/> + <ReturnReceiptNumber>9062289</ReturnReceiptNumber> + <ShoppingTransactionNumber/> + <AcqResponseCode>00</AcqResponseCode> + <QSIResponseCode>0</QSIResponseCode> + <CSCResultCode/> + <AVSResultCode/> + <TransactionTime>2011-07-10 14:17:36</TransactionTime> + <PaystationErrorCode>0</PaystationErrorCode> + <PaystationErrorMessage>Transaction successful</PaystationErrorMessage> + <MerchantReference>Store Purchase</MerchantReference> + <TransactionMode>T</TransactionMode> + <BatchNumber>0710</BatchNumber> + <AuthorizeID/> + <Cardtype/> + <Username>123456</Username> + <RequestIP>192.168.0.1</RequestIP> + <RequestUserAgent/> + <RequestHttpReferrer/> + <PaymentRequestTime>2011-07-10 14:17:36</PaymentRequestTime> + <DigitalOrderTime>2011-07-10 14:17:36</DigitalOrderTime> + <DigitalReceiptTime>2011-07-10 14:17:36</DigitalReceiptTime> + <PaystationTransactionID/> + <RefundedAmount/> + <CapturedAmount>10000</CapturedAmount> + <AuthorisedAmount/> + </PaystationCaptureResponse>) + end + + def successful_refund_response + %(<?xml version="1.0" standalone="yes"?> + <PaystationRefundResponse> + <ec>0</ec> + <em>Transaction successful</em> + <ti>0008813023-01</ti> + <ct>mastercard</ct> + <merchant_ref>Store Purchase</merchant_ref> + <tm>T</tm> + <MerchantSession>70ceae1b3f069e41ca7f4350a1180cb1</MerchantSession> + <UsedAcquirerMerchantID>924518</UsedAcquirerMerchantID> + <TransactionID>0008813023-01</TransactionID> + <RefundAmount>10000</RefundAmount> + <SurchargeAmount/> + <Locale>en</Locale> + <ReturnReceiptNumber>58160420</ReturnReceiptNumber> + <ShoppingTransactionNumber/> + <AcqResponseCode>00</AcqResponseCode> + <QSIResponseCode>0</QSIResponseCode> + <CSCResultCode/> + <AVSResultCode/> + <TransactionTime>2015-06-25 03:23:24</TransactionTime> + <PaystationErrorCode>0</PaystationErrorCode> + <PaystationErrorMessage>Transaction successful</PaystationErrorMessage> + <PaystationExtendedErrorMessage/> + <MerchantReference>Store Purchase</MerchantReference> + <CardNo>512345XXXXXXX346</CardNo> + <CardExpiry>1305</CardExpiry> + <TransactionProcess>refund</TransactionProcess> + <TransactionMode>T</TransactionMode> + <BatchNumber>0625</BatchNumber> + <AuthorizeID/> + <Cardtype>MC</Cardtype> + <Username>609035</Username> + <RequestIP>173.95.131.239</RequestIP> + <RequestUserAgent>Ruby</RequestUserAgent> + <RequestHttpReferrer/> + <PaymentRequestTime>2015-06-25 03:23:24</PaymentRequestTime> + <DigitalOrderTime>2015-06-25 03:23:24</DigitalOrderTime> + <DigitalReceiptTime/> + <PaystationTransactionID/> + <RefundedAmount>10000</RefundedAmount> + <CapturedAmount/> + </PaystationRefundResponse>) + end + + def failed_refund_response + %(<?xml version="1.0" standalone="yes"?> + <FONT FACE="Arial" SIZE="2"><strong>Error 11:</strong> Not enough input parameters.</FONT>) + end + + def pre_scrubbed + 'pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=5123456789012346&pstn_ct=visa&pstn_ex=1305&pstn_cc=123&pstn_tm=T&paystation=_empty' + end + + def post_scrubbed + 'pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=[FILTERED]&pstn_ct=visa&pstn_ex=1305&pstn_cc=[FILTERED]&pstn_tm=T&paystation=_empty' + end end diff --git a/test/unit/gateways/payway_test.rb b/test/unit/gateways/payway_test.rb index d72f7a849b0..42a1aa25321 100644 --- a/test/unit/gateways/payway_test.rb +++ b/test/unit/gateways/payway_test.rb @@ -219,40 +219,40 @@ def test_store private - def successful_response_store - 'response.responseCode=00' - end + def successful_response_store + 'response.responseCode=00' + end - def successful_response_visa - 'response.summaryCode=0&response.responseCode=08&response.cardSchemeName=VISA' - end + def successful_response_visa + 'response.summaryCode=0&response.responseCode=08&response.cardSchemeName=VISA' + end - def successful_response_master_card - 'response.summaryCode=0&response.responseCode=08&response.cardSchemeName=MASTERCARD' - end + def successful_response_master_card + 'response.summaryCode=0&response.responseCode=08&response.cardSchemeName=MASTERCARD' + end - def purchase_with_invalid_credit_card_response - 'response.summaryCode=1&response.responseCode=14' - end + def purchase_with_invalid_credit_card_response + 'response.summaryCode=1&response.responseCode=14' + end - def purchase_with_expired_credit_card_response - 'response.summaryCode=1&response.responseCode=54' - end + def purchase_with_expired_credit_card_response + 'response.summaryCode=1&response.responseCode=54' + end - def purchase_with_invalid_month_response - 'response.summaryCode=3&response.responseCode=QA' - end + def purchase_with_invalid_month_response + 'response.summaryCode=3&response.responseCode=QA' + end - def bad_login_response - 'response.summaryCode=3&response.responseCode=QH' - end + def bad_login_response + 'response.summaryCode=3&response.responseCode=QH' + end - def bad_merchant_response - 'response.summaryCode=3&response.responseCode=QK' - end + def bad_merchant_response + 'response.summaryCode=3&response.responseCode=QK' + end - def certificate - '------BEGIN CERTIFICATE----- + def certificate + '------BEGIN CERTIFICATE----- -MIIDeDCCAmCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDApjb2R5 -ZmF1c2VyMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNj -b20wHhcNMTMxMTEzMTk1NjE2WhcNMTQxMTEzMTk1NjE2WjBBMRMwEQYDVQQDDApj @@ -273,5 +273,5 @@ def certificate -ZJB9YPQZG+vWBdDSca3sUMtvFxpLUFwdKF5APSPOVnhbFJ3vSXY1ulP/R6XW9vnw -6kkQi2fHhU20ugMzp881Eixr+TjC0RvUerLG7g== ------END CERTIFICATE-----' - end + end end diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index cc4eee1f918..031deef53ff 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -9,9 +9,9 @@ def setup :password => 'testpassword' ) - @amount = 100 - @credit_card = credit_card('4242424242424242') - @options = {:order_id => 1} + @amount = 100 + @credit_card = credit_card('4242424242424242') + @options = {:order_id => 1} end def test_successful_authorize From 08d023ee2403629ff44ad8bb9379324a7ab29fdf Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 27 Nov 2018 11:08:49 -0500 Subject: [PATCH 659/677] RuboCop: fix Layout/IndentationWidth --- .rubocop_todo.yml | 6 - .../billing/gateways/authorize_net.rb | 30 ++--- .../billing/gateways/authorize_net_cim.rb | 66 +++++----- .../billing/gateways/cardknox.rb | 4 +- .../billing/gateways/eway_managed.rb | 10 +- lib/active_merchant/billing/gateways/exact.rb | 20 +-- .../billing/gateways/merchant_one.rb | 6 +- .../billing/gateways/merchant_ware.rb | 8 +- .../billing/gateways/mundipagg.rb | 2 +- lib/active_merchant/billing/gateways/ogone.rb | 4 +- lib/active_merchant/billing/gateways/omise.rb | 10 +- lib/active_merchant/billing/gateways/opp.rb | 2 +- .../billing/gateways/paymill.rb | 10 +- .../billing/gateways/paypal.rb | 2 +- .../billing/gateways/payu_latam.rb | 2 +- .../billing/gateways/quickbooks.rb | 4 +- .../billing/gateways/quickpay/quickpay_v10.rb | 2 +- lib/active_merchant/billing/gateways/sage.rb | 22 ++-- .../billing/gateways/sage_pay.rb | 10 +- .../billing/gateways/wirecard.rb | 10 +- .../gateways/remote_first_giving_test.rb | 8 +- .../gateways/remote_merchant_one_test.rb | 4 +- test/remote/gateways/remote_netaxept_test.rb | 94 +++++++------- .../remote/gateways/remote_payflow_uk_test.rb | 10 +- .../remote_usa_epay_transaction_test.rb | 8 +- test/unit/gateways/bpoint_test.rb | 34 ++--- test/unit/gateways/card_stream_test.rb | 2 +- test/unit/gateways/cardknox_test.rb | 8 +- test/unit/gateways/elavon_test.rb | 2 +- test/unit/gateways/eway_test.rb | 8 +- test/unit/gateways/gateway_test.rb | 8 +- test/unit/gateways/hps_test.rb | 2 +- test/unit/gateways/metrics_global_test.rb | 8 +- test/unit/gateways/moneris_test.rb | 72 +++++------ test/unit/gateways/moneris_us_test.rb | 72 +++++------ test/unit/gateways/netbanx_test.rb | 14 +- test/unit/gateways/omise_test.rb | 4 +- test/unit/gateways/opp_test.rb | 4 +- test/unit/gateways/orbital_test.rb | 16 +-- test/unit/gateways/pagarme_test.rb | 18 +-- test/unit/gateways/payflow_test.rb | 4 +- .../gateways/paypal/paypal_common_api_test.rb | 2 +- .../gateways/paypal_digital_goods_test.rb | 120 +++++++++--------- test/unit/gateways/paypal_express_test.rb | 2 +- test/unit/gateways/trust_commerce_test.rb | 8 +- .../gateways/usa_epay_transaction_test.rb | 8 +- test/unit/gateways/verifi_test.rb | 2 +- test/unit/gateways/visanet_peru_test.rb | 2 +- test/unit/gateways/worldpay_test.rb | 14 +- 49 files changed, 391 insertions(+), 397 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 08a3231d05a..b8025e1f862 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -74,12 +74,6 @@ Layout/IndentHash: Layout/IndentHeredoc: Enabled: false -# Offense count: 193 -# Cop supports --auto-correct. -# Configuration parameters: Width, IgnoredPatterns. -Layout/IndentationWidth: - Enabled: false - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index 738bc90a586..a0240cc25ed 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -837,7 +837,7 @@ def parse_normal(action, body) response = {action: action} response[:response_code] = if(element = doc.at_xpath('//transactionResponse/responseCode')) - (empty?(element.content) ? nil : element.content.to_i) + (empty?(element.content) ? nil : element.content.to_i) end if(element = doc.at_xpath('//errors/error')) @@ -855,35 +855,35 @@ def parse_normal(action, body) end response[:avs_result_code] = if(element = doc.at_xpath('//avsResultCode')) - (empty?(element.content) ? nil : element.content) + (empty?(element.content) ? nil : element.content) end response[:transaction_id] = if(element = doc.at_xpath('//transId')) - (empty?(element.content) ? nil : element.content) + (empty?(element.content) ? nil : element.content) end response[:card_code] = if(element = doc.at_xpath('//cvvResultCode')) - (empty?(element.content) ? nil : element.content) + (empty?(element.content) ? nil : element.content) end response[:authorization_code] = if(element = doc.at_xpath('//authCode')) - (empty?(element.content) ? nil : element.content) + (empty?(element.content) ? nil : element.content) end response[:cardholder_authentication_code] = if(element = doc.at_xpath('//cavvResultCode')) - (empty?(element.content) ? nil : element.content) + (empty?(element.content) ? nil : element.content) end response[:account_number] = if(element = doc.at_xpath('//accountNumber')) - (empty?(element.content) ? nil : element.content[-4..-1]) + (empty?(element.content) ? nil : element.content[-4..-1]) end response[:test_request] = if(element = doc.at_xpath('//testRequest')) - (empty?(element.content) ? nil : element.content) + (empty?(element.content) ? nil : element.content) end response[:full_response_code] = if(element = doc.at_xpath('//messages/message/code')) - (empty?(element.content) ? nil : element.content) + (empty?(element.content) ? nil : element.content) end response @@ -900,28 +900,28 @@ def parse_cim(body, options) end response[:result_code] = if(element = doc.at_xpath('//messages/resultCode')) - (empty?(element.content) ? nil : element.content) + (empty?(element.content) ? nil : element.content) end response[:test_request] = if(element = doc.at_xpath('//testRequest')) - (empty?(element.content) ? nil : element.content) + (empty?(element.content) ? nil : element.content) end response[:customer_profile_id] = if(element = doc.at_xpath('//customerProfileId')) - (empty?(element.content) ? nil : element.content) + (empty?(element.content) ? nil : element.content) end response[:customer_payment_profile_id] = if(element = doc.at_xpath('//customerPaymentProfileIdList/numericString')) - (empty?(element.content) ? nil : element.content) + (empty?(element.content) ? nil : element.content) end response[:customer_payment_profile_id] = if(element = doc.at_xpath('//customerPaymentProfileIdList/numericString') || doc.at_xpath('//customerPaymentProfileId')) - (empty?(element.content) ? nil : element.content) + (empty?(element.content) ? nil : element.content) end response[:direct_response] = if(element = doc.at_xpath('//directResponse')) - (empty?(element.content) ? nil : element.content) + (empty?(element.content) ? nil : element.content) end response.merge!(parse_direct_response_elements(response, options)) diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb index 0ca1ec4d7a0..fac2913ff37 100644 --- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb +++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb @@ -380,18 +380,18 @@ def create_customer_profile_transaction(options) requires!(options[:transaction], :type) case options[:transaction][:type] when :void - requires!(options[:transaction], :trans_id) + requires!(options[:transaction], :trans_id) when :refund - requires!(options[:transaction], :trans_id) && - ( - (options[:transaction][:customer_profile_id] && options[:transaction][:customer_payment_profile_id]) || - options[:transaction][:credit_card_number_masked] || - (options[:transaction][:bank_routing_number_masked] && options[:transaction][:bank_account_number_masked]) - ) + requires!(options[:transaction], :trans_id) && + ( + (options[:transaction][:customer_profile_id] && options[:transaction][:customer_payment_profile_id]) || + options[:transaction][:credit_card_number_masked] || + (options[:transaction][:bank_routing_number_masked] && options[:transaction][:bank_account_number_masked]) + ) when :prior_auth_capture - requires!(options[:transaction], :amount, :trans_id) + requires!(options[:transaction], :amount, :trans_id) else - requires!(options[:transaction], :amount, :customer_profile_id, :customer_payment_profile_id) + requires!(options[:transaction], :amount, :customer_profile_id, :customer_payment_profile_id) end request = build_request(:create_customer_profile_transaction, options) commit(:create_customer_profile_transaction, request) @@ -666,33 +666,33 @@ def add_transaction(xml, transaction) # The amount to be billed to the customer case transaction[:type] when :void - tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id]) - tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id]) - tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id]) - xml.tag!('transId', transaction[:trans_id]) + tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id]) + tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id]) + tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id]) + xml.tag!('transId', transaction[:trans_id]) when :refund - xml.tag!('amount', transaction[:amount]) - tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id]) - tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id]) - tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id]) - tag_unless_blank(xml, 'creditCardNumberMasked', transaction[:credit_card_number_masked]) - tag_unless_blank(xml, 'bankRoutingNumberMasked', transaction[:bank_routing_number_masked]) - tag_unless_blank(xml, 'bankAccountNumberMasked', transaction[:bank_account_number_masked]) - add_order(xml, transaction[:order]) if transaction[:order].present? - xml.tag!('transId', transaction[:trans_id]) - add_tax(xml, transaction[:tax]) if transaction[:tax] - add_duty(xml, transaction[:duty]) if transaction[:duty] - add_shipping(xml, transaction[:shipping]) if transaction[:shipping] + xml.tag!('amount', transaction[:amount]) + tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id]) + tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id]) + tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id]) + tag_unless_blank(xml, 'creditCardNumberMasked', transaction[:credit_card_number_masked]) + tag_unless_blank(xml, 'bankRoutingNumberMasked', transaction[:bank_routing_number_masked]) + tag_unless_blank(xml, 'bankAccountNumberMasked', transaction[:bank_account_number_masked]) + add_order(xml, transaction[:order]) if transaction[:order].present? + xml.tag!('transId', transaction[:trans_id]) + add_tax(xml, transaction[:tax]) if transaction[:tax] + add_duty(xml, transaction[:duty]) if transaction[:duty] + add_shipping(xml, transaction[:shipping]) if transaction[:shipping] when :prior_auth_capture - xml.tag!('amount', transaction[:amount]) - add_order(xml, transaction[:order]) if transaction[:order].present? - xml.tag!('transId', transaction[:trans_id]) + xml.tag!('amount', transaction[:amount]) + add_order(xml, transaction[:order]) if transaction[:order].present? + xml.tag!('transId', transaction[:trans_id]) else - xml.tag!('amount', transaction[:amount]) - xml.tag!('customerProfileId', transaction[:customer_profile_id]) - xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id]) - xml.tag!('approvalCode', transaction[:approval_code]) if transaction[:type] == :capture_only - add_order(xml, transaction[:order]) if transaction[:order].present? + xml.tag!('amount', transaction[:amount]) + xml.tag!('customerProfileId', transaction[:customer_profile_id]) + xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id]) + xml.tag!('approvalCode', transaction[:approval_code]) if transaction[:type] == :capture_only + add_order(xml, transaction[:order]) if transaction[:order].present? end if [:auth_capture, :auth_only, :capture_only].include?(transaction[:type]) diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb index e4dd63bba30..938e6ade478 100644 --- a/lib/active_merchant/billing/gateways/cardknox.rb +++ b/lib/active_merchant/billing/gateways/cardknox.rb @@ -81,8 +81,8 @@ def void(authorization, options = {}) def verify(credit_card, options={}) MultiResponse.run(:use_first_response) do |r| - r.process { authorize(100, credit_card, options) } - r.process(:ignore_result) { void(r.authorization, options) } + r.process { authorize(100, credit_card, options) } + r.process(:ignore_result) { void(r.authorization, options) } end end diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb index 9c6101d45e4..fcdd34afbd4 100644 --- a/lib/active_merchant/billing/gateways/eway_managed.rb +++ b/lib/active_merchant/billing/gateways/eway_managed.rb @@ -150,7 +150,7 @@ def parse(body) reply = {} xml = REXML::Document.new(body) if root = REXML::XPath.first(xml, '//soap:Fault') then - reply=parse_fault(root) + reply=parse_fault(root) else if root = REXML::XPath.first(xml, '//ProcessPaymentResponse/ewayResponse') then # Successful payment @@ -232,13 +232,13 @@ def soap_request(arguments, action) # eWay demands all fields be sent, but contain an empty string if blank post = case action when 'QueryCustomer' - arguments + arguments when 'ProcessPayment' - default_payment_fields.merge(arguments) + default_payment_fields.merge(arguments) when 'CreateCustomer' - default_customer_fields.merge(arguments) + default_customer_fields.merge(arguments) when 'UpdateCustomer' - default_customer_fields.merge(arguments) + default_customer_fields.merge(arguments) end xml = Builder::XmlMarkup.new :indent => 2 diff --git a/lib/active_merchant/billing/gateways/exact.rb b/lib/active_merchant/billing/gateways/exact.rb index 06f31316e66..d9649b84e21 100644 --- a/lib/active_merchant/billing/gateways/exact.rb +++ b/lib/active_merchant/billing/gateways/exact.rb @@ -160,14 +160,14 @@ def expdate(credit_card) end def commit(action, request) - response = parse(ssl_post(self.live_url, build_request(action, request), POST_HEADERS)) - - Response.new(successful?(response), message_from(response), response, - :test => test?, - :authorization => authorization_from(response), - :avs_result => { :code => response[:avs] }, - :cvv_result => response[:cvv2] - ) + response = parse(ssl_post(self.live_url, build_request(action, request), POST_HEADERS)) + + Response.new(successful?(response), message_from(response), response, + :test => test?, + :authorization => authorization_from(response), + :avs_result => { :code => response[:avs] }, + :cvv_result => response[:cvv2] + ) rescue ResponseError => e case e.response.code when '401' @@ -183,9 +183,9 @@ def successful?(response) def authorization_from(response) if response[:authorization_num] && response[:transaction_tag] - "#{response[:authorization_num]};#{response[:transaction_tag]}" + "#{response[:authorization_num]};#{response[:transaction_tag]}" else - '' + '' end end diff --git a/lib/active_merchant/billing/gateways/merchant_one.rb b/lib/active_merchant/billing/gateways/merchant_one.rb index f2b081c2074..20f60dd0cd2 100644 --- a/lib/active_merchant/billing/gateways/merchant_one.rb +++ b/lib/active_merchant/billing/gateways/merchant_one.rb @@ -75,9 +75,9 @@ def add_address(post, creditcard, options) end def add_creditcard(post, creditcard) - post['cvv'] = creditcard.verification_value - post['ccnumber'] = creditcard.number - post['ccexp'] = "#{sprintf("%02d", creditcard.month)}#{creditcard.year.to_s[-2, 2]}" + post['cvv'] = creditcard.verification_value + post['ccnumber'] = creditcard.number + post['ccexp'] = "#{sprintf("%02d", creditcard.month)}#{creditcard.year.to_s[-2, 2]}" end def commit(action, money, parameters={}) diff --git a/lib/active_merchant/billing/gateways/merchant_ware.rb b/lib/active_merchant/billing/gateways/merchant_ware.rb index a6d73a2130c..d028024ccb0 100644 --- a/lib/active_merchant/billing/gateways/merchant_ware.rb +++ b/lib/active_merchant/billing/gateways/merchant_ware.rb @@ -226,10 +226,10 @@ def add_credit_card(xml, credit_card) if credit_card.respond_to?(:track_data) && credit_card.track_data.present? xml.tag! 'trackData', credit_card.track_data else - xml.tag! 'strPAN', credit_card.number - xml.tag! 'strExpDate', expdate(credit_card) - xml.tag! 'strCardHolder', credit_card.name - xml.tag! 'strCVCode', credit_card.verification_value if credit_card.verification_value? + xml.tag! 'strPAN', credit_card.number + xml.tag! 'strExpDate', expdate(credit_card) + xml.tag! 'strCardHolder', credit_card.name + xml.tag! 'strCVCode', credit_card.verification_value if credit_card.verification_value? end end diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb index cb23e8e6235..aeac34ebe11 100644 --- a/lib/active_merchant/billing/gateways/mundipagg.rb +++ b/lib/active_merchant/billing/gateways/mundipagg.rb @@ -224,7 +224,7 @@ def url_for(action, auth = nil) when 'capture' "#{url}/charges/#{auth}/capture/" else - "#{url}/charges/" + "#{url}/charges/" end end diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb index 5d6041c887f..883ac94a05a 100644 --- a/lib/active_merchant/billing/gateways/ogone.rb +++ b/lib/active_merchant/billing/gateways/ogone.rb @@ -408,8 +408,8 @@ def post_data(action, parameters = {}) def add_signature(parameters) if @options[:signature].blank? - ActiveMerchant.deprecated(OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE) unless(@options[:signature_encryptor] == 'none') - return + ActiveMerchant.deprecated(OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE) unless(@options[:signature_encryptor] == 'none') + return end add_pair parameters, 'SHASign', calculate_signature(parameters, @options[:signature_encryptor], @options[:signature]) diff --git a/lib/active_merchant/billing/gateways/omise.rb b/lib/active_merchant/billing/gateways/omise.rb index fbb1af839ab..218b099590f 100644 --- a/lib/active_merchant/billing/gateways/omise.rb +++ b/lib/active_merchant/billing/gateways/omise.rb @@ -247,15 +247,15 @@ def message_to_standard_error_code_from(response) message = response['message'] if response['code'] == 'invalid_card' case message when /brand not supported/ - STANDARD_ERROR_CODE[:invalid_number] + STANDARD_ERROR_CODE[:invalid_number] when /number is invalid/ - STANDARD_ERROR_CODE[:incorrect_number] + STANDARD_ERROR_CODE[:incorrect_number] when /expiration date cannot be in the past/ - STANDARD_ERROR_CODE[:expired_card] + STANDARD_ERROR_CODE[:expired_card] when /expiration \w+ is invalid/ - STANDARD_ERROR_CODE[:invalid_expiry_date] + STANDARD_ERROR_CODE[:invalid_expiry_date] else - STANDARD_ERROR_CODE[:processing_error] + STANDARD_ERROR_CODE[:processing_error] end end diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb index 03f6e92286e..8c82574a670 100644 --- a/lib/active_merchant/billing/gateways/opp.rb +++ b/lib/active_merchant/billing/gateways/opp.rb @@ -189,7 +189,7 @@ def execute_referencing(txtype, money, authorization, options) end def add_authentication(post) - post[:authentication] = { entityId: @options[:entity_id], password: @options[:password], userId: @options[:user_id]} + post[:authentication] = { entityId: @options[:entity_id], password: @options[:password], userId: @options[:user_id]} end def add_customer_data(post, payment, options) diff --git a/lib/active_merchant/billing/gateways/paymill.rb b/lib/active_merchant/billing/gateways/paymill.rb index 01b4cd9ebfb..caf64486d8b 100644 --- a/lib/active_merchant/billing/gateways/paymill.rb +++ b/lib/active_merchant/billing/gateways/paymill.rb @@ -129,12 +129,12 @@ def action_with_token(action, money, payment_method, options) options[:money] = money case payment_method when String - self.send("#{action}_with_token", money, payment_method, options) + self.send("#{action}_with_token", money, payment_method, options) else - MultiResponse.run do |r| - r.process { save_card(payment_method, options) } - r.process { self.send("#{action}_with_token", money, r.authorization, options) } - end + MultiResponse.run do |r| + r.process { save_card(payment_method, options) } + r.process { self.send("#{action}_with_token", money, r.authorization, options) } + end end end diff --git a/lib/active_merchant/billing/gateways/paypal.rb b/lib/active_merchant/billing/gateways/paypal.rb index 74769690810..465a0dd2b24 100644 --- a/lib/active_merchant/billing/gateways/paypal.rb +++ b/lib/active_merchant/billing/gateways/paypal.rb @@ -108,7 +108,7 @@ def credit_card_type(type) end def build_response(success, message, response, options = {}) - Response.new(success, message, response, options) + Response.new(success, message, response, options) end end end diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb index 9c73136aca2..1d2b995b083 100644 --- a/lib/active_merchant/billing/gateways/payu_latam.rb +++ b/lib/active_merchant/billing/gateways/payu_latam.rb @@ -365,7 +365,7 @@ def success_from(action, response) when 'verify_credentials' response['code'] == 'SUCCESS' when 'refund', 'void' - response['code'] == 'SUCCESS' && response['transactionResponse'] && (response['transactionResponse']['state'] == 'PENDING' || response['transactionResponse']['state'] == 'APPROVED') + response['code'] == 'SUCCESS' && response['transactionResponse'] && (response['transactionResponse']['state'] == 'PENDING' || response['transactionResponse']['state'] == 'APPROVED') else response['code'] == 'SUCCESS' && response['transactionResponse'] && (response['transactionResponse']['state'] == 'APPROVED') end diff --git a/lib/active_merchant/billing/gateways/quickbooks.rb b/lib/active_merchant/billing/gateways/quickbooks.rb index 1f73575bdab..6759a57aee6 100644 --- a/lib/active_merchant/billing/gateways/quickbooks.rb +++ b/lib/active_merchant/billing/gateways/quickbooks.rb @@ -252,9 +252,9 @@ def cvv_code_from(response) end def success?(response) - return FRAUD_WARNING_CODES.concat(['0']).include?(response['errors'].first['code']) if response['errors'] + return FRAUD_WARNING_CODES.concat(['0']).include?(response['errors'].first['code']) if response['errors'] - !['DECLINED', 'CANCELLED'].include?(response['status']) + !['DECLINED', 'CANCELLED'].include?(response['status']) end def message_from(response) diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb index 971c703d528..e1b00768287 100644 --- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb @@ -163,7 +163,7 @@ def authorization_from(response) if response['token'] response['token'].to_s else - response['id'].to_s + response['id'].to_s end end diff --git a/lib/active_merchant/billing/gateways/sage.rb b/lib/active_merchant/billing/gateways/sage.rb index 52bb573c93e..3f3c9a96bcf 100644 --- a/lib/active_merchant/billing/gateways/sage.rb +++ b/lib/active_merchant/billing/gateways/sage.rb @@ -97,17 +97,17 @@ def supports_scrubbing? end def scrub(transcript) - force_utf8(transcript). - gsub(%r((M_id=)[^&]*), '\1[FILTERED]'). - gsub(%r((M_key=)[^&]*), '\1[FILTERED]'). - gsub(%r((C_cardnumber=)[^&]*), '\1[FILTERED]'). - gsub(%r((C_cvv=)[^&]*), '\1[FILTERED]'). - gsub(%r((C_rte=)[^&]*), '\1[FILTERED]'). - gsub(%r((C_acct=)[^&]*), '\1[FILTERED]'). - gsub(%r((C_ssn=)[^&]*), '\1[FILTERED]'). - gsub(%r((<ns1:CARDNUMBER>).+(</ns1:CARDNUMBER>)), '\1[FILTERED]\2'). - gsub(%r((<ns1:M_ID>).+(</ns1:M_ID>)), '\1[FILTERED]\2'). - gsub(%r((<ns1:M_KEY>).+(</ns1:M_KEY>)), '\1[FILTERED]\2') + force_utf8(transcript). + gsub(%r((M_id=)[^&]*), '\1[FILTERED]'). + gsub(%r((M_key=)[^&]*), '\1[FILTERED]'). + gsub(%r((C_cardnumber=)[^&]*), '\1[FILTERED]'). + gsub(%r((C_cvv=)[^&]*), '\1[FILTERED]'). + gsub(%r((C_rte=)[^&]*), '\1[FILTERED]'). + gsub(%r((C_acct=)[^&]*), '\1[FILTERED]'). + gsub(%r((C_ssn=)[^&]*), '\1[FILTERED]'). + gsub(%r((<ns1:CARDNUMBER>).+(</ns1:CARDNUMBER>)), '\1[FILTERED]\2'). + gsub(%r((<ns1:M_ID>).+(</ns1:M_ID>)), '\1[FILTERED]\2'). + gsub(%r((<ns1:M_KEY>).+(</ns1:M_KEY>)), '\1[FILTERED]\2') end private diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb index 449d7306580..a3cd5f7b657 100644 --- a/lib/active_merchant/billing/gateways/sage_pay.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -361,11 +361,11 @@ def authorization_from(response, params, action) when :store response['Token'] else - [ params[:VendorTxCode], - response['VPSTxId'] || params[:VPSTxId], - response['TxAuthNo'], - response['SecurityKey'] || params[:SecurityKey], - action ].join(';') + [ params[:VendorTxCode], + response['VPSTxId'] || params[:VPSTxId], + response['TxAuthNo'], + response['SecurityKey'] || params[:SecurityKey], + action ].join(';') end end diff --git a/lib/active_merchant/billing/gateways/wirecard.rb b/lib/active_merchant/billing/gateways/wirecard.rb index 71134e66e2a..21218896b6a 100644 --- a/lib/active_merchant/billing/gateways/wirecard.rb +++ b/lib/active_merchant/billing/gateways/wirecard.rb @@ -202,11 +202,11 @@ def build_request(action, money, options) xml.tag! 'WIRECARD_BXML' do xml.tag! 'W_REQUEST' do xml.tag! 'W_JOB' do - xml.tag! 'JobID', '' - # UserID for this transaction - xml.tag! 'BusinessCaseSignature', options[:signature] || options[:login] - # Create the whole rest of the message - add_transaction_data(xml, money, options) + xml.tag! 'JobID', '' + # UserID for this transaction + xml.tag! 'BusinessCaseSignature', options[:signature] || options[:login] + # Create the whole rest of the message + add_transaction_data(xml, money, options) end end end diff --git a/test/remote/gateways/remote_first_giving_test.rb b/test/remote/gateways/remote_first_giving_test.rb index 9c689eb81c1..aa37014c925 100644 --- a/test/remote/gateways/remote_first_giving_test.rb +++ b/test/remote/gateways/remote_first_giving_test.rb @@ -32,11 +32,11 @@ def test_failed_purchase end def test_successful_refund - assert purchase = @gateway.purchase(@amount, @credit_card, @options) - assert_success purchase + assert purchase = @gateway.purchase(@amount, @credit_card, @options) + assert_success purchase - assert response = @gateway.refund(@amount, purchase.authorization) - assert_equal 'REFUND_REQUESTED_AWAITING_REFUND', response.message + assert response = @gateway.refund(@amount, purchase.authorization) + assert_equal 'REFUND_REQUESTED_AWAITING_REFUND', response.message end def test_failed_refund diff --git a/test/remote/gateways/remote_merchant_one_test.rb b/test/remote/gateways/remote_merchant_one_test.rb index 2e8969dadc9..0e4f98fb23e 100644 --- a/test/remote/gateways/remote_merchant_one_test.rb +++ b/test/remote/gateways/remote_merchant_one_test.rb @@ -48,8 +48,8 @@ def test_authorize_and_capture end def test_failed_capture - assert response = @gateway.capture(@amount, '') - assert_failure response + assert response = @gateway.capture(@amount, '') + assert_failure response end def test_invalid_login diff --git a/test/remote/gateways/remote_netaxept_test.rb b/test/remote/gateways/remote_netaxept_test.rb index 6112d9798c9..0ae763f5876 100644 --- a/test/remote/gateways/remote_netaxept_test.rb +++ b/test/remote/gateways/remote_netaxept_test.rb @@ -20,24 +20,24 @@ def test_successful_purchase end def test_failed_purchase - assert response = @gateway.purchase(@amount, @declined_card, @options) - assert_failure response - assert_match(/failure/i, response.message) + assert response = @gateway.purchase(@amount, @declined_card, @options) + assert_failure response + assert_match(/failure/i, response.message) end def test_authorize_and_capture - assert auth = @gateway.authorize(@amount, @credit_card, @options) - assert_success auth - assert_equal 'OK', auth.message - assert auth.authorization - assert capture = @gateway.capture(@amount, auth.authorization) - assert_success capture + assert auth = @gateway.authorize(@amount, @credit_card, @options) + assert_success auth + assert_equal 'OK', auth.message + assert auth.authorization + assert capture = @gateway.capture(@amount, auth.authorization) + assert_success capture end def test_failed_capture - assert response = @gateway.capture(@amount, '') - assert_failure response - assert_equal 'Unable to find transaction', response.message + assert response = @gateway.capture(@amount, '') + assert_failure response + assert_equal 'Unable to find transaction', response.message end def test_successful_refund @@ -49,12 +49,12 @@ def test_successful_refund end def test_failed_refund - assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_success response + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response - response = @gateway.refund(@amount+100, response.authorization) - assert_failure response - assert_equal 'Unable to credit more than captured amount', response.message + response = @gateway.refund(@amount+100, response.authorization) + assert_failure response + assert_equal 'Unable to credit more than captured amount', response.message end def test_successful_void @@ -66,46 +66,46 @@ def test_successful_void end def test_failed_void - assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_success response + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response - response = @gateway.void(response.authorization) - assert_failure response - assert_equal 'Unable to annul, wrong state', response.message + response = @gateway.void(response.authorization) + assert_failure response + assert_equal 'Unable to annul, wrong state', response.message end def test_error_in_transaction_setup - assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:currency => 'BOGG')) - assert_failure response - assert_match(/currency code/, response.message) + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:currency => 'BOGG')) + assert_failure response + assert_match(/currency code/, response.message) end def test_successful_amex_purchase - credit_card = credit_card('378282246310005', :brand => 'american_express') - assert response = @gateway.purchase(@amount, credit_card, @options) - assert_success response - assert_equal 'OK', response.message + credit_card = credit_card('378282246310005', :brand => 'american_express') + assert response = @gateway.purchase(@amount, credit_card, @options) + assert_success response + assert_equal 'OK', response.message end def test_successful_master_purchase - credit_card = credit_card('5413000000000000', :brand => 'master') - assert response = @gateway.purchase(@amount, credit_card, @options) - assert_success response - assert_equal 'OK', response.message + credit_card = credit_card('5413000000000000', :brand => 'master') + assert response = @gateway.purchase(@amount, credit_card, @options) + assert_success response + assert_equal 'OK', response.message end def test_error_in_payment_details - assert response = @gateway.purchase(@amount, credit_card(''), @options) - assert_failure response - assert_equal 'Cardnumber:Required', response.message + assert response = @gateway.purchase(@amount, credit_card(''), @options) + assert_failure response + assert_equal 'Cardnumber:Required', response.message end def test_amount_is_not_required_again_when_capturing_authorization - assert response = @gateway.authorize(@amount, @credit_card, @options) - assert_success response + assert response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response - assert response = @gateway.capture(nil, response.authorization) - assert_equal 'OK', response.message + assert response = @gateway.capture(nil, response.authorization) + assert_equal 'OK', response.message end def test_query_fails @@ -115,12 +115,12 @@ def test_query_fails end def test_invalid_login - gateway = NetaxeptGateway.new( - :login => '', - :password => '' - ) - assert response = gateway.purchase(@amount, @credit_card, @options) - assert_failure response - assert_match(/Unable to authenticate merchant/, response.message) + gateway = NetaxeptGateway.new( + :login => '', + :password => '' + ) + assert response = gateway.purchase(@amount, @credit_card, @options) + assert_failure response + assert_match(/Unable to authenticate merchant/, response.message) end end diff --git a/test/remote/gateways/remote_payflow_uk_test.rb b/test/remote/gateways/remote_payflow_uk_test.rb index 5a5df22e94a..afe6791cfc8 100644 --- a/test/remote/gateways/remote_payflow_uk_test.rb +++ b/test/remote/gateways/remote_payflow_uk_test.rb @@ -47,11 +47,11 @@ def test_declined_purchase end def test_successful_purchase_solo - assert response = @gateway.purchase(100000, @solo, @options) - assert_equal 'Approved', response.message - assert_success response - assert response.test? - assert_not_nil response.authorization + assert response = @gateway.purchase(100000, @solo, @options) + assert_equal 'Approved', response.message + assert_success response + assert response.test? + assert_not_nil response.authorization end def test_no_card_issue_or_card_start_with_switch diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb index a99c5c793e4..e4b6cf3f593 100644 --- a/test/remote/gateways/remote_usa_epay_transaction_test.rb +++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb @@ -44,10 +44,10 @@ def test_successful_authorization_with_manual_entry end def test_successful_purchase_with_manual_entry - @credit_card.manual_entry = true - assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_equal 'Success', response.message - assert_success response + @credit_card.manual_entry = true + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_equal 'Success', response.message + assert_success response end def test_successful_purchase_with_extra_details diff --git a/test/unit/gateways/bpoint_test.rb b/test/unit/gateways/bpoint_test.rb index acdad65c45d..384862ab576 100644 --- a/test/unit/gateways/bpoint_test.rb +++ b/test/unit/gateways/bpoint_test.rb @@ -399,23 +399,23 @@ def failed_void_response end def successful_store_response - %( - <?xml version="1.0" encoding="UTF-8"?> - <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <soap:Body> - <AddTokenResponse xmlns="urn:Eve_1_4_4"> - <AddTokenResult> - <Token>5999992142370790</Token> - <MaskedCardNumber>498765...769</MaskedCardNumber> - <CardType>VC</CardType> - </AddTokenResult> - <response> - <ResponseCode>SUCCESS</ResponseCode> - </response> - </AddTokenResponse> - </soap:Body> - </soap:Envelope> - ) + %( + <?xml version="1.0" encoding="UTF-8"?> + <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <soap:Body> + <AddTokenResponse xmlns="urn:Eve_1_4_4"> + <AddTokenResult> + <Token>5999992142370790</Token> + <MaskedCardNumber>498765...769</MaskedCardNumber> + <CardType>VC</CardType> + </AddTokenResult> + <response> + <ResponseCode>SUCCESS</ResponseCode> + </response> + </AddTokenResponse> + </soap:Body> + </soap:Envelope> + ) end def failed_store_response diff --git a/test/unit/gateways/card_stream_test.rb b/test/unit/gateways/card_stream_test.rb index 340f954a5e7..e7f225346de 100644 --- a/test/unit/gateways/card_stream_test.rb +++ b/test/unit/gateways/card_stream_test.rb @@ -347,7 +347,7 @@ def transcript end def scrubbed_transcript - <<-eos + <<-eos POST /direct/ HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: gateway.cardstream.com\r\nContent-Length: 501\r\n\r\n" amount=&currencyCode=826&transactionUnique=a017ca2ac0569188517ad8368c36a06d&orderRef=AM+test+purchase&customerName=Longbob+Longsen&cardNumber=[FILTERED]&cardExpiryMonth=12&cardExpiryYear=14&cardCVV=[FILTERED]&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostCode=NN17+8YG+&merchantID=102922&action=SALE&type=1&countryCode=GB&threeDSRequired=N&signature=970b3fe099a85c9922a79af46c2cb798616b9fbd044a921ac5eb46cd1907a5e89b8c720aae59c7eb1d81a59563f209d5db51aa3c270838199f2bfdcbe2c1149d eos diff --git a/test/unit/gateways/cardknox_test.rb b/test/unit/gateways/cardknox_test.rb index cbddf0b4d46..bc10d5e0e70 100644 --- a/test/unit/gateways/cardknox_test.rb +++ b/test/unit/gateways/cardknox_test.rb @@ -201,7 +201,7 @@ def test_scrub private def purchase_request - 'xKey=api_key&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=4242424242424242&xCVV=123&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6' + 'xKey=api_key&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=4242424242424242&xCVV=123&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6' end def successful_purchase_response # passed avs and cvv @@ -256,7 +256,7 @@ def successful_check_refund_void end def successful_verify_response - 'xResult=A&xStatus=Approved&xError=&xRefNum=15314566&xAuthCode=608755&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xAuthAmount=1.00&xToken=09dc51aceb98440fbf0847cad2941d45&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen' + 'xResult=A&xStatus=Approved&xError=&xRefNum=15314566&xAuthCode=608755&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xAuthAmount=1.00&xToken=09dc51aceb98440fbf0847cad2941d45&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen' end def failed_verify_response @@ -264,10 +264,10 @@ def failed_verify_response end def pre_scrubbed - 'xKey=api_key&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=4242424242424242&xCVV=123&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6' + 'xKey=api_key&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=4242424242424242&xCVV=123&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6' end def post_scrubbed - 'xKey=[FILTERED]&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=[FILTERED]&xCVV=[FILTERED]&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6' + 'xKey=[FILTERED]&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=[FILTERED]&xCVV=[FILTERED]&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6' end end diff --git a/test/unit/gateways/elavon_test.rb b/test/unit/gateways/elavon_test.rb index a5456d577d4..cf8557ce0af 100644 --- a/test/unit/gateways/elavon_test.rb +++ b/test/unit/gateways/elavon_test.rb @@ -372,7 +372,7 @@ def failed_void_response end def invalid_login_response - <<-RESPONSE + <<-RESPONSE ssl_result=7000\r ssl_result_message=The VirtualMerchant ID and/or User ID supplied in the authorization request is invalid.\r RESPONSE diff --git a/test/unit/gateways/eway_test.rb b/test/unit/gateways/eway_test.rb index bae6c709504..5c1059163e5 100644 --- a/test/unit/gateways/eway_test.rb +++ b/test/unit/gateways/eway_test.rb @@ -70,11 +70,11 @@ def test_failed_refund end def test_amount_style - assert_equal '1034', @gateway.send(:amount, 1034) + assert_equal '1034', @gateway.send(:amount, 1034) - assert_raise(ArgumentError) do - @gateway.send(:amount, '10.34') - end + assert_raise(ArgumentError) do + @gateway.send(:amount, '10.34') + end end def test_ensure_does_not_respond_to_authorize diff --git a/test/unit/gateways/gateway_test.rb b/test/unit/gateways/gateway_test.rb index 56a957f6109..3372ee5de13 100644 --- a/test/unit/gateways/gateway_test.rb +++ b/test/unit/gateways/gateway_test.rb @@ -46,11 +46,11 @@ def test_should_be_able_to_look_for_test_mode end def test_amount_style - assert_equal '10.34', @gateway.send(:amount, 1034) + assert_equal '10.34', @gateway.send(:amount, 1034) - assert_raise(ArgumentError) do - @gateway.send(:amount, '10.34') - end + assert_raise(ArgumentError) do + @gateway.send(:amount, '10.34') + end end def test_card_brand diff --git a/test/unit/gateways/hps_test.rb b/test/unit/gateways/hps_test.rb index 107ec989b05..0f85bf5a2cb 100644 --- a/test/unit/gateways/hps_test.rb +++ b/test/unit/gateways/hps_test.rb @@ -270,7 +270,7 @@ def failed_charge_response end def successful_authorize_response - <<-RESPONSE + <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> diff --git a/test/unit/gateways/metrics_global_test.rb b/test/unit/gateways/metrics_global_test.rb index 5cf3c841bff..0184ddfbeff 100644 --- a/test/unit/gateways/metrics_global_test.rb +++ b/test/unit/gateways/metrics_global_test.rb @@ -90,12 +90,12 @@ def test_add_duplicate_window_with_duplicate_window end def test_purchase_is_valid_csv - params = { :amount => '1.01' } + params = { :amount => '1.01' } - @gateway.send(:add_creditcard, params, @credit_card) + @gateway.send(:add_creditcard, params, @credit_card) - assert data = @gateway.send(:post_data, 'AUTH_ONLY', params) - assert_equal post_data_fixture.size, data.size + assert data = @gateway.send(:post_data, 'AUTH_ONLY', params) + assert_equal post_data_fixture.size, data.size end def test_purchase_meets_minimum_requirements diff --git a/test/unit/gateways/moneris_test.rb b/test/unit/gateways/moneris_test.rb index a4144b398d5..f1cdffd5488 100644 --- a/test/unit/gateways/moneris_test.rb +++ b/test/unit/gateways/moneris_test.rb @@ -122,53 +122,53 @@ def test_refund end def test_amount_style - assert_equal '10.34', @gateway.send(:amount, 1034) + assert_equal '10.34', @gateway.send(:amount, 1034) - assert_raise(ArgumentError) do - @gateway.send(:amount, '10.34') - end + assert_raise(ArgumentError) do + @gateway.send(:amount, '10.34') + end end def test_preauth_is_valid_xml - params = { - :order_id => 'order1', - :amount => '1.01', - :pan => '4242424242424242', - :expdate => '0303', - :crypt_type => 7, - } + params = { + :order_id => 'order1', + :amount => '1.01', + :pan => '4242424242424242', + :expdate => '0303', + :crypt_type => 7, + } - assert data = @gateway.send(:post_data, 'preauth', params) - assert REXML::Document.new(data) - assert_equal xml_capture_fixture.size, data.size + assert data = @gateway.send(:post_data, 'preauth', params) + assert REXML::Document.new(data) + assert_equal xml_capture_fixture.size, data.size end def test_purchase_is_valid_xml - params = { - :order_id => 'order1', - :amount => '1.01', - :pan => '4242424242424242', - :expdate => '0303', - :crypt_type => 7, - } + params = { + :order_id => 'order1', + :amount => '1.01', + :pan => '4242424242424242', + :expdate => '0303', + :crypt_type => 7, + } - assert data = @gateway.send(:post_data, 'purchase', params) - assert REXML::Document.new(data) - assert_equal xml_purchase_fixture.size, data.size + assert data = @gateway.send(:post_data, 'purchase', params) + assert REXML::Document.new(data) + assert_equal xml_purchase_fixture.size, data.size end def test_capture_is_valid_xml - params = { - :order_id => 'order1', - :amount => '1.01', - :pan => '4242424242424242', - :expdate => '0303', - :crypt_type => 7, - } + params = { + :order_id => 'order1', + :amount => '1.01', + :pan => '4242424242424242', + :expdate => '0303', + :crypt_type => 7, + } - assert data = @gateway.send(:post_data, 'preauth', params) - assert REXML::Document.new(data) - assert_equal xml_capture_fixture.size, data.size + assert data = @gateway.send(:post_data, 'preauth', params) + assert REXML::Document.new(data) + assert_equal xml_capture_fixture.size, data.size end def test_successful_verify @@ -717,11 +717,11 @@ def failed_void_response end def xml_purchase_fixture - '<request><store_id>store1</store_id><api_token>yesguy</api_token><purchase><amount>1.01</amount><pan>4242424242424242</pan><expdate>0303</expdate><crypt_type>7</crypt_type><order_id>order1</order_id></purchase></request>' + '<request><store_id>store1</store_id><api_token>yesguy</api_token><purchase><amount>1.01</amount><pan>4242424242424242</pan><expdate>0303</expdate><crypt_type>7</crypt_type><order_id>order1</order_id></purchase></request>' end def xml_capture_fixture - '<request><store_id>store1</store_id><api_token>yesguy</api_token><preauth><amount>1.01</amount><pan>4242424242424242</pan><expdate>0303</expdate><crypt_type>7</crypt_type><order_id>order1</order_id></preauth></request>' + '<request><store_id>store1</store_id><api_token>yesguy</api_token><preauth><amount>1.01</amount><pan>4242424242424242</pan><expdate>0303</expdate><crypt_type>7</crypt_type><order_id>order1</order_id></preauth></request>' end def pre_scrub diff --git a/test/unit/gateways/moneris_us_test.rb b/test/unit/gateways/moneris_us_test.rb index 46aa128e20b..b2bff66d3d1 100644 --- a/test/unit/gateways/moneris_us_test.rb +++ b/test/unit/gateways/moneris_us_test.rb @@ -90,53 +90,53 @@ def test_failed_verify end def test_amount_style - assert_equal '10.34', @gateway.send(:amount, 1034) + assert_equal '10.34', @gateway.send(:amount, 1034) - assert_raise(ArgumentError) do - @gateway.send(:amount, '10.34') - end + assert_raise(ArgumentError) do + @gateway.send(:amount, '10.34') + end end def test_preauth_is_valid_xml - params = { - :order_id => 'order1', - :amount => '1.01', - :pan => '4242424242424242', - :expdate => '0303', - :crypt_type => 7, - } + params = { + :order_id => 'order1', + :amount => '1.01', + :pan => '4242424242424242', + :expdate => '0303', + :crypt_type => 7, + } - assert data = @gateway.send(:post_data, 'us_preauth', params) - assert REXML::Document.new(data) - assert_equal xml_capture_fixture.size, data.size + assert data = @gateway.send(:post_data, 'us_preauth', params) + assert REXML::Document.new(data) + assert_equal xml_capture_fixture.size, data.size end def test_purchase_is_valid_xml - params = { - :order_id => 'order1', - :amount => '1.01', - :pan => '4242424242424242', - :expdate => '0303', - :crypt_type => 7, - } + params = { + :order_id => 'order1', + :amount => '1.01', + :pan => '4242424242424242', + :expdate => '0303', + :crypt_type => 7, + } - assert data = @gateway.send(:post_data, 'us_purchase', params) - assert REXML::Document.new(data) - assert_equal xml_purchase_fixture.size, data.size + assert data = @gateway.send(:post_data, 'us_purchase', params) + assert REXML::Document.new(data) + assert_equal xml_purchase_fixture.size, data.size end def test_capture_is_valid_xml - params = { - :order_id => 'order1', - :amount => '1.01', - :pan => '4242424242424242', - :expdate => '0303', - :crypt_type => 7, - } + params = { + :order_id => 'order1', + :amount => '1.01', + :pan => '4242424242424242', + :expdate => '0303', + :crypt_type => 7, + } - assert data = @gateway.send(:post_data, 'us_preauth', params) - assert REXML::Document.new(data) - assert_equal xml_capture_fixture.size, data.size + assert data = @gateway.send(:post_data, 'us_preauth', params) + assert REXML::Document.new(data) + assert_equal xml_capture_fixture.size, data.size end def test_supported_countries @@ -591,11 +591,11 @@ def successful_echeck_purchase_response end def xml_purchase_fixture - '<request><store_id>monusqa002</store_id><api_token>qatoken</api_token><us_purchase><amount>1.01</amount><pan>4242424242424242</pan><expdate>0303</expdate><crypt_type>7</crypt_type><order_id>order1</order_id></us_purchase></request>' + '<request><store_id>monusqa002</store_id><api_token>qatoken</api_token><us_purchase><amount>1.01</amount><pan>4242424242424242</pan><expdate>0303</expdate><crypt_type>7</crypt_type><order_id>order1</order_id></us_purchase></request>' end def xml_capture_fixture - '<request><store_id>monusqa002</store_id><api_token>qatoken</api_token><us_preauth><amount>1.01</amount><pan>4242424242424242</pan><expdate>0303</expdate><crypt_type>7</crypt_type><order_id>order1</order_id></us_preauth></request>' + '<request><store_id>monusqa002</store_id><api_token>qatoken</api_token><us_preauth><amount>1.01</amount><pan>4242424242424242</pan><expdate>0303</expdate><crypt_type>7</crypt_type><order_id>order1</order_id></us_preauth></request>' end def pre_scrub diff --git a/test/unit/gateways/netbanx_test.rb b/test/unit/gateways/netbanx_test.rb index cb9af17b688..a4a424d27f3 100644 --- a/test/unit/gateways/netbanx_test.rb +++ b/test/unit/gateways/netbanx_test.rb @@ -140,15 +140,15 @@ def test_successful_purchase_with_token end def test_successful_unstore - @gateway.expects(:ssl_request).twice.returns(successful_unstore_response) + @gateway.expects(:ssl_request).twice.returns(successful_unstore_response) - response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015|e4a3cd5a-56db-4d9b-97d3-fdd9ab3bd0f4') - assert_success response - assert response.test? + response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015|e4a3cd5a-56db-4d9b-97d3-fdd9ab3bd0f4') + assert_success response + assert response.test? - response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015') - assert_success response - assert response.test? + response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015') + assert_success response + assert response.test? end def test_scrub diff --git a/test/unit/gateways/omise_test.rb b/test/unit/gateways/omise_test.rb index c3e99f0d83c..5c31855fd64 100644 --- a/test/unit/gateways/omise_test.rb +++ b/test/unit/gateways/omise_test.rb @@ -39,8 +39,8 @@ def test_scrub end def test_gateway_url - assert_equal 'https://api.omise.co/', OmiseGateway::API_URL - assert_equal 'https://vault.omise.co/', OmiseGateway::VAULT_URL + assert_equal 'https://api.omise.co/', OmiseGateway::API_URL + assert_equal 'https://vault.omise.co/', OmiseGateway::VAULT_URL end def test_request_headers diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb index 7302649b7da..a59885917d5 100644 --- a/test/unit/gateways/opp_test.rb +++ b/test/unit/gateways/opp_test.rb @@ -179,11 +179,11 @@ def test_scrub private def pre_scrubbed - 'paymentType=DB&amount=1.00&currency=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=4200000000000000&card.expiryMonth=05&card.expiryYear=2018& card.cvv=123&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=8a8294174b7ecb28014b9699220015ca&authentication.password=sy6KJsT8&authentication.userId=8a8294174b7ecb28014b9699220015cc' + 'paymentType=DB&amount=1.00&currency=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=4200000000000000&card.expiryMonth=05&card.expiryYear=2018& card.cvv=123&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=8a8294174b7ecb28014b9699220015ca&authentication.password=sy6KJsT8&authentication.userId=8a8294174b7ecb28014b9699220015cc' end def post_scrubbed - 'paymentType=DB&amount=1.00&currency=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=[FILTERED]&card.expiryMonth=05&card.expiryYear=2018& card.cvv=[FILTERED]&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=8a8294174b7ecb28014b9699220015ca&authentication.password=[FILTERED]&authentication.userId=8a8294174b7ecb28014b9699220015cc' + 'paymentType=DB&amount=1.00&currency=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=[FILTERED]&card.expiryMonth=05&card.expiryYear=2018& card.cvv=[FILTERED]&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=8a8294174b7ecb28014b9699220015ca&authentication.password=[FILTERED]&authentication.userId=8a8294174b7ecb28014b9699220015cc' end def successful_response(type, id) diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index f030672e46c..2d3e8d8f3f3 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -217,14 +217,14 @@ def test_truncates_phone end def test_truncates_zip - long_zip = '1234567890123' - - response = stub_comms do - @gateway.purchase(50, credit_card, :order_id => 1, :billing_address => address(:zip => long_zip)) - end.check_request do |endpoint, data, headers| - assert_match(/1234567890</, data) - end.respond_with(successful_purchase_response) - assert_success response + long_zip = '1234567890123' + + response = stub_comms do + @gateway.purchase(50, credit_card, :order_id => 1, :billing_address => address(:zip => long_zip)) + end.check_request do |endpoint, data, headers| + assert_match(/1234567890</, data) + end.respond_with(successful_purchase_response) + assert_success response end def test_address_format diff --git a/test/unit/gateways/pagarme_test.rb b/test/unit/gateways/pagarme_test.rb index 4b12bb2739d..3944a780cd2 100644 --- a/test/unit/gateways/pagarme_test.rb +++ b/test/unit/gateways/pagarme_test.rb @@ -614,7 +614,7 @@ def successful_capture_response end def failed_capture_response - <<-FAILED_RESPONSE + <<-FAILED_RESPONSE { "errors": [ { @@ -630,7 +630,7 @@ def failed_capture_response end def successful_refund_response - <<-SUCCESS_RESPONSE + <<-SUCCESS_RESPONSE { "acquirer_name": "development", "acquirer_response_code": "00", @@ -688,7 +688,7 @@ def successful_refund_response end def failed_refund_response - <<-FAILED_RESPONSE + <<-FAILED_RESPONSE { "errors": [ { @@ -704,7 +704,7 @@ def failed_refund_response end def successful_void_response - <<-SUCCESS_RESPONSE + <<-SUCCESS_RESPONSE { "acquirer_name": "pagarme", "acquirer_response_code": "00", @@ -762,7 +762,7 @@ def successful_void_response end def failed_void_response - <<-FAILED_RESPONSE + <<-FAILED_RESPONSE { "errors": [ { @@ -778,7 +778,7 @@ def failed_void_response end def successful_verify_response - <<-SUCCESS_RESPONSE + <<-SUCCESS_RESPONSE { "acquirer_name": "pagarme", "acquirer_response_code": "00", @@ -836,7 +836,7 @@ def successful_verify_response end def successful_verify_void_response - <<-SUCCESS_RESPONSE + <<-SUCCESS_RESPONSE { "acquirer_name": "pagarme", "acquirer_response_code": "00", @@ -894,7 +894,7 @@ def successful_verify_void_response end def failed_verify_response - <<-FAILED_RESPONSE + <<-FAILED_RESPONSE { "acquirer_name": "pagarme", "acquirer_response_code": "88", @@ -968,7 +968,7 @@ def failed_error_response end def failed_json_response - <<-SUCCESS_RESPONSE + <<-SUCCESS_RESPONSE { foo: bar } diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb index 2ddee59bb92..01a4ed9cb0b 100644 --- a/test/unit/gateways/payflow_test.rb +++ b/test/unit/gateways/payflow_test.rb @@ -540,7 +540,7 @@ def successful_recurring_response end def start_date_error_recurring_response - <<-XML + <<-XML <ResponseData> <Result>0</Result> <Message>Field format error: START or NEXTPAYMENTDATE older than last payment date</Message> @@ -553,7 +553,7 @@ def start_date_error_recurring_response end def start_date_missing_recurring_response - <<-XML + <<-XML <ResponseData> <Result>0</Result> <Message>Field format error: START field missing</Message> diff --git a/test/unit/gateways/paypal/paypal_common_api_test.rb b/test/unit/gateways/paypal/paypal_common_api_test.rb index 588406406e0..49751604ab9 100644 --- a/test/unit/gateways/paypal/paypal_common_api_test.rb +++ b/test/unit/gateways/paypal/paypal_common_api_test.rb @@ -86,7 +86,7 @@ def test_build_request_wrapper_plain def test_build_request_wrapper_with_request_details result = @gateway.send(:build_request_wrapper, 'Action', :request_details => true) do |xml| - xml.tag! 'n2:TransactionID', 'baz' + xml.tag! 'n2:TransactionID', 'baz' end assert_equal 'baz', REXML::XPath.first(REXML::Document.new(result), '//ActionReq/ActionRequest/n2:ActionRequestDetails/n2:TransactionID').text end diff --git a/test/unit/gateways/paypal_digital_goods_test.rb b/test/unit/gateways/paypal_digital_goods_test.rb index ab7cf6c03eb..4b433f38843 100644 --- a/test/unit/gateways/paypal_digital_goods_test.rb +++ b/test/unit/gateways/paypal_digital_goods_test.rb @@ -33,45 +33,45 @@ def test_test_redirect_url end def test_setup_request_invalid_requests - assert_raise ArgumentError do - @gateway.setup_purchase(100, - :ip => '127.0.0.1', - :description => 'Test Title', - :return_url => 'http://return.url', - :cancel_return_url => 'http://cancel.url') - end + assert_raise ArgumentError do + @gateway.setup_purchase(100, + :ip => '127.0.0.1', + :description => 'Test Title', + :return_url => 'http://return.url', + :cancel_return_url => 'http://cancel.url') + end - assert_raise ArgumentError do - @gateway.setup_purchase(100, - :ip => '127.0.0.1', - :description => 'Test Title', - :return_url => 'http://return.url', - :cancel_return_url => 'http://cancel.url', - :items => [ ]) - end + assert_raise ArgumentError do + @gateway.setup_purchase(100, + :ip => '127.0.0.1', + :description => 'Test Title', + :return_url => 'http://return.url', + :cancel_return_url => 'http://cancel.url', + :items => [ ]) + end - assert_raise ArgumentError do - @gateway.setup_purchase(100, - :ip => '127.0.0.1', - :description => 'Test Title', - :return_url => 'http://return.url', - :cancel_return_url => 'http://cancel.url', - :items => [ Hash.new ]) - end + assert_raise ArgumentError do + @gateway.setup_purchase(100, + :ip => '127.0.0.1', + :description => 'Test Title', + :return_url => 'http://return.url', + :cancel_return_url => 'http://cancel.url', + :items => [ Hash.new ]) + end - assert_raise ArgumentError do - @gateway.setup_purchase(100, - :ip => '127.0.0.1', - :description => 'Test Title', - :return_url => 'http://return.url', - :cancel_return_url => 'http://cancel.url', - :items => [ { :name => 'Charge', - :number => '1', - :quantity => '1', - :amount => 100, - :description => 'Description', - :category => 'Physical' } ]) - end + assert_raise ArgumentError do + @gateway.setup_purchase(100, + :ip => '127.0.0.1', + :description => 'Test Title', + :return_url => 'http://return.url', + :cancel_return_url => 'http://cancel.url', + :items => [ { :name => 'Charge', + :number => '1', + :quantity => '1', + :amount => 100, + :description => 'Description', + :category => 'Physical' } ]) + end end def test_build_setup_request_valid @@ -93,30 +93,30 @@ def test_build_setup_request_valid private def successful_setup_response -"<?xml version=\"1.0\" encoding=\"UTF-8\"?> -<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:cc=\"urn:ebay:apis:CoreComponentTypes\" xmlns:wsu=\"http://schemas.xmlsoap.org/ws/2002/07/utility\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xmlns:ed=\"urn:ebay:apis:EnhancedDataTypes\" xmlns:ebl=\"urn:ebay:apis:eBLBaseComponents\" xmlns:ns=\"urn:ebay:api:PayPalAPI\"> - <SOAP-ENV:Header> - <Security xmlns=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xsi:type=\"wsse:SecurityType\"></Security> - <RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\" xsi:type=\"ebl:CustomSecurityHeaderType\"> - <Credentials xmlns=\"urn:ebay:apis:eBLBaseComponents\" xsi:type=\"ebl:UserIdPasswordType\"> - <Username xsi:type=\"xs:string\"></Username> - <Password xsi:type=\"xs:string\"></Password> - <Signature xsi:type=\"xs:string\">OMGOMGOMGOMGOMG</Signature> - <Subject xsi:type=\"xs:string\"></Subject> - </Credentials> - </RequesterCredentials> - </SOAP-ENV:Header> - <SOAP-ENV:Body id=\"_0\"> - <SetExpressCheckoutResponse xmlns=\"urn:ebay:api:PayPalAPI\"> - <Timestamp xmlns=\"urn:ebay:apis:eBLBaseComponents\">2011-05-19T20:13:30Z</Timestamp> - <Ack xmlns=\"urn:ebay:apis:eBLBaseComponents\">Success</Ack> - <CorrelationID xmlns=\"urn:ebay:apis:eBLBaseComponents\">da0ed6bc90ef1</CorrelationID> - <Version xmlns=\"urn:ebay:apis:eBLBaseComponents\">72</Version> - <Build xmlns=\"urn:ebay:apis:eBLBaseComponents\">1882144</Build> - <Token xsi:type=\"ebl:ExpressCheckoutTokenType\">EC-0XOMGOMGOMG</Token> - </SetExpressCheckoutResponse> - </SOAP-ENV:Body> - </SOAP-ENV:Envelope>" + "<?xml version=\"1.0\" encoding=\"UTF-8\"?> + <SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:cc=\"urn:ebay:apis:CoreComponentTypes\" xmlns:wsu=\"http://schemas.xmlsoap.org/ws/2002/07/utility\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xmlns:ed=\"urn:ebay:apis:EnhancedDataTypes\" xmlns:ebl=\"urn:ebay:apis:eBLBaseComponents\" xmlns:ns=\"urn:ebay:api:PayPalAPI\"> + <SOAP-ENV:Header> + <Security xmlns=\"http://schemas.xmlsoap.org/ws/2002/12/secext\" xsi:type=\"wsse:SecurityType\"></Security> + <RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\" xsi:type=\"ebl:CustomSecurityHeaderType\"> + <Credentials xmlns=\"urn:ebay:apis:eBLBaseComponents\" xsi:type=\"ebl:UserIdPasswordType\"> + <Username xsi:type=\"xs:string\"></Username> + <Password xsi:type=\"xs:string\"></Password> + <Signature xsi:type=\"xs:string\">OMGOMGOMGOMGOMG</Signature> + <Subject xsi:type=\"xs:string\"></Subject> + </Credentials> + </RequesterCredentials> + </SOAP-ENV:Header> + <SOAP-ENV:Body id=\"_0\"> + <SetExpressCheckoutResponse xmlns=\"urn:ebay:api:PayPalAPI\"> + <Timestamp xmlns=\"urn:ebay:apis:eBLBaseComponents\">2011-05-19T20:13:30Z</Timestamp> + <Ack xmlns=\"urn:ebay:apis:eBLBaseComponents\">Success</Ack> + <CorrelationID xmlns=\"urn:ebay:apis:eBLBaseComponents\">da0ed6bc90ef1</CorrelationID> + <Version xmlns=\"urn:ebay:apis:eBLBaseComponents\">72</Version> + <Build xmlns=\"urn:ebay:apis:eBLBaseComponents\">1882144</Build> + <Token xsi:type=\"ebl:ExpressCheckoutTokenType\">EC-0XOMGOMGOMG</Token> + </SetExpressCheckoutResponse> + </SOAP-ENV:Body> + </SOAP-ENV:Envelope>" end end diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb index 1eef9513781..61c506558a1 100644 --- a/test/unit/gateways/paypal_express_test.rb +++ b/test/unit/gateways/paypal_express_test.rb @@ -779,7 +779,7 @@ def successful_create_billing_agreement_response end def successful_authorize_reference_transaction_response - <<-RESPONSE + <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ed="urn:ebay:apis:EnhancedDataTypes" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI"> <SOAP-ENV:Header> diff --git a/test/unit/gateways/trust_commerce_test.rb b/test/unit/gateways/trust_commerce_test.rb index fbba691fece..08feafb188b 100644 --- a/test/unit/gateways/trust_commerce_test.rb +++ b/test/unit/gateways/trust_commerce_test.rb @@ -29,11 +29,11 @@ def test_unsuccessful_purchase end def test_amount_style - assert_equal '1034', @gateway.send(:amount, 1034) + assert_equal '1034', @gateway.send(:amount, 1034) - assert_raise(ArgumentError) do - @gateway.send(:amount, '10.34') - end + assert_raise(ArgumentError) do + @gateway.send(:amount, '10.34') + end end def test_avs_result diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb index 753e74ba13b..5318db9c1f9 100644 --- a/test/unit/gateways/usa_epay_transaction_test.rb +++ b/test/unit/gateways/usa_epay_transaction_test.rb @@ -348,11 +348,11 @@ def test_add_test_mode_with_false_test_mode_option end def test_amount_style - assert_equal '10.34', @gateway.send(:amount, 1034) + assert_equal '10.34', @gateway.send(:amount, 1034) - assert_raise(ArgumentError) do - @gateway.send(:amount, '10.34') - end + assert_raise(ArgumentError) do + @gateway.send(:amount, '10.34') + end end def test_supported_countries diff --git a/test/unit/gateways/verifi_test.rb b/test/unit/gateways/verifi_test.rb index 7debaabf3cd..404556b2d6c 100644 --- a/test/unit/gateways/verifi_test.rb +++ b/test/unit/gateways/verifi_test.rb @@ -61,7 +61,7 @@ def test_amount_style assert_equal '10.34', @gateway.send(:amount, 1034) assert_raise(ArgumentError) do - @gateway.send(:amount, '10.34') + @gateway.send(:amount, '10.34') end end diff --git a/test/unit/gateways/visanet_peru_test.rb b/test/unit/gateways/visanet_peru_test.rb index bbf3af32b47..49b7a78951b 100644 --- a/test/unit/gateways/visanet_peru_test.rb +++ b/test/unit/gateways/visanet_peru_test.rb @@ -299,7 +299,7 @@ def failed_authorize_response_bad_email end def successful_capture_response - '{"errorCode":0,"errorMessage":"OK","transactionUUID":"8517cf68-4820-4224-959b-01c8117385e0","externalTransactionId":"de9dc65c094fb4f1defddc562731af81","transactionDateTime":1519937673906,"transactionDuration":0,"merchantId":"543025501","userTokenId":null,"aliasName":null,"data":{"FECHAYHORA_TX":null,"DSC_ECI":null,"DSC_COD_ACCION":null,"NOM_EMISOR":null,"ESTADO":"Depositado","RESPUESTA":"1","ID_UNICO":null,"NUMORDEN":null,"CODACCION":null,"ETICKET":null,"IMP_AUTORIZADO":null,"DECISIONCS":null,"COD_AUTORIZA":null,"CODTIENDA":"543025501","PAN":null,"ORI_TARJETA":null}}' + '{"errorCode":0,"errorMessage":"OK","transactionUUID":"8517cf68-4820-4224-959b-01c8117385e0","externalTransactionId":"de9dc65c094fb4f1defddc562731af81","transactionDateTime":1519937673906,"transactionDuration":0,"merchantId":"543025501","userTokenId":null,"aliasName":null,"data":{"FECHAYHORA_TX":null,"DSC_ECI":null,"DSC_COD_ACCION":null,"NOM_EMISOR":null,"ESTADO":"Depositado","RESPUESTA":"1","ID_UNICO":null,"NUMORDEN":null,"CODACCION":null,"ETICKET":null,"IMP_AUTORIZADO":null,"DECISIONCS":null,"COD_AUTORIZA":null,"CODTIENDA":"543025501","PAN":null,"ORI_TARJETA":null}}' end def failed_capture_response diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index 031deef53ff..4e129b76d55 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -4,14 +4,14 @@ class WorldpayTest < Test::Unit::TestCase include CommStub def setup - @gateway = WorldpayGateway.new( - :login => 'testlogin', - :password => 'testpassword' - ) + @gateway = WorldpayGateway.new( + :login => 'testlogin', + :password => 'testpassword' + ) - @amount = 100 - @credit_card = credit_card('4242424242424242') - @options = {:order_id => 1} + @amount = 100 + @credit_card = credit_card('4242424242424242') + @options = {:order_id => 1} end def test_successful_authorize From 989fd1fb886e23a3a49f51609fe303586d36bbb7 Mon Sep 17 00:00:00 2001 From: Filipe Costa <filipebarcos@users.noreply.github.com> Date: Thu, 29 Nov 2018 13:22:05 -0500 Subject: [PATCH 660/677] Missing CHANGELOG release title (#3066) --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 5198e278bed..bdf211e3ffe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ = ActiveMerchant CHANGELOG == HEAD + +== Version 1.87.0 (November 29, 2018) * Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026 * Braintree: Fix passing phone-only billing address [curiousepic] #3025 * Litle: Capitalize check account type [curiousepic] #3028 From 942e902f63cc5d45d788ebf3ef5448d34f6e5c82 Mon Sep 17 00:00:00 2001 From: Edouard Chin <edouard.chin@shopify.com> Date: Fri, 30 Nov 2018 14:52:34 +0100 Subject: [PATCH 661/677] Remove the upperbound constraint on ActiveSupport: (#3065) - During every ActiveSupport major bump, this gemspec needs to be updated, I think we are being too conservative and having an upperbound limit doesn't help. If we wanted to be really conservative we would have to add a upperbound constraint on the minor version as well (`< 5.x`) since Rails doesn't follow semver and minor version can introduce breaking changes. What I think is better is to remove the upperbound constraint, and test AM directly on ActiveSupport edge. Looking at the commit rates on this project, CI would run largely enough to cover us. But we can also add another safety net and run travis on a schedule. --- .travis.yml | 6 ++++++ activemerchant.gemspec | 2 +- gemfiles/Gemfile.rails_master | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 gemfiles/Gemfile.rails_master diff --git a/.travis.yml b/.travis.yml index 68ff33a3358..e2207604777 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ gemfile: - gemfiles/Gemfile.rails51 - gemfiles/Gemfile.rails50 - gemfiles/Gemfile.rails42 +- gemfiles/Gemfile.rails_master jobs: include: @@ -19,6 +20,11 @@ jobs: gemfile: Gemfile script: bundle exec rubocop --parallel +matrix: + exclude: + - rvm: 2.3 + gemfile: 'gemfiles/Gemfile.rails_master' + notifications: email: on_success: never diff --git a/activemerchant.gemspec b/activemerchant.gemspec index 031b34b2576..bb9ea4e14f8 100644 --- a/activemerchant.gemspec +++ b/activemerchant.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.has_rdoc = true if Gem::VERSION < '1.7.0' - s.add_dependency('activesupport', '>= 4.2', '< 6.x') + s.add_dependency('activesupport', '>= 4.2') s.add_dependency('i18n', '>= 0.6.9') s.add_dependency('builder', '>= 2.1.2', '< 4.0.0') s.add_dependency('nokogiri', '~> 1.4') diff --git a/gemfiles/Gemfile.rails_master b/gemfiles/Gemfile.rails_master new file mode 100644 index 00000000000..04b88ec1b00 --- /dev/null +++ b/gemfiles/Gemfile.rails_master @@ -0,0 +1,3 @@ +eval_gemfile '../Gemfile' + +gem 'activesupport', github: 'rails/rails' From 427bccfcfe29605cc4f4e5a1fffdf09025f3c7b1 Mon Sep 17 00:00:00 2001 From: Filipe Costa <filipebarcos@gmail.com> Date: Fri, 30 Nov 2018 08:57:57 -0500 Subject: [PATCH 662/677] Release v1.88.0 --- CHANGELOG | 3 +++ lib/active_merchant/version.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index bdf211e3ffe..6e44bd12a6b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,9 @@ == HEAD +== Version 1.88.0 (November 30, 2018) +* Added ActiveSupport/Rails master support [Edouard-chin] #3065 + == Version 1.87.0 (November 29, 2018) * Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026 * Braintree: Fix passing phone-only billing address [curiousepic] #3025 diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb index 54f720d8bf0..5af2175368e 100644 --- a/lib/active_merchant/version.rb +++ b/lib/active_merchant/version.rb @@ -1,3 +1,3 @@ module ActiveMerchant - VERSION = '1.87.0' + VERSION = '1.88.0' end From 7071f2b9b92c3328bc7c33630cfbe4faece2521b Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Thu, 29 Nov 2018 16:35:09 -0500 Subject: [PATCH 663/677] Worldpay: support MasterCard credits MasterCard and Visa credits do not work the same way, so we were erroneously counting MasterCard credits as failed. Count them as successful. Unit: 40 tests, 227 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 28 tests, 111 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/worldpay.rb | 2 +- test/remote/gateways/remote_worldpay_test.rb | 9 ++++- test/unit/gateways/worldpay_test.rb | 39 +++++++++++++++++-- 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6e44bd12a6b..122c672609e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ = ActiveMerchant CHANGELOG == HEAD +* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068 == Version 1.88.0 (November 30, 2018) * Added ActiveSupport/Rails master support [Edouard-chin] #3065 diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index e5b30d2d6f8..936ef9295d6 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -119,7 +119,7 @@ def refund_request(money, authorization, options) end def credit_request(money, payment_method, options) - commit('credit', build_authorization_request(money, payment_method, options), :ok, options) + commit('credit', build_authorization_request(money, payment_method, options), :ok, 'SENT_FOR_REFUND', options) end def build_request diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index f21d674f2a6..c87d9539397 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -271,12 +271,19 @@ def test_failed_verify assert_match %r{REFUSED}, response.message end - def test_successful_credit_on_cft_gateway + def test_successful_visa_credit_on_cft_gateway credit = @cftgateway.credit(@amount, @credit_card, @options) assert_success credit assert_equal 'SUCCESS', credit.message end + def test_successful_mastercard_credit_on_cft_gateway + cc = credit_card('5555555555554444') + credit = @cftgateway.credit(@amount, cc, @options) + assert_success credit + assert_equal 'SUCCESS', credit.message + end + def test_transcript_scrubbing transcript = capture_transcript(@gateway) do @gateway.purchase(@amount, @credit_card, @options) diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index 4e129b76d55..a1881e04bbc 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -179,16 +179,26 @@ def test_capture assert_success response end - def test_successful_credit + def test_successful_visa_credit response = stub_comms do @gateway.credit(@amount, @credit_card, @options) end.check_request do |endpoint, data, headers| assert_match(/<paymentDetails action="REFUND">/, data) - end.respond_with(successful_credit_response) + end.respond_with(successful_visa_credit_response) assert_success response assert_equal '3d4187536044bd39ad6a289c4339c41c', response.authorization end + def test_successful_mastercard_credit + response = stub_comms do + @gateway.credit(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + assert_match(/<paymentDetails action="REFUND">/, data) + end.respond_with(successful_mastercard_credit_response) + assert_success response + assert_equal 'f25257d251b81fb1fd9c210973c941ff', response.authorization + end + def test_description stub_comms do @gateway.authorize(@amount, @credit_card, @options) @@ -748,7 +758,7 @@ def failed_void_response REQUEST end - def successful_credit_response + def successful_visa_credit_response <<-RESPONSE <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE paymentService PUBLIC "-//WorldPay//DTD WorldPay PaymentService v1//EN" @@ -765,6 +775,29 @@ def successful_credit_response RESPONSE end + def successful_mastercard_credit_response + <<~RESPONSE + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE paymentService PUBLIC "-//WorldPay//DTD WorldPay PaymentService v1//EN" + "http://dtd.worldpay.com/paymentService_v1.dtd"> + <paymentService version="1.4" merchantCode="YOUR_MERCHANT_CODE"> + <reply> + <orderStatus orderCode="f25257d251b81fb1fd9c210973c941ff\"> + <payment> + <paymentMethod>ECMC_DEBIT-SSL</paymentMethod> + <amount value="1110" currencyCode="GBP" exponent="2" debitCreditIndicator="credit"/> + <lastEvent>SENT_FOR_REFUND</lastEvent> + <AuthorisationId id="987654"/> + <balance accountType="IN_PROCESS_CAPTURED"> + <amount value="1110" currencyCode="GBP" exponent="2" debitCreditIndicator="debit"/> + </balance> + </payment> + </orderStatus> + </reply> + </paymentService> + RESPONSE + end + def sample_authorization_request <<-REQUEST <?xml version="1.0" encoding="UTF-8"?> From 1bfa5e9bebc4f656ab13cafddbba8070bb375ab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonni=20T=C3=B8lb=C3=B8ll=20Lund=20Aagesen?= <ta@quickpay.net> Date: Thu, 15 Nov 2018 11:59:05 +0100 Subject: [PATCH 664/677] QuickPay: Update list of supported countries Closes #3049 --- CHANGELOG | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 122c672609e..d671c7424c1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ == HEAD * Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068 +* QuickPay: update supported countries [ta] #3049 == Version 1.88.0 (November 30, 2018) * Added ActiveSupport/Rails master support [Edouard-chin] #3065 diff --git a/README.md b/README.md index 5fbec7885ae..fb9dfdc3705 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,7 @@ The [ActiveMerchant Wiki](http://github.com/activemerchant/active_merchant/wikis * [QuickBooks Merchant Services](http://payments.intuit.com/) - US * [QuickBooks Payments](http://payments.intuit.com/) - US * [Quantum Gateway](http://www.quantumgateway.com) - US -* [QuickPay](http://quickpay.net/) - DE, DK, ES, FI, FR, FO, GB, IS, NO, SE +* [QuickPay](http://quickpay.net/) - AT, BE, BG, CY, CZ, DE, DK, EE, ES, FI, FR, GB, GR, HR, HU, IE, IS, IT, LI, LT, LU, LV, MT, NL, NO, PL, PT, RO, SE SI, SK * [Qvalent](https://www.qvalent.com/) - AU * [Raven](http://www.deepcovelabs.com/raven) - AI, AN, AT, AU, BE, BG, BS, BZ, CA, CH, CR, CY, CZ, DE, DK, DM, DO, EE, EL, ES, FI, FR, GB, GG, GI, HK, HR, HU, IE, IL, IM, IN, IT, JE, KN, LI, LT, LU, LV, MH, MT, MY, NL, NO, NZ, PA, PE, PH, PL, PT, RO, RS, SC, SE, SG, SI, SK, UK, US, VG, ZA * [Realex](http://www.realexpayments.com/) - IE, GB, FR, BE, NL, LU, IT From 3d1c8b7bec92ac8a3811910186b52f2db33f2173 Mon Sep 17 00:00:00 2001 From: Benjamin Pollack <benjamin@spreedly.com> Date: Tue, 4 Dec 2018 08:48:13 -0500 Subject: [PATCH 665/677] Worldpay: set name to 3D when 3DS attempted Unit: 41 tests, 231 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/worldpay.rb | 2 +- test/unit/gateways/worldpay_test.rb | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index d671c7424c1..b319d21db14 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ == HEAD * Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068 * QuickPay: update supported countries [ta] #3049 +* WorldPay: set cardholder name to "3D" for 3DS transactions [bpollack] #3071 == Version 1.88.0 (November 30, 2018) * Added ActiveSupport/Rails master support [Edouard-chin] #3065 diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index 936ef9295d6..aca906ae7f4 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -237,7 +237,7 @@ def add_payment_method(xml, amount, payment_method, options) xml.tag! 'date', 'month' => format(payment_method.month, :two_digits), 'year' => format(payment_method.year, :four_digits) end - xml.tag! 'cardHolderName', payment_method.name + xml.tag! 'cardHolderName', options[:execute_threed] ? '3D' : payment_method.name xml.tag! 'cvc', payment_method.verification_value add_address(xml, (options[:billing_address] || options[:address])) diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index a1881e04bbc..36e2ba8783d 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -506,6 +506,18 @@ def test_failed_verify assert_failure response end + def test_3ds_name_coersion + @options[:execute_threed] = true + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + if /<submit>/ =~ data + assert_match %r{<cardHolderName>3D</cardHolderName>}, data + end + end.respond_with(successful_authorize_response, successful_capture_response) + assert_success response + end + def test_transcript_scrubbing assert_equal scrubbed_transcript, @gateway.scrub(transcript) end From 2821fbdd5941af0880716aa43e23a18f3f26945e Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Mon, 26 Nov 2018 16:16:49 -0500 Subject: [PATCH 666/677] Authorize.Net: Support refunds for bank accounts Refunds for bank accounts require a different structure than credit cards. The routing number, account number and account type must also be passed in the request. Loaded suite test/unit/gateways/authorize_net_test ................................................................................................ 96 tests, 565 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/remote/gateways/remote_authorize_net_test ..................................................................... 69 tests, 238 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + .../billing/gateways/authorize_net.rb | 15 ++++++++++++--- test/unit/gateways/authorize_net_test.rb | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b319d21db14..5d0a7938c2a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068 * QuickPay: update supported countries [ta] #3049 * WorldPay: set cardholder name to "3D" for 3DS transactions [bpollack] #3071 +* Authorize.Net: Support refunds for bank accounts [nfarve] #3063 == Version 1.88.0 (November 30, 2018) * Added ActiveSupport/Rails master support [Edouard-chin] #3065 diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb index a0240cc25ed..ccc8794a05a 100644 --- a/lib/active_merchant/billing/gateways/authorize_net.rb +++ b/lib/active_merchant/billing/gateways/authorize_net.rb @@ -339,9 +339,18 @@ def normal_refund(amount, authorization, options) xml.transactionType('refundTransaction') xml.amount(amount.nil? ? 0 : amount(amount)) xml.payment do - xml.creditCard do - xml.cardNumber(card_number || options[:card_number]) - xml.expirationDate('XXXX') + if options[:routing_number] + xml.bankAccount do + xml.accountType(options[:account_type]) + xml.routingNumber(options[:routing_number]) + xml.accountNumber(options[:account_number]) + xml.nameOnAccount("#{options[:first_name]} #{options[:last_name]}") + end + else + xml.creditCard do + xml.cardNumber(card_number || options[:card_number]) + xml.expirationDate('XXXX') + end end end xml.refTransId(transaction_id) diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb index 813c26dfaaf..2cdfde5abcd 100644 --- a/test/unit/gateways/authorize_net_test.rb +++ b/test/unit/gateways/authorize_net_test.rb @@ -877,6 +877,20 @@ def test_successful_refund assert_equal '2214602071#2224#refund', refund.authorization end + def test_successful_bank_refund + response = stub_comms do + @gateway.refund(50, '12345667', account_type: 'checking', routing_number: '123450987', account_number: '12345667', first_name: 'Louise', last_name: 'Belcher') + end.check_request do |endpoint, data, headers| + parse(data) do |doc| + assert_equal 'checking', doc.at_xpath('//transactionRequest/payment/bankAccount/accountType').content + assert_equal '123450987', doc.at_xpath('//transactionRequest/payment/bankAccount/routingNumber').content + assert_equal '12345667', doc.at_xpath('//transactionRequest/payment/bankAccount/accountNumber').content + assert_equal 'Louise Belcher', doc.at_xpath('//transactionRequest/payment/bankAccount/nameOnAccount').content + end + end.respond_with(successful_refund_response) + assert_success response + end + def test_refund_passing_extra_info response = stub_comms do @gateway.refund(50, '123456789', card_number: @credit_card.number, first_name: 'Bob', last_name: 'Smith', zip: '12345', order_id: '1', description: 'Refund for order 1') From e7aad1c72559aaef84634d7b8a43b2a8264442ed Mon Sep 17 00:00:00 2001 From: Joe Jackson <cpmhjoe@gmail.com> Date: Tue, 4 Dec 2018 11:11:20 -0500 Subject: [PATCH 667/677] Orbital: coerce merchant_id to string Orbital merchant IDs were historically strings, but can now also be integers. To avoid any excitement, coerce them to strings before use. Unit: 70 tests, 422 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 23 tests, 144 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #3072 --- lib/active_merchant/billing/gateways/orbital.rb | 1 + test/unit/gateways/orbital_test.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb index f85b73cd35a..2514617b6da 100644 --- a/lib/active_merchant/billing/gateways/orbital.rb +++ b/lib/active_merchant/billing/gateways/orbital.rb @@ -187,6 +187,7 @@ def initialize(options = {}) requires!(options, :merchant_id) requires!(options, :login, :password) unless options[:ip_authentication] super + @options[:merchant_id] = @options[:merchant_id].to_s end # A – Authorization request diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb index 2d3e8d8f3f3..6b913222dcd 100644 --- a/test/unit/gateways/orbital_test.rb +++ b/test/unit/gateways/orbital_test.rb @@ -153,6 +153,21 @@ def test_order_id_format_for_capture assert_success response end + def test_numeric_merchant_id_for_caputre + gateway = ActiveMerchant::Billing::OrbitalGateway.new( + :login => 'login', + :password => 'password', + :merchant_id => 700000123456 + ) + + response = stub_comms(gateway) do + gateway.capture(101, '4A5398CF9B87744GG84A1D30F2F2321C66249416;1', @options) + end.check_request do |endpoint, data, headers| + assert_match(/<MerchantID>700000123456<\/MerchantID>/, data) + end.respond_with(successful_purchase_response) + assert_success response + end + def test_expiry_date year = (DateTime.now + 1.year).strftime('%y') assert_equal "09#{year}", @gateway.send(:expiry_date, credit_card) From fdc5468704cb9c0c951a3b9657b7a99d61699524 Mon Sep 17 00:00:00 2001 From: Yosuke Hasumi <info@yosuke.ca> Date: Tue, 20 Nov 2018 11:45:12 -0800 Subject: [PATCH 668/677] Stripe: allow specifying a reason for refunds Unit: 130 tests, 698 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 67 tests, 313 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes #3057 --- CHANGELOG | 3 ++- lib/active_merchant/billing/gateways/stripe.rb | 1 + test/remote/gateways/remote_stripe_test.rb | 13 +++++++++++++ test/unit/gateways/stripe_test.rb | 9 +++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 5d0a7938c2a..2f29b7dd084 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,7 +4,8 @@ * Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068 * QuickPay: update supported countries [ta] #3049 * WorldPay: set cardholder name to "3D" for 3DS transactions [bpollack] #3071 -* Authorize.Net: Support refunds for bank accounts [nfarve] #3063 +* Authorize.Net: Support refunds for bank accounts [nfarve] #3063 +* Stripe: support specifying a reason for refunds [yosukehasumi] #3056 == Version 1.88.0 (November 30, 2018) * Added ActiveSupport/Rails master support [Edouard-chin] #3065 diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb index 1650c1baf43..4e107af5eaf 100644 --- a/lib/active_merchant/billing/gateways/stripe.rb +++ b/lib/active_merchant/billing/gateways/stripe.rb @@ -147,6 +147,7 @@ def refund(money, identification, options = {}) post[:refund_application_fee] = true if options[:refund_application_fee] post[:reverse_transfer] = options[:reverse_transfer] if options[:reverse_transfer] post[:metadata] = options[:metadata] if options[:metadata] + post[:reason] = options[:reason] if options[:reason] post[:expand] = [:charge] MultiResponse.run(:first) do |r| diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb index 6be3a6dd4e6..04a5b144138 100644 --- a/test/remote/gateways/remote_stripe_test.rb +++ b/test/remote/gateways/remote_stripe_test.rb @@ -254,6 +254,19 @@ def test_successful_refund assert_success refund end + def test_successful_refund_with_reason + assert response = @gateway.purchase(@amount, @credit_card, @options) + assert_success response + assert response.authorization + + assert refund = @gateway.refund(@amount - 20, response.authorization, reason: 'fraudulent') + assert refund.test? + refund_id = refund.params['id'] + assert_equal refund.authorization, refund_id + assert_success refund + assert_equal 'fraudulent', refund.params['reason'] + end + def test_successful_refund_on_verified_bank_account customer_id = @verified_bank_account[:customer_id] bank_account_id = @verified_bank_account[:bank_account_id] diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb index 34b53e17927..aa68953ee16 100644 --- a/test/unit/gateways/stripe_test.rb +++ b/test/unit/gateways/stripe_test.rb @@ -596,6 +596,15 @@ def test_successful_refund assert_equal 're_test_refund', response.authorization end + def test_successful_refund_with_reason + @gateway.expects(:ssl_request).returns(successful_partially_refunded_response) + + assert response = @gateway.refund(@refund_amount, 'ch_test_charge', reason: 'fraudulent') + assert_success response + + assert_equal 're_test_refund', response.authorization + end + def test_unsuccessful_refund @gateway.expects(:ssl_request).returns(generic_error_response) From ab8c6181dbad9c8ce9bb4ae9bd3643fcad170254 Mon Sep 17 00:00:00 2001 From: Adam <adam@steadlane.com.au> Date: Mon, 23 Jul 2018 14:39:01 +1000 Subject: [PATCH 669/677] Paybox Direct: add support for XPF currency Closes #2938 --- lib/active_merchant/billing/gateways/paybox_direct.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/paybox_direct.rb b/lib/active_merchant/billing/gateways/paybox_direct.rb index e99d787f210..de236330928 100644 --- a/lib/active_merchant/billing/gateways/paybox_direct.rb +++ b/lib/active_merchant/billing/gateways/paybox_direct.rb @@ -34,7 +34,8 @@ class PayboxDirectGateway < Gateway 'CHF'=> '756', 'GBP'=> '826', 'USD'=> '840', - 'EUR'=> '978' + 'EUR'=> '978', + 'XPF'=> '953' } SUCCESS_CODES = ['00000'] From 9968bb6e44901aa4d9fa339b9db8d41a509a255f Mon Sep 17 00:00:00 2001 From: Niaja <niaja@spreedly.com> Date: Wed, 5 Dec 2018 10:17:50 -0500 Subject: [PATCH 670/677] TrustCommerce: Add ACH Ability TrustCommerce supports ach transactions for purchase and credit. This also adds the `aggregator_id` which will become mandatory. Loaded suite test/remote/gateways/remote_trust_commerce_test ....... 15 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Loaded suite test/unit/gateways/trust_commerce_test ......... 9 tests, 22 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 3 ++- .../billing/gateways/trust_commerce.rb | 21 +++++++++++++++++++ test/fixtures.yml | 1 + .../gateways/remote_trust_commerce_test.rb | 18 ++++++++++++++++ test/unit/gateways/trust_commerce_test.rb | 13 +++++++++++- 5 files changed, 54 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2f29b7dd084..5f5a84ad51d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * WorldPay: set cardholder name to "3D" for 3DS transactions [bpollack] #3071 * Authorize.Net: Support refunds for bank accounts [nfarve] #3063 * Stripe: support specifying a reason for refunds [yosukehasumi] #3056 +* TrustCommerce: Add ACH Ability [nfarve] #3073 == Version 1.88.0 (November 30, 2018) * Added ActiveSupport/Rails master support [Edouard-chin] #3065 @@ -31,7 +32,7 @@ * CyberSource: update supported countries [bpollack] #3055 * MiGS: update supported countries [bpollack] #3055 * Clearhaus: update submission data format [bpollack] #3053 -* Forte: Allow void on capture #3059 +* Forte: Allow void on capture [nfarve] #3059 == Version 1.86.0 (October 26, 2018) * UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002 diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb index c10819e6eed..d97cfa0c273 100644 --- a/lib/active_merchant/billing/gateways/trust_commerce.rb +++ b/lib/active_merchant/billing/gateways/trust_commerce.rb @@ -153,6 +153,7 @@ def authorize(money, creditcard_or_billing_id, options = {}) } add_order_id(parameters, options) + add_aggregator(parameters, options) add_customer_data(parameters, options) add_payment_source(parameters, creditcard_or_billing_id) add_addresses(parameters, options) @@ -167,6 +168,7 @@ def purchase(money, creditcard_or_billing_id, options = {}) } add_order_id(parameters, options) + add_aggregator(parameters, options) add_customer_data(parameters, options) add_payment_source(parameters, creditcard_or_billing_id) add_addresses(parameters, options) @@ -181,6 +183,7 @@ def capture(money, authorization, options = {}) :amount => amount(money), :transid => authorization, } + add_aggregator(parameters, options) commit('postauth', parameters) end @@ -192,6 +195,7 @@ def refund(money, identification, options = {}) :amount => amount(money), :transid => identification } + add_aggregator(parameters, options) commit('credit', parameters) end @@ -219,6 +223,7 @@ def void(authorization, options = {}) parameters = { :transid => authorization, } + add_aggregator(parameters, options) commit('reversal', parameters) end @@ -305,14 +310,30 @@ def scrub(transcript) private + def add_aggregator(params, options) + if @options[:aggregator_id] + params[:aggregators] = 1 + params[:aggregator1] = @options[:aggregator_id] + end + end + def add_payment_source(params, source) if source.is_a?(String) add_billing_id(params, source) + elsif card_brand(source) == 'check' + add_check(params, source) else add_creditcard(params, source) end end + def add_check(params, check) + params[:media] = 'ach' + params[:routing] = check.routing_number + params[:account] = check.account_number + params[:savings] = 'y' if check.account_type == 'savings' + end + def add_creditcard(params, creditcard) params[:media] = 'cc' params[:name] = creditcard.name diff --git a/test/fixtures.yml b/test/fixtures.yml index f1de6db6807..be2d8930f18 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -1183,6 +1183,7 @@ trexle: trust_commerce: login: 'TestMerchant' password: 'password' + aggregator_id: 'abc123' # Working credentials, no need to replace usa_epay: diff --git a/test/remote/gateways/remote_trust_commerce_test.rb b/test/remote/gateways/remote_trust_commerce_test.rb index 576fde7292a..196ffe26c7f 100644 --- a/test/remote/gateways/remote_trust_commerce_test.rb +++ b/test/remote/gateways/remote_trust_commerce_test.rb @@ -5,6 +5,7 @@ def setup @gateway = TrustCommerceGateway.new(fixtures(:trust_commerce)) @credit_card = credit_card('4111111111111111') + @check = check({account_number: 55544433221, routing_number: 789456124}) @amount = 100 @@ -59,6 +60,14 @@ def test_successful_purchase_with_avs assert !response.authorization.blank? end + def test_successful_purchase_with_check + assert response = @gateway.purchase(@amount, @check, @options) + assert_match %r{The transaction was successful}, response.message + + assert_success response + assert !response.authorization.blank? + end + def test_unsuccessful_purchase_with_invalid_cvv @credit_card.verification_value = @invalid_verification_value assert response = @gateway.purchase(@amount, @credit_card, @options) @@ -128,6 +137,15 @@ def test_successful_credit assert_success response end + def test_successful_check_refund + purchase = @gateway.purchase(@amount, @check, @options) + + assert response = @gateway.refund(@amount, purchase.authorization) + + assert_match %r{The transaction was successful}, response.message + assert_success response + end + def test_store_failure assert response = @gateway.store(@credit_card) diff --git a/test/unit/gateways/trust_commerce_test.rb b/test/unit/gateways/trust_commerce_test.rb index 08feafb188b..4fedfb09b07 100644 --- a/test/unit/gateways/trust_commerce_test.rb +++ b/test/unit/gateways/trust_commerce_test.rb @@ -1,15 +1,18 @@ require 'test_helper' class TrustCommerceTest < Test::Unit::TestCase + include CommStub def setup @gateway = TrustCommerceGateway.new( :login => 'TestMerchant', - :password => 'password' + :password => 'password', + :aggregator_id => 'abc123' ) # Force SSL post @gateway.stubs(:tclink?).returns(false) @amount = 100 + @check = check @credit_card = credit_card('4111111111111111') end @@ -28,6 +31,14 @@ def test_unsuccessful_purchase assert_failure response end + def test_succesful_purchase_with_check + stub_comms do + @gateway.purchase(@amount, @check) + end.check_request do |endpoint, data, headers| + assert_match(%r{aggregator1}, data) + end.respond_with(successful_purchase_response) + end + def test_amount_style assert_equal '1034', @gateway.send(:amount, 1034) From 630edd91c87e649f6edd34dd8cbb0092aff70829 Mon Sep 17 00:00:00 2001 From: molbrown <molly@spreedly.com> Date: Wed, 5 Dec 2018 10:31:24 -0500 Subject: [PATCH 671/677] Payeezy: Support $0 for verify transactions Payeezy allows $0 authorization. Updating from $1 verify to $0 to resolve failures for customer. ENE-59 Closes #3074 Unit Tests: 33 tests, 156 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote Tests: 33 tests, 131 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/payeezy.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 5f5a84ad51d..05c5e5ec02b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * Authorize.Net: Support refunds for bank accounts [nfarve] #3063 * Stripe: support specifying a reason for refunds [yosukehasumi] #3056 * TrustCommerce: Add ACH Ability [nfarve] #3073 +* Payeezy: Support $0 for verify transactions [molbrown] #3074 == Version 1.88.0 (November 30, 2018) * Added ActiveSupport/Rails master support [Edouard-chin] #3065 diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb index 6342bce30d8..cb2e4ff4c13 100644 --- a/lib/active_merchant/billing/gateways/payeezy.rb +++ b/lib/active_merchant/billing/gateways/payeezy.rb @@ -94,7 +94,7 @@ def void(authorization, options = {}) def verify(credit_card, options={}) MultiResponse.run(:use_first_response) do |r| - r.process { authorize(100, credit_card, options) } + r.process { authorize(0, credit_card, options) } r.process(:ignore_result) { void(r.authorization, options) } end end From 5c5931c1732bb62afe3a1781c3af19c6e6d511ca Mon Sep 17 00:00:00 2001 From: Lancelot Carlson <lcarlson@healpay.com> Date: Thu, 29 Nov 2018 22:29:56 -0500 Subject: [PATCH 672/677] USA ePay: add bank account type --- lib/active_merchant/billing/gateways/usa_epay_transaction.rb | 1 + test/remote/gateways/remote_usa_epay_transaction_test.rb | 2 +- test/unit/gateways/usa_epay_transaction_test.rb | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb index 55d6b439956..7e2f7ae0596 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb @@ -198,6 +198,7 @@ def add_invoice(post, options) def add_payment(post, payment, options={}) if payment.respond_to?(:routing_number) post[:checkformat] = options[:check_format] if options[:check_format] + post[:accounttype] = options[:account_type] if options[:account_type] post[:account] = payment.account_number post[:routing] = payment.routing_number post[:name] = payment.name unless payment.name.blank? diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb index e4b6cf3f593..a4854c02a37 100644 --- a/test/remote/gateways/remote_usa_epay_transaction_test.rb +++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb @@ -30,7 +30,7 @@ def test_successful_purchase_with_echeck end def test_successful_purchase_with_echeck_and_extra_options - extra_options = @options.merge(check_format: 'ARC') + extra_options = @options.merge(check_format: 'ARC', account_type: 'savings') assert response = @gateway.purchase(@amount, @check, extra_options) assert_equal 'Success', response.message assert_success response diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb index 5318db9c1f9..a9d3f79f939 100644 --- a/test/unit/gateways/usa_epay_transaction_test.rb +++ b/test/unit/gateways/usa_epay_transaction_test.rb @@ -55,9 +55,10 @@ def test_successful_request_with_echeck def test_successful_purchase_with_echeck_and_extra_options response = stub_comms do - @gateway.purchase(@amount, @check, @options.merge(check_format: 'ARC')) + @gateway.purchase(@amount, @check, @options.merge(check_format: 'ARC', account_type: 'savings')) end.check_request do |endpoint, data, headers| assert_match(/UMcheckformat=ARC/, data) + assert_match(/UMaccounttype=savings/, data) end.respond_with(successful_purchase_response_echeck) assert_equal 'Success', response.message From 0b76358f219bd71cb699d425d5bf6e10e7da60e4 Mon Sep 17 00:00:00 2001 From: Lancelot Carlson <lcarlson@healpay.com> Date: Thu, 29 Nov 2018 23:41:02 -0500 Subject: [PATCH 673/677] USA ePay: support custom fields and line items --- .../billing/gateways/usa_epay_transaction.rb | 31 +++++++++++++++ .../gateways/usa_epay_transaction_test.rb | 38 +++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb index 7e2f7ae0596..119de3898e7 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb @@ -54,6 +54,8 @@ def authorize(money, credit_card, options = {}) add_customer_data(post, options) end add_split_payments(post, options) + add_custom_fields(post, options) + add_line_items(post, options) add_test_mode(post, options) commit(:authorization, post) @@ -70,6 +72,8 @@ def purchase(money, payment, options = {}) add_customer_data(post, options) end add_split_payments(post, options) + add_custom_fields(post, options) + add_line_items(post, options) add_test_mode(post, options) payment.respond_to?(:routing_number) ? commit(:check_purchase, post) : commit(:purchase, post) @@ -232,6 +236,33 @@ def add_split_payments(post, options) post['onError'] = options[:on_error] || 'Void' end + # see: https://wiki.usaepay.com/developer/transactionapi#merchant_defined_custom_fields + def add_custom_fields(post, options) + return unless options[:custom_fields].is_a?(Hash) + options[:custom_fields].each do |index, custom| + post["custom#{index}"] = custom + end + end + + # see: https://wiki.usaepay.com/developer/transactionapi#line_item_details + def add_line_items(post, options) + return unless options[:line_items].is_a?(Array) + options[:line_items].each_with_index do |line_item, index| + %w(product_ref_num sku name description taxable tax_rate tax_amount commodity_code discount_rate discount_amount).each do |key| + post["line#{index}#{key.delete('_')}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym) + end + + { + quantity: 'qty', + unit: 'um', + }.each do |key, umkey| + post["line#{index}#{umkey}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym) + end + + post["line#{index}cost"] = amount(line_item[:cost]) + end + end + def parse(body) fields = {} for line in body.split('&') diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb index a9d3f79f939..700bea6fa77 100644 --- a/test/unit/gateways/usa_epay_transaction_test.rb +++ b/test/unit/gateways/usa_epay_transaction_test.rb @@ -143,6 +143,44 @@ def test_successful_purchase_split_payment_with_custom_on_error assert_success response end + def test_successful_purchase_custom_fields + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge( + :custom_fields => { + 1 => 'diablo', + 2 => 'mephisto', + 3 => 'baal' + } + )) + end.check_request do |endpoint, data, headers| + assert_match %r{UMcustom1=diablo}, data + assert_match %r{UMcustom2=mephisto}, data + assert_match %r{UMcustom3=baal}, data + end.respond_with(successful_purchase_response) + assert_success response + end + + def test_successful_purchase_line_items + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge( + :line_items => [ + { :sku=> 'abc123', :cost => 119, :quantity => 1 }, + { :sku => 'def456', :cost => 200, :quantity => 2, :name => 'an item' }, + ] + )) + end.check_request do |endpoint, data, headers| + assert_match %r{UMline0sku=abc123}, data + assert_match %r{UMline0cost=1.19}, data + assert_match %r{UMline0qty=1}, data + + assert_match %r{UMline1sku=def456}, data + assert_match %r{UMline1cost=2.00}, data + assert_match %r{UMline1qty=2}, data + assert_match %r{UMline1name=an\+item}, data + end.respond_with(successful_purchase_response) + assert_success response + end + def test_successful_authorize_request @gateway.expects(:ssl_post).returns(successful_authorize_response) From 7585caf787931f05166781f1ebc5c7ed139f825a Mon Sep 17 00:00:00 2001 From: Lancelot Carlson <lcarlson@healpay.com> Date: Fri, 30 Nov 2018 00:16:49 -0500 Subject: [PATCH 674/677] USA ePay: add support for recurring payments --- .../billing/gateways/usa_epay_transaction.rb | 19 ++++++++++++++ .../gateways/usa_epay_transaction_test.rb | 25 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb index 119de3898e7..fb0b277a164 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb @@ -54,6 +54,7 @@ def authorize(money, credit_card, options = {}) add_customer_data(post, options) end add_split_payments(post, options) + add_recurring_fields(post, options) add_custom_fields(post, options) add_line_items(post, options) add_test_mode(post, options) @@ -72,6 +73,7 @@ def purchase(money, payment, options = {}) add_customer_data(post, options) end add_split_payments(post, options) + add_recurring_fields(post, options) add_custom_fields(post, options) add_line_items(post, options) add_test_mode(post, options) @@ -236,6 +238,23 @@ def add_split_payments(post, options) post['onError'] = options[:on_error] || 'Void' end + def add_recurring_fields(post, options) + return unless options[:recurring_fields].is_a?(Hash) + options[:recurring_fields].each do |key, value| + if value == true + value = 'yes' + elsif value == false + next + end + + if key == :bill_amount + value = amount(value) + end + + post[key.to_s.delete('_')] = value + end + end + # see: https://wiki.usaepay.com/developer/transactionapi#merchant_defined_custom_fields def add_custom_fields(post, options) return unless options[:custom_fields].is_a?(Hash) diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb index 700bea6fa77..260195409da 100644 --- a/test/unit/gateways/usa_epay_transaction_test.rb +++ b/test/unit/gateways/usa_epay_transaction_test.rb @@ -143,6 +143,31 @@ def test_successful_purchase_split_payment_with_custom_on_error assert_success response end + def test_successful_purchase_recurring_fields + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge( + :recurring_fields => { + add_customer: true, + schedule: 'quarterly', + bill_source_key: 'bill source key', + bill_amount: 123, + num_left: 5, + start: '20501212', + recurring_receipt: true + } + )) + end.check_request do |endpoint, data, headers| + assert_match %r{UMaddcustomer=yes}, data + assert_match %r{UMschedule=quarterly}, data + assert_match %r{UMbillsourcekey=bill\+source\+key}, data + assert_match %r{UMbillamount=1.23}, data + assert_match %r{UMnumleft=5}, data + assert_match %r{UMstart=20501212}, data + assert_match %r{UMrecurringreceipt=yes}, data + end.respond_with(successful_purchase_response) + assert_success response + end + def test_successful_purchase_custom_fields response = stub_comms do @gateway.purchase(@amount, @credit_card, @options.merge( From 25af741645653cc9cd6dd74a845907f618ab7dc0 Mon Sep 17 00:00:00 2001 From: Lance Carlson <lancecarlson@gmail.com> Date: Tue, 4 Dec 2018 20:22:49 -0500 Subject: [PATCH 675/677] USA ePay: add remote tests for recurring, line items and custom fields Closes #3069 --- CHANGELOG | 1 + .../remote_usa_epay_transaction_test.rb | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 05c5e5ec02b..1e421bcda0c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * Stripe: support specifying a reason for refunds [yosukehasumi] #3056 * TrustCommerce: Add ACH Ability [nfarve] #3073 * Payeezy: Support $0 for verify transactions [molbrown] #3074 +* USA ePay: add support for recurring transactions, custom fields, and line items [lancecarlson] #3069 == Version 1.88.0 (November 30, 2018) * Added ActiveSupport/Rails master support [Edouard-chin] #3065 diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb index a4854c02a37..52c24f212c9 100644 --- a/test/remote/gateways/remote_usa_epay_transaction_test.rb +++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb @@ -68,6 +68,46 @@ def test_successful_purchase_with_email_receipt assert_success response end + def test_successful_purchase_with_recurring_fields + recurring_fields = [ + add_customer: true, + schedule: 'quarterly', + bill_source_key: 'bill source key', + bill_amount: 123, + num_left: 5, + start: '20501212', + recurring_receipt: true + ] + + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(recurring_fields: recurring_fields)) + assert_equal 'Success', response.message + assert_success response + end + + def test_successful_purchase_with_custom_fields + custom_fields = { + 1 => 'multi', + 2 => 'pass', + 3 => 'korben', + 4 => 'dallas' + } + + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(custom_fields: custom_fields)) + assert_equal 'Success', response.message + assert_success response + end + + def test_successful_purchase_with_line_items + line_items = [ + {sku: 'abc123', cost: 119, quantity: 1}, + {sku: 'def456', cost: 200, quantity: 2, name: 'an item' } + ] + + assert response = @gateway.purchase(@amount, @credit_card, @options.merge(line_items: line_items)) + assert_equal 'Success', response.message + assert_success response + end + def test_unsuccessful_purchase # For some reason this will fail with "You have tried this card too # many times, please contact merchant" unless a unique order id is From b7974e288a0ce4c00e5028c47b2fd3fa47032a2f Mon Sep 17 00:00:00 2001 From: molbrown <molly@spreedly.com> Date: Thu, 6 Dec 2018 14:29:08 -0500 Subject: [PATCH 676/677] TrustCommerce: Scrubs password from transcript ENE-64 Unit: 10 tests, 34 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 16 tests, 56 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 68.75% passed - Failures existing on earlier commits, not related to change made in this commit. --- lib/active_merchant/billing/gateways/trust_commerce.rb | 1 + test/unit/gateways/trust_commerce_test.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb index d97cfa0c273..40466fcc006 100644 --- a/lib/active_merchant/billing/gateways/trust_commerce.rb +++ b/lib/active_merchant/billing/gateways/trust_commerce.rb @@ -305,6 +305,7 @@ def scrub(transcript) transcript. gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). gsub(%r((&?cc=)\d*(&?)), '\1[FILTERED]\2'). + gsub(%r((&?password=)[^&]+(&?)), '\1[FILTERED]\2'). gsub(%r((&?cvv=)\d*(&?)), '\1[FILTERED]\2') end diff --git a/test/unit/gateways/trust_commerce_test.rb b/test/unit/gateways/trust_commerce_test.rb index 4fedfb09b07..e94146db360 100644 --- a/test/unit/gateways/trust_commerce_test.rb +++ b/test/unit/gateways/trust_commerce_test.rb @@ -111,7 +111,7 @@ def transcript def scrubbed_transcript <<-TRANSCRIPT -action=sale&demo=y&password=password&custid=TestMerchant&shipto_zip=90001&shipto_state=CA&shipto_city=Somewhere&shipto_address1=123+Test+St.&avs=n&zip=90001&state=CA&city=Somewhere&address1=123+Test+St.&cvv=[FILTERED]&exp=0916&cc=[FILTERED]&name=Longbob+Longsen&media=cc&ip=10.10.10.10&email=cody%40example.com&ticket=%231000.1&amount=100 +action=sale&demo=y&password=[FILTERED]&custid=TestMerchant&shipto_zip=90001&shipto_state=CA&shipto_city=Somewhere&shipto_address1=123+Test+St.&avs=n&zip=90001&state=CA&city=Somewhere&address1=123+Test+St.&cvv=[FILTERED]&exp=0916&cc=[FILTERED]&name=Longbob+Longsen&media=cc&ip=10.10.10.10&email=cody%40example.com&ticket=%231000.1&amount=100 TRANSCRIPT end end From 6253c2171e377d109f6b456b53166a3b386ae9a0 Mon Sep 17 00:00:00 2001 From: Ronnie Taylor <ronnie.taylor@veracross.com> Date: Thu, 6 Dec 2018 22:57:08 -0800 Subject: [PATCH 677/677] Adding support for Check to have a vaulted account id. Port changes from pr 18 commit 954d94a81d21993fbcebd7b5852a2cad3bbcaf6d --- lib/active_merchant/billing/check.rb | 3 ++- .../billing/gateways/blue_snap.rb | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/active_merchant/billing/check.rb b/lib/active_merchant/billing/check.rb index 6dcba4b0267..3c26abb8a0c 100644 --- a/lib/active_merchant/billing/check.rb +++ b/lib/active_merchant/billing/check.rb @@ -8,7 +8,8 @@ module Billing #:nodoc: class Check < Model attr_accessor :first_name, :last_name, :bank_name, :routing_number, :account_number, - :account_holder_type, :account_type, :number + :account_holder_type, :account_type, :number, + :remote_account_id # Used for Canadian bank accounts attr_accessor :institution_number, :transit_number diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb index abd6b2eedcc..a9098385466 100644 --- a/lib/active_merchant/billing/gateways/blue_snap.rb +++ b/lib/active_merchant/billing/gateways/blue_snap.rb @@ -167,6 +167,17 @@ def add_payer_info(doc, payment_method, options) add_ach_info(doc, payment_method) end + def add_payer_info(doc, payment_method, options) + if payment_method.remote_account_id + add_vaulted_ach_info(doc, payment_method) + else + doc.send("payer-info") do + add_personal_info(doc, payment_method, options) + end + add_ach_info(doc, payment_method) + end + end + def add_card_holder_info(doc, payment_method, options) doc.send("card-holder-info") do add_personal_info(doc, payment_method, options) @@ -213,7 +224,12 @@ def add_ach_info(doc, check) doc.send("routing-number", check.routing_number) add_account_type(doc, check) end - # TODO: Be sure to add form field for this and pull the value from it. + doc.send("authorized-by-shopper", "true") + end + + def add_vaulted_ach_info(doc, check) + doc.send("ecp-transaction") + doc.send("vaulted-shopper-id", check.remote_account_id) doc.send("authorized-by-shopper", "true") end